NetworkManager r3277 - in branches/NETWORKMANAGER_0_6_0_RELEASE: . include src



Author: tambeti
Date: Wed Jan 30 20:26:46 2008
New Revision: 3277
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3277&view=rev

Log:
2008-01-30  Tambet Ingo  <tambet ximian com>

	Implement 802.1x wired authentication.



Added:
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.h
Modified:
   branches/NETWORKMANAGER_0_6_0_RELEASE/ChangeLog
   branches/NETWORKMANAGER_0_6_0_RELEASE/include/NetworkManager.h
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/Makefile.am
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.h
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerPolicy.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerSystem.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.h
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-leap.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wep.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-eap.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-psk.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.h
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-device.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nm.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.h
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-11-wireless.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-3-ethernet.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device.c
   branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-supplicant.c

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/include/NetworkManager.h
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/include/NetworkManager.h	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/include/NetworkManager.h	Wed Jan 30 20:26:46 2008
@@ -173,7 +173,8 @@
 	NETWORK_TYPE_UNKNOWN = 0,
 	NETWORK_TYPE_ALLOWED,
 	NETWORK_TYPE_INVALID,
-	NETWORK_TYPE_DEVICE
+	NETWORK_TYPE_DEVICE,
+	NETWORK_TYPE_WIRED
 } NMNetworkType;
 
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/Makefile.am
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/Makefile.am	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/Makefile.am	Wed Jan 30 20:26:46 2008
@@ -66,6 +66,8 @@
 		nm-ap-security-leap.h   		\
 		nm-supplicant.h				\
 		nm-supplicant.c				\
+		nm-wired-network.c			\
+		nm-wired-network.h			\
 		nm-marshal-main.c			\
 		kernel-types.h				\
 		wpa.c					\

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.c	Wed Jan 30 20:26:46 2008
@@ -174,7 +174,7 @@
 {
 	NMData *			data;
 	NMDevice *		dev;
-	NMAccessPoint *	ap;
+	char *essid;
 	DeviceStatus	 	status;
 } NMStatusChangeData;
 
@@ -232,11 +232,9 @@
 	}
 
 	/* If the device was wireless, attach the name of the wireless network that failed to activate */
-	if (cb_data->ap)
+	if (cb_data->essid)
 	{
-		const char *essid = nm_ap_get_essid (cb_data->ap);
-		if (essid)
-			dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &essid, DBUS_TYPE_INVALID);
+		dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &cb_data->essid, DBUS_TYPE_INVALID);
 	}
 	else
 		dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID);
@@ -248,8 +246,7 @@
 	if (message)
 		dbus_message_unref (message);
 
-	if (cb_data->ap)
-		nm_ap_unref (cb_data->ap);
+	g_free (cb_data->essid);
 
 	g_free (dev_path);
 	g_object_unref (G_OBJECT (cb_data->dev));
@@ -259,7 +256,7 @@
 }
 
 
-void nm_dbus_schedule_device_status_change_signal (NMData *data, NMDevice *dev, NMAccessPoint *ap, DeviceStatus status)
+void nm_dbus_schedule_device_status_change_signal (NMData *data, NMDevice *dev, const char *essid, DeviceStatus status)
 {
 	NMStatusChangeData	*cb_data = NULL;
 	GSource			*source;
@@ -271,11 +268,9 @@
 	g_object_ref (G_OBJECT (dev));
 	cb_data->data = data;
 	cb_data->dev = dev;
-	if (ap)
-	{
-		nm_ap_ref (ap);
-		cb_data->ap = ap;
-	}
+	if (essid)
+		cb_data->essid = g_strdup (essid);
+
 	cb_data->status = status;
 
 	source = g_idle_source_new ();

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.h
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.h	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerDbus.h	Wed Jan 30 20:26:46 2008
@@ -62,7 +62,7 @@
 char *		nm_dbus_get_object_path_for_device		(NMDevice *dev);
 char *		nm_dbus_get_object_path_for_network	(NMDevice *dev, NMAccessPoint *ap);
 
-void			nm_dbus_schedule_device_status_change_signal	(NMData *data, NMDevice *dev, NMAccessPoint *ap, DeviceStatus status);
+void			nm_dbus_schedule_device_status_change_signal	(NMData *data, NMDevice *dev, const char *essid, DeviceStatus status);
 
 void			nm_dbus_signal_state_change			(DBusConnection *connection, NMData *data);
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerPolicy.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerPolicy.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerPolicy.c	Wed Jan 30 20:26:46 2008
@@ -51,8 +51,8 @@
 {
 	NMDevice			*dev = NULL;
 	NMData			*data = NULL;
-	NMAccessPoint *	ap = NULL;
 	NMActRequest * dev_req;
+	const char *network_id = NULL;
 
 	g_return_val_if_fail (req != NULL, FALSE);
 
@@ -69,14 +69,19 @@
 	if (!dev_req || (dev_req != req))
 		return FALSE;
 
-    if (nm_device_is_802_11_wireless (dev))
-        ap = nm_act_request_get_ap (req);
+    if (NM_IS_DEVICE_802_11_WIRELESS (dev))
+		network_id = nm_ap_get_essid (nm_act_request_get_ap (req));
+	else if (NM_IS_DEVICE_802_3_ETHERNET (dev)) {
+		NMWiredNetwork *wired_net = nm_act_request_get_wired_network (req);
+		if (wired_net)
+			network_id = nm_wired_network_get_network_id (wired_net);
+	}
 
 	nm_device_activation_success_handler (dev, req);
 
 	nm_act_request_unref (req);
 	nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (dev));
-	nm_dbus_schedule_device_status_change_signal (data, dev, ap, DEVICE_NOW_ACTIVE);
+	nm_dbus_schedule_device_status_change_signal (data, dev, network_id, DEVICE_NOW_ACTIVE);
 	nm_schedule_state_change_signal_broadcast (data);
 
 	return FALSE;
@@ -123,7 +128,7 @@
 {
 	NMDevice *	dev = NULL;
 	NMData *		data = NULL;
-	NMAccessPoint *ap = NULL;
+	const char *network_id = NULL;
 
 	g_return_val_if_fail (req != NULL, FALSE);
 
@@ -135,11 +140,16 @@
 
 	nm_device_activation_failure_handler (dev, req);
 
-    if (nm_device_is_802_11_wireless (dev))
-        ap = nm_act_request_get_ap (req);
+	if (NM_IS_DEVICE_802_11_WIRELESS (dev))
+		network_id = nm_ap_get_essid (nm_act_request_get_ap (req));
+	else if (NM_IS_DEVICE_802_3_ETHERNET (dev)) {
+		NMWiredNetwork *wired_net = nm_act_request_get_wired_network (req);
+		if (wired_net)
+			network_id = nm_wired_network_get_network_id (wired_net);
+	}
 
 	nm_info ("Activation (%s) failed.", nm_device_get_iface (dev));
-	nm_dbus_schedule_device_status_change_signal	(data, dev, ap, DEVICE_ACTIVATION_FAILED);
+	nm_dbus_schedule_device_status_change_signal (data, dev, network_id, DEVICE_ACTIVATION_FAILED);
 
 	nm_device_deactivate (dev);
 	nm_schedule_state_change_signal_broadcast (data);
@@ -455,12 +465,18 @@
 
 		if (has_link)
 		{
-			if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
+			if ((act_req = nm_act_request_new (data, new_dev, FALSE)))
 			{
 				nm_info ("Will activate connection '%s%s%s'.",
 				         nm_device_get_iface (new_dev),
 				         ap ? "/" : "",
 				         ap ? nm_ap_get_essid (ap) : "");
+
+				if (ap) {
+					nm_act_request_set_ap (act_req, ap);
+					nm_ap_unref (ap);
+				}
+
 				nm_policy_schedule_device_activation (act_req);
 				nm_act_request_unref (act_req);
 			}

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerSystem.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerSystem.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/NetworkManagerSystem.c	Wed Jan 30 20:26:46 2008
@@ -277,7 +277,7 @@
 
 	cache = rtnl_link_alloc_cache (nlh);
 	if (!cache) {
-		nm_warning ("%s: couldn't allocate link cache.");
+		nm_warning ("%s: couldn't allocate link cache.", iface);
 		goto out;
 	}
 
@@ -305,7 +305,7 @@
 
 	cache = rtnl_link_alloc_cache (nlh);
 	if (!cache) {
-		nm_warning ("%s: couldn't allocate link cache.");
+		nm_warning ("Couldn't allocate link cache.");
 		goto out;
 	}
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.c	Wed Jan 30 20:26:46 2008
@@ -36,6 +36,7 @@
 	NMData *			data;
 	NMDevice *		dev;
 	NMAccessPoint *	ap;
+	NMWiredNetwork *wired_net;
 	NMIP4Config *		ip4_config;
 
 	gboolean			user_requested;
@@ -48,16 +49,13 @@
 };
 
 
-NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested)
+NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, gboolean user_requested)
 {
 	NMActRequest *	req;
 
 	g_return_val_if_fail (data != NULL, NULL);
 	g_return_val_if_fail (dev != NULL, NULL);
 
-	if (nm_device_is_802_11_wireless (dev))
-		g_return_val_if_fail (ap != NULL, NULL);
-
 	req = g_malloc0 (sizeof (NMActRequest));
 	req->refcount = 1;
 	req->data = data;
@@ -65,10 +63,6 @@
 	g_object_ref (G_OBJECT (dev));
 	req->dev = dev;
 
-	if (ap)
-		nm_ap_ref (ap);
-	req->ap = ap;
-
 	req->user_requested = user_requested;
 	req->dhcp_state = nm_dhcp_manager_get_state_for_device (data->dhcp_manager, dev);
 
@@ -103,6 +97,9 @@
 			g_source_destroy (source);
 		}
 
