diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-05-05 01:16:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-05-05 01:16:40 +0000 |
commit | 3a51012d8ea651591af1a8202c81db5f91d54781 (patch) | |
tree | 3bb9a60da1ba36555d76ae2f42538376030f726c /usr.sbin/rarpd | |
parent | 2abb5705934e184a6c5b2fc405e164f574db9dc2 (diff) |
move static filter out of function
Diffstat (limited to 'usr.sbin/rarpd')
-rw-r--r-- | usr.sbin/rarpd/rarpd.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index 1804e623e61..dfd13043fbb 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.41 2003/07/21 19:44:33 deraadt Exp $ */ +/* $OpenBSD: rarpd.c,v 1.42 2004/05/05 01:16:39 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */ /* @@ -28,7 +28,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: rarpd.c,v 1.41 2003/07/21 19:44:33 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: rarpd.c,v 1.42 2004/05/05 01:16:39 deraadt Exp $"; #endif @@ -286,6 +286,22 @@ bpf_open(void) } return fd; } + +static struct bpf_insn insns[] = { + BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ETHERTYPE_REVARP, 0, 3), + BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), + BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ARPOP_REVREQUEST, 0, 1), + BPF_STMT(BPF_RET | BPF_K, sizeof(struct ether_arp) + + sizeof(struct ether_header)), + BPF_STMT(BPF_RET | BPF_K, 0), +}; + +static struct bpf_program filter = { + sizeof insns / sizeof(insns[0]), + insns +}; + /* * Open a BPF file and attach it to the interface named 'device'. * Set immediate mode, and set a filter that accepts only RARP requests. @@ -293,24 +309,9 @@ bpf_open(void) int rarp_open(char *device) { - int fd; + int fd, immediate; struct ifreq ifr; u_int dlt; - int immediate; - - static struct bpf_insn insns[] = { - BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12), - BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ETHERTYPE_REVARP, 0, 3), - BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20), - BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, ARPOP_REVREQUEST, 0, 1), - BPF_STMT(BPF_RET | BPF_K, sizeof(struct ether_arp) + - sizeof(struct ether_header)), - BPF_STMT(BPF_RET | BPF_K, 0), - }; - static struct bpf_program filter = { - sizeof insns / sizeof(insns[0]), - insns - }; fd = bpf_open(); |