mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 12:30:20 +03:00
[Settings] Use a settings applicator to configure IPv4 routes.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user