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.
32 #include <epan/packet.h>
34 /*ETSI GSM08.16 Network Service */
35 #define NS_UNITDATA 0x00
37 #define NS_RESET_ACK 0x03
39 #define NS_BLOCK_ACK 0x05
40 #define NS_UNBLOCK 0x06
41 #define NS_UNBLOCK_ACK 0x07
42 #define NS_STATUS 0x08
44 #define NS_ALIVE_ACK 0x0b
46 /*ETSI GSM 08.16 IEI coding */
53 static int proto_gprs_ns = -1;
54 static gint ett_gprs_ns = -1;
55 static int hf_gprs_ns_pdutype = -1;
56 static int hf_gprs_ns_ie_type = -1;
57 static int hf_gprs_ns_ie_length = -1;
58 static int hf_gprs_ns_cause = -1;
59 static int hf_gprs_ns_vci = -1;
60 static int hf_gprs_ns_nsei = -1;
61 static int hf_gprs_ns_bvci = -1;
62 static int hf_gprs_ns_spare = -1;
64 static const value_string ns_pdu_type[]= {
65 { NS_UNITDATA, "NS-UNITDATA" },
66 { NS_RESET, "NS-RESET" },
67 { NS_RESET_ACK, "NS-RESET-ACK" },
68 { NS_BLOCK, "NS-BLOCK" },
69 { NS_BLOCK_ACK, "NS-BLOCK-ACK" },
70 { NS_UNBLOCK, "NS-UNBLOCK" },
71 { NS_UNBLOCK_ACK, "NS-UNBLOCK-ACK" },
72 { NS_STATUS, "NS-STATUS" },
73 { NS_ALIVE, "NS-ALIVE" },
74 { NS_ALIVE_ACK, "NS-ALIVE-ACK" },
78 static const value_string ns_ie_type[]= {
87 static const value_string cause_val[]= {
88 { 0x0, "Transit network failure" },
89 { 0x1, "O&M intervention" },
90 { 0x2, "Equipment failure" },
91 { 0x3, "NS-VC blocked " },
92 { 0x4, "NS-VC unknown" },
93 { 0x5, "NS-VC unknown on that NSE" },
94 { 0x8, "Semantically incorrect PDU" },
95 { 0xa, "PDU not compatible with protocol state" },
96 { 0xb, "Protocol error - unspecified" },
97 { 0xc, "Invalid essential IE" },
98 { 0xd, "Missing essential IE" },
102 static dissector_handle_t bssgp_handle;
105 process_tlvs(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
111 guint16 nsvc, bvc, nsei;
113 while (tvb_reported_length_remaining(tvb, offset) > 0) {
114 type = tvb_get_guint8(tvb, offset);
115 proto_tree_add_uint(tree, hf_gprs_ns_ie_type,
116 tvb, offset, 1, type);
120 length = tvb_get_guint8(tvb, offset);
123 * This is the final octet of the length.
131 length = (length << 8) | tvb_get_guint8(tvb, offset);
133 proto_tree_add_uint(tree, hf_gprs_ns_ie_length,
134 tvb, offset, length_len, length);
135 offset += length_len;
141 cause = tvb_get_guint8(tvb, offset);
143 proto_tree_add_uint(tree,
144 hf_gprs_ns_cause, tvb, offset, 1,
147 if (check_col(pinfo->cinfo, COL_INFO)) {
148 col_append_fstr(pinfo->cinfo, COL_INFO,
150 val_to_str(cause, cause_val, "Unknown (0x%02x)"));
154 proto_tree_add_text(tree,
156 "Bad cause length %u, should be 1",
164 nsvc = tvb_get_ntohs(tvb, offset);
166 proto_tree_add_uint(tree,
167 hf_gprs_ns_vci, tvb, offset, 2,
170 if (check_col(pinfo->cinfo, COL_INFO)) {
171 col_append_fstr(pinfo->cinfo, COL_INFO,
176 proto_tree_add_text(tree,
178 "Bad NS-VCI length %u, should be 2",
186 * XXX - dissect as a GPRS NS PDU.
187 * Do the usual "error packet" stuff.
190 proto_tree_add_text(tree,
198 bvc = tvb_get_ntohs(tvb, offset);
200 proto_tree_add_uint(tree,
201 hf_gprs_ns_bvci, tvb, offset, 2,
204 if (check_col(pinfo->cinfo, COL_INFO)) {
205 col_append_fstr(pinfo->cinfo, COL_INFO,
210 proto_tree_add_text(tree,
212 "Bad BVCI length %u, should be 2",
220 nsei = tvb_get_ntohs(tvb, offset);
222 proto_tree_add_uint(tree,
223 hf_gprs_ns_nsei, tvb, offset, 2,
226 if (check_col(pinfo->cinfo, COL_INFO)) {
227 col_append_fstr(pinfo->cinfo, COL_INFO,
232 proto_tree_add_text(tree,
234 "Bad NSEI length %u, should be 2",
242 proto_tree_add_text(tree,
244 "Unknown IE contents");
253 dissect_gprs_ns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
256 proto_item *ti = NULL;
257 proto_tree *gprs_ns_tree = NULL;
262 col_set_str(pinfo->cinfo, COL_PROTOCOL, "GPRS NS");
263 col_clear(pinfo->cinfo, COL_INFO);
265 nspdu = tvb_get_guint8(tvb,offset);
266 if (check_col(pinfo->cinfo, COL_INFO)) {
267 col_add_str(pinfo->cinfo, COL_INFO,
268 val_to_str(nspdu, ns_pdu_type, "Unknown PDU type (0x%02x)"));
271 ti = proto_tree_add_item(tree, proto_gprs_ns, tvb, 0, -1, FALSE);
272 gprs_ns_tree = proto_item_add_subtree(ti, ett_gprs_ns);
273 proto_tree_add_uint(gprs_ns_tree, hf_gprs_ns_pdutype, tvb, 0, 1, nspdu);
293 process_tlvs(tvb, offset, pinfo, gprs_ns_tree);
298 proto_tree_add_item(gprs_ns_tree, hf_gprs_ns_spare, tvb, offset, 1, FALSE);
300 bvc = tvb_get_ntohs(tvb,offset);
301 if (check_col(pinfo->cinfo, COL_INFO))
302 col_append_fstr(pinfo->cinfo, COL_INFO, " BVCI: %u", bvc);
304 proto_tree_add_uint(gprs_ns_tree, hf_gprs_ns_bvci, tvb, offset, 2, bvc);
306 next_tvb = tvb_new_subset_remaining(tvb, offset);
307 call_dissector(bssgp_handle, next_tvb, pinfo, tree);
315 /* Register the protocol with Wireshark */
317 proto_register_gprs_ns(void)
319 static hf_register_info hf[] = {
320 { &hf_gprs_ns_pdutype, {
321 "PDU Type", "gprs_ns.pdutype", FT_UINT8, BASE_HEX,
322 VALS(ns_pdu_type), 0x0, "NS Command", HFILL}},
323 { &hf_gprs_ns_ie_type, {
324 "IE Type", "gprs_ns.ietype", FT_UINT8, BASE_HEX,
325 VALS(ns_ie_type), 0x0, NULL, HFILL}},
326 { &hf_gprs_ns_ie_length, {
327 "IE Length", "gprs_ns.ielength", FT_UINT16, BASE_DEC,
328 NULL, 0x0, NULL, HFILL}},
329 { &hf_gprs_ns_cause, {
330 "Cause", "gprs_ns.cause", FT_UINT8, BASE_HEX,
331 VALS(cause_val), 0x0, NULL, HFILL}},
333 "NSVCI", "gprs_ns.nsvci", FT_UINT16, BASE_DEC,
334 NULL, 0x0, "Network Service Virtual Connection id", HFILL}},
335 { &hf_gprs_ns_nsei, {
336 "NSEI", "gprs_ns.nsei", FT_UINT16, BASE_DEC,
337 NULL, 0x0, "Network Service Entity Id", HFILL}},
338 { &hf_gprs_ns_bvci, {
339 "BVCI", "gprs_ns.bvci", FT_UINT16, BASE_DEC,
340 NULL, 0x0, "Cell ID", HFILL}},
341 { &hf_gprs_ns_spare, {
342 "Spare octet", "gprs_ns.spare", FT_UINT8, BASE_HEX,
343 NULL, 0x0, NULL, HFILL}},
346 /* Setup protocol subtree array */
347 static gint *ett[] = {
351 proto_gprs_ns = proto_register_protocol("GPRS Network service",
352 "GPRS NS","gprs_ns");
353 proto_register_field_array(proto_gprs_ns, hf, array_length(hf));
354 proto_register_subtree_array(ett, array_length(ett));
356 register_dissector("gprs_ns", dissect_gprs_ns, proto_gprs_ns);
360 proto_reg_handoff_gprs_ns(void)
362 bssgp_handle = find_dissector("bssgp");