diff options
-rw-r--r-- | sbin/ifconfig/brconfig.h | 4 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 14 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 6 | ||||
-rw-r--r-- | sys/net/if.c | 27 | ||||
-rw-r--r-- | sys/net/if.h | 5 |
5 files changed, 49 insertions, 7 deletions
diff --git a/sbin/ifconfig/brconfig.h b/sbin/ifconfig/brconfig.h index 84d220b3b9c..8d3471686a6 100644 --- a/sbin/ifconfig/brconfig.h +++ b/sbin/ifconfig/brconfig.h @@ -1,4 +1,4 @@ -/* $OpenBSD: brconfig.h,v 1.3 2010/06/07 15:05:42 jsg Exp $ */ +/* $OpenBSD: brconfig.h,v 1.4 2011/03/13 15:31:41 stsp Exp $ */ /* * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org> @@ -68,7 +68,7 @@ int bridge_rule(int, char **, int); #define IFFBITS \ "\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\ -\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST\21TXREADY\22NOINET6\23INET6_PRIVACY\24MPLS" +\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST\21TXREADY\22NOINET6\23INET6_PRIVACY\24MPLS\25WOL" void printb(char *, unsigned int, char *); diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 2a36956c858..cacf502e81d 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.213 2011/02/17 08:32:29 camield Exp $ +.\" $OpenBSD: ifconfig.8,v 1.214 2011/03/13 15:31:41 stsp Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: February 17 2011 $ +.Dd $Mdocdate: March 13 2011 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -435,6 +435,16 @@ This may be used to enable an interface after an It happens automatically when setting the first address on an interface. If the interface was reset when previously marked down, the hardware will be re-initialized. +.Pp +.It Cm wol +Enable Wake On LAN (WOL). +When enabled, reception of a WOL frame will cause the network card to +power up the system from standby or suspend mode. +WOL frames can be sent using +.Xr arp 8 . +.It Fl wol +Disable WOL. +WOL is disabled at boot by the driver, if possible. .El .Pp .Nm diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 332f84facbf..31cbe30ac0a 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.244 2011/03/01 09:37:31 claudio Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.245 2011/03/13 15:31:41 stsp Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -461,6 +461,8 @@ const struct cmd { { "descr", NEXTARG, 0, setifdesc }, { "-description", 1, 0, unsetifdesc }, { "-descr", 1, 0, unsetifdesc }, + { "wol", IFXF_WOL, 0, setifxflags }, + { "-wol", -IFXF_WOL, 0, setifxflags }, #else /* SMALL */ { "group", NEXTARG, 0, setignore }, { "powersave", NEXTARG0, 0, setignore }, @@ -474,6 +476,8 @@ const struct cmd { { "-inet6", IFXF_NOINET6, 0, setignore } , { "description", NEXTARG, 0, setignore }, { "descr", NEXTARG, 0, setignore }, + { "wol", IFXF_WOL, 0, setignore }, + { "-wol", -IFXF_WOL, 0, setignore }, #endif /* SMALL */ #if 0 /* XXX `create' special-cased below */ diff --git a/sys/net/if.c b/sys/net/if.c index 7beefb68cc0..635371dca9d 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.233 2011/01/25 05:44:05 tedu Exp $ */ +/* $OpenBSD: if.c,v 1.234 2011/03/13 15:31:41 stsp Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1357,6 +1357,31 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) } #endif +#ifndef SMALL_KERNEL + if (ifp->if_capabilities & IFCAP_WOL) { + if (ISSET(ifr->ifr_flags, IFXF_WOL) && + !ISSET(ifp->if_xflags, IFXF_WOL)) { + int s = splnet(); + ifp->if_xflags |= IFXF_WOL; + error = ifp->if_wol(ifp, 1); + splx(s); + if (error) + return (error); + } + if (ISSET(ifp->if_xflags, IFXF_WOL) && + !ISSET(ifr->ifr_flags, IFXF_WOL)) { + int s = splnet(); + ifp->if_xflags &= ~IFXF_WOL; + error = ifp->if_wol(ifp, 0); + splx(s); + if (error) + return (error); + } + } else if (ISSET(ifr->ifr_flags, IFXF_WOL)) { + ifr->ifr_flags &= ~IFXF_WOL; + error = ENOTSUP; + } +#endif ifp->if_xflags = (ifp->if_xflags & IFXF_CANTCHANGE) | (ifr->ifr_flags & ~IFXF_CANTCHANGE); diff --git a/sys/net/if.h b/sys/net/if.h index 3370be6881d..29c3f82885d 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.121 2010/11/17 18:51:57 henning Exp $ */ +/* $OpenBSD: if.h,v 1.122 2011/03/13 15:31:41 stsp Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -278,6 +278,7 @@ struct ifnet { /* and the entries */ int (*if_stop)(struct ifnet *, int); /* timer routine */ void (*if_watchdog)(struct ifnet *); + int (*if_wol)(struct ifnet *, int); struct ifaltq if_snd; /* output queue (includes altq) */ struct sockaddr_dl *if_sadl; /* pointer to our sockaddr_dl */ @@ -329,6 +330,7 @@ struct ifnet { /* and the entries */ #define IFXF_NOINET6 0x2 /* don't do inet6 */ #define IFXF_INET6_PRIVACY 0x4 /* autoconf privacy extension */ #define IFXF_MPLS 0x8 /* supports MPLS */ +#define IFXF_WOL 0x10 /* wake on lan enabled */ #define IFXF_CANTCHANGE \ (IFXF_TXREADY) @@ -352,6 +354,7 @@ struct ifnet { /* and the entries */ #define IFCAP_CSUM_UDPv6 0x00000100 /* can do IPv6/UDP checksums */ #define IFCAP_CSUM_TCPv4_Rx 0x00000200 /* can do IPv4/TCP (Rx only) */ #define IFCAP_CSUM_UDPv4_Rx 0x00000400 /* can do IPv4/UDP (Rx only) */ +#define IFCAP_WOL 0x00008000 /* can do wake on lan */ /* * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) |