summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-05-03 10:15:57 +0200
committerThomas Haller <thaller@redhat.com>2015-06-05 16:52:50 +0200
commit398819c3ac348abb451f4f6ae15e306328a77ec6 (patch)
tree496298fee0c4ca5f4b1e5a7a7b905bd0bbd666b3
parentba084b5b9035075c09ddf8676c8de27df5e0f53a (diff)
downloadNetworkManager-398819c3ac348abb451f4f6ae15e306328a77ec6.tar.gz
platform: factor out ethtool_get_wake_on_lan() function
-rw-r--r--src/platform/nm-linux-platform.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 377ea6db3f..e69ff2cfd6 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -545,6 +545,22 @@ ethtool_get_peer_ifindex (const char *ifname)
return stats->data[peer_ifindex_stat];
}
+static gboolean
+ethtool_get_wake_on_lan (const char *ifname)
+{
+ struct ethtool_wolinfo wol;
+
+ if (!ifname)
+ return FALSE;
+
+ memset (&wol, 0, sizeof (wol));
+ wol.cmd = ETHTOOL_GWOL;
+ if (!ethtool_get (ifname, &wol))
+ return FALSE;
+
+ return wol.wolopts != 0;
+}
+
/******************************************************************
* NMPlatform types and functions
******************************************************************/
@@ -3786,16 +3802,9 @@ link_get_wake_on_lan (NMPlatform *platform, int ifindex)
{
NMLinkType type = link_get_type (platform, ifindex);
- if (type == NM_LINK_TYPE_ETHERNET) {
- struct ethtool_wolinfo wol;
-
- memset (&wol, 0, sizeof (wol));
- wol.cmd = ETHTOOL_GWOL;
- if (!ethtool_get (link_get_name (platform, ifindex), &wol))
- return FALSE;
-
- return wol.wolopts != 0;
- } else if (type == NM_LINK_TYPE_WIFI) {
+ if (type == NM_LINK_TYPE_ETHERNET)
+ return ethtool_get_wake_on_lan (link_get_name (platform, ifindex));
+ else if (type == NM_LINK_TYPE_WIFI) {
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)