dhcpv6-ia: create assignment for unknown IA in rebind messages
[project/odhcpd.git] / src / ubus.c
index 425abe4..d562c0f 100644 (file)
@@ -51,7 +51,7 @@ static int handle_dhcpv4_leases(struct ubus_context *ctx, _unused struct ubus_ob
                        blobmsg_add_string_buffer(&b);
 
                        blobmsg_add_u32(&b, "valid", INFINITE_VALID(lease->valid_until) ?
-                                               INT32_MAX : (uint32_t)(lease->valid_until - now));
+                                               (uint32_t)-1 : (uint32_t)(lease->valid_until - now));
 
                        blobmsg_close_table(&b, l);
                }
@@ -107,8 +107,10 @@ static int handle_dhcpv6_leases(_unused struct ubus_context *ctx, _unused struct
                                addr = iface->ia_addr[i].addr;
                                if (lease->length == 128)
                                        addr.s6_addr32[3] = htonl(lease->assigned);
-                               else
+                               else {
                                        addr.s6_addr32[1] |= htonl(lease->assigned);
+                                       addr.s6_addr32[2] = addr.s6_addr32[3] = 0;
+                               }
 
                                char *c = blobmsg_alloc_string_buffer(&b, NULL, INET6_ADDRSTRLEN);
                                inet_ntop(AF_INET6, &addr, c, INET6_ADDRSTRLEN);
@@ -117,7 +119,7 @@ static int handle_dhcpv6_leases(_unused struct ubus_context *ctx, _unused struct
                        blobmsg_close_table(&b, m);
 
                        blobmsg_add_u32(&b, "valid", INFINITE_VALID(lease->valid_until) ?
-                                               INT32_MAX : (uint32_t)(lease->valid_until - now));
+                                               (uint32_t)-1 : (uint32_t)(lease->valid_until - now));
 
                        blobmsg_close_table(&b, l);
                }