2 * Routines for X.29 packet dissection
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include <epan/packet.h>
14 #include <epan/nlpid.h>
16 void proto_register_x29(void);
17 void proto_reg_handoff_x29(void);
19 static dissector_handle_t x29_handle
;
22 static int hf_msg_code
;
23 static int hf_error_type
;
24 static int hf_inv_msg_code
;
26 /* Generated from convert_proto_tree_add_text.pl */
27 static int hf_x29_pad_message_data
;
28 static int hf_x29_type_reference_value
;
29 static int hf_x29_type_reference
;
30 static int hf_x29_data
;
31 static int hf_x29_type_of_aspect
;
32 static int hf_x29_reselection_message_data
;
33 static int hf_x29_break_value
;
34 static int hf_x29_parameter
;
35 static int hf_x29_value
;
44 #define SET_AND_READ_MSG 0x06
45 #define PARAMETER_IND_MSG 0x00
46 #define INV_TO_CLEAR_MSG 0x01
47 #define BREAK_IND_MSG 0x03
48 #define RESELECTION_MSG 0x07
49 #define ERROR_MSG 0x05
50 #define RESEL_WITH_TOA_NPI_MSG 0x08
52 static const value_string message_code_vals
[] = {
55 { SET_AND_READ_MSG
, "Set and read" },
56 { PARAMETER_IND_MSG
, "Parameter indication" },
57 { INV_TO_CLEAR_MSG
, "Invitation to clear" },
58 { BREAK_IND_MSG
, "Indication of break" },
59 { RESELECTION_MSG
, "Reselection" },
60 { ERROR_MSG
, "Error" },
61 { RESEL_WITH_TOA_NPI_MSG
, "Reselection with TOA/NPI" },
65 static const value_string error_type_vals
[] = {
66 { 0x00, "Received PAD message contained less than eight bits" },
67 { 0x02, "Unrecognized message code in received PAD message" },
68 { 0x04, "Parameter field format was incorrect or incompatible with message code" },
69 { 0x06, "Received PAD message did not contain an integral number of octets" },
70 { 0x08, "Received Parameter Indication PAD message was unsolicited" },
71 { 0x0A, "Received PAD message was too long" },
72 { 0x0C, "Unauthorized reselection PAD message" },
76 static const value_string reference_type_vals
[] = {
77 { 0x01, "Change in PAD Aspect" },
83 dissect_x29(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
95 /* Reject the packet if data is NULL */
98 q_bit_set
= (bool *)data
;
100 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "X.29");
101 col_clear(pinfo
->cinfo
, COL_INFO
);
103 ti
= proto_tree_add_item(tree
, proto_x29
, tvb
, offset
, -1, ENC_NA
);
104 x29_tree
= proto_item_add_subtree(ti
, ett_x29
);
108 * Q bit set - this is a PAD message.
110 msg_code
= tvb_get_uint8(tvb
, offset
);
111 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s PAD message",
112 val_to_str(msg_code
, message_code_vals
,
113 "Unknown (0x%02x)"));
115 proto_tree_add_uint(x29_tree
, hf_msg_code
, tvb
,
116 offset
, 1, msg_code
);
123 case SET_AND_READ_MSG
:
124 case PARAMETER_IND_MSG
:
126 * XXX - dissect the references as per X.3.
128 while (tvb_reported_length_remaining(tvb
, offset
) > 0) {
129 proto_tree_add_item(x29_tree
, hf_x29_parameter
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
131 proto_tree_add_item(x29_tree
, hf_x29_value
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
136 case INV_TO_CLEAR_MSG
:
138 * No data for this message.
143 error_type
= tvb_get_uint8(tvb
, offset
);
144 proto_tree_add_uint(x29_tree
, hf_error_type
, tvb
,
145 offset
, 1, error_type
);
147 if (error_type
!= 0) {
148 proto_tree_add_item(x29_tree
, hf_inv_msg_code
,
149 tvb
, offset
, 1, ENC_BIG_ENDIAN
);
154 if (tvb_reported_length_remaining(tvb
, offset
) > 0) {
155 type_ref
= tvb_get_uint8(tvb
, offset
);
156 proto_tree_add_item(x29_tree
, hf_x29_type_reference
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
160 case 0x01: /* change in PAD Aspect */
162 * XXX - dissect as per X.28.
164 proto_tree_add_item(x29_tree
, hf_x29_type_of_aspect
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
168 case 0x08: /* break */
169 proto_tree_add_item(x29_tree
, hf_x29_break_value
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
174 proto_tree_add_item(x29_tree
, hf_x29_type_reference_value
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
181 case RESELECTION_MSG
:
185 proto_tree_add_item(x29_tree
, hf_x29_reselection_message_data
, tvb
, offset
, -1, ENC_NA
);
188 case RESEL_WITH_TOA_NPI_MSG
:
192 proto_tree_add_item(x29_tree
, hf_x29_reselection_message_data
, tvb
, offset
, -1, ENC_NA
);
196 proto_tree_add_item(x29_tree
, hf_x29_pad_message_data
, tvb
, offset
, -1, ENC_NA
);
201 * Q bit not set - this is data.
203 col_set_str(pinfo
->cinfo
, COL_INFO
, "Data ...");
206 while (tvb_offset_exists(tvb
, offset
)) {
208 * Find the end of the line.
210 tvb_find_line_end(tvb
, offset
, -1,
211 &next_offset
, false);
214 * Now compute the length of the line
215 * *including* the end-of-line indication,
216 * if any; we display it all.
218 linelen
= next_offset
- offset
;
220 proto_tree_add_item(x29_tree
, hf_x29_data
, tvb
, offset
, linelen
, ENC_NA
|ENC_ASCII
);
221 offset
= next_offset
;
226 return tvb_captured_length(tvb
);
230 proto_register_x29(void)
232 static hf_register_info hf
[] = {
234 { "Message code", "x29.msg_code", FT_UINT8
, BASE_HEX
,
235 VALS(message_code_vals
), 0x0, "X.29 PAD message code",
238 { "Error type", "x29.error_type", FT_UINT8
, BASE_HEX
,
239 VALS(error_type_vals
), 0x0, "X.29 error PAD message error type",
242 { "Invalid message code", "x29.inv_msg_code", FT_UINT8
, BASE_HEX
,
243 VALS(message_code_vals
), 0x0, "X.29 Error PAD message invalid message code",
246 /* Generated from convert_proto_tree_add_text.pl */
247 { &hf_x29_type_reference
, { "Type reference", "x29.type_reference", FT_UINT8
, BASE_DEC
, VALS(reference_type_vals
), 0x0, NULL
, HFILL
}},
248 { &hf_x29_type_of_aspect
, { "Type of aspect", "x29.type_of_aspect", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
249 { &hf_x29_break_value
, { "Break value", "x29.break_value", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
250 { &hf_x29_type_reference_value
, { "Type value", "x29.type_reference.value", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
251 { &hf_x29_reselection_message_data
, { "Reselection message data", "x29.reselection_message_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
252 { &hf_x29_pad_message_data
, { "PAD message data", "x29.pad_message_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
253 { &hf_x29_data
, { "Data", "x29.data", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
254 { &hf_x29_parameter
, { "Parameter", "x29.parameter", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
255 { &hf_x29_value
, { "Value", "x29.value", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
257 static int *ett
[] = {
261 proto_x29
= proto_register_protocol("X.29", "X.29", "x29");
262 x29_handle
= register_dissector("x29", dissect_x29
, proto_x29
);
263 proto_register_field_array(proto_x29
, hf
, array_length(hf
));
264 proto_register_subtree_array(ett
, array_length(ett
));
268 proto_reg_handoff_x29(void)
270 dissector_add_uint("x.25.spi", NLPID_SPI_X_29
, x29_handle
);
274 * Editor modelines - https://www.wireshark.org/tools/modelines.html
279 * indent-tabs-mode: t
282 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
283 * :indentSize=8:tabSize=8:noTabs=false: