platform: add link_get_wake_on_lan()
This commit is contained in:
@@ -476,6 +476,15 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
|
||||
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
|
||||
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_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_vlans = link_supports_vlans;
|
||||
|
@@ -2873,6 +2873,31 @@ mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *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
|
||||
@@ -3644,6 +3669,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
||||
platform_class->link_set_mtu = link_set_mtu;
|
||||
|
||||
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_vlans = link_supports_vlans;
|
||||
|
@@ -901,6 +901,23 @@ nm_platform_link_get_physical_port_id (int 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:
|
||||
* @master: Interface index of the master
|
||||
|
@@ -321,6 +321,7 @@ typedef struct {
|
||||
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
||||
|
||||
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_vlans) (NMPlatform *, int ifindex);
|
||||
@@ -466,7 +467,8 @@ gboolean nm_platform_link_set_address (int ifindex, const void *address, size_t
|
||||
guint32 nm_platform_link_get_mtu (int ifindex);
|
||||
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_vlans (int ifindex);
|
||||
|
Reference in New Issue
Block a user