diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-12-09 23:43:25 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-12-12 11:43:34 -0500 |
commit | d3d8ac2f2bac721d99f893c0a0128d21db636d4c (patch) | |
tree | 3d0ca49e1522f81f6a16a932ff4351d7ab7ad5fb /src/libsystemd-dhcp/test-dhcp-client.c | |
parent | 117539f8b76b3517834f4e57e85aeb3a73326a0d (diff) |
dhcp: Add timeout and main loop support
Require a main loop to be set when creating a DHCP client. Set up
a timer to resend DHCP Discover messages and add a 0-2 second
delay to the timeout value. Move to state Selecting after successful
sending of a Discover message.
Diffstat (limited to 'src/libsystemd-dhcp/test-dhcp-client.c')
-rw-r--r-- | src/libsystemd-dhcp/test-dhcp-client.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libsystemd-dhcp/test-dhcp-client.c b/src/libsystemd-dhcp/test-dhcp-client.c index fdcb6b1c49..b8a448d0dc 100644 --- a/src/libsystemd-dhcp/test-dhcp-client.c +++ b/src/libsystemd-dhcp/test-dhcp-client.c @@ -34,11 +34,11 @@ static struct ether_addr mac_addr = { .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'} }; -static void test_request_basic(void) +static void test_request_basic(sd_event *e) { sd_dhcp_client *client; - client = sd_dhcp_client_new(); + client = sd_dhcp_client_new(e); assert(client); @@ -172,12 +172,12 @@ int dhcp_network_send_raw_packet(int index, const void *packet, size_t len) return 575; } -static void test_discover_message(void) +static void test_discover_message(sd_event *e) { sd_dhcp_client *client; int res; - client = sd_dhcp_client_new(); + client = sd_dhcp_client_new(e); assert(client); assert(sd_dhcp_client_set_index(client, 42) >= 0); @@ -192,10 +192,15 @@ static void test_discover_message(void) int main(int argc, char *argv[]) { - test_request_basic(); + sd_event *e; + + assert(sd_event_new(&e) >= 0); + + test_request_basic(e); test_checksum(); - test_discover_message(); + test_discover_message(e); + sd_event_run(e, (uint64_t) -1); return 0; } |