summaryrefslogtreecommitdiffstats
path: root/bpf.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-04-17 09:47:11 +0000
committerRoy Marples <roy@marples.name>2008-04-17 09:47:11 +0000
commit574011fc89d07bd35b8e9d744030d41c71151676 (patch)
tree7812178845cacf0167f80a7ab7e33f29278bfe8d /bpf.c
parent6895fff31eea6a6069b8483f51030f88ff8d21be (diff)
downloaddhcpcd-574011fc89d07bd35b8e9d744030d41c71151676.tar.xz
If _PATH_BPF is set, open that instead of searching for a free BPF device.
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bpf.c b/bpf.c
index 341455e8..e419cb40 100644
--- a/bpf.c
+++ b/bpf.c
@@ -35,6 +35,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,21 +51,26 @@
int
open_socket(struct interface *iface, int protocol)
{
- int n = 0;
int fd = -1;
- char *device;
int flags;
struct ifreq ifr;
int buf = 0;
struct bpf_version pv;
struct bpf_program pf;
+#ifdef _PATH_BPF
+ fd = open(_PATH_BPF, O_RDWR);
+#else
+ char *device;
+ int n = 0;
+
device = xmalloc(sizeof(char) * PATH_MAX);
do {
- snprintf(device, PATH_MAX, "/dev/bpf%d", n++);
+ snprintf(device, PATH_MAX, "/dev/bpf%d", n++);
fd = open(device, O_RDWR);
} while (fd == -1 && errno == EBUSY);
free(device);
+#endif
if (fd == -1)
return -1;