change the signature that asn2wrs generates for functions to marm all parameters...
[obnox/wireshark/wip.git] / epan / dissectors / packet-symantec.c
1 /* packet-symantec.c
2  * Routines for dissection of packets from the Axent Raptor firewall/
3  * Symantec Enterprise Firewall
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
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
31 #include <epan/packet.h>
32
33 #include <epan/etypes.h>
34
35 static dissector_table_t ethertype_dissector_table;
36
37 /* protocols and header fields */
38 static int proto_symantec = -1;
39 static int hf_symantec_if = -1;
40 static int hf_symantec_etype = -1;
41
42 static gint ett_symantec = -1;
43
44 static void
45 dissect_symantec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
46 {
47         proto_item *ti;
48         proto_tree *symantec_tree = NULL;
49         guint16 etype;
50         tvbuff_t *next_tvb;
51
52         /*
53          * The first 4 bytes are the IPv4 address of the interface that
54          * captured the data, followed by 2 bytes of 0, then an Ethernet
55          * type, followed by 36 bytes of 0.
56          */
57         if (check_col(pinfo->cinfo, COL_PROTOCOL))
58                 col_add_str(pinfo->cinfo, COL_PROTOCOL, "Symantec");
59         if (check_col(pinfo->cinfo, COL_INFO))
60                 col_add_fstr(pinfo->cinfo, COL_INFO, "Symantec Enterprise Firewall");
61         if (tree) {
62                 ti = proto_tree_add_protocol_format(tree, proto_symantec, tvb,
63                     0, 44, "Symantec firewall");
64                 symantec_tree = proto_item_add_subtree(ti, ett_symantec);
65         }
66         etype = tvb_get_ntohs(tvb, 6);
67         if (tree) {
68                 proto_tree_add_item(symantec_tree, hf_symantec_if, tvb,
69                     0, 4, FALSE);
70                 proto_tree_add_uint(symantec_tree, hf_symantec_etype, tvb,
71                     6, 2, etype);
72         }
73         next_tvb = tvb_new_subset(tvb, 44, -1, -1);
74         dissector_try_port(ethertype_dissector_table, etype, next_tvb, pinfo,
75             tree);
76 }
77
78 void
79 proto_register_symantec(void)
80 {
81         static hf_register_info hf[] = {
82                 { &hf_symantec_if,
83                     { "Interface",      "symantec.if", FT_IPv4, BASE_NONE, NULL, 0x0,
84                         "Interface", HFILL }},
85                 { &hf_symantec_etype,
86                     { "Type",   "symantec.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
87                         "", HFILL }},
88         };
89         static gint *ett[] = {
90                 &ett_symantec,
91         };
92
93         proto_symantec = proto_register_protocol("Symantec Enterprise Firewall",
94             "Symantec", "symantec");
95         proto_register_field_array(proto_symantec, hf, array_length(hf));
96         proto_register_subtree_array(ett, array_length(ett));
97 }
98
99 void
100 proto_reg_handoff_symantec(void)
101 {
102         dissector_handle_t symantec_handle;
103
104         ethertype_dissector_table = find_dissector_table("ethertype");
105
106         symantec_handle = create_dissector_handle(dissect_symantec,
107             proto_symantec);
108         dissector_add("wtap_encap", WTAP_ENCAP_SYMANTEC, symantec_handle);
109 }