dhcpv4: move and rename handle_dhcpv4()
authorDavid Härdeman <[email protected]>
Wed, 24 Sep 2025 13:00:57 +0000 (15:00 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Fri, 3 Oct 2025 10:53:36 +0000 (12:53 +0200)
Move handle_dhcpv4() below the function it calls (dhcpv4_handle_msg()) and
rename it to dhcpv4_handle_dgram() for consistency with other function names.

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 b63104c865e4994ab178251efdcde40fe82c9e21..f52d8159ea0a7606a2ffdd4b99dc96524c3cf277 100644 (file)
@@ -325,15 +325,6 @@ static int dhcpv4_send_reply(const void *buf, size_t len,
        return sendto(*sock, buf, len, MSG_DONTWAIT, dest, dest_len);
 }
 
-/* Handler for DHCPv4 messages */
-static void handle_dhcpv4(void *addr, void *data, size_t len,
-               struct interface *iface, _unused void *dest_addr)
-{
-       int sock = iface->dhcpv4_event.uloop.fd;
-
-       dhcpv4_handle_msg(addr, data, len, iface, dest_addr, dhcpv4_send_reply, &sock);
-}
-
 /* DNR */
 struct dhcpv4_dnr {
        uint16_t len;
@@ -726,6 +717,15 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len,
 #endif
 }
 
+/* Handler for DHCPv4 messages */
+static void dhcpv4_handle_dgram(void *addr, void *data, size_t len,
+                               struct interface *iface, _unused void *dest_addr)
+{
+       int sock = iface->dhcpv4_event.uloop.fd;
+
+       dhcpv4_handle_msg(addr, data, len, iface, dest_addr, dhcpv4_send_reply, &sock);
+}
+
 static bool dhcpv4_insert_assignment(struct list_head *list, struct dhcp_assignment *a,
                                     uint32_t addr)
 {
@@ -1138,7 +1138,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable)
                        goto out;
                }
 
-               iface->dhcpv4_event.handle_dgram = handle_dhcpv4;
+               iface->dhcpv4_event.handle_dgram = dhcpv4_handle_dgram;
                odhcpd_register(&iface->dhcpv4_event);
        } else {
                while (!list_empty(&iface->dhcpv4_assignments))