Browse Source

[dhcp] Allow DHCP non-option settings to be cleared

dhcppkt_store() is supposed to clear the setting if passed NULL for the
setting data.  In the case of fixed-location fields (e.g. client IP
address), this requires setting the content of the field to all-zeros.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
2df682c5be
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      src/net/dhcppkt.c

+ 3
- 0
src/net/dhcppkt.c View File

138
 int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
138
 int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
139
 		    const void *data, size_t len ) {
139
 		    const void *data, size_t len ) {
140
 	struct dhcp_packet_field *field;
140
 	struct dhcp_packet_field *field;
141
+	void *field_data;
141
 	int rc;
142
 	int rc;
142
 
143
 
143
 	/* If this is a special field, fill it in */
144
 	/* If this is a special field, fill it in */
144
 	if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
145
 	if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
145
 		if ( len > field->len )
146
 		if ( len > field->len )
146
 			return -ENOSPC;
147
 			return -ENOSPC;
148
+		field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
149
+		memset ( field_data, 0, field->len );
147
 		memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
150
 		memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
148
 			 data, len );
151
 			 data, len );
149
 		return 0;
152
 		return 0;

Loading…
Cancel
Save