No NetworkManagerInfo



Hi!

I just compiled NM with under gentoo with the atached ebuild. After
compilation I started NM with success. But when I try to start
NetworkManagerInfo this binary does not exist! I only have the binaries
NetworkManager and NetworkManagerDispatch. Has the NetworkManagerInfo
changed name since the 0.4 release or is something wrong?

magnus

-----------------------------------
 Contact information
  Phone: (+46) (0) 31 206700
  Mobile: (+46) (0) 733-908060
  Email: magnus grand1982 com

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit gnome2 debug eutils

DESCRIPTION="Network configuration and management in an easy way. Desktop env independent"
HOMEPAGE="http://people.redhat.com/dcbw/NetworkManager/";
SRC_URI="http://people.redhat.com/dcbw/${PN}/${PV}/${PN}-${PV}.cvs20050506.tar.gz";

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="crypt wifi debug doc gnome"

RDEPEND=">=sys-apps/dbus-0.23
	>=sys-apps/hal-0.2.91
	sys-apps/iproute2
	wifi? net-wireless/wireless-tools
	>=dev-libs/glib-2.0
	gnome? ( >=x11-libs/gtk+-2
		>=gnome-base/libglade-2
		>=gnome-base/gnome-keyring-0.4
		>=gnome-base/gnome-panel-2
		>=gnome-base/gconf-2
		>=gnome-base/libgnomeui-2 )
	crypt? ( dev-libs/libgcrypt )"
	
DEPEND="${RDEPEND}
	dev-util/pkgconfig
	dev-util/intltool"

S=${WORKDIR}/${PN}-0.4

DOCS="AUTHORS COPYING ChangeLog INSTALL NEWS README"
USE_DESTDIR="1"

G2CONF="${G2CONF} \
	`use_with crypt gcrypt` \
	--disable-more-warnings \
	--with-distro=gentoo \
	--with-dbus-sys=/etc/dbus-1/system.d \
	--enable-notification-icon"

src_unpack () {

	unpack ${A}
	cd ${S}

	epatch ${FILESDIR}/${P}-gentoo_backend.patch

}
diff -Nru NetworkManager-0.4/src/backends/Makefile.am NetworkManager-0.4.gent/src/backends/Makefile.am
--- NetworkManager-0.4/src/backends/Makefile.am	2005-04-15 12:37:26.000000000 -0400
+++ NetworkManager-0.4.gent/src/backends/Makefile.am	2005-05-10 12:53:44.000000000 -0400
@@ -11,7 +11,9 @@
 endif
 
 if TARGET_GENTOO
-libnmbackend_la_SOURCES +=	NetworkManagerGentoo.c
+libnmbackend_la_SOURCES +=	NetworkManagerGentoo.c	\
+						shvar.c				\
+						shvar.h
 endif
 
 if TARGET_DEBIAN
diff -Nru NetworkManager-0.4/src/backends/Makefile.in NetworkManager-0.4.gent/src/backends/Makefile.in
--- NetworkManager-0.4/src/backends/Makefile.in	2005-05-04 17:29:08.000000000 -0400
+++ NetworkManager-0.4.gent/src/backends/Makefile.in	2005-05-10 12:53:44.000000000 -0400
@@ -40,7 +40,10 @@
 @TARGET_REDHAT_TRUE@						shvar.c				\
 @TARGET_REDHAT_TRUE@						shvar.h
 
- TARGET_GENTOO_TRUE@am__append_2 = NetworkManagerGentoo.c
+ TARGET_GENTOO_TRUE@am__append_2 = NetworkManagerGentoo.c	\
+ TARGET_GENTOO_TRUE@						shvar.c				\
+ TARGET_GENTOO_TRUE@						shvar.h
+
 @TARGET_DEBIAN_TRUE am__append_3 = NetworkManagerDebian.c	\
 @TARGET_DEBIAN_TRUE@						interface_parser.c		\
 @TARGET_DEBIAN_TRUE@						interface_parser.h	
@@ -233,7 +236,8 @@
 @TARGET_REDHAT_TRUE@	libnmbackend_la-NetworkManagerRedHat.lo \
 @TARGET_REDHAT_TRUE@	libnmbackend_la-shvar.lo
 @TARGET_GENTOO_TRUE am__objects_2 = \
