a->addr = ntohl(lease->ipaddr.s_addr);
memcpy(a->hwaddr, lease->mac.ether_addr_octet, sizeof(a->hwaddr));
memcpy(a->hostname, lease->hostname, hostlen);
+ a->valid_until = LONG_MAX;
// Assign to all interfaces
struct dhcpv4_assignment *c;
list_for_each_entry(c, &iface->dhcpv4_assignments, head) {
if (c->addr > a->addr) {
list_add_tail(&a->head, &c->head);
+ break;
} else if (c->addr == a->addr) {
// Already an assignment with that number
break;
}
}
+ if (&c->head == &iface->dhcpv4_assignments) {
+ list_add(&a->head, &iface->dhcpv4_assignments);
+ }
if (!a->head.next)
free(a);
struct dhcpv4_assignment *a, *n;
list_for_each_entry_safe(a, n, &iface->dhcpv4_assignments, head) {
if ((htonl(a->addr) & smask->sin_addr.s_addr) !=
- (saddr->sin_addr.s_addr & smask->sin_addr.s_addr)) {
+ (iface->dhcpv4_start.s_addr & smask->sin_addr.s_addr)) {
list_del(&a->head);
free(a);
}
struct dhcpv4_assignment *c, *n, *a = NULL;
list_for_each_entry_safe(c, n, &iface->dhcpv4_assignments, head) {
- if (c->addr == raddr && !memcmp(c->hwaddr, mac, 6)) {
+ if (!memcmp(c->hwaddr, mac, 6)) {
a = c;
- break;
+ if (c->addr == raddr)
+ break;
} else if (c->valid_until < now) {
list_del(&c->head);
free(c);