1 /* packet-gsm_abis_tfp.c
2 * Routines for packet dissection of Ericsson GSM A-bis TFP
3 * (Traffic Forwarding Protocol)
4 * Copyright 2010-2016 by Harald Welte <laforge@gnumonks.org>
6 * TFP is an Ericsson-specific packetized version of replacing TRAU
7 * frames on 8k/16k E1 sub-slots with a paketized frame format which
8 * can be transported over LAPD on a SuperChannel (E1 timeslot bundle)
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
20 #include <epan/packet.h>
21 #include <epan/prefs.h>
23 void proto_register_abis_tfp(void);
24 void proto_reg_handoff_abis_tfp(void);
32 static dissector_handle_t sub_handles[SUB_MAX];
34 /* initialize the protocol and registered fields */
35 static int proto_abis_tfp = -1;
38 static int hf_tfp_hdr_atsr = -1;
39 static int hf_tfp_hdr_slot_rate = -1;
40 static int hf_tfp_hdr_seq_nr = -1;
41 static int hf_tfp_hdr_delay_info = -1;
42 static int hf_tfp_hdr_p = -1;
43 static int hf_tfp_hdr_s = -1;
44 static int hf_tfp_hdr_m = -1;
45 static int hf_tfp_hdr_frame_type = -1;
46 static int hf_tfp_amr_rate = -1;
48 /* initialize the subtree pointers */
49 static int ett_tfp = -1;
51 static const value_string tfp_slot_rate_vals[] = {
52 { 0, "Full Rate (16kbps)" },
53 { 1, "Sub-Channel 0 (8kbps)" },
54 { 2, "Sub-Channel 1 (8kbps)" },
59 #define TFP_PACKED_NONE 0
60 #define TFP_PACKED_SCHEME_1 1
62 static const value_string tfp_packed_vals[] = {
64 { 1, "Packing Scheme 1" },
68 static const value_string tfp_frame_type_vals[] = {
71 { 1, "TFP-SCCE-AMR-IND" },
74 { 0x80, "TFP-AMR-IND" },
75 { 0x81, "TFP-SCCE-AMR-IND" },
76 { 0x82, "TFP-FR-IND" },
77 { 0x83, "TFP-EFR-IND" },
78 { 0x84, "TFP-SCCE-EFR-IND" },
82 static const value_string tfp_amr_len_rate_vals[] = {
83 { 1, "SID_FIRST, ONSET, No speech/data" },
84 { 5, "SID_UPDATE, SID_BAD" },
97 dissect_abis_tfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
100 proto_tree *tfp_tree;
102 guint32 slot_rate, frame_bits, atsr, seq_nr;
107 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TFP");
109 ti = proto_tree_add_item(tree, proto_abis_tfp, tvb, 0, -1, ENC_NA);
110 tfp_tree = proto_item_add_subtree(ti, ett_tfp);
112 proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_atsr, tvb, offset, 2, ENC_BIG_ENDIAN, &atsr);
113 proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_slot_rate, tvb, offset, 2, ENC_BIG_ENDIAN, &slot_rate);
114 proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_seq_nr, tvb, offset, 2, ENC_BIG_ENDIAN, &seq_nr);
115 proto_tree_add_item(tfp_tree, hf_tfp_hdr_delay_info, tvb, offset+1, 2, ENC_BIG_ENDIAN);
116 proto_tree_add_item(tfp_tree, hf_tfp_hdr_p, tvb, offset+1, 2, ENC_BIG_ENDIAN);
117 proto_tree_add_item(tfp_tree, hf_tfp_hdr_s, tvb, offset+2, 1, ENC_NA);
118 proto_tree_add_item(tfp_tree, hf_tfp_hdr_m, tvb, offset+2, 1, ENC_NA);
119 /* Frame Type depends on Slot Rate */
120 ftype = tvb_get_guint8(tvb, offset+2) & 0x1E;
123 proto_tree_add_uint_format_value(tfp_tree, hf_tfp_hdr_frame_type, tvb, offset+2, 1, ftype, "%s",
124 val_to_str(ftype, tfp_frame_type_vals, "Unknown (%u)"));
127 col_append_fstr(pinfo->cinfo, COL_INFO, "TS=%u, Seq=%u, %s, %s ", atsr, seq_nr,
128 val_to_str(slot_rate, tfp_slot_rate_vals, "Unknown (%u)"),
129 val_to_str(ftype, tfp_frame_type_vals, "Unknown (%u)"));
131 /* check for Tail bit == 1, iterate over further octests */
132 while ((tvb_get_guint8(tvb, offset) & 0x01) == 0)
136 switch (ftype & 0x7F) {
137 case 0: /* TFP-AMR.ind */
138 len_remain = tvb_captured_length_remaining(tvb, offset);
139 proto_tree_add_uint(tfp_tree, hf_tfp_amr_rate, tvb, offset, 0, len_remain);
141 case 1: /* TFP-SCCE-AMR.ind */
143 case 2: /* TFP-HR.ind */
145 case 3: /* TFP-EFR.ind */
147 case 4: /* TFP-SCCE-EFR.ind */
151 /* FIXME: implement packed frame support */
156 next_tvb = tvb_new_subset_length(tvb, offset, frame_bits/8);
157 call_dissector(sub_handles[SUB_DATA], next_tvb, pinfo, tree);
163 proto_register_abis_tfp(void)
165 static hf_register_info hf[] = {
167 { "Air Timeslot Resource", "gsm_abis_tfp.atsr",
168 FT_UINT16, BASE_DEC, NULL, 0xe000,
171 { &hf_tfp_hdr_slot_rate,
172 { "Slot Rate", "gsm_abis_tfp.slot_rate",
173 FT_UINT16, BASE_DEC, VALS(tfp_slot_rate_vals), 0x1800,
176 { &hf_tfp_hdr_seq_nr,
177 { "Sequence Number", "gsm_abis_tfp.seq_nr",
178 FT_UINT16, BASE_DEC, NULL, 0x07c0,
181 { &hf_tfp_hdr_delay_info,
182 { "Delay Information (ms)", "gsm_abis_tfp.delay_info",
183 FT_UINT16, BASE_DEC, NULL, 0x003e,
187 { "Packing Scheme", "gsm_abis_tfp.packing_scheme",
188 FT_UINT16, BASE_DEC, VALS(tfp_packed_vals), 0x0180,
192 { "Silence Indicator", "gsm_abis_tfp.silence_ind",
193 FT_BOOLEAN, 8, NULL, 0x40,
197 { "Marker bit", "gsm_abis_tfp.marker",
198 FT_BOOLEAN, 8, NULL, 0x20,
201 { &hf_tfp_hdr_frame_type,
202 { "Frame Type", "gsm_abis_tfp.frame_type",
203 FT_UINT8, BASE_DEC, VALS(tfp_frame_type_vals), 0x1e,
207 { "AMR Rate", "gsm_abis_tfp.amr.rate",
208 FT_UINT8, BASE_DEC, VALS(tfp_amr_len_rate_vals), 0,
212 static gint *ett[] = {
216 /* assign our custom match functions */
217 proto_abis_tfp = proto_register_protocol("GSM A-bis TFP", "Ericsson GSM A-bis TFP",
220 proto_register_field_array(proto_abis_tfp, hf, array_length(hf));
221 proto_register_subtree_array(ett, array_length(ett));
222 register_dissector("gsm_abis_tfp", dissect_abis_tfp, proto_abis_tfp);
225 /* This function is called once at startup and every time the user hits
226 * 'apply' in the preferences dialogue */
228 proto_reg_handoff_abis_tfp(void)
230 sub_handles[SUB_DATA] = find_dissector("data");
234 * Editor modelines - https://www.wireshark.org/tools/modelines.html
239 * indent-tabs-mode: t
242 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
243 * :indentSize=8:tabSize=8:noTabs=false: