2 * Routines for X.29 packet dissection
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/packet.h>
34 #include <epan/strutil.h>
35 #include <epan/nlpid.h>
37 static int proto_x29 = -1;
38 static int hf_msg_code = -1;
39 static int hf_error_type = -1;
40 static int hf_inv_msg_code = -1;
42 static gint ett_x29 = -1;
49 #define SET_AND_READ_MSG 0x06
50 #define PARAMETER_IND_MSG 0x00
51 #define INV_TO_CLEAR_MSG 0x01
52 #define BREAK_IND_MSG 0x03
53 #define RESELECTION_MSG 0x07
54 #define ERROR_MSG 0x05
55 #define RESEL_WITH_TOA_NPI_MSG 0x08
57 static const value_string message_code_vals[] = {
60 { SET_AND_READ_MSG, "Set and read" },
61 { PARAMETER_IND_MSG, "Parameter indication" },
62 { INV_TO_CLEAR_MSG, "Invitation to clear" },
63 { BREAK_IND_MSG, "Indication of break" },
64 { RESELECTION_MSG, "Reselection" },
65 { ERROR_MSG, "Error" },
66 { RESEL_WITH_TOA_NPI_MSG, "Reselection with TOA/NPI" },
70 static const value_string error_type_vals[] = {
71 { 0x00, "Received PAD message contained less than eight bits" },
72 { 0x02, "Unrecognized message code in received PAD message" },
73 { 0x04, "Parameter field format was incorrect or incompatible with message code" },
74 { 0x06, "Received PAD message did not contain an integral number of octets" },
75 { 0x08, "Received Parameter Indication PAD message was unsolicited" },
76 { 0x0A, "Received PAD message was too long" },
77 { 0x0C, "Unauthorized reselection PAD message" },
82 dissect_x29(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
85 proto_tree *x29_tree = NULL;
87 gboolean *q_bit_set = pinfo->private_data;
94 col_set_str(pinfo->cinfo, COL_PROTOCOL, "X.29");
95 if (check_col(pinfo->cinfo, COL_INFO))
96 col_clear(pinfo->cinfo, COL_INFO);
99 ti = proto_tree_add_item(tree, proto_x29, tvb, offset, -1,
101 x29_tree = proto_item_add_subtree(ti, ett_x29);
106 * Q bit set - this is a PAD message.
108 msg_code = tvb_get_guint8(tvb, offset);
109 if (check_col(pinfo->cinfo, COL_INFO)) {
110 col_add_fstr(pinfo->cinfo, COL_INFO, "%s PAD message",
111 val_to_str(msg_code, message_code_vals,
112 "Unknown (0x%02x)"));
114 proto_tree_add_uint(x29_tree, hf_msg_code, tvb,
115 offset, 1, msg_code);
122 case SET_AND_READ_MSG:
123 case PARAMETER_IND_MSG:
125 * XXX - dissect the references as per X.3.
127 while (tvb_reported_length_remaining(tvb, offset) > 0) {
128 proto_tree_add_text(x29_tree, tvb, offset, 2,
129 "Parameter %u, value %u",
130 tvb_get_guint8(tvb, offset),
131 tvb_get_guint8(tvb, offset + 1));
136 case INV_TO_CLEAR_MSG:
138 * No data for this message.
143 error_type = tvb_get_guint8(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, FALSE);
154 if (tvb_reported_length_remaining(tvb, offset) > 0) {
155 type_ref = tvb_get_guint8(tvb, offset);
158 case 0x01: /* change in PAD Aspect */
160 * XXX - dissect as per X.28.
162 proto_tree_add_text(x29_tree, tvb,
163 offset, 1, "Type reference: Change in PAD Aspect");
165 proto_tree_add_text(x29_tree, tvb,
166 offset, 1, "Type of aspect: 0x%02x",
171 case 0x08: /* break */
172 proto_tree_add_text(x29_tree, tvb,
173 offset, 1, "Type reference: Break");
175 proto_tree_add_text(x29_tree, tvb,
176 offset, 1, "Break value: 0x%02x",
182 proto_tree_add_text(x29_tree, tvb,
183 offset, 1, "Unknown type reference (0x%02x)",
186 proto_tree_add_text(x29_tree, tvb,
187 offset, 1, "Type value: 0x%02x",
195 case RESELECTION_MSG:
199 proto_tree_add_text(x29_tree, tvb, offset, -1,
200 "Reselection message data");
203 case RESEL_WITH_TOA_NPI_MSG:
207 proto_tree_add_text(x29_tree, tvb, offset, -1,
208 "Reselection message data");
212 proto_tree_add_text(x29_tree, tvb, offset, -1,
218 * Q bit not set - this is data.
220 if (check_col(pinfo->cinfo, COL_INFO))
221 col_set_str(pinfo->cinfo, COL_INFO, "Data ...");
224 while (tvb_offset_exists(tvb, offset)) {
226 * Find the end of the line.
228 linelen = tvb_find_line_end(tvb, offset, -1,
229 &next_offset, FALSE);
232 * Now compute the length of the line
233 * *including* the end-of-line indication,
234 * if any; we display it all.
236 linelen = next_offset - offset;
238 proto_tree_add_text(x29_tree, tvb, offset,
240 tvb_format_text(tvb, offset, linelen));
241 offset = next_offset;
248 proto_register_x29(void)
250 static hf_register_info hf[] = {
252 { "Message code", "x29.msg_code", FT_UINT8, BASE_HEX,
253 VALS(message_code_vals), 0x0, "X.29 PAD message code",
256 { "Error type", "x29.error_type", FT_UINT8, BASE_HEX,
257 VALS(error_type_vals), 0x0, "X.29 error PAD message error type",
260 { "Invalid message code", "x29.inv_msg_code", FT_UINT8, BASE_HEX,
261 VALS(message_code_vals), 0x0, "X.29 Error PAD message invalid message code",
264 static gint *ett[] = {
268 proto_x29 = proto_register_protocol("X.29", "X.29", "x29");
269 proto_register_field_array(proto_x29, hf, array_length(hf));
270 proto_register_subtree_array(ett, array_length(ett));
274 proto_reg_handoff_x29(void)
276 dissector_handle_t x29_handle;
278 x29_handle = create_dissector_handle(dissect_x29, proto_x29);
279 dissector_add("x.25.spi", NLPID_SPI_X_29, x29_handle);