diff options
author | Simon Fels <simon.fels@canonical.com> | 2018-05-25 17:45:16 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-06-15 09:46:26 +0200 |
commit | ea10016d242c42b86d68d3bae8e5be8d58533671 (patch) | |
tree | ff6e5f2a105e0edbf469260b22710fae1032cc9a | |
parent | 1621c79e7b6c41593958716f0b4e78395f9b2c7d (diff) | |
download | NetworkManager-ea10016d242c42b86d68d3bae8e5be8d58533671.tar.gz |
devices: enable wake-on-wlan when device is enabled
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index f3c23e60f3..5d03d7b79a 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -2423,6 +2423,48 @@ error: /*****************************************************************************/ +static gboolean +wake_on_wlan_enable (NMDevice *device) +{ + NMSettingWirelessWakeOnWLan wowl; + NMSettingWireless *s_wireless; + gs_free char *value = NULL; + + s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS); + if (s_wireless) { + wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless); + if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT) + goto found; + } + + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "wifi.wake-on-wlan", + device); + + if (value) { + wowl = _nm_utils_ascii_str_to_int64 (value, 10, + NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE, + G_MAXINT32, + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT); + + if (NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) { + if (!nm_utils_is_power_of_two (wowl)) { + nm_log_dbg (LOGD_WIFI, "invalid default value %u for wake-on-wlan: " + "'default' and 'ignore' are exclusive flags", (guint) wowl); + wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT; + } + } else if (!NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) { + nm_log_dbg (LOGD_WIFI, "invalid default value %u for wake-on-wlan", (guint) wowl); + wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT; + } + if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT) + goto found; + } + wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE; +found: + return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), wowl); +} + static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason) { @@ -2616,6 +2658,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason) s_wireless = nm_connection_get_setting_wireless (connection); g_assert (s_wireless); + wake_on_wlan_enable (device); + /* If we need secrets, get them */ setting_name = nm_connection_need_secrets (connection, NULL); if (setting_name) { @@ -3083,7 +3127,8 @@ can_reapply_change (NMDevice *device, return nm_device_hash_check_invalid_keys (diffs, NM_SETTING_WIRELESS_SETTING_NAME, error, - NM_SETTING_WIRELESS_MTU); /* reapplied with IP config */ + NM_SETTING_WIRELESS_MTU, /* reapplied with IP config */ + NM_SETTING_WIRELESS_WAKE_ON_WLAN); } device_class = NM_DEVICE_CLASS (nm_device_wifi_parent_class); @@ -3095,6 +3140,20 @@ can_reapply_change (NMDevice *device, error); } +static void +reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_new) +{ + NMDeviceWifi *self = NM_DEVICE_WIFI (device); + + NM_DEVICE_CLASS (nm_device_wifi_parent_class)->reapply_connection (device, + con_old, + con_new); + + _LOGD (LOGD_DEVICE, "reapplying wireless settings"); + + wake_on_wlan_enable (device); +} + /*****************************************************************************/ static void @@ -3264,6 +3323,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) parent_class->deactivate_reset_hw_addr = deactivate_reset_hw_addr; parent_class->unmanaged_on_quit = unmanaged_on_quit; parent_class->can_reapply_change = can_reapply_change; + parent_class->reapply_connection = reapply_connection; parent_class->state_changed = device_state_changed; |