]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-client: move the object definition to the header
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 18 Mar 2026 10:26:22 +0000 (19:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Apr 2026 22:40:07 +0000 (07:40 +0900)
Then, we can split the long sd-dhcp-client.c into small pieces later.

This also drops redundant typedef, which is also in sd-dhcp-client.h.

src/libsystemd-network/dhcp-client-internal.h
src/libsystemd-network/sd-dhcp-client.c

index f75ca71b4350c2bd8f1d814e3818609e1c0e6f24..07e61b0d760e111d5d437c18b9d9a908a2d0ee80 100644 (file)
@@ -3,8 +3,11 @@
 
 #include "sd-dhcp-client.h"
 
-#include "sd-forward.h"
+#include "dhcp-client-id-internal.h"
+#include "ether-addr-util.h"
 #include "network-common.h"
+#include "sd-forward.h"
+#include "socket-util.h"
 
 typedef enum DHCPState {
         DHCP_STATE_STOPPED,
@@ -22,7 +25,67 @@ typedef enum DHCPState {
 
 DECLARE_STRING_TABLE_LOOKUP_TO_STRING(dhcp_state, DHCPState);
 
-typedef struct sd_dhcp_client sd_dhcp_client;
+struct sd_dhcp_client {
+        unsigned n_ref;
+
+        DHCPState state;
+        sd_event *event;
+        int event_priority;
+        sd_event_source *timeout_resend;
+
+        int ifindex;
+        char *ifname;
+
+        sd_device *dev;
+
+        int fd;
+        uint16_t port;
+        uint16_t server_port;
+        union sockaddr_union link;
+        sd_event_source *receive_message;
+        bool request_broadcast;
+        Set *req_opts;
+        bool anonymize;
+        bool rapid_commit;
+        be32_t last_addr;
+        struct hw_addr_data hw_addr;
+        struct hw_addr_data bcast_addr;
+        uint16_t arp_type;
+        sd_dhcp_client_id client_id;
+        char *hostname;
+        char *vendor_class_identifier;
+        char *mudurl;
+        char **user_class;
+        uint32_t mtu;
+        usec_t fallback_lease_lifetime;
+        uint32_t xid;
+        usec_t start_time;
+        usec_t t1_time;
+        usec_t t2_time;
+        usec_t expire_time;
+        uint64_t discover_attempt;
+        uint64_t request_attempt;
+        uint64_t max_discover_attempts;
+        uint64_t max_request_attempts;
+        OrderedHashmap *extra_options;
+        OrderedHashmap *vendor_options;
+        sd_event_source *timeout_t1;
+        sd_event_source *timeout_t2;
+        sd_event_source *timeout_expire;
+        sd_event_source *timeout_ipv6_only_mode;
+        sd_dhcp_client_callback_t callback;
+        void *userdata;
+        sd_dhcp_client_callback_t state_callback;
+        void *state_userdata;
+        sd_dhcp_lease *lease;
+        usec_t start_delay;
+        int ip_service_type;
+        int socket_priority;
+        bool socket_priority_set;
+        bool ipv6_acquired;
+        bool bootp;
+        bool send_release;
+};
 
 int dhcp_client_set_state_callback(
                 sd_dhcp_client *client,
index 19f85e09df945596ad9242e282b06f307909e324..c530e6c222666a6216ef67f82d1b72ffd276e5ed 100644 (file)
@@ -7,11 +7,8 @@
 #include <net/if_arp.h>
 #include <stdio.h>
 
-#include "sd-dhcp-client.h"
-
 #include "alloc-util.h"
 #include "device-util.h"
-#include "dhcp-client-id-internal.h"
 #include "dhcp-client-internal.h"
 #include "dhcp-lease-internal.h"
 #include "dhcp-network.h"
@@ -19,7 +16,6 @@
 #include "dhcp-packet.h"
 #include "dns-domain.h"
 #include "errno-util.h"
-#include "ether-addr-util.h"
 #include "event-util.h"
 #include "fd-util.h"
 #include "hostname-util.h"
@@ -28,7 +24,6 @@
 #include "network-common.h"
 #include "random-util.h"
 #include "set.h"
-#include "socket-util.h"
 #include "sort-util.h"
 #include "string-table.h"
 #include "string-util.h"
 #define TRANSIENT_FAILURE_ATTEMPTS 3 /* Arbitrary limit: how many attempts are considered enough to report
                                       * transient failure. */
 
-struct sd_dhcp_client {
-        unsigned n_ref;
-
-        DHCPState state;
-        sd_event *event;
-        int event_priority;
-        sd_event_source *timeout_resend;
-
-        int ifindex;
-        char *ifname;
-
-        sd_device *dev;
-
-        int fd;
-        uint16_t port;
-        uint16_t server_port;
-        union sockaddr_union link;
-        sd_event_source *receive_message;
-        bool request_broadcast;
-        Set *req_opts;
-        bool anonymize;
-        bool rapid_commit;
-        be32_t last_addr;
-        struct hw_addr_data hw_addr;
-        struct hw_addr_data bcast_addr;
-        uint16_t arp_type;
-        sd_dhcp_client_id client_id;
-        char *hostname;
-        char *vendor_class_identifier;
-        char *mudurl;
-        char **user_class;
-        uint32_t mtu;
-        usec_t fallback_lease_lifetime;
-        uint32_t xid;
-        usec_t start_time;
-        usec_t t1_time;
-        usec_t t2_time;
-        usec_t expire_time;
-        uint64_t discover_attempt;
-        uint64_t request_attempt;
-        uint64_t max_discover_attempts;
-        uint64_t max_request_attempts;
-        OrderedHashmap *extra_options;
-        OrderedHashmap *vendor_options;
-        sd_event_source *timeout_t1;
-        sd_event_source *timeout_t2;
-        sd_event_source *timeout_expire;
-        sd_event_source *timeout_ipv6_only_mode;
-        sd_dhcp_client_callback_t callback;
-        void *userdata;
-        sd_dhcp_client_callback_t state_callback;
-        void *state_userdata;
-        sd_dhcp_lease *lease;
-        usec_t start_delay;
-        int ip_service_type;
-        int socket_priority;
-        bool socket_priority_set;
-        bool ipv6_acquired;
-        bool bootp;
-        bool send_release;
-};
-
 static const uint8_t default_req_opts[] = {
         SD_DHCP_OPTION_SUBNET_MASK,
         SD_DHCP_OPTION_ROUTER,