summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-ipv4ll.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-01 21:51:49 +0200
committerTom Gundersen <teg@jklm.no>2015-10-11 15:04:16 +0200
commit129dc1b489d924d28956b09a06f03d7607beb8ad (patch)
tree9ff47f802047fa6c2d92c437d0881f8e2a64a1b7 /src/libsystemd-network/test-ipv4ll.c
parenta2fae7bbb21bdcc9d0a2094b7fd6b364ffbaae86 (diff)
sd-ipv4ll: allow initial address to be set explicitly
This is useful in case the daemon is restarted and the state of the IPv4LL client should be serialized/deserialized.
Diffstat (limited to 'src/libsystemd-network/test-ipv4ll.c')
-rw-r--r--src/libsystemd-network/test-ipv4ll.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c
index e72204d992..b67a9f17d7 100644
--- a/src/libsystemd-network/test-ipv4ll.c
+++ b/src/libsystemd-network/test-ipv4ll.c
@@ -100,6 +100,7 @@ int arp_network_bind_raw_socket(int index, be32_t address, const struct ether_ad
}
static void test_public_api_setters(sd_event *e) {
+ struct in_addr address = {};
unsigned seed = 0;
sd_ipv4ll *ll;
struct ether_addr mac_addr = {
@@ -118,6 +119,16 @@ static void test_public_api_setters(sd_event *e) {
assert_se(sd_ipv4ll_set_callback(NULL, NULL, NULL) == -EINVAL);
assert_se(sd_ipv4ll_set_callback(ll, NULL, NULL) == 0);
+ assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
+ address.s_addr |= htobe32(169U << 24 | 254U << 16);
+ assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
+ address.s_addr |= htobe32(0x00FF);
+ assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
+ address.s_addr |= htobe32(0xF000);
+ assert_se(sd_ipv4ll_set_address(ll, &address) == 0);
+ address.s_addr |= htobe32(0x0F00);
+ assert_se(sd_ipv4ll_set_address(ll, &address) == -EINVAL);
+
assert_se(sd_ipv4ll_set_address_seed(NULL, seed) == -EINVAL);
assert_se(sd_ipv4ll_set_address_seed(ll, seed) == 0);