2
* Copyright 2007, Intel Corporation
4
* This file is part of PowerTOP
6
* This program file is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
* You should have received a copy of the GNU General Public License
16
* along with this program in a file named COPYING; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301 USA
22
* Arjan van de Ven <arjan@linux.intel.com>
30
#include <sys/types.h>
32
#include <linux/types.h>
34
#include <linux/sockios.h>
35
#include <sys/ioctl.h>
37
/* work around a bug in debian -- it exposes kernel internal types to userspace */
42
#include <linux/ethtool.h>
52
void activate_WOL_suggestion(void)
56
struct ethtool_wolinfo wol;
59
memset(&ifr, 0, sizeof(struct ifreq));
61
sock = socket(AF_INET, SOCK_DGRAM, 0);
65
strcpy(ifr.ifr_name, "eth0");
67
/* Check if the interface is up */
68
ret = ioctl(sock, SIOCGIFFLAGS, &ifr);
74
if (ifr.ifr_flags & (IFF_UP | IFF_RUNNING)) {
79
memset(&wol, 0, sizeof(wol));
81
wol.cmd = ETHTOOL_GWOL;
82
ifr.ifr_data = (caddr_t)&wol;
83
ioctl(sock, SIOCETHTOOL, &ifr);
84
wol.cmd = ETHTOOL_SWOL;
86
ioctl(sock, SIOCETHTOOL, &ifr);
93
void suggest_WOL_off(void)
97
struct ethtool_wolinfo wol;
100
memset(&ifr, 0, sizeof(struct ifreq));
102
sock = socket(AF_INET, SOCK_DGRAM, 0);
106
strcpy(ifr.ifr_name, "eth0");
108
/* Check if the interface is up */
109
ret = ioctl(sock, SIOCGIFFLAGS, &ifr);
115
if (ifr.ifr_flags & (IFF_UP | IFF_RUNNING)) {
120
memset(&wol, 0, sizeof(wol));
122
wol.cmd = ETHTOOL_GWOL;
123
ifr.ifr_data = (caddr_t)&wol;
124
ioctl(sock, SIOCETHTOOL, &ifr);
128
"Disable Ethernet Wake-On-Lan with the following command:\n"
129
" ethtool -s eth0 wol d \n"
130
"Wake-on-Lan keeps the phy active, this costs power."), 5,
131
'W', _(" W - disable Wake-On-Lan "), activate_WOL_suggestion);