2 * Routines for GPRS Network Service (ETSI GSM 08.16 version 6.3.0)
4 * Copyright 2003, Josef Korelus <jkor@quick.cz>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/packet.h>
35 /*ETSI GSM08.16 Network Service */
36 #define NS_UNITDATA 0x00
38 #define NS_RESET_ACK 0x03
40 #define NS_BLOCK_ACK 0x05
41 #define NS_UNBLOCK 0x06
42 #define NS_UNBLOCK_ACK 0x07
43 #define NS_STATUS 0x08
45 #define NS_ALIVE_ACK 0x0b
47 /*ETSI GSM 08.16 IEI coding */
54 static int proto_gprs_ns = -1;
55 static gint ett_gprs_ns = -1;
56 static int hf_gprs_ns_pdutype = -1;
57 static int hf_gprs_ns_ie_type = -1;
58 static int hf_gprs_ns_ie_length = -1;
59 static int hf_gprs_ns_cause = -1;
60 static int hf_gprs_ns_vci = -1;
61 static int hf_gprs_ns_nsei = -1;
62 static int hf_gprs_ns_bvci = -1;
63 static int hf_gprs_ns_spare = -1;
65 static const value_string ns_pdu_type[]= {
66 { NS_UNITDATA, "NS-UNITDATA" },
67 { NS_RESET, "NS-RESET" },
68 { NS_RESET_ACK, "NS-RESET-ACK" },
69 { NS_BLOCK, "NS-BLOCK" },
70 { NS_BLOCK_ACK, "NS-BLOCK-ACK" },
71 { NS_UNBLOCK, "NS-UNBLOCK" },
72 { NS_UNBLOCK_ACK, "NS-UNBLOCK-ACK" },
73 { NS_STATUS, "NS-STATUS" },
74 { NS_ALIVE, "NS-ALIVE" },
75 { NS_ALIVE_ACK, "NS-ALIVE-ACK" },
79 static const value_string ns_ie_type[]= {
88 static const value_string cause_val[]= {
89 { 0x0, "Transit network failure" },
90 { 0x1, "O&M intervention" },
91 { 0x2, "Equipment failure" },
92 { 0x3, "NS-VC blocked " },
93 { 0x4, "NS-VC unknown" },
94 { 0x5, "NS-VC unknown on that NSE" },
95 { 0x8, "Semantically incorrect PDU" },
96 { 0xa, "PDU not compatible with protocol state" },
97 { 0xb, "Protocol error - unspecified" },
98 { 0xc, "Invalid essential IE" },
99 { 0xd, "Missing essential IE" },
103 static dissector_handle_t bssgp_handle;
106 process_tlvs(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
112 guint16 nsvc, bvc, nsei;
114 while (tvb_reported_length_remaining(tvb, offset) > 0) {
115 type = tvb_get_guint8(tvb, offset);
116 proto_tree_add_uint(tree, hf_gprs_ns_ie_type,
117 tvb, offset, 1, type);
121 length = tvb_get_guint8(tvb, offset);
124 * This is the final octet of the length.
132 length = (length << 8) | tvb_get_guint8(tvb, offset);
134 proto_tree_add_uint(tree, hf_gprs_ns_ie_length,
135 tvb, offset, length_len, length);
136 offset += length_len;
142 cause = tvb_get_guint8(tvb, offset);
144 proto_tree_add_uint(tree,
145 hf_gprs_ns_cause, tvb, offset, 1,
148 if (check_col(pinfo->cinfo, COL_INFO)) {
149 col_append_fstr(pinfo->cinfo, COL_INFO,
151 val_to_str(cause, cause_val, "Unknown (0x%02x)"));
155 proto_tree_add_text(tree,
157 "Bad cause length %u, should be 1",
165 nsvc = tvb_get_ntohs(tvb, offset);
167 proto_tree_add_uint(tree,
168 hf_gprs_ns_vci, tvb, offset, 2,
171 if (check_col(pinfo->cinfo, COL_INFO)) {
172 col_append_fstr(pinfo->cinfo, COL_INFO,
177 proto_tree_add_text(tree,
179 "Bad NS-VCI length %u, should be 2",
187 * XXX - dissect as a GPRS NS PDU.
188 * Do the usual "error packet" stuff.
191 proto_tree_add_text(tree,
199 bvc = tvb_get_ntohs(tvb, offset);
201 proto_tree_add_uint(tree,
202 hf_gprs_ns_bvci, tvb, offset, 2,
205 if (check_col(pinfo->cinfo, COL_INFO)) {
206 col_append_fstr(pinfo->cinfo, COL_INFO,
211 proto_tree_add_text(tree,
213 "Bad BVCI length %u, should be 2",
221 nsei = tvb_get_ntohs(tvb, offset);
223 proto_tree_add_uint(tree,
224 hf_gprs_ns_nsei, tvb, offset, 2,
227 if (check_col(pinfo->cinfo, COL_INFO)) {
228 col_append_fstr(pinfo->cinfo, COL_INFO,
233 proto_tree_add_text(tree,
235 "Bad NSEI length %u, should be 2",
243 proto_tree_add_text(tree,
245 "Unknown IE contents");
254 dissect_gprs_ns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
257 proto_item *ti = NULL;
258 proto_tree *gprs_ns_tree = NULL;
263 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GPRS NS");
264 if (check_col(pinfo->cinfo, COL_INFO))
265 col_clear(pinfo->cinfo, COL_INFO);
267 nspdu = tvb_get_guint8(tvb,offset);
268 if (check_col(pinfo->cinfo, COL_INFO)) {
269 col_add_str(pinfo->cinfo, COL_INFO,
270 val_to_str(nspdu, ns_pdu_type, "Unknown PDU type (0x%02x)"));
273 ti = proto_tree_add_item(tree, proto_gprs_ns, tvb, 0, -1, FALSE);
274 gprs_ns_tree = proto_item_add_subtree(ti, ett_gprs_ns);
275 proto_tree_add_uint(gprs_ns_tree, hf_gprs_ns_pdutype, tvb, 0, 1, nspdu);
295 process_tlvs(tvb, offset, pinfo, gprs_ns_tree);
300 proto_tree_add_item(gprs_ns_tree, hf_gprs_ns_spare, tvb, offset, 1, FALSE);
302 bvc = tvb_get_ntohs(tvb,offset);
303 if (check_col(pinfo->cinfo, COL_INFO))
304 col_append_fstr(pinfo->cinfo, COL_INFO, " BVCI: %u", bvc);
306 proto_tree_add_uint(gprs_ns_tree, hf_gprs_ns_bvci, tvb, offset, 2, bvc);
308 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
309 call_dissector(bssgp_handle, next_tvb, pinfo, tree);
317 /* Register the protocol with Wireshark */
319 proto_register_gprs_ns(void)
321 static hf_register_info hf[] = {
322 { &hf_gprs_ns_pdutype, {
323 "PDU Type", "gprs_ns.pdutype", FT_UINT8, BASE_HEX,
324 VALS(ns_pdu_type), 0x0, "NS Command", HFILL}},
325 { &hf_gprs_ns_ie_type, {
326 "IE Type", "gprs_ns.ietype", FT_UINT8, BASE_HEX,
327 VALS(ns_ie_type), 0x0, NULL, HFILL}},
328 { &hf_gprs_ns_ie_length, {
329 "IE Length", "gprs_ns.ielength", FT_UINT16, BASE_DEC,
330 NULL, 0x0, NULL, HFILL}},
331 { &hf_gprs_ns_cause, {
332 "Cause", "gprs_ns.cause", FT_UINT8, BASE_HEX,
333 VALS(cause_val), 0x0, NULL, HFILL}},
335 "NSVCI", "gprs_ns.nsvci", FT_UINT16, BASE_DEC,
336 NULL, 0x0, "Network Service Virtual Connection id", HFILL}},
337 { &hf_gprs_ns_nsei, {
338 "NSEI", "gprs_ns.nsei", FT_UINT16, BASE_DEC,
339 NULL, 0x0, "Network Service Entity Id", HFILL}},
340 { &hf_gprs_ns_bvci, {
341 "BVCI", "gprs_ns.bvci", FT_UINT16, BASE_DEC,
342 NULL, 0x0, "Cell ID", HFILL}},
343 { &hf_gprs_ns_spare, {
344 "Spare octet", "gprs_ns.spare", FT_UINT8, BASE_HEX,
345 NULL, 0x0, NULL, HFILL}},
348 /* Setup protocol subtree array */
349 static gint *ett[] = {
353 proto_gprs_ns = proto_register_protocol("GPRS Network service",
354 "GPRS NS","gprs_ns");
355 proto_register_field_array(proto_gprs_ns, hf, array_length(hf));
356 proto_register_subtree_array(ett, array_length(ett));
358 register_dissector("gprs_ns", dissect_gprs_ns, proto_gprs_ns);
362 proto_reg_handoff_gprs_ns(void)
364 bssgp_handle = find_dissector("bssgp");