[Settings] Use a settings applicator to configure IPv4 routes.

This commit is contained in:
Michael Brown
2008-03-21 00:01:27 +00:00
parent eae6ac3d0b
commit aec9b8a41b
7 changed files with 51 additions and 86 deletions

View File

@@ -1025,46 +1025,3 @@ int start_dhcp ( struct job_interface *job, struct net_device *netdev,
ref_put ( &dhcp->refcnt );
return rc;
}
/****************************************************************************
*
* Network device configurator
*
*/
/**
* Configure network device from DHCP options
*
* @v netdev Network device
* @v options DHCP options block
* @ret rc Return status code
*/
int dhcp_configure_netdev ( struct net_device *netdev,
struct dhcp_option_block *options ) {
struct in_addr address = { 0 };
struct in_addr netmask = { 0 };
struct in_addr gateway = { INADDR_NONE };
int rc;
/* Retrieve IP address configuration */
find_dhcp_ipv4_option ( options, DHCP_EB_YIADDR, &address );
find_dhcp_ipv4_option ( options, DHCP_SUBNET_MASK, &netmask );
find_dhcp_ipv4_option ( options, DHCP_ROUTERS, &gateway );
/* Do nothing unless we have at least an IP address to use */
if ( ! address.s_addr )
return 0;
/* Clear any existing routing table entry */
del_ipv4_address ( netdev );
/* Set up new IP address configuration */
if ( ( rc = add_ipv4_address ( netdev, address, netmask,
gateway ) ) != 0 ) {
DBG ( "Could not configure %s with DHCP results: %s\n",
netdev->name, strerror ( rc ) );
return rc;
}
return 0;
}