From 3bdab8112692dda215718fc18d7182f53eeb9ea6 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 16 Aug 2005 17:16:40 +0000 Subject: [PATCH] 2005-08-16 Robert Love Patch from j@bootlab.org * src/backends/NetworkManagerDebian.c, src/backends/interface_parser.c, src/backends/interface_parser.h: Debian dialup support. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@851 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 6 ++ src/backends/NetworkManagerDebian.c | 86 +++++++++++++++++++++++++++++ src/backends/interface_parser.c | 5 ++ src/backends/interface_parser.h | 1 + 4 files changed, 98 insertions(+) diff --git a/ChangeLog b/ChangeLog index 400f227e69..9565ed9029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-08-16 Robert Love + + Patch from j@bootlab.org + * src/backends/NetworkManagerDebian.c, src/backends/interface_parser.c, + src/backends/interface_parser.h: Debian dialup support. + 2005-08-16 Christopher Aillon * vpn-daemons/vpnc/properties/nm-vpnc-dialog.glade: diff --git a/src/backends/NetworkManagerDebian.c b/src/backends/NetworkManagerDebian.c index d4e6073506..7bc2d2fe6f 100644 --- a/src/backends/NetworkManagerDebian.c +++ b/src/backends/NetworkManagerDebian.c @@ -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 @@ NMIP4Config *nm_system_device_new_ip4_system_config (NMDevice *dev) 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; +} diff --git a/src/backends/interface_parser.c b/src/backends/interface_parser.c index 935789670e..715fab0095 100644 --- a/src/backends/interface_parser.c +++ b/src/backends/interface_parser.c @@ -162,6 +162,11 @@ void ifparser_destroy() first = last = NULL; } +if_block *ifparser_getfirst() +{ + return first; +} + if_block *ifparser_getif(const char* iface) { if_block *curr = first; diff --git a/src/backends/interface_parser.h b/src/backends/interface_parser.h index 3cfecfcfd2..584278f662 100644 --- a/src/backends/interface_parser.h +++ b/src/backends/interface_parser.h @@ -45,6 +45,7 @@ void ifparser_destroy(); 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