diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index a289ccb15b..c60e8b54cf 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -684,6 +684,7 @@ set(DISSECTOR_SRC dissectors/packet-ipmi.c dissectors/packet-ipmi-session.c dissectors/packet-ipnet.c + dissectors/packet-ipoib.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 c2f0cd062c..4745c25ee4 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -605,6 +605,7 @@ DISSECTOR_SRC = \ packet-ipmi.c \ packet-ipmi-session.c \ packet-ipnet.c \ + packet-ipoib.c \ packet-ipp.c \ packet-ipsec.c \ packet-ipsec-tcp.c \ diff --git a/epan/dissectors/packet-ipoib.c b/epan/dissectors/packet-ipoib.c new file mode 100644 index 0000000000..3244e3d1eb --- /dev/null +++ b/epan/dissectors/packet-ipoib.c @@ -0,0 +1,122 @@ +/* packet-ipoib.c + * Routines for decoding IP over InfiniBand (IPoIB) packet disassembly + * See: http://tools.ietf.org/html/rfc4391#section-6 + * + * $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_ipoib = -1; +static int hf_type = -1; +static int hf_reserved = -1; + +static gint ett_raw = -1; + +static dissector_handle_t arp_handle; +static dissector_handle_t ip_handle; +static dissector_handle_t ipv6_handle; + +static void +dissect_ipoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + proto_tree *fh_tree; + proto_item *ti; + tvbuff_t *next_tvb; + guint16 type; + + /* load the top pane info. This should be overwritten by + the next protocol in the stack */ + col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPoIB"); + col_set_str(pinfo->cinfo, COL_INFO, "IP over Infiniband"); + + /* populate a tree in the second pane with the IPoIB header data */ + if (tree) { + ti = proto_tree_add_item (tree, proto_ipoib, tvb, 0, 4, ENC_NA); + fh_tree = proto_item_add_subtree(ti, ett_raw); + + proto_tree_add_item(fh_tree, hf_type, tvb, 0, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(fh_tree, hf_reserved, tvb, 2, 2, ENC_BIG_ENDIAN); + } + + next_tvb = tvb_new_subset_remaining(tvb, 4); + + type = tvb_get_ntohs(tvb, 0); + switch (type) { + case ETHERTYPE_IP: + call_dissector(ip_handle, next_tvb, pinfo, tree); + break; + case ETHERTYPE_IPv6: + call_dissector(ipv6_handle, next_tvb, pinfo, tree); + break; + case ETHERTYPE_ARP: + case ETHERTYPE_REVARP: + call_dissector(arp_handle, next_tvb, pinfo, tree); + break; + default: + break; + } +} + +void +proto_register_ipoib(void) +{ + static hf_register_info hf[] = { + { &hf_type, + { "Type", "ipoib.type", + FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, + NULL, HFILL }}, + { &hf_reserved, + { "Reserved", "ipoib.reserved", + FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }} + }; + + static gint *ett[] = { + &ett_raw + }; + + proto_ipoib = proto_register_protocol("IP over Infiniband", "IPoIB", "ipoib"); + proto_register_field_array(proto_ipoib, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_ipoib(void) +{ + dissector_handle_t ipoib_handle; + + /* + * Get handles for the ARP, IP and IPv6 dissectors. + */ + arp_handle = find_dissector("arp"); + ip_handle = find_dissector("ip"); + ipv6_handle = find_dissector("ipv6"); + + ipoib_handle = create_dissector_handle(dissect_ipoib, proto_ipoib); + dissector_add("wtap_encap", WTAP_ENCAP_IP_OVER_IB, ipoib_handle); +} diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index a778e37da7..baf6ed007e 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -376,7 +376,8 @@ static const struct { { 240, WTAP_ENCAP_NETANALYZER }, /* netANALYZER pseudo-header in transparent mode */ { 241, WTAP_ENCAP_NETANALYZER_TRANSPARENT }, - + /* IP-over-Infiniband, as specified by RFC 4391 section 6 */ + { 242, WTAP_ENCAP_IP_OVER_IB }, /* * To repeat: diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 477cf3dffc..aac38c21dd 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -211,6 +211,7 @@ int snoop_open(wtap *wth, int *err, gchar **err_info) WTAP_ENCAP_UNKNOWN, /* 100VG-AnyLAN Token Ring */ WTAP_ENCAP_UNKNOWN, /* "ISO 8802/3 and Ethernet" */ WTAP_ENCAP_UNKNOWN, /* 100BaseT (but that's just Ethernet) */ + WTAP_ENCAP_IP_OVER_IB, /* Infiniband */ }; #define NUM_SNOOP_ENCAPS (sizeof snoop_encap / sizeof snoop_encap[0]) #define SNOOP_PRIVATE_BIT 0x80000000 diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 70d743e981..464023103b 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -512,7 +512,10 @@ static struct encap_type_info encap_table_base[] = { { "netANALYZER", "netanalyzer" }, /* WTAP_ENCAP_NETANALYZER_TRANSPARENT */ - { "netANALYZER-Transparent", "netanalyzer-transparent" } + { "netANALYZER-Transparent", "netanalyzer-transparent" }, + + /* WTAP_ENCAP_IP_OVER_IB */ + { "IP over Infiniband", "ip-over-ib" } }; gint wtap_num_encap_types = sizeof(encap_table_base) / sizeof(struct encap_type_info); diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 4849b495e0..91fea6a25b 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -226,6 +226,7 @@ extern "C" { #define WTAP_ENCAP_MIME 134 #define WTAP_ENCAP_NETANALYZER 135 #define WTAP_ENCAP_NETANALYZER_TRANSPARENT 136 +#define WTAP_ENCAP_IP_OVER_IB 137 #define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()