Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-gmr1_dtap.c
blobe8e14f381ff7202d92f7d757a4178cabae43b364
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 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include "config.h"
20 #include <epan/packet.h>
22 #include "packet-gmr1_common.h"
24 void proto_register_gmr1_dtap(void);
25 void proto_reg_handoff_gmr1_dtap(void);
27 /* GMR-1 DTAP proto */
28 static int proto_gmr1_dtap;
30 static int hf_gmr1_dtap_protocol_discriminator;
31 static int hf_gmr1_dtap_message_elements;
33 /* GMR-1 DTAP sub tree */
34 static int ett_gmr1_dtap;
35 static int ett_gmr1_pd;
37 /* Handoffs */
38 static dissector_handle_t gsm_dtap_handle;
39 static dissector_handle_t dtap_handle;
42 static int
43 dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
45 uint32_t len, offset;
46 gmr1_msg_func_t msg_func;
47 const char *msg_str;
48 int ett_tree;
49 int hf_idx;
50 proto_item *dtap_item = NULL/*, *pd_item = NULL*/;
51 proto_tree *dtap_tree = NULL/*, *pd_tree = NULL*/;
52 uint32_t oct[2];
53 uint8_t pd;
55 /* Scan init */
56 len = tvb_captured_length(tvb);
57 offset = 0;
59 /* Protocol descriptor */
60 oct[0] = tvb_get_uint8(tvb, offset++);
62 if ((oct[0] & GMR1_PD_EXT_MSK) == GMR1_PD_EXT_VAL)
63 pd = oct[0] & 0xff;
64 else
65 pd = oct[0] & 0x0f;
67 /* HACK: Quick delegation hack to GSM */
68 if (pd != GMR1_PD_RR) {
69 call_dissector(gsm_dtap_handle, tvb, pinfo, tree);
70 return tvb_captured_length(tvb);
73 /* Fill up some info */
74 col_append_str(pinfo->cinfo, COL_INFO, " (DTAP) ");
76 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",
77 val_to_str(pd, gmr1_pd_short_vals, "Unknown (%u)"));
79 /* Get message parameters */
80 oct[1] = tvb_get_uint8(tvb, offset);
82 gmr1_get_msg_params((gmr1_pd_e)pd, oct[1], &msg_str, &ett_tree, &hf_idx, &msg_func);
84 /* Create protocol tree */
85 if (msg_str == NULL)
87 dtap_item = proto_tree_add_protocol_format(
88 tree, proto_gmr1_dtap, tvb, 0, len,
89 "GMR-1 DTAP - Message Type (0x%02x)", oct[1]);
90 dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
92 col_append_fstr(pinfo->cinfo, COL_INFO, "Message Type (0x%02x) ", oct[1]);
94 else
96 dtap_item = proto_tree_add_protocol_format(
97 tree, proto_gmr1_dtap, tvb, 0, -1,
98 "GMR-1 DTAP - %s", msg_str);
99 dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
101 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
104 /* Start over */
105 offset = 0;
107 /* Protocol discriminator item */
108 /*pd_item =*/ proto_tree_add_uint(
109 dtap_tree, hf_gmr1_dtap_protocol_discriminator, tvb, 1, 1, pd);
111 /*pd_tree = proto_item_add_subtree(pd_item, ett_gmr1_pd);*/
113 /* Move on */
114 offset++;
116 /* Message type - [1] 11.4 */
117 proto_tree_add_uint_format(
118 dtap_tree, hf_idx, tvb, offset, 1, oct[1],
119 "Message Type: %s", msg_str ? msg_str : "(Unknown)"
122 offset++;
124 /* Decode elements */
125 if (msg_func) {
126 (*msg_func)(tvb, dtap_tree, pinfo, offset, len - offset);
127 } else {
128 proto_tree_add_item(dtap_tree, hf_gmr1_dtap_message_elements, tvb, offset, len - offset, ENC_NA);
131 /* Done ! */
132 return tvb_captured_length(tvb);
136 void
137 proto_register_gmr1_dtap(void)
139 static hf_register_info hf[] = {
140 { &hf_gmr1_dtap_protocol_discriminator,
141 { "Protocol Discriminator", "gmr1.dtap.protocol_discriminator",
142 FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0,
143 NULL, HFILL }
145 { &hf_gmr1_dtap_message_elements,
146 { "Message elements", "gmr1.dtap.message_elements",
147 FT_BYTES, BASE_NONE, NULL, 0x0,
148 NULL, HFILL }
152 static int *ett[] = {
153 &ett_gmr1_dtap,
154 &ett_gmr1_pd,
157 /* Setup protocol subtree array */
158 proto_register_subtree_array(ett, array_length(ett));
160 /* Register the protocol name and field description */
161 proto_gmr1_dtap = proto_register_protocol("GEO-Mobile Radio (1) DTAP", "GMR-1 DTAP", "gmr1.dtap");
162 proto_register_field_array(proto_gmr1_dtap, hf, array_length(hf));
164 /* Register dissector */
165 dtap_handle = register_dissector("gmr1_dtap", dissect_gmr1_dtap, proto_gmr1_dtap);
168 void
169 proto_reg_handoff_gmr1_dtap(void)
171 dissector_add_uint("lapsat.sapi", 0 , dtap_handle); /* LAPSat: CC/RR/MM */
172 dissector_add_uint("lapsat.sapi", 3 , dtap_handle); /* LAPSat: SMS/SS */
174 gsm_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_gmr1_dtap);
178 * Editor modelines - https://www.wireshark.org/tools/modelines.html
180 * Local variables:
181 * c-basic-offset: 8
182 * tab-width: 8
183 * indent-tabs-mode: t
184 * End:
186 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
187 * :indentSize=8:tabSize=8:noTabs=false: