tcpdump mailing list archives
libpcap: patches required for OpenSolaris/SXCE build >= 125
From: Darren Reed <Darren.Reed () Sun COM>
Date: Tue, 24 Nov 2009 15:55:58 -0800
To compile libpcap on OpenSolaris (or Solaris Express Community Edition) build 125 and later to use the native BPF with both IPNET and traditional MAC (ethernet, etc) packet sniffing, the attached patches are required.The attached patches represent what's in our internal build tree for libpcap.
Changes are also required for tcpdump, but I'll send those in a separate email.
Darren
--- Makefile.in.dist Mon Oct 27 18:26:13 2008 +++ Makefile.in Wed Oct 21 21:36:27 2009 @@ -44,6 +44,7 @@ # You shouldn't need to edit anything below. # +LD = /usr/bin/ld CC = @CC@ CCOPT = @V_CCOPT@ INCLS = -I. @V_INCLS@ @@ -326,7 +327,7 @@ # libpcap.so: $(OBJ) @rm -f $@ - $(CC) -shared -Wl,-soname,$@.1 -o $@.`cat $(srcdir)/VERSION` $(OBJ) $(DAGLIBS) + $(LD) -shared -Wl,-soname,$@.1 -o $@.`cat $(srcdir)/VERSION` $(OBJ) $(DAGLIBS) # # The following rule succeeds, but the result is untested.
--- pcap/bpf.h Fri Oct 10 19:42:44 2008 +++ pcap/bpf.h.new Tue Sep 15 21:06:40 2009 @@ -821,8 +821,17 @@ */ #define DLT_IEEE802_15_4_NONASK_PHY 215 +#define DLT_IPNET 226 /* Assigned by tcpdump.org */ +#define DLT_IPOIB 162 /* Private until we know what it is */ /* + * IPNET + */ +#define IPNET_OUTBOUND 1 +#define IPNET_INBOUND 2 + + +/* * DLT and savefile link type values are split into a class and * a member of that class. A class value of 0 indicates a regular * DLT_/LINKTYPE_ value.
--- configure.in.dist Tue Sep 25 19:09:46 2007 +++ configure.in Fri Jul 17 13:08:17 2009 @@ -187,7 +187,7 @@ AC_MSG_CHECKING(packet capture type) if test ! -z "$with_pcap" ; then V_PCAP="$withval" -elif test -r /dev/bpf ; then +elif test -r /dev/bpf -o -h /dev/bpf ; then # # Cloning BPF device. #
*** gencode.c.dist Fri Oct 10 19:42:44 2008 --- gencode.c Tue Sep 15 20:59:00 2009 *************** *** 200,205 **** --- 200,206 ---- static inline struct block *gen_true(void); static inline struct block *gen_false(void); static struct block *gen_ether_linktype(int); + static struct block *gen_ipnet_linktype(int); static struct block *gen_linux_sll_linktype(int); static struct slist *gen_load_prism_llprefixlen(void); static struct slist *gen_load_avs_llprefixlen(void); *************** *** 1497,1502 **** --- 1498,1510 ---- off_nl = -1; off_nl_nosnap = -1; return; + + case DLT_IPNET: + off_linktype = 1; + off_macpl = 24; /* ipnet header length */ + off_nl = 0; + off_nl_nosnap = -1; + return; } bpf_error("unknown data link type %d", linktype); /* NOTREACHED */ *************** *** 1931,1936 **** --- 1939,1971 ---- } /* + * "proto" is an Ethernet type value and for IPNET, if it is not IPv4 + * or IPv6 then we have an error. + */ + static struct block * + gen_ipnet_linktype(proto) + register int proto; + { + struct block *b0, *b1; + + switch (proto) { + case ETHERTYPE_IP: + return gen_cmp(OR_LINK, off_linktype, BPF_B, + (bpf_int32)AF_INET); + /* NOTREACHED */ + + case ETHERTYPE_IPV6: + return gen_cmp(OR_LINK, off_linktype, BPF_B, + (bpf_int32)AF_INET6); + /* NOTREACHED */ + default : + break; + } + + return gen_false(); + } + + /* * Generate code to match a particular packet type. * * "proto" is an Ethernet type value, if > ETHERMTU, or an LLC SAP *************** *** 3327,3332 **** --- 3362,3370 ---- */ return gen_mcmp(OR_LINK, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */ + case DLT_IPNET: + return gen_ipnet_linktype(proto); + case DLT_LINUX_IRDA: bpf_error("IrDA link-layer type filtering not implemented"); *************** *** 7250,7255 **** --- 7288,7305 ---- dir); break; + #ifdef DL_IPNET + case DLT_IPNET: + if (dir) { + /* match outgoing packets */ + b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_OUTBOUND); + } else { + /* match incoming packets */ + b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_INBOUND); + } + break; + #endif + case DLT_LINUX_SLL: if (dir) { /*
--- pcap.c.dist Fri Oct 10 19:42:44 2008 +++ pcap.c Tue Sep 15 21:09:24 2009 @@ -623,6 +623,7 @@ DLT_CHOICE(DLT_BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"), DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"), DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"), + DLT_CHOICE(DLT_IPNET, "Solaris IPNET"), DLT_CHOICE_SENTINEL };
--- pcap-bpf.c.dist Fri Oct 10 19:42:44 2008 +++ pcap-bpf.c Tue Sep 15 21:02:08 2009 @@ -37,6 +37,7 @@ #include <sys/file.h> #include <sys/ioctl.h> #include <sys/utsname.h> +#include <fcntl.h> #ifdef HAVE_ZEROCOPY_BPF #include <machine/atomic.h> @@ -510,7 +511,8 @@ if (v == DLT_EN10MB) { is_ethernet = 1; for (i = 0; i < bdlp->bfl_len; i++) { - if (bdlp->bfl_list[i] != DLT_EN10MB) { + if (bdlp->bfl_list[i] != DLT_EN10MB && + bdlp->bfl_list[i] != DLT_IPNET) { is_ethernet = 0; break; }
--- savefile.c.dist Fri Oct 10 19:42:44 2008 +++ savefile.c Tue Sep 15 21:10:11 2009 @@ -647,7 +647,9 @@ */ #define LINKTYPE_IEEE802_15_4_NONASK_PHY 215 +#define LINKTYPE_IPNET 226 + static struct linktype_map { int dlt; int linktype; @@ -952,6 +954,9 @@ /* IEEE 802.15.4 with PHY data for non-ASK PHYs */ { DLT_IEEE802_15_4_NONASK_PHY, LINKTYPE_IEEE802_15_4_NONASK_PHY }, + /* Solaris IPNET */ + { DLT_IPNET, LINKTYPE_IPNET }, + { -1, -1 } };
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- libpcap: patches required for OpenSolaris/SXCE build >= 125 Darren Reed (Nov 24)
- Re: libpcap: patches required for OpenSolaris/SXCE build >= 125 Michael Richardson (Nov 24)
- Re: libpcap: patches required for OpenSolaris/SXCE Darren Reed (Nov 25)
- Re: libpcap: patches required for OpenSolaris/SXCE build >= 125 Guy Harris (Nov 25)
- Re: libpcap: patches required for OpenSolaris/SXCE build >= 125 Guy Harris (Nov 25)
- Re: libpcap: patches required for OpenSolaris/SXCE Darren Reed (Nov 27)
- Re: libpcap: patches required for OpenSolaris/SXCE Darren Reed (Nov 29)
- Re: libpcap: patches required for OpenSolaris/SXCE Guy Harris (Nov 30)
- Re: libpcap: patches required for OpenSolaris/SXCE Darren Reed (Nov 30)
- Re: libpcap: patches required for OpenSolaris/SXCE Guy Harris (Dec 01)
- Re: libpcap: patches required for OpenSolaris/SXCE Sebastien Roy (Dec 01)
- Re: libpcap: patches required for OpenSolaris/SXCE build >= 125 Guy Harris (Nov 25)
- Re: libpcap: patches required for OpenSolaris/SXCE build >= 125 Michael Richardson (Nov 24)