Module Name: src
Committed By: uebayasi
Date: Sat May 26 01:58:21 UTC 2012
Modified Files:
src/distrib/sets/lists/base: mi
src/distrib/sets/lists/comp: mi
src/distrib/sets/lists/man: mi
src/usr.sbin: Makefile
Added Files:
src/usr.sbin/wakeonlan: Makefile wakeonlan.8 wakeonlan.c
Removed Files:
src/usr.sbin/wake: Makefile wake.8 wake.c
Log Message:
Rename wake(8) to wakeonlan(8). Approved by core@.
To generate a diff of this commit:
cvs rdiff -u -r1.991 -r1.992 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1758 -r1.1759 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.1390 -r1.1391 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.264 -r1.265 src/usr.sbin/Makefile
cvs rdiff -u -r1.2 -r0 src/usr.sbin/wake/Makefile
cvs rdiff -u -r1.8 -r0 src/usr.sbin/wake/wake.8
cvs rdiff -u -r1.13 -r0 src/usr.sbin/wake/wake.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/wakeonlan/Makefile \
src/usr.sbin/wakeonlan/wakeonlan.8 src/usr.sbin/wakeonlan/wakeonlan.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.991 src/distrib/sets/lists/base/mi:1.992
--- src/distrib/sets/lists/base/mi:1.991 Wed May 9 22:04:05 2012
+++ src/distrib/sets/lists/base/mi Sat May 26 01:58:17 2012
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.991 2012/05/09 22:04:05 christos Exp $
+# $NetBSD: mi,v 1.992 2012/05/26 01:58:17 uebayasi Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -1495,7 +1495,8 @@
./usr/sbin/veriexecgen base-sysutil-bin
./usr/sbin/vipw base-sysutil-bin
./usr/sbin/vnconfig base-sysutil-bin
-./usr/sbin/wake base-netutil-bin
+./usr/sbin/wake base-obsolete
+./usr/sbin/wakeonlan base-netutil-bin
./usr/sbin/wiconfig base-sysutil-bin
./usr/sbin/wire-test base-netutil-bin
./usr/sbin/wlanctl base-sysutil-bin
Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1758 src/distrib/sets/lists/comp/mi:1.1759
--- src/distrib/sets/lists/comp/mi:1.1758 Sun May 13 09:00:51 2012
+++ src/distrib/sets/lists/comp/mi Sat May 26 01:58:18 2012
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1758 2012/05/13 09:00:51 mrg Exp $
+# $NetBSD: mi,v 1.1759 2012/05/26 01:58:18 uebayasi Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4326,7 +4326,8 @@
./usr/libdata/debug/usr/sbin/veriexecgen.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/vipw.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/vnconfig.debug comp-sysutil-debug debug
-./usr/libdata/debug/usr/sbin/wake.debug comp-netutil-debug debug
+./usr/libdata/debug/usr/sbin/wake.debug comp-obsolete obsolete
+./usr/libdata/debug/usr/sbin/wakeonlan.debug comp-netutil-debug debug
./usr/libdata/debug/usr/sbin/wiconfig.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/wire-test.debug comp-netutil-debug debug
./usr/libdata/debug/usr/sbin/wlanctl.debug comp-sysutil-debug debug
Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1390 src/distrib/sets/lists/man/mi:1.1391
--- src/distrib/sets/lists/man/mi:1.1390 Tue May 15 17:47:48 2012
+++ src/distrib/sets/lists/man/mi Sat May 26 01:58:20 2012
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1390 2012/05/15 17:47:48 rkujawa Exp $
+# $NetBSD: mi,v 1.1391 2012/05/26 01:58:20 uebayasi Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2950,7 +2950,8 @@
./usr/share/man/cat8/virtual.0 man-postfix-catman postfix,.cat
./usr/share/man/cat8/vmstat.0 man-obsolete obsolete
./usr/share/man/cat8/vnconfig.0 man-sysutil-catman .cat
-./usr/share/man/cat8/wake.0 man-netutil-catman .cat
+./usr/share/man/cat8/wake.0 man-obsolete obsolete
+./usr/share/man/cat8/wakeonlan.0 man-netutil-catman .cat
./usr/share/man/cat8/walnut/MAKEDEV.0 man-obsolete obsolete
./usr/share/man/cat8/walnut/makedev.0 man-obsolete obsolete
./usr/share/man/cat8/wdogctl.0 man-sysutil-catman .cat
@@ -5527,7 +5528,8 @@
./usr/share/man/html8/virecover.html man-sysutil-htmlman html
./usr/share/man/html8/virtual.html man-postfix-htmlman postfix,html
./usr/share/man/html8/vnconfig.html man-sysutil-htmlman html
-./usr/share/man/html8/wake.html man-netutil-htmlman html
+./usr/share/man/html8/wake.html man-obsolete obsolete
+./usr/share/man/html8/wakeonlan.html man-netutil-htmlman html
./usr/share/man/html8/wdogctl.html man-sysutil-htmlman html
./usr/share/man/html8/wiconfig.html man-netutil-htmlman html
./usr/share/man/html8/wire-test.html man-netutil-htmlman html
@@ -8475,7 +8477,8 @@
./usr/share/man/man8/virtual.8 man-postfix-man postfix,.man
./usr/share/man/man8/vmstat.8 man-obsolete obsolete
./usr/share/man/man8/vnconfig.8 man-sysutil-man .man
-./usr/share/man/man8/wake.8 man-netutil-man .man
+./usr/share/man/man8/wake.8 man-obsolete obsolete
+./usr/share/man/man8/wakeonlan.8 man-netutil-man .man
./usr/share/man/man8/walnut/MAKEDEV.8 man-obsolete obsolete
./usr/share/man/man8/walnut/makedev.8 man-obsolete obsolete
./usr/share/man/man8/wdogctl.8 man-sysutil-man .man
Index: src/usr.sbin/Makefile
diff -u src/usr.sbin/Makefile:1.264 src/usr.sbin/Makefile:1.265
--- src/usr.sbin/Makefile:1.264 Fri Mar 23 21:30:57 2012
+++ src/usr.sbin/Makefile Sat May 26 01:58:20 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.264 2012/03/23 21:30:57 christos Exp $
+# $NetBSD: Makefile,v 1.265 2012/05/26 01:58:20 uebayasi Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@@ -29,7 +29,7 @@ SUBDIR= ac accton acpitools altq apm apm
tadpolectl tcpdchk tcpdmatch tcpdrop timed tpctl tprof traceroute trpt \
unlink usbdevs user \
videomode vipw veriexecgen vnconfig \
- wake wiconfig wlanctl wsconscfg wsfontload wsmoused wsmuxctl \
+ wakeonlan wiconfig wlanctl wsconscfg wsfontload wsmoused wsmuxctl \
zdump zic
.if ${MKMAKEMANDB} != "no"
Added files:
Index: src/usr.sbin/wakeonlan/Makefile
diff -u /dev/null src/usr.sbin/wakeonlan/Makefile:1.1
--- /dev/null Sat May 26 01:58:21 2012
+++ src/usr.sbin/wakeonlan/Makefile Sat May 26 01:58:20 2012
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2012/05/26 01:58:20 uebayasi Exp $
+
+PROG= wakeonlan
+SRCS= wakeonlan.c
+
+MAN= wakeonlan.8
+
+.include <bsd.prog.mk>
Index: src/usr.sbin/wakeonlan/wakeonlan.8
diff -u /dev/null src/usr.sbin/wakeonlan/wakeonlan.8:1.1
--- /dev/null Sat May 26 01:58:21 2012
+++ src/usr.sbin/wakeonlan/wakeonlan.8 Sat May 26 01:58:20 2012
@@ -0,0 +1,68 @@
+.\" $NetBSD: wakeonlan.8,v 1.1 2012/05/26 01:58:20 uebayasi Exp $
+.\"
+.\" Copyright (c) 2009, 2010 Marc Balmer <[email protected]>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd May 25, 2012
+.Dt WAKEONLAN 8
+.Os
+.Sh NAME
+.Nm wakeonlan
+.Nd send Wake on LAN frames to hosts on a local Ethernet network
+.Sh SYNOPSIS
+.Nm
+.Op Ar interface
+.Ar lladdr
+.Op Ar lladdr ...
+.Sh DESCRIPTION
+The
+.Nm
+program is used to send Wake on LAN (WoL) frames over a local
+Ethernet network to one or more hosts using their link layer (hardware)
+addresses.
+WoL functionality is generally enabled in a machine's BIOS
+and can be used to power on machines from a remote system without
+having physical access to them.
+.Pp
+.Ar interface
+is an Ethernet interface of the local machine and is used to send the
+Wake on LAN frames over it.
+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
+(six hexadecimal numbers separated by colons)
+or as a hostname entry in
+.Pa /etc/ethers .
+.Nm
+accepts multiple
+.Ar lladdr
+addresses.
+Link layer addresses can be determined and set using
+.Xr ifconfig 8 .
+.Sh FILES
+.Bl -tag -width "/etc/ethers" -compact
+.It /etc/ethers
+Ethernet host name data base.
+.El
+.Sh SEE ALSO
+.Xr ethers 5 ,
+.Xr ifconfig 8
+.Sh AUTHORS
+.Nm
+was written by
+.An Marc Balmer
+.Aq [email protected] .
Index: src/usr.sbin/wakeonlan/wakeonlan.c
diff -u /dev/null src/usr.sbin/wakeonlan/wakeonlan.c:1.1
--- /dev/null Sat May 26 01:58:21 2012
+++ src/usr.sbin/wakeonlan/wakeonlan.c Sat May 26 01:58:21 2012
@@ -0,0 +1,218 @@
+/* $NetBSD: wakeonlan.c,v 1.1 2012/05/26 01:58:21 uebayasi Exp $ */
+
+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Marc Balmer <[email protected]>
+ * Copyright (C) 2000 Eugene M. Kim. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Author's name may not be used endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Send Wake on LAN packets to hosts on a local Ethernet network */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <ifaddrs.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+
+#ifndef SYNC_LEN
+#define SYNC_LEN 6
+#endif
+
+#ifndef DESTADDR_COUNT
+#define DESTADDR_COUNT 16
+#endif
+
+__dead static void usage(void);
+static int wake(int, const char *);
+static int bind_if_to_bpf(char const *, int);
+static int find_ether(char *, size_t);
+static int get_ether(char const *, struct ether_addr *);
+static int send_wakeup(int, struct ether_addr const *);
+
+static void
+usage(void)
+{
+ fprintf(stderr, "usage: %s [interface] lladdr [lladdr ...]\n",
+ getprogname());
+ exit(EXIT_FAILURE);
+}
+
+static int
+wake(int bpf, const char *host)
+{
+ struct ether_addr macaddr;
+
+ if (get_ether(host, &macaddr) == -1)
+ return -1;
+
+ return send_wakeup(bpf, &macaddr);
+}
+
+static int
+bind_if_to_bpf(char const *ifname, int bpf)
+{
+ struct ifreq ifr;
+ u_int dlt;
+
+ if (strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)) >=
+ sizeof(ifr.ifr_name)) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ if (ioctl(bpf, BIOCSETIF, &ifr) == -1)
+ return -1;
+ if (ioctl(bpf, BIOCGDLT, &dlt) == -1)
+ return -1;
+ if (dlt != DLT_EN10MB) {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+ return 0;
+}
+
+static int
+find_ether(char *dst, size_t len)
+{
+ struct ifaddrs *ifap, *ifa;
+ struct sockaddr_dl *sdl = NULL;
+ int nifs;
+
+ if (dst == NULL || len == 0)
+ return 0;
+
+ if (getifaddrs(&ifap) != 0)
+ return -1;
+
+ /* XXX also check the link state */
+ 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);
+ nifs++;
+ }
+ }
+
+ freeifaddrs(ifap);
+ return nifs == 1 ? 0 : -1;
+}
+
+static int
+get_ether(char const *text, struct ether_addr *addr)
+{
+ struct ether_addr *paddr;
+
+ paddr = ether_aton(text);
+ if (paddr != NULL) {
+ *addr = *paddr;
+ return 0;
+ }
+ if (ether_hostton(text, addr))
+ return -1;
+ return 0;
+}
+
+static int
+send_wakeup(int bpf, struct ether_addr const *addr)
+{
+ struct {
+ struct ether_header hdr;
+ u_char data[SYNC_LEN + ETHER_ADDR_LEN * DESTADDR_COUNT];
+ } pkt;
+ u_char *p;
+ int i;
+ ssize_t bw, len;
+
+ memset(pkt.hdr.ether_dhost, 0xff, sizeof(pkt.hdr.ether_dhost));
+ pkt.hdr.ether_type = htons(0);
+ memset(pkt.data, 0xff, SYNC_LEN);
+ for (p = pkt.data + SYNC_LEN, i = 0; i < DESTADDR_COUNT;
+ p += ETHER_ADDR_LEN, i++)
+ memcpy(p, addr->ether_addr_octet, ETHER_ADDR_LEN);
+ p = (u_char *)(void *)&pkt;
+ len = sizeof(pkt);
+ bw = 0;
+ while (len) {
+ if ((bw = write(bpf, p, len)) == -1)
+ return -1;
+ len -= bw;
+ p += bw;
+ }
+ return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int bpf, n;
+ char ifname[IF_NAMESIZE];
+
+ if (argc < 2)
+ usage();
+
+ if ((bpf = open(_PATH_BPF, O_RDWR)) == -1)
+ err(EXIT_FAILURE, "Cannot open bpf interface");
+
+ n = 2;
+ if (bind_if_to_bpf(argv[1], bpf) == -1) {
+ if (find_ether(ifname, sizeof(ifname)))
+ err(EXIT_FAILURE, "Failed to determine ethernet "
+ "interface");
+ if (bind_if_to_bpf(ifname, bpf) == -1)
+ err(EXIT_FAILURE, "Cannot bind to interface `%s'",
+ ifname);
+ --n;
+ } else
+ strlcpy(ifname, argv[1], sizeof(ifname));
+
+ if (n >= argc)
+ usage();
+ for (; n < argc; n++)
+ if (wake(bpf, argv[n]))
+ warn("Cannot send Wake on LAN frame over `%s' to `%s'",
+ ifname, argv[n]);
+ return EXIT_SUCCESS;
+}