]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp: move definition of sd_dhcp_route and related functions to dhcp-route.[ch]
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Apr 2026 19:50:05 +0000 (04:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 13 May 2026 00:41:24 +0000 (09:41 +0900)
This also renames arguments for storing results.
No functional change, just refactoring and preparation for later commits.

src/libsystemd-network/dhcp-lease-internal.h
src/libsystemd-network/dhcp-route.c [new file with mode: 0644]
src/libsystemd-network/dhcp-route.h [new file with mode: 0644]
src/libsystemd-network/meson.build
src/libsystemd-network/network-internal.c
src/libsystemd-network/sd-dhcp-lease.c
src/network/test-network.c
src/systemd/sd-dhcp-lease.h

index b436287aeed04909dd5932b2ff510a72f80d2586..bc411a4f36cd3373b96c21c62f4cdf2c716b59c8 100644 (file)
 #include "sd-forward.h"
 #include "list.h"
 
-struct sd_dhcp_route {
-        struct in_addr dst_addr;
-        struct in_addr gw_addr;
-        unsigned char dst_prefixlen;
-};
-
 struct sd_dhcp_raw_option {
         LIST_FIELDS(struct sd_dhcp_raw_option, options);
 
diff --git a/src/libsystemd-network/dhcp-route.c b/src/libsystemd-network/dhcp-route.c
new file mode 100644 (file)
index 0000000..3382827
--- /dev/null
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "sd-dhcp-lease.h"
+
+#include "dhcp-route.h"  /* IWYU pragma: keep */
+
+int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *ret) {
+        assert_return(route, -EINVAL);
+        assert_return(ret, -EINVAL);
+
+        *ret = route->dst_addr;
+        return 0;
+}
+
+int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *ret) {
+        assert_return(route, -EINVAL);
+        assert_return(ret, -EINVAL);
+
+        *ret = route->dst_prefixlen;
+        return 0;
+}
+
+int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *ret) {
+        assert_return(route, -EINVAL);
+        assert_return(ret, -EINVAL);
+
+        *ret = route->gw_addr;
+        return 0;
+}
diff --git a/src/libsystemd-network/dhcp-route.h b/src/libsystemd-network/dhcp-route.h
new file mode 100644 (file)
index 0000000..e313c08
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "sd-forward.h"
+
+#include "in-addr-util.h"  /* IWYU pragma: keep */
+
+struct sd_dhcp_route {
+        struct in_addr dst_addr;
+        struct in_addr gw_addr;
+        uint8_t dst_prefixlen;
+};
index 500882319e63e5eec4066be3751a6644c36a05c0..74e09fac84cb18e6c4b40d6365e05a60ff32676e 100644 (file)
@@ -8,6 +8,7 @@ libsystemd_network_sources = files(
         'dhcp-option.c',
         'dhcp-packet.c',
         'dhcp-protocol.c',
+        'dhcp-route.c',
         'dhcp6-network.c',
         'dhcp6-option.c',
         'dhcp6-protocol.c',
index c1eaa361afa0d5e5cf87ffca63c40fe722310db5..cc29d9fd1b14e41865d79ca886aadd02b640f922 100644 (file)
@@ -3,8 +3,10 @@
 #include <arpa/inet.h>
 #include <stdio.h>
 
+#include "sd-dhcp-lease.h"
+
 #include "alloc-util.h"
-#include "dhcp-lease-internal.h"
+#include "dhcp-route.h"
 #include "dns-resolver-internal.h"
 #include "extract-word.h"
 #include "hexdecoct.h"
index bfe4874be5a5f265473881e2fd644d58ac81727f..8003f37fd3122a7a4a641bace8c353218f9e9f62 100644 (file)
@@ -11,6 +11,7 @@
 #include "alloc-util.h"
 #include "dhcp-lease-internal.h"
 #include "dhcp-option.h"
+#include "dhcp-route.h"
 #include "dns-def.h"
 #include "dns-domain.h"
 #include "dns-resolver-internal.h"
@@ -1802,27 +1803,3 @@ int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **ret) {
         *ret = lease->timezone;
         return 0;
 }
-
-int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination) {
-        assert_return(route, -EINVAL);
-        assert_return(destination, -EINVAL);
-
-        *destination = route->dst_addr;
-        return 0;
-}
-
-int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length) {
-        assert_return(route, -EINVAL);
-        assert_return(length, -EINVAL);
-
-        *length = route->dst_prefixlen;
-        return 0;
-}
-
-int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway) {
-        assert_return(route, -EINVAL);
-        assert_return(gateway, -EINVAL);
-
-        *gateway = route->gw_addr;
-        return 0;
-}
index ab3a86e10b193272525c57e03ff6c508eec1cb4f..c78c50e3a757351c8166d38a9cae3a028f2fcc17 100644 (file)
@@ -3,7 +3,7 @@
 #include <arpa/inet.h>
 
 #include "alloc-util.h"
-#include "dhcp-lease-internal.h"
+#include "dhcp-route.h"
 #include "hashmap.h"
 #include "hostname-setup.h"
 #include "network-internal.h"
index 3aa67c3fa540bf4987b58a727900acf69a3c5a45..2dbee5450d5eb975b1b37edcd356a4193ba46e30 100644 (file)
@@ -86,9 +86,9 @@ int sd_dhcp_lease_get_6rd(
                 size_t *ret_n_br_addresses);
 int sd_dhcp_lease_has_6rd(sd_dhcp_lease *lease);
 
-int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination);
-int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length);
-int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway);
+int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *ret);
+int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *ret);
+int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *ret);
 
 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_lease, sd_dhcp_lease_unref);