MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-gmr1_dtap.c
blob38937906441f4b13c1287a1d548f5479cc8a5a8c
1 /* packet-gmr1_dtap.c
3 * Routines for GMR-1 DTAP dissection in wireshark.
4 * Copyright (c) 2011 Sylvain Munaut <tnt@246tNt.com>
6 * References:
7 * [1] ETSI TS 101 376-4-8 V1.3.1 - GMR-1 04.008
8 * [2] ETSI TS 101 376-4-8 V2.2.1 - GMPRS-1 04.008
9 * [3] ETSI TS 101 376-4-8 V3.1.1 - GMR-1 3G 44.008
11 * $Id$
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include "config.h"
34 #include <glib.h>
35 #include <epan/packet.h>
37 #include "packet-gmr1_common.h"
40 /* GMR-1 DTAP proto */
41 static int proto_gmr1_dtap = -1;
43 /* GMR-1 DTAP sub tree */
44 static gint ett_gmr1_dtap = -1;
45 static gint ett_gmr1_pd = -1;
47 /* Handoffs */
48 static dissector_handle_t gsm_dtap_handle;
51 static void
52 dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
54 guint32 len, offset;
55 gmr1_msg_func_t msg_func;
56 const gchar *msg_str;
57 gint ett_tree;
58 int hf_idx;
59 proto_item *dtap_item = NULL/*, *pd_item = NULL*/;
60 proto_tree *dtap_tree = NULL/*, *pd_tree = NULL*/;
61 guint32 oct[2];
62 guint8 pd;
64 /* Scan init */
65 len = tvb_length(tvb);
66 offset = 0;
68 /* Protocol descriptor */
69 oct[0] = tvb_get_guint8(tvb, offset++);
71 if ((oct[0] & GMR1_PD_EXT_MSK) == GMR1_PD_EXT_VAL)
72 pd = oct[0] & 0xff;
73 else
74 pd = oct[0] & 0x0f;
76 /* HACK: Quick delegation hack to GSM */
77 if (pd != GMR1_PD_RR) {
78 call_dissector(gsm_dtap_handle, tvb, pinfo, tree);
79 return;
82 /* Fill up some info */
83 col_append_str(pinfo->cinfo, COL_INFO, " (DTAP) ");
85 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",
86 val_to_str(pd, gmr1_pd_short_vals, "Unknown (%u)"));
88 /* Get message parameters */
89 oct[1] = tvb_get_guint8(tvb, offset);
91 gmr1_get_msg_params((gmr1_pd_e)pd, oct[1], &msg_str, &ett_tree, &hf_idx, &msg_func);
93 /* Create protocol tree */
94 if (msg_str == NULL)
96 dtap_item = proto_tree_add_protocol_format(
97 tree, proto_gmr1_dtap, tvb, 0, len,
98 "GMR-1 DTAP - Message Type (0x%02x)", oct[1]);
99 dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
101 col_append_fstr(pinfo->cinfo, COL_INFO, "Message Type (0x%02x) ", oct[1]);
103 else
105 dtap_item = proto_tree_add_protocol_format(
106 tree, proto_gmr1_dtap, tvb, 0, -1,
107 "GMR-1 DTAP - %s", msg_str);
108 dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
110 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
113 /* Start over */
114 offset = 0;
116 /* Protocol discriminator item */
117 /*pd_item =*/ proto_tree_add_text(
118 dtap_tree, tvb, 1, 1,
119 "Protocol Discriminator: %s",
120 val_to_str(pd, gmr1_pd_vals, "Unknown (%u)")
123 /*pd_tree = proto_item_add_subtree(pd_item, ett_gmr1_pd);*/
125 /* Move on */
126 offset++;
128 /* Message type - [1] 11.4 */
129 proto_tree_add_uint_format(
130 dtap_tree, hf_idx, tvb, offset, 1, oct[1],
131 "Message Type: %s", msg_str ? msg_str : "(Unknown)"
134 offset++;
136 /* Decode elements */
137 if (msg_func) {
138 (*msg_func)(tvb, dtap_tree, pinfo, offset, len - offset);
139 } else {
140 proto_tree_add_text(dtap_tree, tvb, offset, len - offset,
141 "Message Elements");
144 /* Done ! */
145 return;
149 void
150 proto_register_gmr1_dtap(void)
152 #if 0
153 static hf_register_info hf[] = {
155 #endif
156 static gint *ett[] = {
157 &ett_gmr1_dtap,
158 &ett_gmr1_pd,
161 /* Setup protocol subtree array */
162 proto_register_subtree_array(ett, array_length(ett));
164 /* Register the protocol name and field description */
165 proto_gmr1_dtap = proto_register_protocol("GEO-Mobile Radio (1) DTAP", "GMR-1 DTAP", "gmr1.dtap");
166 #if 0
167 proto_register_field_array(proto_gmr1_dtap, hf, array_length(hf));
168 #endif
169 /* Register dissector */
170 register_dissector("gmr1_dtap", dissect_gmr1_dtap, proto_gmr1_dtap);
173 void
174 proto_reg_handoff_gmr1_dtap(void)
176 dissector_handle_t dtap_handle;
178 dtap_handle = find_dissector("gmr1_dtap");
179 dissector_add_uint("lapsat.sapi", 0 , dtap_handle); /* LAPSat: CC/RR/MM */
180 dissector_add_uint("lapsat.sapi", 3 , dtap_handle); /* LAPSat: SMS/SS */
182 gsm_dtap_handle = find_dissector("gsm_a_dtap");