/src/wireshark/epan/dissectors/packet-lapbether.c
Line | Count | Source |
1 | | /* packet-lapbether.c |
2 | | * Routines for lapbether frame disassembly |
3 | | * Richard Sharpe <rsharpe@ns.aus.com> based on the lapb module by |
4 | | * Olivier Abad <oabad@noos.fr> |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | #include "config.h" |
14 | | |
15 | | #include <epan/packet.h> |
16 | | #include <epan/etypes.h> |
17 | | |
18 | | void proto_register_lapbether(void); |
19 | | void proto_reg_handoff_lapbether(void); |
20 | | |
21 | | static int proto_lapbether; |
22 | | |
23 | | static int hf_lapbether_length; |
24 | | |
25 | | static int ett_lapbether; |
26 | | |
27 | | static dissector_handle_t lapbether_handle; |
28 | | static dissector_handle_t lapb_handle; |
29 | | |
30 | | static int |
31 | | dissect_lapbether(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
32 | 87 | { |
33 | 87 | proto_tree *lapbether_tree, *ti; |
34 | 87 | int len; |
35 | 87 | tvbuff_t *next_tvb; |
36 | | |
37 | 87 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "LAPBETHER"); |
38 | 87 | col_clear(pinfo->cinfo, COL_INFO); |
39 | | |
40 | 87 | len = tvb_get_uint8(tvb, 0) + tvb_get_uint8(tvb, 1) * 256; |
41 | | |
42 | 87 | if (tree) { |
43 | | |
44 | 86 | ti = proto_tree_add_protocol_format(tree, proto_lapbether, tvb, 0, 2, |
45 | 86 | "LAPBETHER"); |
46 | | |
47 | 86 | lapbether_tree = proto_item_add_subtree(ti, ett_lapbether); |
48 | 86 | proto_tree_add_uint_format(lapbether_tree, hf_lapbether_length, tvb, 0, 2, |
49 | 86 | len, "Length: %u", len); |
50 | | |
51 | 86 | } |
52 | | |
53 | 87 | next_tvb = tvb_new_subset_length(tvb, 2, len); |
54 | 87 | call_dissector(lapb_handle, next_tvb, pinfo, tree); |
55 | | |
56 | 87 | return tvb_captured_length(tvb); |
57 | 87 | } |
58 | | |
59 | | void |
60 | | proto_register_lapbether(void) |
61 | 14 | { |
62 | 14 | static hf_register_info hf[] = { |
63 | 14 | { &hf_lapbether_length, |
64 | 14 | { "Length Field", "lapbether.length", FT_UINT16, BASE_DEC, NULL, 0x0, |
65 | 14 | "LAPBEther Length Field", HFILL }}, |
66 | | |
67 | 14 | }; |
68 | 14 | static int *ett[] = { |
69 | 14 | &ett_lapbether, |
70 | 14 | }; |
71 | | |
72 | 14 | proto_lapbether = proto_register_protocol ("Link Access Procedure Balanced Ethernet (LAPBETHER)", |
73 | 14 | "LAPBETHER", "lapbether"); |
74 | 14 | proto_register_field_array (proto_lapbether, hf, array_length(hf)); |
75 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
76 | | |
77 | 14 | lapbether_handle = register_dissector("lapbether", dissect_lapbether, proto_lapbether); |
78 | 14 | } |
79 | | |
80 | | /* The registration hand-off routine */ |
81 | | void |
82 | | proto_reg_handoff_lapbether(void) |
83 | 14 | { |
84 | | /* |
85 | | * Get a handle for the LAPB dissector. |
86 | | */ |
87 | 14 | lapb_handle = find_dissector_add_dependency("lapb", proto_lapbether); |
88 | | |
89 | 14 | dissector_add_uint("ethertype", ETHERTYPE_DEC, lapbether_handle); |
90 | | |
91 | 14 | } |
92 | | |
93 | | /* |
94 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
95 | | * |
96 | | * Local Variables: |
97 | | * c-basic-offset: 2 |
98 | | * tab-width: 8 |
99 | | * indent-tabs-mode: nil |
100 | | * End: |
101 | | * |
102 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
103 | | * :indentSize=2:tabSize=8:noTabs=true: |
104 | | */ |