Module Name: src
Committed By: mbalmer
Date: Fri Jun 26 09:00:49 UTC 2009
Modified Files:
src/usr.sbin/wake: wake.c
Log Message:
/dev/bpf is cloneable, no need to dance around /dev/bpfN to find an
available device.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/wake/wake.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/wake/wake.c
diff -u src/usr.sbin/wake/wake.c:1.3 src/usr.sbin/wake/wake.c:1.4
--- src/usr.sbin/wake/wake.c:1.3 Thu Jun 25 22:26:54 2009
+++ src/usr.sbin/wake/wake.c Fri Jun 26 09:00:49 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: wake.c,v 1.3 2009/06/25 22:26:54 mbalmer Exp $ */
+/* $NetBSD: wake.c,v 1.4 2009/06/26 09:00:49 mbalmer Exp $ */
/*
* Copyright (C) 2006, 2007, 2008, 2009 Marc Balmer <[email protected]>
@@ -44,6 +44,7 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <paths.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -51,10 +52,6 @@
#include <sysexits.h>
#include <unistd.h>
-#ifndef BPF_PATH_FORMAT
-#define BPF_PATH_FORMAT "/dev/bpf%u"
-#endif
-
#ifndef SYNC_LEN
#define SYNC_LEN 6
#endif
@@ -66,7 +63,6 @@
__dead void usage(void);
int wake(const char *iface, const char *host);
-int get_bpf(void);
int bind_if_to_bpf(char const *ifname, int bpf);
int get_ether(char const *text, struct ether_addr *addr);
int send_wakeup(int bpf, struct ether_addr const *addr);
@@ -86,7 +82,7 @@
int res, bpf;
struct ether_addr macaddr;
- bpf = get_bpf();
+ bpf = open(_PATH_BPF, O_RDWR);
if (bpf == -1) {
printf("no bpf\n");
return -1;
@@ -102,26 +98,6 @@
}
int
-get_bpf(void)
-{
- int i, fd;
- char path[MAXPATHLEN];
-
- 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(char const *ifname, int bpf)
{
struct ifreq ifr;