1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
Index: wsutil/encap_util.c
===================================================================
--- wsutil/encap_util.c (revision 26844)
+++ wsutil/encap_util.c (working copy)
@@ -331,6 +331,8 @@
{ 214, WTAP_ENCAP_X2E_XORAYA },
/* IEEE 802.15.4 Wireless PAN non-ASK PHY */
{ 215, WTAP_ENCAP_IEEE802_15_4_NONASK_PHY },
+ { 2342, WTAP_ENCAP_GSMTAP_UM },
+ { 2343, WTAP_ENCAP_GSMTAP_ABIS },
/*
* To repeat:
Index: epan/dissectors/packet-gsmtap.c
===================================================================
--- epan/dissectors/packet-gsmtap.c (revision 0)
+++ epan/dissectors/packet-gsmtap.c (revision 0)
@@ -0,0 +1,256 @@
+/* packet-gsmtap.c
+ * Routines for GSMTAP captures
+ *
+ * (C) 2008 by Harald Welte <laforge@gnumonks.org>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/prefs.h>
+
+#include "packet-gsmtap.h"
+
+static int proto_gsmtap = -1;
+
+static int hf_gsmtap_version = -1;
+static int hf_gsmtap_hdrlen = -1;
+static int hf_gsmtap_type = -1;
+static int hf_gsmtap_timeslot = -1;
+static int hf_gsmtap_arfcn = -1;
+static int hf_gsmtap_noise_db = -1;
+static int hf_gsmtap_signal_db = -1;
+static int hf_gsmtap_frame_nr = -1;
+static int hf_gsmtap_burst_type = -1;
+static int hf_gsmtap_antenna = -1;
+
+static gint ett_gsmtap = -1;
+
+enum {
+ SUB_DATA = 0,
+ SUB_UM,
+ SUB_ABIS,
+
+ SUB_MAX
+};
+
+typedef gboolean (*sub_checkfunc_t)(packet_info *);
+
+static dissector_handle_t sub_handles[SUB_MAX];
+
+static const char *gsmtap_bursts[] = {
+ [GSMTAP_BURST_UNKNOWN] = "UNKNOWN",
+ [GSMTAP_BURST_FCCH] = "FCCH",
+ [GSMTAP_BURST_PARTIAL_SCH] = "PARTIAL_SCH",
+ [GSMTAP_BURST_SCH] = "SCH",
+ [GSMTAP_BURST_CTS_SCH] = "CTS_SCH",
+ [GSMTAP_BURST_COMPACT_SCH] = "COMPACT_SCH",
+ [GSMTAP_BURST_NORMAL] = "NORMAL",
+ [GSMTAP_BURST_DUMMY] = "DUMMY",
+ [GSMTAP_BURST_ACCESS] = "ACCESS",
+};
+
+static const char *gsmtap_get_burst(unsigned int burst_type)
+{
+ const char *desc = "UNSUPPORTED";
+
+ if (burst_type >= sizeof(gsmtap_bursts)/sizeof(const char *))
+ return desc;
+ if (gsmtap_bursts[burst_type] == NULL)
+ return desc;
+
+ return gsmtap_bursts[burst_type];
+}
+
+static const char *gsmtap_get_type(int type)
+{
+ const char *desc;
+
+ switch (type) {
+ case GSMTAP_TYPE_UM:
+ desc = "GSM Um (MS<->BTS)";
+ break;
+ case GSMTAP_TYPE_ABIS:
+ desc = "GSM Abis (BTS<->BSC)";
+ break;
+ case GSMTAP_TYPE_UM_BURST:
+ desc = "GSM Um burst (BTS<->BSC)";
+ break;
+ default:
+ desc = "<unknown type>";
+ break;
+ }
+
+ return desc;
+}
+
+static void
+dissect_gsmtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ int sub_handle, len, offset = 0;
+ proto_item *ti;
+ proto_tree *gsmtap_tree = NULL;
+ tvbuff_t *payload_tvb;
+
+ u_int8_t version, hdr_len, type, ts, noise_db, signal_db;
+ u_int8_t burst_type, antenna;
+ u_int16_t arfcn;
+ u_int32_t frame_nr;
+
+ len = tvb_length(tvb);
+
+ //pinfo->ptype = PT_I2C;
+
+ version = tvb_get_guint8(tvb, offset + 0);
+ hdr_len = tvb_get_guint8(tvb, offset + 1) <<2;
+ type = tvb_get_guint8(tvb, offset + 2);
+ ts = tvb_get_guint8(tvb, offset + 3);
+
+ arfcn = tvb_get_ntohs(tvb, offset + 4);
+ noise_db = tvb_get_guint8(tvb, offset + 6);
+ signal_db = tvb_get_guint8(tvb, offset + 7);
+
+ frame_nr = tvb_get_ntohl(tvb, offset + 8);
+
+ burst_type = tvb_get_guint8(tvb, offset + 12);
+ antenna = tvb_get_guint8(tvb, offset + 13);
+
+ payload_tvb = tvb_new_subset(tvb, hdr_len, len-hdr_len, len-hdr_len);
+
+#if 0
+ if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
+ if (is_event)
+ col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "I2C Event");
+ else
+ col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "I2C %s",
+ (flags & I2C_FLAG_RD) ? "Read" : "Write");
+ }
+
+ if (check_col(pinfo->cinfo, COL_DEF_SRC)) {
+ col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "I2C-%d", bus);
+ }
+
+ if (check_col(pinfo->cinfo, COL_DEF_DST)) {
+ if (is_event)
+ col_add_fstr(pinfo->cinfo, COL_DEF_DST, "----");
+ else
+ col_add_fstr(pinfo->cinfo, COL_DEF_DST, "0x%02x", addr);
+ }
+
+#endif
+ if (check_col(pinfo->cinfo, COL_INFO)) {
+ col_add_fstr(pinfo->cinfo, COL_INFO, "GSM TAP, %d bytes", len);
+ }
+
+ if (tree) {
+ ti = proto_tree_add_protocol_format(tree, proto_gsmtap, tvb,
+ 0, hdr_len,
+ "GSM TAP Header");
+ gsmtap_tree = proto_item_add_subtree(ti, ett_gsmtap);
+ proto_tree_add_item(gsmtap_tree, hf_gsmtap_version,
+ tvb, offset, 1, FALSE);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_hdrlen,
+ tvb, offset+1, 1, hdr_len,
+ "Header length: %u bytes", hdr_len);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_type,
+ tvb, offset+2, 1, type,
+ "Type: %s (0x%02x)",
+ gsmtap_get_type(type), type);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_burst_type,
+ tvb, offset+12, 1, burst_type,
+ "Burst: %s",
+ gsmtap_get_burst(burst_type));
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_arfcn,
+ tvb, offset+4, 2, arfcn,
+ "ARFCN: %u", arfcn);
+ proto_tree_add_item(gsmtap_tree, hf_gsmtap_timeslot,
+ tvb, offset+3, 1, FALSE);
+ proto_tree_add_item(gsmtap_tree, hf_gsmtap_antenna,
+ tvb, offset+13, 1, FALSE);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_noise_db,
+ tvb, offset+6, 1, noise_db,
+ "Noise level: %u dB", noise_db);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_signal_db,
+ tvb, offset+7, 1, signal_db,
+ "Signal level: %u dB", signal_db);
+ proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_frame_nr,
+ tvb, offset+8, 4, frame_nr,
+ "Frame Number: %u", frame_nr);
+ }
+ switch (type) {
+ case GSMTAP_TYPE_UM:
+ switch (burst_type) {
+ case GSMTAP_BURST_NORMAL:
+ sub_handle = SUB_UM;
+ break;
+ default:
+ sub_handle = SUB_DATA;
+ break;
+ }
+ break;
+ case GSMTAP_TYPE_UM_BURST:
+ default:
+ sub_handle = SUB_DATA;
+ break;
+ }
+ call_dissector(sub_handles[sub_handle], payload_tvb, pinfo, tree);
+}
+
+void
+proto_register_gsmtap(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_gsmtap_version, { "Version", "gsmtap.version", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_hdrlen, { "Header Length", "gsmtap.hdr_len", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_type, { "Type", "gsmtap.type", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_timeslot, { "Time Slot", "gsmtap.ts", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_arfcn, { "ARFCN", "gsmtap.arfcn", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_noise_db, { "Noise dB", "gsmtap.noise_db", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_signal_db, { "Signal dB", "gsmtap.signal_db", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_frame_nr, { "Frame Number", "gsmtap.frame_nr", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_burst_type, { "Burst Type", "gsmtap.burst_type", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ { &hf_gsmtap_antenna, { "Antenna Number", "gsmtap.antenna", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL }},
+ };
+ static gint *ett[] = {
+ &ett_gsmtap
+ };
+
+ proto_gsmtap = proto_register_protocol("GSM Radiotap", "GSMTAP", "gsmtap");
+ proto_register_field_array(proto_gsmtap, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+void
+proto_reg_handoff_gsmtap(void)
+{
+ dissector_handle_t gsmtap_handle;
+
+ sub_handles[SUB_DATA] = find_dissector("data");
+ sub_handles[SUB_UM] = find_dissector("gsm_a_ccch");
+ sub_handles[SUB_ABIS] = find_dissector("gsm_a_dtap");
+ gsmtap_handle = create_dissector_handle(dissect_gsmtap, proto_gsmtap);
+ dissector_add("wtap_encap", WTAP_ENCAP_GSMTAP_UM, gsmtap_handle);
+}
Index: epan/dissectors/packet-gsmtap.h
===================================================================
--- epan/dissectors/packet-gsmtap.h (revision 0)
+++ epan/dissectors/packet-gsmtap.h (revision 0)
@@ -0,0 +1,41 @@
+#ifndef _GSMTAP_H
+#define _GSMTAP_H
+
+/* gsmtap header, pseudo-header in front of the actua GSM payload*/
+
+#include <sys/types.h>
+
+#define GSMTAP_VERSION 0x01
+
+#define GSMTAP_TYPE_UM 0x01
+#define GSMTAP_TYPE_ABIS 0x02
+#define GSMTAP_TYPE_UM_BURST 0x03 /* raw burst bits */
+
+#define GSMTAP_BURST_UNKNOWN 0x00
+#define GSMTAP_BURST_FCCH 0x01
+#define GSMTAP_BURST_PARTIAL_SCH 0x02
+#define GSMTAP_BURST_SCH 0x03
+#define GSMTAP_BURST_CTS_SCH 0x04
+#define GSMTAP_BURST_COMPACT_SCH 0x05
+#define GSMTAP_BURST_NORMAL 0x06
+#define GSMTAP_BURST_DUMMY 0x07
+#define GSMTAP_BURST_ACCESS 0x08
+
+struct gsmtap_hdr {
+ u_int8_t version; /* version, set to 0x01 currently */
+ u_int8_t hdr_len; /* length in number of 32bit words */
+ u_int8_t type; /* see GSMTAP_TYPE_* */
+ u_int8_t timeslot; /* timeslot (0..7 on Um) */
+
+ u_int16_t arfcn; /* ARFCN (frequency) */
+ u_int8_t noise_db; /* noise figure in dB */
+ u_int8_t signal_db; /* signal level in dB */
+
+ u_int32_t frame_number; /* GSM Frame Number (FN) */
+
+ u_int8_t burst_type; /* Type of burst, see above */
+ u_int8_t antenna_nr; /* Antenna Number */
+ u_int16_t res; /* reserved for future use (RFU) */
+
+} __attribute__((packed));
+#endif /* _GSMTAP_H */
Index: epan/dissectors/Makefile.common
===================================================================
--- epan/dissectors/Makefile.common (revision 26844)
+++ epan/dissectors/Makefile.common (working copy)
@@ -453,6 +453,7 @@
packet-gsm_bssmap_le.c \
packet-gsm_sms.c \
packet-gsm_sms_ud.c \
+ packet-gsmtap.c \
packet-gssapi.c \
packet-gtp.c \
packet-gvrp.c \
@@ -974,6 +975,7 @@
packet-gsm_a_common.h \
packet-gsm_map.h \
packet-gsm_sms.h \
+ packet-gsmtap.h \
packet-gssapi.h \
packet-gtp.h \
packet-h223.h \
Index: wiretap/wtap.c
===================================================================
--- wiretap/wtap.c (revision 26844)
+++ wiretap/wtap.c (working copy)
@@ -430,7 +430,13 @@
{ "I2C", "i2c" },
/* WTAP_ENCAP_IEEE802_15_4_NONASK_PHY */
- { "IEEE 802.15.4 Wireless PAN non-ASK PHY", "wpan-nonask-phy" }
+ { "IEEE 802.15.4 Wireless PAN non-ASK PHY", "wpan-nonask-phy" },
+
+ /* WTAP_GSMTAP_UM */
+ { "GSMTAP Um Interface (MS<->BTS)", "gsmtap-um" },
+
+ /* WTAP_GSMTAP_ABIS */
+ { "GSMTAP Abis Interface (BTS<->BSC)", "gsmtap-abis" }
};
gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info);
Index: wiretap/wtap.h
===================================================================
--- wiretap/wtap.h (revision 26844)
+++ wiretap/wtap.h (working copy)
@@ -204,6 +204,8 @@
#define WTAP_ENCAP_X2E_SERIAL 111
#define WTAP_ENCAP_I2C 112
#define WTAP_ENCAP_IEEE802_15_4_NONASK_PHY 113
+#define WTAP_ENCAP_GSMTAP_UM 114
+#define WTAP_ENCAP_GSMTAP_ABIS 115
#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()
|