dect
/
libpcap
Archived
13
0
Fork 0

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.
This commit is contained in:
Darren Reed 2009-11-24 21:40:44 -05:00 committed by Michael Richardson
parent 5aa0044891
commit bdc25fca79
6 changed files with 69 additions and 2 deletions

View 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@

View 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.
#

View File

@ -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) {
/*

View 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;
}

View 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

View 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 }
};