summaryrefslogtreecommitdiffstats
path: root/src/net/dhcppkt.c
diff options
context:
space:
mode:
authorMichael Brown2009-04-15 22:08:02 +0200
committerMichael Brown2009-04-15 22:08:02 +0200
commitb363d19a164c0741623182e327367d3f323c6cf8 (patch)
tree0f24a365308264f2ca9751c3f62fb945e409a330 /src/net/dhcppkt.c
parent[smbios] Add asset tag setting (diff)
downloadipxe-b363d19a164c0741623182e327367d3f323c6cf8.tar.gz
ipxe-b363d19a164c0741623182e327367d3f323c6cf8.tar.xz
ipxe-b363d19a164c0741623182e327367d3f323c6cf8.zip
[dhcp] Accept filename via DHCP option 67 as well as BOOTP filename field
Allow options with dedicated BOOTP fields to fall back to using the equivalent DHCP option if the relevant field is empty.
Diffstat (limited to 'src/net/dhcppkt.c')
-rw-r--r--src/net/dhcppkt.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/net/dhcppkt.c b/src/net/dhcppkt.c
index 1f2d373c..2f3e6802 100644
--- a/src/net/dhcppkt.c
+++ b/src/net/dhcppkt.c
@@ -155,6 +155,8 @@ int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
memset ( field_data, 0, field->len );
memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
data, len );
+ /* Erase any equivalent option from the options block */
+ dhcpopt_store ( &dhcppkt->options, tag, NULL, 0 );
return 0;
}
@@ -181,14 +183,16 @@ int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag,
void *data, size_t len ) {
struct dhcp_packet_field *field;
void *field_data;
- size_t field_len;
+ size_t field_len = 0;
- /* If this is a special field, return it */
+ /* Identify special field, if any */
if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
field_len = field->used_len ( field_data, field->len );
- if ( ! field_len )
- return -ENOENT;
+ }
+
+ /* Return special field, if it exists and is populated */
+ if ( field_len ) {
if ( len > field_len )
len = field_len;
memcpy ( data, field_data, len );