diff options
| author | 2016-05-28 07:00:18 +0000 | |
|---|---|---|
| committer | 2016-05-28 07:00:18 +0000 | |
| commit | 2abf9a0d86fa9b4fb1b6fb30d464b452304d1b90 (patch) | |
| tree | 3c1599cc8846249363d55b245b3c954b2c92dc84 /usr.sbin/arp/arp.c | |
| parent | Do the endpoint verification before opening the pipe on the selected (diff) | |
| download | wireguard-openbsd-2abf9a0d86fa9b4fb1b6fb30d464b452304d1b90.tar.xz wireguard-openbsd-2abf9a0d86fa9b4fb1b6fb30d464b452304d1b90.zip | |
Replace the /dev/bpf* open loop with a plain open("/dev/bpf0", ...).
ok deraadt jca
Diffstat (limited to 'usr.sbin/arp/arp.c')
| -rw-r--r-- | usr.sbin/arp/arp.c | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 019d4bf0b07..77c5a6b599c 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arp.c,v 1.74 2016/03/23 08:28:31 mpi Exp $ */ +/* $OpenBSD: arp.c,v 1.75 2016/05/28 07:00:18 natano Exp $ */ /* $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */ /* @@ -808,12 +808,7 @@ sec2str(time_t total) * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BPF_PATH_FORMAT -#define BPF_PATH_FORMAT "/dev/bpf%u" -#endif - int do_wakeup(const char *, const char *, int); -int get_bpf(void); int bind_if_to_bpf(const char *, int); int get_ether(const char *, struct ether_addr *); int send_frame(int, const struct ether_addr *); @@ -825,9 +820,8 @@ wake(const char *ether_addr, const char *iface) char *pname = NULL; int bpf; - bpf = get_bpf(); - if (bpf == -1) - errx(1, "Failed to bind to bpf."); + if ((bpf = open("/dev/bpf0", O_RDWR)) == -1) + err(1, "Failed to bind to bpf"); if (iface == NULL) { if (getifaddrs(&ifa) == -1) @@ -876,25 +870,6 @@ do_wakeup(const char *eaddr, const char *iface, int bpf) } int -get_bpf(void) -{ - char path[PATH_MAX]; - int i, fd; - - for (i = 0; ; i++) { - if (snprintf(path, sizeof(path), BPF_PATH_FORMAT, i) == -1) - return -1; - fd = open(path, O_RDWR); - if (fd != -1) - return fd; - if (errno == EBUSY) - continue; - break; - } - return -1; -} - -int bind_if_to_bpf(const char *ifname, int bpf) { struct ifreq ifr; |
