*/
/** List of registered DHCP option blocks */
-static LIST_HEAD ( option_blocks );
-
-/** Registered DHCP option applicators */
-static struct dhcp_option_applicator dhcp_option_applicators[0]
- __table_start ( struct dhcp_option_applicator, dhcp_applicators );
-static struct dhcp_option_applicator dhcp_option_applicators_end[0]
- __table_end ( struct dhcp_option_applicator, dhcp_applicators );
+LIST_HEAD ( dhcp_option_blocks );
/**
* Obtain printable version of a DHCP option tag
if ( options ) {
return find_dhcp_option_with_encap ( options, tag, NULL );
} else {
- list_for_each_entry ( options, &option_blocks, list ) {
+ list_for_each_entry ( options, &dhcp_option_blocks, list ) {
if ( ( option = find_dhcp_option ( options, tag ) ) )
return option;
}
options, options->priority );
/* Insert after any existing blocks which have a higher priority */
- list_for_each_entry ( existing, &option_blocks, list ) {
+ list_for_each_entry ( existing, &dhcp_option_blocks, list ) {
if ( options->priority > existing->priority )
break;
}
dhcpopt_get ( options );
list_add_tail ( &options->list, &existing->list );
+
+ /* Apply all registered DHCP options */
+ apply_global_dhcp_options();
}
/**
option = find_dhcp_option_with_encap ( options, tag, &encapsulator );
if ( option ) {
old_len = dhcp_option_len ( option );
- DBG ( "Resizing DHCP option %s from length %d to %d in block "
+ DBG ( "Resizing DHCP option %s from length %d to %zd in block "
"%p\n", dhcp_tag_name (tag), option->len, len, options );
} else {
old_len = 0;
- DBG ( "Creating DHCP option %s (length %d) in block %p\n",
+ DBG ( "Creating DHCP option %s (length %zd) in block %p\n",
dhcp_tag_name ( tag ), len, options );
}
* @ret rc Return status code
*/
int apply_dhcp_options ( struct dhcp_option_block *options ) {
- struct dhcp_option_applicator *applicator;
- struct dhcp_option *option;
struct in_addr tftp_server;
struct uri *uri;
char uri_string[32];
- unsigned int tag;
- int rc;
/* Set current working URI based on TFTP server */
find_dhcp_ipv4_option ( options, DHCP_EB_SIADDR, &tftp_server );
churi ( uri );
uri_put ( uri );
- /* Call all registered DHCP option applicators */
- for ( applicator = dhcp_option_applicators ;
- applicator < dhcp_option_applicators_end ; applicator++ ) {
- tag = applicator->tag;
- option = find_dhcp_option ( options, tag );
- if ( ! option )
- continue;
- if ( ( rc = applicator->apply ( tag, option ) ) != 0 ) {
- DBG ( "Could not apply DHCP option %s: %s\n",
- dhcp_tag_name ( tag ), strerror ( rc ) );
- return rc;
- }
- }
-
return 0;
}
+
+/**
+ * Apply global DHCP options
+ *
+ * @ret rc Return status code
+ */
+int apply_global_dhcp_options ( void ) {
+ return apply_dhcp_options ( NULL );
+}