aboutsummaryrefslogtreecommitdiffstats
path: root/gpxe/src/net/dhcppkt.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/net/dhcppkt.c')
-rw-r--r--gpxe/src/net/dhcppkt.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gpxe/src/net/dhcppkt.c b/gpxe/src/net/dhcppkt.c
index 1f2d373c..20a0e666 100644
--- a/gpxe/src/net/dhcppkt.c
+++ b/gpxe/src/net/dhcppkt.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
@@ -155,6 +157,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 +185,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 );