- TARGET_GENTOO_TRUE@	libnmbackend_la-NetworkManagerGentoo.lo
+ TARGET_GENTOO_TRUE@	libnmbackend_la-NetworkManagerGentoo.lo \
+ TARGET_GENTOO_TRUE@	libnmbackend_la-shvar.lo
 @TARGET_DEBIAN_TRUE am__objects_3 = \
 @TARGET_DEBIAN_TRUE@	libnmbackend_la-NetworkManagerDebian.lo \
 @TARGET_DEBIAN_TRUE@	libnmbackend_la-interface_parser.lo
diff -Nru NetworkManager-0.4/src/backends/NetworkManagerGentoo.c NetworkManager-0.4.gent/src/backends/NetworkManagerGentoo.c
--- NetworkManager-0.4/src/backends/NetworkManagerGentoo.c	2005-04-04 12:24:36.000000000 -0400
+++ NetworkManager-0.4.gent/src/backends/NetworkManagerGentoo.c	2005-05-10 13:52:03.000000000 -0400
@@ -1,8 +1,6 @@
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
- * Dan Willemsen <dan willemsen us>
- * Robert Paskowitz
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,22 +17,17 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  * (C) Copyright 2004 Red Hat, Inc.
- * (C) Copyright 2004 Dan Willemsen
- * (C) Copyright 2004 Robert Paskowitz
  */
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <arpa/inet.h>
 #include <signal.h>
-#include "nm-utils.h"
-
-/* get strnlen */
-#define __USE_GNU 
-#include <string.h>
-
+#include <arpa/inet.h>
 #include "NetworkManagerSystem.h"
 #include "NetworkManagerUtils.h"
+#include "NetworkManagerDevice.h"
+#include "nm-utils.h"
+#include "shvar.h"
 
 /*
  * nm_system_init
@@ -44,12 +37,11 @@
  */
 void nm_system_init (void)
 {
-	/* While dhcpcd is the client of choice, it's not forced upon the user
-	 * So we should probably put in a check for available clients, and
-	 * modify our commands appropriatly.
-	 */
+	/* Kill any dhclients lying around */
+	nm_system_kill_all_dhcp_daemons ();
 }
 
+
 /*
  * nm_system_device_flush_routes
  *
@@ -58,17 +50,85 @@
  */
 void nm_system_device_flush_routes (NMDevice *dev)
 {
-	char	buf [100];
+	g_return_if_fail (dev != NULL);
 
+	/* Not really applicable for test devices */
+	if (nm_device_is_test_device (dev))
+		return;
+
+	nm_system_device_flush_routes_with_iface (nm_device_get_iface (dev));
+}
+
+
+/*
+ * nm_system_device_flush_routes_with_iface
+ *
+ * Flush all routes associated with a network device
+ *
+ */
+void nm_system_device_flush_routes_with_iface (const char *iface)
+{
+	char	*buf;
+
+	g_return_if_fail (iface != NULL);
+
+	/* Remove routing table entries */
+	buf = g_strdup_printf ("/sbin/ip route flush dev %s", iface);
+	nm_spawn_process (buf);
+	g_free (buf);
+}
+
+
+/*
+ * nm_system_device_add_default_route_via_device
+ *
+ * Add default route to the given device
+ *
+ */
+void nm_system_device_add_default_route_via_device (NMDevice *dev)
+{
 	g_return_if_fail (dev != NULL);
 
 	/* Not really applicable for test devices */
 	if (nm_device_is_test_device (dev))
 		return;
-	snprintf (buf, 100, "/sbin/ip route flush dev %s", nm_device_get_iface (dev));
+
+	nm_system_device_add_default_route_via_device_with_iface (nm_device_get_iface (dev));
+}
+
+
+/*
+ * nm_system_device_add_default_route_via_device_with_iface
+ *
+ * Add default route to the given device
+ *
+ */
+void nm_system_device_add_default_route_via_device_with_iface (const char *iface)
+{
+	char	*buf;
+
+	g_return_if_fail (iface != NULL);
+
+	/* Add default gateway */
+	buf = g_strdup_printf ("/sbin/ip route add default dev %s", iface);
 	nm_spawn_process (buf);
+	g_free (buf);
 }
 
