HTTPS (almost) everywhere.
[metze/wireshark/wip.git] / epan / dissectors / packet-lapbether.c
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 = -1;
22
23 static int hf_lapbether_length = -1;
24
25 static gint ett_lapbether = -1;
26
27 static dissector_handle_t lapb_handle;
28
29 static int
30 dissect_lapbether(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
31 {
32     proto_tree *lapbether_tree, *ti;
33     int         len;
34     tvbuff_t   *next_tvb;
35
36     col_set_str(pinfo->cinfo, COL_PROTOCOL, "LAPBETHER");
37     col_clear(pinfo->cinfo, COL_INFO);
38
39     len = tvb_get_guint8(tvb, 0) + tvb_get_guint8(tvb, 1) * 256;
40
41     if (tree) {
42
43       ti = proto_tree_add_protocol_format(tree, proto_lapbether, tvb, 0, 2,
44                                           "LAPBETHER");
45
46       lapbether_tree = proto_item_add_subtree(ti, ett_lapbether);
47       proto_tree_add_uint_format(lapbether_tree, hf_lapbether_length, tvb, 0, 2,
48                                  len, "Length: %u", len);
49
50     }
51
52     next_tvb = tvb_new_subset_length(tvb, 2, len);
53     call_dissector(lapb_handle, next_tvb, pinfo, tree);
54
55     return tvb_captured_length(tvb);
56 }
57
58 void
59 proto_register_lapbether(void)
60 {
61     static hf_register_info hf[] = {
62       { &hf_lapbether_length,
63         { "Length Field", "lapbether.length", FT_UINT16, BASE_DEC, NULL, 0x0,
64           "LAPBEther Length Field", HFILL }},
65
66     };
67     static gint *ett[] = {
68         &ett_lapbether,
69     };
70
71     proto_lapbether = proto_register_protocol ("Link Access Procedure Balanced Ethernet (LAPBETHER)",
72         "LAPBETHER", "lapbether");
73     proto_register_field_array (proto_lapbether, hf, array_length(hf));
74     proto_register_subtree_array(ett, array_length(ett));
75 }
76
77 /* The registration hand-off routine */
78 void
79 proto_reg_handoff_lapbether(void)
80 {
81   dissector_handle_t lapbether_handle;
82
83   /*
84    * Get a handle for the LAPB dissector.
85    */
86   lapb_handle = find_dissector_add_dependency("lapb", proto_lapbether);
87
88   lapbether_handle = create_dissector_handle(dissect_lapbether,
89                                              proto_lapbether);
90   dissector_add_uint("ethertype", ETHERTYPE_DEC, lapbether_handle);
91
92 }
93
94 /*
95  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
96  *
97  * Local Variables:
98  * c-basic-offset: 2
99  * tab-width: 8
100  * indent-tabs-mode: nil
101  * End:
102  *
103  * ex: set shiftwidth=2 tabstop=8 expandtab:
104  * :indentSize=2:tabSize=8:noTabs=true:
105  */