|
@@ -87,55 +87,6 @@ unsigned long dhcp_num_option ( struct dhcp_option *option ) {
|
87
|
87
|
return value;
|
88
|
88
|
}
|
89
|
89
|
|
90
|
|
-/**
|
91
|
|
- * Obtain value of an IPv4-address DHCP option
|
92
|
|
- *
|
93
|
|
- * @v option DHCP option, or NULL
|
94
|
|
- * @v inp IPv4 address to fill in
|
95
|
|
- *
|
96
|
|
- * Parses the IPv4 address value from a DHCP option, if present. It
|
97
|
|
- * is permitted to call dhcp_ipv4_option() with @c option set to NULL;
|
98
|
|
- * in this case the address will be set to 0.0.0.0.
|
99
|
|
- */
|
100
|
|
-void dhcp_ipv4_option ( struct dhcp_option *option, struct in_addr *inp ) {
|
101
|
|
- if ( option )
|
102
|
|
- *inp = option->data.in;
|
103
|
|
-}
|
104
|
|
-
|
105
|
|
-/**
|
106
|
|
- * Print DHCP string option value into buffer
|
107
|
|
- *
|
108
|
|
- * @v buf Buffer into which to write the string
|
109
|
|
- * @v size Size of buffer
|
110
|
|
- * @v option DHCP option, or NULL
|
111
|
|
- * @ret len Length of formatted string
|
112
|
|
- *
|
113
|
|
- * DHCP option strings are stored without a NUL terminator. This
|
114
|
|
- * function provides a convenient way to extract these DHCP strings
|
115
|
|
- * into standard C strings. It is permitted to call dhcp_snprintf()
|
116
|
|
- * with @c option set to NULL; in this case the buffer will be filled
|
117
|
|
- * with an empty string.
|
118
|
|
- *
|
119
|
|
- * The usual snprintf() semantics apply with regard to buffer size,
|
120
|
|
- * return value when the buffer is too small, etc.
|
121
|
|
- */
|
122
|
|
-int dhcp_snprintf ( char *buf, size_t size, struct dhcp_option *option ) {
|
123
|
|
- size_t len;
|
124
|
|
- char *content = "";
|
125
|
|
-
|
126
|
|
- if ( option ) {
|
127
|
|
- /* Shrink buffer size so that it is only just large
|
128
|
|
- * enough to contain the option data. snprintf() will
|
129
|
|
- * take care of everything else (inserting the NUL etc.)
|
130
|
|
- */
|
131
|
|
- len = ( option->len + 1 );
|
132
|
|
- if ( len < size )
|
133
|
|
- size = len;
|
134
|
|
- content = option->data.string;
|
135
|
|
- }
|
136
|
|
- return snprintf ( buf, size, "%s", content );
|
137
|
|
-}
|
138
|
|
-
|
139
|
90
|
/**
|
140
|
91
|
* Calculate length of a normal DHCP option
|
141
|
92
|
*
|
|
@@ -461,19 +412,6 @@ struct dhcp_option * set_dhcp_option ( struct dhcp_option_block *options,
|
461
|
412
|
return option;
|
462
|
413
|
}
|
463
|
414
|
|
464
|
|
-/**
|
465
|
|
- * Find DHCP option within all registered DHCP options blocks
|
466
|
|
- *
|
467
|
|
- * @v tag DHCP option tag to search for
|
468
|
|
- * @ret option DHCP option, or NULL if not found
|
469
|
|
- *
|
470
|
|
- * This function exists merely as a notational shorthand for
|
471
|
|
- * find_dhcp_option() with @c options set to NULL.
|
472
|
|
- */
|
473
|
|
-struct dhcp_option * find_global_dhcp_option ( unsigned int tag ) {
|
474
|
|
- return find_dhcp_option ( NULL, tag );
|
475
|
|
-}
|
476
|
|
-
|
477
|
415
|
/**
|
478
|
416
|
* Find DHCP numerical option, and return its value
|
479
|
417
|
*
|
|
@@ -493,62 +431,6 @@ unsigned long find_dhcp_num_option ( struct dhcp_option_block *options,
|
493
|
431
|
return dhcp_num_option ( find_dhcp_option ( options, tag ) );
|
494
|
432
|
}
|
495
|
433
|
|
496
|
|
-/**
|
497
|
|
- * Find DHCP numerical option, and return its value
|
498
|
|
- *
|
499
|
|
- * @v tag DHCP option tag to search for
|
500
|
|
- * @ret value Numerical value of the option, or 0 if not found
|
501
|
|
- *
|
502
|
|
- * This function exists merely as a notational shorthand for a call to
|
503
|
|
- * find_global_dhcp_option() followed by a call to dhcp_num_option().
|
504
|
|
- * It is not possible to distinguish between the cases "option not
|
505
|
|
- * found" and "option has a value of zero" using this function; if
|
506
|
|
- * this matters to you then issue the two constituent calls directly
|
507
|
|
- * and check that find_global_dhcp_option() returns a non-NULL value.
|
508
|
|
- */
|
509
|
|
-unsigned long find_global_dhcp_num_option ( unsigned int tag ) {
|
510
|
|
- return dhcp_num_option ( find_global_dhcp_option ( tag ) );
|
511
|
|
-}
|
512
|
|
-
|
513
|
|
-/**
|
514
|
|
- * Find DHCP IPv4-address option, and return its value
|
515
|
|
- *
|
516
|
|
- * @v options DHCP options block
|
517
|
|
- * @v tag DHCP option tag to search for
|
518
|
|
- * @v inp IPv4 address to fill in
|
519
|
|
- * @ret value Numerical value of the option, or 0 if not found
|
520
|
|
- *
|
521
|
|
- * This function exists merely as a notational shorthand for a call to
|
522
|
|
- * find_dhcp_option() followed by a call to dhcp_ipv4_option(). It is
|
523
|
|
- * not possible to distinguish between the cases "option not found"
|
524
|
|
- * and "option has a value of 0.0.0.0" using this function; if this
|
525
|
|
- * matters to you then issue the two constituent calls directly and
|
526
|
|
- * check that find_dhcp_option() returns a non-NULL value.
|
527
|
|
- */
|
528
|
|
-void find_dhcp_ipv4_option ( struct dhcp_option_block *options,
|
529
|
|
- unsigned int tag, struct in_addr *inp ) {
|
530
|
|
- dhcp_ipv4_option ( find_dhcp_option ( options, tag ), inp );
|
531
|
|
-}
|
532
|
|
-
|
533
|
|
-/**
|
534
|
|
- * Find DHCP IPv4-address option, and return its value
|
535
|
|
- *
|
536
|
|
- * @v options DHCP options block
|
537
|
|
- * @v tag DHCP option tag to search for
|
538
|
|
- * @v inp IPv4 address to fill in
|
539
|
|
- * @ret value Numerical value of the option, or 0 if not found
|
540
|
|
- *
|
541
|
|
- * This function exists merely as a notational shorthand for a call to
|
542
|
|
- * find_dhcp_option() followed by a call to dhcp_ipv4_option(). It is
|
543
|
|
- * not possible to distinguish between the cases "option not found"
|
544
|
|
- * and "option has a value of 0.0.0.0" using this function; if this
|
545
|
|
- * matters to you then issue the two constituent calls directly and
|
546
|
|
- * check that find_dhcp_option() returns a non-NULL value.
|
547
|
|
- */
|
548
|
|
-void find_global_dhcp_ipv4_option ( unsigned int tag, struct in_addr *inp ) {
|
549
|
|
- dhcp_ipv4_option ( find_global_dhcp_option ( tag ), inp );
|
550
|
|
-}
|
551
|
|
-
|
552
|
434
|
/**
|
553
|
435
|
* Delete DHCP option
|
554
|
436
|
*
|