]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If _PATH_BPF is set, open that instead of searching for a free BPF device.
authorRoy Marples <roy@marples.name>
Thu, 17 Apr 2008 09:47:11 +0000 (09:47 +0000)
committerRoy Marples <roy@marples.name>
Thu, 17 Apr 2008 09:47:11 +0000 (09:47 +0000)
bpf.c

diff --git a/bpf.c b/bpf.c
index 341455e898579686867908f07dd45028e31da5ca..e419cb40f82361bb39b79b3898444b85a52606ce 100644 (file)
--- 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>
 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;