summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-dhcp-server.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-05-25 00:29:13 +0200
committerTom Gundersen <teg@jklm.no>2014-06-13 17:07:19 +0200
commit20af7091de0cdf92bf299addfc3f96c3ef805bd8 (patch)
treeec3d865eee312619cd8a3f00336474489cd966d9 /src/libsystemd-network/test-dhcp-server.c
parent8de4a226c71ef43e652274b33b5d19211a44ac7b (diff)
sd-dhcp-server: add support for setting the server address
Diffstat (limited to 'src/libsystemd-network/test-dhcp-server.c')
-rw-r--r--src/libsystemd-network/test-dhcp-server.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsystemd-network/test-dhcp-server.c b/src/libsystemd-network/test-dhcp-server.c
index dd0f29a04c..f0f9cfe582 100644
--- a/src/libsystemd-network/test-dhcp-server.c
+++ b/src/libsystemd-network/test-dhcp-server.c
@@ -32,6 +32,12 @@
static void test_basic(sd_event *event) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
+ struct in_addr address_lo = {
+ .s_addr = htonl(INADDR_LOOPBACK),
+ };
+ struct in_addr address_any = {
+ .s_addr = htonl(INADDR_ANY),
+ };
/* attach to loopback interface */
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
@@ -48,6 +54,11 @@ static void test_basic(sd_event *event) {
assert_se(sd_dhcp_server_ref(server) == server);
assert_se(!sd_dhcp_server_unref(server));
+ assert_se(sd_dhcp_server_start(server) == -EUNATCH);
+ assert_se(sd_dhcp_server_set_address(server, &address_any) == -EINVAL);
+ assert_se(sd_dhcp_server_set_address(server, &address_lo) >= 0);
+ assert_se(sd_dhcp_server_set_address(server, &address_lo) == -EBUSY);
+
assert_se(sd_dhcp_server_start(server) >= 0);
assert_se(sd_dhcp_server_start(server) == -EBUSY);
assert_se(sd_dhcp_server_stop(server) >= 0);
@@ -74,8 +85,14 @@ static void test_message_handler(void) {
.option_type.type = DHCP_DISCOVER,
.end = DHCP_OPTION_END,
};
+ struct in_addr address_lo = {
+ .s_addr = htonl(INADDR_LOOPBACK),
+ };
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
+ assert_se(sd_dhcp_server_set_address(server, &address_lo) >= 0);
+ assert_se(sd_dhcp_server_attach_event(server, NULL, 0) >= 0);
+ assert_se(sd_dhcp_server_start(server) >= 0);
assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == 1);