NetworkManager r4141 - in trunk: . src src/ppp-manager



Author: dcbw
Date: Thu Oct  2 17:10:00 2008
New Revision: 4141
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4141&view=rev

Log:
2008-10-02  Dan Williams  <dcbw redhat com>

	* src/ppp-manager/nm-ppp-manager.c
	  src/ppp-manager/nm-ppp-manager.h
		- (impl_ppp_manager_need_secrets): tries secrets twice before asking
			the settings daemon for completely new ones
		- (create_pppd_cmd_line): new parameter 'ppp_name' used to set the
			local PPP peer name; allow PPP debuging by launching NM with
			the environment variable NM_PPP_DEBUG defined
		- (nm_ppp_manager_start): new parameter 'ppp_name' passed to
			create_pppd_cmd_line()

	* src/nm-serial-device.c
	  src/nm-serial-device.h
		- New 'get_ppp_name' function for subclasses to implement to return the
			local PPP peer name
		- (real_act_stage2_config): call 'get_ppp_name' function of subclasses
			and pass that name to the PPP manager

	* src/nm-device-ethernet.c
		- (pppoe_stage2_config): pass the PPPoE username to the PPP manager as
			the local peer name

	* src/nm-cdma-device.c
		- (real_get_ppp_name): implement using the CDMA username



Modified:
   trunk/ChangeLog
   trunk/src/nm-cdma-device.c
   trunk/src/nm-device-ethernet.c
   trunk/src/nm-serial-device.c
   trunk/src/nm-serial-device.h
   trunk/src/ppp-manager/nm-ppp-manager.c
   trunk/src/ppp-manager/nm-ppp-manager.h

Modified: trunk/src/nm-cdma-device.c
==============================================================================
--- trunk/src/nm-cdma-device.c	(original)
+++ trunk/src/nm-cdma-device.c	Thu Oct  2 17:10:00 2008
@@ -312,6 +312,21 @@
 	nm_device_activate_schedule_stage1_device_prepare (dev);
 }
 
+static const char *
+real_get_ppp_name (NMSerialDevice *device, NMActRequest *req)
+{
+	NMConnection *connection;
+	NMSettingCdma *s_cdma;
+
+	connection = nm_act_request_get_connection (req);
+	g_assert (connection);
+
+	s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
+	g_assert (s_cdma);
+
+	return s_cdma->username;
+}
+
 /*****************************************************************************/
 /* Monitor device handling */
 
@@ -521,6 +536,7 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
+	NMSerialDeviceClass *serial_class = NM_SERIAL_DEVICE_CLASS (klass);
 
 	g_type_class_add_private (object_class, sizeof (NMCdmaDevicePrivate));
 
@@ -534,6 +550,8 @@
 	device_class->act_stage1_prepare = real_act_stage1_prepare;
 	device_class->connection_secrets_updated = real_connection_secrets_updated;
 
