diff options
| author | Roy Marples <roy@marples.name> | 2009-03-23 22:02:37 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-03-23 22:02:37 +0000 |
| commit | 4a4bcf7cf5fa713dd62912f0c1c7c2e1ef543e4b (patch) | |
| tree | e98d97c8e1e83686cc6ae8c2e956d9fc6c8a6ea9 /configure.c | |
| parent | a43ccb9f89972786e75b2140edf109af72bd8467 (diff) | |
| download | dhcpcd-4a4bcf7cf5fa713dd62912f0c1c7c2e1ef543e4b.tar.xz | |
Improve PTP INFORM support some more.
Diffstat (limited to 'configure.c')
| -rw-r--r-- | configure.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/configure.c b/configure.c index 159f1479..dbb9118d 100644 --- a/configure.c +++ b/configure.c @@ -42,6 +42,7 @@ #include "config.h" #include "common.h" #include "configure.h" +#include "dhcp.h" #include "if-options.h" #include "if-pref.h" #include "net.h" @@ -513,7 +514,8 @@ add_subnet_route(struct rt *rt, const struct interface *iface) } static struct rt * -get_routes(const struct interface *iface) { +get_routes(const struct interface *iface) +{ struct rt *rt, *nrt = NULL, *r = NULL; if (iface->state->options->routes != NULL) { @@ -538,6 +540,22 @@ get_routes(const struct interface *iface) { return get_option_routes(iface->state->new); } +static struct rt * +add_destination_route(struct rt *rt, const struct interface *iface) +{ + struct rt *r; + + if (!(iface->flags & IFF_POINTOPOINT) || + !has_option_mask(iface->state->options->dstmask, DHO_ROUTER)) + return rt; + r = xmalloc(sizeof(*r)); + r->dest.s_addr = INADDR_ANY; + r->net.s_addr = INADDR_ANY; + r->gate.s_addr = iface->dst.s_addr; + r->next = rt; + return r; +} + void build_routes(void) { @@ -549,6 +567,7 @@ build_routes(void) continue; dnr = get_routes(ifp); dnr = add_subnet_route(dnr, ifp); + dnr = add_destination_route(dnr, ifp); for (rt = dnr; rt && (rtn = rt->next, 1); lrt = rt, rt = rtn) { rt->iface = ifp; /* Is this route already in our table? */ @@ -618,6 +637,7 @@ configure(struct interface *iface) { struct dhcp_message *dhcp = iface->state->new; struct dhcp_lease *lease = &iface->state->lease; + struct if_options *ifo = iface->state->options; struct rt *rt; /* As we are now adjusting an interface, we need to ensure @@ -633,7 +653,7 @@ configure(struct interface *iface) } /* This also changes netmask */ - if (!(iface->state->options->options & DHCPCD_INFORM) || + if (!(ifo->options & DHCPCD_INFORM) || !has_address(iface->name, &lease->addr, &lease->net)) { syslog(LOG_DEBUG, "%s: adding IP address %s/%d", @@ -668,7 +688,7 @@ configure(struct interface *iface) build_routes(); if (!iface->state->lease.frominfo && - !(iface->state->options->options & DHCPCD_INFORM)) + !(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))) if (write_lease(iface, dhcp) == -1) syslog(LOG_ERR, "write_lease: %m"); run_script(iface); |
