diff options
author | David Ward <david.ward@ll.mit.edu> | 2009-12-03 20:44:35 +0300 |
---|---|---|
committer | Denis Ovsienko <infrastation@yandex.ru> | 2009-12-03 20:44:35 +0300 |
commit | 362573e5642b29ffeef5000351adc2d6ed6dfca3 (patch) | |
tree | 2b1c84f9498563959f43b54335ab8a07c4e7e6c2 /isisd | |
parent | cdb9950482e1180b4a2b6ba05d171bdf2649c84c (diff) |
isisd: fix BPF ioctl() calls, treat "true" and "false" as reserved
Avoid a potential conflict with the C99 defines 'true' and 'false'
found in <stdbool.h> by choosing better variable names.
Also fix the calls to these ioctls, as described in <net/bpf.h>
in FreeBSD, NetBSD, and OpenBSD:
* BIOCGBLEN, BIOCIMMEDIATE, BIOCSSEESENT (the parameter should be
of type 'u_int')
* BIOCPROMISC (there should be no parameters)
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_bpf.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index e66ac98a..8c3602db 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -56,7 +56,7 @@ struct bpf_insn llcfilter[] = { BPF_STMT (BPF_RET + BPF_K, (u_int) - 1), BPF_STMT (BPF_RET + BPF_K, 0) }; -int readblen = 0; +u_int readblen = 0; u_char *readbuff = NULL; /* @@ -77,8 +77,7 @@ open_bpf_dev (struct isis_circuit *circuit) int i = 0, fd; char bpfdev[128]; struct ifreq ifr; - u_int16_t blen; - int true = 1, false = 0; + u_int blen, immediate, seesent; struct timeval timeout; struct bpf_program bpf_prog; @@ -123,7 +122,8 @@ open_bpf_dev (struct isis_circuit *circuit) * Otherwise, a read will block until either the kernel * buffer becomes full or a timeout occurs. */ - if (ioctl (fd, BIOCIMMEDIATE, (caddr_t) & true) < 0) + immediate = 1; + if (ioctl (fd, BIOCIMMEDIATE, (caddr_t) & immediate) < 0) { zlog_warn ("failed to set BPF dev to immediate mode"); } @@ -132,7 +132,8 @@ open_bpf_dev (struct isis_circuit *circuit) /* * We want to see only incoming packets */ - if (ioctl (fd, BIOCSSEESENT, (caddr_t) & false) < 0) + seesent = 0; + if (ioctl (fd, BIOCSSEESENT, (caddr_t) & seesent) < 0) { zlog_warn ("failed to set BPF dev to incoming only mode"); } @@ -141,7 +142,7 @@ open_bpf_dev (struct isis_circuit *circuit) /* * ...but all of them */ - if (ioctl (fd, BIOCPROMISC, (caddr_t) & true) < 0) + if (ioctl (fd, BIOCPROMISC) < 0) { zlog_warn ("failed to set BPF dev to promiscuous mode"); } |