PPPoE



Heya,

After all these ppp manager mails I decided to see what really is
missing from NM to add some new PPP based connections (NM supposedly
supported only PPP over serial line). I chose PPPoE since I need to
implement it anyway. Turns out, it's as easy as I imagined it would
be. Well, almost. There's one issue that needs fixing. The current
interaction between ppp manager and pppd plugin is over dbus and
plugin emits signals when stuff changes and manager listens for these.
It has to be the other way around (manager has to register a
well-known service on dbus and plugin needs to call it's methods).
Otherwise, there's no way the plugin can ask for credentials when it
needs them for CHAP or PAP. So that and UI are missing for now.

Attached are the patches to implement PPPoE. 407 insertions, 16 deletions.

Tambet
From 1d894148f3e561efa47533f68dd36cae8e4ffd69 Mon Sep 17 00:00:00 2001
From: Tambet Ingo <tambet gmail com>
Date: Wed, 5 Mar 2008 20:48:19 -0600
Subject: [PATCH] Implement NMSettingPPPOE.


diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index ddbac0b..f95ace6 100644
--- a/libnm-util/Makefile.am
+++ b/libnm-util/Makefile.am
@@ -18,6 +18,7 @@ libnm_util_include_HEADERS = 		\
 	nm-setting-connection.h		\
 	nm-setting-ip4-config.h		\
 	nm-setting-ppp.h		\
+	nm-setting-pppoe.h		\
 	nm-setting-serial.h		\
 	nm-setting-gsm.h		\
 	nm-setting-cdma.h		\
@@ -35,6 +36,7 @@ libnm_util_la_SOURCES=			\
 	nm-setting-connection.c		\
 	nm-setting-ip4-config.c		\
 	nm-setting-ppp.c		\
+	nm-setting-pppoe.c		\
 	nm-setting-serial.c		\
 	nm-setting-gsm.c		\
 	nm-setting-cdma.c		\
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index d44dd6a..074a8f0 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -9,6 +9,7 @@
 #include "nm-setting-connection.h"
 #include "nm-setting-ip4-config.h"
 #include "nm-setting-ppp.h"
+#include "nm-setting-pppoe.h"
 #include "nm-setting-wired.h"
 #include "nm-setting-wireless.h"
 #include "nm-setting-wireless-security.h"
@@ -68,6 +69,7 @@ register_default_settings (void)
 		{ NM_SETTING_GSM_SETTING_NAME,               NM_TYPE_SETTING_GSM },
 		{ NM_SETTING_CDMA_SETTING_NAME,              NM_TYPE_SETTING_CDMA },
 		{ NM_SETTING_PPP_SETTING_NAME,               NM_TYPE_SETTING_PPP },
+		{ NM_SETTING_PPPOE_SETTING_NAME,             NM_TYPE_SETTING_PPPOE },
 		{ NM_SETTING_VPN_SETTING_NAME,               NM_TYPE_SETTING_VPN },
 		{ NM_SETTING_VPN_PROPERTIES_SETTING_NAME,    NM_TYPE_SETTING_VPN_PROPERTIES },
 		{ NULL }
diff --git a/libnm-util/nm-setting-pppoe.c b/libnm-util/nm-setting-pppoe.c
new file mode 100644
index 0000000..3bbe2e4
--- /dev/null
+++ b/libnm-util/nm-setting-pppoe.c
@@ -0,0 +1,123 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#include "nm-setting-pppoe.h"
+
+G_DEFINE_TYPE (NMSettingPPPOE, nm_setting_pppoe, NM_TYPE_SETTING)
+
+enum {
+	PROP_0,
+	PROP_USERNAME,
+	PROP_PASSWORD,
+
+	LAST_PROP
+};
+
+NMSetting *
+nm_setting_pppoe_new (void)
+{
+	return (NMSetting *) g_object_new (NM_TYPE_SETTING_PPPOE, NULL);
+}
+
+static gboolean
+verify (NMSetting *setting, GSList *all_settings)
+{
+	NMSettingPPPOE *self = NM_SETTING_PPPOE (setting);
+
+	if (!self->username) {
+		g_warning ("Missing username");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static GPtrArray *
+need_secrets (NMSetting *setting)
+{
+	NMSettingPPPOE *self = NM_SETTING_PPPOE (setting);
+	GPtrArray *secrets;
+
+	if (self->password)
+		return NULL;
+
+	secrets = g_ptr_array_sized_new (1);
+	g_ptr_array_add (secrets, NM_SETTING_PPPOE_PASSWORD);
+
+	return secrets;
+}
+
+static void
+nm_setting_pppoe_init (NMSettingPPPOE *setting)
+{
+	((NMSetting *) setting)->name = g_strdup (NM_SETTING_PPPOE_SETTING_NAME);
+}
+
+static void
+set_property (GObject *object, guint prop_id,
+		    const GValue *value, GParamSpec *pspec)
+{
+	NMSettingPPPOE *setting = NM_SETTING_PPPOE (object);
+
+	switch (prop_id) {
+	case PROP_USERNAME:
+		g_free (setting->username);
+		setting->username = g_value_dup_string (value);
+		break;
+	case PROP_PASSWORD:
+		g_free (setting->password);
+		setting->password = g_value_dup_string (value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+get_property (GObject *object, guint prop_id,
+		    GValue *value, GParamSpec *pspec)
+{
+	NMSettingPPPOE *setting = NM_SETTING_PPPOE (object);
+
+	switch (prop_id) {
+	case PROP_USERNAME:
+		g_value_set_string (value, setting->username);
+		break;
+	case PROP_PASSWORD:
+		g_value_set_string (value, setting->password);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+nm_setting_pppoe_class_init (NMSettingPPPOEClass *setting_class)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
+	NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
+
+	/* virtual methods */
+	object_class->set_property = set_property;
+	object_class->get_property = get_property;
+	parent_class->verify       = verify;
+	parent_class->need_secrets = need_secrets;
+
+	/* Properties */
+	g_object_class_install_property
+		(object_class, PROP_USERNAME,
+		 g_param_spec_string (NM_SETTING_PPPOE_USERNAME,
+						  "Username",
+						  "Username",
+						  NULL,
+						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+
+	g_object_class_install_property
+		(object_class, PROP_PASSWORD,
+		 g_param_spec_string (NM_SETTING_PPPOE_USERNAME,
+						  "Password",
+						  "Password",
+						  NULL,
+						  G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
+}
diff --git a/libnm-util/nm-setting-pppoe.h b/libnm-util/nm-setting-pppoe.h
new file mode 100644
index 0000000..583b91b
--- /dev/null
+++ b/libnm-util/nm-setting-pppoe.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#ifndef NM_SETTING_PPPOE_H
+#define NM_SETTING_PPPOE_H
+
+#include <nm-setting.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_SETTING_PPPOE            (nm_setting_pppoe_get_type ())
+#define NM_SETTING_PPPOE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_PPPOE, NMSettingPPPOE))
+#define NM_SETTING_PPPOE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEClass))
+#define NM_IS_SETTING_PPPOE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_PPPOE))
+#define NM_IS_SETTING_PPPOE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING_PPPOE))
+#define NM_SETTING_PPPOE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_PPPOE, NMSettingPPPOEClass))
+
+#define NM_SETTING_PPPOE_SETTING_NAME "pppoe"
+
+#define NM_SETTING_PPPOE_USERNAME "username"
+#define NM_SETTING_PPPOE_PASSWORD "password"
+
+typedef struct {
+	NMSetting parent;
+
+	char *username;
+	char *password;
+} NMSettingPPPOE;
+
+typedef struct {
+	NMSettingClass parent;
+} NMSettingPPPOEClass;
+
+GType nm_setting_pppoe_get_type (void);
+
+NMSetting *nm_setting_pppoe_new (void);
+
+G_END_DECLS
+
+#endif /* NM_SETTING_PPPOE_H */
-- 
1.5.2.4

From 94467834a62fa59088fbe43d71bc4350f854b9eb Mon Sep 17 00:00:00 2001
From: Tambet Ingo <tambet gmail com>
Date: Wed, 5 Mar 2008 21:18:16 -0600
Subject: [PATCH] Make NMPPPManager take NMConnection argument to the start() method.


diff --git a/src/nm-serial-device.c b/src/nm-serial-device.c
index fe1604e..558c759 100644
--- a/src/nm-serial-device.c
+++ b/src/nm-serial-device.c
@@ -843,17 +843,21 @@ static NMActStageReturn
 real_act_stage2_config (NMDevice *device)
 {
 	NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (device);
-	NMSettingPPP *setting;
+	NMActRequest *req;
+	NMConnection *connection;
 	GError *err = NULL;
 	NMActStageReturn ret;
 
-	setting = NM_SETTING_PPP (serial_device_get_setting (NM_SERIAL_DEVICE (device), NM_TYPE_SETTING_PPP));
+	req = nm_device_get_act_request (device);
+	g_assert (req);
+	connection = nm_act_request_get_connection (req);
+	g_assert (connection);
 
 	priv->ppp_manager = nm_ppp_manager_new ();
 
 	if (nm_ppp_manager_start (priv->ppp_manager,
 						 nm_device_get_iface (device),
-						 setting,
+						 connection,
 						 &err)) {
 		g_signal_connect (priv->ppp_manager, "state-changed",
 					   G_CALLBACK (ppp_state_changed),
diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
index b75d5de..6ec2c98 100644
--- a/src/ppp-manager/nm-ppp-manager.c
+++ b/src/ppp-manager/nm-ppp-manager.c
@@ -7,6 +7,7 @@
 #include <unistd.h>
 
 #include "nm-ppp-manager.h"
+#include "nm-setting-ppp.h"
 #include "nm-dbus-manager.h"
 #include "nm-utils.h"
 #include "nm-marshal.h"
@@ -501,19 +502,22 @@ pppd_child_setup (gpointer user_data G_GNUC_UNUSED)
 gboolean
 nm_ppp_manager_start (NMPPPManager *manager,
 				  const char *device,
-				  NMSettingPPP *setting,
+				  NMConnection *connection,
 				  GError **err)
 {
 	NMPPPManagerPrivate *priv;
+	NMSettingPPP *ppp_setting;
 	NMCmdLine *ppp_cmd;
 	char *cmd_str;
 	GSource *ppp_watch;
 
 	g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE);
 	g_return_val_if_fail (device != NULL, FALSE);
-	g_return_val_if_fail (setting != NULL, FALSE);
+	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
 
-	ppp_cmd = create_pppd_cmd_line (setting, device, err);
+	ppp_setting = NM_SETTING_PPP (nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP));
+
+	ppp_cmd = create_pppd_cmd_line (ppp_setting, device, err);
 	if (!ppp_cmd)
 		return FALSE;
 
diff --git a/src/ppp-manager/nm-ppp-manager.h b/src/ppp-manager/nm-ppp-manager.h
index 4e2790a..597afc1 100644
--- a/src/ppp-manager/nm-ppp-manager.h
+++ b/src/ppp-manager/nm-ppp-manager.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 #ifndef NM_PPP_MANAGER_H
 #define NM_PPP_MANAGER_H
 
@@ -5,7 +7,7 @@
 #include <glib-object.h>
 
 #include "nm-ppp-status.h"
-#include "nm-setting-ppp.h"
+#include "nm-connection.h"
 #include "nm-ip4-config.h"
 #include "nm-pppd-plugin.h"
 
@@ -33,9 +35,9 @@ GType nm_ppp_manager_get_type (void);
 NMPPPManager *nm_ppp_manager_new (void);
 
 gboolean nm_ppp_manager_start (NMPPPManager *manager,
-							   const char *device,
-							   NMSettingPPP *setting,
-							   GError **err);
+						 const char *device,
+						 NMConnection *connection,
+						 GError **err);
 
 void     nm_ppp_manager_stop  (NMPPPManager *manager);
 
-- 
1.5.2.4

From edf1711bacc871d3f7b5091d21ad71f1929db9c7 Mon Sep 17 00:00:00 2001
From: Tambet Ingo <tambet gmail com>
Date: Wed, 5 Mar 2008 22:17:59 -0600
Subject: [PATCH] Add PPPoE support to Ethernet device.


diff --git a/src/nm-device-802-3-ethernet.c b/src/nm-device-802-3-ethernet.c
index b78c130..46125bf 100644
--- a/src/nm-device-802-3-ethernet.c
+++ b/src/nm-device-802-3-ethernet.c
@@ -39,6 +39,8 @@
 #include "NetworkManagerSystem.h"
 #include "nm-setting-connection.h"
 #include "nm-setting-wired.h"
+#include "nm-setting-pppoe.h"
+#include "ppp-manager/nm-ppp-manager.h"
 #include "nm-utils.h"
 
 #include "nm-device-802-3-ethernet-glue.h"
@@ -58,6 +60,10 @@ typedef struct {
 
 	NMSupplicantInterface *sup_iface;
 	gulong			iface_state_id; 
+
+	/* PPPoE */
+	NMPPPManager *ppp_manager;
+	NMIP4Config  *pending_ip4_config;
 } NMDevice8023EthernetPrivate;
 
 enum {
@@ -385,6 +391,148 @@ real_get_best_connection (NMDevice *dev,
 	return NULL;
 }
 
+/*****************************************************************************/
+/* PPPoE */
+
+static void
+ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data)
+{
+	NMDevice *device = NM_DEVICE (user_data);
+
+	switch (status) {
+	case NM_PPP_STATUS_NETWORK:
+		nm_device_state_changed (device, NM_DEVICE_STATE_IP_CONFIG);
+		break;
+	case NM_PPP_STATUS_DISCONNECT:
+		nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+ppp_ip4_config (NMPPPManager *ppp_manager,
+			 const char *iface,
+			 NMIP4Config *config,
+			 gpointer user_data)
+{
+	NMDevice *device = NM_DEVICE (user_data);
+
+	nm_device_set_ip_iface (device, iface);
+	NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device)->pending_ip4_config = g_object_ref (config);
+	nm_device_activate_schedule_stage4_ip_config_get (device);
+}
+
+static NMActStageReturn
+pppoe_stage2_config (NMDevice8023Ethernet *self)
+{
+	NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
+	NMActRequest *req;
+	NMConnection *connection;
+	GError *err = NULL;
+	NMActStageReturn ret;
+
+	req = nm_device_get_act_request (NM_DEVICE (self));
+	g_assert (req);
+	connection = nm_act_request_get_connection (req);
+	g_assert (connection);
+
+	priv->ppp_manager = nm_ppp_manager_new ();
+
+	if (nm_ppp_manager_start (priv->ppp_manager,
+						 nm_device_get_iface (NM_DEVICE (self)),
+						 connection,
+						 &err)) {
+		g_signal_connect (priv->ppp_manager, "state-changed",
+					   G_CALLBACK (ppp_state_changed),
+					   self);
+		g_signal_connect (priv->ppp_manager, "ip4-config",
+					   G_CALLBACK (ppp_ip4_config),
+					   self);
+		ret = NM_ACT_STAGE_RETURN_POSTPONE;
+	} else {
+		nm_warning ("%s", err->message);
+		g_error_free (err);
+
+		g_object_unref (priv->ppp_manager);
+		priv->ppp_manager = NULL;
+
+		ret = NM_ACT_STAGE_RETURN_FAILURE;
+	}
+
+	return ret;
+}
+
+/* FIXME: Move it to nm-device.c and then get rid of all foo_device_get_setting() all around.
+   It's here now to keep the patch short. */
+static NMSetting *
+device_get_setting (NMDevice *device, GType setting_type)
+{
+	NMActRequest *req;
+	NMSetting *setting = NULL;
+
+	req = nm_device_get_act_request (device);
+	if (req) {
+		NMConnection *connection;
+
+		connection = nm_act_request_get_connection (req);
+		if (connection)
+			setting = nm_connection_get_setting (connection, setting_type);
+	}
+
+	return setting;
+}
+
+static NMActStageReturn
+real_act_stage2_config (NMDevice *device)
+{
+	NMSettingConnection *s_connection;
+	NMActStageReturn ret;
+
+	s_connection = NM_SETTING_CONNECTION (device_get_setting (device, NM_TYPE_SETTING_CONNECTION));
+	g_assert (s_connection);
+
+	if (!strcmp (s_connection->type, NM_SETTING_WIRED_SETTING_NAME))
+		ret = NM_ACT_STAGE_RETURN_SUCCESS;
+	else if (!strcmp (s_connection->type, NM_SETTING_PPPOE_SETTING_NAME))
+		ret = pppoe_stage2_config (NM_DEVICE_802_3_ETHERNET (device));
+	else {
+		nm_warning ("Invalid connection type '%s' for ethernet device", s_connection->type);
+		ret = NM_ACT_STAGE_RETURN_FAILURE;
+	}
+
+	return ret;
+}
+
+static NMActStageReturn
+real_act_stage4_get_ip4_config (NMDevice *device, NMIP4Config **config)
+{
+	NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
+
+	*config = priv->pending_ip4_config;
+	priv->pending_ip4_config = NULL;
+
+	return NM_ACT_STAGE_RETURN_SUCCESS;
+}
+
+static void
+real_deactivate_quickly (NMDevice *device)
+{
+	NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
+
+	if (priv->pending_ip4_config) {
+		g_object_unref (priv->pending_ip4_config);
+		priv->pending_ip4_config = NULL;
+	}
+
+	if (priv->ppp_manager) {
+		g_object_unref (priv->ppp_manager);
+		priv->ppp_manager = NULL;
+	}
+}
+
+
 static void
 nm_device_802_3_ethernet_dispose (GObject *object)
 {
@@ -470,6 +618,10 @@ nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *klass)
 	parent_class->set_hw_address = real_set_hw_address;
 	parent_class->get_best_connection = real_get_best_connection;
 
+	parent_class->act_stage2_config = real_act_stage2_config;
+	parent_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
+	parent_class->deactivate_quickly = real_deactivate_quickly;
+
 	/* properties */
 	g_object_class_install_property
 		(object_class, PROP_HW_ADDRESS,
-- 
1.5.2.4

From c7b3ed4fb2873280195c333d9e24b476a1a1cedd Mon Sep 17 00:00:00 2001
From: Tambet Ingo <tambet gmail com>
Date: Wed, 5 Mar 2008 22:18:30 -0600
Subject: [PATCH] Add PPPoE support to the PPP manager.


diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
index 6ec2c98..9bc7431 100644
--- a/src/ppp-manager/nm-ppp-manager.c
+++ b/src/ppp-manager/nm-ppp-manager.c
@@ -8,6 +8,7 @@
 
 #include "nm-ppp-manager.h"
 #include "nm-setting-ppp.h"
+#include "nm-setting-pppoe.h"
 #include "nm-dbus-manager.h"
 #include "nm-utils.h"
 #include "nm-marshal.h"
@@ -417,7 +418,10 @@ start_dbus_watcher (NMPPPManager *manager)
 }
 
 static NMCmdLine *
-create_pppd_cmd_line (NMSettingPPP *setting, const char *device, GError **err)
+create_pppd_cmd_line (NMSettingPPP *setting, 
+				  NMSettingPPPOE *pppoe,
+				  const char *device,
+				  GError **err)
 {
 	const char *ppp_binary;
 	NMCmdLine *cmd;
@@ -433,6 +437,14 @@ create_pppd_cmd_line (NMSettingPPP *setting, const char *device, GError **err)
 	cmd = nm_cmd_line_new ();
 	nm_cmd_line_add_string (cmd, ppp_binary);
 
+	if (pppoe) {
+		nm_cmd_line_add_string (cmd, "plugin");
+		nm_cmd_line_add_string (cmd, "rp-pppoe.so");
+
+		nm_cmd_line_add_string (cmd, "user");
+		nm_cmd_line_add_string (cmd, pppoe->username);
+	}
+
 	nm_cmd_line_add_string (cmd, "nodetach");
 	nm_cmd_line_add_string (cmd, "lock");
 	nm_cmd_line_add_string (cmd, device);
@@ -499,6 +511,38 @@ pppd_child_setup (gpointer user_data G_GNUC_UNUSED)
 	setpgid (pid, pid);
 }
 
+static void
+pppoe_fill_defaults (NMSettingPPP *setting)
+{
+	if (!setting->mtu)
+		setting->mtu = 1492;
+
+	if (!setting->mru)
+		setting->mru = 1492;
+
+	if (!setting->lcp_echo_interval)
+		setting->lcp_echo_interval = 20;
+
+	if (!setting->lcp_echo_failure)
+		setting->lcp_echo_failure = 3;
+
+	setting->noauth = TRUE;
+	setting->usepeerdns = TRUE;
+	setting->nodeflate = TRUE;
+
+	/* FIXME: These commented settings should be set as well, update NMSettingPPP first. */
+#if 0
+	setting->noipdefault = TRUE;
+	setting->default_asyncmap = TRUE;
+	setting->defaultroute = TRUE;
+	setting->hide_password = TRUE;
+	setting->noaccomp = TRUE;
+	setting->nopcomp = TRUE;
+	setting->novj = TRUE;
+	setting->novjccomp = TRUE;
+#endif
+}
+
 gboolean
 nm_ppp_manager_start (NMPPPManager *manager,
 				  const char *device,
@@ -507,6 +551,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
 {
 	NMPPPManagerPrivate *priv;
 	NMSettingPPP *ppp_setting;
+	NMSettingPPPOE *pppoe_setting;
 	NMCmdLine *ppp_cmd;
 	char *cmd_str;
 	GSource *ppp_watch;
@@ -516,8 +561,12 @@ nm_ppp_manager_start (NMPPPManager *manager,
 	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
 
 	ppp_setting = NM_SETTING_PPP (nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP));
+	pppoe_setting = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
+
+	if (pppoe_setting)
+		pppoe_fill_defaults (ppp_setting);
 
-	ppp_cmd = create_pppd_cmd_line (ppp_setting, device, err);
+	ppp_cmd = create_pppd_cmd_line (ppp_setting, pppoe_setting, device, err);
 	if (!ppp_cmd)
 		return FALSE;
 
diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c
index baf83b6..fd56552 100644
--- a/src/ppp-manager/nm-pppd-plugin.c
+++ b/src/ppp-manager/nm-pppd-plugin.c
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
 
+#include <string.h>
 #include <pppd/pppd.h>
 #include <pppd/fsm.h>
 #include <pppd/ipcp.h>
@@ -303,6 +304,20 @@ nm_ip_up (void *data, int arg)
 	g_hash_table_destroy (hash);
 }
 
+static int
+get_credentials (char *username, char *password)
+{
+	/* return -1 on error */
+
+	/* FIXME: Get username and password from NM */
+	strncpy (username, "username", MAXNAMELEN);
+	username[MAXNAMELEN - 1] = '\0';
+	strncpy (password, "password", MAXSECRETLEN);
+	password[MAXSECRETLEN - 1] = '\0';
+
+	return 0;
+}
+
 static void
 nm_exit_notify (void *data, int arg)
 {
@@ -353,6 +368,9 @@ plugin_init (void)
 	plugin = nm_pppd_plugin_new (bus);
 	dbus_g_connection_unref (bus);
 
+	chap_passwd_hook = get_credentials;
+	pap_passwd_hook = get_credentials;
+
 	add_notifier (&phasechange, nm_phasechange, plugin);
 	add_notifier (&ip_up_notifier, nm_ip_up, plugin);
 	add_notifier (&exitnotify, nm_exit_notify, plugin);
-- 
1.5.2.4



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