summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/libpcap/Config.in12
-rw-r--r--package/libpcap/patches/101-makefile_create_bindir.patch11
-rw-r--r--package/libpcap/patches/102-makefile_disable_manpages.patch78
-rw-r--r--package/libpcap/patches/103-makefile_flex_workaround.patch14
-rw-r--r--package/libpcap/patches/200-debian_fix_any_intf.patch149
-rw-r--r--package/libpcap/patches/201-space_optimization.patch133
-rw-r--r--package/libpcap/patches/202-protocol_api.patch141
-rw-r--r--package/libpcap/patches/203-undef_iw_mode_monitor.patch11
8 files changed, 549 insertions, 0 deletions
diff --git a/package/libpcap/Config.in b/package/libpcap/Config.in
new file mode 100644
index 0000000000..1b9463e6aa
--- /dev/null
+++ b/package/libpcap/Config.in
@@ -0,0 +1,12 @@
+config PCAP_HAS_USB
+ bool "Include USB support"
+ depends PACKAGE_libpcap
+ depends PACKAGE_kmod-usb-core
+ default n
+
+config PCAP_HAS_BT
+ bool "Include bluetooth support"
+ depends PACKAGE_libpcap
+ depends PACKAGE_kmod-bluetooth
+ depends BROKEN
+ default n
diff --git a/package/libpcap/patches/101-makefile_create_bindir.patch b/package/libpcap/patches/101-makefile_create_bindir.patch
new file mode 100644
index 0000000000..5264fb2f68
--- /dev/null
+++ b/package/libpcap/patches/101-makefile_create_bindir.patch
@@ -0,0 +1,11 @@
+--- 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 \
diff --git a/package/libpcap/patches/102-makefile_disable_manpages.patch b/package/libpcap/patches/102-makefile_disable_manpages.patch
new file mode 100644
index 0000000000..f0a4f3821a
--- /dev/null
+++ b/package/libpcap/patches/102-makefile_disable_manpages.patch
@@ -0,0 +1,78 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -461,14 +461,6 @@
+ (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@)
+ $(INSTALL_DATA) $(srcdir)/pcap/pcap.h \
+ $(DESTDIR)$(includedir)/pcap/pcap.h
+ $(INSTALL_DATA) $(srcdir)/pcap/bpf.h \
+@@ -487,36 +479,6 @@
+ [ -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 \
+- $(INSTALL_DATA) $(srcdir)/$$i \
+- $(DESTDIR)$(mandir)/man3/$$i; done
+- ln $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_name.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_major_version.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_next_ex.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+- ln $(DESTDIR)$(mandir)/man3/pcap_open_offline.3pcap \
+- $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.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/'` \
+- $(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/'` \
+- $(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 @@
+ rm -f $(DESTDIR)$(includedir)/pcap.h
+ rm -f $(DESTDIR)$(includedir)/pcap-bpf.h
+ rm -f $(DESTDIR)$(includedir)/pcap-namedb.h
+- 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
+- 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*
diff --git a/package/libpcap/patches/103-makefile_flex_workaround.patch b/package/libpcap/patches/103-makefile_flex_workaround.patch
new file mode 100644
index 0000000000..5d0334272a
--- /dev/null
+++ b/package/libpcap/patches/103-makefile_flex_workaround.patch
@@ -0,0 +1,14 @@
+
+ Copyright (C) 2006 Markus Wigge
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -55,7 +55,7 @@ SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
+ 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@
diff --git a/package/libpcap/patches/200-debian_fix_any_intf.patch b/package/libpcap/patches/200-debian_fix_any_intf.patch
new file mode 100644
index 0000000000..8da6ef2237
--- /dev/null
+++ b/package/libpcap/patches/200-debian_fix_any_intf.patch
@@ -0,0 +1,149 @@
+--- 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;
diff --git a/package/libpcap/patches/201-space_optimization.patch b/package/libpcap/patches/201-space_optimization.patch
new file mode 100644
index 0000000000..29c293b623
--- /dev/null
+++ b/package/libpcap/patches/201-space_optimization.patch
@@ -0,0 +1,133 @@
+--- a/gencode.c
++++ b/gencode.c
+@@ -439,20 +439,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
+@@ -698,6 +698,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
+@@ -2278,45 +2278,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/libpcap/patches/202-protocol_api.patch b/package/libpcap/patches/202-protocol_api.patch
new file mode 100644
index 0000000000..dc5e45a246
--- /dev/null
+++ b/package/libpcap/patches/202-protocol_api.patch
@@ -0,0 +1,141 @@
+--- a/pcap-int.h
++++ b/pcap-int.h
+@@ -187,6 +187,7 @@ struct pcap_opt {
+ char *source;
+ int promisc;
+ int rfmon;
++ int proto; /* protocol for packet socket (linux) */
+ };
+
+ /*
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -273,7 +273,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);
+ 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)
+ * (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,
+ "socket: %s", pcap_strerror(errno));
+@@ -522,6 +522,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
+@@ -1673,8 +1676,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) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
+@@ -1763,7 +1766,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));
+@@ -1815,7 +1818,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;
+@@ -2440,7 +2443,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;
+@@ -2449,7 +2452,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) {
+@@ -3119,7 +3122,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
+@@ -152,6 +152,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;
++ p->opt.proto = -1;
++
+ return (p);
+ }
+
+@@ -212,6 +214,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
+@@ -61,6 +61,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
+@@ -263,6 +264,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);
++int pcap_set_protocol(pcap_t *, unsigned short);
+ int pcap_activate(pcap_t *);
+
+ pcap_t *pcap_open_live(const char *, int, int, int, char *);
diff --git a/package/libpcap/patches/203-undef_iw_mode_monitor.patch b/package/libpcap/patches/203-undef_iw_mode_monitor.patch
new file mode 100644
index 0000000000..5339781fbc
--- /dev/null
+++ b/package/libpcap/patches/203-undef_iw_mode_monitor.patch
@@ -0,0 +1,11 @@
+--- a/pcap-linux.c
++++ b/pcap-linux.c
+@@ -194,6 +194,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