summaryrefslogtreecommitdiffstats
path: root/src/net/dhcpopts.c
diff options
context:
space:
mode:
authorMichael Brown2008-03-25 21:46:16 +0100
committerMichael Brown2008-03-25 21:46:16 +0100
commit92d15eff30410dcb0ec406e06b131fb7d9179ffd (patch)
tree191d29013372b541d353bbfa55114b8060dd557c /src/net/dhcpopts.c
parent[PXEXT] Avoid returning a false EOF when we have an empty buffer queued (diff)
downloadipxe-92d15eff30410dcb0ec406e06b131fb7d9179ffd.tar.gz
ipxe-92d15eff30410dcb0ec406e06b131fb7d9179ffd.tar.xz
ipxe-92d15eff30410dcb0ec406e06b131fb7d9179ffd.zip
[Settings] Remove assumption that all settings have DHCP tag values
Allow for settings to be described by something other than a DHCP option tag if desirable. Currently used only for the MAC address setting. Separate out fake DHCP packet creation code from dhcp.c to fakedhcp.c. Remove notion of settings from dhcppkt.c. Rationalise dhcp.c to use settings API only for final registration of the DHCP options, rather than using {store,fetch}_setting throughout.
Diffstat (limited to 'src/net/dhcpopts.c')
-rw-r--r--src/net/dhcpopts.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/net/dhcpopts.c b/src/net/dhcpopts.c
index 64b310d4..1898011a 100644
--- a/src/net/dhcpopts.c
+++ b/src/net/dhcpopts.c
@@ -118,6 +118,11 @@ static int find_dhcp_option_with_encap ( struct dhcp_options *options,
ssize_t remaining = options->len;
unsigned int option_len;
+ /* Sanity check */
+ if ( tag == DHCP_PAD )
+ return -ENOENT;
+
+ /* Search for option */
while ( remaining ) {
/* Calculate length of this option. Abort processing
* if the length is malformed (i.e. takes us beyond
@@ -128,6 +133,9 @@ static int find_dhcp_option_with_encap ( struct dhcp_options *options,
remaining -= option_len;
if ( remaining < 0 )
break;
+ /* Check for explicit end marker */
+ if ( option->tag == DHCP_END )
+ break;
/* Check for matching tag */
if ( option->tag == tag ) {
DBGC ( options, "DHCPOPT %p found %s (length %d)\n",
@@ -135,9 +143,6 @@ static int find_dhcp_option_with_encap ( struct dhcp_options *options,
option_len );
return offset;
}
- /* Check for explicit end marker */
- if ( option->tag == DHCP_END )
- break;
/* Check for start of matching encapsulation block */
if ( DHCP_IS_ENCAP_OPT ( tag ) &&
( option->tag == DHCP_ENCAPSULATOR ( tag ) ) ) {
@@ -151,6 +156,7 @@ static int find_dhcp_option_with_encap ( struct dhcp_options *options,
}
offset += option_len;
}
+
return -ENOENT;
}
@@ -255,6 +261,10 @@ static int set_dhcp_option ( struct dhcp_options *options, unsigned int tag,
size_t new_len = ( len ? ( len + DHCP_OPTION_HEADER_LEN ) : 0 );
int rc;
+ /* Sanity check */
+ if ( tag == DHCP_PAD )
+ return -ENOTTY;
+
/* Find old instance of this option, if any */
offset = find_dhcp_option_with_encap ( options, tag, &encap_offset );
if ( offset >= 0 ) {