libs/libpcap: update to 1.8.1
Update libpcap to upstream release 1.8.1 Change the name from libpcap.so.1.3 to libpcap.so.1 Remove parts of patch 201 which moved code among src files. Import patch 204 from Debian to update the USB path. Signed-off-by: Paul Wassi <p.wassi@gmx.at> Signed-off-by: Felix Fietkau <nbd@nbd.name> [fix parallel build bug]
This commit is contained in:
		| @@ -8,12 +8,12 @@ | |||||||
| include $(TOPDIR)/rules.mk | include $(TOPDIR)/rules.mk | ||||||
|  |  | ||||||
| PKG_NAME:=libpcap | PKG_NAME:=libpcap | ||||||
| PKG_VERSION:=1.7.4 | PKG_VERSION:=1.8.1 | ||||||
| PKG_RELEASE:=1 | PKG_RELEASE:=1 | ||||||
|  |  | ||||||
| PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | ||||||
| PKG_SOURCE_URL:=http://www.tcpdump.org/release/ | PKG_SOURCE_URL:=http://www.tcpdump.org/release/ | ||||||
| PKG_MD5SUM:=b2e13142bbaba857ab1c6894aedaf547 | PKG_MD5SUM:=3d48f9cd171ff12b0efd9134b52f1447 | ||||||
| PKG_FIXUP:=patch-libtool | PKG_FIXUP:=patch-libtool | ||||||
|  |  | ||||||
| PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> | PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> | ||||||
|   | |||||||
| @@ -3,13 +3,12 @@ build a shared library. | |||||||
|  |  | ||||||
| --- a/Makefile.in | --- a/Makefile.in | ||||||
| +++ b/Makefile.in | +++ b/Makefile.in | ||||||
| @@ -38,6 +38,14 @@ mandir = @mandir@ | @@ -38,6 +38,13 @@ mandir = @mandir@ | ||||||
|  srcdir = @srcdir@ |  srcdir = @srcdir@ | ||||||
|  VPATH = @srcdir@ |  VPATH = @srcdir@ | ||||||
|   |   | ||||||
| +# some defines for shared library compilation | +# some defines for shared library compilation | ||||||
| +MAJ=1.3 | +LIBVERSION=1 | ||||||
| +LIBVERSION=$(MAJ).0 |  | ||||||
| +LIBNAME=pcap | +LIBNAME=pcap | ||||||
| +LIBRARY=lib$(LIBNAME).a | +LIBRARY=lib$(LIBNAME).a | ||||||
| +SOLIBRARY=lib$(LIBNAME).so | +SOLIBRARY=lib$(LIBNAME).so | ||||||
| @@ -18,30 +17,30 @@ build a shared library. | |||||||
|  # |  # | ||||||
|  # You shouldn't need to edit anything below. |  # You shouldn't need to edit anything below. | ||||||
|  # |  # | ||||||
| @@ -62,7 +70,8 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ | @@ -62,7 +69,8 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ | ||||||
|  PROG=libpcap |  PROG=libpcap | ||||||
|   |   | ||||||
|  # Standard CFLAGS |  # Standard CFLAGS | ||||||
| -FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) | -FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) | ||||||
| +FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS) | +FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS) | ||||||
| +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ) | +CFLAGS_SHARED = -shared -Wl,-soname,$(SHAREDLIB) | ||||||
|   |   | ||||||
|  INSTALL = @INSTALL@ |  INSTALL = @INSTALL@ | ||||||
|  INSTALL_PROGRAM = @INSTALL_PROGRAM@ |  INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||||||
| @@ -82,7 +91,11 @@ YACC = @V_YACC@ | @@ -77,7 +85,11 @@ YACC = @YACC@ | ||||||
|  # problem if you don't own the file but can write to the directory. |  # problem if you don't own the file but can write to the directory. | ||||||
|  .c.o: |  .c.o: | ||||||
|  	@rm -f $@ |  	@rm -f $@ | ||||||
| -	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c | -	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c | ||||||
| +	$(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c | +	$(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c | ||||||
| + | + | ||||||
| +%_pic.o: %.c | +%_pic.o: %.c %.o | ||||||
| +	@rm -f $@ | +	@rm -f $@ | ||||||
| +	$(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c | +	$(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c | ||||||
|   |   | ||||||
|  PSRC =	pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@ |  PSRC =	pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ | ||||||
|  FSRC =  fad-@V_FINDALLDEVS@.c |  FSRC =  @V_FINDALLDEVS@ | ||||||
| @@ -98,6 +111,7 @@ SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $( | @@ -93,6 +105,7 @@ SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $( | ||||||
|  # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot |  # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot | ||||||
|  # hack the extra indirection |  # hack the extra indirection | ||||||
|  OBJ =	$(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) |  OBJ =	$(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) | ||||||
| @@ -49,7 +48,7 @@ build a shared library. | |||||||
|  PUBHDR = \ |  PUBHDR = \ | ||||||
|  	pcap.h \ |  	pcap.h \ | ||||||
|  	pcap-bpf.h \ |  	pcap-bpf.h \ | ||||||
| @@ -153,7 +167,7 @@ TAGFILES = \ | @@ -157,7 +170,7 @@ TAGFILES = \ | ||||||
|   |   | ||||||
|  CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ |  CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ | ||||||
|  	$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ |  	$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ | ||||||
| @@ -58,7 +57,7 @@ build a shared library. | |||||||
|   |   | ||||||
|  MAN1 = pcap-config.1 |  MAN1 = pcap-config.1 | ||||||
|   |   | ||||||
| @@ -365,7 +379,7 @@ libpcap.a: $(OBJ) | @@ -365,7 +378,7 @@ libpcap.a: $(OBJ) | ||||||
|  	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) |  	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) | ||||||
|  	$(RANLIB) $@ |  	$(RANLIB) $@ | ||||||
|   |   | ||||||
| @@ -67,33 +66,32 @@ build a shared library. | |||||||
|   |   | ||||||
|  libpcap.so: $(OBJ) |  libpcap.so: $(OBJ) | ||||||
|  	@rm -f $@ |  	@rm -f $@ | ||||||
| @@ -443,6 +457,13 @@ libpcap.shareda: $(OBJ) | @@ -443,6 +456,12 @@ libpcap.shareda: $(OBJ) | ||||||
|  # |  # | ||||||
|  libpcap.none: |  libpcap.none: | ||||||
|   |   | ||||||
| +$(SHAREDLIB): $(OBJ_PIC) | +$(SHAREDLIB): $(OBJ_PIC) | ||||||
| +	-@rm -f $@ | +	-@rm -f $@ | ||||||
| +	-@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ) | +	-@rm -f $(SOLIBRARY) | ||||||
| +	$(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS) | +	$(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS) | ||||||
| +	ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ) | +	ln -s $(SHAREDLIB) $(SOLIBRARY) | ||||||
| +	ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY) |  | ||||||
| + | + | ||||||
|  scanner.c: $(srcdir)/scanner.l |  scanner.c: $(srcdir)/scanner.l | ||||||
|  	@rm -f $@ $@.bottom |  	$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $< | ||||||
|  	$(srcdir)/runlex.sh $(LEX) -o$@ $< |  scanner.h: scanner.c | ||||||
| @@ -453,6 +474,9 @@ scanner.c: $(srcdir)/scanner.l | @@ -455,6 +474,9 @@ scanner.h: scanner.c | ||||||
|  scanner.o: scanner.c tokdefs.h |  scanner.o: scanner.c grammar.h | ||||||
|  	$(CC) $(FULL_CFLAGS) -c scanner.c |  	$(CC) $(FULL_CFLAGS) -c scanner.c | ||||||
|   |   | ||||||
| +scanner_pic.o: scanner.c tokdefs.h | +scanner_pic.o: scanner.c grammar.h | ||||||
| +	$(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c | +	$(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c | ||||||
| + | + | ||||||
|  pcap.o: version.h |  pcap.o: pcap_version.h | ||||||
|   |   | ||||||
|  tokdefs.h: grammar.c |  grammar.c: $(srcdir)/grammar.y | ||||||
| @@ -466,9 +490,16 @@ grammar.o: grammar.c | @@ -472,9 +494,16 @@ grammar.o: grammar.c | ||||||
|  	@rm -f $@ |  gencode.o: $(srcdir)/gencode.c grammar.h scanner.h | ||||||
|  	$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c |  	$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c | ||||||
|   |   | ||||||
| +grammar_pic.o: grammar.c | +grammar_pic.o: grammar.c | ||||||
| +	@rm -f $@ | +	@rm -f $@ | ||||||
| @@ -108,7 +106,7 @@ build a shared library. | |||||||
|  snprintf.o: $(srcdir)/missing/snprintf.c |  snprintf.o: $(srcdir)/missing/snprintf.c | ||||||
|  	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c |  	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c | ||||||
|   |   | ||||||
| @@ -506,6 +537,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt | @@ -501,6 +530,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt | ||||||
|  bpf_filter.o: bpf_filter.c |  bpf_filter.o: bpf_filter.c | ||||||
|  	$(CC) $(FULL_CFLAGS) -c bpf_filter.c |  	$(CC) $(FULL_CFLAGS) -c bpf_filter.c | ||||||
|   |   | ||||||
| @@ -118,7 +116,7 @@ build a shared library. | |||||||
|  # |  # | ||||||
|  # Generate the pcap-config script. |  # Generate the pcap-config script. | ||||||
|  # |  # | ||||||
| @@ -622,14 +656,12 @@ install: install-shared install-archive | @@ -623,14 +655,11 @@ install: install-shared install-archive | ||||||
|  		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done |  		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done | ||||||
|   |   | ||||||
|  install-shared: install-shared-$(DYEXT) |  install-shared: install-shared-$(DYEXT) | ||||||
| @@ -132,14 +130,13 @@ build a shared library. | |||||||
| -	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \ | -	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \ | ||||||
| -	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so | -	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so | ||||||
| +	$(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/ | +	$(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/ | ||||||
| +	ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ) | +	ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY) | ||||||
| +	ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY) |  | ||||||
|  install-shared-dylib: libpcap.dylib |  install-shared-dylib: libpcap.dylib | ||||||
|  	[ -d $(DESTDIR)$(libdir) ] || \ |  	[ -d $(DESTDIR)$(libdir) ] || \ | ||||||
|  	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) |  	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) | ||||||
| --- a/aclocal.m4 | --- a/aclocal.m4 | ||||||
| +++ b/aclocal.m4 | +++ b/aclocal.m4 | ||||||
| @@ -438,7 +438,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, | @@ -470,7 +470,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, | ||||||
|  			esac |  			esac | ||||||
|  			;; |  			;; | ||||||
|  		    esac |  		    esac | ||||||
| @@ -148,7 +145,7 @@ build a shared library. | |||||||
|  		    V_SONAME_OPT="-Wl,-soname," |  		    V_SONAME_OPT="-Wl,-soname," | ||||||
|  		    V_RPATH_OPT="-Wl,-rpath," |  		    V_RPATH_OPT="-Wl,-rpath," | ||||||
|  		    ;; |  		    ;; | ||||||
| @@ -501,7 +501,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, | @@ -533,7 +533,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, | ||||||
|  		    # |  		    # | ||||||
|  		    # "cc" is GCC. |  		    # "cc" is GCC. | ||||||
|  		    # |  		    # | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- a/Makefile.in | --- a/Makefile.in | ||||||
| +++ b/Makefile.in | +++ b/Makefile.in | ||||||
| @@ -590,70 +590,12 @@ install: install-shared install-archive | @@ -589,70 +589,12 @@ install: install-shared install-archive | ||||||
|  	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir)) |  	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir)) | ||||||
|  	[ -d $(DESTDIR)$(includedir)/pcap ] || \ |  	[ -d $(DESTDIR)$(includedir)/pcap ] || \ | ||||||
|  	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap) |  	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap) | ||||||
| @@ -70,4 +70,4 @@ | |||||||
| -		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done | -		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done | ||||||
|   |   | ||||||
|  install-shared: install-shared-$(DYEXT) |  install-shared: install-shared-$(DYEXT) | ||||||
|  install-shared-so: libpcap.so |  install-shared-so: $(SHAREDLIB) | ||||||
|   | |||||||
| @@ -3,12 +3,12 @@ | |||||||
|  |  | ||||||
| --- a/Makefile.in | --- a/Makefile.in | ||||||
| +++ b/Makefile.in | +++ b/Makefile.in | ||||||
| @@ -57,7 +57,7 @@ LN_S = @LN_S@ | @@ -56,7 +56,7 @@ LN_S = @LN_S@ | ||||||
|  MKDEP = @MKDEP@ |  MKDEP = @MKDEP@ | ||||||
|  CCOPT = @V_CCOPT@ |  CCOPT = @V_CCOPT@ | ||||||
|  INCLS = -I. @V_INCLS@ |  INCLS = -I. @V_INCLS@ | ||||||
| -DEFS = @DEFS@ @V_DEFS@ | -DEFS = -DBUILDING_PCAP @DEFS@ @V_DEFS@ | ||||||
| +DEFS = -D_BSD_SOURCE @DEFS@ @V_DEFS@ | +DEFS = -DBUILDING_PCAP -D_BSD_SOURCE @DEFS@ @V_DEFS@ | ||||||
|  ADDLOBJS = @ADDLOBJS@ |  ADDLOBJS = @ADDLOBJS@ | ||||||
|  ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@ |  ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@ | ||||||
|  LIBS = @LIBS@ |  LIBS = @LIBS@ | ||||||
|   | |||||||
| @@ -1,140 +1,7 @@ | |||||||
| --- 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 | --- a/pcap-common.c | ||||||
| +++ b/pcap-common.c | +++ b/pcap-common.c | ||||||
| @@ -1372,14 +1372,23 @@ swap_pseudo_headers(int linktype, struct | @@ -1447,14 +1447,23 @@ swap_pseudo_headers(int linktype, struct | ||||||
|  	switch (linktype) { |  		break; | ||||||
|   |   | ||||||
|  	case DLT_USB_LINUX: |  	case DLT_USB_LINUX: | ||||||
| +#ifndef PCAP_SUPPORT_USB | +#ifndef PCAP_SUPPORT_USB | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
|  | This API extension is used by ead (Emergency Access Daemon) | ||||||
|  |  | ||||||
| --- a/pcap-linux.c | --- a/pcap-linux.c | ||||||
| +++ b/pcap-linux.c | +++ b/pcap-linux.c | ||||||
| @@ -414,7 +414,7 @@ static int	iface_get_id(int fd, const ch | @@ -425,7 +425,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_mtu(int fd, const char *device, char *ebuf); | ||||||
|  static int 	iface_get_arptype(int fd, const char *device, char *ebuf); |  static int 	iface_get_arptype(int fd, const char *device, char *ebuf); | ||||||
|  #ifdef HAVE_PF_PACKET_SOCKETS |  #ifdef HAVE_PF_PACKET_SOCKETS | ||||||
| @@ -9,16 +11,16 @@ | |||||||
|  #ifdef IW_MODE_MONITOR |  #ifdef IW_MODE_MONITOR | ||||||
|  static int	has_wext(int sock_fd, const char *device, char *ebuf); |  static int	has_wext(int sock_fd, const char *device, char *ebuf); | ||||||
|  #endif /* IW_MODE_MONITOR */ |  #endif /* IW_MODE_MONITOR */ | ||||||
| @@ -1028,7 +1028,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) | @@ -1059,7 +1059,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) | ||||||
|  	 * (We assume that if we have Wireless Extensions support |  	 * (We assume that if we have Wireless Extensions support | ||||||
|  	 * we also have PF_PACKET 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, htons(ETH_P_ALL)); | ||||||
| +	sock_fd = socket(PF_PACKET, SOCK_RAW, p->opt.proto); | +	sock_fd = socket(PF_PACKET, SOCK_RAW, p->opt.proto); | ||||||
|  	if (sock_fd == -1) { |  	if (sock_fd == -1) { | ||||||
|  		(void)snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, |  		(void)pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, | ||||||
|  		    "socket: %s", pcap_strerror(errno)); |  		    "socket: %s", pcap_strerror(errno)); | ||||||
| @@ -1337,6 +1337,9 @@ pcap_activate_linux(pcap_t *handle) | @@ -1456,6 +1456,9 @@ pcap_activate_linux(pcap_t *handle) | ||||||
|  	handle->read_op = pcap_read_linux; |  	handle->read_op = pcap_read_linux; | ||||||
|  	handle->stats_op = pcap_stats_linux; |  	handle->stats_op = pcap_stats_linux; | ||||||
|   |   | ||||||
| @@ -28,7 +30,7 @@ | |||||||
|  	/* |  	/* | ||||||
|  	 * The "any" device is a special device which causes us not |  	 * The "any" device is a special device which causes us not | ||||||
|  	 * to bind to a particular device and thus to look at all |  	 * to bind to a particular device and thus to look at all | ||||||
| @@ -3160,8 +3163,8 @@ activate_new(pcap_t *handle) | @@ -3335,8 +3338,8 @@ activate_new(pcap_t *handle) | ||||||
|  	 * try a SOCK_RAW socket for the raw interface. |  	 * try a SOCK_RAW socket for the raw interface. | ||||||
|  	 */ |  	 */ | ||||||
|  	sock_fd = is_any_device ? |  	sock_fd = is_any_device ? | ||||||
| @@ -39,16 +41,16 @@ | |||||||
|   |   | ||||||
|  	if (sock_fd == -1) { |  	if (sock_fd == -1) { | ||||||
|  		if (errno == EINVAL || errno == EAFNOSUPPORT) { |  		if (errno == EINVAL || errno == EAFNOSUPPORT) { | ||||||
| @@ -3279,7 +3282,7 @@ activate_new(pcap_t *handle) | @@ -3454,7 +3457,7 @@ activate_new(pcap_t *handle) | ||||||
|  				return PCAP_ERROR; |  				return PCAP_ERROR; | ||||||
|  			} |  			} | ||||||
|  			sock_fd = socket(PF_PACKET, SOCK_DGRAM, |  			sock_fd = socket(PF_PACKET, SOCK_DGRAM, | ||||||
| -			    htons(ETH_P_ALL)); | -			    htons(ETH_P_ALL)); | ||||||
| +			    handle->opt.proto); | +			    handle->opt.proto); | ||||||
|  			if (sock_fd == -1) { |  			if (sock_fd == -1) { | ||||||
|  				snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, |  				pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, | ||||||
|  				    "socket: %s", pcap_strerror(errno)); |  				    "socket: %s", pcap_strerror(errno)); | ||||||
| @@ -3343,7 +3346,7 @@ activate_new(pcap_t *handle) | @@ -3518,7 +3521,7 @@ activate_new(pcap_t *handle) | ||||||
|  		} |  		} | ||||||
|   |   | ||||||
|  		if ((err = iface_bind(sock_fd, handlep->ifindex, |  		if ((err = iface_bind(sock_fd, handlep->ifindex, | ||||||
| @@ -57,7 +59,7 @@ | |||||||
|  		    	close(sock_fd); |  		    	close(sock_fd); | ||||||
|  			if (err < 0) |  			if (err < 0) | ||||||
|  				return err; |  				return err; | ||||||
| @@ -5050,7 +5053,7 @@ iface_get_id(int fd, const char *device, | @@ -5271,7 +5274,7 @@ iface_get_id(int fd, const char *device, | ||||||
|   *  or a PCAP_ERROR_ value on a hard error. |   *  or a PCAP_ERROR_ value on a hard error. | ||||||
|   */ |   */ | ||||||
|  static int |  static int | ||||||
| @@ -66,7 +68,7 @@ | |||||||
|  { |  { | ||||||
|  	struct sockaddr_ll	sll; |  	struct sockaddr_ll	sll; | ||||||
|  	int			err; |  	int			err; | ||||||
| @@ -5059,7 +5062,7 @@ iface_bind(int fd, int ifindex, char *eb | @@ -5280,7 +5283,7 @@ iface_bind(int fd, int ifindex, char *eb | ||||||
|  	memset(&sll, 0, sizeof(sll)); |  	memset(&sll, 0, sizeof(sll)); | ||||||
|  	sll.sll_family		= AF_PACKET; |  	sll.sll_family		= AF_PACKET; | ||||||
|  	sll.sll_ifindex		= ifindex; |  	sll.sll_ifindex		= ifindex; | ||||||
| @@ -75,18 +77,18 @@ | |||||||
|   |   | ||||||
|  	if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) { |  	if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) == -1) { | ||||||
|  		if (errno == ENETDOWN) { |  		if (errno == ENETDOWN) { | ||||||
| @@ -6049,7 +6052,7 @@ activate_old(pcap_t *handle) | @@ -6325,7 +6328,7 @@ activate_old(pcap_t *handle) | ||||||
|   |   | ||||||
|  	/* Open the socket */ |  	/* Open the socket */ | ||||||
|   |   | ||||||
| -	handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); | -	handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL)); | ||||||
| +	handle->fd = socket(PF_INET, SOCK_PACKET, handle->opt.proto); | +	handle->fd = socket(PF_INET, SOCK_PACKET, handle->opt.proto); | ||||||
|  	if (handle->fd == -1) { |  	if (handle->fd == -1) { | ||||||
|  		snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, |  		pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, | ||||||
|  			 "socket: %s", pcap_strerror(errno)); |  			 "socket: %s", pcap_strerror(errno)); | ||||||
| --- a/pcap.c | --- a/pcap.c | ||||||
| +++ b/pcap.c | +++ b/pcap.c | ||||||
| @@ -562,6 +562,7 @@ pcap_create_common(const char *source, c | @@ -578,6 +578,7 @@ pcap_create_common(char *ebuf, size_t si | ||||||
|  	p->opt.promisc = 0; |  	p->opt.promisc = 0; | ||||||
|  	p->opt.rfmon = 0; |  	p->opt.rfmon = 0; | ||||||
|  	p->opt.immediate = 0; |  	p->opt.immediate = 0; | ||||||
| @@ -94,7 +96,7 @@ | |||||||
|  	p->opt.tstamp_type = -1;	/* default to not setting time stamp type */ |  	p->opt.tstamp_type = -1;	/* default to not setting time stamp type */ | ||||||
|  	p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; |  	p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; | ||||||
|   |   | ||||||
| @@ -725,6 +726,15 @@ pcap_get_tstamp_precision(pcap_t *p) | @@ -771,6 +772,15 @@ pcap_get_tstamp_precision(pcap_t *p) | ||||||
|  } |  } | ||||||
|   |   | ||||||
|  int |  int | ||||||
| @@ -112,7 +114,7 @@ | |||||||
|  	int status; |  	int status; | ||||||
| --- a/pcap/pcap.h | --- a/pcap/pcap.h | ||||||
| +++ b/pcap/pcap.h | +++ b/pcap/pcap.h | ||||||
| @@ -66,6 +66,7 @@ extern "C" { | @@ -68,6 +68,7 @@ extern "C" { | ||||||
|  #define PCAP_VERSION_MINOR 4 |  #define PCAP_VERSION_MINOR 4 | ||||||
|   |   | ||||||
|  #define PCAP_ERRBUF_SIZE 256 |  #define PCAP_ERRBUF_SIZE 256 | ||||||
| @@ -120,20 +122,20 @@ | |||||||
|   |   | ||||||
|  /* |  /* | ||||||
|   * Compatibility for systems that have a bpf.h that |   * Compatibility for systems that have a bpf.h that | ||||||
| @@ -283,6 +284,7 @@ int	pcap_set_timeout(pcap_t *, int); | @@ -287,6 +288,7 @@ PCAP_API int	pcap_set_timeout(pcap_t *, | ||||||
|  int	pcap_set_tstamp_type(pcap_t *, int); |  PCAP_API int	pcap_set_tstamp_type(pcap_t *, int); | ||||||
|  int	pcap_set_immediate_mode(pcap_t *, int); |  PCAP_API int	pcap_set_immediate_mode(pcap_t *, int); | ||||||
|  int	pcap_set_buffer_size(pcap_t *, int); |  PCAP_API int	pcap_set_buffer_size(pcap_t *, int); | ||||||
| +int	pcap_set_protocol(pcap_t *, unsigned short); | +PCAP_API int	pcap_set_protocol(pcap_t *, unsigned short); | ||||||
|  int	pcap_set_tstamp_precision(pcap_t *, int); |  PCAP_API int	pcap_set_tstamp_precision(pcap_t *, int); | ||||||
|  int	pcap_get_tstamp_precision(pcap_t *); |  PCAP_API int	pcap_get_tstamp_precision(pcap_t *); | ||||||
|  int	pcap_activate(pcap_t *); |  PCAP_API int	pcap_activate(pcap_t *); | ||||||
| --- a/pcap-int.h | --- a/pcap-int.h | ||||||
| +++ b/pcap-int.h | +++ b/pcap-int.h | ||||||
| @@ -109,6 +109,7 @@ struct pcap_opt { | @@ -111,6 +111,7 @@ struct pcap_opt { | ||||||
|  	char	*source; |  	char	*device; | ||||||
|  	int	timeout;	/* timeout for buffering */ |  	int	timeout;	/* timeout for buffering */ | ||||||
|  	int	buffer_size; |  	u_int	buffer_size; | ||||||
| +	int	proto;		/* protocol for packet socket (linux) */ | +	int	proto;		/* protocol for packet socket (linux) */ | ||||||
|  	int	promisc; |  	int	promisc; | ||||||
|  	int	rfmon;		/* monitor mode */ |  	int	rfmon;		/* monitor mode */ | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- a/pcap-linux.c | --- a/pcap-linux.c | ||||||
| +++ b/pcap-linux.c | +++ b/pcap-linux.c | ||||||
| @@ -254,6 +254,8 @@ | @@ -263,6 +263,8 @@ | ||||||
|  typedef int		socklen_t; |  typedef int		socklen_t; | ||||||
|  #endif |  #endif | ||||||
|   |   | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								package/libs/libpcap/patches/204-usb-bus-path.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								package/libs/libpcap/patches/204-usb-bus-path.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | Fix USB bus path; /proc/bus/usb is deprecated. | ||||||
|  |  | ||||||
|  | --- a/pcap-usb-linux.c | ||||||
|  | +++ b/pcap-usb-linux.c | ||||||
|  | @@ -71,7 +71,7 @@ | ||||||
|  |  #define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon" | ||||||
|  |  #define USB_TEXT_DIR "/sys/kernel/debug/usb/usbmon" | ||||||
|  |  #define SYS_USB_BUS_DIR "/sys/bus/usb/devices" | ||||||
|  | -#define PROC_USB_BUS_DIR "/proc/bus/usb" | ||||||
|  | +#define PROC_USB_BUS_DIR "/dev/bus/usb" | ||||||
|  |  #define USB_LINE_LEN 4096 | ||||||
|  |   | ||||||
|  |  #if __BYTE_ORDER == __LITTLE_ENDIAN | ||||||
		Reference in New Issue
	
	Block a user
	 p-wassi
					p-wassi