+		if (req->wired_net)
+			g_object_unref (req->wired_net);
+
 		memset (req, 0, sizeof (NMActRequest));
 		g_free (req);
 	}
@@ -124,6 +121,14 @@
 }
 
 
+gboolean nm_act_request_get_user_requested (NMActRequest *req)
+{
+	g_return_val_if_fail (req != NULL, FALSE);
+
+	return req->user_requested;
+}
+
+
 NMAccessPoint * nm_act_request_get_ap (NMActRequest *req)
 {
 	g_return_val_if_fail (req != NULL, NULL);
@@ -132,11 +137,42 @@
 }
 
 
-gboolean nm_act_request_get_user_requested (NMActRequest *req)
+void nm_act_request_set_ap (NMActRequest *req, NMAccessPoint *ap)
 {
-	g_return_val_if_fail (req != NULL, FALSE);
+	g_return_if_fail (req != NULL);
 
-	return req->user_requested;
+	if (req->ap)
+	{
+		nm_ap_unref (req->ap);
+		req->ap = NULL;
+	}
+	if (ap)
+	{
+		nm_ap_ref (ap);
+		req->ap = ap;
+	}
+}
+
+
+NMWiredNetwork *nm_act_request_get_wired_network (NMActRequest *req)
+{
+	g_return_val_if_fail (req != NULL, NULL);
+
+	return req->wired_net;
+}
+
+
+void nm_act_request_set_wired_network (NMActRequest *req, NMWiredNetwork *wired_net)
+{
+	g_return_if_fail (req != NULL);
+
+	if (req->wired_net)
+	{
+		g_object_unref (req->wired_net);
+		req->wired_net = NULL;
+	}
+	if (wired_net)
+		req->wired_net = g_object_ref (wired_net);
 }
 
 
@@ -242,4 +278,3 @@
 
 	req->dhcp_timeout = dhcp_timeout;
 }
-

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.h
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.h	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-activation-request.h	Wed Jan 30 20:26:46 2008
@@ -28,19 +28,25 @@
 #include "NetworkManagerMain.h"
 #include "nm-device.h"
 #include "NetworkManagerAP.h"
+#include "nm-wired-network.h"
 #include "nm-ip4-config.h"
 
 
 
-NMActRequest *		nm_act_request_new				(NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested);
+NMActRequest *		nm_act_request_new				(NMData *data, NMDevice *dev, gboolean user_requested);
 void				nm_act_request_ref				(NMActRequest *req);
 void				nm_act_request_unref			(NMActRequest *req);
 
 NMDevice *		nm_act_request_get_dev			(NMActRequest *req);
 NMData *			nm_act_request_get_data			(NMActRequest *req);
-NMAccessPoint *	nm_act_request_get_ap			(NMActRequest *req);
 gboolean			nm_act_request_get_user_requested	(NMActRequest *req);
 
