+static bool dhcpv4_insert_assignment(struct list_head *list, struct dhcp_assignment *a,
+ uint32_t addr)
+{
+ uint32_t h_addr = ntohl(addr);
+ struct dhcp_assignment *c;
+
+ list_for_each_entry(c, list, head) {
+ uint32_t c_addr = ntohl(c->addr);
+
+ if (c_addr == h_addr)
+ return false;
+
+ if (c_addr > h_addr)
+ break;
+ }
+
+ /* Insert new node before c (might match list head) */
+ a->addr = addr;
+ list_add_tail(&a->head, &c->head);
+
+ return true;
+}
+
+static char* ip4toa(uint32_t addr)
+{
+ static char buf[16];
+
+ snprintf(buf, sizeof(buf), "%u.%u.%u.%u",
+ ((uint8_t *)&addr)[0], ((uint8_t *)&addr)[1],
+ ((uint8_t *)&addr)[2], ((uint8_t *)&addr)[3]);
+
+ return buf;
+}
+