summaryrefslogtreecommitdiff
path: root/dhcpctl/cltest2.c
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2020-02-10 08:29:22 -0500
committerThomas Markwalder <tmark@isc.org>2022-01-20 16:31:28 -0500
commitb675d3a0badea8e19ffcc964b74c324ebcdcf62c (patch)
tree04d91ba345b88f8de396c32f4b536c6f6afc966f /dhcpctl/cltest2.c
parent80dfe8061cd62dd5679ef75fec918fe152835ea2 (diff)
downloadisc-dhcp-b675d3a0badea8e19ffcc964b74c324ebcdcf62c.tar.gz
dhcpctl/cltest2.c Added use of dhcp_timed_connect() dhcpctl/dhcpctl.3 Added entry for dhcp_timed_connect() dhcpctl/dhcpctl.* dhcpctl_timed_connect() - new function dhcp_timed_wait_for_completion() - corrected commentary
Diffstat (limited to 'dhcpctl/cltest2.c')
-rw-r--r--dhcpctl/cltest2.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/dhcpctl/cltest2.c b/dhcpctl/cltest2.c
index 26249a3e..821441cd 100644
--- a/dhcpctl/cltest2.c
+++ b/dhcpctl/cltest2.c
@@ -68,6 +68,9 @@ void print_object(char *msg, dhcpctl_handle handle);
* 5. Disconnect
* 6. Reconnect
* 7. Refresh the host object
+ * 8. Disconnect
+ * 9. Time connect
+ * 10. Time connect retry
*
* Note that this program tests dhcpctl_timed_wait_for_completion() by calling
* it with extremely small timeouts.
@@ -143,7 +146,6 @@ int main (argc, argv)
break;
}
-
/* Now we'll test disconnect */
status = dhcpctl_disconnect(&connection, 0);
fail_on_error(status, "can't disconnect");
@@ -161,6 +163,29 @@ int main (argc, argv)
print_object("After reconnect/refresh", host);
+ /* Now we'll disconnect */
+ status = dhcpctl_disconnect(&connection, 0);
+ fail_on_error(status, "can't disconnect");
+
+ /* Try a timed connect */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 1;
+ status = dhcpctl_timed_connect (&connection, ip_address, port, 0, &timeout);
+
+ /* Try again if we time out */
+ if (status == ISC_R_TIMEDOUT) {
+ printf ("Retry timed connect\n");
+ timeout.tv_sec = 10;
+ status = dhcpctl_timed_connect (&connection, ip_address, port, 0,
+ &timeout);
+ }
+
+ fail_on_error(status ,"can't reconnect");
+
+ /* Lastly we'll disconnect to clean up */
+ status = dhcpctl_disconnect(&connection, 0);
+ fail_on_error(status ,"can't disconnect");
+
exit (0);
}