+NMAccessPoint *	nm_act_request_get_ap			(NMActRequest *req);
+void			nm_act_request_set_ap			(NMActRequest *req, NMAccessPoint *ap);
+
+NMWiredNetwork *nm_act_request_get_wired_network	(NMActRequest *req);
+void			nm_act_request_set_wired_network	(NMActRequest *req, NMWiredNetwork *network);
+
 NMIP4Config *		nm_act_request_get_ip4_config		(NMActRequest *req);
 void				nm_act_request_set_ip4_config		(NMActRequest *req, NMIP4Config *ip4_config);
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-leap.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-leap.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-leap.c	Wed Jan 30 20:26:46 2008
@@ -100,7 +100,7 @@
 real_write_supplicant_config (NMAPSecurity *instance,
                               struct wpa_ctrl *ctrl,
                               int nwid,
-                              gboolean user_created)
+                              NMAPSecurityWriteFlags flag)
 {
 	NMAPSecurityLEAP *	self = NM_AP_SECURITY_LEAP (instance);
 	gboolean			success = FALSE;
@@ -109,6 +109,11 @@
 
 	g_return_val_if_fail (nm_ap_security_get_we_cipher (instance) == NM_AUTH_TYPE_LEAP, FALSE);
 
+	/* LEAP is not valid for wired */
+	if (flag == NM_AP_SECURITY_WRITE_FLAG_WIRED)
+		goto out;
+
+
 	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA", nwid))
 		   goto out;
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wep.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wep.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wep.c	Wed Jan 30 20:26:46 2008
@@ -115,12 +115,16 @@
 real_write_supplicant_config (NMAPSecurity *instance,
                               struct wpa_ctrl *ctrl,
                               int nwid,
-                              gboolean adhoc)
+                              NMAPSecurityWriteFlags flag)
 {
 	gboolean			success = FALSE;
 	char *			msg = NULL;
 	const char *		key = nm_ap_security_get_key (instance);
 
+	/* WEP is not valid for wired */
+	if (flag == NM_AP_SECURITY_WRITE_FLAG_WIRED)
+		goto out;
+
 	/* WEP network setup */
 	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
 			"SET_NETWORK %i key_mgmt NONE", nwid))

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-eap.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-eap.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-eap.c	Wed Jan 30 20:26:46 2008
@@ -171,7 +171,7 @@
 real_write_supplicant_config (NMAPSecurity *instance,
                               struct wpa_ctrl *ctrl,
                               int nwid,
-                              gboolean adhoc)
+                              NMAPSecurityWriteFlags flag)
 {
 	NMAPSecurityWPA_EAP * self = NM_AP_SECURITY_WPA_EAP (instance);
 	gboolean			success = FALSE;
@@ -212,15 +212,17 @@
 
 	/* WPA-EAP network setup */
 
-	if (self->priv->wpa_version == IW_AUTH_WPA_VERSION_WPA)
-	{
-		if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA", nwid))
-			goto out;
-	}
-	else
-	{
-		if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA2", nwid))
-			goto out;
+	if (flag != NM_AP_SECURITY_WRITE_FLAG_WIRED) {
+		if (self->priv->wpa_version == IW_AUTH_WPA_VERSION_WPA)
+		{
+			if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA", nwid))
+				goto out;
+		}
+		else
+		{
+			if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA2", nwid))
+				goto out;
+		}
 	}
 
 	if (key_type != IW_AUTH_CIPHER_WEP104)
@@ -307,7 +309,8 @@
 	 * Set the pairwise and group cipher, if the user provided one.  If user selected "Automatic", we
 	 * let wpa_supplicant sort it out.  Likewise, if the user selected "Dynamic WEP", we do nothing.
 	 */
-	if (key_type != NM_AUTH_TYPE_WPA_PSK_AUTO && key_type != IW_AUTH_CIPHER_WEP104)
+	if (flag != NM_AP_SECURITY_WRITE_FLAG_WIRED &&
+	    key_type != NM_AUTH_TYPE_WPA_PSK_AUTO && key_type != IW_AUTH_CIPHER_WEP104)
 	{
 		const char *cipher;
 
@@ -329,8 +332,9 @@
 			goto out;
 	}
 
-	nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
-			"SET_NETWORK %i fragment_size 1300", nwid);
+	if (flag != NM_AP_SECURITY_WRITE_FLAG_WIRED)
+		nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
+												"SET_NETWORK %i fragment_size 1300", nwid);
 
 	success = TRUE;
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-psk.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-psk.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security-wpa-psk.c	Wed Jan 30 20:26:46 2008
@@ -134,7 +134,7 @@
 real_write_supplicant_config (NMAPSecurity *instance,
                               struct wpa_ctrl *ctrl,
                               int nwid,
-                              gboolean adhoc)
+                              NMAPSecurityWriteFlags flag)
 {
 	NMAPSecurityWPA_PSK * self = NM_AP_SECURITY_WPA_PSK (instance);
 	gboolean			success = FALSE;
@@ -145,6 +145,11 @@
 	char *			pairwise_cipher = NULL;
 	char *			group_cipher = NULL;
 
+
+	/* WPA-PSK is not valid for wired */
+	if (flag == NM_AP_SECURITY_WRITE_FLAG_WIRED)
+		goto out;
+
 	/* WPA-PSK network setup */
 
 	if (self->priv->wpa_version == IW_AUTH_WPA_VERSION_WPA)
@@ -161,7 +166,7 @@
 	}
 
 	/* Ad-Hoc has to be WPA-NONE */
-	if (adhoc)
+	if (flag == NM_AP_SECURITY_WRITE_FLAG_ADHOC)
 		key_mgmt = "WPA-NONE";
 
 	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
@@ -189,7 +194,7 @@
 		pairwise_cipher = group_cipher = "NONE";
 
 	/* Ad-Hoc requires pairwise cipher of NONE */
-	if (adhoc)
+	if (flag == NM_AP_SECURITY_WRITE_FLAG_ADHOC)
 		pairwise_cipher = "NONE";
 
 	/* If user selected "Automatic", we let wpa_supplicant sort it out */

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.c	Wed Jan 30 20:26:46 2008
@@ -171,7 +171,7 @@
 nm_ap_security_write_supplicant_config (NMAPSecurity *self,
                                         struct wpa_ctrl *ctrl,
                                         int nwid,
-                                        gboolean adhoc)
+                                        NMAPSecurityWriteFlags flag)
 {
 	g_return_val_if_fail (self != NULL, FALSE);
 	g_return_val_if_fail (ctrl != NULL, FALSE);
@@ -181,7 +181,7 @@
 		return FALSE;
 
 	return NM_AP_SECURITY_GET_CLASS (self)->write_supplicant_config_func (self,
-			ctrl, nwid, adhoc);
+			ctrl, nwid, flag);
 }
 
 void
@@ -240,7 +240,7 @@
 real_write_supplicant_config (NMAPSecurity *self,
                               struct wpa_ctrl *ctrl,
                               int nwid,
-                              gboolean adhoc)
+                              NMAPSecurityWriteFlags flag)
 {
 	/* Unencrypted network setup */
 	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.h
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.h	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-ap-security.h	Wed Jan 30 20:26:46 2008
@@ -40,6 +40,12 @@
 #define NM_IS_AP_SECURITY_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass),  NM_TYPE_AP_SECURITY))
 #define NM_AP_SECURITY_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_AP_SECURITY, NMAPSecurityClass))
 
+typedef enum {
+	NM_AP_SECURITY_WRITE_FLAG_NONE,
+	NM_AP_SECURITY_WRITE_FLAG_ADHOC,
+	NM_AP_SECURITY_WRITE_FLAG_WIRED
+} NMAPSecurityWriteFlags;
+
 typedef struct _NMAPSecurity NMAPSecurity;
 typedef struct _NMAPSecurityClass NMAPSecurityClass;
 typedef struct _NMAPSecurityPrivate NMAPSecurityPrivate;
@@ -67,7 +73,7 @@
 	gboolean	(*write_supplicant_config_func)(NMAPSecurity *self,
 									  struct wpa_ctrl *ctrl,
 									  int nwid,
-									  gboolean adhoc);
+									  NMAPSecurityWriteFlags flag);
 
 	guint32 (*get_default_capabilities_func)(NMAPSecurity *self);
 	gboolean (*get_authentication_required_func)(NMAPSecurity *self);
@@ -94,7 +100,7 @@
 gboolean		nm_ap_security_write_supplicant_config (NMAPSecurity *self,
 									struct wpa_ctrl *ctrl,
 									int nwid,
-									gboolean adhoc);
+									NMAPSecurityWriteFlags flag);
 
 const char *	nm_ap_security_get_description (NMAPSecurity *self);
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-device.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-device.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-device.c	Wed Jan 30 20:26:46 2008
@@ -448,8 +448,17 @@
 				}
 			}
 		}
-		else
+		else {
+			NMActRequest *req = nm_device_get_act_request (dev);
+
+			if (req) {
+				NMWiredNetwork *wired_net = nm_act_request_get_wired_network (req);
+				if (wired_net)
+					active_network_path = g_strdup (nm_wired_network_get_network_id (wired_net));
+			}
+
 			speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (dev));
+		}
 
 		if (!active_network_path)
 			active_network_path = g_strdup ("");

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nm.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nm.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nm.c	Wed Jan 30 20:26:46 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -227,10 +229,11 @@
 	const char * INVALID_ARGS_MESSAGE = "NetworkManager::setActiveDevice called with invalid arguments.";
 	NMDevice *		dev = NULL;
 	DBusMessage *		reply = NULL;
