1 Index: epan/dissectors/packet-gsmtap.c
2 ===================================================================
4 +++ epan/dissectors/packet-gsmtap.c
7 + * Routines for GSMTAP captures
9 + * (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
13 + * Wireshark - Network traffic analyzer
14 + * By Gerald Combs <gerald@wireshark.org>
15 + * Copyright 1998 Gerald Combs
17 + * This program is free software; you can redistribute it and/or
18 + * modify it under the terms of the GNU General Public License
19 + * as published by the Free Software Foundation; either version 2
20 + * of the License, or (at your option) any later version.
22 + * This program is distributed in the hope that it will be useful,
23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 + * GNU General Public License for more details.
27 + * You should have received a copy of the GNU General Public License
28 + * along with this program; if not, write to the Free Software
29 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 +/* GSMTAP is a generic header format for GSM protocol captures,
35 + * it uses the IANA-assigned UDP port number 4729 and carries
36 + * payload in various formats of GSM interfaces such as Um MAC
37 + * blocks or Um bursts.
39 + * Example programs generating GSMTAP data are airprobe
40 + * (http://airprobe.org/) or OsmocomBB (http://bb.osmocom.org/)
48 +#include <epan/packet.h>
49 +#include <epan/prefs.h>
51 +#include "packet-gsmtap.h"
53 +static int proto_gsmtap = -1;
55 +static int hf_gsmtap_version = -1;
56 +static int hf_gsmtap_hdrlen = -1;
57 +static int hf_gsmtap_type = -1;
58 +static int hf_gsmtap_timeslot = -1;
59 +static int hf_gsmtap_subslot = -1;
60 +static int hf_gsmtap_arfcn = -1;
61 +static int hf_gsmtap_uplink = -1;
62 +static int hf_gsmtap_noise_dbm = -1;
63 +static int hf_gsmtap_signal_dbm = -1;
64 +static int hf_gsmtap_frame_nr = -1;
65 +static int hf_gsmtap_burst_type = -1;
66 +static int hf_gsmtap_channel_type = -1;
67 +static int hf_gsmtap_antenna = -1;
69 +static int hf_sacch_l1h_power_lev = -1;
70 +static int hf_sacch_l1h_fpc = -1;
71 +static int hf_sacch_l1h_ta = -1;
73 +static gint ett_gsmtap = -1;
76 + GSMTAP_SUB_DATA = 0,
78 + GSMTAP_SUB_UM_LAPDM,
84 +static dissector_handle_t sub_handles[GSMTAP_SUB_MAX];
86 +static const value_string gsmtap_bursts[] = {
87 + { GSMTAP_BURST_UNKNOWN, "UNKNOWN" },
88 + { GSMTAP_BURST_FCCH, "FCCH" },
89 + { GSMTAP_BURST_PARTIAL_SCH, "PARTIAL SCH" },
90 + { GSMTAP_BURST_SCH, "SCH" },
91 + { GSMTAP_BURST_CTS_SCH, "CTS SCH" },
92 + { GSMTAP_BURST_COMPACT_SCH, "COMPACT SCH" },
93 + { GSMTAP_BURST_NORMAL, "NORMAL" },
94 + { GSMTAP_BURST_DUMMY, "DUMMY" },
95 + { GSMTAP_BURST_ACCESS, "RACH" },
99 +static const value_string gsmtap_channels[] = {
100 + { GSMTAP_CHANNEL_UNKNOWN, "UNKNOWN" },
101 + { GSMTAP_CHANNEL_BCCH, "BCCH" },
102 + { GSMTAP_CHANNEL_CCCH, "CCCH" },
103 + { GSMTAP_CHANNEL_RACH, "RACH" },
104 + { GSMTAP_CHANNEL_AGCH, "AGCH" },
105 + { GSMTAP_CHANNEL_PCH, "PCH" },
106 + { GSMTAP_CHANNEL_SDCCH, "SDCCH" },
107 + { GSMTAP_CHANNEL_SDCCH4, "SDCCH/4" },
108 + { GSMTAP_CHANNEL_SDCCH8, "SDCCH/8" },
109 + { GSMTAP_CHANNEL_TCH_F, "FACCH/F" },
110 + { GSMTAP_CHANNEL_TCH_H, "FACCH/H" },
111 + { GSMTAP_CHANNEL_ACCH|
112 + GSMTAP_CHANNEL_SDCCH, "LSACCH" },
113 + { GSMTAP_CHANNEL_ACCH|
114 + GSMTAP_CHANNEL_SDCCH4, "SACCH/4" },
115 + { GSMTAP_CHANNEL_ACCH|
116 + GSMTAP_CHANNEL_SDCCH8, "SACCH/8" },
117 + { GSMTAP_CHANNEL_ACCH|
118 + GSMTAP_CHANNEL_TCH_F, "SACCH/F" },
119 + { GSMTAP_CHANNEL_ACCH|
120 + GSMTAP_CHANNEL_TCH_F, "SACCH/H" },
124 +static const value_string gsmtap_types[] = {
125 + { GSMTAP_TYPE_UM, "GSM Um (MS<->BTS)" },
126 + { GSMTAP_TYPE_ABIS, "GSM Abis (BTS<->BSC)" },
127 + { GSMTAP_TYPE_UM_BURST, "GSM Um burst (MS<->BTS)" },
131 +/* dissect a SACCH L1 header which is included in the first 2 bytes
132 + * of every SACCH frame (according to TS 04.04) */
134 +dissect_sacch_l1h(tvbuff_t *tvb, proto_tree *tree)
137 + proto_tree *l1h_tree = NULL;
142 + ti = proto_tree_add_protocol_format(tree, proto_gsmtap, tvb, 0, 2,
143 + "SACCH L1 Header, Power Level: %u, Timing Advance: %u",
144 + tvb_get_guint8(tvb, 0) & 0x1f,
145 + tvb_get_guint8(tvb, 1));
146 + l1h_tree = proto_item_add_subtree(ti, ett_gsmtap);
148 + proto_tree_add_item(l1h_tree, hf_sacch_l1h_power_lev, tvb, 0, 1, FALSE);
149 + /* Fast Power Control */
150 + proto_tree_add_item(l1h_tree, hf_sacch_l1h_fpc, tvb, 0, 1, FALSE);
151 + /* Acutal Timing Advance */
152 + proto_tree_add_item(l1h_tree, hf_sacch_l1h_ta, tvb, 1, 1, FALSE);
155 +/* dissect a GSMTAP header and hand payload off to respective dissector */
157 +dissect_gsmtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
159 + int sub_handle, len, offset = 0;
161 + proto_tree *gsmtap_tree = NULL;
162 + tvbuff_t *payload_tvb, *l1h_tvb = NULL;
163 + guint8 hdr_len, type, sub_type;
166 + len = tvb_length(tvb);
168 + hdr_len = tvb_get_guint8(tvb, offset + 1) <<2;
169 + type = tvb_get_guint8(tvb, offset + 2);
170 + sub_type = tvb_get_guint8(tvb, offset + 12);
171 + arfcn = tvb_get_ntohs(tvb, offset + 4);
173 + /* In case of a SACCH, there is a two-byte L1 header in front
174 + * of the packet (see TS 04.04) */
175 + if (type == GSMTAP_TYPE_UM &&
176 + sub_type & GSMTAP_CHANNEL_ACCH) {
177 + l1h_tvb = tvb_new_subset(tvb, hdr_len, 2, 2);
178 + payload_tvb = tvb_new_subset(tvb, hdr_len+2, len-(hdr_len+2),
181 + payload_tvb = tvb_new_subset(tvb, hdr_len, len-hdr_len,
185 + /* We don't want any UDP related info left in the INFO field, as the
186 + * gsm_a_dtap dissector will not clear but only append */
187 + col_clear(pinfo->cinfo, COL_INFO);
189 + col_set_str(pinfo->cinfo, COL_PROTOCOL, "GSMTAP");
191 + if (arfcn & GSMTAP_ARFCN_F_UPLINK) {
192 + col_append_str(pinfo->cinfo, COL_RES_NET_SRC, "MS");
193 + col_append_str(pinfo->cinfo, COL_RES_NET_DST, "BTS");
194 + /* p2p_dir is used by the LAPDm dissector */
195 + pinfo->p2p_dir = P2P_DIR_SENT;
197 + col_set_str(pinfo->cinfo, COL_RES_NET_SRC, "BTS");
198 + switch (sub_type & ~GSMTAP_CHANNEL_ACCH) {
199 + case GSMTAP_CHANNEL_BCCH:
200 + case GSMTAP_CHANNEL_CCCH:
201 + case GSMTAP_CHANNEL_PCH:
202 + case GSMTAP_CHANNEL_AGCH:
203 + col_set_str(pinfo->cinfo, COL_RES_NET_DST, "Broadcast");
206 + col_set_str(pinfo->cinfo, COL_RES_NET_DST, "MS");
209 + /* p2p_dir is used by the LAPDm dissector */
210 + pinfo->p2p_dir = P2P_DIR_RECV;
214 + ti = proto_tree_add_protocol_format(tree, proto_gsmtap, tvb, 0, hdr_len,
215 + "GSM TAP Header, ARFCN: %u (%s), TS: %u, Channel: %s (%u)",
216 + arfcn & GSMTAP_ARFCN_MASK,
217 + arfcn & GSMTAP_ARFCN_F_UPLINK ? "Uplink" : "Downlink",
218 + tvb_get_guint8(tvb, offset+3),
219 + match_strval(tvb_get_guint8(tvb, offset+12), gsmtap_channels),
220 + tvb_get_guint8(tvb, offset+14));
221 + gsmtap_tree = proto_item_add_subtree(ti, ett_gsmtap);
222 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_version,
223 + tvb, offset, 1, FALSE);
224 + proto_tree_add_uint_format(gsmtap_tree, hf_gsmtap_hdrlen,
225 + tvb, offset+1, 1, hdr_len,
226 + "Header length: %u bytes", hdr_len);
227 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_type,
228 + tvb, offset+2, 1, FALSE);
229 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_timeslot,
230 + tvb, offset+3, 1, FALSE);
231 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_arfcn,
232 + tvb, offset+4, 2, FALSE);
233 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_uplink,
234 + tvb, offset+4, 2, FALSE);
235 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_noise_dbm,
236 + tvb, offset+6, 1, FALSE);
237 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_signal_dbm,
238 + tvb, offset+7, 1, FALSE);
239 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_frame_nr,
240 + tvb, offset+8, 4, FALSE);
241 + if (type == GSMTAP_TYPE_UM_BURST)
242 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_burst_type,
243 + tvb, offset+12, 1, FALSE);
244 + else if (type == GSMTAP_TYPE_UM)
245 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_channel_type,
246 + tvb, offset+12, 1, FALSE);
247 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_antenna,
248 + tvb, offset+13, 1, FALSE);
249 + proto_tree_add_item(gsmtap_tree, hf_gsmtap_subslot,
250 + tvb, offset+14, 1, FALSE);
254 + case GSMTAP_TYPE_UM:
256 + dissect_sacch_l1h(l1h_tvb, tree);
257 + switch (sub_type & ~GSMTAP_CHANNEL_ACCH) {
258 + case GSMTAP_CHANNEL_BCCH:
259 + case GSMTAP_CHANNEL_CCCH:
260 + case GSMTAP_CHANNEL_PCH:
261 + case GSMTAP_CHANNEL_AGCH:
262 + /* FIXME: we might want to skip idle frames */
263 + sub_handle = GSMTAP_SUB_UM;
265 + case GSMTAP_CHANNEL_SDCCH:
266 + case GSMTAP_CHANNEL_SDCCH4:
267 + case GSMTAP_CHANNEL_SDCCH8:
268 + case GSMTAP_CHANNEL_TCH_F:
269 + case GSMTAP_CHANNEL_TCH_H:
270 + sub_handle = GSMTAP_SUB_UM_LAPDM;
272 + case GSMTAP_CHANNEL_RACH:
274 + sub_handle = GSMTAP_SUB_DATA;
278 + case GSMTAP_TYPE_UM_BURST:
280 + sub_handle = GSMTAP_SUB_DATA;
283 + call_dissector(sub_handles[sub_handle], payload_tvb, pinfo, tree);
286 +static const true_false_string sacch_l1h_fpc_mode_vals = {
292 +proto_register_gsmtap(void)
294 + static hf_register_info hf[] = {
295 + { &hf_gsmtap_version, { "Version", "gsmtap.version",
296 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
297 + { &hf_gsmtap_hdrlen, { "Header Length", "gsmtap.hdr_len",
298 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
299 + { &hf_gsmtap_type, { "Payload Type", "gsmtap.type",
300 + FT_UINT8, BASE_DEC, VALS(gsmtap_types), 0, NULL, HFILL } },
301 + { &hf_gsmtap_timeslot, { "Time Slot", "gsmtap.ts",
302 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
303 + { &hf_gsmtap_arfcn, { "ARFCN", "gsmtap.arfcn",
304 + FT_UINT16, BASE_DEC, NULL, GSMTAP_ARFCN_MASK, NULL, HFILL } },
305 + { &hf_gsmtap_uplink, { "Uplink", "gsmtap.uplink",
306 + FT_UINT16, BASE_DEC, NULL, GSMTAP_ARFCN_F_UPLINK, NULL, HFILL } },
307 + { &hf_gsmtap_noise_dbm, { "Signal/Noise Ratio (dB)", "gsmtap.snr_db",
308 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
309 + { &hf_gsmtap_signal_dbm, { "Signal Level (dBm)", "gsmtap.signal_dbm",
310 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
311 + { &hf_gsmtap_frame_nr, { "GSM Frame Number", "gsmtap.frame_nr",
312 + FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL } },
313 + { &hf_gsmtap_burst_type, { "Burst Type", "gsmtap.burst_type",
314 + FT_UINT8, BASE_DEC, VALS(gsmtap_bursts), 0, NULL, HFILL }},
315 + { &hf_gsmtap_channel_type, { "Channel Type", "gsmtap.chan_type",
316 + FT_UINT8, BASE_DEC, VALS(gsmtap_channels), 0, NULL, HFILL }},
317 + { &hf_gsmtap_antenna, { "Antenna Number", "gsmtap.antenna",
318 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
319 + { &hf_gsmtap_subslot, { "Sub-Slot", "gsmtap.sub_slot",
320 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
322 + { &hf_sacch_l1h_power_lev, { "MS power level", "gsmtap.sacch_l1.power_lev",
323 + FT_UINT8, BASE_DEC, NULL, 0x1f, NULL, HFILL } },
324 + { &hf_sacch_l1h_fpc, { "FPC", "gsmtap.sacch_l1.fpc",
325 + FT_BOOLEAN, 8, TFS(&sacch_l1h_fpc_mode_vals), 0x04,
327 + { &hf_sacch_l1h_ta, { "Actual Timing Advance", "gsmtap.sacch_l1.ta",
328 + FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
330 + static gint *ett[] = {
334 + proto_gsmtap = proto_register_protocol("GSM Radiotap", "GSMTAP", "gsmtap");
335 + proto_register_field_array(proto_gsmtap, hf, array_length(hf));
336 + proto_register_subtree_array(ett, array_length(ett));
340 +proto_reg_handoff_gsmtap(void)
342 + dissector_handle_t gsmtap_handle;
344 + sub_handles[GSMTAP_SUB_DATA] = find_dissector("data");
345 + sub_handles[GSMTAP_SUB_UM] = find_dissector("gsm_a_ccch");
346 + sub_handles[GSMTAP_SUB_UM_LAPDM] = find_dissector("lapdm");
347 + sub_handles[GSMTAP_SUB_ABIS] = find_dissector("gsm_a_dtap");
348 + gsmtap_handle = create_dissector_handle(dissect_gsmtap, proto_gsmtap);
349 + dissector_add("udp.port", GSMTAP_UDP_PORT, gsmtap_handle);
351 Index: epan/dissectors/packet-gsmtap.h
352 ===================================================================
354 +++ epan/dissectors/packet-gsmtap.h
359 +/* gsmtap header, pseudo-header in front of the actua/ GSM payload */
361 +/* GSMTAP is a generic header format for GSM protocol captures,
362 + * it uses the IANA-assigned UDP port number 4729 and carries
363 + * payload in various formats of GSM interfaces such as Um MAC
364 + * blocks or Um bursts.
366 + * Example programs generating GSMTAP data are airprobe
367 + * (http://airprobe.org/) or OsmocomBB (http://bb.osmocom.org/)
370 +#define GSMTAP_TYPE_UM 0x01
371 +#define GSMTAP_TYPE_ABIS 0x02
372 +#define GSMTAP_TYPE_UM_BURST 0x03 /* raw burst bits */
374 +#define GSMTAP_BURST_UNKNOWN 0x00
375 +#define GSMTAP_BURST_FCCH 0x01
376 +#define GSMTAP_BURST_PARTIAL_SCH 0x02
377 +#define GSMTAP_BURST_SCH 0x03
378 +#define GSMTAP_BURST_CTS_SCH 0x04
379 +#define GSMTAP_BURST_COMPACT_SCH 0x05
380 +#define GSMTAP_BURST_NORMAL 0x06
381 +#define GSMTAP_BURST_DUMMY 0x07
382 +#define GSMTAP_BURST_ACCESS 0x08
383 +#define GSMTAP_BURST_NONE 0x09
385 +#define GSMTAP_CHANNEL_UNKNOWN 0x00
386 +#define GSMTAP_CHANNEL_BCCH 0x01
387 +#define GSMTAP_CHANNEL_CCCH 0x02
388 +#define GSMTAP_CHANNEL_RACH 0x03
389 +#define GSMTAP_CHANNEL_AGCH 0x04
390 +#define GSMTAP_CHANNEL_PCH 0x05
391 +#define GSMTAP_CHANNEL_SDCCH 0x06
392 +#define GSMTAP_CHANNEL_SDCCH4 0x07
393 +#define GSMTAP_CHANNEL_SDCCH8 0x08
394 +#define GSMTAP_CHANNEL_TCH_F 0x09
395 +#define GSMTAP_CHANNEL_TCH_H 0x0a
396 +#define GSMTAP_CHANNEL_ACCH 0x80
398 +#define GSMTAP_ARFCN_F_PCS 0x8000
399 +#define GSMTAP_ARFCN_F_UPLINK 0x4000
400 +#define GSMTAP_ARFCN_MASK 0x3fff
402 +#define GSMTAP_UDP_PORT 4729
404 +/* This is the header as it is used by gsmtap-generating software.
405 + * It is not used by the wireshark dissector and provided for reference only.
407 + guint8 version; // version, set to 0x01 currently
408 + guint8 hdr_len; // length in number of 32bit words
409 + guint8 type; // see GSMTAP_TYPE_*
410 + guint8 timeslot; // timeslot (0..7 on Um)
412 + guint16 arfcn; // ARFCN (frequency)
413 + gint8 signal_dbm; // signal level in dBm
414 + gint8 snr_db; // signal/noise ratio in dB
416 + guint32 frame_number; // GSM Frame Number (FN)
418 + guint8 sub_type; // Type of burst/channel, see above
419 + guint8 antenna_nr; // Antenna Number
420 + guint8 sub_slot; // sub-slot within timeslot
421 + guint8 res; // reserved for future use (RFU)
425 +#endif /* _GSMTAP_H */
426 Index: epan/dissectors/Makefile.common
427 ===================================================================
428 --- epan/dissectors/Makefile.common.orig
429 +++ epan/dissectors/Makefile.common
432 packet-gsm_sms_ud.c \
438 @@ -1072,6 +1073,7 @@
439 packet-gsm_a_common.h \