Browse Source

[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.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
b363d19a16
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      src/net/dhcppkt.c

+ 8
- 4
src/net/dhcppkt.c View File

155
 		memset ( field_data, 0, field->len );
155
 		memset ( field_data, 0, field->len );
156
 		memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
156
 		memcpy ( dhcp_packet_field ( dhcppkt->dhcphdr, field ),
157
 			 data, len );
157
 			 data, len );
158
+		/* Erase any equivalent option from the options block */
159
+		dhcpopt_store ( &dhcppkt->options, tag, NULL, 0 );
158
 		return 0;
160
 		return 0;
159
 	}
161
 	}
160
 
162
 
181
 		    void *data, size_t len ) {
183
 		    void *data, size_t len ) {
182
 	struct dhcp_packet_field *field;
184
 	struct dhcp_packet_field *field;
183
 	void *field_data;
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
 	if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
189
 	if ( ( field = find_dhcp_packet_field ( tag ) ) != NULL ) {
188
 		field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
190
 		field_data = dhcp_packet_field ( dhcppkt->dhcphdr, field );
189
 		field_len = field->used_len ( field_data, field->len );
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
 		if ( len > field_len )
196
 		if ( len > field_len )
193
 			len = field_len;
197
 			len = field_len;
194
 		memcpy ( data, field_data, len );
198
 		memcpy ( data, field_data, len );

Loading…
Cancel
Save