aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ipnet.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2009-12-03 15:27:39 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2009-12-03 15:27:39 +0000
commite592902393a7fbd63ce0bd135b51ef0181168252 (patch)
tree29f8b56386a377b142f0528f3a24586c55988fe0 /epan/dissectors/packet-ipnet.c
parent39f0b9efde36d57693479071eb0413a6fce593f4 (diff)
From Petr Sumbera via bug 4284:
Added support for Solaris IPNET layer From me: Some code cleanup in packet-ipnet.c Added packet-ipnet.c to CMakeFiles.txt Added WTAP_ENCAP_IPNET to encap_table_base[] svn path=/trunk/; revision=31159
Diffstat (limited to 'epan/dissectors/packet-ipnet.c')
-rw-r--r--epan/dissectors/packet-ipnet.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/epan/dissectors/packet-ipnet.c b/epan/dissectors/packet-ipnet.c
new file mode 100644
index 0000000000..3802ae158c
--- /dev/null
+++ b/epan/dissectors/packet-ipnet.c
@@ -0,0 +1,143 @@
+/* packet-ipnet.c
+ * Routines for decoding Solaris IPNET packet disassembly
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <string.h>
+#include <epan/packet.h>
+
+static int proto_ipnet = -1;
+static int hf_version = -1;
+static int hf_family = -1;
+static int hf_htype = -1;
+static int hf_pktlen = -1;
+static int hf_ifindex = -1;
+static int hf_grifindex = -1;
+static int hf_zsrc = -1;
+static int hf_zdst = -1;
+
+static gint ett_raw = -1;
+
+static dissector_handle_t ip_handle;
+static dissector_handle_t ipv6_handle;
+
+static void
+dissect_ipnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_tree *fh_tree;
+ proto_item *ti;
+ tvbuff_t *next_tvb;
+ guint32 pktlen;
+ guint8 family;
+
+ /* load the top pane info. This should be overwritten by
+ the next protocol in the stack */
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPNET");
+ col_set_str(pinfo->cinfo, COL_INFO, "Solaris IPNET");
+
+ /* populate a tree in the second pane with the IPNET header data */
+ if(tree) {
+ ti = proto_tree_add_item (tree, proto_ipnet, tvb, 0, 24, FALSE);
+ fh_tree = proto_item_add_subtree(ti, ett_raw);
+
+ proto_tree_add_item(fh_tree, hf_version, tvb, 0, 1, FALSE);
+ proto_tree_add_item(fh_tree, hf_family, tvb, 1, 1, FALSE);
+ proto_tree_add_item(fh_tree, hf_htype, tvb, 2, 2, FALSE);
+ proto_tree_add_item(fh_tree, hf_pktlen, tvb, 4, 4, FALSE);
+ proto_tree_add_item(fh_tree, hf_ifindex, tvb, 8, 4, FALSE);
+ proto_tree_add_item(fh_tree, hf_grifindex, tvb, 12, 4, FALSE);
+ proto_tree_add_item(fh_tree, hf_zsrc, tvb, 16, 4, FALSE);
+ proto_tree_add_item(fh_tree, hf_zdst, tvb, 20, 4, FALSE);
+ }
+
+ pktlen = tvb_get_ntohl(tvb, 4);
+ next_tvb = tvb_new_subset_remaining(tvb, tvb_length(tvb) - pktlen);
+
+ family = tvb_get_guint8(tvb, 1);
+ switch (family) {
+ case 2: /* AF_INET */
+ call_dissector(ip_handle, next_tvb, pinfo, tree);
+ break;
+ case 26: /* AF_INET6 */
+ call_dissector(ipv6_handle, next_tvb, pinfo, tree);
+ break;
+ default:
+ break;
+ }
+}
+
+void
+proto_register_ipnet(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_version, { "Header version", "ipnet.version",
+ FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_family, { "Address family", "ipnet.family",
+ FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_htype, { "Hook type", "ipnet.htype",
+ FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_pktlen, { "Data length", "ipnet.pktlen",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_ifindex, { "Interface index", "ipnet.ifindex",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_grifindex, { "Group interface index", "ipnet.grifindex",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_zsrc, { "Source Zone ID", "ipnet.zsrc",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_zdst, { "Destination Zone ID", "ipnet.zdst",
+ FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+ };
+ static gint *ett[] = {
+ &ett_raw,
+ };
+
+ proto_ipnet = proto_register_protocol("Solaris IPNET", "IPNET", "ipnet");
+ proto_register_field_array(proto_ipnet, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+void
+proto_reg_handoff_ipnet(void)
+{
+ dissector_handle_t ipnet_handle;
+
+ /*
+ * Get handles for the IP and IPv6 dissectors.
+ */
+ ip_handle = find_dissector("ip");
+ ipv6_handle = find_dissector("ipv6");
+
+ ipnet_handle = create_dissector_handle(dissect_ipnet, proto_ipnet);
+ dissector_add("wtap_encap", WTAP_ENCAP_IPNET, ipnet_handle);
+}