diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-04 20:11:53 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-20 20:59:00 +0200 |
commit | fb70992d3973cf09f421260780c4ac96b99467e7 (patch) | |
tree | de3a04cdd04fd65b59d58d9f817e77bb531be742 /src/libsystemd-network | |
parent | treewide: split commandline into command line (diff) | |
download | systemd-fb70992d3973cf09f421260780c4ac96b99467e7.tar.xz systemd-fb70992d3973cf09f421260780c4ac96b99467e7.zip |
sd-dhcp6-client: introduce sd_dhcp6_lease_has_pd_prefix() and friend
No functional change, just refactoring.
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-lease.c | 8 | ||||
-rw-r--r-- | src/libsystemd-network/test-dhcp6-client.c | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index 6dcc25888d..9d1c69ed3f 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -243,6 +243,10 @@ void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease) { lease->addr_iter = lease->ia_na ? lease->ia_na->addresses : NULL; } +int sd_dhcp6_lease_has_address(sd_dhcp6_lease *lease) { + return lease && lease->ia_na; +} + int sd_dhcp6_lease_get_pd( sd_dhcp6_lease *lease, struct in6_addr *ret_prefix, @@ -273,6 +277,10 @@ void sd_dhcp6_lease_reset_pd_prefix_iter(sd_dhcp6_lease *lease) { lease->prefix_iter = lease->ia_pd ? lease->ia_pd->addresses : NULL; } +int sd_dhcp6_lease_has_pd_prefix(sd_dhcp6_lease *lease) { + return lease && lease->ia_pd; +} + int dhcp6_lease_add_dns(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { assert(lease); assert(optval || optlen == 0); diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index ccf9208d43..a954bfb666 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -902,6 +902,9 @@ static void test_lease_managed(sd_dhcp6_client *client) { assert_se(dhcp6_lease_get_serverid(lease, &id, &len) >= 0); assert_se(memcmp_nn(id, len, server_id, sizeof(server_id)) == 0); + assert_se(sd_dhcp6_lease_has_address(lease)); + assert_se(sd_dhcp6_lease_has_pd_prefix(lease)); + sd_dhcp6_lease_reset_address_iter(lease); assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref, <_valid) >= 0); assert_se(in6_addr_equal(&addr, &ia_na_address1)); |