2009-12-03 15:27:39 +00:00
|
|
|
/* packet-ipnet.c
|
|
|
|
* Routines for decoding Solaris IPNET packet disassembly
|
|
|
|
*
|
|
|
|
* 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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-12-03 15:27:39 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2009-12-03 15:27:39 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
|
2009-12-03 17:31:26 +00:00
|
|
|
#include <epan/aftypes.h>
|
2009-12-03 15:27:39 +00:00
|
|
|
#include <epan/packet.h>
|
2013-11-29 20:53:00 +00:00
|
|
|
#include <wiretap/wtap.h>
|
2009-12-03 15:27:39 +00:00
|
|
|
|
2013-12-15 23:44:12 +00:00
|
|
|
void proto_register_ipnet(void);
|
|
|
|
void proto_reg_handoff_ipnet(void);
|
|
|
|
|
2009-12-03 15:27:39 +00:00
|
|
|
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;
|
|
|
|
|
2009-12-03 17:31:26 +00:00
|
|
|
static const value_string solaris_family_vals[] = {
|
|
|
|
{ SOLARIS_AF_INET, "Solaris AF_INET" },
|
|
|
|
{ SOLARIS_AF_INET6, "Solaris AF_INET6" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string htype_vals[] = {
|
|
|
|
{ 0, "Inbound" },
|
|
|
|
{ 1, "Outbound" },
|
|
|
|
{ 2, "Local" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2009-12-03 15:27:39 +00:00
|
|
|
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) {
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item (tree, proto_ipnet, tvb, 0, 24, ENC_NA);
|
2009-12-03 15:27:39 +00:00
|
|
|
fh_tree = proto_item_add_subtree(ti, ett_raw);
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(fh_tree, hf_version, tvb, 0, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_family, tvb, 1, 1, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_htype, tvb, 2, 2, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_pktlen, tvb, 4, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_ifindex, tvb, 8, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_grifindex, tvb, 12, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_zsrc, tvb, 16, 4, ENC_BIG_ENDIAN);
|
|
|
|
proto_tree_add_item(fh_tree, hf_zdst, tvb, 20, 4, ENC_BIG_ENDIAN);
|
2009-12-03 15:27:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pktlen = tvb_get_ntohl(tvb, 4);
|
2014-06-19 17:18:16 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, tvb_length(tvb) - pktlen);
|
2009-12-03 15:27:39 +00:00
|
|
|
|
|
|
|
family = tvb_get_guint8(tvb, 1);
|
|
|
|
switch (family) {
|
2009-12-03 17:31:26 +00:00
|
|
|
case SOLARIS_AF_INET:
|
2009-12-03 15:27:39 +00:00
|
|
|
call_dissector(ip_handle, next_tvb, pinfo, tree);
|
|
|
|
break;
|
2009-12-03 17:31:26 +00:00
|
|
|
case SOLARIS_AF_INET6:
|
2009-12-03 15:27:39 +00:00
|
|
|
call_dissector(ipv6_handle, next_tvb, pinfo, tree);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_ipnet(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_version, { "Header version", "ipnet.version",
|
2009-12-03 15:27:39 +00:00
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_family, { "Address family", "ipnet.family",
|
2009-12-03 17:31:26 +00:00
|
|
|
FT_UINT8, BASE_DEC, VALS(solaris_family_vals), 0x0, NULL, HFILL }},
|
2009-12-03 15:27:39 +00:00
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_htype, { "Hook type", "ipnet.htype",
|
2009-12-03 17:31:26 +00:00
|
|
|
FT_UINT16, BASE_DEC, VALS(htype_vals), 0x0, NULL, HFILL }},
|
2009-12-03 15:27:39 +00:00
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_pktlen, { "Data length", "ipnet.pktlen",
|
2009-12-03 15:27:39 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_ifindex, { "Interface index", "ipnet.ifindex",
|
2009-12-03 15:27:39 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_grifindex, { "Group interface index", "ipnet.grifindex",
|
2009-12-03 15:27:39 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_zsrc, { "Source Zone ID", "ipnet.zsrc",
|
2009-12-03 15:27:39 +00:00
|
|
|
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
|
|
|
|
2014-09-30 23:12:26 +00:00
|
|
|
{ &hf_zdst, { "Destination Zone ID", "ipnet.zdst",
|
2009-12-03 15:27:39 +00:00
|
|
|
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);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("wtap_encap", WTAP_ENCAP_IPNET, ipnet_handle);
|
2009-12-03 15:27:39 +00:00
|
|
|
}
|
2014-09-30 23:12:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|