Add editor modelines; Adjust whitespace as needed.
[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  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #include "config.h"
26
27 #include <glib.h>
28 #include <epan/packet.h>
29 #include <epan/etypes.h>
30
31 void proto_register_lapbether(void);
32 void proto_reg_handoff_lapbether(void);
33
34 static int proto_lapbether = -1;
35
36 static int hf_lapbether_length = -1;
37
38 static gint ett_lapbether = -1;
39
40 static dissector_handle_t lapb_handle;
41
42 static void
43 dissect_lapbether(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
44 {
45     proto_tree *lapbether_tree, *ti;
46     int         len;
47     tvbuff_t   *next_tvb;
48
49     col_set_str(pinfo->cinfo, COL_PROTOCOL, "LAPBETHER");
50     col_clear(pinfo->cinfo, COL_INFO);
51
52     len = tvb_get_guint8(tvb, 0) + tvb_get_guint8(tvb, 1) * 256;
53
54     if (tree) {
55
56       ti = proto_tree_add_protocol_format(tree, proto_lapbether, tvb, 0, 2,
57                                           "LAPBETHER");
58
59       lapbether_tree = proto_item_add_subtree(ti, ett_lapbether);
60       proto_tree_add_uint_format(lapbether_tree, hf_lapbether_length, tvb, 0, 2,
61                                  len, "Length: %u", len);
62
63     }
64
65     next_tvb = tvb_new_subset_length(tvb, 2, len);
66     call_dissector(lapb_handle, next_tvb, pinfo, tree);
67
68 }
69
70 void
71 proto_register_lapbether(void)
72 {
73     static hf_register_info hf[] = {
74       { &hf_lapbether_length,
75         { "Length Field", "lapbether.length", FT_UINT16, BASE_DEC, NULL, 0x0,
76           "LAPBEther Length Field", HFILL }},
77
78     };
79     static gint *ett[] = {
80         &ett_lapbether,
81     };
82
83     proto_lapbether = proto_register_protocol ("Link Access Procedure Balanced Ethernet (LAPBETHER)",
84         "LAPBETHER", "lapbether");
85     proto_register_field_array (proto_lapbether, hf, array_length(hf));
86     proto_register_subtree_array(ett, array_length(ett));
87 }
88
89 /* The registration hand-off routine */
90 void
91 proto_reg_handoff_lapbether(void)
92 {
93   dissector_handle_t lapbether_handle;
94
95   /*
96    * Get a handle for the LAPB dissector.
97    */
98   lapb_handle = find_dissector("lapb");
99
100   lapbether_handle = create_dissector_handle(dissect_lapbether,
101                                              proto_lapbether);
102   dissector_add_uint("ethertype", ETHERTYPE_DEC, lapbether_handle);
103
104 }
105
106 /*
107  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
108  *
109  * Local Variables:
110  * c-basic-offset: 2
111  * tab-width: 8
112  * indent-tabs-mode: nil
113  * End:
114  *
115  * ex: set shiftwidth=2 tabstop=8 expandtab:
116  * :indentSize=2:tabSize=8:noTabs=true:
117  */