diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index c3ae41d412..67a46f8176 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -638,6 +638,7 @@ set(DISSECTOR_SRC dissectors/packet-ipfc.c dissectors/packet-ipmi.c dissectors/packet-ipmi-session.c + dissectors/packet-ipnet.c dissectors/packet-ipp.c dissectors/packet-ipsec.c dissectors/packet-ipsec-tcp.c diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 46ecbcc980..08bcd71668 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -543,6 +543,7 @@ DISSECTOR_SRC = \ packet-ipfc.c \ packet-ipmi.c \ packet-ipmi-session.c \ + packet-ipnet.c \ packet-ipp.c \ packet-ipsec.c \ packet-ipsec-tcp.c \ 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 + * 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 +#include +#include + +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); +} diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index a7b830cbd2..235bc6d802 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -353,6 +353,8 @@ static const struct { { 224, WTAP_ENCAP_FIBRE_CHANNEL_FC2 }, /* Fibre Channel FC-2 frame with Delimiter */ { 225, WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS }, + /* Solaris DLPI */ + { 226, WTAP_ENCAP_IPNET }, /* * To repeat: diff --git a/wiretap/snoop.c b/wiretap/snoop.c index c7c3d20ef3..3ddb12a2ef 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -213,6 +213,18 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) WTAP_ENCAP_UNKNOWN, /* 100BaseT (but that's just Ethernet) */ }; #define NUM_SNOOP_ENCAPS (sizeof snoop_encap / sizeof snoop_encap[0]) + #define SNOOP_PRIVATE_BIT 0x80000000 + static const int snoop_private_encap[] = { + WTAP_ENCAP_UNKNOWN, /* Not Used */ + WTAP_ENCAP_UNKNOWN, /* IPv4 Tunnel Link */ + WTAP_ENCAP_UNKNOWN, /* IPv6 Tunnel Link */ + WTAP_ENCAP_UNKNOWN, /* Virtual network interface */ + WTAP_ENCAP_UNKNOWN, /* IEEE 802.11 */ + WTAP_ENCAP_IPNET, /* ipnet(7D) link */ + WTAP_ENCAP_UNKNOWN, /* IPMP stub interface */ + WTAP_ENCAP_UNKNOWN, /* 6to4 Tunnel Link */ + }; + #define NUM_SNOOP_PRIVATE_ENCAPS (sizeof snoop_private_encap / sizeof snoop_private_encap[0]) static const int shomiti_encap[] = { WTAP_ENCAP_ETHERNET, /* IEEE 802.3 */ WTAP_ENCAP_UNKNOWN, /* IEEE 802.4 Token Bus */ @@ -382,6 +394,18 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) /* This is a Shomiti file */ wth->file_type = WTAP_FILE_SHOMITI; + } else if (hdr.network & SNOOP_PRIVATE_BIT) { + if ((hdr.network^SNOOP_PRIVATE_BIT) >= NUM_SNOOP_PRIVATE_ENCAPS + || snoop_private_encap[hdr.network^SNOOP_PRIVATE_BIT] == WTAP_ENCAP_UNKNOWN) { + *err = WTAP_ERR_UNSUPPORTED_ENCAP; + *err_info = g_strdup_printf("snoop: private network type %u unknown or unsupported", + hdr.network); + return -1; + } + file_encap = snoop_private_encap[hdr.network^SNOOP_PRIVATE_BIT]; + + /* This is a snoop file */ + wth->file_type = WTAP_FILE_SNOOP; } else { if (hdr.network >= NUM_SNOOP_ENCAPS || snoop_encap[hdr.network] == WTAP_ENCAP_UNKNOWN) { diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 1231c4b95a..0735c7eb78 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -454,7 +454,10 @@ static struct encap_type_info encap_table_base[] = { { "Fibre Channel FC-2 With Frame Delimiter", "fc2sof"}, /* WTAP_ENCAP_JPEG_JFIF */ - { "JPEG/JFIF", "jfif" } + { "JPEG/JFIF", "jfif" }, + + /* WTAP_ENCAP_IPNET */ + { "Solaris IPNET", "ipnet" } }; diff --git a/wiretap/wtap.h b/wiretap/wtap.h index e6dd385356..c0bb2687ce 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -213,6 +213,7 @@ extern "C" { #define WTAP_ENCAP_FIBRE_CHANNEL_FC2 121 #define WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS 122 #define WTAP_ENCAP_JPEG_JFIF 123 +#define WTAP_ENCAP_IPNET 124 #define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()