]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove gateways from the ROUTES and add to GATEWAYS
authorRoy Marples <roy@marples.name>
Sun, 15 Apr 2007 17:51:04 +0000 (17:51 +0000)
committerRoy Marples <roy@marples.name>
Sun, 15 Apr 2007 17:51:04 +0000 (17:51 +0000)
define #INFO_COMPAT if you wish your .info file to add support for some
old 1.x and 2.x structure.

ChangeLog
configure.c
configure.h

index bfc5316b4d36b280d5f3fa81d44464128da8055f..e50c038d78d721b2e5991a692f2dc88812a791f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 :/
index c539e9d719aea5f4940ff2c47e2724b3b7a04b76..26bd090ba8d152a1112e2a2dbccc450b5faadcc6 100644 (file)
@@ -373,13 +373,29 @@ static int write_info(const interface_t *iface, const dhcp_t *dhcp,
                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 @@ static int write_info(const interface_t *iface, const dhcp_t *dhcp,
        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;
 }
index 1daa07d38a5843e7865f03a2554c05d48358d1d4..99e62c9de00a2114147b8353c14220d499f1f9fc 100644 (file)
@@ -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"