aboutsummaryrefslogtreecommitdiffstats
path: root/package/ead/src/pfc.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-12-24 10:42:12 +0000
committerFelix Fietkau <nbd@openwrt.org>2008-12-24 10:42:12 +0000
commit2d86ea2a1d66045472b405d7395a9732f3340f94 (patch)
tree44d30dc88e3fd191ab22e729a32c1267381af70b /package/ead/src/pfc.c
parent067e900705377b83a21fd7cb0cebd9f850e8d379 (diff)
downloadupstream-2d86ea2a1d66045472b405d7395a9732f3340f94.tar.gz
upstream-2d86ea2a1d66045472b405d7395a9732f3340f94.tar.bz2
upstream-2d86ea2a1d66045472b405d7395a9732f3340f94.zip
add the 'ead' package (emergency access daemon), which can provide remote access to your device, even if the ip and firewall settings are broken
SVN-Revision: 13738
Diffstat (limited to 'package/ead/src/pfc.c')
-rw-r--r--package/ead/src/pfc.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/package/ead/src/pfc.c b/package/ead/src/pfc.c
new file mode 100644
index 0000000000..402e37f31d
--- /dev/null
+++ b/package/ead/src/pfc.c
@@ -0,0 +1,54 @@
+/*
+ * Small pcap precompiler
+ * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pcap.h>
+
+int main (int argc, char ** argv)
+{
+ struct bpf_program filter;
+ pcap_t *pc;
+ int i;
+
+ if (argc != 2)
+ {
+ printf ("Usage: %s <expression>\n", argv[0]);
+ return 1;
+ }
+
+ pc = pcap_open_dead(DLT_EN10MB, 1500);
+ if (pcap_compile(pc, &filter, argv[1], 1, 0) != 0) {
+ printf("error in active-filter expression: %s\n", pcap_geterr(pc));
+ return 1;
+ }
+
+ printf("/* precompiled expression: %s */\n\n"
+ "static struct bpf_insn pktfilter_insns[] = {\n",
+ argv[1]);
+
+ for (i = 0; i < filter.bf_len; i++) {
+ struct bpf_insn *in = &filter.bf_insns[i];
+ printf("\t{ .code = 0x%04x, .jt = 0x%02x, .jf = 0x%02x, .k = 0x%08x },\n", in->code, in->jt, in->jf, in->k);
+ }
+ printf("};\n\n"
+ "static struct bpf_program pktfilter = {\n"
+ "\t.bf_len = %d,\n"
+ "\t.bf_insns = pktfilter_insns,\n"
+ "};\n", filter.bf_len);
+ return 0;
+
+}