+
+/*
+ * nm_system_device_has_active_routes
+ *
+ * Find out whether the specified device has any routes in the routing
+ * table.
+ *
+ */
+gboolean nm_system_device_has_active_routes (NMDevice *dev)
+{
+	return (FALSE);
+}
+
+
 /*
  * nm_system_device_flush_addresses
  *
@@ -77,78 +137,48 @@
  */
 void nm_system_device_flush_addresses (NMDevice *dev)
 {
-	char	buf [100];
-
 	g_return_if_fail (dev != NULL);
 
 	/* Not really applicable for test devices */
 	if (nm_device_is_test_device (dev))
 		return;
 
-	snprintf (buf, 100, "/sbin/ip address flush dev %s", nm_device_get_iface (dev));
-	nm_spawn_process (buf);
+	nm_system_device_flush_addresses_with_iface (nm_device_get_iface (dev));
 }
 
 
 /*
- * nm_system_device_setup_static_ip4_config
+ * nm_system_device_flush_addresses_with_iface
  *
- * Set up the device with a particular IPv4 address/netmask/gateway.
- *
- * Returns:	TRUE	on success
- *			FALSE on error
+ * Flush all network addresses associated with a network device
  *
  */
-gboolean nm_system_device_setup_static_ip4_config (NMDevice *dev)
+void nm_system_device_flush_addresses_with_iface (const char *iface)
 {
-#define IPBITS  (sizeof (guint32) * 8)
-	struct in_addr	ip_addr, net_addr, broad_addr, gate_addr;
-	int			i, err;
-	guint32		prefix = IPBITS;
-	const char	*iface;
-	char			*buf;
-	char			*addr, *netmask, *broadcast, *gateway;
-	
-	nm_warning ("nm_system_device_setup_static_ip4_config() is not implemented yet for this distribution.\n");
-	
-	/* Extract the addresses back into strings */
+	char	*buf;
 
-	ip_addr.s_addr = nm_device_config_get_ip4_address (dev);
-	net_addr.s_addr = nm_device_config_get_ip4_netmask (dev);
-	broad_addr.s_addr = nm_device_config_get_ip4_broadcast (dev);
-	gate_addr.s_addr = nm_device_config_get_ip4_gateway (dev);
-	
-	addr = g_strdup (inet_ntoa (ip_addr));
-	netmask = g_strdup (inet_ntoa (net_addr));
-	broadcast = g_strdup (inet_ntoa (broad_addr));
-	gateway = g_strdup (inet_ntoa (gate_addr));
-	iface = nm_device_get_iface (dev);
-	
-	/* Flush the device and routes */
-	nm_system_device_flush_addresses (dev);
-	nm_system_device_flush_routes (dev);
-
-	/* Set the IP/broadcast */
-	buf = g_strdup_printf("/sbin/ip addr add local %s dev %s broadcast %s %s", addr, iface, broadcast, iface);
-	nm_warning ("Running: %s", buf);
-	/* Set the gateway */
-	buf = g_strdup_printf("/sbin/ip route replace default dev %s via %s", iface, gateway);
-	nm_warning ("Running: %s", buf);
-	
-	/* Inform other computers the we are on network */
-	buf = g_strdup_printf ("/sbin/arping -q -A -c 1 -I %s %s", iface, addr);
-	nm_warning ("Running: %s", buf);
-	buf = g_strdup_printf ("/sbin/arping -q -U -c 1 -I %s %s", iface, addr);
-	nm_warning ("Running: %s", buf);
-	
-	return(TRUE);
-	
-error:
-	g_free(buf);
-	return(FALSE);
+	g_return_if_fail (iface != NULL);
+
+	/* Remove all IP addresses for a device */
+	buf = g_strdup_printf ("/sbin/ip address flush dev %s", iface);
+	nm_spawn_process (buf);
+	g_free (buf);
 }
 
 
