Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/wake Only use an auto-determined interface if it is...
details: https://anonhg.NetBSD.org/src/rev/1d4b04391508
branches: trunk
changeset: 750523:1d4b04391508
user: mbalmer <mbalmer%NetBSD.org@localhost>
date: Mon Jan 04 11:34:39 2010 +0000
description:
Only use an auto-determined interface if it is the only one in the system
that is up and running. This change prevents wake(8) from picking an
arbitrary interface (which is possibly the wrong one).
diffstat:
usr.sbin/wake/wake.8 | 13 ++++++-------
usr.sbin/wake/wake.c | 9 +++++----
2 files changed, 11 insertions(+), 11 deletions(-)
diffs (75 lines):
diff -r ea25feb92af9 -r 1d4b04391508 usr.sbin/wake/wake.8
--- a/usr.sbin/wake/wake.8 Mon Jan 04 10:06:53 2010 +0000
+++ b/usr.sbin/wake/wake.8 Mon Jan 04 11:34:39 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: wake.8,v 1.7 2010/01/03 19:04:26 wiz Exp $
+.\" $NetBSD: wake.8,v 1.8 2010/01/04 11:34:39 mbalmer Exp $
.\"
.\" Copyright (c) 2009, 2010 Marc Balmer <marc%msys.ch@localhost>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd January 3, 2010
+.Dd January 4, 2010
.Dt WAKE 8
.Os
.Sh NAME
@@ -35,13 +35,12 @@
and can be used to power on machines from a remote system without
having physical access to them.
.Pp
-If
.Ar interface
-is an Ethernet interface of the local machine, it is used to send the
+is an Ethernet interface of the local machine and is used to send the
Wake on LAN frames over it.
-Else
-.Nm
-uses the first Ethernet device found in the system.
+If there is only one Ethernet device available that is up and running, then the
+.Ar interface
+argument can be omitted.
.Ar lladdr
is the link layer address of the remote machine.
This can be specified as the actual hardware address
diff -r ea25feb92af9 -r 1d4b04391508 usr.sbin/wake/wake.c
--- a/usr.sbin/wake/wake.c Mon Jan 04 10:06:53 2010 +0000
+++ b/usr.sbin/wake/wake.c Mon Jan 04 11:34:39 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wake.c,v 1.10 2010/01/03 17:58:14 mbalmer Exp $ */
+/* $NetBSD: wake.c,v 1.11 2010/01/04 11:34:39 mbalmer Exp $ */
/*
* Copyright (C) 2006, 2007, 2008, 2009, 2010 Marc Balmer <marc%msys.ch@localhost>
@@ -117,6 +117,7 @@
{
struct ifaddrs *ifap, *ifa;
struct sockaddr_dl *sdl = NULL;
+ int nifs;
if (dst == NULL || len == 0)
return 0;
@@ -125,18 +126,18 @@
return -1;
/* XXX also check the link state */
- for (ifa = ifap; ifa; ifa = ifa->ifa_next)
+ for (nifs = 0, ifa = ifap; ifa; ifa = ifa->ifa_next)
if (ifa->ifa_addr->sa_family == AF_LINK &&
ifa->ifa_flags & IFF_UP && ifa->ifa_flags & IFF_RUNNING) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
if (sdl->sdl_type == IFT_ETHER) {
strlcpy(dst, ifa->ifa_name, len);
- break;
+ nifs++;
}
}
freeifaddrs(ifap);
- return 0;
+ return nifs == 1 ? 0 : -1;
}
static int
Home |
Main Index |
Thread Index |
Old Index