From 716ca530e1c4515d8683c9d5be3d56b301758b66 Mon Sep 17 00:00:00 2001 From: James <> Date: Wed, 4 Nov 2015 11:49:21 +0000 Subject: trunk-47381 --- .../libpcap/patches/100-debian_shared_lib.patch | 174 +++++++++++++++++++++ .../patches/102-makefile_disable_manpages.patch | 73 +++++++++ .../patches/103-makefile_flex_workaround.patch | 14 ++ .../libpcap/patches/201-space_optimization.patch | 159 +++++++++++++++++++ .../libs/libpcap/patches/202-protocol_api.patch | 140 +++++++++++++++++ .../patches/203-undef_iw_mode_monitor.patch | 11 ++ 6 files changed, 571 insertions(+) create mode 100644 package/libs/libpcap/patches/100-debian_shared_lib.patch create mode 100644 package/libs/libpcap/patches/102-makefile_disable_manpages.patch create mode 100644 package/libs/libpcap/patches/103-makefile_flex_workaround.patch create mode 100644 package/libs/libpcap/patches/201-space_optimization.patch create mode 100644 package/libs/libpcap/patches/202-protocol_api.patch create mode 100644 package/libs/libpcap/patches/203-undef_iw_mode_monitor.patch (limited to 'package/libs/libpcap/patches') 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 0000000..b294e51 --- /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 @@ mandir = @mandir@ + 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. + # +@@ -63,7 +71,8 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ + 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@ +@@ -83,7 +92,11 @@ YACC = @V_YACC@ + # 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@ @DBUS_SRC@ + FSRC = fad-@V_FINDALLDEVS@.c +@@ -99,6 +112,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) + PUBHDR = \ + pcap.h \ + pcap-bpf.h \ +@@ -153,7 +167,7 @@ TAGFILES = \ + + 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 + +@@ -363,7 +377,7 @@ libpcap.a: $(OBJ) + $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) + $(RANLIB) $@ + +-shared: libpcap.$(DYEXT) ++shared: $(SHAREDLIB) + + libpcap.so: $(OBJ) + @rm -f $@ +@@ -441,6 +455,13 @@ libpcap.shareda: $(OBJ) + # + 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$@ $< +@@ -448,6 +469,9 @@ scanner.c: $(srcdir)/scanner.l + 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 +@@ -461,9 +485,16 @@ grammar.o: grammar.c + @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 + +@@ -501,6 +532,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt + 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. + # +@@ -618,11 +652,9 @@ install-shared: install-shared-$(DYEXT) + 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 +@@ -440,7 +440,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, + esac + ;; + esac +- V_CCOPT="$V_CCOPT $PIC_OPT" ++ V_CCOPT="$V_CCOPT" + V_SONAME_OPT="-Wl,-soname," + V_RPATH_OPT="-Wl,-rpath," + ;; +@@ -503,7 +503,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, + # + # "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 @@ do + 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 0000000..59b903c --- /dev/null +++ b/package/libs/libpcap/patches/102-makefile_disable_manpages.patch @@ -0,0 +1,73 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -590,70 +590,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 +- (cd $(DESTDIR)$(mandir)/man3 && \ +- rm -f pcap_datalink_val_to_description.3pcap && \ +- $(LN_S) pcap_datalink_val_to_name.3pcap \ +- pcap_datalink_val_to_description.3pcap && \ +- rm -f pcap_dump_fopen.3pcap && \ +- $(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \ +- rm -f pcap_freealldevs.3pcap && \ +- $(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \ +- rm -f pcap_perror.3pcap && \ +- $(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \ +- rm -f pcap_sendpacket.3pcap && \ +- $(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \ +- rm -f pcap_free_datalinks.3pcap && \ +- $(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \ +- rm -f pcap_free_tstamp_types.3pcap && \ +- $(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \ +- rm -f pcap_dispatch.3pcap && \ +- $(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \ +- rm -f pcap_minor_version.3pcap && \ +- $(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \ +- rm -f pcap_next.3pcap && \ +- $(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \ +- rm -f pcap_open_dead_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_dead.3pcap \ +- pcap_open_dead_with_tstamp_precision.3pcap && \ +- rm -f pcap_open_offline_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \ +- rm -f pcap_fopen_offline.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \ +- rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \ +- $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \ +- rm -f pcap_tstamp_type_val_to_description.3pcap && \ +- $(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \ +- rm -f pcap_getnonblock.3pcap && \ +- $(LN_S) pcap_setnonblock.3pcap 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 0000000..a7ab9ad --- /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 +@@ -57,7 +57,7 @@ LN_S = @LN_S@ + MKDEP = @MKDEP@ + 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 0000000..f331a18 --- /dev/null +++ b/package/libs/libpcap/patches/201-space_optimization.patch @@ -0,0 +1,159 @@ +--- a/gencode.c ++++ b/gencode.c +@@ -543,20 +543,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 +@@ -1087,6 +1087,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 +@@ -2203,45 +2203,6 @@ icode_to_fcode(struct block *root, u_int + 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 + dot_dump_node(struct block *block, struct bpf_program *prog, FILE *out) +--- a/pcap-common.c ++++ b/pcap-common.c +@@ -1372,14 +1372,23 @@ swap_pseudo_headers(int linktype, struct + switch (linktype) { + + case DLT_USB_LINUX: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 0); + break; + + case DLT_USB_LINUX_MMAPPED: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 1); + break; + + case DLT_NFLOG: ++#ifndef PCAP_SUPPORT_NETFILTER ++ return; ++#endif + swap_nflog_header(hdr, data); + break; + } 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 0000000..d0c32a5 --- /dev/null +++ b/package/libs/libpcap/patches/202-protocol_api.patch @@ -0,0 +1,140 @@ +--- a/pcap-linux.c ++++ b/pcap-linux.c +@@ -414,7 +414,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 */ +@@ -1028,7 +1028,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)); +@@ -1337,6 +1337,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 +@@ -3160,8 +3163,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) { +@@ -3279,7 +3282,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)); +@@ -3343,7 +3346,7 @@ activate_new(pcap_t *handle) + } + + if ((err = iface_bind(sock_fd, handlep->ifindex, +- handle->errbuf)) != 1) { ++ handle->errbuf, handle->opt.proto)) != 1) { + close(sock_fd); + if (err < 0) + return err; +@@ -5050,7 +5053,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; +@@ -5059,7 +5062,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) { +@@ -6049,7 +6052,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 +@@ -562,6 +562,7 @@ pcap_create_common(const char *source, c + p->opt.promisc = 0; + p->opt.rfmon = 0; + p->opt.immediate = 0; ++ p->opt.proto = -1; + p->opt.tstamp_type = -1; /* default to not setting time stamp type */ + p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; + +@@ -725,6 +726,15 @@ pcap_get_tstamp_precision(pcap_t *p) + } + + 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 +@@ -66,6 +66,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 +@@ -283,6 +284,7 @@ int pcap_set_timeout(pcap_t *, int); + int pcap_set_tstamp_type(pcap_t *, int); + int pcap_set_immediate_mode(pcap_t *, int); + int pcap_set_buffer_size(pcap_t *, int); ++int pcap_set_protocol(pcap_t *, unsigned short); + int pcap_set_tstamp_precision(pcap_t *, int); + int pcap_get_tstamp_precision(pcap_t *); + int pcap_activate(pcap_t *); +--- a/pcap-int.h ++++ b/pcap-int.h +@@ -109,6 +109,7 @@ struct pcap_opt { + char *source; + int timeout; /* timeout for buffering */ + int buffer_size; ++ int proto; /* protocol for packet socket (linux) */ + int promisc; + int rfmon; /* monitor mode */ + int immediate; /* immediate mode - deliver packets as soon as they arrive */ 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 0000000..f847a5e --- /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 @@ + 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 -- cgit v1.2.3