diff options
Diffstat (limited to 'package/libs/libpcap')
-rw-r--r-- | package/libs/libpcap/Config.in | 15 | ||||
-rw-r--r-- | package/libs/libpcap/Makefile | 89 | ||||
-rw-r--r-- | package/libs/libpcap/patches/100-debian_shared_lib.patch | 174 | ||||
-rw-r--r-- | package/libs/libpcap/patches/102-makefile_disable_manpages.patch | 74 | ||||
-rw-r--r-- | package/libs/libpcap/patches/103-makefile_flex_workaround.patch | 14 | ||||
-rw-r--r-- | package/libs/libpcap/patches/201-space_optimization.patch | 133 | ||||
-rw-r--r-- | package/libs/libpcap/patches/202-protocol_api.patch | 140 | ||||
-rw-r--r-- | package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch | 11 |
8 files changed, 650 insertions, 0 deletions
diff --git a/package/libs/libpcap/Config.in b/package/libs/libpcap/Config.in new file mode 100644 index 000000000..5fee75a59 --- /dev/null +++ b/package/libs/libpcap/Config.in @@ -0,0 +1,15 @@ +menu "Configuration" + depends on PACKAGE_libpcap + +config PCAP_HAS_USB + bool "Include USB support" + depends on PACKAGE_kmod-usb-core + default n + +config PCAP_HAS_BT + bool "Include bluetooth support" + depends on PACKAGE_kmod-bluetooth + depends on BROKEN + default n + +endmenu diff --git a/package/libs/libpcap/Makefile b/package/libs/libpcap/Makefile new file mode 100644 index 000000000..f1d287225 --- /dev/null +++ b/package/libs/libpcap/Makefile @@ -0,0 +1,89 @@ +# +# Copyright (C) 2006-2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libpcap +PKG_VERSION:=1.3.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.tcpdump.org/release/ +PKG_MD5SUM:=f78455a92622b7a3c05c58b6ad1cec7e + +PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org> + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/libpcap + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Low-level packet capture library + URL:=http://www.tcpdump.org/ + MENU:=1 +endef + +define Package/libpcap/description +This package contains a system-independent library for user-level network packet +capture. +endef + +define Package/libpcap/config + source "$(SOURCE)/Config.in" +endef + +TARGET_CFLAGS += \ + -ffunction-sections \ + -fdata-sections + +CONFIGURE_VARS += \ + ac_cv_linux_vers=$(LINUX_VERSION) \ + ac_cv_header_libusb_1_0_libusb_h=no \ + ac_cv_netfilter_can_compile=no + + +CONFIGURE_ARGS += \ + --enable-shared \ + --enable-static \ + --disable-yydebug \ + --enable-ipv6 \ + --with-build-cc="$(HOSTCC)" \ + --with-pcap=linux \ + --without-septel \ + --without-dag \ + --without-libnl \ + --disable-can + +MAKE_FLAGS += \ + CCOPT="$(TARGET_CFLAGS) -I$(BUILD_DIR)/linux/include" + +define Build/Configure + $(call Build/Configure/Default) + $(if $(CONFIG_PCAP_HAS_USB),,$(SED) '/^#define PCAP_SUPPORT_USB/D' $(PKG_BUILD_DIR)/config.h) + $(if $(CONFIG_PCAP_HAS_USB),,$(SED) 's/pcap-usb-linux.c *//' $(PKG_BUILD_DIR)/Makefile) + $(if $(CONFIG_PCAP_HAS_BT),,$(SED) '/^#define PCAP_SUPPORT_BT/D' $(PKG_BUILD_DIR)/config.h) + $(if $(CONFIG_PCAP_HAS_BT),,$(SED) 's/pcap-bt-linux.c *//' $(PKG_BUILD_DIR)/Makefile) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/pcap* $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.{a,so*} $(1)/usr/lib/ +endef + +define Package/libpcap/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libpcap)) diff --git a/package/libs/libpcap/patches/100-debian_shared_lib.patch b/package/libs/libpcap/patches/100-debian_shared_lib.patch new file mode 100644 index 000000000..30cb10ae3 --- /dev/null +++ b/package/libs/libpcap/patches/100-debian_shared_lib.patch @@ -0,0 +1,174 @@ +Debian-specific modifications to the upstream Makefile.in to +build a shared library. + +--- a/Makefile.in ++++ b/Makefile.in +@@ -40,6 +40,14 @@ + srcdir = @srcdir@ + VPATH = @srcdir@ + ++# some defines for shared library compilation ++MAJ=1.3 ++LIBVERSION=$(MAJ).0 ++LIBNAME=pcap ++LIBRARY=lib$(LIBNAME).a ++SOLIBRARY=lib$(LIBNAME).so ++SHAREDLIB=$(SOLIBRARY).$(LIBVERSION) ++ + # + # You shouldn't need to edit anything below. + # +@@ -60,7 +68,8 @@ + PROG=libpcap + + # Standard CFLAGS +-FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) ++FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS) ++CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ) + + INSTALL = @INSTALL@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -80,7 +89,11 @@ + # problem if you don't own the file but can write to the directory. + .c.o: + @rm -f $@ +- $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c ++ $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c ++ ++%_pic.o: %.c ++ @rm -f $@ ++ $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c + + PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ + FSRC = fad-@V_FINDALLDEVS@.c +@@ -96,6 +109,7 @@ + # 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) + PUBHDR = \ + pcap.h \ + pcap-bpf.h \ +@@ -148,7 +162,7 @@ + + CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ + $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ +- lex.yy.c pcap-config ++ lex.yy.c pcap-config $(OBJ_PIC) + + MAN1 = pcap-config.1 + +@@ -352,7 +366,7 @@ + $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) + $(RANLIB) $@ + +-shared: libpcap.$(DYEXT) ++shared: $(SHAREDLIB) + + libpcap.so: $(OBJ) + @rm -f $@ +@@ -430,6 +444,13 @@ + # + libpcap.none: + ++$(SHAREDLIB): $(OBJ_PIC) ++ -@rm -f $@ ++ -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ) ++ $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS) ++ ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ) ++ ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY) ++ + scanner.c: $(srcdir)/scanner.l + @rm -f $@ + $(srcdir)/runlex.sh $(LEX) -o$@ $< +@@ -437,6 +458,9 @@ + scanner.o: scanner.c tokdefs.h + $(CC) $(FULL_CFLAGS) -c scanner.c + ++scanner_pic.o: scanner.c tokdefs.h ++ $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c ++ + pcap.o: version.h + + tokdefs.h: grammar.c +@@ -450,9 +474,16 @@ + @rm -f $@ + $(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c + ++grammar_pic.o: grammar.c ++ @rm -f $@ ++ $(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c ++ + version.o: version.c + $(CC) $(FULL_CFLAGS) -c version.c + ++version_pic.o: version.c ++ $(CC) -fPIC $(FULL_CFLAGS) -c version.c -o $@ ++ + snprintf.o: $(srcdir)/missing/snprintf.c + $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c + +@@ -490,6 +521,9 @@ + bpf_filter.o: bpf_filter.c + $(CC) $(FULL_CFLAGS) -c bpf_filter.c + ++bpf_filter_pic.o: bpf_filter.c ++ $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@ ++ + # + # Generate the pcap-config script. + # +@@ -607,11 +641,9 @@ + install-shared-so: libpcap.so + [ -d $(DESTDIR)$(libdir) ] || \ + (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) +- VER=`cat $(srcdir)/VERSION`; \ +- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ +- $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \ +- ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \ +- ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so ++ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/ ++ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ) ++ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY) + install-shared-dylib: libpcap.dylib + [ -d $(DESTDIR)$(libdir) ] || \ + (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -262,7 +262,7 @@ + esac + ;; + esac +- V_CCOPT="$V_CCOPT $PIC_OPT" ++ V_CCOPT="$V_CCOPT" + V_SONAME_OPT="-Wl,-soname," + V_RPATH_OPT="-Wl,-rpath," + ;; +@@ -325,7 +325,7 @@ + # + # "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," +--- a/pcap-config.in ++++ b/pcap-config.in +@@ -36,16 +36,6 @@ + esac + shift + done +-if [ "$V_RPATH_OPT" != "" ] +-then +- # +- # If libdir isn't /usr/lib, add it to the run-time linker path. +- # +- if [ "$libdir" != "/usr/lib" ] +- then +- RPATH=$V_RPATH_OPT$libdir +- fi +-fi + if [ "$static" = 1 ] + then + # diff --git a/package/libs/libpcap/patches/102-makefile_disable_manpages.patch b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch new file mode 100644 index 000000000..50ea2211a --- /dev/null +++ b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch @@ -0,0 +1,74 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -571,71 +571,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) +- [ -d $(DESTDIR)$(mandir)/man1 ] || \ +- (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) +- [ -d $(DESTDIR)$(mandir)/man3 ] || \ +- (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3) +- [ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \ +- (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@) + 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_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_freealldevs.3pcap +- ln $(DESTDIR)$(mandir)/man3/pcap_findalldevs.3pcap \ +- $(DESTDIR)$(mandir)/man3/pcap_freealldevs.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_free_datalinks.3pcap +- ln $(DESTDIR)$(mandir)/man3/pcap_list_datalinks.3pcap \ +- $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap +- rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap +- ln $(DESTDIR)$(mandir)/man3/pcap_list_tstamp_types.3pcap \ +- $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.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) `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) `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 diff --git a/package/libs/libpcap/patches/103-makefile_flex_workaround.patch b/package/libs/libpcap/patches/103-makefile_flex_workaround.patch new file mode 100644 index 000000000..a90e0ce1a --- /dev/null +++ b/package/libs/libpcap/patches/103-makefile_flex_workaround.patch @@ -0,0 +1,14 @@ + + Copyright (C) 2006 Markus Wigge + +--- a/Makefile.in ++++ b/Makefile.in +@@ -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@ + ADDLOBJS = @ADDLOBJS@ + ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@ + LIBS = @LIBS@ diff --git a/package/libs/libpcap/patches/201-space_optimization.patch b/package/libs/libpcap/patches/201-space_optimization.patch new file mode 100644 index 000000000..f3eec4c83 --- /dev/null +++ b/package/libs/libpcap/patches/201-space_optimization.patch @@ -0,0 +1,133 @@ +--- a/gencode.c ++++ b/gencode.c +@@ -491,20 +491,6 @@ pcap_compile_nopcap(int snaplen_arg, int + } + + /* +- * Clean up a "struct bpf_program" by freeing all the memory allocated +- * in it. +- */ +-void +-pcap_freecode(struct bpf_program *program) +-{ +- program->bf_len = 0; +- if (program->bf_insns != NULL) { +- free((char *)program->bf_insns); +- program->bf_insns = NULL; +- } +-} +- +-/* + * Backpatch the blocks in 'list' to 'target'. The 'sense' field indicates + * which of the jt and jf fields has been resolved and which is a pointer + * back to another unresolved block (or nil). At least one of the fields +--- a/pcap.c ++++ b/pcap.c +@@ -748,6 +748,59 @@ static const u_char charmap[] = { + (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377', + }; + ++/* ++ * Clean up a "struct bpf_program" by freeing all the memory allocated ++ * in it. ++ */ ++void ++pcap_freecode(struct bpf_program *program) ++{ ++ program->bf_len = 0; ++ if (program->bf_insns != NULL) { ++ free((char *)program->bf_insns); ++ program->bf_insns = NULL; ++ } ++} ++ ++/* ++ * Make a copy of a BPF program and put it in the "fcode" member of ++ * a "pcap_t". ++ * ++ * If we fail to allocate memory for the copy, fill in the "errbuf" ++ * member of the "pcap_t" with an error message, and return -1; ++ * otherwise, return 0. ++ */ ++int ++install_bpf_program(pcap_t *p, struct bpf_program *fp) ++{ ++ size_t prog_size; ++ ++ /* ++ * Validate the program. ++ */ ++ if (!bpf_validate(fp->bf_insns, fp->bf_len)) { ++ snprintf(p->errbuf, sizeof(p->errbuf), ++ "BPF program is not valid"); ++ return (-1); ++ } ++ ++ /* ++ * Free up any already installed program. ++ */ ++ pcap_freecode(&p->fcode); ++ ++ prog_size = sizeof(*fp->bf_insns) * fp->bf_len; ++ p->fcode.bf_len = fp->bf_len; ++ p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size); ++ if (p->fcode.bf_insns == NULL) { ++ snprintf(p->errbuf, sizeof(p->errbuf), ++ "malloc: %s", pcap_strerror(errno)); ++ return (-1); ++ } ++ memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size); ++ return (0); ++} ++ + int + pcap_strcasecmp(const char *s1, const char *s2) + { +--- a/optimize.c ++++ b/optimize.c +@@ -2292,45 +2292,6 @@ icode_to_fcode(root, lenp) + return fp; + } + +-/* +- * Make a copy of a BPF program and put it in the "fcode" member of +- * a "pcap_t". +- * +- * If we fail to allocate memory for the copy, fill in the "errbuf" +- * member of the "pcap_t" with an error message, and return -1; +- * otherwise, return 0. +- */ +-int +-install_bpf_program(pcap_t *p, struct bpf_program *fp) +-{ +- size_t prog_size; +- +- /* +- * Validate the program. +- */ +- if (!bpf_validate(fp->bf_insns, fp->bf_len)) { +- snprintf(p->errbuf, sizeof(p->errbuf), +- "BPF program is not valid"); +- return (-1); +- } +- +- /* +- * Free up any already installed program. +- */ +- pcap_freecode(&p->fcode); +- +- prog_size = sizeof(*fp->bf_insns) * fp->bf_len; +- p->fcode.bf_len = fp->bf_len; +- p->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size); +- if (p->fcode.bf_insns == NULL) { +- snprintf(p->errbuf, sizeof(p->errbuf), +- "malloc: %s", pcap_strerror(errno)); +- return (-1); +- } +- memcpy(p->fcode.bf_insns, fp->bf_insns, prog_size); +- return (0); +-} +- + #ifdef BDEBUG + static void + opt_dump(root) diff --git a/package/libs/libpcap/patches/202-protocol_api.patch b/package/libs/libpcap/patches/202-protocol_api.patch new file mode 100644 index 000000000..fabbac73f --- /dev/null +++ b/package/libs/libpcap/patches/202-protocol_api.patch @@ -0,0 +1,140 @@ +--- a/pcap-int.h ++++ b/pcap-int.h +@@ -209,6 +209,7 @@ struct pcap_opt { + char *source; + int promisc; + int rfmon; ++ int proto; /* protocol for packet socket (linux) */ + int tstamp_type; + }; + +--- a/pcap-linux.c ++++ b/pcap-linux.c +@@ -363,7 +363,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); + #endif /* IW_MODE_MONITOR */ +@@ -980,7 +980,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(handle->errbuf, PCAP_ERRBUF_SIZE, + "socket: %s", pcap_strerror(errno)); +@@ -1266,6 +1266,9 @@ pcap_activate_linux(pcap_t *handle) + handle->read_op = pcap_read_linux; + handle->stats_op = pcap_stats_linux; + ++ if (handle->opt.proto < 0) ++ handle->opt.proto = (int) htons(ETH_P_ALL); ++ + /* + * The "any" device is a special device which causes us not + * to bind to a particular device and thus to look at all +@@ -2897,8 +2900,8 @@ activate_new(pcap_t *handle) + * 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)); ++ socket(PF_PACKET, SOCK_DGRAM, handle->opt.proto) : ++ socket(PF_PACKET, SOCK_RAW, handle->opt.proto); + + if (sock_fd == -1) { + if (errno == EINVAL || errno == EAFNOSUPPORT) { +@@ -3015,7 +3018,7 @@ activate_new(pcap_t *handle) + return PCAP_ERROR; + } + sock_fd = socket(PF_PACKET, SOCK_DGRAM, +- htons(ETH_P_ALL)); ++ handle->opt.proto); + if (sock_fd == -1) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "socket: %s", pcap_strerror(errno)); +@@ -3078,7 +3081,7 @@ activate_new(pcap_t *handle) + } + + if ((err = iface_bind(sock_fd, handle->md.ifindex, +- handle->errbuf)) != 1) { ++ handle->errbuf, handle->opt.proto)) != 1) { + close(sock_fd); + if (err < 0) + return err; +@@ -4149,7 +4152,7 @@ iface_get_id(int fd, const char *device, + * or a PCAP_ERROR_ value on a hard error. + */ + static int +-iface_bind(int fd, int ifindex, char *ebuf) ++iface_bind(int fd, int ifindex, char *ebuf, unsigned short proto) + { + struct sockaddr_ll sll; + int err; +@@ -4158,7 +4161,7 @@ iface_bind(int fd, int ifindex, char *eb + memset(&sll, 0, sizeof(sll)); + sll.sll_family = AF_PACKET; + sll.sll_ifindex = ifindex; +- sll.sll_protocol = htons(ETH_P_ALL); ++ sll.sll_protocol = proto; + + if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) { + if (errno == ENETDOWN) { +@@ -5040,7 +5043,7 @@ activate_old(pcap_t *handle) + + /* Open the socket */ + +- handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); ++ handle->fd = socket(PF_INET, SOCK_PACKET, handle->opt.proto); + if (handle->fd == -1) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "socket: %s", pcap_strerror(errno)); +--- a/pcap.c ++++ b/pcap.c +@@ -309,6 +309,7 @@ pcap_create_common(const char *source, c + pcap_set_snaplen(p, 65535); /* max packet size */ + p->opt.promisc = 0; + p->opt.buffer_size = 0; ++ p->opt.proto = -1; + p->opt.tstamp_type = -1; /* default to not setting time stamp type */ + return (p); + } +@@ -405,6 +406,15 @@ pcap_set_buffer_size(pcap_t *p, int buff + } + + int ++pcap_set_protocol(pcap_t *p, unsigned short proto) ++{ ++ if (pcap_check_activated(p)) ++ return PCAP_ERROR_ACTIVATED; ++ p->opt.proto = proto; ++ return 0; ++} ++ ++int + pcap_activate(pcap_t *p) + { + int status; +--- a/pcap/pcap.h ++++ b/pcap/pcap.h +@@ -68,6 +68,7 @@ extern "C" { + #define PCAP_VERSION_MINOR 4 + + #define PCAP_ERRBUF_SIZE 256 ++#define HAS_PROTO_EXTENSION + + /* + * Compatibility for systems that have a bpf.h that +@@ -280,6 +281,7 @@ int pcap_set_rfmon(pcap_t *, int); + int pcap_set_timeout(pcap_t *, int); + int pcap_set_tstamp_type(pcap_t *, int); + int pcap_set_buffer_size(pcap_t *, int); ++int pcap_set_protocol(pcap_t *, unsigned short); + int pcap_activate(pcap_t *); + + int pcap_list_tstamp_types(pcap_t *, int **); diff --git a/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch b/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch new file mode 100644 index 000000000..508c6590a --- /dev/null +++ b/package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch @@ -0,0 +1,11 @@ +--- a/pcap-linux.c ++++ b/pcap-linux.c +@@ -254,6 +254,8 @@ static const char rcsid[] _U_ = + typedef int socklen_t; + #endif + ++#undef IW_MODE_MONITOR ++ + #ifndef MSG_TRUNC + /* + * This is being compiled on a system that lacks MSG_TRUNC; define it |