summaryrefslogtreecommitdiff
path: root/package/libpcap/patches/105-space_optimization.patch
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-04-25 03:30:10 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-04-25 03:30:10 +0000
commit25e9d9025668dc638fcd171e43bbf9cd2895ea31 (patch)
tree8cd67a42e3d96f455272f278298be302efbabd16 /package/libpcap/patches/105-space_optimization.patch
parent8ce7b559d0f6533bcbe154f332855426d1d7a368 (diff)
downloadmtk-20170518-25e9d9025668dc638fcd171e43bbf9cd2895ea31.zip
mtk-20170518-25e9d9025668dc638fcd171e43bbf9cd2895ea31.tar.gz
mtk-20170518-25e9d9025668dc638fcd171e43bbf9cd2895ea31.tar.bz2
pcap: update to version 1.0.0, add extension for changing the desired protocol for the internal raw socket (useful for reducing the cpu overhead of capture)
SVN-Revision: 15398
Diffstat (limited to 'package/libpcap/patches/105-space_optimization.patch')
-rw-r--r--package/libpcap/patches/105-space_optimization.patch102
1 files changed, 59 insertions, 43 deletions
diff --git a/package/libpcap/patches/105-space_optimization.patch b/package/libpcap/patches/105-space_optimization.patch
index 17265cd..29c293b 100644
--- a/package/libpcap/patches/105-space_optimization.patch
+++ b/package/libpcap/patches/105-space_optimization.patch
@@ -1,6 +1,6 @@
--- a/gencode.c
+++ b/gencode.c
-@@ -429,20 +429,6 @@ pcap_compile_nopcap(int snaplen_arg, int
+@@ -439,20 +439,6 @@ pcap_compile_nopcap(int snaplen_arg, int
}
/*
@@ -21,48 +21,9 @@
* 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/optimize.c
-+++ b/optimize.c
-@@ -2263,36 +2263,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;
--
-- /*
-- * 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)
--- a/pcap.c
+++ b/pcap.c
-@@ -463,6 +463,52 @@ static const u_char charmap[] = {
+@@ -698,6 +698,59 @@ static const u_char charmap[] = {
(u_char)'\374', (u_char)'\375', (u_char)'\376', (u_char)'\377',
};
@@ -80,7 +41,6 @@
+ }
+}
+
-+
+/*
+ * Make a copy of a BPF program and put it in the "fcode" member of
+ * a "pcap_t".
@@ -95,6 +55,15 @@
+ 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);
@@ -111,7 +80,54 @@
+ 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)