|
@@ -22,10 +22,20 @@ int test_dhcp ( struct net_device *netdev ) {
|
22
|
22
|
if ( ( rc = async_wait ( start_dhcp ( &dhcp ) ) ) != 0 )
|
23
|
23
|
goto out_no_options;
|
24
|
24
|
|
|
25
|
+ /* Register options received via DHCP */
|
|
26
|
+ register_dhcp_options ( dhcp.options );
|
|
27
|
+
|
25
|
28
|
/* Retrieve IP address configuration */
|
26
|
|
- find_dhcp_ipv4_option ( dhcp.options, DHCP_EB_YIADDR, &address );
|
27
|
|
- find_dhcp_ipv4_option ( dhcp.options, DHCP_SUBNET_MASK, &netmask );
|
28
|
|
- find_dhcp_ipv4_option ( dhcp.options, DHCP_ROUTERS, &gateway );
|
|
29
|
+ find_global_dhcp_ipv4_option ( DHCP_EB_YIADDR, &address );
|
|
30
|
+ find_global_dhcp_ipv4_option ( DHCP_SUBNET_MASK, &netmask );
|
|
31
|
+ find_global_dhcp_ipv4_option ( DHCP_ROUTERS, &gateway );
|
|
32
|
+
|
|
33
|
+ printf ( "IP %s", inet_ntoa ( address ) );
|
|
34
|
+ printf ( " netmask %s", inet_ntoa ( netmask ) );
|
|
35
|
+ printf ( " gateway %s\n", inet_ntoa ( gateway ) );
|
|
36
|
+
|
|
37
|
+ printf ( "Lease time is %ld seconds\n",
|
|
38
|
+ find_global_dhcp_num_option ( DHCP_LEASE_TIME ) );
|
29
|
39
|
|
30
|
40
|
/* Remove old IP address configuration */
|
31
|
41
|
del_ipv4_address ( netdev );
|
|
@@ -35,11 +45,8 @@ int test_dhcp ( struct net_device *netdev ) {
|
35
|
45
|
gateway ) ) != 0 )
|
36
|
46
|
goto out_no_del_ipv4;
|
37
|
47
|
|
38
|
|
- printf ( "IP %s", inet_ntoa ( address ) );
|
39
|
|
- printf ( " netmask %s", inet_ntoa ( netmask ) );
|
40
|
|
- printf ( " gateway %s\n", inet_ntoa ( gateway ) );
|
41
|
|
-
|
42
|
|
- /* Free DHCP options */
|
|
48
|
+ /* Unregister and free DHCP options */
|
|
49
|
+ unregister_dhcp_options ( dhcp.options );
|
43
|
50
|
free_dhcp_options ( dhcp.options );
|
44
|
51
|
out_no_options:
|
45
|
52
|
/* Take down IP interface */
|