]> The Tcpdump Group git mirrors - libpcap/commitdiff
To compile libpcap on OpenSolaris (or Solaris Express Community Edition)
authorDarren Reed <[email protected]>
Wed, 25 Nov 2009 02:40:44 +0000 (21:40 -0500)
committerMichael Richardson <[email protected]>
Wed, 25 Nov 2009 02:40:44 +0000 (21:40 -0500)
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.

Makefile.in
configure.in
gencode.c
pcap-bpf.c
pcap/bpf.h
savefile.c

index ce34c7a2281a93cba77a942d5072e13189950e49..24dc74decf180d43afbda4657d7cc5153b91987e 100644 (file)
@@ -44,6 +44,7 @@ VPATH = @srcdir@
 # You shouldn't need to edit anything below.
 #
 
+LD = /usr/bin/ld
 CC = @CC@
 CCOPT = @V_CCOPT@
 INCLS = -I. @V_INCLS@
index 43cd323951b5c60ff4ade715271fc939e60824ce..e4442917a77a9a31808e3b9e5721185963572f91 100644 (file)
@@ -295,7 +295,7 @@ AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
 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.
        #
index 8d9a1c78428543381ad1aa55b8565488b3a5758a..db3516483b69aa8098d1da570cc1de1c95dadc2a 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -212,6 +212,7 @@ static struct block *gen_uncond(int);
 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);
@@ -1569,6 +1570,13 @@ init_linktype(p)
                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 */
@@ -2002,6 +2010,33 @@ gen_ether_linktype(proto)
        }
 }
 
+/*
+ * "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.
  *
@@ -3399,6 +3434,9 @@ gen_linktype(proto)
                 */
                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");
 
@@ -7329,6 +7367,18 @@ gen_inbound(dir)
                          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) {
                        /*
index 86d1bee048386257805a78b86baa9fd77aaf6942..3cb91debc34308025623c33ba83564fb754e960c 100644 (file)
@@ -51,6 +51,7 @@ static const char rcsid[] _U_ =
 #include <sys/ioccom.h>
 #endif
 #include <sys/utsname.h>
+#include <fcntl.h>
 
 #ifdef HAVE_ZEROCOPY_BPF
 #include <machine/atomic.h>
@@ -542,7 +543,8 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf)
                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;
                                }
index b5f5ed2fc689dfaa63b1736015ad51ed008c5094..cd61f83fe7e521b9a34f891750f9e0af61e11061 100644 (file)
@@ -953,6 +953,15 @@ struct bpf_version {
  */
 #define DLT_CAN_SOCKETCAN              227
 
+#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
index 4832f34f2da97502dc8a01607fe2eb692c11d399..1a2f2bec60def8d88d32b718cb087e80f65a96fe 100644 (file)
@@ -793,6 +793,8 @@ static const char rcsid[] _U_ =
  */
 #define LINKTYPE_CAN_SOCKETCAN                 227
 
+#define        LINKTYPE_IPNET          226
+
 
 static struct linktype_map {
        int     dlt;
@@ -1135,6 +1137,9 @@ static struct linktype_map {
        /* CAN frames with SocketCAN headers */
        { DLT_CAN_SOCKETCAN,    LINKTYPE_CAN_SOCKETCAN },
 
+       /* Solaris IPNET */
+       { DLT_IPNET,            LINKTYPE_IPNET },
+
        { -1,                   -1 }
 };