+	serial_class->get_ppp_name = real_get_ppp_name;
+
 	/* Properties */
 	g_object_class_install_property
 		(object_class, PROP_MONITOR_IFACE,

Modified: trunk/src/nm-device-ethernet.c
==============================================================================
--- trunk/src/nm-device-ethernet.c	(original)
+++ trunk/src/nm-device-ethernet.c	Thu Oct  2 17:10:00 2008
@@ -1235,6 +1235,8 @@
 pppoe_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
 {
 	NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
+	NMConnection *connection;
+	NMSettingPPPOE *s_pppoe;
 	NMActRequest *req;
 	GError *err = NULL;
 	NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
@@ -1242,8 +1244,14 @@
 	req = nm_device_get_act_request (NM_DEVICE (self));
 	g_assert (req);
 
+	connection = nm_act_request_get_connection (req);
+	g_assert (req);
+
+	s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
+	g_assert (s_pppoe);
+
 	priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (NM_DEVICE (self)));
-	if (nm_ppp_manager_start (priv->ppp_manager, req, &err)) {
+	if (nm_ppp_manager_start (priv->ppp_manager, req, s_pppoe->username, &err)) {
 		g_signal_connect (priv->ppp_manager, "state-changed",
 					   G_CALLBACK (ppp_state_changed),
 					   self);

Modified: trunk/src/nm-serial-device.c
==============================================================================
--- trunk/src/nm-serial-device.c	(original)
+++ trunk/src/nm-serial-device.c	Thu Oct  2 17:10:00 2008
@@ -1013,15 +1013,20 @@
 real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
 {
 	NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (device);
+	NMSerialDeviceClass *serial_class = NM_SERIAL_DEVICE_GET_CLASS (device);
 	NMActRequest *req;
 	GError *err = NULL;
 	NMActStageReturn ret;
+	const char *ppp_name = NULL;
 
 	req = nm_device_get_act_request (device);
 	g_assert (req);
 
+	if (serial_class->get_ppp_name)
+		ppp_name = serial_class->get_ppp_name (NM_SERIAL_DEVICE (device), req);
+
 	priv->ppp_manager = nm_ppp_manager_new (nm_device_get_iface (device));
-	if (nm_ppp_manager_start (priv->ppp_manager, req, &err)) {
+	if (nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, &err)) {
 		g_signal_connect (priv->ppp_manager, "state-changed",
 					   G_CALLBACK (ppp_state_changed),
 					   device);

Modified: trunk/src/nm-serial-device.h
==============================================================================
--- trunk/src/nm-serial-device.h	(original)
+++ trunk/src/nm-serial-device.h	Thu Oct  2 17:10:00 2008
@@ -23,6 +23,8 @@
 typedef struct {
 	NMDeviceClass parent;
 
+	const char * (*get_ppp_name) (NMSerialDevice *device, NMActRequest *req);
+
 	/* Signals */
 	void (*ppp_stats) (NMSerialDevice *device, guint32 in_bytes, guint32 out_bytes);
 } NMSerialDeviceClass;

Modified: trunk/src/ppp-manager/nm-ppp-manager.c
==============================================================================
--- trunk/src/ppp-manager/nm-ppp-manager.c	(original)
+++ trunk/src/ppp-manager/nm-ppp-manager.c	Thu Oct  2 17:10:00 2008
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <arpa/inet.h>
+#include <stdlib.h>
 
 #include <errno.h>
 #include <sys/socket.h>
@@ -408,9 +409,13 @@
 	}
 
 	tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), PPP_MANAGER_SECRET_TRIES));
+	/* Only ask for completely new secrets after retrying them once; some PPP
+	 * servers (T-Mobile USA) appear to ask a few times when they actually don't
+	 * even care what you pass back.
+	 */
 	nm_act_request_request_connection_secrets (priv->act_req,
 	                                           setting_name,
-	                                           tries ? TRUE : FALSE,
+	                                           tries > 1 ? TRUE : FALSE,
 	                                           SECRETS_CALLER_PPP,
 	                                           hint1,
 	                                           hint2);
@@ -698,11 +703,13 @@
 create_pppd_cmd_line (NMPPPManager *self,
                       NMSettingPPP *setting, 
                       NMSettingPPPOE *pppoe,
+                      const char *ppp_name,
                       GError **err)
 {
 	NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
 	const char *ppp_binary;
 	NMCmdLine *cmd;
+	const char *ppp_debug;
 
 	ppp_binary = nm_find_pppd ();
 	if (!ppp_binary) {
@@ -718,6 +725,15 @@
 	nm_cmd_line_add_string (cmd, "nodetach");
 	nm_cmd_line_add_string (cmd, "lock");
 
+	ppp_debug = getenv ("NM_PPP_DEBUG");
+	if (ppp_debug)
+		nm_cmd_line_add_string (cmd, "debug");
+
+	if (ppp_name) {
+		nm_cmd_line_add_string (cmd, "user");
+		nm_cmd_line_add_string (cmd, ppp_name);
+	}
+
 	if (pppoe) {
 		char *dev_str;
 
@@ -732,9 +748,6 @@
 			nm_cmd_line_add_string (cmd, "rp_pppoe_service");
 			nm_cmd_line_add_string (cmd, pppoe->service);
 		}
-
-		nm_cmd_line_add_string (cmd, "user");
-		nm_cmd_line_add_string (cmd, pppoe->username);
 	} else {
 		nm_cmd_line_add_string (cmd, priv->parent_iface);
 		/* Don't send some random address as the local address */
@@ -843,7 +856,10 @@
 }
 
 gboolean
-nm_ppp_manager_start (NMPPPManager *manager, NMActRequest *req, GError **err)
+nm_ppp_manager_start (NMPPPManager *manager,
+                      NMActRequest *req,
+                      const char *ppp_name,
+                      GError **err)
 {
 	NMPPPManagerPrivate *priv;
 	NMConnection *connection;
@@ -863,7 +879,7 @@
 	if (pppoe_setting)
 		pppoe_fill_defaults (ppp_setting);
 
-	ppp_cmd = create_pppd_cmd_line (manager, ppp_setting, pppoe_setting, err);
+	ppp_cmd = create_pppd_cmd_line (manager, ppp_setting, pppoe_setting, ppp_name, err);
 	if (!ppp_cmd)
 		return FALSE;
 

Modified: trunk/src/ppp-manager/nm-ppp-manager.h
==============================================================================
--- trunk/src/ppp-manager/nm-ppp-manager.h	(original)
+++ trunk/src/ppp-manager/nm-ppp-manager.h	Thu Oct  2 17:10:00 2008
@@ -38,7 +38,10 @@
 
 NMPPPManager *nm_ppp_manager_new (const char *iface);
 
-gboolean nm_ppp_manager_start (NMPPPManager *manager, NMActRequest *req, GError **err);
+gboolean nm_ppp_manager_start (NMPPPManager *manager,
+                               NMActRequest *req,
+                               const char *ppp_name,
+                               GError **err);
 
 void     nm_ppp_manager_update_secrets (NMPPPManager *manager,
                                         const char *device,



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