summary refs log tree commit diff
path: root/src/nm-wifi-ap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-wifi-ap.c')
-rw-r--r--src/nm-wifi-ap.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/nm-wifi-ap.c b/src/nm-wifi-ap.c
index be836df0..92a99b69 100644
--- a/src/nm-wifi-ap.c
+++ b/src/nm-wifi-ap.c
@@ -19,10 +19,9 @@
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
-#include "wireless-helper.h"
-
 #include <string.h>
 #include <stdlib.h>
+#include <netinet/ether.h>
 
 #include "nm-wifi-ap.h"
 #include "nm-wifi-ap-utils.h"
@@ -30,7 +29,7 @@
 #include "nm-utils.h"
 #include "nm-logging.h"
 #include "nm-dbus-manager.h"
-#include "wpa.h"
+
 #include "nm-properties-changed-signal.h"
 #include "nm-setting-wireless.h"
 #include "nm-glib-compat.h"
@@ -43,6 +42,7 @@
 typedef struct
 {
 	char *dbus_path;
+	char *supplicant_path;   /* D-Bus object path of this AP from wpa_supplicant */
 
 	/* Scanned or cached values */
 	GByteArray *	ssid;
@@ -107,6 +107,7 @@ finalize (GObject *object)
 	NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
 
 	g_free (priv->dbus_path);
+	g_free (priv->supplicant_path);
 	if (priv->ssid)
 		g_byte_array_free (priv->ssid, TRUE);
 
@@ -183,7 +184,7 @@ get_property (GObject *object, guint prop_id,
 		g_value_set_uint (value, priv->freq);
 		break;
 	case PROP_HW_ADDRESS:
-		g_value_take_string (value, nm_ether_ntop (&priv->address));
+		g_value_take_string (value, nm_utils_hwaddr_ntoa (&priv->address, ARPHRD_ETHER));
 		break;
 	case PROP_MODE:
 		g_value_set_uint (value, priv->mode);
@@ -346,15 +347,10 @@ nm_ap_export_to_dbus (NMAccessPoint *ap)
  * Create a new, blank user access point info structure
  *
  */
-NMAccessPoint *nm_ap_new (void)
+static NMAccessPoint *
+nm_ap_new (void)
 {
-	GObject *object;
-
-	object = g_object_new (NM_TYPE_AP, NULL);
-	if (!object)
-		return NULL;
-
-	return (NMAccessPoint *) object;
+	return (NMAccessPoint *) g_object_new (NM_TYPE_AP, NULL);
 }
 
 static NM80211ApSecurityFlags
@@ -431,7 +427,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
 		GArray *array = g_value_get_boxed (variant);
 
 		if (!strcmp (key, "SSID")) {
-			guint32 len = MIN (IW_ESSID_MAX_SIZE, array->len);
+			guint32 len = MIN (32, array->len);
 			GByteArray *ssid;
 
 			/* Stupid ieee80211 layer uses <hidden> */
@@ -510,7 +506,7 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
 }
 
 NMAccessPoint *
-nm_ap_new_from_properties (GHashTable *properties)
+nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
 {
 	NMAccessPoint *ap;
 	GTimeVal cur_time;
@@ -525,6 +521,8 @@ nm_ap_new_from_properties (GHashTable *properties)
 	g_object_freeze_notify (G_OBJECT (ap));
 	g_hash_table_foreach (properties, foreach_property_cb, ap);
 
+	nm_ap_set_supplicant_path (ap, supplicant_path);
+
 	/* ignore APs with invalid BSSIDs */
 	addr = nm_ap_get_address (ap);
 	if (   !(memcmp (addr->ether_addr_octet, bad_bssid1, ETH_ALEN))
@@ -635,7 +633,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
 
 	g_return_val_if_fail (connection != NULL, NULL);
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	g_return_val_if_fail (s_wireless != NULL, NULL);
 
 	ssid = nm_setting_wireless_get_ssid (s_wireless);
@@ -672,7 +670,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
 		nm_ap_set_freq (ap, freq);
 	}
 
-	s_wireless_sec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 	/* Assume presence of a security setting means the AP is encrypted */
 	if (!s_wireless_sec)
 		goto done;
@@ -784,6 +782,24 @@ nm_ap_get_dbus_path (NMAccessPoint *ap)
 	return NM_AP_GET_PRIVATE (ap)->dbus_path;
 }
 
+const char *
+nm_ap_get_supplicant_path (NMAccessPoint *ap)
+{
+	g_return_val_if_fail (NM_IS_AP (ap), NULL);
+
+	return NM_AP_GET_PRIVATE (ap)->supplicant_path;
+}
+
+void
+nm_ap_set_supplicant_path (NMAccessPoint *ap, const char *path)
+{
+	g_return_if_fail (NM_IS_AP (ap));
+	g_return_if_fail (path != NULL);
+
+	g_free (NM_AP_GET_PRIVATE (ap)->supplicant_path);
+	NM_AP_GET_PRIVATE (ap)->supplicant_path = g_strdup (path);
+}
+
 /*
  * Get/set functions for ssid
  *
@@ -1130,7 +1146,7 @@ nm_ap_check_compatible (NMAccessPoint *self,
 
 	priv = NM_AP_GET_PRIVATE (self);
 
-	s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
+	s_wireless = nm_connection_get_setting_wireless (connection);
 	if (s_wireless == NULL)
 		return FALSE;
 	
@@ -1168,8 +1184,7 @@ nm_ap_check_compatible (NMAccessPoint *self,
 			return FALSE;
 	}
 
-	s_wireless_sec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection,
-	                                                                          NM_TYPE_SETTING_WIRELESS_SECURITY);
+	s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
 
 	return nm_setting_wireless_ap_security_compatible (s_wireless,
 	                                                   s_wireless_sec,