-	char *			dev_path;
-	NMAccessPoint *	ap = NULL;
+	char *			dev_path = NULL;
+	NMAPSecurity * 	security = NULL;
 	NMActRequest * req;
 	DBusMessageIter	iter;
+	char *			network_id = NULL;
 
 	g_return_val_if_fail (connection != NULL, NULL);
 	g_return_val_if_fail (message != NULL, NULL);
@@ -253,62 +256,62 @@
 	if (!dev || !(nm_device_get_capabilities (dev) & NM_DEVICE_CAP_NM_SUPPORTED))
 	{
 		reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
-						"The requested network device does not exist.");
+									   "The requested network device does not exist.");
 		nm_warning ("%s:%d (%s): Invalid device (device not found).", __FILE__, __LINE__, __func__);
 		goto out;
 	}
 
-	if (nm_device_is_802_11_wireless (dev))
-	{
-		NMAPSecurity * 	security = NULL;
-		char *			essid = NULL;
-
-		if (!dbus_message_iter_next (&iter) || (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING))
-		{
-			nm_warning ("%s:%d (%s): Invalid argument type (essid).", __FILE__, __LINE__, __func__);
+	/* Next up is the network id... */
+	if (dbus_message_iter_next (&iter) && (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_STRING))
+		dbus_message_iter_get_basic (&iter, &network_id);
+
+	/* and finally, the security object */
+	if (dbus_message_iter_next (&iter)) {
+		security = nm_ap_security_new_deserialize (&iter);
+		if (!security) {
+			/* There was security info, but it was invalid */
+			reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, INVALID_ARGS_ERROR, INVALID_ARGS_MESSAGE);
+			nm_warning ("%s:%d (%s): Invalid argument (security info).", __FILE__, __LINE__, __func__);
 			goto out;
 		}
+	}
 
-		/* grab ssid and ensure validity */
-		dbus_message_iter_get_basic (&iter, &essid);
-		if (!essid || (strlen (essid) <= 0))
-		{
-			nm_warning ("%s:%d (%s): Invalid argument (essid).", __FILE__, __LINE__, __func__);
-			goto out;
-		}
+	req = nm_act_request_new (data->data, dev, TRUE);
 
-		/* If there's security information, we use that.  If not, we
-		 * make some up from the scan list.
-		 */
-		if (dbus_message_iter_next (&iter))
-		{
-			if (!(security = nm_ap_security_new_deserialize (&iter)))
-			{
-				/* There was security info, but it was invalid */
-				reply = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, INVALID_ARGS_ERROR, INVALID_ARGS_MESSAGE);
-				nm_warning ("%s:%d (%s): Invalid argument (wireless security info).", __FILE__, __LINE__, __func__);
-				goto out;
-			}
+	if (nm_device_is_802_11_wireless (dev)) {
+		NMAccessPoint *ap;
+
+		if (!network_id || (strlen (network_id) <= 0)) {
+			nm_warning ("%s:%d (%s): Invalid argument type (essid).", __FILE__, __LINE__, __func__);
+			goto out;
 		}
 
 		/* Set up the wireless-specific activation request properties */
-		ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (dev), essid, security);
-		if (security)
-	 		g_object_unref (G_OBJECT (security));
+		ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (dev), network_id, security);
+		nm_act_request_set_ap (req, ap);
+	} else if (nm_device_is_802_3_ethernet (dev)) {
+		if (network_id && security) {
+			NMWiredNetwork *wired_net;
 
-		nm_info ("User Switch: %s / %s", dev_path, essid);
+			wired_net = nm_wired_network_new (network_id, security);
+			nm_act_request_set_wired_network (req, wired_net);
+			g_object_unref (wired_net);
+		}
 	}
-	else if (nm_device_is_802_3_ethernet (dev))
-	{
+
+	if (network_id)
+		nm_info ("User Switch: %s / %s", dev_path, network_id);
+	else
 		nm_info ("User Switch: %s", dev_path);
-	}
 
 	nm_device_deactivate (dev);
 	nm_schedule_state_change_signal_broadcast (data->data);
-	req = nm_act_request_new (data->data, dev, ap, TRUE);
 	nm_policy_schedule_device_activation (req);
 	nm_act_request_unref (req);
 
+	if (security)
+		g_object_unref (security);
+
 	/* empty success message */
 	reply = dbus_message_new_method_return (message);
 	if (!reply)
@@ -398,7 +401,10 @@
 	g_object_unref (G_OBJECT (security));
 	nm_ap_set_user_created (new_ap, TRUE);
 
-	req = nm_act_request_new (data->data, dev, new_ap, TRUE);
+	req = nm_act_request_new (data->data, dev, TRUE);
+	nm_act_request_set_ap (req, new_ap);
+	nm_ap_unref (new_ap);
+
 	nm_policy_schedule_device_activation (req);
 	nm_act_request_unref (req);
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.c	Wed Jan 30 20:26:46 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -22,6 +24,7 @@
 #include "NetworkManager.h"
 #include "nm-device.h"
 #include "nm-activation-request.h"
+#include "nm-device-802-3-ethernet.h"
 #include "NetworkManagerAPList.h"
 #include "NetworkManagerPolicy.h"
 #include "NetworkManagerUtils.h"
@@ -29,42 +32,23 @@
 #include "nm-utils.h"
 
 
