Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-gmr1_common.c
blob7ec4ed6a58829d8f4c9edd26d7670235818a1c29
1 /* packet-gmr1_common.c
3 * Routines for GMR-1 dissection in wireshark (common stuff).
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
10 * [4] ETSI TS 100 940 V7.21.0 - GSM 04.08
11 * [5] ETSI TS 101 376-4-12 V3.2.1 - GMR-1 3G 44.060
12 * [6] ETSI TS 101 376-5-6 V1.3.1 - GMR-1 05.008
14 * Wireshark - Network traffic analyzer
15 * By Gerald Combs <gerald@wireshark.org>
16 * Copyright 1998 Gerald Combs
18 * SPDX-License-Identifier: GPL-2.0-or-later
21 #include "config.h"
23 #include <epan/packet.h>
25 #include "packet-gmr1_common.h"
27 #include "packet-gmr1_rr.h"
29 void proto_register_gmr1_common(void);
31 /* GMR-1 Common proto */
32 static int proto_gmr1_common;
35 /* ------------------------------------------------------------------------ */
36 /* Protocol descriptor (see [1] 11.2 & [4] 10.2) */
37 /* ------------------------------------------------------------------------ */
39 const value_string gmr1_pd_vals[] = {
40 { GMR1_PD_CC, "Call Control; call related SS messages" },
41 { GMR1_PD_MM, "Mobility Management messages" },
42 { GMR1_PD_RR, "Radio Resource management messages" },
43 { GMR1_PD_GMM, "GPRS Mobility Management messages" },
44 { GMR1_PD_SM, "Session Management messages" },
45 { GMR1_PD_DTRS, "DTMF transmission and reception service" },
46 { 0, NULL }
49 const value_string gmr1_pd_short_vals[] = {
50 { GMR1_PD_CC, "CC" }, /* Call Control; call related SS messages */
51 { GMR1_PD_MM, "MM" }, /* Mobility Management messages */
52 { GMR1_PD_RR, "RR" }, /* Radio Resource management messages */
53 { GMR1_PD_GMM, "GMM" }, /* GPRS Mobility Management messages */
54 { GMR1_PD_SM, "SM" }, /* Session Management messages */
55 { GMR1_PD_DTRS, "DTRS" }, /* DTMF transmission and reception service */
56 { 0, NULL}
60 /* ------------------------------------------------------------------------ */
61 /* Common Information Elements */
62 /* ------------------------------------------------------------------------ */
64 static const value_string gmr1_ie_common_strings[] = {
65 { GMR1_IE_COM_CM2,
66 "Mobile Earth Station Classmark 2" }, /* [1] 11.5.1.6 */
67 { GMR1_IE_COM_SPARE_NIBBLE,
68 "Spare Half Octet" }, /* [1] 11.5.1.8 */
69 { 0, NULL}
71 value_string_ext gmr1_ie_common_strings_ext = VALUE_STRING_EXT_INIT(gmr1_ie_common_strings);
73 int ett_gmr1_ie_common[NUM_GMR1_IE_COMMON];
75 /* Fields */
76 int hf_gmr1_skip_ind;
77 int hf_gmr1_l3_pd;
78 int hf_gmr1_elem_id;
79 int hf_gmr1_len;
81 static int hf_com_cm2_spare1;
82 static int hf_com_cm2_revision;
83 static int hf_com_cm2_early_send;
84 static int hf_com_cm2_a5_1;
85 static int hf_com_cm2_mes_type;
86 static int hf_com_cm2_spare2;
87 static int hf_com_cm2_ss_screen_ind;
88 static int hf_com_cm2_sms_cap;
89 static int hf_com_cm2_spare3;
90 static int hf_com_cm2_freq_cap;
91 static int hf_com_cm2_cm3_presence;
92 static int hf_com_cm2_spare4;
93 static int hf_com_cm2_a5_3;
94 static int hf_com_cm2_a5_2_gmr1;
95 static int hf_com_spare_nibble;
97 /* [1] 11.5.1.6 - Mobile Earth Station Classmark 2 */
98 static const value_string com_cm2_revision_vals[] = {
99 { 0, "Reserved for Phase 1" },
100 { 1, "Phase 2 MESs" },
101 { 2, "Reserved" },
102 { 3, "Reserved" },
103 { 0, NULL }
106 static const value_string com_cm2_early_send_vals[] = {
107 { 0, "\"Controlled Early Classmark Sending\" option is not implemented" },
108 { 1, "\"Controlled Early Classmark Sending\" option is implemented" },
109 { 0, NULL }
112 static const value_string com_cm2_a5_1_vals[] = {
113 { 0, "Encryption algorithm A5/1 available" },
114 { 1, "Encryption algorithm A5/1 not available" },
115 { 0, NULL }
118 static const value_string com_cm2_mes_type_vals[] = {
119 { 0, "Class 1 Reserved" },
120 { 1, "Class 2 Used by all fixed GMR-1 terminals" },
121 { 2, "Class 3 Used by all vehicular GMR-1 terminals" },
122 { 3, "Class 4 Used by all handheld GMR-1 terminals" },
123 { 0, NULL }
126 static const value_string com_cm2_ss_screen_ind_vals[] = {
127 { 0, "Defined in GSM 04.80 [29]" },
128 { 1, "Defined in GSM 04.80 [29]" },
129 { 2, "Defined in GSM 04.80 [29]" },
130 { 3, "Defined in GSM 04.80 [29]" },
131 { 0, NULL }
134 static const value_string com_cm2_sms_cap_vals[] = {
135 { 0, "MES does not support mobile terminated point-to-point SMS" },
136 { 1, "MES supports mobile terminated point-to-point SMS" },
137 { 0, NULL }
140 static const value_string com_cm2_freq_cap_vals[] = {
141 { 0, "Not used in GMR-1" },
142 { 1, "Not used in GMR-1" },
143 { 0, NULL }
146 static const value_string com_cm3_presence_vals[] = {
147 { 0, "No additional MES capability information available" },
148 { 1, "Additional MES capabilities are described in the Classmark 3 IE" },
149 { 0, NULL }
152 static const value_string com_cm2_a5_3_vals[] = {
153 { 0, "Encryption algorithm A5/3 not available" },
154 { 1, "Encryption algorithm A5/3 available" },
155 { 0, NULL }
158 static const value_string com_cm2_a5_2_gmr1_vals[] = {
159 { 0, "Encryption algorithm GMR-1 A5/2 not available" },
160 { 1, "Encryption algorithm GMR-1 A5/2 available" },
161 { 0, NULL }
164 GMR1_IE_FUNC(gmr1_ie_com_cm2)
166 proto_tree_add_item(tree, hf_com_cm2_spare1,
167 tvb, offset, 1, ENC_BIG_ENDIAN);
169 proto_tree_add_item(tree, hf_com_cm2_revision,
170 tvb, offset, 1, ENC_BIG_ENDIAN);
172 proto_tree_add_item(tree, hf_com_cm2_early_send,
173 tvb, offset, 1, ENC_BIG_ENDIAN);
175 proto_tree_add_item(tree, hf_com_cm2_a5_1,
176 tvb, offset, 1, ENC_BIG_ENDIAN);
178 proto_tree_add_item(tree, hf_com_cm2_mes_type,
179 tvb, offset, 1, ENC_BIG_ENDIAN);
181 offset++;
183 proto_tree_add_item(tree, hf_com_cm2_spare2,
184 tvb, offset, 1, ENC_BIG_ENDIAN);
186 proto_tree_add_item(tree, hf_com_cm2_ss_screen_ind,
187 tvb, offset, 1, ENC_BIG_ENDIAN);
189 proto_tree_add_item(tree, hf_com_cm2_sms_cap,
190 tvb, offset, 1, ENC_BIG_ENDIAN);
192 proto_tree_add_item(tree, hf_com_cm2_spare3,
193 tvb, offset, 1, ENC_BIG_ENDIAN);
195 proto_tree_add_item(tree, hf_com_cm2_freq_cap,
196 tvb, offset, 1, ENC_BIG_ENDIAN);
198 offset++;
200 proto_tree_add_item(tree, hf_com_cm2_cm3_presence,
201 tvb, offset, 1, ENC_BIG_ENDIAN);
203 proto_tree_add_item(tree, hf_com_cm2_spare4,
204 tvb, offset, 1, ENC_BIG_ENDIAN);
206 proto_tree_add_item(tree, hf_com_cm2_a5_3,
207 tvb, offset, 1, ENC_BIG_ENDIAN);
209 proto_tree_add_item(tree, hf_com_cm2_a5_2_gmr1,
210 tvb, offset, 1, ENC_BIG_ENDIAN);
212 offset++;
214 return 3;
217 /* [1] 11.5.1.8 - Spare Half Octet */
218 GMR1_IE_FUNC(gmr1_ie_com_spare_nibble)
220 proto_tree_add_item(tree, hf_com_spare_nibble, tvb, offset, 1, ENC_BIG_ENDIAN);
222 return 1;
225 elem_fcn gmr1_ie_common_func[NUM_GMR1_IE_COMMON] = {
226 gmr1_ie_com_cm2, /* MES Classmark 2 */
227 gmr1_ie_com_spare_nibble, /* Spare Half Octet */
231 /* ------------------------------------------------------------------------ */
232 /* Messages and IEs parsing */
233 /* ------------------------------------------------------------------------ */
235 void
236 gmr1_get_msg_params(gmr1_pd_e pd, uint8_t oct, const char **msg_str,
237 int *ett_tree, int *hf_idx, gmr1_msg_func_t *msg_func_p)
239 switch (pd) {
240 case GMR1_PD_RR:
241 gmr1_get_msg_rr_params(oct, 1, msg_str, ett_tree, hf_idx, msg_func_p);
242 break;
244 default:
245 *msg_str = NULL;
246 *ett_tree = -1;
247 *hf_idx = -1;
248 *msg_func_p = NULL;
253 /* ------------------------------------------------------------------------ */
254 /* Register code */
255 /* ------------------------------------------------------------------------ */
257 void
258 proto_register_gmr1_common(void)
260 static hf_register_info hf[] = {
261 { &hf_gmr1_skip_ind,
262 { "Skip Indicator", "gmr1.skip_ind",
263 FT_UINT8, BASE_DEC, NULL, 0xf0,
264 NULL, HFILL }
266 { &hf_gmr1_l3_pd,
267 { "Protocol discriminator","gmr1.l3_protocol_discriminator",
268 FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0f,
269 NULL, HFILL }
271 { &hf_gmr1_elem_id,
272 { "Element ID", "gmr1.ie.elem_id",
273 FT_UINT8, BASE_HEX, NULL, 0,
274 NULL, HFILL }
276 { &hf_gmr1_len,
277 { "Length", "gmr1.ie.length",
278 FT_UINT8, BASE_DEC, NULL, 0,
279 NULL, HFILL }
281 { &hf_com_cm2_spare1,
282 { "Spare", "gmr1.common.cm2.spare1",
283 FT_UINT8, BASE_DEC, NULL, 0x80,
284 NULL, HFILL }
286 { &hf_com_cm2_revision,
287 { "Revision Level", "gmr1.common.cm2.revision",
288 FT_UINT8, BASE_DEC, VALS(com_cm2_revision_vals), 0x60,
289 NULL, HFILL }
291 { &hf_com_cm2_early_send,
292 { "ES IND", "gmr1.common.cm2.early_send",
293 FT_UINT8, BASE_DEC, VALS(com_cm2_early_send_vals), 0x10,
294 NULL, HFILL }
296 { &hf_com_cm2_a5_1,
297 { "A5/1", "gmr1.common.cm2.a5_1",
298 FT_UINT8, BASE_DEC, VALS(com_cm2_a5_1_vals), 0x08,
299 NULL, HFILL }
301 { &hf_com_cm2_mes_type,
302 { "MES terminal type", "gmr1.common.cm2.mes_type",
303 FT_UINT8, BASE_DEC, VALS(com_cm2_mes_type_vals), 0x07,
304 NULL, HFILL }
306 { &hf_com_cm2_spare2,
307 { "Spare", "gmr1.common.cm2.spare2",
308 FT_UINT8, BASE_DEC, NULL, 0xc0,
309 NULL, HFILL }
311 { &hf_com_cm2_ss_screen_ind,
312 { "SS Screening Indicator", "gmr1.common.cm2.ss_screen_ind",
313 FT_UINT8, BASE_DEC, VALS(com_cm2_ss_screen_ind_vals), 0x30,
314 NULL, HFILL }
316 { &hf_com_cm2_sms_cap,
317 { "SM capability", "gmr1.common.cm2.sms_cap",
318 FT_UINT8, BASE_DEC, VALS(com_cm2_sms_cap_vals), 0x08,
319 NULL, HFILL }
321 { &hf_com_cm2_spare3,
322 { "Spare", "gmr1.common.cm2.spare3",
323 FT_UINT8, BASE_DEC, NULL, 0x06,
324 NULL, HFILL }
326 { &hf_com_cm2_freq_cap,
327 { "FC", "gmr1.common.cm2.freq_cap",
328 FT_UINT8, BASE_DEC, VALS(com_cm2_freq_cap_vals), 0x01,
329 NULL, HFILL }
331 { &hf_com_cm2_cm3_presence,
332 { "CM3", "gmr1.common.cm2.cm3_presence",
333 FT_UINT8, BASE_DEC, VALS(com_cm3_presence_vals), 0x80,
334 NULL, HFILL }
336 { &hf_com_cm2_spare4,
337 { "Spare", "gmr1.common.cm2.spare4",
338 FT_UINT8, BASE_DEC, NULL, 0x7c,
339 NULL, HFILL }
341 { &hf_com_cm2_a5_3,
342 { "A5/3", "gmr1.common.cm2.a5_3",
343 FT_UINT8, BASE_DEC, VALS(com_cm2_a5_3_vals), 0x02,
344 NULL, HFILL }
346 { &hf_com_cm2_a5_2_gmr1,
347 { "A5/2 GMR-1", "gmr1.common.cm2.a5_2_gmr1",
348 FT_UINT8, BASE_DEC, VALS(com_cm2_a5_2_gmr1_vals), 0x01,
349 NULL, HFILL }
351 { &hf_com_spare_nibble,
352 { "Spare Half Octet", "gmr1.common.spare_nibble",
353 FT_UINT8, BASE_HEX, NULL, 0x0,
354 NULL, HFILL }
358 /* Register the protocol name and field description */
359 proto_gmr1_common = proto_register_protocol("GEO-Mobile Radio (1) Common", "GMR-1 Common", "gmr1.common");
361 proto_register_field_array(proto_gmr1_common, hf, array_length(hf));
365 * Editor modelines - https://www.wireshark.org/tools/modelines.html
367 * Local variables:
368 * c-basic-offset: 8
369 * tab-width: 8
370 * indent-tabs-mode: t
371 * End:
373 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
374 * :indentSize=8:tabSize=8:noTabs=false: