/src/wireshark/epan/dissectors/packet-mac-lte-framed.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Routines for MAC LTE format files with context info as header. |
2 | | * |
3 | | * Martin Mathieson |
4 | | * |
5 | | * Wireshark - Network traffic analyzer |
6 | | * By Gerald Combs <gerald@wireshark.org> |
7 | | * Copyright 1998 Gerald Combs |
8 | | * |
9 | | * SPDX-License-Identifier: GPL-2.0-or-later |
10 | | */ |
11 | | |
12 | | #include "config.h" |
13 | | |
14 | | #include <epan/packet.h> |
15 | | #include <epan/proto_data.h> |
16 | | #include "packet-mac-lte.h" |
17 | | |
18 | | void proto_register_mac_lte_framed(void); |
19 | | |
20 | | /* Initialize the protocol and registered fields. */ |
21 | | static int proto_mac_lte_framed; |
22 | | |
23 | | extern int proto_mac_lte; |
24 | | |
25 | | /* Main dissection function. */ |
26 | | static int dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo, |
27 | | proto_tree *tree, void* data _U_) |
28 | 0 | { |
29 | 0 | int offset = 0; |
30 | 0 | struct mac_lte_info *p_mac_lte_info; |
31 | 0 | tvbuff_t *mac_tvb; |
32 | 0 | bool infoAlreadySet = false; |
33 | | |
34 | | /* Need to find enabled mac-lte dissector */ |
35 | 0 | dissector_handle_t mac_lte_handle = find_dissector("mac-lte"); |
36 | 0 | if (!mac_lte_handle) { |
37 | 0 | return 0; |
38 | 0 | } |
39 | | |
40 | | /* Do this again on re-dissection to re-discover offset of actual PDU */ |
41 | | |
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 | 0 | if ((size_t)tvb_reported_length_remaining(tvb, offset) < (3+2)) { |
47 | 0 | return 5; |
48 | 0 | } |
49 | | |
50 | | /* If redissecting, use previous info struct (if available) */ |
51 | 0 | p_mac_lte_info = (struct mac_lte_info*)p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0); |
52 | 0 | if (p_mac_lte_info == NULL) { |
53 | | /* Allocate new info struct for this frame */ |
54 | 0 | p_mac_lte_info = wmem_new0(wmem_file_scope(), struct mac_lte_info); |
55 | 0 | infoAlreadySet = false; |
56 | 0 | } |
57 | 0 | else { |
58 | 0 | infoAlreadySet = true; |
59 | 0 | } |
60 | | |
61 | | /* Dissect the fields to populate p_mac_lte */ |
62 | 0 | if (!dissect_mac_lte_context_fields(p_mac_lte_info, tvb, pinfo, tree, &offset)) { |
63 | 0 | return offset; |
64 | 0 | } |
65 | | |
66 | | /* Store info in packet (first time) */ |
67 | 0 | if (!infoAlreadySet) { |
68 | 0 | p_add_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0, p_mac_lte_info); |
69 | 0 | } |
70 | | |
71 | | /**************************************/ |
72 | | /* OK, now dissect as MAC LTE */ |
73 | | |
74 | | /* Create tvb that starts at actual MAC PDU */ |
75 | 0 | mac_tvb = tvb_new_subset_remaining(tvb, offset); |
76 | 0 | call_dissector_only(mac_lte_handle, mac_tvb, pinfo, tree, NULL); |
77 | 0 | return tvb_captured_length(tvb); |
78 | 0 | } |
79 | | |
80 | | void proto_register_mac_lte_framed(void) |
81 | 14 | { |
82 | | /* Register protocol. */ |
83 | 14 | proto_mac_lte_framed = proto_register_protocol("mac-lte-framed", "MAC-LTE-FRAMED", "mac-lte-framed"); |
84 | | |
85 | | /* Allow other dissectors to find this one by name. */ |
86 | 14 | register_dissector("mac-lte-framed", dissect_mac_lte_framed, proto_mac_lte_framed); |
87 | 14 | } |
88 | | |
89 | | /* |
90 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
91 | | * |
92 | | * Local variables: |
93 | | * c-basic-offset: 4 |
94 | | * tab-width: 8 |
95 | | * indent-tabs-mode: nil |
96 | | * End: |
97 | | * |
98 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
99 | | * :indentSize=4:tabSize=8:noTabs=true: |
100 | | */ |