-/*
- * nm_dbus_get_user_key_for_network_cb
- *
- * Callback from nm_dbus_get_user_key_for_network when NetworkManagerInfo returns
- * the new user key.
- *
- */
-static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRequest *req)
+static gboolean
+nm_dbus_get_wireless_user_key_done (DBusMessage *reply, NMActRequest *req)
 {
-	DBusMessage *		reply = NULL;
-	NMData *			data;
-	NMDevice *		dev;
-	NMAccessPoint *	ap;
-	NMAPSecurity *		security;
-	DBusMessageIter	iter;
+	NMAccessPoint *ap;
+	NMData *data;
+	NMAPSecurity *security;
+	DBusMessageIter iter;
 
-	g_return_if_fail (pcall != NULL);
-	g_return_if_fail (req != NULL);
+	const char *iface = nm_device_get_iface (nm_act_request_get_dev (req));
 
 	data = nm_act_request_get_data (req);
 	g_assert (data);
 
-	dev = nm_act_request_get_dev (req);
-	g_assert (dev);
-
 	ap = nm_act_request_get_ap (req);
 	g_assert (ap);
 
-	if (!dbus_pending_call_get_completed (pcall))
-		goto out;
-
-	if (!(reply = dbus_pending_call_steal_reply (pcall)))
-		goto out;
-
-	if (message_is_error (reply))
-	{
+	if (message_is_error (reply)) {
 		DBusError err;
 
 		dbus_error_init (&err);
@@ -72,10 +56,8 @@
 
 		/* Check for cancelled error */
 		if (strcmp (err.name, NMI_DBUS_USER_KEY_CANCELED_ERROR) == 0)
-		{
 			nm_info ("Activation (%s) New wireless user key request for network '%s' was canceled.",
-					nm_device_get_iface (dev), nm_ap_get_essid (ap));
-		}
+				    iface, nm_ap_get_essid (ap));
 		else
 			nm_warning ("nm_dbus_get_user_key_for_network_cb(): dbus returned an error.\n  (%s) %s\n", err.name, err.message);
 
@@ -87,15 +69,13 @@
 		 * here...  ad nauseum.  Figure out how to deal with a failure here.
 		 */
 		nm_ap_list_append_ap (data->invalid_ap_list, ap);
-		nm_policy_schedule_activation_failed (req);
-		goto out;
+		return FALSE;
 	}
 
-	nm_info ("Activation (%s) New wireless user key for network '%s' received.", nm_device_get_iface (dev), nm_ap_get_essid (ap));
+	nm_info ("Activation (%s) New wireless user key for network '%s' received.", iface, nm_ap_get_essid (ap));
 
 	dbus_message_iter_init (reply, &iter);
-	if ((security = nm_ap_security_new_deserialize (&iter)))
-	{
+	if ((security = nm_ap_security_new_deserialize (&iter))) {
 		NMAccessPoint *allowed_ap;
 
 		nm_ap_set_security (ap, security);
@@ -106,11 +86,91 @@
 			nm_ap_set_security (allowed_ap, security);
 
 		g_object_unref (G_OBJECT (security));	/* set_security copies the object */
-		nm_device_activate_schedule_stage1_device_prepare (req);
 	}
+
+	return TRUE;
+}
+
+static gboolean
+nm_dbus_get_wired_user_key_done (DBusMessage *reply, NMActRequest *req)
+{
+	NMAPSecurity *security;
+	DBusMessageIter iter;
+	NMWiredNetwork *wired_net;
+	const char *iface = nm_device_get_iface (nm_act_request_get_dev (req));
+
+	wired_net = nm_act_request_get_wired_network (req);
+	g_assert (wired_net);
+
+	if (message_is_error (reply)) {
+		DBusError err;
+
+		dbus_error_init (&err);
+		dbus_set_error_from_message (&err, reply);
+
+		/* Check for cancelled error */
+		if (strcmp (err.name, NMI_DBUS_USER_KEY_CANCELED_ERROR) == 0)
+			nm_info ("Activation (%s) New wired user key request was canceled.", iface);
+		else
+			nm_warning ("nm_dbus_get_user_key_for_network_cb(): dbus returned an error.\n  (%s) %s\n", err.name, err.message);
+
+		dbus_error_free (&err);
+		return FALSE;
+	}
+
+	nm_info ("Activation (%s) New wired user key received.", iface);
+
+	dbus_message_iter_init (reply, &iter);
+	if ((security = nm_ap_security_new_deserialize (&iter))) {
+		nm_wired_network_set_security (wired_net, security);
+		g_object_unref (security);
+	}
+
+	return TRUE;
+}
+
+/*
+ * nm_dbus_get_user_key_for_network_cb
+ *
+ * Callback from nm_dbus_get_user_key_for_network when NetworkManagerInfo returns
+ * the new user key.
+ *
+ */
+static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRequest *req)
+{
+	NMDevice *dev;
+	gboolean success;
+	DBusMessage *reply = NULL;
+
+	g_return_if_fail (pcall != NULL);
+	g_return_if_fail (req != NULL);
+
+	if (!dbus_pending_call_get_completed (pcall))
+		goto out;
+
+	if (!(reply = dbus_pending_call_steal_reply (pcall)))
+		goto out;
+
+	dev = nm_act_request_get_dev (req);
+	g_assert (dev);
+
 	nm_act_request_set_user_key_pending_call (req, NULL);
 
-out:
+	if (NM_IS_DEVICE_802_11_WIRELESS (dev))
+		success = nm_dbus_get_wireless_user_key_done (reply, req);
+	else if (NM_IS_DEVICE_802_3_ETHERNET (dev))
+		success = nm_dbus_get_wired_user_key_done (reply, req);
+	else {
+		g_error ("Unhandled device type (%s)", G_OBJECT_TYPE_NAME (dev));
+		return;
+	}
+
+	if (success)
+		nm_device_activate_schedule_stage1_device_prepare (req);
+	else
+		nm_policy_schedule_activation_failed (req);
+
+ out:
 	if (reply)
 		dbus_message_unref (reply);
 	nm_act_request_unref (req);
@@ -126,11 +186,8 @@
  */
 void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest *req, const gboolean new_key)
 {
-	DBusMessage *		message;
-	DBusPendingCall *	pcall;
 	NMData *			data;
 	NMDevice *		dev;
-	NMAccessPoint *	ap;
 	gint32			attempt = 1;
 	char *			dev_path;
 	char *			net_path;
@@ -145,22 +202,44 @@
 	dev = nm_act_request_get_dev (req);
 	g_assert (dev);
 
-	ap = nm_act_request_get_ap (req);
-	g_assert (ap);
+	if (NM_IS_DEVICE_802_11_WIRELESS (dev)) {
+		NMAccessPoint *	ap;
 
-	essid = nm_ap_get_essid (ap);
-	nm_info ("Activation (%s) New wireless user key requested for network '%s'.", nm_device_get_iface (dev), essid);
+		ap = nm_act_request_get_ap (req);
+		g_assert (ap);
 
-	if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getKeyForNetwork")))
-	{
-		nm_warning ("nm_dbus_get_user_key_for_network(): Couldn't allocate the dbus message");
+		essid = nm_ap_get_essid (ap);
+		net_path = nm_dbus_get_object_path_for_network (dev, ap);
+
+		nm_info ("Activation (%s) New wireless user key requested for network '%s'.",
+			    nm_device_get_iface (dev), essid);
+
+	} else if (NM_IS_DEVICE_802_3_ETHERNET (dev)) {
+		NMWiredNetwork *wired_net;
+
+		wired_net = nm_act_request_get_wired_network (req);
+		g_assert (wired_net);
+		
+		essid = nm_wired_network_get_network_id (wired_net);
+		net_path = g_strdup ("/");
+	} else {
+		g_error ("Unhandled device type (%s)", G_OBJECT_TYPE_NAME (dev));
 		return;
 	}
 
 	dev_path = nm_dbus_get_object_path_for_device (dev);
-	net_path = nm_dbus_get_object_path_for_network (dev, ap);
+
 	if (dev_path && strlen (dev_path) && net_path && strlen (net_path))
 	{
+		DBusMessage *message;
+		DBusPendingCall *pcall;
+
+		if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getKeyForNetwork")))
+		{
+			nm_warning ("nm_dbus_get_user_key_for_network(): Couldn't allocate the dbus message");
+			return;
+		}
+
 		dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path,
 									DBUS_TYPE_OBJECT_PATH, &net_path,
 									DBUS_TYPE_STRING, &essid,
@@ -176,7 +255,11 @@
 		}
 		else
 			nm_warning ("nm_dbus_get_user_key_for_network(): could not send dbus message");
-	} else nm_warning ("nm_dbus_get_user_key_for_network(): bad object path data");
+
+		dbus_message_unref (message);
+	} else
+		nm_warning ("nm_dbus_get_user_key_for_network(): bad object path data");
+
 	g_free (net_path);
 	g_free (dev_path);
 
@@ -184,8 +267,6 @@
 	 * we just hang in the activation process and nothing happens
 	 * until the user cancels stuff.
 	 */
-
-	dbus_message_unref (message);
 }
 
 
@@ -219,26 +300,15 @@
 }
 
 
