On Wed, 2017-01-18 at 17:32 +0100, Simon Fels wrote:
--- libnm-core/nm-setting-wireless.c | 85 ++++++++++++++++++++++++++++++++++++++++ libnm-core/nm-setting-wireless.h | 47 ++++++++++++++++++++++ libnm/libnm.ver | 3 ++ man/NetworkManager.conf.xml | 4 ++ 4 files changed, 139 insertions(+) diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm- setting-wireless.c index 1d129f6..a2ed849 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -63,6 +63,8 @@ typedef struct { gboolean hidden; guint32 powersave; NMSettingMacRandomization mac_address_randomization; + guint32 wowl; + char *wowl_password; } NMSettingWirelessPrivate; enum { @@ -83,6 +85,8 @@ enum { PROP_HIDDEN, PROP_POWERSAVE, PROP_MAC_ADDRESS_RANDOMIZATION, + PROP_WAKE_ON_WLAN, + PROP_WAKE_ON_WLAN_PASSWORD, LAST_PROP }; @@ -939,6 +943,43 @@ nm_setting_wireless_get_security (NMSetting *setting, return NULL; } +/** + * nm_setting_wireless_get_wake_on_wlan: + * @setting: the #NMSettingWireless + * + * Returns the Wake-on-WLAN options enabled for the connection + * + * Returns: the Wake-on-WLAN options + * + * Since: 1.6 + */ +NMSettingWirelessWakeOnWLan +nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE); + + return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->wowl; +} + +/** + * nm_setting_wired_get_wake_on_lan_password: + * @setting: the #NMSettingWireless + * + * Returns the Wake-on-WLAN password. This only applies to + * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC. + * + * Returns: the Wake-on-WLAN setting password, or %NULL if there is no password. + * + * Since: 1.6 + */ +const char * +nm_setting_wireless_get_wake_on_wlan_password (NMSettingWireless *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL); + + return NM_SETTING_WIRELESS_GET_PRIVATE (setting)-wowl_password;+} + static void clear_blacklist_item (char **item_p) { @@ -1051,6 +1092,13 @@ set_property (GObject *object, guint prop_id, case PROP_MAC_ADDRESS_RANDOMIZATION: priv->mac_address_randomization = g_value_get_uint (value); break; + case PROP_WAKE_ON_WLAN: + priv->wowl = g_value_get_uint (value); + break; + case PROP_WAKE_ON_WLAN_PASSWORD: + g_free (priv->wowl_password); + priv->wowl_password = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1113,6 +1161,12 @@ get_property (GObject *object, guint prop_id, case PROP_MAC_ADDRESS_RANDOMIZATION: g_value_set_uint (value, nm_setting_wireless_get_mac_address_randomization (setting)); break; + case PROP_WAKE_ON_WLAN: + g_value_set_uint (value, nm_setting_wireless_get_wake_on_wlan (setting)); + break; + case PROP_WAKE_ON_WLAN_PASSWORD: + g_value_set_string (value, nm_setting_wireless_get_wake_on_wlan_password (setting)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1623,4 +1677,35 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_wireless_class) _nm_setting_class_add_dbus_only_property (setting_class, "security", G_VARIANT_TYPE_STR ING, nm_setting_wireles s_get_security, NULL); + + /** + * NMSettingWireless:wake-on-wlan: + * + * The #NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options. + * + * Since: 1.2 + **/ + g_object_class_install_property + (object_class, PROP_WAKE_ON_WLAN, + g_param_spec_uint (NM_SETTING_WIRELESS_WAKE_ON_WLAN, "", "", + 0, G_MAXUINT32, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** + * NMSettingWireless:wake-on-wlan-password: + * + * If specified, the password used with magic-packet-based + * Wake-on-LAN, represented as a MAC address. If %NULL, + * no password will be required. + * + * Since: 1.2
should be Since: 1.8
+ **/ + g_object_class_install_property + (object_class, PROP_WAKE_ON_WLAN_PASSWORD, + g_param_spec_string (NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm- setting-wireless.h index 35fa79c..adbfe48 100644 --- a/libnm-core/nm-setting-wireless.h +++ b/libnm-core/nm-setting-wireless.h @@ -41,6 +41,48 @@ G_BEGIN_DECLS #define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless" +/** + * NMSettingWirelessWakeOnWLan: + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE: Wake-on-WLAN disabled + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY: Wake on any activity + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT: Wake on disconnect + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC: Wake on magic packet + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE: Wake on GTK rekey failure + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST: Wake on EAP identity request + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE: Wake on 4way hanshake + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE: Wake on rfkill release + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL: Wake on all events. This does not + * include the exclusive flags @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT or + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE. + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT: Use the default value + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE: Don't change configured settings + * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS: Mask of flags that are + * incompatible with other flags + * + * Options for #NMSettingWireless:wake-on-wlan. Note that not all options + * are supported by all devices. + * + * Since: 1.2 + */ +typedef enum { /*< flags >*/ + NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE = 0, /*< skip >*/ + NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY = (1 << 1), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT = (1 << 2), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC = (1 << 3), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE = (1 << 4), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST = (1 << 5), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE = (1 << 6), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE = (1 << 7), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP = (1 << 8), + _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM, /*< skip >*/ + NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM - 1, /*< skip >*/ + NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL = ((NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST << 1) - 1) - (1 << 0 /*DEFAULT*/), /*< skip >*/ + + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT = (1 << 0), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE = (1 << 15), + NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT | NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE, /*< skip >*/ +} NMSettingWirelessWakeOnWLan; + #define NM_SETTING_WIRELESS_SSID "ssid" #define NM_SETTING_WIRELESS_MODE "mode" #define NM_SETTING_WIRELESS_BAND "band" @@ -57,6 +99,8 @@ G_BEGIN_DECLS #define NM_SETTING_WIRELESS_HIDDEN "hidden" #define NM_SETTING_WIRELESS_POWERSAVE "powersave" #define NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION "mac- address-randomization" +#define NM_SETTING_WIRELESS_WAKE_ON_WLAN "wake-on-wlan" +#define NM_SETTING_WIRELESS_WAKE_ON_WLAN_PASSWORD "wake-on-wlan- password" /** * NM_SETTING_WIRELESS_MODE_ADHOC: @@ -164,6 +208,9 @@ gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless NM8021 1ApSecurityFlags ap_rsn, NM8021 1Mode ap_mode); +NMSettingWirelessWakeOnWLan nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting); +const char * nm_setting_wireless_get_wake_on_wlan_password (NMSettingWireless *setting);
needs NM_AVAILABLE_IN_1_8
+ G_END_DECLS #endif /* __NM_SETTING_WIRELESS_H__ */ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index d0562e2..1e603bf 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1139,6 +1139,9 @@ global: nm_setting_802_1x_get_phase2_client_cert_uri; nm_setting_802_1x_get_private_key_uri; nm_setting_802_1x_get_phase2_private_key_uri; + nm_setting_wireless_get_wake_on_wlan; + nm_setting_wireless_get_wake_on_wlan_password; + nm_setting_wireless_wake_on_wlan_get_type;
"nm-1-6" just branched off from "master". So, no new API can be added to libnm_1_6_0. The symbols need to be added to a new "libnm_1_8_0" section. Do you wish for upstream to backport this API? How far? As said, backporting API is a pain.
nm_utils_is_json_object; nm_utils_version; nm_utils_is_valid_iface_name; diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml index 8c93ac4..1906278 100644 --- a/man/NetworkManager.conf.xml +++ b/man/NetworkManager.conf.xml @@ -671,6 +671,10 @@ ipv6.ip6-privacy=0 <listitem><para>If left unspecified, the default value "<literal>ignore</literal>" will be used.</para></listitem> </varlistentry> + <varlistentry> + <term><varname>wifi.wake-on-wlan</varname></term> + <listitem><para>If left unspecified, the global default value will be used </para></listitem>
let's drop the extra description. Some entries have additional description if the global default is more complex and warrants explanation.
+ </varlistentry> </variablelist> </para> </refsect2>
Thomas
Attachment:
signature.asc
Description: This is a digitally signed message part