epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-mac-lte-framed.c
blob86cfe27b18127877b1766f424ced819dd960dd52
1 /* Routines for MAC LTE format files with context info as header.
3 * Martin Mathieson
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/proto_data.h>
16 #include "packet-mac-lte.h"
18 void proto_register_mac_lte_framed(void);
20 /* Initialize the protocol and registered fields. */
21 static int proto_mac_lte_framed;
23 extern int proto_mac_lte;
25 /* Main dissection function. */
26 static int dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo,
27 proto_tree *tree, void* data _U_)
29 int offset = 0;
30 struct mac_lte_info *p_mac_lte_info;
31 tvbuff_t *mac_tvb;
32 bool infoAlreadySet = false;
34 /* Need to find enabled mac-lte dissector */
35 dissector_handle_t mac_lte_handle = find_dissector("mac-lte");
36 if (!mac_lte_handle) {
37 return 0;
40 /* Do this again on re-dissection to re-discover offset of actual PDU */
42 /* Needs to be at least as long as:
43 - fixed header bytes
44 - tag for data
45 - at least one byte of MAC PDU payload */
46 if ((size_t)tvb_reported_length_remaining(tvb, offset) < (3+2)) {
47 return 5;
50 /* If redissecting, use previous info struct (if available) */
51 p_mac_lte_info = (struct mac_lte_info*)p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0);
52 if (p_mac_lte_info == NULL) {
53 /* Allocate new info struct for this frame */
54 p_mac_lte_info = wmem_new0(wmem_file_scope(), struct mac_lte_info);
55 infoAlreadySet = false;
57 else {
58 infoAlreadySet = true;
61 /* Dissect the fields to populate p_mac_lte */
62 if (!dissect_mac_lte_context_fields(p_mac_lte_info, tvb, pinfo, tree, &offset)) {
63 return offset;
66 /* Store info in packet (first time) */
67 if (!infoAlreadySet) {
68 p_add_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0, p_mac_lte_info);
71 /**************************************/
72 /* OK, now dissect as MAC LTE */
74 /* Create tvb that starts at actual MAC PDU */
75 mac_tvb = tvb_new_subset_remaining(tvb, offset);
76 call_dissector_only(mac_lte_handle, mac_tvb, pinfo, tree, NULL);
77 return tvb_captured_length(tvb);
80 void proto_register_mac_lte_framed(void)
82 /* Register protocol. */
83 proto_mac_lte_framed = proto_register_protocol("mac-lte-framed", "MAC-LTE-FRAMED", "mac-lte-framed");
85 /* Allow other dissectors to find this one by name. */
86 register_dissector("mac-lte-framed", dissect_mac_lte_framed, proto_mac_lte_framed);
90 * Editor modelines - https://www.wireshark.org/tools/modelines.html
92 * Local variables:
93 * c-basic-offset: 4
94 * tab-width: 8
95 * indent-tabs-mode: nil
96 * End:
98 * vi: set shiftwidth=4 tabstop=8 expandtab:
99 * :indentSize=4:tabSize=8:noTabs=true: