|
@@ -24,6 +24,7 @@
|
24
|
24
|
#include <assert.h>
|
25
|
25
|
#include <vsprintf.h>
|
26
|
26
|
#include <gpxe/list.h>
|
|
27
|
+#include <gpxe/in.h>
|
27
|
28
|
#include <gpxe/dhcp.h>
|
28
|
29
|
|
29
|
30
|
/** @file
|
|
@@ -85,6 +86,21 @@ unsigned long dhcp_num_option ( struct dhcp_option *option ) {
|
85
|
86
|
return value;
|
86
|
87
|
}
|
87
|
88
|
|
|
89
|
+/**
|
|
90
|
+ * Obtain value of an IPv4-address DHCP option
|
|
91
|
+ *
|
|
92
|
+ * @v option DHCP option, or NULL
|
|
93
|
+ * @v inp IPv4 address to fill in
|
|
94
|
+ *
|
|
95
|
+ * Parses the IPv4 address value from a DHCP option, if present. It
|
|
96
|
+ * is permitted to call dhcp_ipv4_option() with @c option set to NULL;
|
|
97
|
+ * in this case the address will be set to 0.0.0.0.
|
|
98
|
+ */
|
|
99
|
+void dhcp_ipv4_option ( struct dhcp_option *option, struct in_addr *inp ) {
|
|
100
|
+ if ( option )
|
|
101
|
+ *inp = option->data.in;
|
|
102
|
+}
|
|
103
|
+
|
88
|
104
|
/**
|
89
|
105
|
* Calculate length of a normal DHCP option
|
90
|
106
|
*
|
|
@@ -460,6 +476,45 @@ unsigned long find_global_dhcp_num_option ( unsigned int tag ) {
|
460
|
476
|
return dhcp_num_option ( find_global_dhcp_option ( tag ) );
|
461
|
477
|
}
|
462
|
478
|
|
|
479
|
+/**
|
|
480
|
+ * Find DHCP IPv4-address option, and return its value
|
|
481
|
+ *
|
|
482
|
+ * @v options DHCP options block
|
|
483
|
+ * @v tag DHCP option tag to search for
|
|
484
|
+ * @v inp IPv4 address to fill in
|
|
485
|
+ * @ret value Numerical value of the option, or 0 if not found
|
|
486
|
+ *
|
|
487
|
+ * This function exists merely as a notational shorthand for a call to
|
|
488
|
+ * find_dhcp_option() followed by a call to dhcp_ipv4_option(). It is
|
|
489
|
+ * not possible to distinguish between the cases "option not found"
|
|
490
|
+ * and "option has a value of 0.0.0.0" using this function; if this
|
|
491
|
+ * matters to you then issue the two constituent calls directly and
|
|
492
|
+ * check that find_dhcp_option() returns a non-NULL value.
|
|
493
|
+ */
|
|
494
|
+void find_dhcp_ipv4_option ( struct dhcp_option_block *options,
|
|
495
|
+ unsigned int tag, struct in_addr *inp ) {
|
|
496
|
+ dhcp_ipv4_option ( find_dhcp_option ( options, tag ), inp );
|
|
497
|
+}
|
|
498
|
+
|
|
499
|
+/**
|
|
500
|
+ * Find DHCP IPv4-address option, and return its value
|
|
501
|
+ *
|
|
502
|
+ * @v options DHCP options block
|
|
503
|
+ * @v tag DHCP option tag to search for
|
|
504
|
+ * @v inp IPv4 address to fill in
|
|
505
|
+ * @ret value Numerical value of the option, or 0 if not found
|
|
506
|
+ *
|
|
507
|
+ * This function exists merely as a notational shorthand for a call to
|
|
508
|
+ * find_dhcp_option() followed by a call to dhcp_ipv4_option(). It is
|
|
509
|
+ * not possible to distinguish between the cases "option not found"
|
|
510
|
+ * and "option has a value of 0.0.0.0" using this function; if this
|
|
511
|
+ * matters to you then issue the two constituent calls directly and
|
|
512
|
+ * check that find_dhcp_option() returns a non-NULL value.
|
|
513
|
+ */
|
|
514
|
+void find_global_dhcp_ipv4_option ( unsigned int tag, struct in_addr *inp ) {
|
|
515
|
+ dhcp_ipv4_option ( find_global_dhcp_option ( tag ), inp );
|
|
516
|
+}
|
|
517
|
+
|
463
|
518
|
/**
|
464
|
519
|
* Delete DHCP option
|
465
|
520
|
*
|