+#if 0
+	/* Alert other computers of our new address */
+	temp_addr.s_addr = addr;
+	buf = g_strdup_printf ("/sbin/arping -q -A -c 1 -I %s %s", iface, inet_ntoa (temp_addr));
+	nm_spawn_process (buf);
+	g_free (buf);
+	g_usleep (G_USEC_PER_SEC * 2);
+	buf = g_strdup_printf ("/sbin/arping -q -U -c 1 -I %s %s", iface, inet_ntoa (temp_addr));
+	nm_spawn_process (buf);
+	g_free (buf);
+#endif
+
+
 /*
  * nm_system_enable_loopback
  *
@@ -157,10 +187,24 @@
  */
 void nm_system_enable_loopback (void)
 {
-	nm_spawn_process ("/sbin/ip link set dev lo up");
-	nm_spawn_process ("/sbin/ip addr add 127.0.0.1/8 brd 127.255.255.255 dev lo label loopback");
+	nm_spawn_process("/etc/init.d/net.lo start");
+}
+
+
+/*
+ * nm_system_flush_loopback_routes
+ *
+ * Flush all routes associated with the loopback device, because it
+ * sometimes gets the first route for ZeroConf/Link-Local traffic.
+ *
+ */
+void nm_system_flush_loopback_routes (void)
+{
+	/* Remove routing table entries for lo */
+	nm_spawn_process ("/sbin/ip route flush dev lo");
 }
 
+
 /*
  * nm_system_delete_default_route
  *
@@ -172,35 +216,55 @@
 	nm_spawn_process ("/sbin/ip route del default");
 }
 
+
+/*
+ * nm_system_flush_arp_cache
+ *
+ * Flush all entries in the arp cache.
+ *
+ */
+void nm_system_flush_arp_cache (void)
+{
+	nm_spawn_process ("/sbin/ip neigh flush all");
+}
+
+
 /*
  * nm_system_kill_all_dhcp_daemons
  *
- * Kill all DHCP daemons currently running, done at startup
+ * Kill all DHCP daemons currently running, done at startup.
  *
  */
 void nm_system_kill_all_dhcp_daemons (void)
 {
-	nm_spawn_process ("/usr/bin/killall -q dhcpcd");
 }
 
+
 /*
  * nm_system_update_dns
  *
- * Make glibc/nscd aware of any changes to the resolv.conf file by
- * restarting nscd. Only restart if already running.
+ * Invalidate the nscd host cache, if it exists, since
+ * we changed resolv.conf.
  *
  */
 void nm_system_update_dns (void)
 {
-	if(nm_spawn_process ("/etc/init.d/nscd status"))
+#ifdef NM_NO_NAMED
+	if (nm_spawn_process ("/etc/init.d/nscd status") != 0)
 		nm_spawn_process ("/etc/init.d/nscd restart");
+
+	nm_info ("Clearing nscd hosts cache.");
+	nm_spawn_process ("/usr/sbin/nscd -i hosts");
+#else
+	nm_spawn_process ("/usr/bin/killall -q nscd");
+#endif
 }
 
+
 /*
  * nm_system_load_device_modules
  *
- * Loads any network adapter kernel modules, these should already be loaded
- * by /etc/modules.autoload.d/kernel-2.x
+ * Gentoo should have all modules loaded.
  *
  */
 void nm_system_load_device_modules (void)
@@ -208,7 +272,6 @@
 }
 
 
-
 /*
  * nm_system_restart_mdns_responder
  *
@@ -218,6 +281,9 @@
  */
 void nm_system_restart_mdns_responder (void)
 {
+	nm_spawn_process ("/etc/init.d/mDNSResponder stop");
+	nm_spawn_process ("/etc/init.d/mDNSResponder zap");
+	nm_spawn_process ("/etc/init.d/mDNSResponder start");
 }
 
 
@@ -229,173 +295,241 @@
  */
 void nm_system_device_add_ip6_link_address (NMDevice *dev)
 {
+	char *buf;
+	char	*addr;
+	struct ether_addr hw_addr;
+	unsigned char eui[8];
+
+	nm_device_get_hw_address(dev, &hw_addr);
+
+	memcpy (eui, &(hw_addr.ether_addr_octet), sizeof (hw_addr.ether_addr_octet));
+	memmove (eui+5, eui+3, 3);
+	eui[3] = 0xff;
+	eui[4] = 0xfe;
+	eui[0] ^= 2;
+
+	/* Add the default link-local IPv6 address to a device */
+	buf = g_strdup_printf ("/sbin/ip -6 address add fe80::%x%02x:%x%02x:%x%02x:%x%02x/64 dev %s",
+						eui[0], eui[1], eui[2], eui[3], eui[4], eui[5],
+						eui[6], eui[7], nm_device_get_iface (dev));
+	nm_spawn_process (buf);
+	g_free (buf);
 }
 
 
