Merge ~morphis/snappy-hwe-snaps/+git/network-manager:feature/network-manager/wowlan into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2
- Git
- lp:~morphis/snappy-hwe-snaps/+git/network-manager
- feature/network-manager/wowlan
- Merge into network-manager/xenial/1.2.2
Proposed by
Simon Fels
Status: | Merged |
---|---|
Approved by: | Alfonso Sanchez-Beato |
Approved revision: | 1b01b90d1d7d430728c12d1b754c7eb7c650520d |
Merged at revision: | d1b544155fa0b5cac871c35130a02d512dc94cf1 |
Proposed branch: | ~morphis/snappy-hwe-snaps/+git/network-manager:feature/network-manager/wowlan |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2 |
Diff against target: |
635 lines (+345/-1) 15 files modified
clients/cli/settings.c (+64/-1) libnm-core/nm-core-enum-types.c (+27/-0) libnm-core/nm-core-enum-types.h (+2/-0) libnm-core/nm-setting-wireless.c (+85/-0) libnm-core/nm-setting-wireless.h (+47/-0) libnm/libnm.ver (+3/-0) libnm/nm-setting-docs.xml (+2/-0) src/devices/wifi/nm-device-wifi.c (+41/-0) src/platform/nm-linux-platform.c (+8/-0) src/platform/nm-platform.c (+10/-0) src/platform/nm-platform.h (+3/-0) src/platform/wifi/wifi-utils-nl80211.c (+40/-0) src/platform/wifi/wifi-utils-private.h (+3/-0) src/platform/wifi/wifi-utils.c (+8/-0) src/platform/wifi/wifi-utils.h (+2/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
System Enablement Bot | continuous-integration | Needs Fixing | |
Tony Espy | Pending | ||
Review via email: mp+314914@code.launchpad.net |
Commit message
Description of the change
Implement Wake-on-WLAN support for NetworkManager
This introduces two new configuration options wifi.wake-on-wlan and wifi.wake-
Upstream submission is waiting until this MP is merged.
Changes are split into multiple commits for easier upstream submission.
To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
LGTM
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/clients/cli/settings.c b/clients/cli/settings.c |
2 | index 1651aab..cc34cd2 100644 |
3 | --- a/clients/cli/settings.c |
4 | +++ b/clients/cli/settings.c |
5 | @@ -205,6 +205,8 @@ NmcOutputField nmc_fields_setting_wireless[] = { |
6 | SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS), /* 13 */ |
7 | SETTING_FIELD (NM_SETTING_WIRELESS_HIDDEN), /* 14 */ |
8 | SETTING_FIELD (NM_SETTING_WIRELESS_POWERSAVE), /* 15 */ |
9 | + SETTING_FIELD (NM_SETTING_WIRELESS_WAKE_ON_WLAN), /* 16 */ |
10 | + SETTING_FIELD (NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD), /* 17 */ |
11 | {NULL, NULL, 0, NULL, FALSE, FALSE, 0} |
12 | }; |
13 | #define NMC_FIELDS_SETTING_WIRELESS_ALL "name"","\ |
14 | @@ -222,7 +224,9 @@ NmcOutputField nmc_fields_setting_wireless[] = { |
15 | NM_SETTING_WIRELESS_MTU","\ |
16 | NM_SETTING_WIRELESS_SEEN_BSSIDS","\ |
17 | NM_SETTING_WIRELESS_HIDDEN"," \ |
18 | - NM_SETTING_WIRELESS_POWERSAVE |
19 | + NM_SETTING_WIRELESS_POWERSAVE"," \ |
20 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN"," \ |
21 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD |
22 | |
23 | /* Available fields for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */ |
24 | NmcOutputField nmc_fields_setting_wireless_security[] = { |
25 | @@ -1901,6 +1905,24 @@ nmc_property_wireless_get_mac_address_randomization (NMSetting *setting, NmcProp |
26 | return g_strdup_printf (_("unknown")); |
27 | } |
28 | |
29 | +static char * |
30 | +nmc_property_wireless_get_wake_on_wlan (NMSetting *setting, NmcPropertyGetType get_type) |
31 | +{ |
32 | + NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting); |
33 | + NMSettingWirelessWakeOnWLan wowl; |
34 | + gs_free char *str = NULL; |
35 | + char *ret; |
36 | + |
37 | + wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless); |
38 | + str = nm_utils_enum_to_str (nm_setting_wireless_wake_on_wlan_get_type (), wowl); |
39 | + |
40 | + if (get_type == NMC_PROPERTY_GET_PARSABLE) { |
41 | + ret = str; |
42 | + str = NULL; |
43 | + return ret; |
44 | + } else |
45 | + return g_strdup_printf ("%s (%u)", str, wowl); |
46 | +} |
47 | |
48 | /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property get functions --- */ |
49 | DEFINE_GETTER (nmc_property_wifi_sec_get_key_mgmt, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT) |
50 | @@ -5013,6 +5035,39 @@ nmc_property_wireless_set_mac_address_randomization (NMSetting *setting, |
51 | return TRUE; |
52 | } |
53 | |
54 | +static gboolean |
55 | +nmc_property_wireless_set_wake_on_wlan (NMSetting *setting, const char *prop, const char *val, GError **error) |
56 | +{ |
57 | + NMSettingWirelessWakeOnWLan wowl; |
58 | + gs_free const char **options = NULL; |
59 | + gs_free char *options_str = NULL; |
60 | + long int t; |
61 | + gboolean ret; |
62 | + |
63 | + if (nmc_string_to_int_base (val, 0, TRUE, |
64 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, |
65 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST, |
66 | + &t)) |
67 | + wowl = (NMSettingWirelessWakeOnWLan) t; |
68 | + else { |
69 | + ret = nm_utils_enum_from_str (nm_setting_wireless_wake_on_wlan_get_type (), |
70 | + val, |
71 | + (int *) &wowl, |
72 | + NULL); |
73 | + if (!ret) { |
74 | + options = nm_utils_enum_get_values (nm_setting_wireless_wake_on_wlan_get_type (), |
75 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, |
76 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST); |
77 | + options_str = g_strjoinv (",", (char **) options); |
78 | + g_set_error (error, 1, 0, _("invalid option '%s', use one of [%s]"), val, options_str); |
79 | + return FALSE; |
80 | + } |
81 | + } |
82 | + |
83 | + g_object_set (setting, prop, (guint) wowl, NULL); |
84 | + return TRUE; |
85 | +} |
86 | + |
87 | /* --- NM_SETTING_WIRELESS_SECURITY_SETTING_NAME property setter functions --- */ |
88 | /* 'key-mgmt' */ |
89 | static const char *wifi_sec_valid_key_mgmts[] = { "none", "ieee8021x", "wpa-none", "wpa-psk", "wpa-eap", NULL }; |
90 | @@ -7202,6 +7257,13 @@ nmc_properties_init (void) |
91 | NULL, |
92 | NULL, |
93 | NULL); |
94 | + nmc_add_prop_funcs (GLUE (WIRELESS, WAKE_ON_WLAN), |
95 | + nmc_property_wireless_get_wake_on_wlan, |
96 | + nmc_property_wireless_set_wake_on_wlan, |
97 | + NULL, |
98 | + NULL, |
99 | + NULL, |
100 | + NULL); |
101 | |
102 | /* Add editable properties for NM_SETTING_WIRELESS_SECURITY_SETTING_NAME */ |
103 | nmc_add_prop_funcs (GLUE (WIRELESS_SECURITY, KEY_MGMT), |
104 | @@ -8064,6 +8126,7 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc, const char *one_prop, |
105 | set_val_str (arr, 13, nmc_property_wireless_get_seen_bssids (setting, NMC_PROPERTY_GET_PRETTY)); |
106 | set_val_str (arr, 14, nmc_property_wireless_get_hidden (setting, NMC_PROPERTY_GET_PRETTY)); |
107 | set_val_str (arr, 15, nmc_property_wireless_get_powersave (setting, NMC_PROPERTY_GET_PRETTY)); |
108 | + set_val_str (arr, 16, nmc_property_wireless_get_wake_on_wlan (setting, NMC_PROPERTY_GET_PRETTY)); |
109 | g_ptr_array_add (nmc->output_data, arr); |
110 | |
111 | print_data (nmc); /* Print all data */ |
112 | diff --git a/libnm-core/nm-core-enum-types.c b/libnm-core/nm-core-enum-types.c |
113 | index 83f5e88..58581bb 100644 |
114 | --- a/libnm-core/nm-core-enum-types.c |
115 | +++ b/libnm-core/nm-core-enum-types.c |
116 | @@ -1053,6 +1053,33 @@ nm_wep_key_type_get_type (void) |
117 | return g_define_type_id__volatile; |
118 | } |
119 | GType |
120 | +nm_setting_wireless_wake_on_wlan_get_type (void) |
121 | +{ |
122 | + static volatile gsize g_define_type_id__volatile = 0; |
123 | + |
124 | + if (g_once_init_enter (&g_define_type_id__volatile)) |
125 | + { |
126 | + static const GFlagsValue values[] = { |
127 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY", "any" }, |
128 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT", "disconnect" }, |
129 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC", "magic" }, |
130 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE", "gtk-rekey-failure" }, |
131 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST", "eap-identity-request" }, |
132 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE", "4way-handshake" }, |
133 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE", "rfkill-release" }, |
134 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP", "tcp" }, |
135 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT", "default" }, |
136 | + { NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE", "ignore" }, |
137 | + { 0, NULL, NULL } |
138 | + }; |
139 | + GType g_define_type_id = |
140 | + g_flags_register_static (g_intern_static_string ("NMSettingWirelessWakeOnWLan"), values); |
141 | + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); |
142 | + } |
143 | + |
144 | + return g_define_type_id__volatile; |
145 | +} |
146 | +GType |
147 | nm_setting_wireless_powersave_get_type (void) |
148 | { |
149 | static volatile gsize g_define_type_id__volatile = 0; |
150 | diff --git a/libnm-core/nm-core-enum-types.h b/libnm-core/nm-core-enum-types.h |
151 | index d316b5e..0958c26 100644 |
152 | --- a/libnm-core/nm-core-enum-types.h |
153 | +++ b/libnm-core/nm-core-enum-types.h |
154 | @@ -91,6 +91,8 @@ GType nm_setting_wired_wake_on_lan_get_type (void) G_GNUC_CONST; |
155 | #define NM_TYPE_SETTING_WIRED_WAKE_ON_LAN (nm_setting_wired_wake_on_lan_get_type ()) |
156 | GType nm_wep_key_type_get_type (void) G_GNUC_CONST; |
157 | #define NM_TYPE_WEP_KEY_TYPE (nm_wep_key_type_get_type ()) |
158 | +GType nm_setting_wireless_wake_on_wlan_get_type (void) G_GNUC_CONST; |
159 | +#define NM_TYPE_SETTING_WIRELESS_WAKE_ON_WLAN (nm_setting_wireless_wake_on_wlan_get_type ()) |
160 | GType nm_setting_wireless_powersave_get_type (void) G_GNUC_CONST; |
161 | #define NM_TYPE_SETTING_WIRELESS_POWERSAVE (nm_setting_wireless_powersave_get_type ()) |
162 | GType nm_setting_secret_flags_get_type (void) G_GNUC_CONST; |
163 | diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c |
164 | index ee4ac6f..95c6466 100644 |
165 | --- a/libnm-core/nm-setting-wireless.c |
166 | +++ b/libnm-core/nm-setting-wireless.c |
167 | @@ -60,6 +60,8 @@ typedef struct { |
168 | gboolean hidden; |
169 | guint32 powersave; |
170 | NMSettingMacRandomization mac_address_randomization; |
171 | + guint32 wowl; |
172 | + char *wowl_password; |
173 | } NMSettingWirelessPrivate; |
174 | |
175 | enum { |
176 | @@ -79,6 +81,8 @@ enum { |
177 | PROP_HIDDEN, |
178 | PROP_POWERSAVE, |
179 | PROP_MAC_ADDRESS_RANDOMIZATION, |
180 | + PROP_WAKE_ON_WLAN, |
181 | + PROP_WAKE_ON_WLAN_PASSWORD, |
182 | |
183 | LAST_PROP |
184 | }; |
185 | @@ -850,6 +854,43 @@ nm_setting_wireless_get_security (NMSetting *setting, |
186 | return NULL; |
187 | } |
188 | |
189 | +/** |
190 | + * nm_setting_wireless_get_wake_on_wlan: |
191 | + * @setting: the #NMSettingWireless |
192 | + * |
193 | + * Returns the Wake-on-WLAN options enabled for the connection |
194 | + * |
195 | + * Returns: the Wake-on-WLAN options |
196 | + * |
197 | + * Since: 1.2 |
198 | + */ |
199 | +NMSettingWirelessWakeOnWLan |
200 | +nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting) |
201 | +{ |
202 | + g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE); |
203 | + |
204 | + return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->wowl; |
205 | +} |
206 | + |
207 | +/** |
208 | + * nm_setting_wired_get_wake_on_lan_password: |
209 | + * @setting: the #NMSettingWireless |
210 | + * |
211 | + * Returns the Wake-on-WLAN password. This only applies to |
212 | + * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC. |
213 | + * |
214 | + * Returns: the Wake-on-WLAN setting password, or %NULL if there is no password. |
215 | + * |
216 | + * Since: 1.2 |
217 | + */ |
218 | +const char * |
219 | +nm_setting_wireless_get_wake_on_wlan_password (NMSettingWireless *setting) |
220 | +{ |
221 | + g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL); |
222 | + |
223 | + return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->wowl_password; |
224 | +} |
225 | + |
226 | static void |
227 | clear_blacklist_item (char **item_p) |
228 | { |
229 | @@ -957,6 +998,13 @@ set_property (GObject *object, guint prop_id, |
230 | case PROP_MAC_ADDRESS_RANDOMIZATION: |
231 | priv->mac_address_randomization = g_value_get_uint (value); |
232 | break; |
233 | + case PROP_WAKE_ON_WLAN: |
234 | + priv->wowl = g_value_get_uint (value); |
235 | + break; |
236 | + case PROP_WAKE_ON_WLAN_PASSWORD: |
237 | + g_free (priv->wowl_password); |
238 | + priv->wowl_password = g_value_dup_string (value); |
239 | + break; |
240 | default: |
241 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
242 | break; |
243 | @@ -1016,6 +1064,12 @@ get_property (GObject *object, guint prop_id, |
244 | case PROP_MAC_ADDRESS_RANDOMIZATION: |
245 | g_value_set_uint (value, nm_setting_wireless_get_mac_address_randomization (setting)); |
246 | break; |
247 | + case PROP_WAKE_ON_WLAN: |
248 | + g_value_set_uint (value, nm_setting_wireless_get_wake_on_wlan (setting)); |
249 | + break; |
250 | + case PROP_WAKE_ON_WLAN_PASSWORD: |
251 | + g_value_set_string (value, nm_setting_wireless_get_wake_on_wlan_password (setting)); |
252 | + break; |
253 | default: |
254 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
255 | break; |
256 | @@ -1431,4 +1485,35 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class) |
257 | _nm_setting_class_add_dbus_only_property (parent_class, "security", |
258 | G_VARIANT_TYPE_STRING, |
259 | nm_setting_wireless_get_security, NULL); |
260 | + |
261 | + /** |
262 | + * NMSettingWireless:wake-on-wlan: |
263 | + * |
264 | + * The #NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options. |
265 | + * |
266 | + * Since: 1.2 |
267 | + **/ |
268 | + g_object_class_install_property |
269 | + (object_class, PROP_WAKE_ON_WLAN, |
270 | + g_param_spec_uint (NM_SETTING_WIRELESS_WAKE_ON_WLAN, "", "", |
271 | + 0, G_MAXUINT32, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, |
272 | + G_PARAM_CONSTRUCT | |
273 | + G_PARAM_READWRITE | |
274 | + G_PARAM_STATIC_STRINGS)); |
275 | + |
276 | + /** |
277 | + * NMSettingWireless:wake-on-wlan-password: |
278 | + * |
279 | + * If specified, the password used with magic-packet-based |
280 | + * Wake-on-LAN, represented as a MAC address. If %NULL, |
281 | + * no password will be required. |
282 | + * |
283 | + * Since: 1.2 |
284 | + **/ |
285 | + g_object_class_install_property |
286 | + (object_class, PROP_WAKE_ON_WLAN_PASSWORD, |
287 | + g_param_spec_string (NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD, "", "", |
288 | + NULL, |
289 | + G_PARAM_READWRITE | |
290 | + G_PARAM_STATIC_STRINGS)); |
291 | } |
292 | diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h |
293 | index 574cee5..f81b391 100644 |
294 | --- a/libnm-core/nm-setting-wireless.h |
295 | +++ b/libnm-core/nm-setting-wireless.h |
296 | @@ -41,6 +41,48 @@ G_BEGIN_DECLS |
297 | |
298 | #define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless" |
299 | |
300 | +/** |
301 | + * NMSettingWirelessWakeOnWLan: |
302 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE: Wake-on-WLAN disabled |
303 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY: Wake on any activity |
304 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT: Wake on disconnect |
305 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC: Wake on magic packet |
306 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE: Wake on GTK rekey failure |
307 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST: Wake on EAP identity request |
308 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE: Wake on 4way hanshake |
309 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE: Wake on rfkill release |
310 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL: Wake on all events. This does not |
311 | + * include the exclusive flags @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT or |
312 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE. |
313 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT: Use the default value |
314 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE: Don't change configured settings |
315 | + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS: Mask of flags that are |
316 | + * incompatible with other flags |
317 | + * |
318 | + * Options for #NMSettingWireless:wake-on-wlan. Note that not all options |
319 | + * are supported by all devices. |
320 | + * |
321 | + * Since: 1.2 |
322 | + */ |
323 | +typedef enum { /*< flags >*/ |
324 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE = 0, /*< skip >*/ |
325 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY = (1 << 1), |
326 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT = (1 << 2), |
327 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC = (1 << 3), |
328 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE = (1 << 4), |
329 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST = (1 << 5), |
330 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE = (1 << 6), |
331 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE = (1 << 7), |
332 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP = (1 << 8), |
333 | + _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM, /*< skip >*/ |
334 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM - 1, /*< skip >*/ |
335 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL = ((NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST << 1) - 1) - (1 << 0 /*DEFAULT*/), /*< skip >*/ |
336 | + |
337 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT = (1 << 0), |
338 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE = (1 << 15), |
339 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT | NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE, /*< skip >*/ |
340 | +} NMSettingWirelessWakeOnWLan; |
341 | + |
342 | #define NM_SETTING_WIRELESS_SSID "ssid" |
343 | #define NM_SETTING_WIRELESS_MODE "mode" |
344 | #define NM_SETTING_WIRELESS_BAND "band" |
345 | @@ -56,6 +98,8 @@ G_BEGIN_DECLS |
346 | #define NM_SETTING_WIRELESS_HIDDEN "hidden" |
347 | #define NM_SETTING_WIRELESS_POWERSAVE "powersave" |
348 | #define NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION "mac-address-randomization" |
349 | +#define NM_SETTING_WIRELESS_WAKE_ON_WLAN "wake-on-wlan" |
350 | +#define NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD "wake-on-wlan-password" |
351 | |
352 | /** |
353 | * NM_SETTING_WIRELESS_MODE_ADHOC: |
354 | @@ -160,6 +204,9 @@ gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless |
355 | NM80211ApSecurityFlags ap_rsn, |
356 | NM80211Mode ap_mode); |
357 | |
358 | +NMSettingWirelessWakeOnWLan nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting); |
359 | +const char * nm_setting_wireless_get_wake_on_wlan_password (NMSettingWireless *setting); |
360 | + |
361 | G_END_DECLS |
362 | |
363 | #endif /* __NM_SETTING_WIRELESS_H__ */ |
364 | diff --git a/libnm/libnm.ver b/libnm/libnm.ver |
365 | index 7ece1b2..392cbc8 100644 |
366 | --- a/libnm/libnm.ver |
367 | +++ b/libnm/libnm.ver |
368 | @@ -1020,6 +1020,9 @@ global: |
369 | nm_setting_wireless_get_powersave; |
370 | nm_setting_wireless_get_mac_address_randomization; |
371 | nm_setting_wireless_powersave_get_type; |
372 | + nm_setting_wireless_get_wake_on_wlan; |
373 | + nm_setting_wireless_get_wake_on_wlan_password; |
374 | + nm_setting_wireless_wake_on_wlan_get_type; |
375 | nm_utils_bond_mode_int_to_string; |
376 | nm_utils_bond_mode_string_to_int; |
377 | nm_utils_enum_from_str; |
378 | diff --git a/libnm/nm-setting-docs.xml b/libnm/nm-setting-docs.xml |
379 | index d3ede91..76b07ec 100644 |
380 | --- a/libnm/nm-setting-docs.xml |
381 | +++ b/libnm/nm-setting-docs.xml |
382 | @@ -353,6 +353,8 @@ |
383 | <property name="seen-bssids" type="array of string" default="[]" description="A list of BSSIDs (each BSSID formatted as a MAC address like "00:11:22:33:44:55") that have been detected as part of the Wi-Fi network. NetworkManager internally tracks previously seen BSSIDs. The property is only meant for reading and reflects the BSSID list of NetworkManager. The changes you make to this property will not be preserved." /> |
384 | <property name="ssid" type="byte array" description="SSID of the Wi-Fi network. Must be specified." /> |
385 | <property name="tx-power" type="uint32" default="0" description="If non-zero, directs the device to use the specified transmit power. Units are dBm. This property is highly driver dependent and not all devices support setting a static transmit power." /> |
386 | + <property name="wake-on-wlan" type="uint32" default="1" description="The NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY (0x2), NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT (0x4), NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC (0x8), NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE (0x10), NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST (0x20), NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE (0x40), NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE (0x80), NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP (0x100) or the special values NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE (0x8000) (to disable management of Wake-on-WLAN in NetworkManager)." /> |
387 | + <property name="wake-on-wlan-password" type="string" description="If specified, the password used with magic-packet-based Wake-on-LAN, represented as a MAC address. If NULL, no password will be required." /> |
388 | </setting> |
389 | <setting name="802-11-wireless-security"> |
390 | <property name="auth-alg" type="string" description="When WEP is used (ie, key-mgmt = "none" or "ieee8021x") indicate the 802.11 authentication algorithm required by the AP here. One of "open" for Open System, "shared" for Shared Key, or "leap" for Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = "ieee8021x" and auth-alg = "leap") the "leap-username" and "leap-password" properties must be specified." /> |
391 | diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c |
392 | index 95a89ea..48276fb 100644 |
393 | --- a/src/devices/wifi/nm-device-wifi.c |
394 | +++ b/src/devices/wifi/nm-device-wifi.c |
395 | @@ -2418,6 +2418,45 @@ set_powersave (NMDevice *device) |
396 | powersave == NM_SETTING_WIRELESS_POWERSAVE_ENABLE); |
397 | } |
398 | |
399 | +static gboolean |
400 | +wake_on_wlan_enable (NMDevice *device) |
401 | +{ |
402 | + NMSettingWirelessWakeOnWLan wowl; |
403 | + NMSettingWireless *s_wireless; |
404 | + const char *password = NULL; |
405 | + gs_free char *value = NULL; |
406 | + |
407 | + s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_WIRELESS); |
408 | + if (s_wireless) { |
409 | + wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless); |
410 | + password = nm_setting_wireless_get_wake_on_wlan_password (s_wireless); |
411 | + if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT) |
412 | + goto found; |
413 | + } |
414 | + |
415 | + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, |
416 | + "wireless.wake-on-wlan", |
417 | + device); |
418 | + |
419 | + if (value) { |
420 | + wowl = _nm_utils_ascii_str_to_int64 (value, 10, |
421 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE, |
422 | + G_MAXINT32, |
423 | + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT); |
424 | + |
425 | + if ( NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS) |
426 | + && !nm_utils_is_power_of_two (wowl)) { |
427 | + nm_log_dbg (LOGD_WIFI, "invalid default value %u for wake-on-wlan", (guint) wowl); |
428 | + wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT; |
429 | + } |
430 | + if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT) |
431 | + goto found; |
432 | + } |
433 | + wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE; |
434 | +found: |
435 | + return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), wowl, password); |
436 | +} |
437 | + |
438 | static NMActStageReturn |
439 | act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) |
440 | { |
441 | @@ -2451,6 +2490,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) |
442 | s_wireless = nm_connection_get_setting_wireless (connection); |
443 | g_assert (s_wireless); |
444 | |
445 | + wake_on_wlan_enable (device); |
446 | + |
447 | /* If we need secrets, get them */ |
448 | setting_name = nm_connection_need_secrets (connection, NULL); |
449 | if (setting_name) { |
450 | diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c |
451 | index c504550..bbc3659 100644 |
452 | --- a/src/platform/nm-linux-platform.c |
453 | +++ b/src/platform/nm-linux-platform.c |
454 | @@ -5248,6 +5248,13 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru |
455 | wifi_utils_indicate_addressing_running (wifi_data, running); |
456 | } |
457 | |
458 | +static gboolean |
459 | +wifi_set_wake_on_wlan (NMPlatform *platform, int ifindex, NMSettingWirelessWakeOnWLan wowl, const char *password) |
460 | +{ |
461 | + WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE); |
462 | + return wifi_utils_set_wake_on_wlan (wifi_data, wowl, password); |
463 | +} |
464 | + |
465 | /******************************************************************/ |
466 | |
467 | static gboolean |
468 | @@ -6420,6 +6427,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) |
469 | platform_class->wifi_set_powersave = wifi_set_powersave; |
470 | platform_class->wifi_find_frequency = wifi_find_frequency; |
471 | platform_class->wifi_indicate_addressing_running = wifi_indicate_addressing_running; |
472 | + platform_class->wifi_set_wake_on_wlan = wifi_set_wake_on_wlan; |
473 | |
474 | platform_class->mesh_get_channel = mesh_get_channel; |
475 | platform_class->mesh_set_channel = mesh_set_channel; |
476 | diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c |
477 | index 26ac766..5f0527d 100644 |
478 | --- a/src/platform/nm-platform.c |
479 | +++ b/src/platform/nm-platform.c |
480 | @@ -2381,6 +2381,16 @@ nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gbo |
481 | klass->wifi_indicate_addressing_running (self, ifindex, running); |
482 | } |
483 | |
484 | +gboolean |
485 | +nm_platform_wifi_set_wake_on_wlan (NMPlatform *self, int ifindex, NMSettingWirelessWakeOnWLan wowl, const char *password) |
486 | +{ |
487 | + _CHECK_SELF (self, klass, FALSE); |
488 | + |
489 | + g_return_val_if_fail (ifindex > 0, FALSE); |
490 | + |
491 | + return klass->wifi_set_wake_on_wlan (self, ifindex, wowl, password); |
492 | +} |
493 | + |
494 | guint32 |
495 | nm_platform_mesh_get_channel (NMPlatform *self, int ifindex) |
496 | { |
497 | diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h |
498 | index 658b709..18ad5b2 100644 |
499 | --- a/src/platform/nm-platform.h |
500 | +++ b/src/platform/nm-platform.h |
501 | @@ -32,6 +32,7 @@ |
502 | #include "nm-core-utils.h" |
503 | #include "nm-setting-vlan.h" |
504 | #include "nm-setting-wired.h" |
505 | +#include "nm-setting-wireless.h" |
506 | |
507 | #define NM_TYPE_PLATFORM (nm_platform_get_type ()) |
508 | #define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform)) |
509 | @@ -586,6 +587,7 @@ typedef struct { |
510 | void (*wifi_set_powersave) (NMPlatform *, int ifindex, guint32 powersave); |
511 | guint32 (*wifi_find_frequency) (NMPlatform *, int ifindex, const guint32 *freqs); |
512 | void (*wifi_indicate_addressing_running) (NMPlatform *, int ifindex, gboolean running); |
513 | + gboolean (*wifi_set_wake_on_wlan) (NMPlatform *, int ifindex, NMSettingWirelessWakeOnWLan wowl, const char *password); |
514 | |
515 | guint32 (*mesh_get_channel) (NMPlatform *, int ifindex); |
516 | gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel); |
517 | @@ -836,6 +838,7 @@ void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM |
518 | void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave); |
519 | guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs); |
520 | void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running); |
521 | +gboolean nm_platform_wifi_set_wake_on_wlan (NMPlatform *self, int ifindex, NMSettingWirelessWakeOnWLan wowl, const char *password); |
522 | |
523 | guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex); |
524 | gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel); |
525 | diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c |
526 | index 79f217a..7d546b3 100644 |
527 | --- a/src/platform/wifi/wifi-utils-nl80211.c |
528 | +++ b/src/platform/wifi/wifi-utils-nl80211.c |
529 | @@ -469,6 +469,45 @@ nla_put_failure: |
530 | return FALSE; |
531 | } |
532 | |
533 | +static gboolean |
534 | +wifi_nl80211_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl, const char *password) |
535 | +{ |
536 | + WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data; |
537 | + struct nl_msg *msg; |
538 | + struct nlattr *triggers; |
539 | + int err; |
540 | + |
541 | + msg = nl80211_alloc_msg(nl80211, NL80211_CMD_SET_WOWLAN, 0); |
542 | + if (!msg) |
543 | + return FALSE; |
544 | + |
545 | + triggers = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS); |
546 | + |
547 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY)) |
548 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_ANY); |
549 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT)) |
550 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_DISCONNECT); |
551 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC)) |
552 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_MAGIC_PKT); |
553 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE)) |
554 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE); |
555 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST)) |
556 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST); |
557 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE)) |
558 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE); |
559 | + if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE)) |
560 | + NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE); |
561 | + |
562 | + nla_nest_end(msg, triggers); |
563 | + |
564 | + err = nl80211_send_and_recv (nl80211, msg, NULL, NULL); |
565 | + return err ? FALSE : TRUE; |
566 | + |
567 | +nla_put_failure: |
568 | + nlmsg_free (msg); |
569 | + return FALSE; |
570 | +} |
571 | + |
572 | /* @divisor: pass what value @xbm should be divided by to get dBm */ |
573 | static guint32 |
574 | nl80211_xbm_to_percent (gint32 xbm, guint32 divisor) |
575 | @@ -1040,6 +1079,7 @@ wifi_nl80211_init (const char *iface, int ifindex) |
576 | nl80211->parent.get_mode = wifi_nl80211_get_mode; |
577 | nl80211->parent.set_mode = wifi_nl80211_set_mode; |
578 | nl80211->parent.set_powersave = wifi_nl80211_set_powersave; |
579 | + nl80211->parent.set_wake_on_wlan = wifi_nl80211_set_wake_on_wlan; |
580 | nl80211->parent.get_freq = wifi_nl80211_get_freq; |
581 | nl80211->parent.find_freq = wifi_nl80211_find_freq; |
582 | nl80211->parent.get_bssid = wifi_nl80211_get_bssid; |
583 | diff --git a/src/platform/wifi/wifi-utils-private.h b/src/platform/wifi/wifi-utils-private.h |
584 | index 21a4c57..c3e48ef 100644 |
585 | --- a/src/platform/wifi/wifi-utils-private.h |
586 | +++ b/src/platform/wifi/wifi-utils-private.h |
587 | @@ -38,6 +38,9 @@ struct WifiData { |
588 | /* Set power saving mode on an interface */ |
589 | gboolean (*set_powersave) (WifiData *data, guint32 powersave); |
590 | |
591 | + /* Set WakeOnWLAN mode on an interface */ |
592 | + gboolean (*set_wake_on_wlan) (WifiData *data, NMSettingWirelessWakeOnWLan wowl, const char *password); |
593 | + |
594 | /* Return current frequency in MHz (really associated BSS frequency) */ |
595 | guint32 (*get_freq) (WifiData *data); |
596 | |
597 | diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c |
598 | index 38e5a05..d72865b 100644 |
599 | --- a/src/platform/wifi/wifi-utils.c |
600 | +++ b/src/platform/wifi/wifi-utils.c |
601 | @@ -105,6 +105,14 @@ wifi_utils_set_powersave (WifiData *data, guint32 powersave) |
602 | return data->set_powersave ? data->set_powersave (data, powersave) : TRUE; |
603 | } |
604 | |
605 | +gboolean |
606 | +wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl, const char *password) |
607 | +{ |
608 | + g_return_val_if_fail (data != NULL, FALSE); |
609 | + |
610 | + return data->set_wake_on_wlan ? data->set_wake_on_wlan (data, wowl, password) : TRUE; |
611 | +} |
612 | + |
613 | guint32 |
614 | wifi_utils_get_freq (WifiData *data) |
615 | { |
616 | diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h |
617 | index 21dac9e..87ab2f2 100644 |
618 | --- a/src/platform/wifi/wifi-utils.h |
619 | +++ b/src/platform/wifi/wifi-utils.h |
620 | @@ -26,6 +26,7 @@ |
621 | |
622 | #include "nm-default.h" |
623 | #include "nm-dbus-interface.h" |
624 | +#include "nm-setting-wireless.h" |
625 | |
626 | typedef struct WifiData WifiData; |
627 | |
628 | @@ -65,6 +66,7 @@ gboolean wifi_utils_get_wowlan (WifiData *data); |
629 | |
630 | gboolean wifi_utils_set_powersave (WifiData *data, guint32 powersave); |
631 | |
632 | +gboolean wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl, const char *password); |
633 | |
634 | /* OLPC Mesh-only functions */ |
635 | guint32 wifi_utils_get_mesh_channel (WifiData *data); |
FAILED: Continuous integration, rev:1b01b90d1d7 d430728c12d1b75 4c7eb7c650520d /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 662/ /jenkins. canonical. com/system- enablement/ job/generic- run-snap- spread- tests/380/ console /jenkins. canonical. com/system- enablement/ job/generic- update- snap-mp/ 570/console
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 662/rebuild
https:/