changeset 98:f1c783988dd2 draft

Remove gateways from the ROUTES and add to GATEWAYS define #INFO_COMPAT if you wish your .info file to add support for some old 1.x and 2.x structure.
author Roy Marples <roy@marples.name>
date Sun, 15 Apr 2007 17:51:04 +0000
parents f1ba63faf6ca
children 8814440c9675
files ChangeLog configure.c configure.h
diffstat 3 files changed, 56 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 14 07:53:33 2007 +0000
+++ b/ChangeLog	Sun Apr 15 17:51:04 2007 +0000
@@ -1,3 +1,7 @@
+Remove gateways from the ROUTES and add to GATEWAYS
+define #INFO_COMPAT if you wish your .info file to add support for some
+old 1.x and 2.x structure.
+
 dhcpcd-3.0.17
 Minimum message size is now 300 bytes for crappy DHCP servers who think
 they have to obey the BOOTP minimum message size :/
--- a/configure.c	Sat Apr 14 07:53:33 2007 +0000
+++ b/configure.c	Sun Apr 15 17:51:04 2007 +0000
@@ -373,13 +373,29 @@
 		fprintf (f, "MTU='%d'\n", dhcp->mtu);
 
 	if (dhcp->routes) {
+		bool doneone = false;
 		fprintf (f, "ROUTES='");
 		for (route = dhcp->routes; route; route = route->next) {
-			fprintf (f, "%s", inet_ntoa (route->destination));
-			fprintf (f, ",%s", inet_ntoa (route->netmask));
-			fprintf (f, ",%s", inet_ntoa (route->gateway));
-			if (route->next)
-				fprintf (f, " ");
+			if (route->destination.s_addr != 0) {
+				if (doneone)
+					fprintf (f, " ");
+				fprintf (f, "%s", inet_ntoa (route->destination));
+				fprintf (f, ",%s", inet_ntoa (route->netmask));
+				fprintf (f, ",%s", inet_ntoa (route->gateway));
+				doneone = true;
+			}
+		}
+		fprintf (f, "'\n");
+
+		doneone = false;
+		fprintf (f, "GATEWAYS='");
+		for (route = dhcp->routes; route; route = route->next) {
+			if (route->destination.s_addr == 0) {
+				if (doneone)
+					fprintf (f, " ");
+				fprintf (f, "%s", inet_ntoa (route->gateway));
+				doneone = true;
+			}
 		}
 		fprintf (f, "'\n");
 	}
@@ -448,6 +464,34 @@
 	else
 		fprintf (f, "CLIENTID='%s'\n", hwaddr_ntoa (iface->hwaddr, iface->hwlen));
 	fprintf (f, "DHCPCHADDR='%s'\n", hwaddr_ntoa (iface->hwaddr, iface->hwlen));
+
+#ifdef INFO_COMPAT
+	/* Support the old .info settings if we need to */
+	if (dhcp->dnsservers) {
+		fprintf (f, "DNS='");
+		for (address = dhcp->dnsservers; address; address = address->next) {
+			fprintf (f, "%s", inet_ntoa (address->address));
+			if (address->next)
+				fprintf (f, ",");
+		}
+		fprintf (f, "'\n");
+	}
+
+	if (dhcp->routes) {
+		bool doneone = false;
+		fprintf (f, "GATEWAY='");
+		for (route = dhcp->routes; route; route = route->next) {
+			if (route->destination.s_addr == 0) {
+				if (doneone)
+					fprintf (f, ",");
+				fprintf (f, "%s", inet_ntoa (route->gateway));
+				doneone = true;
+			}
+		}
+		fprintf (f, "'\n");
+	}
+#endif
+	
 	fclose (f);
 	return 0;
 }
--- a/configure.h	Sat Apr 14 07:53:33 2007 +0000
+++ b/configure.h	Sun Apr 15 17:51:04 2007 +0000
@@ -29,6 +29,9 @@
 #define ENABLE_NIS
 #define ENABLE_INFO
 
+/* Define this to enable some compatability with 1.x and 2.x info files */
+// #define INFO_COMPAT
+
 #include "dhcpcd.h"
 #include "interface.h"
 #include "dhcp.h"