+typedef struct GentooSystemConfigData
+{
+	NMIP4Config *	config;
+	gboolean		use_dhcp;
+} GentooSystemConfigData;
+
 /*
- * nm_system_device_update_config_info
+ * nm_system_device_get_system_config
+ *
+ * Read in the config file for a device.
  *
- * Retrieve any relevant configuration info for a particular device
- * from the system network configuration information.  Clear out existing
- * info before setting stuff too.
- *
- */
-void nm_system_device_update_config_info (NMDevice *dev)
-{
-	char		*cfg_file_path = NULL;
-	FILE		*file = NULL;
-	char		 buffer[100];
-	char		 confline[100], dhcpline[100], ipline[100];
-	int		 ipa, ipb, ipc, ipd;
- 	int		 nNext =  0, bNext = 0, count = 0;
-	char		*confToken;
-	gboolean	 data_good = FALSE;
-	gboolean	 use_dhcp = TRUE;
-	guint32	 ip4_address = 0;
-	guint32	 ip4_netmask = 0;
-	guint32	 ip4_gateway = 0;
-	guint32	 ip4_broadcast = 0;
+ */
+void *nm_system_device_get_system_config (NMDevice *dev)
+{
+	char *				iface = NULL;
+	char *				buf = NULL;
+	char **				strv = NULL;
+	char *				error = NULL;
+	int				i;
 
-	g_return_if_fail (dev != NULL);
+	in_addr_t			ip;
 
-	/* We use DHCP on an interface unless told not to */
-	nm_device_config_set_use_dhcp (dev, TRUE);
-	nm_device_config_set_ip4_address (dev, 0);
-	nm_device_config_set_ip4_gateway (dev, 0);
-	nm_device_config_set_ip4_netmask (dev, 0);
+	GentooSystemConfigData *	sys_data = NULL;
+	shvarFile *			file;
 
-	/* Gentoo systems store this information in
-	 * /etc/conf.d/net, this is for all interfaces.
+	g_return_val_if_fail (dev != NULL, NULL);
+
+	/* Gentoo systems store this information in /etc/conf.d/net
 	 */
 
-	cfg_file_path = g_strdup_printf ("/etc/conf.d/net");
-	if (!cfg_file_path)
-		return;
+	sys_data = g_malloc0 (sizeof (GentooSystemConfigData));
+	sys_data->use_dhcp = TRUE;
 
-	if (!(file = fopen (cfg_file_path, "r")))
-	{
-		g_free (cfg_file_path);
-		return;
-	}
- 	sprintf(confline, "iface_%s", nm_device_get_iface (dev));
- 	sprintf(dhcpline, "iface_%s=\"dhcp\"", nm_device_get_iface (dev));
-	while (fgets (buffer, 499, file) && !feof (file))
+	iface = g_strdup_printf ("iface_%s", nm_device_get_iface (dev));
+	if (!iface)
+		return sys_data;
+
+	if (!(file = svNewFile (SYSCONFDIR "/conf.d/net")))
+		return sys_data;
+
+	buf = svGetValue (file, iface);
+	g_free (iface);
+	if (!buf)
+		return sys_data;
+
+	if (strcasecmp (buf, "dhcp"))
+		sys_data->use_dhcp = FALSE;
+
+	sys_data->config = nm_ip4_config_new ();
+
+	if (!(sys_data->use_dhcp))
 	{
-		/* Kock off newline if any */
-		g_strstrip (buffer);
 
-		if (strncmp (buffer, confline, strlen(confline)) == 0)
-			{
-			/* Make sure this config file is for this device */
-			if (strncmp (&buffer[strlen(confline) - strlen(nm_device_get_iface (dev))], 
-				nm_device_get_iface (dev), strlen(nm_device_get_iface (dev))) != 0)
-				{
-				nm_warning ("System config file '%s' does not define device '%s'\n",
-                                             cfg_file_path, nm_device_get_iface (dev));
-				break;
-			}
-			else
-				data_good = TRUE;
+		strv = g_strsplit(buf, " ", 0);
+		if (g_strv_length(strv) < 5)
+		{
+			error = "length";
+			goto out;
+		}
+
+		/* Set address */
+		if (!inet_aton(strv[0], &ip))
+		{
+			error = "address";
+			goto out;
+		}
+		nm_ip4_config_set_address (sys_data->config, ip);
+
+		/* Set netmask */
+		for (i=1 ; *(strv + i) ; i++)
+		{
+			/* if a netmask is listed, use it.  otherwise generate one */
+			if (!strcmp(*(strv + i), "netmask") && *(strv + ++i) && inet_aton(*(strv + i), &ip))
+				nm_ip4_config_set_netmask (sys_data->config, ip);
 
-			if (strncmp (buffer, dhcpline, strlen(dhcpline)) == 0)
-			{
-				use_dhcp = TRUE;
-			}
 			else
 			{
-				use_dhcp = FALSE;
-				confToken = strtok(&buffer[strlen(confline) + 2], " ");
-				while (count < 3)
-					{
-					if (nNext == 1 && bNext == 1)
-					{
-						ip4_address = inet_addr (confToken);
-						count++;
-						continue;
-					}
-					if (strcmp(confToken, "netmask") == 0)
-					{
-						confToken = strtok(NULL, " ");
-						ip4_netmask = inet_addr (confToken);
-						count++;
-						nNext = 1;
-					}
-					else if (strcmp(confToken, "broadcast") == 0)
-					{
-						confToken = strtok(NULL, " ");
-						count++;
-						bNext = 1;
-					}
-					else
-					{
-						ip4_address = inet_addr (confToken);
-						count++;
-					}
-						confToken = strtok(NULL, " ");
-					}
-				}
+				guint32	addr = nm_ip4_config_get_address (sys_data->config);
+
+				/* Make a default netmask if we have an IP address */
+				if (((ntohl (addr) & 0xFF000000) >> 24) <= 127)
+					nm_ip4_config_set_netmask (sys_data->config, htonl (0xFF000000));
+				else if (((ntohl (addr) & 0xFF000000) >> 24) <= 191)
+					nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFF0000));
+				else
+					nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFFFF00));
 			}