-/*
- * nm_dbus_update_network_info
- *
- * Tell NetworkManagerInfo the updated info of the AP
- *
- */
-gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, const gboolean automatic)
-{
-	DBusMessage *		message;
-	gboolean			success = FALSE;
-	const char *		essid;
-	gchar *			char_bssid;
-	NMAPSecurity *		security;
-	const struct ether_addr *addr;
-	DBusMessageIter	iter;
-
-	g_return_val_if_fail (connection != NULL, FALSE);
-	g_return_val_if_fail (ap != NULL, FALSE);
-
-	essid = nm_ap_get_essid (ap);
+static gboolean update_network_info (DBusConnection *connection,
+							  const char *network_id,
+							  gboolean automatic,
+							  const char *bssid,
+							  NMAPSecurity *security)
+{
+	DBusMessage *message;
+	DBusMessageIter iter;
+	gboolean success = FALSE;
 
 	if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "updateNetworkInfo")))
 	{
@@ -249,19 +319,52 @@
 	dbus_message_iter_init_append (message, &iter);
 
 	/* First argument: ESSID (STRING) */
-	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &essid);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &network_id);
 
 	/* Second argument: Automatic (BOOLEAN) */
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &automatic);
 
 	/* Third argument: Access point's BSSID */
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &bssid);
+
+	/* Serialize the AP's security info into the message */
+	if (nm_ap_security_serialize (security, &iter) != 0)
+		goto unref;
+
+	if (dbus_connection_send (connection, message, NULL))
+		success = TRUE;
+	else
+		nm_warning ("update_network_info(): failed to send dbus message.");
+
+unref:
+	dbus_message_unref (message);
+
+out:
+	return success;
+
+}
+
+
+/*
+ * nm_dbus_update_network_info
+ *
+ * Tell NetworkManagerInfo the updated info of the AP
+ *
+ */
+gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, const gboolean automatic)
+{
+	gboolean success;
+	gchar *char_bssid;
+	const struct ether_addr *addr;
+
+	g_return_val_if_fail (connection != NULL, FALSE);
+	g_return_val_if_fail (ap != NULL, FALSE);
+
 	addr = nm_ap_get_address (ap);
 	if ((nm_ap_get_mode (ap) == IW_MODE_INFRA) && nm_ethernet_address_is_valid (addr))
 	{
 		char_bssid = g_new0 (gchar, 20);
 		iw_ether_ntop (addr, char_bssid);
-		dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &char_bssid);
-		g_free (char_bssid);
 	}
 	else
 	{
@@ -269,26 +372,30 @@
 		 * the BSSID is usually randomly constructed by the driver and
 		 * changed every time you activate the network.
 		 */
-		char_bssid = " ";
-		dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &char_bssid);
+		char_bssid = g_strdup (" ");
 	}
 
-	/* Serialize the AP's security info into the message */
-	security = nm_ap_get_security (ap);
-	g_assert (security);
-	if (nm_ap_security_serialize (security, &iter) != 0)
-		goto unref;
+	success = update_network_info (connection,
+							 nm_ap_get_essid (ap),
+							 automatic,
+							 char_bssid,
+							 nm_ap_get_security (ap));
+	g_free (char_bssid);
 
-	if (dbus_connection_send (connection, message, NULL))
-		success = TRUE;
-	else
-		nm_warning ("nm_dbus_update_network_info(): failed to send dbus message.");
+	return success;
+}
 
-unref:
-	dbus_message_unref (message);
 
-out:
-	return success;
+gboolean nm_dbus_update_wired_network_info (DBusConnection *connection, NMWiredNetwork *wired_net)
+{
+	g_return_val_if_fail (connection != NULL, FALSE);
+	g_return_val_if_fail (wired_net != NULL, FALSE);
+
+	return update_network_info (connection,
+						   nm_wired_network_get_network_id (wired_net),
+						   FALSE,
+						   "WIRED", /* CRAPPY HACK */
+						   nm_wired_network_get_security (wired_net));
 }
 
 

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.h
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.h	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-dbus-nmi.h	Wed Jan 30 20:26:46 2008
@@ -24,6 +24,7 @@
 
 #include "NetworkManager.h"
 #include "NetworkManagerAP.h"
+#include "nm-wired-network.h"
 
 void			nm_dbus_get_user_key_for_network		(DBusConnection *connection, NMActRequest *req, const gboolean new_key);
 
@@ -33,6 +34,9 @@
 
 gboolean		nm_dbus_update_network_info			(DBusConnection *connection, NMAccessPoint *ap, const gboolean user_requested);
 
+gboolean		nm_dbus_update_wired_network_info	(DBusConnection *connection, NMWiredNetwork *wired_net);
+
+
 void			nm_dbus_update_one_allowed_network		(DBusConnection *connection, const char *network, NMData *data);
 
 void			nm_dbus_update_allowed_networks		(DBusConnection *connection, NMAccessPointList *list, NMData *data);

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-11-wireless.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-11-wireless.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-11-wireless.c	Wed Jan 30 20:26:46 2008
@@ -2536,7 +2536,10 @@
 	if (nm_device_activation_should_cancel (NM_DEVICE (self)))
 		goto out;
 
-	if (!nm_ap_security_write_supplicant_config (nm_ap_get_security (ap), ctrl, nwid, is_adhoc))
+	if (!nm_ap_security_write_supplicant_config (nm_ap_get_security (ap), ctrl, nwid,
+										is_adhoc ?
+										NM_AP_SECURITY_WRITE_FLAG_ADHOC :
+										NM_AP_SECURITY_WRITE_FLAG_NONE))
 		goto out;
 
 	if (nm_device_activation_should_cancel (NM_DEVICE (self)))
@@ -2720,6 +2723,9 @@
 
 	g_assert (ap);
 
+	if (self->priv->supplicant)
+		g_object_unref (self->priv->supplicant);
+
 	/* If we need an encryption key, get one */
 	if (ap_need_key (self, ap, &ask_user))
 	{

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-3-ethernet.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-3-ethernet.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device-802-3-ethernet.c	Wed Jan 30 20:26:46 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -30,8 +32,10 @@
 #include "nm-device-private.h"
 #include "NetworkManagerMain.h"
 #include "nm-activation-request.h"
+#include "nm-supplicant.h"
 #include "NetworkManagerUtils.h"
 #include "NetworkManagerPolicy.h"
+#include "nm-dbus-nmi.h"
 #include "nm-utils.h"
 #include "kernel-types.h"
 
@@ -44,6 +48,9 @@
 	char *			carrier_file_path;
 	gulong			link_connected_id;
 	gulong			link_disconnected_id;
+	NMSupplicant *		supplicant;
+	GSource *			link_timeout;
+	gboolean			failed_8021x;
 };
 
 static gboolean supports_mii_carrier_detect (NMDevice8023Ethernet *dev);
@@ -56,6 +63,8 @@
                                                           GObject *obj,
                                                           NMDevice8023Ethernet *self);
 
+static void remove_link_timeout (NMDevice8023Ethernet *self);
+
 
 static void
 nm_device_802_3_ethernet_init (NMDevice8023Ethernet * self)
@@ -99,7 +108,9 @@
 static gboolean
 link_activated_helper (NMDevice8023Ethernet *self)
 {
-	nm_device_set_active_link (NM_DEVICE (self), TRUE);
+	if (!self->priv->failed_8021x)
+		nm_device_set_active_link (NM_DEVICE (self), TRUE);
+
 	return FALSE;
 }
 
@@ -154,7 +165,7 @@
 	gchar *	contents;
 	gsize	length;
 
