summaryrefslogtreecommitdiffstats
path: root/src/tests/dhcptest.c
diff options
context:
space:
mode:
authorMichael Brown2006-07-20 05:02:34 +0200
committerMichael Brown2006-07-20 05:02:34 +0200
commit7ca8bcd98c2cfb1f685ed80a9ba803062db1f603 (patch)
treec26131262079769a4c1728f5b206141150a1cd7b /src/tests/dhcptest.c
parentSwitch default stack to Nikhil's TCP/IP stack (diff)
downloadipxe-7ca8bcd98c2cfb1f685ed80a9ba803062db1f603.tar.gz
ipxe-7ca8bcd98c2cfb1f685ed80a9ba803062db1f603.tar.xz
ipxe-7ca8bcd98c2cfb1f685ed80a9ba803062db1f603.zip
Print out the lease time, just to show how easy it is.
Diffstat (limited to 'src/tests/dhcptest.c')
-rw-r--r--src/tests/dhcptest.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/tests/dhcptest.c b/src/tests/dhcptest.c
index b61535f2e..ce7cb106e 100644
--- a/src/tests/dhcptest.c
+++ b/src/tests/dhcptest.c
@@ -22,10 +22,20 @@ int test_dhcp ( struct net_device *netdev ) {
if ( ( rc = async_wait ( start_dhcp ( &dhcp ) ) ) != 0 )
goto out_no_options;
+ /* Register options received via DHCP */
+ register_dhcp_options ( dhcp.options );
+
/* Retrieve IP address configuration */
- find_dhcp_ipv4_option ( dhcp.options, DHCP_EB_YIADDR, &address );
- find_dhcp_ipv4_option ( dhcp.options, DHCP_SUBNET_MASK, &netmask );
- find_dhcp_ipv4_option ( dhcp.options, DHCP_ROUTERS, &gateway );
+ find_global_dhcp_ipv4_option ( DHCP_EB_YIADDR, &address );
+ find_global_dhcp_ipv4_option ( DHCP_SUBNET_MASK, &netmask );
+ find_global_dhcp_ipv4_option ( DHCP_ROUTERS, &gateway );
+
+ printf ( "IP %s", inet_ntoa ( address ) );
+ printf ( " netmask %s", inet_ntoa ( netmask ) );
+ printf ( " gateway %s\n", inet_ntoa ( gateway ) );
+
+ printf ( "Lease time is %ld seconds\n",
+ find_global_dhcp_num_option ( DHCP_LEASE_TIME ) );
/* Remove old IP address configuration */
del_ipv4_address ( netdev );
@@ -35,11 +45,8 @@ int test_dhcp ( struct net_device *netdev ) {
gateway ) ) != 0 )
goto out_no_del_ipv4;
- printf ( "IP %s", inet_ntoa ( address ) );
- printf ( " netmask %s", inet_ntoa ( netmask ) );
- printf ( " gateway %s\n", inet_ntoa ( gateway ) );
-
- /* Free DHCP options */
+ /* Unregister and free DHCP options */
+ unregister_dhcp_options ( dhcp.options );
free_dhcp_options ( dhcp.options );
out_no_options:
/* Take down IP interface */