Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-gmr1_common.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-gmr1_common.c
2
 *
3
 * Routines for GMR-1 dissection in wireshark (common stuff).
4
 * Copyright (c) 2011 Sylvain Munaut <tnt@246tNt.com>
5
 *
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
13
 *
14
 * Wireshark - Network traffic analyzer
15
 * By Gerald Combs <gerald@wireshark.org>
16
 * Copyright 1998 Gerald Combs
17
 *
18
 * SPDX-License-Identifier: GPL-2.0-or-later
19
 */
20
21
#include "config.h"
22
23
#include <epan/packet.h>
24
25
#include "packet-gmr1_common.h"
26
27
#include "packet-gmr1_rr.h"
28
29
void proto_register_gmr1_common(void);
30
31
/* GMR-1 Common proto */
32
static int proto_gmr1_common;
33
34
35
/* ------------------------------------------------------------------------ */
36
/* Protocol descriptor (see [1] 11.2 & [4] 10.2)                            */
37
/* ------------------------------------------------------------------------ */
38
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 }
47
};
48
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}
57
};
58
59
60
/* ------------------------------------------------------------------------ */
61
/* Common Information Elements                                              */
62
/* ------------------------------------------------------------------------ */
63
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}
70
};
71
value_string_ext gmr1_ie_common_strings_ext = VALUE_STRING_EXT_INIT(gmr1_ie_common_strings);
72
73
int ett_gmr1_ie_common[NUM_GMR1_IE_COMMON];
74
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;
80
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;
96
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 }
104
};
105
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 }
110
};
111
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 }
116
};
117
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 }
124
};
125
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 }
132
};
133
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 }
138
};
139
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 }
144
};
145
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 }
150
};
151
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 }
156
};
157
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 }
162
};
163
164
GMR1_IE_FUNC(gmr1_ie_com_cm2)
165
0
{
166
0
  proto_tree_add_item(tree, hf_com_cm2_spare1,
167
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
168
169
0
  proto_tree_add_item(tree, hf_com_cm2_revision,
170
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
171
172
0
  proto_tree_add_item(tree, hf_com_cm2_early_send,
173
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
174
175
0
  proto_tree_add_item(tree, hf_com_cm2_a5_1,
176
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
177
178
0
  proto_tree_add_item(tree, hf_com_cm2_mes_type,
179
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
180
181
0
  offset++;
182
183
0
  proto_tree_add_item(tree, hf_com_cm2_spare2,
184
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
185
186
0
  proto_tree_add_item(tree, hf_com_cm2_ss_screen_ind,
187
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
188
189
0
  proto_tree_add_item(tree, hf_com_cm2_sms_cap,
190
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
191
192
0
  proto_tree_add_item(tree, hf_com_cm2_spare3,
193
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
194
195
0
  proto_tree_add_item(tree, hf_com_cm2_freq_cap,
196
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
197
198
0
  offset++;
199
200
0
  proto_tree_add_item(tree, hf_com_cm2_cm3_presence,
201
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
202
203
0
  proto_tree_add_item(tree, hf_com_cm2_spare4,
204
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
205
206
0
  proto_tree_add_item(tree, hf_com_cm2_a5_3,
207
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
208
209
0
  proto_tree_add_item(tree, hf_com_cm2_a5_2_gmr1,
210
0
                      tvb, offset, 1, ENC_BIG_ENDIAN);
211
212
0
  offset++;
213
214
0
  return 3;
215
0
}
216
217
/* [1] 11.5.1.8 - Spare Half Octet */
218
GMR1_IE_FUNC(gmr1_ie_com_spare_nibble)
219
0
{
220
0
  proto_tree_add_item(tree, hf_com_spare_nibble, tvb, offset, 1, ENC_BIG_ENDIAN);
221
222
0
  return 1;
223
0
}
224
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 */
228
};
229
230
231
/* ------------------------------------------------------------------------ */
232
/* Messages and IEs parsing                                                 */
233
/* ------------------------------------------------------------------------ */
234
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)
238
1
{
239
1
  switch (pd) {
240
1
  case GMR1_PD_RR:
241
1
    gmr1_get_msg_rr_params(oct, 1, msg_str, ett_tree, hf_idx, msg_func_p);
242
1
    break;
243
244
0
  default:
245
0
    *msg_str = NULL;
246
0
    *ett_tree = -1;
247
0
    *hf_idx = -1;
248
0
    *msg_func_p = NULL;
249
1
  }
250
1
}
251
252
253
/* ------------------------------------------------------------------------ */
254
/* Register code                                                            */
255
/* ------------------------------------------------------------------------ */
256
257
void
258
proto_register_gmr1_common(void)
259
14
{
260
14
  static hf_register_info hf[] = {
261
14
    { &hf_gmr1_skip_ind,
262
14
      { "Skip Indicator", "gmr1.skip_ind",
263
14
        FT_UINT8, BASE_DEC, NULL, 0xf0,
264
14
        NULL, HFILL }
265
14
    },
266
14
    { &hf_gmr1_l3_pd,
267
14
      { "Protocol discriminator","gmr1.l3_protocol_discriminator",
268
14
        FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0f,
269
14
        NULL, HFILL }
270
14
    },
271
14
    { &hf_gmr1_elem_id,
272
14
      { "Element ID", "gmr1.ie.elem_id",
273
14
        FT_UINT8, BASE_HEX, NULL, 0,
274
14
        NULL, HFILL }
275
14
    },
276
14
    { &hf_gmr1_len,
277
14
      { "Length", "gmr1.ie.length",
278
14
        FT_UINT8, BASE_DEC, NULL, 0,
279
14
        NULL, HFILL }
280
14
    },
281
14
    { &hf_com_cm2_spare1,
282
14
      { "Spare", "gmr1.common.cm2.spare1",
283
14
        FT_UINT8, BASE_DEC, NULL, 0x80,
284
14
        NULL, HFILL }
285
14
    },
286
14
    { &hf_com_cm2_revision,
287
14
      { "Revision Level", "gmr1.common.cm2.revision",
288
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_revision_vals), 0x60,
289
14
        NULL, HFILL }
290
14
    },
291
14
    { &hf_com_cm2_early_send,
292
14
      { "ES IND", "gmr1.common.cm2.early_send",
293
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_early_send_vals), 0x10,
294
14
        NULL, HFILL }
295
14
    },
296
14
    { &hf_com_cm2_a5_1,
297
14
      { "A5/1", "gmr1.common.cm2.a5_1",
298
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_a5_1_vals), 0x08,
299
14
        NULL, HFILL }
300
14
    },
301
14
    { &hf_com_cm2_mes_type,
302
14
      { "MES terminal type", "gmr1.common.cm2.mes_type",
303
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_mes_type_vals), 0x07,
304
14
        NULL, HFILL }
305
14
    },
306
14
    { &hf_com_cm2_spare2,
307
14
      { "Spare", "gmr1.common.cm2.spare2",
308
14
        FT_UINT8, BASE_DEC, NULL, 0xc0,
309
14
        NULL, HFILL }
310
14
    },
311
14
    { &hf_com_cm2_ss_screen_ind,
312
14
      { "SS Screening Indicator", "gmr1.common.cm2.ss_screen_ind",
313
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_ss_screen_ind_vals), 0x30,
314
14
        NULL, HFILL }
315
14
    },
316
14
    { &hf_com_cm2_sms_cap,
317
14
      { "SM capability", "gmr1.common.cm2.sms_cap",
318
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_sms_cap_vals), 0x08,
319
14
        NULL, HFILL }
320
14
    },
321
14
    { &hf_com_cm2_spare3,
322
14
      { "Spare", "gmr1.common.cm2.spare3",
323
14
        FT_UINT8, BASE_DEC, NULL, 0x06,
324
14
        NULL, HFILL }
325
14
    },
326
14
    { &hf_com_cm2_freq_cap,
327
14
      { "FC", "gmr1.common.cm2.freq_cap",
328
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_freq_cap_vals), 0x01,
329
14
        NULL, HFILL }
330
14
    },
331
14
    { &hf_com_cm2_cm3_presence,
332
14
      { "CM3", "gmr1.common.cm2.cm3_presence",
333
14
        FT_UINT8, BASE_DEC, VALS(com_cm3_presence_vals), 0x80,
334
14
        NULL, HFILL }
335
14
    },
336
14
    { &hf_com_cm2_spare4,
337
14
      { "Spare", "gmr1.common.cm2.spare4",
338
14
        FT_UINT8, BASE_DEC, NULL, 0x7c,
339
14
        NULL, HFILL }
340
14
    },
341
14
    { &hf_com_cm2_a5_3,
342
14
      { "A5/3", "gmr1.common.cm2.a5_3",
343
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_a5_3_vals), 0x02,
344
14
        NULL, HFILL }
345
14
    },
346
14
    { &hf_com_cm2_a5_2_gmr1,
347
14
      { "A5/2 GMR-1", "gmr1.common.cm2.a5_2_gmr1",
348
14
        FT_UINT8, BASE_DEC, VALS(com_cm2_a5_2_gmr1_vals), 0x01,
349
14
        NULL, HFILL }
350
14
    },
351
14
    { &hf_com_spare_nibble,
352
14
      { "Spare Half Octet", "gmr1.common.spare_nibble",
353
14
        FT_UINT8, BASE_HEX, NULL, 0x0,
354
14
        NULL, HFILL }
355
14
    },
356
14
  };
357
358
  /* Register the protocol name and field description */
359
14
  proto_gmr1_common = proto_register_protocol("GEO-Mobile Radio (1) Common", "GMR-1 Common", "gmr1.common");
360
361
14
  proto_register_field_array(proto_gmr1_common, hf, array_length(hf));
362
14
}
363
364
/*
365
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
366
 *
367
 * Local variables:
368
 * c-basic-offset: 8
369
 * tab-width: 8
370
 * indent-tabs-mode: t
371
 * End:
372
 *
373
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
374
 * :indentSize=8:tabSize=8:noTabs=false:
375
 */