Update libpcap to version 1.1.1
Signed-off-by: Christoph König <christoph.koenig@ikt.uni-hannover.de> SVN-Revision: 26995
This commit is contained in:
parent
60f66ded72
commit
a1713cc3cb
8 changed files with 109 additions and 261 deletions
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
@ -8,12 +8,12 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libpcap
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=1.1.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.tcpdump.org/release/
|
||||
PKG_MD5SUM:=9ad1358c5dec48456405eac197a46d3d
|
||||
PKG_MD5SUM:=1bca27d206970badae248cfa471bbb47
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ build a shared library.
|
|||
VPATH = @srcdir@
|
||||
|
||||
+# some defines for shared library compilation
|
||||
+MAJ=1.0
|
||||
+LIBVERSION=$(MAJ).0
|
||||
+MAJ=1.1
|
||||
+LIBVERSION=$(MAJ).1
|
||||
+LIBNAME=pcap
|
||||
+LIBRARY=lib$(LIBNAME).a
|
||||
+SOLIBRARY=lib$(LIBNAME).so
|
||||
|
@ -23,7 +23,7 @@ build a shared library.
|
|||
#
|
||||
# You shouldn't need to edit anything below.
|
||||
#
|
||||
@@ -56,6 +64,7 @@ PROG=libpcap
|
||||
@@ -59,6 +67,7 @@ PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
|
||||
|
@ -31,7 +31,7 @@ build a shared library.
|
|||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
@@ -75,7 +84,11 @@ YACC = @V_YACC@
|
||||
@@ -78,7 +87,11 @@ YACC = @V_YACC@
|
||||
# problem if you don't own the file but can write to the directory.
|
||||
.c.o:
|
||||
@rm -f $@
|
||||
|
@ -42,38 +42,37 @@ build a shared library.
|
|||
+ @rm -f $@
|
||||
+ $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
|
||||
FSRC = fad-@V_FINDALLDEVS@.c
|
||||
@@ -90,6 +103,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
|
||||
@@ -94,6 +107,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||
+OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
|
||||
HDR = \
|
||||
acconfig.h \
|
||||
arcnet.h \
|
||||
@@ -122,7 +136,8 @@ TAGHDR = \
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR) $(TAGHDR)
|
||||
PUBHDR = \
|
||||
pcap.h \
|
||||
pcap-bpf.h \
|
||||
@@ -131,7 +145,7 @@ TAGFILES = \
|
||||
|
||||
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
|
||||
+CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c \
|
||||
+ $(OBJ_PIC) libpcap.so*
|
||||
CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
|
||||
opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
|
||||
- lex.yy.c pcap-config
|
||||
+ lex.yy.c pcap-config $(OBJ_PIC)
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
||||
@@ -311,7 +326,7 @@ EXTRA_DIST = \
|
||||
@@ -324,7 +338,7 @@ EXTRA_DIST = \
|
||||
Win32/Src/inet_net.c \
|
||||
Win32/Src/inet_pton.c
|
||||
|
||||
-all: libpcap.a pcap-config
|
||||
+all: libpcap.a pcap-config $(SHAREDLIB)
|
||||
-all: libpcap.a shared pcap-config
|
||||
+all: libpcap.a shared pcap-config $(SHAREDLIB)
|
||||
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
@@ -344,6 +359,13 @@ libpcap.dylib: $(OBJ)
|
||||
-compatibility_version 1 \
|
||||
-current_version `sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`
|
||||
@@ -409,6 +423,13 @@ libpcap.shareda: $(OBJ)
|
||||
#
|
||||
libpcap.none:
|
||||
|
||||
+$(SHAREDLIB): $(OBJ_PIC)
|
||||
+ -@rm -f $@
|
||||
|
@ -84,8 +83,8 @@ build a shared library.
|
|||
+
|
||||
scanner.c: $(srcdir)/scanner.l
|
||||
@rm -f $@
|
||||
./runlex.sh $(LEX) -o$@ $<
|
||||
@@ -351,6 +373,9 @@ scanner.c: $(srcdir)/scanner.l
|
||||
$(srcdir)/runlex.sh $(LEX) -o$@ $<
|
||||
@@ -416,6 +437,9 @@ scanner.c: $(srcdir)/scanner.l
|
||||
scanner.o: scanner.c tokdefs.h
|
||||
$(CC) $(CFLAGS) -c scanner.c
|
||||
|
||||
|
@ -95,7 +94,7 @@ build a shared library.
|
|||
pcap.o: version.h
|
||||
|
||||
tokdefs.h: grammar.c
|
||||
@@ -364,9 +389,17 @@ grammar.o: grammar.c
|
||||
@@ -429,9 +453,17 @@ grammar.o: grammar.c
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
|
||||
|
||||
|
@ -113,7 +112,7 @@ build a shared library.
|
|||
snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
|
||||
|
||||
@@ -392,6 +425,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
|
||||
@@ -469,6 +501,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
|
||||
bpf_filter.o: bpf_filter.c
|
||||
$(CC) $(CFLAGS) -c bpf_filter.c
|
||||
|
||||
|
@ -123,35 +122,33 @@ build a shared library.
|
|||
#
|
||||
# Generate the pcap-config script.
|
||||
#
|
||||
@@ -418,6 +454,9 @@ install: libpcap.a pcap-config
|
||||
@@ -604,6 +639,9 @@ install-archive-so install-archive-dylib
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
||||
+ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
|
||||
+ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
|
||||
+ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
|
||||
[ -d $(DESTDIR)$(includedir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
||||
[ -d $(DESTDIR)$(includedir)/pcap ] || \
|
||||
install-archive-shareda:
|
||||
#
|
||||
# AIX, however, doesn't, so we don't install the archive
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -8658,7 +8658,7 @@ irix*)
|
||||
;;
|
||||
|
||||
linux*)
|
||||
- V_CCOPT="$V_CCOPT -fPIC"
|
||||
+ V_CCOPT="$V_CCOPT"
|
||||
;;
|
||||
|
||||
osf*)
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -943,7 +943,7 @@ irix*)
|
||||
;;
|
||||
|
||||
linux*)
|
||||
- V_CCOPT="$V_CCOPT -fPIC"
|
||||
+ V_CCOPT="$V_CCOPT"
|
||||
;;
|
||||
|
||||
osf*)
|
||||
@@ -3229,7 +3229,7 @@ _ACEOF
|
||||
# or accepts command-line arguments like
|
||||
# those the GNU linker accepts.
|
||||
#
|
||||
- V_CCOPT="$V_CCOPT -fpic"
|
||||
+ V_CCOPT="$V_CCOPT"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
@@ -3292,7 +3292,7 @@ _ACEOF
|
||||
#
|
||||
# "cc" is GCC.
|
||||
#
|
||||
- V_CCOPT="$V_CCOPT -fpic"
|
||||
+ V_CCOPT="$V_CCOPT"
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -484,6 +484,8 @@ install: libpcap.a pcap-config
|
||||
$(DESTDIR)$(includedir)/pcap-bpf.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap-namedb.h \
|
||||
$(DESTDIR)$(includedir)/pcap-namedb.h
|
||||
+ [ -d $(DESTDIR)$(bindir) ] || \
|
||||
+ (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
|
||||
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
|
@ -1,6 +1,6 @@
|
|||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -461,14 +461,6 @@ install: libpcap.a pcap-config
|
||||
@@ -539,62 +539,12 @@ install: install-shared install-archive
|
||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
||||
[ -d $(DESTDIR)$(includedir)/pcap ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
|
||||
|
@ -12,67 +12,78 @@
|
|||
- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
|
||||
- [ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
|
||||
- (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/pcap.h \
|
||||
$(DESTDIR)$(includedir)/pcap/pcap.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/bpf.h \
|
||||
@@ -487,36 +479,6 @@ install: libpcap.a pcap-config
|
||||
for i in $(PUBHDR); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(includedir)/$$i; done
|
||||
[ -d $(DESTDIR)$(bindir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
|
||||
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
|
||||
- for i in $(MAN1); do \
|
||||
- $(INSTALL_DATA) $(srcdir)/$$i \
|
||||
- $(DESTDIR)$(mandir)/man1/$$i; done
|
||||
- for i in $(MAN3PCAP); do \
|
||||
- for i in $(MAN3PCAP_NOEXPAND); do \
|
||||
- $(INSTALL_DATA) $(srcdir)/$$i \
|
||||
- $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
- for i in $(MAN3PCAP_EXPAND:.in=); do \
|
||||
- $(INSTALL_DATA) $$i \
|
||||
- $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_name.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_major_version.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_next_ex.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_open_offline.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
- ln $(DESTDIR)$(mandir)/man3/pcap_setnonblock.3pcap \
|
||||
- $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
- for i in $(MANFILE); do \
|
||||
- $(INSTALL_DATA) $(srcdir)/`echo $$i | sed 's/.manfile.in/.manfile/'` \
|
||||
- $(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
|
||||
- $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
|
||||
- for i in $(MANMISC); do \
|
||||
- $(INSTALL_DATA) $(srcdir)/`echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
- $(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
- $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
install-shared: install-shared-$(DYEXT)
|
||||
install-shared-so: libpcap.so
|
||||
@@ -536,23 +498,6 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(includedir)/pcap.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap-bpf.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap-namedb.h
|
||||
@@ -654,23 +604,6 @@ uninstall: uninstall-shared
|
||||
rm -f $(DESTDIR)$(includedir)/$$i; done
|
||||
-rmdir $(DESTDIR)$(includedir)/pcap
|
||||
rm -f $(DESTDIR)/$(bindir)/pcap-config
|
||||
- for i in $(MAN1); do \
|
||||
- rm -f $(DESTDIR)$(mandir)/man1/$$i; done
|
||||
- for i in $(MAN3PCAP); do \
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
|
||||
- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
- for i in $(MANFILE); do \
|
||||
- rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
|
||||
- for i in $(MANMISC); do \
|
||||
- rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES) libpcap*.dylib libpcap.so*
|
||||
uninstall-shared: uninstall-shared-$(DYEXT)
|
||||
uninstall-shared-so:
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -55,7 +55,7 @@ SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
|
||||
@@ -56,7 +56,7 @@ LD = /usr/bin/ld
|
||||
CC = @CC@
|
||||
CCOPT = @V_CCOPT@
|
||||
INCLS = -I. @V_INCLS@
|
||||
-DEFS = @DEFS@ @V_DEFS@
|
||||
+DEFS = -D_BSD_SOURCE @DEFS@ @V_DEFS@
|
||||
LIBS = @V_LIBS@
|
||||
DAGLIBS = @DAGLIBS@
|
||||
DEPLIBS = @DEPLIBS@
|
||||
ADDLOBJS = @ADDLOBJS@
|
||||
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
||||
LIBS = @LIBS@
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
--- a/pcap-linux.c
|
||||
+++ b/pcap-linux.c
|
||||
@@ -297,6 +297,12 @@ pcap_create(const char *device, char *eb
|
||||
{
|
||||
pcap_t *handle;
|
||||
|
||||
+ /*
|
||||
+ * A null device name is equivalent to the "any" device.
|
||||
+ */
|
||||
+ if (device == NULL)
|
||||
+ device = "any";
|
||||
+
|
||||
#ifdef HAVE_DAG_API
|
||||
if (strstr(device, "dag")) {
|
||||
return dag_create(device, ebuf);
|
||||
@@ -338,10 +344,9 @@ pcap_can_set_rfmon_linux(pcap_t *p)
|
||||
struct iwreq ireq;
|
||||
#endif
|
||||
|
||||
- if (p->opt.source == NULL) {
|
||||
+ if (strcmp(p->opt.source, "any") == 0) {
|
||||
/*
|
||||
- * This is equivalent to the "any" device, and we don't
|
||||
- * support monitor mode on it.
|
||||
+ * Monitor mode makes no sense on the "any" device.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
@@ -518,12 +523,11 @@ pcap_activate_linux(pcap_t *handle)
|
||||
handle->stats_op = pcap_stats_linux;
|
||||
|
||||
/*
|
||||
- * NULL and "any" are special devices which give us the hint to
|
||||
- * monitor all devices.
|
||||
+ * The "any" device is a special device which causes us not
|
||||
+ * to bind to a particular device and thus to look at all
|
||||
+ * devices.
|
||||
*/
|
||||
- if (!device || strcmp(device, "any") == 0) {
|
||||
- device = NULL;
|
||||
- handle->md.device = strdup("any");
|
||||
+ if (strcmp(device, "any") == 0) {
|
||||
if (handle->opt.promisc) {
|
||||
handle->opt.promisc = 0;
|
||||
/* Just a warning. */
|
||||
@@ -531,10 +535,9 @@ pcap_activate_linux(pcap_t *handle)
|
||||
"Promiscuous mode not supported on the \"any\" device");
|
||||
status = PCAP_WARNING_PROMISC_NOTSUP;
|
||||
}
|
||||
+ }
|
||||
|
||||
- } else
|
||||
- handle->md.device = strdup(device);
|
||||
-
|
||||
+ handle->md.device = strdup(device);
|
||||
if (handle->md.device == NULL) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
|
||||
pcap_strerror(errno) );
|
||||
@@ -1657,19 +1660,21 @@ static int
|
||||
activate_new(pcap_t *handle)
|
||||
{
|
||||
#ifdef HAVE_PF_PACKET_SOCKETS
|
||||
+ const char *device = handle->opt.source;
|
||||
+ int is_any_device = (strcmp(device, "any") == 0);
|
||||
int sock_fd = -1, arptype, val;
|
||||
int err = 0;
|
||||
struct packet_mreq mr;
|
||||
- const char* device = handle->opt.source;
|
||||
|
||||
/*
|
||||
- * Open a socket with protocol family packet. If a device is
|
||||
- * given we try to open it in raw mode otherwise we use
|
||||
- * the cooked interface.
|
||||
- */
|
||||
- sock_fd = device ?
|
||||
- socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))
|
||||
- : socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
|
||||
+ * Open a socket with protocol family packet. If the
|
||||
+ * "any" device was specified, we open a SOCK_DGRAM
|
||||
+ * socket for the cooked interface, otherwise we first
|
||||
+ * try a SOCK_RAW socket for the raw interface.
|
||||
+ */
|
||||
+ sock_fd = is_any_device ?
|
||||
+ socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) :
|
||||
+ socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||
|
||||
if (sock_fd == -1) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
|
||||
@@ -1704,7 +1709,7 @@ activate_new(pcap_t *handle)
|
||||
* to cooked mode if we have an unknown interface type
|
||||
* or a type we know doesn't work well in raw mode.
|
||||
*/
|
||||
- if (device) {
|
||||
+ if (!is_any_device) {
|
||||
/* Assume for now we don't need cooked mode. */
|
||||
handle->md.cooked = 0;
|
||||
|
||||
@@ -1819,15 +1824,23 @@ activate_new(pcap_t *handle)
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
- * This is cooked mode.
|
||||
+ * The "any" device.
|
||||
+ */
|
||||
+ if (handle->opt.rfmon) {
|
||||
+ /*
|
||||
+ * It doesn't support monitor mode.
|
||||
+ */
|
||||
+ return PCAP_ERROR_RFMON_NOTSUP;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * It uses cooked mode.
|
||||
*/
|
||||
handle->md.cooked = 1;
|
||||
handle->linktype = DLT_LINUX_SLL;
|
||||
|
||||
/*
|
||||
* We're not bound to a device.
|
||||
- * XXX - true? Or true only if we're using
|
||||
- * the "any" device?
|
||||
* For now, we're using this as an indication
|
||||
* that we can't transmit; stop doing that only
|
||||
* if we figure out how to transmit in cooked
|
||||
@@ -1852,10 +1865,13 @@ activate_new(pcap_t *handle)
|
||||
|
||||
/*
|
||||
* Hmm, how can we set promiscuous mode on all interfaces?
|
||||
- * I am not sure if that is possible at all.
|
||||
+ * I am not sure if that is possible at all. For now, we
|
||||
+ * silently ignore attempts to turn promiscuous mode on
|
||||
+ * for the "any" device (so you don't have to explicitly
|
||||
+ * disable it in programs such as tcpdump).
|
||||
*/
|
||||
|
||||
- if (device && handle->opt.promisc) {
|
||||
+ if (!is_any_device && handle->opt.promisc) {
|
||||
memset(&mr, 0, sizeof(mr));
|
||||
mr.mr_ifindex = handle->md.ifindex;
|
||||
mr.mr_type = PACKET_MR_PROMISC;
|
||||
@@ -3118,7 +3134,7 @@ activate_old(pcap_t *handle)
|
||||
|
||||
/* Bind to the given device */
|
||||
|
||||
- if (!device) {
|
||||
+ if (strcmp(device, "any") == 0) {
|
||||
strncpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
return PCAP_ERROR;
|
|
@ -1,6 +1,6 @@
|
|||
--- a/pcap-int.h
|
||||
+++ b/pcap-int.h
|
||||
@@ -187,6 +187,7 @@ struct pcap_opt {
|
||||
@@ -209,6 +209,7 @@ struct pcap_opt {
|
||||
char *source;
|
||||
int promisc;
|
||||
int rfmon;
|
||||
|
@ -10,25 +10,25 @@
|
|||
/*
|
||||
--- a/pcap-linux.c
|
||||
+++ b/pcap-linux.c
|
||||
@@ -273,7 +273,7 @@ static int iface_get_id(int fd, const ch
|
||||
@@ -335,7 +335,7 @@ static int iface_get_id(int fd, const ch
|
||||
static int iface_get_mtu(int fd, const char *device, char *ebuf);
|
||||
static int iface_get_arptype(int fd, const char *device, char *ebuf);
|
||||
#ifdef HAVE_PF_PACKET_SOCKETS
|
||||
-static int iface_bind(int fd, int ifindex, char *ebuf);
|
||||
+static int iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto);
|
||||
#ifdef IW_MODE_MONITOR
|
||||
static int has_wext(int sock_fd, const char *device, char *ebuf);
|
||||
static int enter_rfmon_mode_wext(pcap_t *handle, int sock_fd,
|
||||
const char *device);
|
||||
@@ -362,7 +362,7 @@ pcap_can_set_rfmon_linux(pcap_t *p)
|
||||
#endif /* IW_MODE_MONITOR */
|
||||
@@ -881,7 +881,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle)
|
||||
* (We assume that if we have Wireless Extensions support
|
||||
* we also have PF_PACKET support.)
|
||||
*/
|
||||
- sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
|
||||
+ sock_fd = socket(PF_PACKET, SOCK_RAW, p->opt.proto);
|
||||
if (sock_fd == -1) {
|
||||
(void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
(void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket: %s", pcap_strerror(errno));
|
||||
@@ -522,6 +522,9 @@ pcap_activate_linux(pcap_t *handle)
|
||||
@@ -1128,6 +1128,9 @@ pcap_activate_linux(pcap_t *handle)
|
||||
handle->read_op = pcap_read_linux;
|
||||
handle->stats_op = pcap_stats_linux;
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
/*
|
||||
* The "any" device is a special device which causes us not
|
||||
* to bind to a particular device and thus to look at all
|
||||
@@ -1673,8 +1676,8 @@ activate_new(pcap_t *handle)
|
||||
@@ -2684,8 +2687,8 @@ activate_new(pcap_t *handle)
|
||||
* try a SOCK_RAW socket for the raw interface.
|
||||
*/
|
||||
sock_fd = is_any_device ?
|
||||
|
@ -49,7 +49,7 @@
|
|||
|
||||
if (sock_fd == -1) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
|
||||
@@ -1763,7 +1766,7 @@ activate_new(pcap_t *handle)
|
||||
@@ -2783,7 +2786,7 @@ activate_new(pcap_t *handle)
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
sock_fd = socket(PF_PACKET, SOCK_DGRAM,
|
||||
|
@ -58,7 +58,7 @@
|
|||
if (sock_fd == -1) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket: %s", pcap_strerror(errno));
|
||||
@@ -1815,7 +1818,7 @@ activate_new(pcap_t *handle)
|
||||
@@ -2835,7 +2838,7 @@ activate_new(pcap_t *handle)
|
||||
}
|
||||
|
||||
if ((err = iface_bind(sock_fd, handle->md.ifindex,
|
||||
|
@ -67,7 +67,7 @@
|
|||
close(sock_fd);
|
||||
if (err < 0)
|
||||
return err;
|
||||
@@ -2440,7 +2443,7 @@ iface_get_id(int fd, const char *device,
|
||||
@@ -3640,7 +3643,7 @@ iface_get_id(int fd, const char *device,
|
||||
* or a PCAP_ERROR_ value on a hard error.
|
||||
*/
|
||||
static int
|
||||
|
@ -76,7 +76,7 @@
|
|||
{
|
||||
struct sockaddr_ll sll;
|
||||
int err;
|
||||
@@ -2449,7 +2452,7 @@ iface_bind(int fd, int ifindex, char *eb
|
||||
@@ -3649,7 +3652,7 @@ iface_bind(int fd, int ifindex, char *eb
|
||||
memset(&sll, 0, sizeof(sll));
|
||||
sll.sll_family = AF_PACKET;
|
||||
sll.sll_ifindex = ifindex;
|
||||
|
@ -85,7 +85,7 @@
|
|||
|
||||
if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) {
|
||||
if (errno == ENETDOWN) {
|
||||
@@ -3119,7 +3122,7 @@ activate_old(pcap_t *handle)
|
||||
@@ -4359,7 +4362,7 @@ activate_old(pcap_t *handle)
|
||||
|
||||
/* Open the socket */
|
||||
|
||||
|
@ -96,7 +96,7 @@
|
|||
"socket: %s", pcap_strerror(errno));
|
||||
--- a/pcap.c
|
||||
+++ b/pcap.c
|
||||
@@ -152,6 +152,8 @@ pcap_create_common(const char *source, c
|
||||
@@ -258,6 +258,8 @@ pcap_create_common(const char *source, c
|
||||
pcap_set_snaplen(p, 65535); /* max packet size */
|
||||
p->opt.promisc = 0;
|
||||
p->opt.buffer_size = 0;
|
||||
|
@ -105,10 +105,11 @@
|
|||
return (p);
|
||||
}
|
||||
|
||||
@@ -212,6 +214,15 @@ pcap_set_buffer_size(pcap_t *p, int buff
|
||||
@@ -317,6 +319,15 @@ pcap_set_buffer_size(pcap_t *p, int buff
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
+int
|
||||
+pcap_set_protocol(pcap_t *p, unsigned short proto)
|
||||
+{
|
||||
+ if (pcap_check_activated(p))
|
||||
|
@ -117,13 +118,12 @@
|
|||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
int
|
||||
pcap_activate(pcap_t *p)
|
||||
{
|
||||
int status;
|
||||
--- a/pcap/pcap.h
|
||||
+++ b/pcap/pcap.h
|
||||
@@ -61,6 +61,7 @@ extern "C" {
|
||||
@@ -68,6 +68,7 @@ extern "C" {
|
||||
#define PCAP_VERSION_MINOR 4
|
||||
|
||||
#define PCAP_ERRBUF_SIZE 256
|
||||
|
@ -131,7 +131,7 @@
|
|||
|
||||
/*
|
||||
* Compatibility for systems that have a bpf.h that
|
||||
@@ -263,6 +264,7 @@ int pcap_can_set_rfmon(pcap_t *);
|
||||
@@ -276,6 +277,7 @@ int pcap_can_set_rfmon(pcap_t *);
|
||||
int pcap_set_rfmon(pcap_t *, int);
|
||||
int pcap_set_timeout(pcap_t *, int);
|
||||
int pcap_set_buffer_size(pcap_t *, int);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/pcap-linux.c
|
||||
+++ b/pcap-linux.c
|
||||
@@ -194,6 +194,8 @@ static const char rcsid[] _U_ =
|
||||
@@ -254,6 +254,8 @@ static const char rcsid[] _U_ =
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue