dhcpv4: move find_assignment_by_hwaddr()
authorDavid Härdeman <[email protected]>
Wed, 24 Sep 2025 13:38:12 +0000 (15:38 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Fri, 3 Oct 2025 10:54:06 +0000 (12:54 +0200)
Move find_assignment_by_hwaddr() down to just before the sole user
(dhcpv4_lease()).

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/264
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv4.c

index 2c6416b19d2f6b4aa0202d666b0c8a2ffe9091d6..a09c4609f7a0b814eec3c58d0df2c231c91b432a 100644 (file)
@@ -50,17 +50,6 @@ struct odhcpd_ref_ip {
        struct odhcpd_ipaddr addr;
 };
 
-static struct dhcp_assignment *find_assignment_by_hwaddr(struct interface *iface, const uint8_t *hwaddr)
-{
-       struct dhcp_assignment *a;
-
-       list_for_each_entry(a, &iface->dhcpv4_assignments, head)
-               if (!memcmp(a->hwaddr, hwaddr, 6))
-                       return a;
-
-       return NULL;
-}
-
 static void inc_ref_cnt_ip(struct odhcpd_ref_ip **ptr, struct odhcpd_ref_ip *ip)
 {
        *ptr = ip;
@@ -400,6 +389,16 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a,
        return false;
 }
 
+static struct dhcp_assignment *find_assignment_by_hwaddr(struct interface *iface, const uint8_t *hwaddr)
+{
+       struct dhcp_assignment *a;
+
+       list_for_each_entry(a, &iface->dhcpv4_assignments, head)
+               if (!memcmp(a->hwaddr, hwaddr, 6))
+                       return a;
+
+       return NULL;
+}
 
 static struct dhcp_assignment*
 dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac,