summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>1998-12-22 22:39:19 +0000
committerTed Lemon <source@isc.org>1998-12-22 22:39:19 +0000
commit6203084368a1ba2403e8cc0ba2c38cdbcf147b3c (patch)
treee01afa87d04538df28d25f78e1bc8e8b4b7c90bd /common
parentef0ab0b3847f6210544bacbe22e3b16597e738c4 (diff)
downloadisc-dhcp-6203084368a1ba2403e8cc0ba2c38cdbcf147b3c.tar.gz
Share packet filter with lpf.c
Diffstat (limited to 'common')
-rw-r--r--common/bpf.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/common/bpf.c b/common/bpf.c
index 60ccb09b..3e4b422f 100644
--- a/common/bpf.c
+++ b/common/bpf.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.19.2.1 1998/12/20 18:21:52 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.19.2.2 1998/12/22 22:39:19 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -137,12 +137,12 @@ void if_register_send (info)
}
#endif /* USE_BPF_SEND */
-#ifdef USE_BPF_RECEIVE
+#if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE)
/* Packet filter program...
XXX Changes to the filter program may require changes to the constant
offsets used in if_register_send to patch the BPF program! XXX */
-struct bpf_insn filter [] = {
+struct bpf_insn dhcp_bpf_filter [] = {
/* Make sure this is an IP packet... */
BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12),
BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
@@ -169,6 +169,10 @@ struct bpf_insn filter [] = {
BPF_STMT(BPF_RET+BPF_K, 0),
};
+int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
+#endif
+
+#if defined (USE_BPF_RECEIVE)
void if_register_receive (info)
struct interface_info *info;
{
@@ -220,13 +224,13 @@ void if_register_receive (info)
info -> rbuf_len = 0;
/* Set up the bpf filter program structure. */
- p.bf_len = sizeof filter / sizeof (struct bpf_insn);
- p.bf_insns = filter;
+ p.bf_len = dhcp_bpf_filter_len;
+ p.bf_insns = dhcp_bpf_filter;
/* Patch the server port into the BPF program...
XXX changes to filter program may require changes
to the insn number(s) used below! XXX */
- filter [8].k = ntohs (local_port);
+ dhcp_bpf_filter [8].k = ntohs (local_port);
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
error ("Can't install packet filter program: %m");