components/tcpdump/patches/10-arphrd-infiniband.patch
author John Beck <John.Beck@Oracle.COM>
Mon, 24 Mar 2014 17:43:42 -0700
changeset 1788 7948c9c48347
parent 1632 fd2ec3291103
child 4468 2f1bf786d396
permissions -rw-r--r--
18418978 PosixGroupsTester fails during python 2.6 regress test due to ListEqual

#
# InfiniBand support
#
diff -N -u -r tcpdump-4.5.1.orig/interface.h tcpdump-4.5.1/interface.h
--- tcpdump-4.5.1.orig/interface.h	2013-03-24 16:49:18.000000000 -0500
+++ tcpdump-4.5.1/interface.h	2013-12-02 11:48:13.394398375 -0600
@@ -205,6 +205,7 @@
 extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
+extern u_int ipoib_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int token_print(const u_char *, u_int, u_int);
 extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void fddi_print(const u_char *, u_int, u_int);
diff -N -u -r tcpdump-4.5.1.orig/Makefile.in tcpdump-4.5.1/Makefile.in
--- tcpdump-4.5.1.orig/Makefile.in	2013-03-24 16:49:18.000000000 -0500
+++ tcpdump-4.5.1/Makefile.in	2013-12-02 11:47:25.102106791 -0600
@@ -83,6 +83,7 @@
 	print-esp.c print-ether.c print-fddi.c print-forces.c print-fr.c \
 	print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
 	print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \
+	print-ipoib.c \
 	print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
 	print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
         print-lmp.c print-lspping.c print-lwapp.c \
diff -N -u -r tcpdump-4.5.1.orig/netdissect.h tcpdump-4.5.1/netdissect.h
--- tcpdump-4.5.1.orig/netdissect.h	2013-03-24 16:49:18.000000000 -0500
+++ tcpdump-4.5.1/netdissect.h	2013-12-02 11:48:46.057536548 -0600
@@ -319,6 +319,7 @@
 
 extern u_int ether_if_print(netdissect_options *,
                             const struct pcap_pkthdr *,const u_char *);
+extern u_int ipoib_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int netanalyzer_if_print(netdissect_options *,
                                   const struct pcap_pkthdr *,const u_char *);
 extern u_int netanalyzer_transparent_if_print(netdissect_options *,
diff -N -u -r tcpdump-4.5.1.orig/print-arp.c tcpdump-4.5.1/print-arp.c
--- tcpdump-4.5.1.orig/print-arp.c	2013-02-20 21:54:34.000000000 -0600
+++ tcpdump-4.5.1/print-arp.c	2013-12-02 11:51:40.229231503 -0600
@@ -58,6 +58,7 @@
 #define ARPHRD_ATM2225  19      /* ATM (RFC 2225) */
 #define ARPHRD_STRIP    23      /* Ricochet Starmode Radio hardware format */
 #define ARPHRD_IEEE1394 24      /* IEEE 1394 (FireWire) hardware format */
+#define ARPHRD_INFINIBAND 32	/* InfiniBand RFC 4391 */
         u_short ar_pro;         /* format of protocol address */
         u_char  ar_hln;         /* length of hardware address */
         u_char  ar_pln;         /* length of protocol address */
@@ -118,6 +119,7 @@
     { ARPHRD_STRIP, "Strip" },
     { ARPHRD_IEEE1394, "IEEE 1394" },
     { ARPHRD_ATM2225, "ATM" },
+    { ARPHRD_INFINIBAND, "InfiniBand" },
     { 0, NULL }
 };
 
diff -N -u -r tcpdump-4.5.1.orig/print-ipoib.c tcpdump-4.5.1/print-ipoib.c
--- tcpdump-4.5.1.orig/print-ipoib.c	1969-12-31 18:00:00.000000000 -0600
+++ tcpdump-4.5.1/print-ipoib.c	2013-12-02 11:53:24.664773530 -0600
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 
+ *	1997, 2000, 2011, 2012
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header$";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <pcap.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+extern const struct tok ethertype_values[];
+extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int );
+
+#define	IPOIB_HDRLEN	44
+
+static inline void
+ipoib_hdr_print(register const u_char *bp, u_int length)
+{
+	u_int16_t ether_type;
+	char abuf[40];
+
+	ether_type = EXTRACT_16BITS(&bp[40]);
+	if (!qflag) {
+		(void)printf(", ethertype %s (0x%04x)",
+			     tok2str(ethertype_values,"Unknown", ether_type),
+			     ether_type);
+	} else {
+		(void)printf(", ethertype %s",
+			     tok2str(ethertype_values,"Unknown", ether_type));
+	}
+
+	(void)printf(", length %u: ", length);
+}
+
+/*
+ * Print an InfiniBand frame.
+ * This might be encapsulated within another frame; we might be passed
+ * a pointer to a function that can print header information for that
+ * frame's protocol, and an argument to pass to that function.
+ */
+static void
+ipoib_print(const u_char *p, u_int length, u_int caplen,
+    void (*print_encap_header)(const u_char *), const u_char *encap_header_arg)
+{
+	const u_char *orig_hdr = p;
+	u_int orig_length;
+	u_short ether_type;
+	u_short extracted_ether_type;
+
+	if (caplen < IPOIB_HDRLEN || length < IPOIB_HDRLEN) {
+		printf("[|ipoib]");
+		return;
+	}
+
+	if (eflag) {
+		if (print_encap_header != NULL)
+			(*print_encap_header)(encap_header_arg);
+		ipoib_hdr_print(p, length);
+	}
+	orig_length = length;
+
+	length -= IPOIB_HDRLEN;
+	caplen -= IPOIB_HDRLEN;
+	ether_type = EXTRACT_16BITS(&p[40]);
+	p += IPOIB_HDRLEN;
+
+	if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+		/* ether_type not known, print raw packet */
+		if (!eflag) {
+			if (print_encap_header != NULL)
+				(*print_encap_header)(encap_header_arg);
+			ipoib_hdr_print(orig_hdr , orig_length);
+		}
+
+		if (!suppress_default_print)
+			default_print(p, caplen);
+	}
+}
+
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+ipoib_if_print(const struct pcap_pkthdr *h, const u_char *p)
+{
+	ipoib_print(p, h->len, h->caplen, NULL, NULL);
+
+	return (IPOIB_HDRLEN);
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff -N -u -r tcpdump-4.5.1.orig/tcpdump.c tcpdump-4.5.1/tcpdump.c
--- tcpdump-4.5.1.orig/tcpdump.c	2013-03-24 16:49:18.000000000 -0500
+++ tcpdump-4.5.1/tcpdump.c	2013-12-02 11:52:41.512481340 -0600
@@ -311,6 +311,9 @@
 #ifdef DLT_IPV6
 	{ raw_if_print,		DLT_IPV6 },
 #endif
+#ifdef DLT_IPOIB
+	{ ipoib_if_print,	DLT_IPOIB },
+#endif
 	{ NULL,			0 },
 };