Rename the routines that handle dissector tables with unsigned integer
[obnox/wireshark/wip.git] / epan / dissectors / packet-snaeth.c
1 /* packet-snaeth.c
2  * Routines for SNA-over-Ethernet (Ethernet type 80d5)
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <glib.h>
30 #include <epan/packet.h>
31 #include <epan/etypes.h>
32
33 /*
34  * See
35  *
36  * http://www.cisco.com/univercd/cc/td/doc/product/software/ssr90/rpc_r/18059.pdf
37  */
38
39 static int proto_snaeth = -1;
40 static int hf_snaeth_len = -1;
41
42 static gint ett_snaeth = -1;
43
44 static dissector_handle_t llc_handle;
45
46 static void
47 dissect_snaeth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
48 {
49         proto_tree      *snaeth_tree;
50         proto_item      *snaeth_ti;
51         guint16         len;
52         tvbuff_t        *next_tvb;
53
54         col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNAETH");
55         col_set_str(pinfo->cinfo, COL_INFO, "SNA over Ethernet");
56
57         /* length */
58         len = tvb_get_ntohs(tvb, 0);
59
60         if (tree) {
61                 snaeth_ti = proto_tree_add_item(tree, proto_snaeth, tvb, 0, 3,
62                     FALSE);
63                 snaeth_tree = proto_item_add_subtree(snaeth_ti, ett_snaeth);
64                 proto_tree_add_uint(snaeth_tree, hf_snaeth_len, tvb, 0, 2, len);
65                 proto_tree_add_text(snaeth_tree, tvb, 2, 1, "Padding");
66         }
67
68         /*
69          * Adjust the length of this tvbuff to include only the SNA-over-
70          * Ethernet header and data.
71          */
72         set_actual_length(tvb, 3 + len);
73
74         /*
75          * Rest of packet starts with an 802.2 LLC header.
76          */
77         next_tvb = tvb_new_subset_remaining(tvb, 3);
78         call_dissector(llc_handle, next_tvb, pinfo, tree);
79 }
80
81 void
82 proto_register_snaeth(void)
83 {
84         static hf_register_info hf[] = {
85                 { &hf_snaeth_len,
86                 { "Length",     "snaeth_len", FT_UINT16, BASE_DEC, NULL, 0x0,
87                         "Length of LLC payload", HFILL }},
88         };
89         static gint *ett[] = {
90                 &ett_snaeth,
91         };
92
93         proto_snaeth = proto_register_protocol("SNA-over-Ethernet",
94             "SNAETH", "snaeth");
95         proto_register_field_array(proto_snaeth, hf, array_length(hf));
96         proto_register_subtree_array(ett, array_length(ett));
97 }
98
99 void
100 proto_reg_handoff_snaeth(void)
101 {
102         dissector_handle_t snaeth_handle;
103
104         /*
105          * Get handle for the LLC dissector.
106          */
107         llc_handle = find_dissector("llc");
108
109         snaeth_handle = create_dissector_handle(dissect_snaeth, proto_snaeth);
110         dissector_add_uint("ethertype", ETHERTYPE_SNA, snaeth_handle);
111 }