From: Roy Marples Date: Sun, 15 Apr 2007 17:51:04 +0000 (+0000) Subject: Remove gateways from the ROUTES and add to GATEWAYS X-Git-Tag: v3.2.3~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c12527eef4e2523b19f5460770d458c952b724cd;p=thirdparty%2Fdhcpcd.git 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. --- diff --git a/ChangeLog b/ChangeLog index bfc5316b..e50c038d 100644 --- 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 :/ diff --git a/configure.c b/configure.c index c539e9d7..26bd090b 100644 --- a/configure.c +++ b/configure.c @@ -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; } diff --git a/configure.h b/configure.h index 1daa07d3..99e62c9d 100644 --- a/configure.h +++ b/configure.h @@ -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"