-		/* If we aren't using dhcp, then try to get the gateway */
-		if (!use_dhcp)
-			{
-			sprintf(ipline, "gateway=\"%s/", nm_device_get_iface (dev));
-			if (strncmp(buffer, ipline, strlen(ipline) - 1) == 0)
+		}
+
+		/* Set broadcast */
+		for (i=1 ; *(strv + i) ; i++)
+		{
+			/* if a broadcast is listed, use it.  otherwise generate one */
+			if (!strcmp(*(strv + i), "broadcast") && *(strv + ++i) && inet_aton(*(strv + i), &ip))
+				nm_ip4_config_set_broadcast (sys_data->config, ip);
+			else
 			{
-				sprintf(ipline, "gateway=\"%s/%%d.%%d.%%d.%%d\"", nm_device_get_iface (dev) );
-				sscanf(buffer, ipline, &ipa, &ipb, &ipc, &ipd);
-				sprintf(ipline, "%d.%d.%d.%d", ipa, ipb, ipc, ipd);
-				ip4_gateway = inet_addr (ipline);
+				guint32 broadcast   =   ((nm_ip4_config_get_address (sys_data->config) 
+							& nm_ip4_config_get_netmask (sys_data->config))
+							| ~nm_ip4_config_get_netmask (sys_data->config));
+				nm_ip4_config_set_broadcast (sys_data->config, broadcast);
 			}
-		}		
+		}
+
+		/* Set gateway */
+		if (buf) g_free (buf);
+		buf = svGetValue (file, "gateway");
+		if (!buf)
+		{
+			error = "gateway";
+			goto out;
+		}
+		g_strfreev(strv);
+		strv = g_strsplit(buf, " ", 0);
+		for (i=0 ; *(strv + i) ; i++)
+		{
+			/* If we have a valid gateway, use it. otherwise error */
+			if (!strncmp(*(strv + i), nm_device_get_iface (dev), strlen (nm_device_get_iface (dev))) &&
+					inet_aton (*(strv + i) + strlen (nm_device_get_iface (dev)) + 1, &ip))
+				nm_ip4_config_set_gateway (sys_data->config, ip);
+		}
+		if (!nm_ip4_config_get_gateway (sys_data->config))
+		{
+				error = "gateway";
+				goto out;
+		}
 	}
