diff options
author | Travis Kemen <thepeople@openwrt.org> | 2010-03-08 15:03:42 +0000 |
---|---|---|
committer | Travis Kemen <thepeople@openwrt.org> | 2010-03-08 15:03:42 +0000 |
commit | 9b8f12303affdbeaa9b73c73af4ed6557c7bc2de (patch) | |
tree | 8a38529c7b7d542f927353bd960c85a98f54c9c0 /package/libpcap/patches | |
parent | 3c829c412c3f93e72991dcfd29f0ff15f07263f1 (diff) | |
download | mtk-20170518-9b8f12303affdbeaa9b73c73af4ed6557c7bc2de.zip mtk-20170518-9b8f12303affdbeaa9b73c73af4ed6557c7bc2de.tar.gz mtk-20170518-9b8f12303affdbeaa9b73c73af4ed6557c7bc2de.tar.bz2 |
finish cleaning my broken commit
SVN-Revision: 20061
Diffstat (limited to 'package/libpcap/patches')
-rw-r--r-- | package/libpcap/patches/101-debian_fix_any_intf.patch | 149 | ||||
-rw-r--r-- | package/libpcap/patches/102-fix_install.patch | 11 | ||||
-rw-r--r-- | package/libpcap/patches/103-flex_workaround.patch | 14 | ||||
-rw-r--r-- | package/libpcap/patches/105-space_optimization.patch | 133 | ||||
-rw-r--r-- | package/libpcap/patches/106-protocol_api.patch | 141 |
5 files changed, 0 insertions, 448 deletions
diff --git a/package/libpcap/patches/101-debian_fix_any_intf.patch b/package/libpcap/patches/101-debian_fix_any_intf.patch deleted file mode 100644 index 8da6ef2..0000000 --- a/package/libpcap/patches/101-debian_fix_any_intf.patch +++ /dev/null @@ -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; diff --git a/package/libpcap/patches/102-fix_install.patch b/package/libpcap/patches/102-fix_install.patch deleted file mode 100644 index 5264fb2..0000000 --- a/package/libpcap/patches/102-fix_install.patch +++ /dev/null @@ -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 \ diff --git a/package/libpcap/patches/103-flex_workaround.patch b/package/libpcap/patches/103-flex_workaround.patch deleted file mode 100644 index 5d03342..0000000 --- a/package/libpcap/patches/103-flex_workaround.patch +++ /dev/null @@ -1,14 +0,0 @@ - - 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/105-space_optimization.patch b/package/libpcap/patches/105-space_optimization.patch deleted file mode 100644 index 29c293b..0000000 --- a/package/libpcap/patches/105-space_optimization.patch +++ /dev/null @@ -1,133 +0,0 @@ ---- 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/106-protocol_api.patch b/package/libpcap/patches/106-protocol_api.patch deleted file mode 100644 index dc5e45a..0000000 --- a/package/libpcap/patches/106-protocol_api.patch +++ /dev/null @@ -1,141 +0,0 @@ ---- 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 *); |