platform: add link_get_wake_on_lan()

This commit is contained in:
Dan Winship
2014-02-05 11:56:44 +01:00
parent 79675fc1c9
commit ddb17bef81
4 changed files with 56 additions and 1 deletions

View File

@@ -476,6 +476,15 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
return NULL; return NULL;
} }
static gboolean
link_get_wake_on_lan (NMPlatform *platform, int ifindex)
{
/* We call link_get just to cause an error to be set if @ifindex is bad. */
link_get (platform, ifindex);
return FALSE;
}
static gboolean static gboolean
link_supports_carrier_detect (NMPlatform *platform, int ifindex) link_supports_carrier_detect (NMPlatform *platform, int ifindex)
{ {
@@ -1301,6 +1310,7 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
platform_class->link_set_mtu = link_set_mtu; platform_class->link_set_mtu = link_set_mtu;
platform_class->link_get_physical_port_id = link_get_physical_port_id; platform_class->link_get_physical_port_id = link_get_physical_port_id;
platform_class->link_get_wake_on_lan = link_get_wake_on_lan;
platform_class->link_supports_carrier_detect = link_supports_carrier_detect; platform_class->link_supports_carrier_detect = link_supports_carrier_detect;
platform_class->link_supports_vlans = link_supports_vlans; platform_class->link_supports_vlans = link_supports_vlans;

View File

@@ -2873,6 +2873,31 @@ mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *ssid)
return wifi_utils_set_mesh_ssid (wifi_data, ssid); return wifi_utils_set_mesh_ssid (wifi_data, ssid);
} }
static gboolean
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) {
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_get_wowlan (wifi_data);
} else
return FALSE;
}
/******************************************************************/ /******************************************************************/
static int static int
@@ -3644,6 +3669,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->link_set_mtu = link_set_mtu; platform_class->link_set_mtu = link_set_mtu;
platform_class->link_get_physical_port_id = link_get_physical_port_id; platform_class->link_get_physical_port_id = link_get_physical_port_id;
platform_class->link_get_wake_on_lan = link_get_wake_on_lan;
platform_class->link_supports_carrier_detect = link_supports_carrier_detect; platform_class->link_supports_carrier_detect = link_supports_carrier_detect;
platform_class->link_supports_vlans = link_supports_vlans; platform_class->link_supports_vlans = link_supports_vlans;

View File

@@ -901,6 +901,23 @@ nm_platform_link_get_physical_port_id (int ifindex)
return klass->link_get_physical_port_id (platform, ifindex); return klass->link_get_physical_port_id (platform, ifindex);
} }
/**
* nm_platform_link_get_wake_onlan:
* @ifindex: Interface index
*
* Returns: the "Wake-on-LAN" status for @ifindex.
*/
gboolean
nm_platform_link_get_wake_on_lan (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex >= 0, FALSE);
g_return_val_if_fail (klass->link_get_wake_on_lan, FALSE);
return klass->link_get_wake_on_lan (platform, ifindex);
}
/** /**
* nm_platform_link_enslave: * nm_platform_link_enslave:
* @master: Interface index of the master * @master: Interface index of the master

View File

@@ -321,6 +321,7 @@ typedef struct {
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu); gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex); char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
gboolean (*link_get_wake_on_lan) (NMPlatform *, int ifindex);
gboolean (*link_supports_carrier_detect) (NMPlatform *, int ifindex); gboolean (*link_supports_carrier_detect) (NMPlatform *, int ifindex);
gboolean (*link_supports_vlans) (NMPlatform *, int ifindex); gboolean (*link_supports_vlans) (NMPlatform *, int ifindex);
@@ -467,6 +468,7 @@ guint32 nm_platform_link_get_mtu (int ifindex);
gboolean nm_platform_link_set_mtu (int ifindex, guint32 mtu); gboolean nm_platform_link_set_mtu (int ifindex, guint32 mtu);
char *nm_platform_link_get_physical_port_id (int ifindex); char *nm_platform_link_get_physical_port_id (int ifindex);
gboolean nm_platform_link_get_wake_on_lan (int ifindex);
gboolean nm_platform_link_supports_carrier_detect (int ifindex); gboolean nm_platform_link_supports_carrier_detect (int ifindex);
gboolean nm_platform_link_supports_vlans (int ifindex); gboolean nm_platform_link_supports_vlans (int ifindex);