[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.
This commit is contained in:
parent
3ad348e55a
commit
2df682c5be
|
@ -138,12 +138,15 @@ find_dhcp_packet_field ( unsigned int tag ) {
|
||||||
int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
|
int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
|
||||||
const void *data, size_t len ) {
|
const void *data, size_t len ) {
|
||||||
struct dhcp_packet_field *field;
|
struct dhcp_packet_field *field;
|
||||||
|
void *field_data;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* If this is a special field, fill it in */
|
/* If this is a special field, fill it in */
|
||||||
if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
|
if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
|
||||||
if ( len > field->len )
|
if ( len > field->len )
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
|
field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
|
||||||
|
memset ( field_data, 0, field->len );
|
||||||
memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
|
memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
|
||||||
data, len );
|
data, len );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Reference in New Issue