X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=package%2Flibs%2Flibpcap%2Fpatches%2F201-space_optimization.patch;fp=package%2Flibs%2Flibpcap%2Fpatches%2F201-space_optimization.patch;h=b0a91bb0ef9a547f1a59b56e3f7ce960684dd37f;hb=e6fbf31baae41b618ff333f3ae55ff032333bd6a;hp=ee3cd3b8586f3e9601f83c80c24dc9a023c3f404;hpb=54bdfb4a32386b47d6c3bb98668f434e36a5285a;p=15.05%2Fopenwrt.git diff --git a/package/libs/libpcap/patches/201-space_optimization.patch b/package/libs/libpcap/patches/201-space_optimization.patch index ee3cd3b858..b0a91bb0ef 100644 --- a/package/libs/libpcap/patches/201-space_optimization.patch +++ b/package/libs/libpcap/patches/201-space_optimization.patch @@ -1,133 +1,26 @@ ---- a/gencode.c -+++ b/gencode.c -@@ -511,20 +511,6 @@ pcap_compile_nopcap(int snaplen_arg, int - } +--- a/pcap-common.c ++++ b/pcap-common.c +@@ -1447,14 +1447,23 @@ swap_pseudo_headers(int linktype, struct + break; - /* -- * 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 -@@ -1075,6 +1075,59 @@ static const u_char charmap[] = { - (u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377', - }; + case DLT_USB_LINUX: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 0); + break; -+/* -+ * 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 -@@ -2193,45 +2193,6 @@ icode_to_fcode(struct block *root, u_int - return fp; - } + case DLT_USB_LINUX_MMAPPED: ++#ifndef PCAP_SUPPORT_USB ++ return; ++#endif + swap_linux_usb_header(hdr, data, 1); + break; --/* -- * 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(struct block *root) + case DLT_NFLOG: ++#ifndef PCAP_SUPPORT_NETFILTER ++ return; ++#endif + swap_nflog_header(hdr, data); + break; + }