diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-06-29 15:35:21 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-07-03 11:32:53 +0200 |
commit | 18df6cca092743a07be8e0f05d0a9ef941957b66 (patch) | |
tree | f438a10bde79dc55de8f0dee53bf70276ed82a4e /src/dhcpv6-ia.c | |
parent | 803b83ec64d6f77262b378b83af0a9d84da68c49 (diff) |
treewide: rework logic to retrieve IPv6 interface addresses
Retrieve IPv6 interface addresses when the interface gets created; this
allows to get rid of the IPv6 address dump logic in ndp.c.
Add IPv4 address support in odhcp_ipaddr struct.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv6-ia.c')
-rw-r--r-- | src/dhcpv6-ia.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index c2221d8..502373f 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -248,7 +248,7 @@ void dhcpv6_enum_ia_addrs(struct interface *iface, struct dhcpv6_assignment *c, if (!valid_addr(&addrs[i], now)) continue; - addr = addrs[i].addr; + addr = addrs[i].addr.in6; pref = addrs[i].preferred; valid = addrs[i].valid; if (prefix == 128) { @@ -444,7 +444,7 @@ static void apply_lease(struct interface *iface, struct dhcpv6_assignment *a, bo size_t addrlen = (a->managed) ? (size_t)a->managed_size : iface->ia_addr_len; for (size_t i = 0; i < addrlen; ++i) { - struct in6_addr prefix = addrs[i].addr; + struct in6_addr prefix = addrs[i].addr.in6; prefix.s6_addr32[1] |= htonl(a->assigned); prefix.s6_addr32[2] = prefix.s6_addr32[3] = 0; odhcpd_setup_route(&prefix, (a->managed_size) ? addrs[i].prefix : a->length, @@ -661,11 +661,12 @@ void dhcpv6_ia_preupdate(struct interface *iface) apply_lease(iface, c, false); } -void dhcpv6_ia_postupdate(struct interface *iface, time_t now) +void dhcpv6_ia_postupdate(struct interface *iface) { if (iface->dhcpv6 != RELAYD_SERVER) return; + time_t now = odhcpd_time(); int minprefix = -1; for (size_t i = 0; i < iface->ia_addr_len; ++i) { if (iface->ia_addr[i].preferred > (uint32_t)now && @@ -802,7 +803,7 @@ static size_t append_reply(uint8_t *buf, size_t buflen, uint16_t status, .preferred = htonl(prefix_pref), .valid = htonl(prefix_valid), .prefix = (a->managed_size) ? addrs[i].prefix : a->length, - .addr = addrs[i].addr + .addr = addrs[i].addr.in6, }; p.addr.s6_addr32[1] |= htonl(a->assigned); p.addr.s6_addr32[2] = p.addr.s6_addr32[3] = 0; @@ -820,7 +821,7 @@ static size_t append_reply(uint8_t *buf, size_t buflen, uint16_t status, struct dhcpv6_ia_addr n = { .type = htons(DHCPV6_OPT_IA_ADDR), .len = htons(sizeof(n) - 4), - .addr = addrs[i].addr, + .addr = addrs[i].addr.in6, .preferred = htonl(prefix_pref), .valid = htonl(prefix_valid) }; @@ -879,7 +880,7 @@ static size_t append_reply(uint8_t *buf, size_t buflen, uint16_t status, if (!valid_addr(&addrs[i], now)) continue; - struct in6_addr addr = addrs[i].addr; + struct in6_addr addr = addrs[i].addr.in6; if (ia->type == htons(DHCPV6_OPT_IA_PD)) { addr.s6_addr32[1] |= htonl(a->assigned); addr.s6_addr32[2] = addr.s6_addr32[3] = 0; |