summaryrefslogtreecommitdiffstats
path: root/src/usr/dhcpmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2007-11-21 05:48:18 +0100
committerMichael Brown2007-11-21 05:48:18 +0100
commitfb809da2dfe9d715a02de7033ede46854d176c2e (patch)
tree78b7f6462aa74a4ebc9f243c69bf2c41676d0714 /src/usr/dhcpmgmt.c
parentAdd PXE-required DHCP options to DHCPDISCOVER and DHCPREQUEST packets. (diff)
downloadipxe-fb809da2dfe9d715a02de7033ede46854d176c2e.tar.gz
ipxe-fb809da2dfe9d715a02de7033ede46854d176c2e.tar.xz
ipxe-fb809da2dfe9d715a02de7033ede46854d176c2e.zip
Remove some assumptions about DHCP obtaining only a single options block.
Diffstat (limited to 'src/usr/dhcpmgmt.c')
-rw-r--r--src/usr/dhcpmgmt.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c
index bd05c5ee..0c6b4588 100644
--- a/src/usr/dhcpmgmt.c
+++ b/src/usr/dhcpmgmt.c
@@ -32,27 +32,30 @@
*
*/
-static struct dhcp_option_block *dhcp_options = NULL;
-
static int dhcp_success ( struct net_device *netdev,
struct dhcp_option_block *options ) {
- dhcp_options = dhcpopt_get ( options );
+ DBGC ( options, "DHCP client registering options %p\n", options );
register_dhcp_options ( options );
return dhcp_configure_netdev ( netdev, options );
}
int dhcp ( struct net_device *netdev ) {
+ struct dhcp_option_block *options;
+ struct dhcp_option_block *tmp;
int rc;
/* Check we can open the interface first */
if ( ( rc = ifopen ( netdev ) ) != 0 )
return rc;
- /* Unregister any previously acquired options */
- if ( dhcp_options ) {
- unregister_dhcp_options ( dhcp_options );
- dhcpopt_put ( dhcp_options );
- dhcp_options = NULL;
+ /* Unregister any option blocks acquired via DHCP */
+ list_for_each_entry_safe ( options, tmp, &dhcp_option_blocks, list ) {
+ /* Skip static option blocks (e.g. from NVS) */
+ if ( find_dhcp_option ( options, DHCP_MESSAGE_TYPE ) ) {
+ DBGC ( options, "DHCP client unregistering options "
+ "%p\n", options );
+ unregister_dhcp_options ( options );
+ }
}
/* Perform DHCP */