-	fclose (file);
-	g_free (cfg_file_path);
- 
-	/* If successful, set values on the device */
-	if (data_good)
+	
+
+#if 0
+	nm_debug ("------ Config (%s)", nm_device_get_iface (dev));
+	nm_debug ("    DHCP=%d\n", sys_data->use_dhcp);
+	nm_debug ("    ADDR=%d\n", nm_ip4_config_get_address (sys_data->config));
+	nm_debug ("    GW=%d\n", nm_ip4_config_get_gateway (sys_data->config));
+	nm_debug ("    NM=%d\n", nm_ip4_config_get_netmask (sys_data->config));
+	nm_debug ("---------------------\n");
+#endif
+
+out:
+	svCloseFile (file);
+
+	if (buf)
+		g_free (buf);
+	if (strv)
+		g_strfreev (strv);
+
+	if (error)
 	{
-		nm_device_config_set_use_dhcp (dev, use_dhcp);
-		if (ip4_address)
-			nm_device_config_set_ip4_address (dev, ip4_address);
-		if (ip4_gateway)
-			nm_device_config_set_ip4_gateway (dev, ip4_gateway);
-		if (ip4_netmask)
-			nm_device_config_set_ip4_netmask (dev, ip4_netmask);
-		if (ip4_broadcast)
-			nm_device_config_set_ip4_broadcast (dev, ip4_broadcast);
+
+		sys_data->use_dhcp = TRUE;
+
+		nm_warning ("Network configuration for device '%s' was invalid (invalid %s). "
+			"Will use DHCP instead.", nm_device_get_iface (dev), error);
+
+		/* Clear out the config */
+		nm_ip4_config_unref (sys_data->config);
+		sys_data->config = NULL;
 	}
+
+	return (void *)sys_data;
 }
 
+
 /*
- * nm_system_device_add_default_route_via_device
+ * nm_system_device_free_system_config
  *
- * Flush all routes associated with a network device
+ * Free stored system config data
  *
  */
-void nm_system_device_add_default_route_via_device (NMDevice *dev)
+void nm_system_device_free_system_config (NMDevice *dev, void *system_config_data)
 {
+	GentooSystemConfigData *sys_data = (GentooSystemConfigData *)system_config_data;
+
+	g_return_if_fail (dev != NULL);
+
+	if (!sys_data)
+		return;
+
+	if (sys_data->config)
+		nm_ip4_config_unref (sys_data->config);
 }
- 
- 
+
+
 /*
- * nm_system_flush_loopback_routes
+ * nm_system_device_get_use_dhcp
  *
- * Flush all routes associated with the loopback device, because it
- * sometimes gets the first route for ZeroConf/Link-Local traffic.
+ * Return whether the distro-specific system config tells us to use
+ * dhcp for this device.
  *
  */
-void nm_system_flush_loopback_routes (void)
+gboolean nm_system_device_get_use_dhcp (NMDevice *dev)
 {
+	GentooSystemConfigData	*sys_data;
+
+	g_return_val_if_fail (dev != NULL, TRUE);
+
+	if ((sys_data = nm_device_get_system_config_data (dev)))
+		return sys_data->use_dhcp;
+
+	return TRUE;
 }
 
- 
-/*
- * nm_system_flush_arp_cache
- *
- * Flush all entries in the arp cache.
- *
- */
-void nm_system_flush_arp_cache (void)
+
+NMIP4Config *nm_system_device_new_ip4_system_config (NMDevice *dev)
 {
+	GentooSystemConfigData	*sys_data;
+	NMIP4Config		*new_config = NULL;
+
+	g_return_val_if_fail (dev != NULL, NULL);
+
+	if ((sys_data = nm_device_get_system_config_data (dev)))
+		new_config = nm_ip4_config_copy (sys_data->config);
+
+	return new_config;
 }
 


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