summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-dhcp6-client.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2015-01-20 19:35:56 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2015-01-27 09:35:24 +0200
commite7504d95479455be5cef120fc8e0a48fd74ad5ca (patch)
tree33d1addd0d885141868f9b05f1fc48e7e1d60e9a /src/libsystemd-network/test-dhcp6-client.c
parent2a481c84561d6c8ce37d75cc334f7c149ffb2bb9 (diff)
sd-dhcp6-lease: Revise address iteration functions
Revise the address iteration functions so that one helper function resets the iterator to the start of the address list while the second one fetches addresses one by one. The test case is also updated.
Diffstat (limited to 'src/libsystemd-network/test-dhcp6-client.c')
-rw-r--r--src/libsystemd-network/test-dhcp6-client.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index 75908391f0..9386f31ce4 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -286,26 +286,27 @@ static int test_advertise_option(sd_event *e) {
assert_se(opt_clientid);
- assert_se(sd_dhcp6_lease_get_first_address(lease, &addr, &lt_pref,
- &lt_valid) >= 0);
+ sd_dhcp6_lease_reset_address_iter(lease);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) >= 0);
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
assert_se(lt_pref == 150);
assert_se(lt_valid == 180);
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) == -ENOMSG);
- assert_se(sd_dhcp6_lease_get_first_address(lease, &addr, &lt_pref,
- &lt_valid) >= 0);
+ sd_dhcp6_lease_reset_address_iter(lease);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) >= 0);
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
- assert_se(sd_dhcp6_lease_get_first_address(lease, &addr, &lt_pref,
- &lt_valid) >= 0);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) == -ENOMSG);
+ sd_dhcp6_lease_reset_address_iter(lease);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) >= 0);
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) == -ENOMSG);
assert_se(dhcp6_lease_get_serverid(lease, &opt, &len) >= 0);
assert_se(len == 14);
@@ -439,14 +440,15 @@ static int test_client_verify_request(DHCP6Message *request, uint8_t *option,
assert_se(found_clientid && found_iana && found_serverid &&
found_elapsed_time);
- assert_se(sd_dhcp6_lease_get_first_address(lease, &addr, &lt_pref,
- &lt_valid) >= 0);
+ sd_dhcp6_lease_reset_address_iter(lease);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) >= 0);
assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
assert_se(lt_pref == 150);
assert_se(lt_valid == 180);
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) == -ENOMSG);
return 0;
}
@@ -587,11 +589,10 @@ static int test_client_verify_information_request(DHCP6Message *information_requ
assert_se(r == -ENOMSG);
assert_se(found_clientid && found_elapsed_time);
- assert_se(sd_dhcp6_lease_get_first_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
+ sd_dhcp6_lease_reset_address_iter(lease);
- assert_se(sd_dhcp6_lease_get_next_address(lease, &addr, &lt_pref,
- &lt_valid) == -ENOMSG);
+ assert_se(sd_dhcp6_lease_get_address(lease, &addr, &lt_pref,
+ &lt_valid) == -ENOMSG);
return 0;
}