summary refs log tree commit diff
path: root/libnm-util/nm-setting-wireless.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-02-03 14:49:22 +0100
committerMichael Biebl <biebl@debian.org>2013-02-03 14:49:22 +0100
commit9c202e3e860b3be9e1f8882630b69affbb130102 (patch)
tree8202bf39f2129486971fa7d5ae0dee61a561aa53 /libnm-util/nm-setting-wireless.c
parent36cb2f364a821e1be50b23e03a18891ec55adb06 (diff)
Imported Upstream version 0.9.7.995 upstream/0.9.7.995
Diffstat (limited to 'libnm-util/nm-setting-wireless.c')
-rw-r--r--libnm-util/nm-setting-wireless.c68
1 files changed, 43 insertions, 25 deletions
diff --git a/libnm-util/nm-setting-wireless.c b/libnm-util/nm-setting-wireless.c
index f9ed3108..ace22cbc 100644
--- a/libnm-util/nm-setting-wireless.c
+++ b/libnm-util/nm-setting-wireless.c
@@ -34,6 +34,7 @@
 #include "nm-utils.h"
 #include "nm-dbus-glib-types.h"
 #include "nm-utils-private.h"
+#include "nm-setting-private.h"
 
 /**
  * SECTION:nm-setting-wireless
@@ -62,7 +63,12 @@ nm_setting_wireless_error_quark (void)
 }
 
 
-G_DEFINE_TYPE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING)
+G_DEFINE_TYPE_WITH_CODE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING,
+                         _nm_register_setting (NM_SETTING_WIRELESS_SETTING_NAME,
+                                               g_define_type_id,
+                                               1,
+                                               NM_SETTING_WIRELESS_ERROR))
+NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS)
 
 #define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
 
@@ -187,14 +193,21 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
 	if (!strcmp (key_mgmt, "wpa-none")) {
 		if (ap_mode != NM_802_11_MODE_ADHOC)
 			return FALSE;
-		// FIXME: validate ciphers if the BSSID actually puts WPA/RSN IE in
-		// it's beacon
+		/* FIXME: validate ciphers if they're in the beacon */
 		return TRUE;
 	}
 
-	/* Stuff after this point requires infrastructure */
-	if (ap_mode != NM_802_11_MODE_INFRA)
-		return FALSE;
+	/* Adhoc WPA2 (ie, RSN IBSS) */
+	if (ap_mode == NM_802_11_MODE_ADHOC) {
+		if (strcmp (key_mgmt, "wpa-psk"))
+			return FALSE;
+
+		/* Ensure the AP has RSN PSK capability */
+		if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_PSK))
+			return FALSE;
+
+		/* Fall through and check ciphers in generic WPA-PSK code */
+	}
 
 	/* Dynamic WEP or LEAP */
 	if (!strcmp (key_mgmt, "ieee8021x")) {
@@ -502,15 +515,16 @@ nm_setting_wireless_get_hidden (NMSettingWireless *setting)
  * @setting: the #NMSettingWireless
  * @bssid: the new BSSID to add to the list
  *
- * Adds a new WiFi AP's BSSID to the previously seen BSSID list of the setting.
- * NetworkManager tracks previously seen BSSIDs internally so this function
- * no longer has much use.
+ * Adds a new Wi-Fi AP's BSSID to the previously seen BSSID list of the setting.
+ * NetworkManager now tracks previously seen BSSIDs internally so this function
+ * no longer has much use. Actually, changes you make using this function will
+ * not be preserved.
  *
  * Returns: %TRUE if @bssid was already known, %FALSE if not
  **/
 gboolean
 nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
-									const char *bssid)
+                                    const char *bssid)
 {
 	NMSettingWirelessPrivate *priv;
 	char *lower_bssid;
@@ -584,7 +598,7 @@ static gboolean
 verify (NMSetting *setting, GSList *all_settings, GError **error)
 {
 	NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
-	const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NULL };
+	const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL };
 	const char *valid_bands[] = { "a", "bg", NULL };
 	GSList *iter;
 
@@ -881,15 +895,15 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
 	/**
 	 * NMSettingWireless:mode:
 	 *
-	 * WiFi network mode; one of 'infrastructure' or 'adhoc'.  If blank,
+	 * WiFi network mode; one of 'infrastructure', 'adhoc' or 'ap'.  If blank,
 	 * infrastructure is assumed.
 	 **/
 	g_object_class_install_property
 		(object_class, PROP_MODE,
 		 g_param_spec_string (NM_SETTING_WIRELESS_MODE,
 						  "Mode",
-						  "WiFi network mode; one of 'infrastructure' or "
-						  "'adhoc'.  If blank, infrastructure is assumed.",
+						  "WiFi network mode; one of 'infrastructure', "
+						  "'adhoc' or 'ap'.  If blank, infrastructure is assumed.",
 						  NULL,
 						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
 
@@ -1054,21 +1068,25 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
 	 * NMSettingWireless:seen-bssids:
 	 *
 	 * 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 WiFI network.
-	 * NetworkManager internally tracks previously seen BSSIDs so this property
-	 * is no longer of much use.
+	 * '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 BBSID list of NetworkManager. The changes you
+	 * make to this property will not be preserved.
 	 **/
 	g_object_class_install_property
 		(object_class, PROP_SEEN_BSSIDS,
 		 _nm_param_spec_specialized (NM_SETTING_WIRELESS_SEEN_BSSIDS,
-							   "Seen BSSIDS",
-							   "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 WiFI network. "
-							   "NetworkManager internally tracks previously seen "
-							   "BSSIDs so this property is no longer of much use.",
-							   DBUS_TYPE_G_LIST_OF_STRING,
-							   G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
+		                             "Seen BSSIDS",
+		                             "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 WiFI network. "
+		                             "NetworkManager internally tracks previously seen "
+		                             "BSSIDs. The property is only meant for reading "
+		                             "and reflects the BBSID list of NetworkManager. "
+		                             "The changes you make to this property will not be "
+		                             "preserved.",
+		                             DBUS_TYPE_G_LIST_OF_STRING,
+		                             G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE));
 
 	/**
 	 * NMSettingWireless:mtu: