aboutsummaryrefslogtreecommitdiffstats
path: root/package/ppp/utils
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-03-18 17:27:20 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-03-18 17:27:20 +0000
commit5359dd8c8a0ad7c6c3ea7f0211b26b378263965f (patch)
tree52813f9ebd13e23690eceb048dcb8cfb54863a17 /package/ppp/utils
parenta10c122fe2cdd175541eb14cebe58d599b5c7dce (diff)
downloadupstream-5359dd8c8a0ad7c6c3ea7f0211b26b378263965f.tar.gz
upstream-5359dd8c8a0ad7c6c3ea7f0211b26b378263965f.tar.bz2
upstream-5359dd8c8a0ad7c6c3ea7f0211b26b378263965f.zip
precompile ppp active filter (reduces libpcap overhead to only a few k), enable by default to support proper demand dialling, fixes #307
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@3401 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/ppp/utils')
-rw-r--r--package/ppp/utils/pfc.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/package/ppp/utils/pfc.c b/package/ppp/utils/pfc.c
new file mode 100644
index 0000000000..5476be170a
--- /dev/null
+++ b/package/ppp/utils/pfc.c
@@ -0,0 +1,51 @@
+/*
+ * Taken from fli4l 3.0
+ * Make sure you compile it against the same libpcap version used in OpenWrt
+ */
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+
+#include <pcap.h>
+#include <pcap-bpf.h>
+
+int main (int argc, char ** argv)
+{
+ pcap_t *pc; /* Fake struct pcap so we can compile expr */
+ struct bpf_program filter; /* Filter program for link-active pkts */
+ u_int32_t netmask=0;
+
+ int dflag = 3;
+ if (argc == 4)
+ {
+ if (!strcmp (argv[1], "-d"))
+ {
+ dflag = atoi (argv[2]);
+ argv += 2;
+ argc -=2;
+ }
+ }
+ if (argc != 2)
+ {
+ printf ("usage; %s [ -d <debug_level> ] expression\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_PPP_PPPD, PPP_HDRLEN);
+ if (pcap_compile(pc, &filter, argv[1], 1, netmask) == 0)
+ {
+ printf ("#\n# Expression: %s\n#\n", argv[1]);
+ bpf_dump (&filter, dflag);
+ return 0;
+ }
+ else
+ {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ }
+ return 1;
+}