diff options
author | Tom Gundersen <teg@jklm.no> | 2014-05-25 00:29:13 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-06-13 17:07:19 +0200 |
commit | 20af7091de0cdf92bf299addfc3f96c3ef805bd8 (patch) | |
tree | ec3d865eee312619cd8a3f00336474489cd966d9 /src/libsystemd-network/test-dhcp-server.c | |
parent | sd-dhcp-server: bind to raw socket for sending (diff) | |
download | systemd-20af7091de0cdf92bf299addfc3f96c3ef805bd8.tar.xz systemd-20af7091de0cdf92bf299addfc3f96c3ef805bd8.zip |
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.c | 17 |
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); |