summaryrefslogtreecommitdiff
path: root/bpf.c
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>1996-05-16 23:55:04 +0000
committerTed Lemon <source@isc.org>1996-05-16 23:55:04 +0000
commit019f8a12eb0cc87d3077c8e495eea13c6658a5f5 (patch)
tree2f18c88c80fd875f8e4d6eda05481ecabfc840df /bpf.c
parentdd4f610d15db1cc62d17d5487db70d767920da01 (diff)
downloadisc-dhcp-019f8a12eb0cc87d3077c8e495eea13c6658a5f5.tar.gz
Fix up pointer types; add support for Alpha OSF/1 pfilt, which is only slightly different
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/bpf.c b/bpf.c
index 7e6d4ac7..93f35686 100644
--- a/bpf.c
+++ b/bpf.c
@@ -51,6 +51,9 @@ static char copyright[] =
#include <sys/uio.h>
#include <net/bpf.h>
+#ifdef NEED_OSF_PFILT_HACKS
+#include <net/pfilt.h>
+#endif
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
@@ -71,9 +74,9 @@ int if_register_bpf (info, ifp)
/* Open a BPF device */
for (b = 0; 1; b++) {
#ifndef NO_SNPRINTF
- snprintf(filename, sizeof(filename), "/dev/bpf%d", b);
+ snprintf(filename, sizeof(filename), BPF_FORMAT, b);
#else
- sprintf(filename, "/dev/bpf%d", b);
+ sprintf(filename, BPF_FORMAT, b);
#endif
sock = open (filename, O_RDWR, 0);
if (sock < 0) {
@@ -161,6 +164,7 @@ void if_register_receive (info, interface)
struct bpf_version v;
u_int32_t addr;
struct bpf_program p;
+ u_int32_t bits;
/* Open a BPF device and hang it on this interface... */
info -> rfdesc = if_register_bpf (info, interface);
@@ -179,6 +183,21 @@ void if_register_receive (info, interface)
if (ioctl (info -> rfdesc, BIOCIMMEDIATE, &flag) < 0)
error ("Can't set immediate mode on bpf device: %m");
+#ifdef NEED_OSF_PFILT_HACKS
+ /* Allow the copyall flag to be set... */
+ if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0)
+ error ("Can't set ALLOWCOPYALL: %m");
+
+ /* Clear all the packet filter mode bits first... */
+ bits = 0;
+ if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
+ error ("Can't clear pfilt bits: %m");
+
+ /* Set the ENBATCH, ENCOPYALL, ENBPFHDR bits... */
+ bits = ENBATCH | ENCOPYALL | ENBPFHDR;
+ if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
+ error ("Can't set ENBATCH|ENCOPYALL|ENBPFHDR: %m");
+#endif
/* Get the required BPF buffer length from the kernel. */
if (ioctl (info -> rfdesc, BIOCGBLEN, &info -> rbuf_max) < 0)
error ("Can't get bpf buffer length: %m");
@@ -226,7 +245,7 @@ size_t send_packet (interface, packet, raw, len, to, hto)
(unsigned char *)raw, len);
/* Fire it off */
- iov [0].iov_base = buf;
+ iov [0].iov_base = (char *)buf;
iov [0].iov_len = bufp;
iov [1].iov_base = (char *)raw;
iov [1].iov_len = len;