diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-03-13 15:31:42 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2011-03-13 15:31:42 +0000 |
commit | 99928b0969778ebd83c82b996a1ff05f719ac6dd (patch) | |
tree | 719028bc7c0a9fff84dff372f7a11c0d2e6a22fc /sys/net | |
parent | c9dc38004d407de8e6923f4d8359e05b0e41552b (diff) |
Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 27 | ||||
-rw-r--r-- | sys/net/if.h | 5 |
2 files changed, 30 insertions, 2 deletions
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) |