-	if (nm_device_get_removed (NM_DEVICE (self)))
+	if (nm_device_get_removed (NM_DEVICE (self)) || self->priv->failed_8021x)
 		goto out;
 
 	/* Devices that don't support carrier detect are always "on" and
@@ -208,6 +219,23 @@
 }
 
 
+static void
+real_deactivate_quickly (NMDevice *dev)
+{
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (dev);
+
+	if (self->priv->supplicant) {
+		g_object_unref (self->priv->supplicant);
+		self->priv->supplicant = NULL;
+	}
+
+	remove_link_timeout (self);
+
+	self->priv->failed_8021x = FALSE;
+	real_update_link (dev);
+}
+
+
 static NMActStageReturn
 real_act_stage1_prepare (NMDevice *dev, NMActRequest *req)
 {
@@ -227,6 +255,238 @@
 	return parent_class->act_stage1_prepare (dev, req);
 }
 
+static gboolean
+supplicant_send_network_config (NMDevice8023Ethernet *self,
+                                NMAPSecurity *security)
+{
+	gboolean success = FALSE;
+	char *response = NULL;
+	int nwid;
+	struct wpa_ctrl *ctrl;
+
+	ctrl = nm_supplicant_get_ctrl (self->priv->supplicant);
+	g_assert (ctrl);
+
+	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "AP_SCAN 0"))
+		goto out;
+
+	/* Standard network setup info */
+	if (!(response = nm_utils_supplicant_request (ctrl, "ADD_NETWORK"))) {
+		nm_warning ("Supplicant error for ADD_NETWORK.\n");
+		goto out;
+	}
+	if (sscanf (response, "%i\n", &nwid) != 1)
+	{
+		nm_warning ("Supplicant error for ADD_NETWORK.  Response: '%s'\n", response);
+		g_free (response);
+		goto out;
+	}
+	g_free (response);
+
+	if (!nm_ap_security_write_supplicant_config (security, ctrl, nwid, NM_AP_SECURITY_WRITE_FLAG_WIRED))
+		goto out;
+
+	if (nm_device_activation_should_cancel (NM_DEVICE (self)))
+		goto out;
+
+	if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
+										"ENABLE_NETWORK %i", nwid))
+		goto out;
+
+	success = TRUE;
+out:
+	return success;
+}
+
+static void
+remove_link_timeout (NMDevice8023Ethernet *self)
+{
+	if (self->priv->link_timeout) {
+		g_source_destroy (self->priv->link_timeout);
+		self->priv->link_timeout = NULL;
+	}
+}
+
+static void
+link_timeout_done (gpointer user_data)
+{
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (user_data);
+
+	self->priv->link_timeout = NULL;
+}
+
+static gboolean
+link_timeout_cb (gpointer user_data)
+{
+	NMDevice *			dev = NM_DEVICE (user_data);
+ 	NMDevice8023Ethernet *	self = NM_DEVICE_802_3_ETHERNET (user_data);	
+ 	NMActRequest *			req = nm_device_get_act_request (dev);
+ 	NMData *				data = nm_device_get_app_data (dev);
+
+ 	/* Disconnect event during initial authentication and credentials
+ 	 * ARE checked - we are likely to have wrong key.  Ask the user for
+ 	 * another one.
+ 	 */
+ 	if (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG) {
+ 		/* Association/authentication failed, we must have bad encryption key */
+ 		nm_info ("Activation (%s/wired): disconnected during association,"
+ 		         " asking for new key.", nm_device_get_iface (dev));
+ 		nm_supplicant_remove_timeout (self->priv->supplicant);
+ 		nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
+ 	} else {
+ 		nm_info ("%s: link timed out.", nm_device_get_iface (dev));
+		self->priv->failed_8021x = TRUE;
+ 		nm_device_set_active_link (dev, FALSE);
+ 	}
+
+	return FALSE;
+}
+
+static gboolean
+supplicant_timed_out (gpointer user_data)
+{
+	NMDevice *dev = NM_DEVICE (user_data);
+	NMData *data = nm_device_get_app_data (dev);
+	NMActRequest *req = nm_device_get_act_request (dev);
+
+	nm_info ("Activation (%s/): association took too long, asking for new key.", nm_device_get_iface (dev));
+	nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
+
+	return FALSE;
+}
+
+static void
+supplicant_state_changed (NMSupplicant *supplicant,
+					 gboolean connected,
+					 gpointer user_data)
+{
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (user_data);
+	NMDevice *dev = NM_DEVICE (self);
+	NMActRequest *req = nm_device_get_act_request (NM_DEVICE (self));
+
+	if (connected) {
+		remove_link_timeout (self);
+		nm_device_set_active_link (dev, TRUE);
+
+		/* If this is the initial association during device activation,
+		 * schedule the next activation stage.
+		 */
+		if (req && (nm_act_request_get_stage (req) == NM_ACT_STAGE_DEVICE_CONFIG)) {
+			nm_info ("Activation (%s) Stage 2 of 5 (Device Configure) successful.",
+				    nm_device_get_iface (dev));
+			nm_supplicant_remove_timeout (self->priv->supplicant);
+			nm_device_activate_schedule_stage3_ip_config_start (req);
+		}
+	} else {
+		if (nm_device_is_activated (dev) || nm_device_is_activating (dev)) {
+			/* Start the link timeout so we allow some time for reauthentication */
+			if (!self->priv->link_timeout) {
+				self->priv->link_timeout = g_timeout_source_new (8000);
+				g_source_set_callback (self->priv->link_timeout,
+								   link_timeout_cb,
+								   self,
+								   link_timeout_done);
+				g_source_attach (self->priv->link_timeout, nm_device_get_main_context (dev));
+				g_source_unref (self->priv->link_timeout);
+			}
+		} else
+			nm_device_set_active_link (dev, FALSE);
+	}
+}
+
+static void
+supplicant_down (NMSupplicant *supplicant,
+			  gpointer user_data)
+{
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (user_data);
+
+	remove_link_timeout (self);
+}
+
+static NMActStageReturn
+real_act_stage2_config (NMDevice *dev, NMActRequest *req)
+{
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (dev);
+	NMWiredNetwork *wired_net;
+	NMAPSecurity *security;
+	const char *iface;
+	GMainContext *ctx;
+
+	if (self->priv->supplicant)
+		g_object_unref (self->priv->supplicant);
+
+	wired_net = nm_act_request_get_wired_network (req);
+	if (!wired_net)
+		return NM_ACT_STAGE_RETURN_SUCCESS;
+
+	iface = nm_device_get_iface (dev);
+	security = nm_wired_network_get_security (wired_net);
+
+	if (!nm_ap_security_get_key (security)) {
+		NMData *data = nm_act_request_get_data (req);
+
+		nm_info ("Activation (%s): using 802.1X authentication, but NO valid key exists. New key needed.", iface);
+		nm_dbus_get_user_key_for_network (data->dbus_connection, req, FALSE);
+
+		return NM_ACT_STAGE_RETURN_POSTPONE;
+	}
+
+	nm_info ("Activation (%s): using 802.1X authentication and a key exists. No new key needed.", iface);
+
+	self->priv->supplicant = nm_supplicant_new ();
+	g_signal_connect (self->priv->supplicant, "state-changed",
+				   G_CALLBACK (supplicant_state_changed),
+				   self);
+
+	g_signal_connect (self->priv->supplicant, "down",
+				   G_CALLBACK (supplicant_down),
+				   self);
+
+	ctx = nm_device_get_main_context (dev);
+
+	if (!nm_supplicant_exec (self->priv->supplicant, ctx)) {
+		nm_warning ("Activation (%s): couldn't start the supplicant.", iface);
+		goto out;
+	}
+	if (!nm_supplicant_interface_init (self->priv->supplicant, iface, "wired")) {
+		nm_warning ("Activation (%s): couldn't connect to the supplicant.", iface);
+		goto out;
+	}
+	if (!nm_supplicant_monitor_start (self->priv->supplicant, ctx, 10,
+							    supplicant_timed_out, self)) {
+		nm_warning ("Activation (%s): couldn't monitor the supplicant.", iface);
+		goto out;
+	}
+	if (!supplicant_send_network_config (self, security)) {
+		nm_warning ("Activation (%s): couldn't send security information"
+				  " to the supplicant.", iface);
+		goto out;
+	}
+
+	/* We'll get stage3 started when the supplicant connects */
+	return NM_ACT_STAGE_RETURN_POSTPONE;
+
+out:
+	g_object_unref (self->priv->supplicant);
+	self->priv->supplicant = NULL;
+
+	return NM_ACT_STAGE_RETURN_FAILURE;
+}
+
+static void
+real_activation_success_handler (NMDevice *dev, NMActRequest *req)
+{
+	NMWiredNetwork *wired_net;
+
+	wired_net = nm_act_request_get_wired_network (req);
+	if (wired_net) {
+		NMData *app_data;
+
+		app_data = nm_act_request_get_data (req);
+		nm_dbus_update_wired_network_info (app_data->dbus_connection, wired_net);
+	}
+}
+
 static void
 nm_device_802_3_ethernet_dispose (GObject *object)
 {
@@ -292,6 +552,9 @@
 	parent_class->init = real_init;
 	parent_class->update_link = real_update_link;
 	parent_class->act_stage1_prepare = real_act_stage1_prepare;
+	parent_class->act_stage2_config = real_act_stage2_config;
+	parent_class->deactivate_quickly = real_deactivate_quickly;
+	parent_class->activation_success_handler = real_activation_success_handler;
 
 	g_type_class_add_private (object_class, sizeof (NMDevice8023EthernetPrivate));
 }

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-device.c	Wed Jan 30 20:26:46 2008
@@ -620,7 +620,7 @@
 				do_switch = TRUE;
 
 			/* FIXME: Why is this activation request created here and never used? */
