[dhcp-agent-commits] dhcp-agent/src dhcp-lease.c,1.5,1.6 dhcp-server-conf.c,1.6,1.7 dhcp-server-conf
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-07-14 05:58:25
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23680/src Modified Files: dhcp-lease.c dhcp-server-conf.c dhcp-server-conf.h Log Message: added more lease def options Index: dhcp-lease.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-lease.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-lease.c 13 Jul 2003 05:44:30 -0000 1.5 --- dhcp-lease.c 14 Jul 2003 05:58:17 -0000 1.6 *************** *** 112,117 **** case LEASE_RANGE_ADDRESS: addr_range = data; ! lease_def->address_info.address_range.bottom_range = *(ip_addr_t *)list_first(addr_range); ! lease_def->address_info.address_range.top_range = *(ip_addr_t *)list_second(addr_range); break; --- 112,117 ---- case LEASE_RANGE_ADDRESS: addr_range = data; ! lease_def->address_info.address_range.top_range = *(ip_addr_t *)list_first(addr_range); ! lease_def->address_info.address_range.bottom_range = *(ip_addr_t *)list_second(addr_range); break; Index: dhcp-server-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-conf.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-server-conf.c 13 Jul 2003 05:44:30 -0000 1.6 --- dhcp-server-conf.c 14 Jul 2003 05:58:17 -0000 1.7 *************** *** 60,63 **** --- 60,67 ---- static const arg_symbol_t *hostname_lease_arg_symbols[] = { NULL, NULL, NULL }; + static const arg_type_t mac_lease_arg_types[] = { CONF_MAC_ADDRESS, CONF_ADDRESS, CONF_GROUP}; + static const char **mac_lease_arg_strings[] = { NULL, NULL, NULL }; + static const arg_symbol_t *mac_lease_arg_symbols[] = { NULL, NULL, NULL }; + static const arg_type_t option_arg_types[] = { CONF_STRING, CONF_ASSIGNMENT, CONF_STRING_LIST }; static const char **option_arg_strings[] = { NULL, NULL, NULL }; *************** *** 86,90 **** }; ! /* range-lease command. */ static const command_t command_hostname_lease = { DIRECTIVE_HOSTNAME_LEASE, --- 90,94 ---- }; ! /* hostname-lease command. */ static const command_t command_hostname_lease = { DIRECTIVE_HOSTNAME_LEASE, *************** *** 96,99 **** --- 100,113 ---- }; + /* mac-lease command. */ + static const command_t command_mac_lease = { + DIRECTIVE_MAC_LEASE, + "mac-lease", + 3, + mac_lease_arg_strings, + mac_lease_arg_types, + mac_lease_arg_symbols, + }; + static const command_t command_option = { DIRECTIVE_OPTION, *************** *** 108,113 **** &command_set, &command_range_lease, - &command_option, &command_hostname_lease, NULL, }; --- 122,128 ---- &command_set, &command_range_lease, &command_hostname_lease, + &command_mac_lease, + &command_option, NULL, }; *************** *** 119,122 **** --- 134,138 ---- static int directive_option_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data); static int directive_hostname_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data); + static int directive_hw_address_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data); /* indexed by directive types in dhcp-client-conf.h . */ *************** *** 124,129 **** directive_set_handler, directive_range_handler, - directive_option_handler, directive_hostname_handler, }; --- 140,146 ---- directive_set_handler, directive_range_handler, directive_hostname_handler, + directive_hw_address_handler, + directive_option_handler, }; *************** *** 283,287 **** case DIRECTIVE_OPTION: ! if(directive_option_handler(server_conf, lower_directive, GROUP_LEASE_DEF, option_list)) return 1; --- 300,304 ---- case DIRECTIVE_OPTION: ! if(directive_option_handler(server_conf, lower_directive, group_type, option_list)) return 1; *************** *** 325,329 **** /* create option handler by calling the general lease handler. */ option_list = list_create(); ! directive_lease_handler_proc(server_conf, directive, group_type, group_data, option_list); lease_def = lease_definition_create(NULL, LEASE_RANGE_ADDRESS, address_pair, option_list, lease_expiry, renew_time, rebind_time); --- 342,346 ---- /* create option handler by calling the general lease handler. */ option_list = list_create(); ! directive_lease_handler_proc(server_conf, directive, GROUP_LEASE_DEF, group_data, option_list); lease_def = lease_definition_create(NULL, LEASE_RANGE_ADDRESS, address_pair, option_list, lease_expiry, renew_time, rebind_time); *************** *** 336,344 **** } static int directive_hostname_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data) { - uint32_t lease_expiry = 0; - uint32_t renew_time = 0; - uint32_t rebind_time = 0; lease_constraint_t *constraint; list_t *args, *option_list; --- 353,359 ---- } + /* hostname handler. */ static int directive_hostname_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data) { lease_constraint_t *constraint; list_t *args, *option_list; *************** *** 346,349 **** --- 361,367 ---- ip_addr_t *ip_address; lease_definition_t *lease_def; + uint32_t lease_expiry = 0; + uint32_t renew_time = 0; + uint32_t rebind_time = 0; /* arguments. */ *************** *** 360,364 **** ip_address = list_second(args); option_list = list_create(); ! directive_lease_handler_proc(server_conf, directive, group_type, group_data, option_list); lease_def = lease_definition_create(constraint, LEASE_SINGLE_ADDRESS, ip_address, option_list, --- 378,382 ---- ip_address = list_second(args); option_list = list_create(); ! directive_lease_handler_proc(server_conf, directive, GROUP_LEASE_DEF, group_data, option_list); lease_def = lease_definition_create(constraint, LEASE_SINGLE_ADDRESS, ip_address, option_list, *************** *** 369,372 **** --- 387,426 ---- } + /* hardware address handler. */ + static int directive_hw_address_handler(server_conf_t *server_conf, directive_t *directive, int group_type, void *group_data) + { + lease_constraint_t *constraint; + list_t *args, *option_list; + eth_addr_t *eth_addr; + char *eth_addr_string; + ip_addr_t *ip_address; + lease_definition_t *lease_def; + uint32_t lease_expiry = 0; + uint32_t renew_time = 0; + uint32_t rebind_time = 0; + + /* arguments. */ + args = directive->arguments; + + /* first argument is the hostname. */ + eth_addr = list_first(args); + + if((constraint = lease_constraint_create(LEASE_CONSTRAINT_HARDWARE_ADDRESS, eth_addr)) == NULL) { + eth_addr_string = eth_addr_to_string(*eth_addr); + ERROR_MESSAGE("illegal mac address constraint specified: %s", eth_addr_string); + xfree(eth_addr_string); + return 1; + } + + ip_address = list_second(args); + option_list = list_create(); + directive_lease_handler_proc(server_conf, directive, GROUP_LEASE_DEF, group_data, option_list); + + lease_def = lease_definition_create(constraint, LEASE_SINGLE_ADDRESS, ip_address, option_list, + lease_expiry, renew_time, rebind_time); + list_add(server_conf->lease_defs, lease_def); + + return 0; + } /* lease option handler. */ *************** *** 380,384 **** if(group_type == GROUP_NULL) { ! ERROR_MESSAGE("dhcp option setting found outside of lease defintion"); return 1; } --- 434,438 ---- if(group_type == GROUP_NULL) { ! ERROR_MESSAGE("dhcp option setting found outside of lease definition"); return 1; } Index: dhcp-server-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-conf.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-server-conf.h 13 Jul 2003 05:44:30 -0000 1.5 --- dhcp-server-conf.h 14 Jul 2003 05:58:17 -0000 1.6 *************** *** 45,49 **** enum var_symbols { SERVER_VAR_RENEW_PERCENT = 0, SERVER_VAR_REBIND_PERCENT }; ! enum directive_types { DIRECTIVE_SET = 0, DIRECTIVE_RANGE_LEASE, DIRECTIVE_OPTION, DIRECTIVE_HOSTNAME_LEASE }; enum group_types { GROUP_NULL = 0, GROUP_LEASE_DEF }; --- 45,49 ---- enum var_symbols { SERVER_VAR_RENEW_PERCENT = 0, SERVER_VAR_REBIND_PERCENT }; ! enum directive_types { DIRECTIVE_SET = 0, DIRECTIVE_RANGE_LEASE, DIRECTIVE_HOSTNAME_LEASE, DIRECTIVE_MAC_LEASE, DIRECTIVE_OPTION }; enum group_types { GROUP_NULL = 0, GROUP_LEASE_DEF }; |