[dhcp-agent-commits] dhcp-agent/src dhcp-client-conf.c,1.16,1.17 dhcp-client-conf.h,1.9,1.10 dhcp-sy
Status: Alpha
Brought to you by:
actmodern
|
From: <act...@us...> - 2003-01-03 22:05:13
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src
In directory sc8-pr-cvs1:/tmp/cvs-serv11631
Modified Files:
dhcp-client-conf.c dhcp-client-conf.h dhcp-sysconf.c
Log Message:
added \'configure\' keyword
Index: dhcp-client-conf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** dhcp-client-conf.c 3 Jan 2003 21:29:22 -0000 1.16
--- dhcp-client-conf.c 3 Jan 2003 22:05:06 -0000 1.17
***************
*** 101,104 ****
--- 101,108 ----
static const arg_symbol_t *require_arg_symbols[] = { NULL };
+ static const arg_type_t configure_arg_types[] = { CONF_STRING_LIST };
+ static const char **configure_arg_strings[] = { NULL };
+ static const arg_symbol_t *configure_arg_symbols[] = { NULL };
+
static const arg_type_t server_arg_types[] = { CONF_IDENTIFIER, CONF_ADDRESS, CONF_GROUP };
static const char **server_arg_strings[] = { server_strings, NULL, NULL };
***************
*** 147,150 ****
--- 151,164 ----
};
+ /* request command. */
+ static const command_t command_configure = {
+ DIRECTIVE_CONFIGURE,
+ "configure",
+ 1,
+ configure_arg_strings,
+ configure_arg_types,
+ configure_arg_symbols,
+ };
+
/* server command. */
static const command_t command_server = {
***************
*** 163,166 ****
--- 177,181 ----
&command_require,
&command_server,
+ &command_configure,
NULL,
};
***************
*** 189,192 ****
--- 204,208 ----
static int directive_require_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data);
static int directive_server_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data);
+ static int directive_configure_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data);
/* indexed by directive types in dhcp-client-conf.h . */
***************
*** 197,200 ****
--- 213,217 ----
directive_require_handler,
directive_server_handler,
+ directive_configure_handler,
};
***************
*** 229,233 ****
}
-
static int client_conf_set_variable(conf_params_t *params, arg_symbol_t var_symbol, const char *var_value)
{
--- 246,249 ----
***************
*** 385,388 ****
--- 401,429 ----
}
+ uint8_t client_conf_get_opt_configure_set(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr)
+ {
+ conf_params_t *params;
+
+ params = get_params_for(cc->parameters.lower_params, ip_addr, eth_addr);
+
+ if(params != NULL && params->configure_set)
+ return 1;
+ else
+ return cc->parameters.configure_set;
+ }
+
+ /* get required options */
+ uint8_t *client_conf_get_opt_configure_bit_array(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr)
+ {
+ conf_params_t *params;
+
+ params = get_params_for(cc->parameters.lower_params, ip_addr, eth_addr);
+
+ if(params != NULL && params->configure_set)
+ return params->configure_options;
+ else
+ return cc->parameters.configure_options;
+ }
+
/* get number of times to attempt icmp operations where applicable */
int client_conf_get_icmp_retries(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr)
***************
*** 584,587 ****
--- 625,645 ----
return 0;
+ }
+
+ static int directive_configure_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data)
+ {
+ directive_t *directive = directive_data;
+ list_t *args;
+ list_t *string_list;
+
+ args = directive->arguments;
+ string_list = list_first(args);
+
+ if(fill_option_bit_array_from_string_list(string_list, params->configure_options))
+ return 1;
+
+ params->configure_set = 1;
+ return 0;
+
}
Index: dhcp-client-conf.h
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dhcp-client-conf.h 3 Jan 2003 21:29:22 -0000 1.9
--- dhcp-client-conf.h 3 Jan 2003 22:05:07 -0000 1.10
***************
*** 56,59 ****
--- 56,62 ----
uint8_t required_options[MAX_OPTIONS_HANDLED + 1]; /* which options we require. */
+ uint8_t configure_set;
+ uint8_t configure_options[MAX_OPTIONS_HANDLED + 1]; /* which options we actually handle. */
+
uint8_t icmp_retries_set; /* whether the icmp retries is explicitly set. */
int icmp_retries; /* amount of times we should retry icmp operations. */
***************
*** 77,81 ****
/* directive types. */
! enum directive_types { DIRECTIVE_SET_BOOLEAN = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST, DIRECTIVE_REQUIRE, DIRECTIVE_SERVER_GROUP };
/* symbols for variable substitution. */
--- 80,84 ----
/* directive types. */
! enum directive_types { DIRECTIVE_SET_BOOLEAN = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST, DIRECTIVE_REQUIRE, DIRECTIVE_SERVER_GROUP, DIRECTIVE_CONFIGURE };
/* symbols for variable substitution. */
***************
*** 102,107 ****
--- 105,113 ----
extern uint8_t *client_conf_get_opt_required_bit_array(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr);
+ extern uint8_t client_conf_get_opt_configure_set(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr);
+ extern uint8_t *client_conf_get_opt_configure_bit_array(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr);
extern int client_conf_get_icmp_retries(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr);
extern uint8_t client_conf_get_do_measure_router_latency_icmp(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr);
+
#endif /* DHCP_CLIENT_CONF_H */
Index: dhcp-sysconf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-sysconf.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** dhcp-sysconf.c 3 Jan 2003 21:29:22 -0000 1.13
--- dhcp-sysconf.c 3 Jan 2003 22:05:08 -0000 1.14
***************
*** 463,466 ****
--- 463,467 ----
void *data;
cache_entry_t *ce;
+ uint8_t *configure_opts = NULL;
/* Clean up any config files we have. */
***************
*** 474,477 ****
--- 475,489 ----
sysconf_setup_interface(options, dc);
+ /* ask client conf if we're supposed to configure certain options.
+ * if so get the bit array. */
+
+ if(client_conf_get_opt_configure_set(dc->conf, dhcp_client_get_server_ip_address(dc),
+ dhcp_client_get_server_hw_address(dc))) {
+
+ configure_opts = client_conf_get_opt_configure_bit_array(dc->conf,
+ dhcp_client_get_server_ip_address(dc),
+ dhcp_client_get_server_hw_address(dc));
+ }
+
/* Now walk through the other options, performing setup and
* cleanup operations as necessary. */
***************
*** 480,488 ****
while((ce = list_next(options)) != NULL) {
! /* Make sure we know how to setup this option. */
! if(sysconf_handlers[ce->tag].setup == NULL ||
! option_convert_handlers[ce->tag].serialize_to_internal == NULL)
! continue;
data = option_convert_handlers[ce->tag].serialize_to_internal(ce->value);
--- 492,512 ----
while((ce = list_next(options)) != NULL) {
! /* Make sure we know how to setup this option, and we're
! * supposed to. */
! if(configure_opts) {
!
! if(sysconf_handlers[ce->tag].setup == NULL ||
! option_convert_handlers[ce->tag].serialize_to_internal == NULL ||
! configure_opts[ce->tag] == 0)
! continue;
!
! } else {
!
! if(sysconf_handlers[ce->tag].setup == NULL ||
! option_convert_handlers[ce->tag].serialize_to_internal == NULL)
! continue;
!
! }
data = option_convert_handlers[ce->tag].serialize_to_internal(ce->value);
|