[PATCH 1/4] libnm-core: add wake-on-wlan configuration items



---
 libnm-core/nm-core-enum-types.c  | 27 +++++++++++++
 libnm-core/nm-core-enum-types.h  |  2 +
 libnm-core/nm-setting-wireless.c | 85 ++++++++++++++++++++++++++++++++++++++++
 libnm-core/nm-setting-wireless.h | 47 ++++++++++++++++++++++
 libnm/libnm.ver                  |  3 ++
 libnm/nm-setting-docs.xml        |  2 +
 6 files changed, 166 insertions(+)

diff --git a/libnm-core/nm-core-enum-types.c b/libnm-core/nm-core-enum-types.c
index 83f5e88..58581bb 100644
--- a/libnm-core/nm-core-enum-types.c
+++ b/libnm-core/nm-core-enum-types.c
@@ -1053,6 +1053,33 @@ nm_wep_key_type_get_type (void)
   return g_define_type_id__volatile;
 }
 GType
+nm_setting_wireless_wake_on_wlan_get_type (void)
+{
+  static volatile gsize g_define_type_id__volatile = 0;
+
+  if (g_once_init_enter (&g_define_type_id__volatile))
+    {
+      static const GFlagsValue values[] = {
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY", "any" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT", 
"disconnect" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC", "magic" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE, 
"NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE", "gtk-rekey-failure" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST, 
"NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST", "eap-identity-request" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE, 
"NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE", "4way-handshake" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE, 
"NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE", "rfkill-release" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP", "tcp" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT", "default" },
+        { NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE, "NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE", "ignore" },
+        { 0, NULL, NULL }
+      };
+      GType g_define_type_id =
+        g_flags_register_static (g_intern_static_string ("NMSettingWirelessWakeOnWLan"), values);
+      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+    }
+
+  return g_define_type_id__volatile;
+}
+GType
 nm_setting_wireless_powersave_get_type (void)
 {
   static volatile gsize g_define_type_id__volatile = 0;
diff --git a/libnm-core/nm-core-enum-types.h b/libnm-core/nm-core-enum-types.h
index d316b5e..0958c26 100644
--- a/libnm-core/nm-core-enum-types.h
+++ b/libnm-core/nm-core-enum-types.h
@@ -91,6 +91,8 @@ GType nm_setting_wired_wake_on_lan_get_type (void) G_GNUC_CONST;
 #define NM_TYPE_SETTING_WIRED_WAKE_ON_LAN (nm_setting_wired_wake_on_lan_get_type ())
 GType nm_wep_key_type_get_type (void) G_GNUC_CONST;
 #define NM_TYPE_WEP_KEY_TYPE (nm_wep_key_type_get_type ())
+GType nm_setting_wireless_wake_on_wlan_get_type (void) G_GNUC_CONST;
+#define NM_TYPE_SETTING_WIRELESS_WAKE_ON_WLAN (nm_setting_wireless_wake_on_wlan_get_type ())
 GType nm_setting_wireless_powersave_get_type (void) G_GNUC_CONST;
 #define NM_TYPE_SETTING_WIRELESS_POWERSAVE (nm_setting_wireless_powersave_get_type ())
 GType nm_setting_secret_flags_get_type (void) G_GNUC_CONST;
diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c
index ee4ac6f..95c6466 100644
--- a/libnm-core/nm-setting-wireless.c
+++ b/libnm-core/nm-setting-wireless.c
@@ -60,6 +60,8 @@ typedef struct {
        gboolean hidden;
        guint32 powersave;
        NMSettingMacRandomization mac_address_randomization;
+       guint32 wowl;
+       char *wowl_password;
 } NMSettingWirelessPrivate;
 
 enum {
@@ -79,6 +81,8 @@ enum {
        PROP_HIDDEN,
        PROP_POWERSAVE,
        PROP_MAC_ADDRESS_RANDOMIZATION,
+       PROP_WAKE_ON_WLAN,
+       PROP_WAKE_ON_WLAN_PASSWORD,
 
        LAST_PROP
 };
@@ -850,6 +854,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.2
+ */
+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.2
+ */
+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)
 {
@@ -957,6 +998,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;
@@ -1016,6 +1064,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;
@@ -1431,4 +1485,35 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
        _nm_setting_class_add_dbus_only_property (parent_class, "security",
                                                  G_VARIANT_TYPE_STRING,
                                                  nm_setting_wireless_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
+        **/
+       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 574cee5..f81b391 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"
@@ -56,6 +98,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:
@@ -160,6 +204,9 @@ gboolean          nm_setting_wireless_ap_security_compatible (NMSettingWireless
                                                               NM80211ApSecurityFlags ap_rsn,
                                                               NM80211Mode ap_mode);
 
+NMSettingWirelessWakeOnWLan  nm_setting_wireless_get_wake_on_wlan          (NMSettingWireless *setting);
+const char *                 nm_setting_wireless_get_wake_on_wlan_password (NMSettingWireless *setting);
+
 G_END_DECLS
 
 #endif /* __NM_SETTING_WIRELESS_H__ */
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 7ece1b2..392cbc8 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1020,6 +1020,9 @@ global:
        nm_setting_wireless_get_powersave;
        nm_setting_wireless_get_mac_address_randomization;
        nm_setting_wireless_powersave_get_type;
+       nm_setting_wireless_get_wake_on_wlan;
+       nm_setting_wireless_get_wake_on_wlan_password;
+       nm_setting_wireless_wake_on_wlan_get_type;
        nm_utils_bond_mode_int_to_string;
        nm_utils_bond_mode_string_to_int;
        nm_utils_enum_from_str;
diff --git a/libnm/nm-setting-docs.xml b/libnm/nm-setting-docs.xml
index d3ede91..76b07ec 100644
--- a/libnm/nm-setting-docs.xml
+++ b/libnm/nm-setting-docs.xml
@@ -353,6 +353,8 @@
     <property name="seen-bssids" type="array of string" default="[]" description="A list of BSSIDs (each 
BSSID formatted as a MAC address like &quot;00:11:22:33:44:55&quot;) 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." />
     <property name="ssid" type="byte array" description="SSID of the Wi-Fi network. Must be specified." />
     <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." />
+    <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)." 
/>
+    <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." />
   </setting>
   <setting name="802-11-wireless-security">
     <property name="auth-alg" type="string" description="When WEP is used (ie, key-mgmt = &quot;none&quot; 
or &quot;ieee8021x&quot;) indicate the 802.11 authentication algorithm required by the AP here.  One of 
&quot;open&quot; for Open System, &quot;shared&quot; for Shared Key, or &quot;leap&quot; for Cisco LEAP.  
When using Cisco LEAP (ie, key-mgmt = &quot;ieee8021x&quot; and auth-alg = &quot;leap&quot;) the 
&quot;leap-username&quot; and &quot;leap-password&quot; properties must be specified." />
-- 
2.7.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]