X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=src%2Fdhcpv6-ia.c;h=b0a0adadf32630b66f730bd7fe550f170ae06899;hb=700f5abbeff4e3dcc0f6b12d4883315e2cfb9b74;hp=e8b6e9fa07dae4dda39e1fb60c033e7506ad24e8;hpb=e05553099c47b92420c21ff30b07709dfa40a84a;p=project%2Fodhcpd.git diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index e8b6e9f..b0a0ada 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -1,5 +1,6 @@ /** * Copyright (C) 2013 Steven Barth + * Copyright (C) 2016 Hans Dedecker * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License v2 as published by @@ -114,6 +115,8 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable) odhcpd_urandom(a->key, sizeof(a->key)); memcpy(a->clid_data, lease->duid, lease->duid_len); memcpy(a->mac, lease->mac.ether_addr_octet, sizeof(a->mac)); + /* Static assignment */ + a->flags |= OAF_STATIC; /* Infinite valid */ a->valid_until = 0; @@ -322,7 +325,7 @@ void dhcpv6_write_statefile(void) struct in_addr addr = {htonl(c->addr)}; inet_ntop(AF_INET, &addr, ipbuf, sizeof(ipbuf) - 1); - if (c->hostname[0]) { + if (c->hostname) { fputs(ipbuf, fp); char b[256]; @@ -1130,7 +1133,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, if (assigned && hdr->msg_type == DHCPV6_MSG_SOLICIT) { a->flags &= ~OAF_BOUND; - if (!INFINITE_VALID(a->valid_until)) + if (!(a->flags & OAF_STATIC)) a->valid_until = now; } else if (assigned && hdr->msg_type == DHCPV6_MSG_REQUEST) { if (hostname_len > 0) { @@ -1161,7 +1164,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, apply_lease(iface, a, true); } } else if (hdr->msg_type == DHCPV6_MSG_RELEASE) { - if (!INFINITE_VALID(a->valid_until)) + if (!(a->flags & OAF_STATIC)) a->valid_until = now - 1; a->flags &= ~OAF_BOUND; @@ -1169,7 +1172,7 @@ ssize_t dhcpv6_handle_ia(uint8_t *buf, size_t buflen, struct interface *iface, } else if (hdr->msg_type == DHCPV6_MSG_DECLINE && a->length == 128) { a->flags &= ~OAF_BOUND; - if (!INFINITE_VALID(a->valid_until)) { + if (!(a->flags & OAF_STATIC)) { a->clid_len = 0; a->valid_until = now + 3600; // Block address for 1h }