1 /* Routines for MAC LTE format files with context info as header.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <epan/wmem/wmem.h>
31 #include "packet-mac-lte.h"
34 /* Initialize the protocol and registered fields. */
35 static int proto_mac_lte_framed
= -1;
37 extern int proto_mac_lte
;
39 /* Main dissection function. */
40 static void dissect_mac_lte_framed(tvbuff_t
*tvb
, packet_info
*pinfo
,
44 struct mac_lte_info
*p_mac_lte_info
;
46 gboolean infoAlreadySet
= FALSE
;
48 /* Need to find enabled mac-lte dissector */
49 dissector_handle_t mac_lte_handle
= find_dissector("mac-lte");
50 if (!mac_lte_handle
) {
54 /* Do this again on re-dissection to re-discover offset of actual PDU */
56 /* Needs to be at least as long as:
59 - at least one byte of MAC PDU payload */
60 if ((size_t)tvb_length_remaining(tvb
, offset
) < (3+2)) {
64 /* If redissecting, use previous info struct (if available) */
65 p_mac_lte_info
= (struct mac_lte_info
*)p_get_proto_data(pinfo
->fd
, proto_mac_lte
, 0);
66 if (p_mac_lte_info
== NULL
) {
67 /* Allocate new info struct for this frame */
68 p_mac_lte_info
= (struct mac_lte_info
*)wmem_alloc0(wmem_file_scope(), sizeof(struct mac_lte_info
));
69 infoAlreadySet
= FALSE
;
72 infoAlreadySet
= TRUE
;
75 /* Dissect the fields to populate p_mac_lte */
76 if (!dissect_mac_lte_context_fields(p_mac_lte_info
, tvb
, &offset
)) {
80 /* Store info in packet (first time) */
81 if (!infoAlreadySet
) {
82 p_add_proto_data(pinfo
->fd
, proto_mac_lte
, 0, p_mac_lte_info
);
85 /**************************************/
86 /* OK, now dissect as MAC LTE */
88 /* Create tvb that starts at actual MAC PDU */
89 mac_tvb
= tvb_new_subset_remaining(tvb
, offset
);
90 call_dissector_only(mac_lte_handle
, mac_tvb
, pinfo
, tree
, NULL
);
93 void proto_register_mac_lte_framed(void)
95 /* Register protocol. */
96 proto_mac_lte_framed
= proto_register_protocol("mac-lte-framed", "MAC-LTE-FRAMED", "mac-lte-framed");
98 /* Allow other dissectors to find this one by name. */
99 register_dissector("mac-lte-framed", dissect_mac_lte_framed
, proto_mac_lte_framed
);