|
@@ -117,7 +117,7 @@ static int find_dhcp_option_with_encap ( struct dhcp_options *options,
|
117
|
117
|
unsigned int original_tag __attribute__ (( unused )) = tag;
|
118
|
118
|
struct dhcp_option *option;
|
119
|
119
|
int offset = 0;
|
120
|
|
- ssize_t remaining = options->len;
|
|
120
|
+ ssize_t remaining = options->used_len;
|
121
|
121
|
unsigned int option_len;
|
122
|
122
|
|
123
|
123
|
/* Sanity check */
|
|
@@ -199,8 +199,8 @@ static int resize_dhcp_option ( struct dhcp_options *options,
|
199
|
199
|
DBGC ( options, "DHCPOPT %p overlength option\n", options );
|
200
|
200
|
return -ENOSPC;
|
201
|
201
|
}
|
202
|
|
- new_options_len = ( options->len + delta );
|
203
|
|
- if ( new_options_len > options->max_len ) {
|
|
202
|
+ new_options_len = ( options->used_len + delta );
|
|
203
|
+ if ( new_options_len > options->alloc_len ) {
|
204
|
204
|
/* Reallocate options block if allowed to do so. */
|
205
|
205
|
if ( can_realloc ) {
|
206
|
206
|
new_data = realloc ( options->data, new_options_len );
|
|
@@ -211,7 +211,7 @@ static int resize_dhcp_option ( struct dhcp_options *options,
|
211
|
211
|
return -ENOMEM;
|
212
|
212
|
}
|
213
|
213
|
options->data = new_data;
|
214
|
|
- options->max_len = new_options_len;
|
|
214
|
+ options->alloc_len = new_options_len;
|
215
|
215
|
} else {
|
216
|
216
|
DBGC ( options, "DHCPOPT %p out of space\n", options );
|
217
|
217
|
return -ENOMEM;
|
|
@@ -227,13 +227,13 @@ static int resize_dhcp_option ( struct dhcp_options *options,
|
227
|
227
|
}
|
228
|
228
|
encapsulator->len = new_encapsulator_len;
|
229
|
229
|
}
|
230
|
|
- options->len = new_options_len;
|
|
230
|
+ options->used_len = new_options_len;
|
231
|
231
|
|
232
|
232
|
/* Move remainder of option data */
|
233
|
233
|
option = dhcp_option ( options, offset );
|
234
|
234
|
source = ( ( ( void * ) option ) + old_len );
|
235
|
235
|
dest = ( ( ( void * ) option ) + new_len );
|
236
|
|
- end = ( options->data + options->max_len );
|
|
236
|
+ end = ( options->data + options->alloc_len );
|
237
|
237
|
memmove ( dest, source, ( end - dest ) );
|
238
|
238
|
|
239
|
239
|
return 0;
|
|
@@ -277,7 +277,7 @@ static int set_dhcp_option ( struct dhcp_options *options, unsigned int tag,
|
277
|
277
|
creation_offset = find_dhcp_option_with_encap ( options, DHCP_END,
|
278
|
278
|
NULL );
|
279
|
279
|
if ( creation_offset < 0 )
|
280
|
|
- creation_offset = options->len;
|
|
280
|
+ creation_offset = options->used_len;
|
281
|
281
|
/* Find old instance of this option, if any */
|
282
|
282
|
offset = find_dhcp_option_with_encap ( options, tag, &encap_offset );
|
283
|
283
|
if ( offset >= 0 ) {
|
|
@@ -402,14 +402,14 @@ int dhcpopt_fetch ( struct dhcp_options *options, unsigned int tag,
|
402
|
402
|
* The "used length" field will be updated based on scanning through
|
403
|
403
|
* the block to find the end of the options.
|
404
|
404
|
*/
|
405
|
|
-static void dhcpopt_update_len ( struct dhcp_options *options ) {
|
|
405
|
+static void dhcpopt_update_used_len ( struct dhcp_options *options ) {
|
406
|
406
|
struct dhcp_option *option;
|
407
|
407
|
int offset = 0;
|
408
|
|
- ssize_t remaining = options->max_len;
|
|
408
|
+ ssize_t remaining = options->alloc_len;
|
409
|
409
|
unsigned int option_len;
|
410
|
410
|
|
411
|
411
|
/* Find last non-pad option */
|
412
|
|
- options->len = 0;
|
|
412
|
+ options->used_len = 0;
|
413
|
413
|
while ( remaining ) {
|
414
|
414
|
option = dhcp_option ( options, offset );
|
415
|
415
|
option_len = dhcp_option_len ( option );
|
|
@@ -418,7 +418,7 @@ static void dhcpopt_update_len ( struct dhcp_options *options ) {
|
418
|
418
|
break;
|
419
|
419
|
offset += option_len;
|
420
|
420
|
if ( option->tag != DHCP_PAD )
|
421
|
|
- options->len = offset;
|
|
421
|
+ options->used_len = offset;
|
422
|
422
|
}
|
423
|
423
|
}
|
424
|
424
|
|
|
@@ -427,21 +427,21 @@ static void dhcpopt_update_len ( struct dhcp_options *options ) {
|
427
|
427
|
*
|
428
|
428
|
* @v options Uninitialised DHCP option block
|
429
|
429
|
* @v data Memory for DHCP option data
|
430
|
|
- * @v max_len Length of memory for DHCP option data
|
|
430
|
+ * @v alloc_len Length of memory for DHCP option data
|
431
|
431
|
*
|
432
|
432
|
* The memory content must already be filled with valid DHCP options.
|
433
|
433
|
* A zeroed block counts as a block of valid DHCP options.
|
434
|
434
|
*/
|
435
|
435
|
void dhcpopt_init ( struct dhcp_options *options, void *data,
|
436
|
|
- size_t max_len ) {
|
|
436
|
+ size_t alloc_len ) {
|
437
|
437
|
|
438
|
438
|
/* Fill in fields */
|
439
|
439
|
options->data = data;
|
440
|
|
- options->max_len = max_len;
|
|
440
|
+ options->alloc_len = alloc_len;
|
441
|
441
|
|
442
|
442
|
/* Update length */
|
443
|
|
- dhcpopt_update_len ( options );
|
|
443
|
+ dhcpopt_update_used_len ( options );
|
444
|
444
|
|
445
|
|
- DBGC ( options, "DHCPOPT %p created (data %p len %#zx max_len %#zx)\n",
|
446
|
|
- options, options->data, options->len, options->max_len );
|
|
445
|
+ DBGC ( options, "DHCPOPT %p created (data %p lengths %#zx,%#zx)\n",
|
|
446
|
+ options, options->data, options->used_len, options->alloc_len );
|
447
|
447
|
}
|