|
@@ -155,6 +155,8 @@ int dhcppkt_store ( struct dhcp_packet *dhcppkt, unsigned int tag,
|
155
|
155
|
memset ( field_data, 0, field->len );
|
156
|
156
|
memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
|
157
|
157
|
data, len );
|
|
158
|
+ /* Erase any equivalent option from the options block */
|
|
159
|
+ dhcpopt_store ( &dhcppkt->options, tag, NULL, 0 );
|
158
|
160
|
return 0;
|
159
|
161
|
}
|
160
|
162
|
|
|
@@ -181,14 +183,16 @@ int dhcppkt_fetch ( struct dhcp_packet *dhcppkt, unsigned int tag,
|
181
|
183
|
void *data, size_t len ) {
|
182
|
184
|
struct dhcp_packet_field *field;
|
183
|
185
|
void *field_data;
|
184
|
|
- size_t field_len;
|
|
186
|
+ size_t field_len = 0;
|
185
|
187
|
|
186
|
|
- /* If this is a special field, return it */
|
|
188
|
+ /* Identify special field, if any */
|
187
|
189
|
if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
|
188
|
190
|
field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
|
189
|
191
|
field_len = field->used_len ( field_data, field->len );
|
190
|
|
- if ( ! field_len )
|
191
|
|
- return -ENOENT;
|
|
192
|
+ }
|
|
193
|
+
|
|
194
|
+ /* Return special field, if it exists and is populated */
|
|
195
|
+ if ( field_len ) {
|
192
|
196
|
if ( len > field_len )
|
193
|
197
|
len = field_len;
|
194
|
198
|
memcpy ( data, field_data, len );
|