-			/* if (do_switch && (act_req = nm_act_request_new (app_data, self, NULL, TRUE))) */
+			/* if (do_switch && (act_req = nm_act_request_new (app_data, self, TRUE))) */
 			if (do_switch)
 			{
 				nm_info ("Will activate wired connection '%s' because it now has a link.", nm_device_get_iface (self));

Modified: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-supplicant.c
==============================================================================
--- branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-supplicant.c	(original)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-supplicant.c	Wed Jan 30 20:26:46 2008
@@ -256,6 +256,7 @@
 static void
 supplicant_state_changed (NMSupplicant *self, gboolean up)
 {
+	nm_info ("Supplicant state changed: %d", up);
 	g_signal_emit (self, signals[STATE_CHANGED], 0, up);
 }
 

Added: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.c
==============================================================================
--- (empty file)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.c	Wed Jan 30 20:26:46 2008
@@ -0,0 +1,89 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#include "nm-wired-network.h"
+
+G_DEFINE_TYPE (NMWiredNetwork, nm_wired_network, G_TYPE_OBJECT)
+
+#define NM_WIRED_NETWORK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_WIRED_NETWORK, NMWiredNetworkPrivate))
+
+typedef struct {
+	char *network_id;
+	NMAPSecurity *security;
+} NMWiredNetworkPrivate;
+
+NMWiredNetwork *
+nm_wired_network_new (const char *network_id, NMAPSecurity *security)
+{
+	NMWiredNetwork *wired_net;
+	NMWiredNetworkPrivate *priv;
+
+	g_return_val_if_fail (network_id != NULL, NULL);
+	g_return_val_if_fail (security != NULL, NULL);
+
+	wired_net = (NMWiredNetwork *) g_object_new (NM_TYPE_WIRED_NETWORK, NULL);
+	if (!wired_net)
+		return NULL;
+
+	priv = NM_WIRED_NETWORK_GET_PRIVATE (wired_net);
+	priv->network_id = g_strdup (network_id);
+	priv->security = g_object_ref (security);
+
+	return wired_net;
+}
+
+const char *
+nm_wired_network_get_network_id (NMWiredNetwork *net)
+{
+	g_return_val_if_fail (NM_IS_WIRED_NETWORK (net), NULL);
+
+	return NM_WIRED_NETWORK_GET_PRIVATE (net)->network_id;
+}
+
+NMAPSecurity *
+nm_wired_network_get_security (NMWiredNetwork *net)
+{
+	g_return_val_if_fail (NM_IS_WIRED_NETWORK (net), NULL);
+
+	return NM_WIRED_NETWORK_GET_PRIVATE (net)->security;
+}
+
+void
+nm_wired_network_set_security (NMWiredNetwork *net, NMAPSecurity *security)
+{
+	NMWiredNetworkPrivate *priv;
+
+	g_return_if_fail (NM_IS_WIRED_NETWORK (net));
+
+	priv = NM_WIRED_NETWORK_GET_PRIVATE (net);
+	if (priv->security)
+		g_object_unref (priv->security);
+
+	priv->security = security ? g_object_ref (security) : NULL;
+}
+
+
+static void
+nm_wired_network_init (NMWiredNetwork *wired_net)
+{
+}
+
+static void
+finalize (GObject *object)
+{
+	NMWiredNetworkPrivate *priv = NM_WIRED_NETWORK_GET_PRIVATE (object);
+
+	g_free (priv->network_id);
+	g_object_unref (priv->security);
+
+	G_OBJECT_CLASS (nm_wired_network_parent_class)->finalize (object);
+}
+
+static void
+nm_wired_network_class_init (NMWiredNetworkClass *wired_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (wired_class);
+
+	g_type_class_add_private (wired_class, sizeof (NMWiredNetworkPrivate));
+
+	object_class->finalize = finalize;
+}

Added: branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.h
==============================================================================
--- (empty file)
+++ branches/NETWORKMANAGER_0_6_0_RELEASE/src/nm-wired-network.h	Wed Jan 30 20:26:46 2008
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#ifndef NM_WIRED_NETWORK_H
+#define NM_WIRED_NETWORK_H 1
+
+#include <glib/gtypes.h>
+#include <glib-object.h>
+#include "nm-ap-security.h"
+
+#define NM_TYPE_WIRED_NETWORK            (nm_wired_network_get_type ())
+#define NM_WIRED_NETWORK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIRED_NETWORK, NMWiredNetwork))
+#define NM_WIRED_NETWORK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIRED_NETWORK, NMWiredNetworkClass))
+#define NM_IS_WIRED_NETWORK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIRED_NETWORK))
+#define NM_IS_WIRED_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_WIRED_NETWORK))
+#define NM_WIRED_NETWORK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIRED_NETWORK, NMWiredNetworkClass))
+
+typedef struct {
+	GObject parent;
+} NMWiredNetwork;
+
+typedef struct {
+	GObjectClass parent;
+} NMWiredNetworkClass;
+
+GType nm_wired_network_get_type (void);
+
+NMWiredNetwork *nm_wired_network_new            (const char     *network_id,
+									    NMAPSecurity   *security);
+
+const char     *nm_wired_network_get_network_id (NMWiredNetwork *net);
+NMAPSecurity   *nm_wired_network_get_security   (NMWiredNetwork *net);
+void            nm_wired_network_set_security   (NMWiredNetwork *net,
+									    NMAPSecurity   *security);
+
+#endif /* NM_WIRED_NETWORK_H */



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