Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-gmr1_dtap.c
Line
Count
Source
1
/* packet-gmr1_dtap.c
2
 *
3
 * Routines for GMR-1 DTAP dissection in wireshark.
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
 *
11
 * Wireshark - Network traffic analyzer
12
 * By Gerald Combs <gerald@wireshark.org>
13
 * Copyright 1998 Gerald Combs
14
 *
15
 * SPDX-License-Identifier: GPL-2.0-or-later
16
 */
17
18
#include "config.h"
19
20
#include <epan/packet.h>
21
22
#include "packet-gmr1_common.h"
23
24
void proto_register_gmr1_dtap(void);
25
void proto_reg_handoff_gmr1_dtap(void);
26
27
/* GMR-1 DTAP proto */
28
static int proto_gmr1_dtap;
29
30
static int hf_gmr1_dtap_protocol_discriminator;
31
static int hf_gmr1_dtap_message_elements;
32
33
/* GMR-1 DTAP sub tree */
34
static int ett_gmr1_dtap;
35
static int ett_gmr1_pd;
36
37
/* Handoffs */
38
static dissector_handle_t gsm_dtap_handle;
39
static dissector_handle_t dtap_handle;
40
41
42
static int
43
dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
44
0
{
45
0
  uint32_t len, offset;
46
0
  gmr1_msg_func_t msg_func;
47
0
  const char *msg_str;
48
0
  int ett_tree;
49
0
  int hf_idx;
50
0
  proto_item *dtap_item = NULL/*, *pd_item = NULL*/;
51
0
  proto_tree *dtap_tree = NULL/*, *pd_tree = NULL*/;
52
0
  uint32_t oct[2];
53
0
  uint8_t pd;
54
55
  /* Scan init */
56
0
  len = tvb_captured_length(tvb);
57
0
  offset = 0;
58
59
  /* Protocol descriptor */
60
0
  oct[0] = tvb_get_uint8(tvb, offset++);
61
62
0
  if ((oct[0] & GMR1_PD_EXT_MSK) == GMR1_PD_EXT_VAL)
63
0
    pd = oct[0] & 0xff;
64
0
  else
65
0
    pd = oct[0] & 0x0f;
66
67
  /* HACK: Quick delegation hack to GSM */
68
0
  if (pd != GMR1_PD_RR) {
69
0
    call_dissector(gsm_dtap_handle, tvb, pinfo, tree);
70
0
    return tvb_captured_length(tvb);
71
0
  }
72
73
  /* Fill up some info */
74
0
  col_append_str(pinfo->cinfo, COL_INFO, " (DTAP) ");
75
76
0
  col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ",
77
0
    val_to_str(pinfo->pool, pd, gmr1_pd_short_vals, "Unknown (%u)"));
78
79
  /* Get message parameters */
80
0
  oct[1] = tvb_get_uint8(tvb, offset);
81
82
0
  gmr1_get_msg_params((gmr1_pd_e)pd, oct[1], &msg_str, &ett_tree, &hf_idx, &msg_func);
83
84
  /* Create protocol tree */
85
0
  if (msg_str == NULL)
86
0
  {
87
0
    dtap_item = proto_tree_add_protocol_format(
88
0
      tree, proto_gmr1_dtap, tvb, 0, len,
89
0
      "GMR-1 DTAP - Message Type (0x%02x)", oct[1]);
90
0
    dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
91
92
0
    col_append_fstr(pinfo->cinfo, COL_INFO, "Message Type (0x%02x) ", oct[1]);
93
0
  }
94
0
  else
95
0
  {
96
0
    dtap_item = proto_tree_add_protocol_format(
97
0
      tree, proto_gmr1_dtap, tvb, 0, -1,
98
0
      "GMR-1 DTAP - %s", msg_str);
99
0
    dtap_tree = proto_item_add_subtree(dtap_item, ett_gmr1_dtap);
100
101
0
    col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", msg_str);
102
0
  }
103
104
  /* Start over */
105
0
  offset = 0;
106
107
  /* Protocol discriminator item */
108
  /*pd_item =*/ proto_tree_add_uint(
109
0
    dtap_tree, hf_gmr1_dtap_protocol_discriminator, tvb, 0, 1, pd);
110
111
  /*pd_tree = proto_item_add_subtree(pd_item, ett_gmr1_pd);*/
112
113
    /* Move on */
114
0
  offset++;
115
116
  /* Message type - [1] 11.4 */
117
0
  proto_tree_add_uint_format(
118
0
    dtap_tree, hf_idx, tvb, offset, 1, oct[1],
119
0
    "Message Type: %s", msg_str ? msg_str : "(Unknown)"
120
0
  );
121
122
0
  offset++;
123
124
  /* Decode elements */
125
0
  if (msg_func) {
126
0
    (*msg_func)(tvb, dtap_tree, pinfo, offset, len - offset);
127
0
  } else {
128
0
    proto_tree_add_item(dtap_tree, hf_gmr1_dtap_message_elements, tvb, offset, len - offset, ENC_NA);
129
0
  }
130
131
  /* Done ! */
132
0
  return tvb_captured_length(tvb);
133
0
}
134
135
136
void
137
proto_register_gmr1_dtap(void)
138
16
{
139
16
  static hf_register_info hf[] = {
140
16
    { &hf_gmr1_dtap_protocol_discriminator,
141
16
      { "Protocol Discriminator", "gmr1.dtap.protocol_discriminator",
142
16
      FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0,
143
16
      NULL, HFILL }
144
16
    },
145
16
    { &hf_gmr1_dtap_message_elements,
146
16
      { "Message elements", "gmr1.dtap.message_elements",
147
16
      FT_BYTES, BASE_NONE, NULL, 0x0,
148
16
      NULL, HFILL }
149
16
    },
150
16
  };
151
152
16
  static int *ett[] = {
153
16
    &ett_gmr1_dtap,
154
16
    &ett_gmr1_pd,
155
16
  };
156
157
  /* Setup protocol subtree array */
158
16
  proto_register_subtree_array(ett, array_length(ett));
159
160
  /* Register the protocol name and field description */
161
16
  proto_gmr1_dtap = proto_register_protocol("GEO-Mobile Radio (1) DTAP", "GMR-1 DTAP", "gmr1.dtap");
162
16
  proto_register_field_array(proto_gmr1_dtap, hf, array_length(hf));
163
164
  /* Register dissector */
165
16
  dtap_handle = register_dissector("gmr1_dtap", dissect_gmr1_dtap, proto_gmr1_dtap);
166
16
}
167
168
void
169
proto_reg_handoff_gmr1_dtap(void)
170
16
{
171
16
  dissector_add_uint("lapsat.sapi", 0 , dtap_handle); /* LAPSat: CC/RR/MM */
172
16
  dissector_add_uint("lapsat.sapi", 3 , dtap_handle); /* LAPSat: SMS/SS */
173
174
16
  gsm_dtap_handle = find_dissector_add_dependency("gsm_a_dtap", proto_gmr1_dtap);
175
16
}
176
177
/*
178
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
179
 *
180
 * Local variables:
181
 * c-basic-offset: 8
182
 * tab-width: 8
183
 * indent-tabs-mode: t
184
 * End:
185
 *
186
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
187
 * :indentSize=8:tabSize=8:noTabs=false:
188
 */