1 /* Routines for UMTS FP Hint protocol disassembly
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 #include <epan/packet.h>
34 #include "packet-umts_fp.h"
35 #include "packet-umts_mac.h"
36 #include "packet-rlc.h"
37 #include "wiretap/erf.h"
39 static int proto_fp_hint = -1;
41 extern int proto_umts_mac;
44 static int ett_fph = -1;
45 static int ett_fph_rb = -1;
46 static int ett_fph_ddi_entry = -1;
47 static int ett_fph_tf = -1;
49 static int hf_fph_frametype = -1;
50 static int hf_fph_channeltype = -1;
51 static int hf_fph_chcnt = -1;
52 static int hf_fph_dchid = -1;
53 static int hf_fph_urnti = -1;
54 static int hf_fph_rlcmode = -1;
55 static int hf_fph_content = -1;
56 static int hf_fph_rbid = -1;
57 static int hf_fph_ctmux = -1;
58 static int hf_fph_ciphered = -1;
59 static int hf_fph_deciphered = -1;
60 static int hf_fph_macdflowid = -1;
61 static int hf_fph_rb = -1;
62 static int hf_fph_ddi_entry = -1;
63 static int hf_fph_ddi_size = -1;
64 static int hf_fph_ddi_logical = -1;
65 static int hf_fph_ddi_value = -1;
66 static int hf_fph_tf = -1;
67 static int hf_fph_tf_n = -1;
68 static int hf_fph_tf_size = -1;
70 static dissector_handle_t data_handle;
71 static dissector_handle_t ethwithfcs_handle;
72 static dissector_handle_t atm_untrunc_handle;
73 static dissector_handle_t erf_handle;
103 static const value_string fph_frametype_vals[] = {
104 { FPH_FRAME_ERF_AAL2, "ERF AAL2" },
105 { FPH_FRAME_ETHERNET, "Ethernet" },
109 static const value_string fph_channeltype_vals[] = {
110 { FPH_CHANNEL_PCH, "PCH" },
111 { FPH_CHANNEL_RACH, "RACH" },
112 { FPH_CHANNEL_FACH, "FACH" },
113 { FPH_CHANNEL_DCH, "DCH" },
114 { FPH_CHANNEL_HSDSCH, "HSDSCH" },
115 { FPH_CHANNEL_EDCH, "E-DCH" },
119 static const value_string fph_rlcmode_vals[] = {
120 { RLC_TM, "Transparent Mode" },
121 { RLC_UM, "Unacknowledged Mode" },
122 { RLC_AM, "Acknowledged Mode" },
126 static const value_string fph_content_vals[] = {
127 { FPH_CONTENT_UNKNOWN, "Unknown" },
128 { FPH_CONTENT_DCCH, "DCCH" },
129 { FPH_CONTENT_PS_DTCH, "PS DTCH" },
130 { FPH_CONTENT_CS_DTCH, "PS DTCH" },
134 static const true_false_string fph_ctmux_vals = {
135 "C/T Mux field present", "C/T Mux field not present"
138 static const true_false_string fph_ciphered_vals = {
139 "Ciphered", "Not ciphered"
142 static const true_false_string fph_deciphered_vals = {
143 "Deciphered", "Not deciphered"
146 static guint16 assign_rb_info(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, guint8 rbcnt, proto_tree *tree)
148 guint8 i = 0, next_byte;
149 guint8 rlc_mode, content, rb_id, ctmux, ciphered, deciphered;
151 struct umts_mac_info *macinf;
152 struct rlc_info *rlcinf;
154 macinf = p_get_proto_data(pinfo->fd, proto_umts_mac);
155 rlcinf = p_get_proto_data(pinfo->fd, proto_rlc);
157 macinf = se_alloc0(sizeof(struct umts_mac_info));
158 p_add_proto_data(pinfo->fd, proto_umts_mac, macinf);
161 rlcinf = se_alloc0(sizeof(struct rlc_info));
162 p_add_proto_data(pinfo->fd, proto_rlc, rlcinf);
166 urnti = tvb_get_letohl(tvb, offset);
167 next_byte = tvb_get_guint8(tvb, offset + 4);
168 rlc_mode = next_byte & 0x3;
169 content = (next_byte >> 2) & 0x3;
170 rb_id = next_byte >> 4;
171 next_byte = tvb_get_guint8(tvb, offset + 5);
172 rb_id |= (next_byte & 0x01) << 4;
173 ctmux = (next_byte >> 1) & 0x1;
174 ciphered = (next_byte >> 2) & 0x1;
175 deciphered = (next_byte >> 3) & 0x1;
177 if (i >= MAX_RLC_CHANS) {
179 pi = proto_tree_add_text(tree, tvb, offset, -1,
180 "Frame contains more Radio Bearers than currently supported (%u present, %u supported)",
181 rbcnt, MAX_RLC_CHANS);
184 if (i >= MAX_MAC_FRAMES) {
186 pi = proto_tree_add_text(tree, tvb, offset, -1,
187 "Frame contains more MAC Frames than currently supported (%u present, %u supported)",
188 rbcnt, MAX_MAC_FRAMES);
192 rlcinf->mode[i] = rlc_mode;
193 rlcinf->rbid[i] = rb_id;
194 rlcinf->urnti[i] = urnti;
195 rlcinf->ciphered[i] = ciphered;
196 rlcinf->deciphered[i] = deciphered;
198 macinf->ctmux[i] = ctmux ? TRUE : FALSE;
200 case FPH_CONTENT_DCCH:
201 macinf->content[i] = MAC_CONTENT_DCCH;
203 case FPH_CONTENT_PS_DTCH:
204 macinf->content[i] = MAC_CONTENT_PS_DTCH;
206 case FPH_CONTENT_CS_DTCH:
207 macinf->content[i] = MAC_CONTENT_CS_DTCH;
210 macinf->content[i] = MAC_CONTENT_UNKNOWN;
217 pi = proto_tree_add_item(tree, hf_fph_rb, tvb, offset, 8, TRUE);
218 subtree = proto_item_add_subtree(pi, ett_fph_rb);
221 proto_tree_add_uint(subtree, hf_fph_urnti, tvb, offset, 4, urnti);
222 pi = proto_tree_add_bits_item(subtree, hf_fph_content, tvb, (offset+4)*8+4, 2, TRUE);
223 pi = proto_tree_add_bits_item(subtree, hf_fph_rlcmode, tvb, (offset+4)*8+6, 2, TRUE);
224 proto_tree_add_item(subtree, hf_fph_rbid, tvb, (offset+4), 2, TRUE);
225 proto_tree_add_boolean(subtree, hf_fph_ctmux, tvb, offset+5, 1, ctmux);
226 proto_tree_add_boolean(subtree, hf_fph_ciphered, tvb, offset+5, 1, ciphered);
227 proto_tree_add_boolean(subtree, hf_fph_deciphered, tvb, offset+5, 1, deciphered);
235 static void assign_fph_pch(tvbuff_t *tvb, packet_info *pinfo _U_, guint16 offset, fp_info *fpi, proto_tree *tree _U_)
238 guint16 blkcnt, blksz;
241 fpi->channel = CHANNEL_PCH;
243 hdr = tvb_get_ptr(tvb, offset, 4);
244 blkcnt = hdr[0] | ((hdr[1] & 0x01) << 8);
245 blksz = (hdr[1] >> 1) | ((hdr[2] & 0x3f) << 7);
246 pich = (hdr[2] >> 6) | ((hdr[3] & 0x01) << 2);
250 fpi->paging_indications = 18;
253 fpi->paging_indications = 36;
256 fpi->paging_indications = 72;
259 fpi->paging_indications = 144;
262 fpi->paging_indications = 0;
265 fpi->chan_tf_size[0] = blksz;
266 fpi->chan_num_tbs[0] = blkcnt;
269 static void assign_fph_rach(tvbuff_t *tvb, packet_info *pinfo _U_, guint16 offset, fp_info *fpi, proto_tree *tree)
273 guint16 blkcnt, blksz;
275 fpi->channel = CHANNEL_RACH_FDD;
277 hdr = tvb_get_ptr(tvb, offset, 4);
278 blkcnt = hdr[0] | ((hdr[1] & 0x01) << 8);
279 blksz = (hdr[1] >> 1) | ((hdr[2] & 0x3f) << 7);
282 fpi->chan_tf_size[0] = blksz;
283 fpi->chan_num_tbs[0] = blkcnt;
286 rbcnt = tvb_get_guint8(tvb, offset); offset++;
288 offset = assign_rb_info(tvb, pinfo, offset, rbcnt, tree);
291 static void assign_fph_dch(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, fp_info *fpi, proto_tree *tree)
293 guint8 dch_id, rbcnt;
300 fpi->channel = CHANNEL_DCH;
301 cnt = tvb_get_guint8(tvb, offset); offset++;
304 proto_tree_add_uint(tree, hf_fph_chcnt, tvb, offset-1, 1, cnt);
306 fpi->num_chans = cnt;
307 fpi->dch_crc_present = 1;
309 pi = proto_tree_add_item(tree, hf_fph_tf, tvb, offset, 4, TRUE);
310 subtree = proto_item_add_subtree(pi, ett_fph_rb);
311 hdr = tvb_get_ptr(tvb, offset, 4);
312 dch_id = hdr[0] & 0x1f;
314 N = ((hdr[1] & 0x3f)<<3) | (hdr[0] >> 5);
315 size = ((hdr[3] & 0x07)<<10) | (hdr[2] << 2) | ((hdr[1] & 0xc0)>>6);
316 size = size == 0x1fff ? 0 : size;
318 fpi->chan_tf_size[i] = size;
319 fpi->chan_num_tbs[i] = N;
322 proto_tree_add_bits_item(subtree, hf_fph_dchid, tvb, offset*8+3, 5, TRUE);
323 proto_tree_add_uint(subtree, hf_fph_tf_n, tvb, offset, 2, N);
325 proto_tree_add_uint(subtree, hf_fph_tf_size, tvb, offset + 1, 3, size);
328 if (i > MAX_FP_CHANS) {
330 pi = proto_tree_add_text(tree, tvb, offset, -1,
331 "Frame contains more FP channels than currently supported (%u supported)",
337 rbcnt = tvb_get_guint8(tvb, offset); offset++;
339 offset = assign_rb_info(tvb, pinfo, offset, rbcnt, tree);
342 static void assign_fph_fach(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, fp_info *fpi, proto_tree *tree)
346 guint16 blkcnt, blksz;
348 fpi->channel = CHANNEL_FACH_FDD;
350 hdr = tvb_get_ptr(tvb, offset, 4);
351 blkcnt = hdr[0] | ((hdr[1] & 0x01) << 8);
352 blksz = (hdr[1] >> 1) | ((hdr[2] & 0x3f) << 7);
355 fpi->chan_tf_size[0] = blksz;
356 fpi->chan_num_tbs[0] = blkcnt;
359 rbcnt = tvb_get_guint8(tvb, offset); offset++;
361 offset = assign_rb_info(tvb, pinfo, offset, rbcnt, tree);
364 static void assign_fph_hsdsch(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, fp_info *fpi, proto_tree *tree)
366 guint8 rbcnt, macdflow_id;
368 fpi->channel = CHANNEL_HSDSCH;
369 macdflow_id = tvb_get_guint8(tvb, offset);
372 proto_tree_add_uint(tree, hf_fph_macdflowid, tvb, offset, 1, macdflow_id);
375 rbcnt = tvb_get_guint8(tvb, offset); offset++;
377 offset = assign_rb_info(tvb, pinfo, offset, rbcnt, tree);
380 static void assign_fph_edch(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, fp_info *fpi, proto_tree *tree)
382 guint8 rbcnt, macdflow_id, maces_cnt, i = 0;
386 proto_tree *subtree = NULL;
388 fpi->channel = CHANNEL_EDCH;
389 macdflow_id = tvb_get_guint8(tvb, offset);
392 proto_tree_add_uint(tree, hf_fph_macdflowid, tvb, offset, 1, macdflow_id);
396 maces_cnt = tvb_get_guint8(tvb, offset); offset++;
398 fpi->no_ddi_entries = maces_cnt;
399 while (i < maces_cnt) {
400 ddi = tvb_get_guint8(tvb, offset++);
401 logical = tvb_get_guint8(tvb, offset++);
402 maces_size = tvb_get_letohs(tvb, offset);
404 fpi->edch_ddi[i] = ddi;
405 fpi->edch_macd_pdu_size[i] = maces_size;
407 pi = proto_tree_add_item(tree, hf_fph_ddi_entry, tvb, offset - 4, 4, TRUE);
408 subtree = proto_item_add_subtree(pi, ett_fph_ddi_entry);
409 proto_tree_add_uint(subtree, hf_fph_ddi_value, tvb, offset - 4, 1, ddi);
410 proto_tree_add_uint(subtree, hf_fph_ddi_logical, tvb, offset - 3, 1, logical);
411 proto_tree_add_uint(subtree, hf_fph_ddi_size, tvb, offset - 2, 2, maces_size);
414 if (i >= MAX_EDCH_DDIS) {
416 pi = proto_tree_add_text(tree, tvb, offset, -1,
417 "Frame contains more FP channels than currently supported (%u supported)",
424 rbcnt = tvb_get_guint8(tvb, offset); offset++;
426 offset = assign_rb_info(tvb, pinfo, offset, rbcnt, tree);
429 static void attach_info(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, guint8 channel_type, guint8 frame_type, proto_tree *tree)
433 fpi = p_get_proto_data(pinfo->fd, proto_fp);
435 fpi = se_alloc0(sizeof(fp_info));
436 p_add_proto_data(pinfo->fd, proto_fp, fpi);
439 fpi->is_uplink = pinfo->p2p_dir == P2P_DIR_RECV;
440 /* TODO make this configurable */
442 fpi->release_year = 2006;
443 fpi->release_month = 9;
444 fpi->dch_crc_present = 1;
446 switch (frame_type) {
447 case FPH_FRAME_ERF_AAL2:
448 fpi->link_type = FP_Link_ATM;
450 case FPH_FRAME_ETHERNET:
451 fpi->link_type = FP_Link_Ethernet;
454 fpi->link_type = FP_Link_Unknown;
457 /* at the moment, only IuB is supported */
458 fpi->iface_type = IuB_Interface;
459 /* at the moment, only FDD is supported */
460 fpi->division = Division_FDD;
462 switch (channel_type) {
463 case FPH_CHANNEL_PCH:
464 assign_fph_pch(tvb, pinfo, offset, fpi, tree);
466 case FPH_CHANNEL_RACH:
467 assign_fph_rach(tvb, pinfo, offset, fpi, tree);
469 case FPH_CHANNEL_FACH:
470 assign_fph_fach(tvb, pinfo, offset, fpi, tree);
472 case FPH_CHANNEL_DCH:
473 assign_fph_dch(tvb, pinfo, offset, fpi, tree);
475 case FPH_CHANNEL_HSDSCH:
476 assign_fph_hsdsch(tvb, pinfo, offset, fpi, tree);
478 case FPH_CHANNEL_EDCH:
479 assign_fph_edch(tvb, pinfo, offset, fpi, tree);
486 static void dissect_fp_hint(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
488 guint8 frame_type, channel_type;
491 guint32 atm_aal2_ext, atm_hdr;
494 dissector_handle_t *next_dissector;
496 proto_tree *fph_tree = NULL;
498 if (check_col(pinfo->cinfo, COL_PROTOCOL))
499 col_set_str(pinfo->cinfo, COL_PROTOCOL, "FP Hint");
501 hdrlen = tvb_get_letohs(tvb, 0);
502 frame_type = tvb_get_guint8(tvb, 2);
503 channel_type = tvb_get_guint8(tvb, 3);
506 ti = proto_tree_add_item(tree, proto_fp_hint, tvb, 0, hdrlen, TRUE);
507 fph_tree = proto_item_add_subtree(ti, ett_fph);
508 proto_tree_add_uint(fph_tree, hf_fph_frametype, tvb, 2, 1, frame_type);
509 proto_tree_add_uint(fph_tree, hf_fph_channeltype, tvb, 3, 1, channel_type);
512 /* attach FP, MAC, RLC information */
513 attach_info(tvb, pinfo, 4, channel_type, frame_type, fph_tree);
514 switch (frame_type) {
515 case FPH_FRAME_ERF_AAL2:
516 memset(&pinfo->pseudo_header->erf, 0, sizeof(pinfo->pseudo_header->erf));
517 pinfo->pseudo_header->erf.phdr.type = ERF_TYPE_AAL2;
518 /* store p2p direction in ERF flags */
519 pinfo->pseudo_header->erf.phdr.flags |= pinfo->p2p_dir;
520 /* set ATM properties */
521 pinfo->pseudo_header->atm.type = TRAF_UMTS_FP;
522 pinfo->pseudo_header->atm.subtype = TRAF_UNKNOWN;
523 next_dissector = &erf_handle;
525 case FPH_FRAME_ETHERNET:
526 next_dissector = ðwithfcs_handle;
529 next_dissector = &data_handle;
532 next_tvb = tvb_new_subset(tvb, hdrlen, -1, -1);
533 call_dissector(*next_dissector, next_tvb, pinfo, tree);
537 proto_register_fp_hint(void)
539 static hf_register_info hf[] = {
540 { &hf_fph_frametype, { "Frame Type", "fp_hint.frame_type", FT_UINT8, BASE_HEX, VALS(fph_frametype_vals), 0x0, "Frame Type", HFILL } },
541 { &hf_fph_channeltype, { "Channel Type", "fp_hint.channel_type", FT_UINT8, BASE_HEX, VALS(fph_channeltype_vals), 0x0, "Channel Type", HFILL } },
542 { &hf_fph_chcnt, { "Number of Channels", "fp_hint.num_chan", FT_UINT8, BASE_DEC, NULL, 0, "Number of Channels", HFILL } },
543 { &hf_fph_dchid, { "DCH ID", "fp_hint.dchid", FT_UINT8, BASE_DEC, NULL, 0, "DCH ID", HFILL } },
544 { &hf_fph_macdflowid, { "MACd Flow ID", "fp_hint.macdflowid", FT_UINT8, BASE_DEC, NULL, 0, "MACd Flow ID", HFILL } },
545 /* traffic format details */
546 { &hf_fph_tf, { "Traffic Format", "fp_hint.tf", FT_NONE, BASE_NONE, NULL, 0, "", HFILL } },
547 { &hf_fph_tf_n, { "N", "fp_hint.tf.n", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL } },
548 { &hf_fph_tf_size, { "Size", "fp_hintf.tf.size", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL } },
549 /* DDI information for E-DCH */
550 { &hf_fph_ddi_entry, { "DDI Entry", "fp_hint.ddi", FT_NONE, BASE_NONE, NULL, 0, "", HFILL } },
551 { &hf_fph_ddi_value, { "DDI", "fp_hint.ddi.value", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL } },
552 { &hf_fph_ddi_logical, { "Logical Channel ID", "fp_hint.ddi.logical", FT_UINT8, BASE_DEC, NULL, 0, "", HFILL } },
553 { &hf_fph_ddi_size, { "Size", "fp_hint.ddi.size", FT_UINT16, BASE_DEC, NULL, 0, "", HFILL } },
554 /* radio bearer details */
555 { &hf_fph_rb, { "Radio Bearer", "fp_hint.rb", FT_NONE, BASE_NONE, NULL, 0, "", HFILL } },
556 { &hf_fph_urnti, { "U-RNTI", "fp_hint.rb.urnti", FT_UINT32, BASE_HEX, NULL, 0x0, "U-RNTI", HFILL } },
557 { &hf_fph_content, { "Content", "fp_hint.rb.content", FT_UINT8, BASE_DEC, VALS(fph_content_vals), 0, "Content", HFILL } },
558 { &hf_fph_rlcmode, { "RLC Mode", "fp_hint.rb.rlc_mode", FT_UINT8, BASE_DEC, VALS(fph_rlcmode_vals), 0, "RLC Mode", HFILL } },
559 { &hf_fph_rbid, { "Radio Bearer ID", "fp_hint.rb.rbid", FT_UINT16, BASE_DEC, NULL, 0x01f0, "Radio Bearer ID", HFILL } },
560 { &hf_fph_ctmux, { "C/T Mux", "fp_hint.rb.ctmux", FT_BOOLEAN, BASE_NONE, TFS(&fph_ctmux_vals), 0, "C/T Mux field", HFILL } },
561 { &hf_fph_ciphered, { "Ciphered", "fp_hint.rb.ciphered", FT_BOOLEAN, BASE_NONE, TFS(&fph_ciphered_vals), 0, "Ciphered flag", HFILL } },
562 { &hf_fph_deciphered, { "Deciphered", "fp_hint.rb.deciphered", FT_BOOLEAN, BASE_NONE, TFS(&fph_deciphered_vals), 0, "Deciphered flag", HFILL } }
565 static gint *ett[] = {
572 proto_fp_hint = proto_register_protocol("FP Hint", "FP Hint", "fp_hint");
573 register_dissector("fp_hint", dissect_fp_hint, proto_fp_hint);
575 proto_register_field_array(proto_fp_hint, hf, array_length(hf));
576 proto_register_subtree_array(ett, array_length(ett));
580 proto_reg_handoff_fp_hint(void)
582 atm_untrunc_handle = find_dissector("atm_untruncated");
583 data_handle = find_dissector("data");
584 ethwithfcs_handle = find_dissector("eth_withfcs");
585 erf_handle = find_dissector("erf");