Remove "text2pcap-scanner.obj" and "tools\lemon\lemon.obj" when a "nmake
[obnox/wireshark/wip.git] / 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@cybercable.fr>
5  *
6  * $Id: packet-lapbether.c,v 1.6 2001/06/18 02:17:48 guy Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@zing.org>
10  * Copyright 1998
11  *
12  * 
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  * 
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
34 #endif
35
36 #include <stdio.h>
37 #include <glib.h>
38 #include <string.h>
39 #include "packet.h"
40 #include "etypes.h"
41
42 static int proto_lapbether = -1;
43
44 static int hf_lapbether_length = -1;
45
46 static gint ett_lapbether = -1;
47
48 static dissector_handle_t lapb_handle;
49
50 static void
51 dissect_lapbether(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
52 {
53     proto_tree          *lapbether_tree, *ti;
54     int                 len;
55     tvbuff_t            *next_tvb;
56
57     if (check_col(pinfo->fd, COL_PROTOCOL))
58         col_set_str(pinfo->fd, COL_PROTOCOL, "LAPBETHER");
59     if (check_col(pinfo->fd, COL_INFO))
60         col_clear(pinfo->fd, COL_INFO);
61
62     len = tvb_get_guint8(tvb, 0) + tvb_get_guint8(tvb, 1) * 256;
63
64     if (tree) {
65
66       ti = proto_tree_add_protocol_format(tree, proto_lapbether, tvb, 0, 2, 
67                                           "LAPBETHER");
68
69       lapbether_tree = proto_item_add_subtree(ti, ett_lapbether);
70       proto_tree_add_uint_format(lapbether_tree, hf_lapbether_length, tvb, 0, 2, 
71                                  len, "Length: %u", len);
72
73     }
74
75     next_tvb = tvb_new_subset(tvb, 2, len, len);
76     call_dissector(lapb_handle, next_tvb, pinfo, tree);
77
78 }
79
80 void
81 proto_register_lapbether(void)
82 {
83     static hf_register_info hf[] = {
84       { &hf_lapbether_length,
85         { "Length Field", "lapbether.length", FT_UINT16, BASE_DEC, NULL, 0x0, 
86           "LAPBEther Length Field", HFILL }},
87
88     };
89     static gint *ett[] = {
90         &ett_lapbether,
91     };
92
93     proto_lapbether = proto_register_protocol ("Link Access Procedure Balanced Ethernet (LAPBETHER)",
94         "LAPBETHER", "lapbether");
95     proto_register_field_array (proto_lapbether, hf, array_length(hf));
96     proto_register_subtree_array(ett, array_length(ett));
97 }
98
99 /* The registration hand-off routine */
100 void
101 proto_reg_handoff_lapbether(void)
102 {
103
104   /*
105    * Get a handle for the LAPB dissector.
106    */
107   lapb_handle = find_dissector("lapb");
108
109   dissector_add("ethertype", ETHERTYPE_DEC, dissect_lapbether, proto_lapbether);
110
111 }