[patch] Dial Up Debian Backend



attached patch adds dial up support to the debian backend.
this uses the same approach as used in SuSEs backend, just
changing it to parse /etc/network/interfaces for ppp connections.

j
Index: src/backends/NetworkManagerDebian.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/backends/NetworkManagerDebian.c,v
retrieving revision 1.28
diff -u -r1.28 NetworkManagerDebian.c
--- src/backends/NetworkManagerDebian.c	16 Jun 2005 01:00:26 -0000	1.28
+++ src/backends/NetworkManagerDebian.c	16 Aug 2005 16:17:08 -0000
@@ -30,6 +30,7 @@
 #include "NetworkManagerSystem.h"
 #include "NetworkManagerUtils.h"
 #include "NetworkManagerDevice.h"
+#include "NetworkManagerDialup.h"
 #include "interface_parser.h"
 #include "nm-utils.h"
 
@@ -641,3 +642,88 @@
 
 	return new_config;
 }
+
+void nm_system_deactivate_all_dialup (GSList *list)
+{
+	GSList *elt;
+
+	for (elt = list; elt; elt = g_slist_next (elt))
+	{
+		NMDialUpConfig *config = (NMDialUpConfig *) elt->data;
+		char *cmd;
+
+		cmd = g_strdup_printf ("/sbin/ifdown %s", (char *) config->data);
+		nm_spawn_process (cmd);
+		g_free (cmd);
+	}
+}
+
+gboolean nm_system_activate_dialup (GSList *list, const char *dialup)
+{
+	GSList *elt;
+	gboolean ret = FALSE;
+
+	for (elt = list; elt; elt = g_slist_next (elt))
+	{
+		NMDialUpConfig *config = (NMDialUpConfig *) elt->data;
+		if (strcmp (dialup, config->name) == 0)
+		{
+			char *cmd;
+
+			nm_info ("Activating dialup device %s (%s) ...", dialup, (char *) config->data);
+			cmd = g_strdup_printf ("/sbin/ifup %s", (char *) config->data);
+			nm_spawn_process (cmd);
+			g_free (cmd);
+			ret = TRUE;
+			break;
+		}
+	}
+
+	return ret;
+}
+
+GSList * nm_system_get_dialup_config (void)
+{
+	const char *buf;
+	if_block *curr_device;
+	gboolean       error = FALSE;
+	GError *err;
+	unsigned int i = 0;
+	size_t len;
+	GSList *list = NULL;
+	if_block *curr;
+	ifparser_init();
+
+	/* FIXME: get all ppp(and others?) lines from /e/n/i here */
+	curr = ifparser_getfirst();
+	while(curr!=NULL)
+	{
+		NMDialUpConfig *config;
+		if (strcmp(curr->type,"iface")==0) 
+		{
+			buf = ifparser_getkey(curr,"inet");
+			if (buf && strcmp (buf, "ppp")==0)
+			{
+				config = g_malloc (sizeof (NMDialUpConfig));
+				config->name = g_strdup_printf ("Modem (#%d)", i++);
+				config->data = g_strdup (curr->name);	/* interface name */
+
+				list = g_slist_append (list, config);
+
+				nm_info ("Found dial up configuration for %s: %s", config->name, (char *) config->data);
+			}
+		}
+		curr = curr->next;
+	}
+	ifparser_destroy();
+
+	/* Hack: Go back and remove the "(#0)" if there is only one device */
+	if (i == 1)
+	{
+		NMDialUpConfig *config = (NMDialUpConfig *) list->data;
+		g_free (config->name);
+		config->name = g_strdup ("Modem");
+	}
+
+	return list;
+}
Index: src/backends/interface_parser.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/backends/interface_parser.c,v
retrieving revision 1.4
diff -u -r1.4 interface_parser.c
--- src/backends/interface_parser.c	4 Apr 2005 16:24:36 -0000	1.4
+++ src/backends/interface_parser.c	16 Aug 2005 16:17:08 -0000
@@ -162,6 +162,11 @@
 	first = last = NULL;
 }
 
+if_block *ifparser_getfirst()
+{
+	return first;
+}
+
 if_block *ifparser_getif(const char* iface)
 {
 	if_block *curr = first;
Index: src/backends/interface_parser.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/backends/interface_parser.h,v
retrieving revision 1.1
diff -u -r1.1 interface_parser.h
--- src/backends/interface_parser.h	11 Nov 2004 02:24:04 -0000	1.1
+++ src/backends/interface_parser.h	16 Aug 2005 16:17:08 -0000
@@ -45,6 +45,7 @@
 
 const char* ifparser_interfaces();
 if_block *ifparser_getif(const char* iface);
+if_block *ifparser_getfirst();
 const char *ifparser_getkey(if_block* iface, const char *key);
 
 #endif


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