[dhcp-agent-commits] dhcp-agent/src Makefile.am,1.23,1.24 dhcp-client-conf.c,1.26,1.27 dhcp-client-c
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-06-17 07:34:22
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv15241/src Modified Files: Makefile.am dhcp-client-conf.c dhcp-client-conf.h dhcp-client-guile.c dhcp-client-states.c dhcp-client.c dhcp-client.h dhcp-librawnet.h dhcp-option-convert.c dhcp-option.c dhcp-option.h Log Message: revamped client state machine Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Makefile.am 8 Jun 2003 22:18:00 -0000 1.23 --- Makefile.am 17 Jun 2003 07:34:15 -0000 1.24 *************** *** 3,7 **** # Main source Makefile.am ! AM_CFLAGS = -Wall -Werror INCLUDES = ${PCAP_INC} ${DNET_INC} ${GUILE_INC} CPPFLAGS = -DDHCPSYSCONFDIR=\"${dhcpsysconfdir}\" -DDHCPSYSCONF_CLIENTDIR=\"${dhcpsysconf_clientdir}\" \ --- 3,7 ---- # Main source Makefile.am ! AM_CFLAGS = -Wall -Werror -g INCLUDES = ${PCAP_INC} ${DNET_INC} ${GUILE_INC} CPPFLAGS = -DDHCPSYSCONFDIR=\"${dhcpsysconfdir}\" -DDHCPSYSCONF_CLIENTDIR=\"${dhcpsysconf_clientdir}\" \ Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** dhcp-client-conf.c 8 Jun 2003 22:14:51 -0000 1.26 --- dhcp-client-conf.c 17 Jun 2003 07:34:15 -0000 1.27 *************** *** 771,774 **** --- 771,786 ---- } + /* get timeout threshold for dhcp discover operations. */ + int client_conf_get_dhcp_discover_timeout(client_conf_t *cc) + { + return get_conf_int_var(cc->params, CLIENT_VAR_DHCP_DISCOVER_TIMEOUT, CLIENT_DEFAULT_DHCP_DISCOVER_TIMEOUT); + } + + /* get timeout threshold for dhcp request operations. */ + int client_conf_get_dhcp_request_timeout(client_conf_t *cc) + { + return get_conf_int_var(cc->params, CLIENT_VAR_DHCP_REQUEST_TIMEOUT, CLIENT_DEFAULT_DHCP_REQUEST_TIMEOUT); + } + /* get timeout threshold for arp operations. */ int client_conf_get_arp_timeout(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr) Index: dhcp-client-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dhcp-client-conf.h 8 Jun 2003 22:14:51 -0000 1.16 --- dhcp-client-conf.h 17 Jun 2003 07:34:15 -0000 1.17 *************** *** 104,107 **** --- 104,109 ---- extern int client_conf_get_icmp_echo_timeout(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr); extern int client_conf_get_icmp_subnet_timeout(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr); + extern int client_conf_get_dhcp_discover_timeout(client_conf_t *cc); + extern int client_conf_get_dhcp_request_timeout(client_conf_t *cc); extern int client_conf_get_arp_timeout(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr); extern const char *client_conf_get_hostname(client_conf_t *cc); Index: dhcp-client-guile.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-guile.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-client-guile.c 8 Jun 2003 22:15:24 -0000 1.7 --- dhcp-client-guile.c 17 Jun 2003 07:34:15 -0000 1.8 *************** *** 385,389 **** dc = client_control_smob->dc; ! client_do_shutdown(dc); /* never really returns but to avoid compiler warning. */ --- 385,389 ---- dc = client_control_smob->dc; ! client_shutdown(dc); /* never really returns but to avoid compiler warning. */ *************** *** 692,711 **** case STATE_SETUP: ! hook = scm_c_eval_string("dhcp-bound-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! case STATE_REBIND: ! ! hook = scm_c_eval_string("dhcp-rebind-hook"); ! scm_c_run_hook(hook, SCM_EOL); ! break; ! ! case STATE_RENEW: ! hook = scm_c_eval_string("dhcp-renew-hook"); scm_c_run_hook(hook, SCM_EOL); break; ! case STATE_DO_SHUTDOWN: hook = scm_c_eval_string("dhcp-release-hook"); scm_c_run_hook(hook, SCM_EOL); --- 692,700 ---- case STATE_SETUP: ! hook = scm_c_eval_string("dhcp-bind-hook"); scm_c_run_hook(hook, SCM_EOL); break; ! case STATE_SHUTDOWN: hook = scm_c_eval_string("dhcp-release-hook"); scm_c_run_hook(hook, SCM_EOL); *************** *** 784,796 **** /* bound hook. */ hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-bound-hook", hook); ! ! /* rebind. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-rebind-hook", hook); ! ! /* renew. */ ! hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-renew-hook", hook); /* release. */ --- 773,777 ---- /* bound hook. */ hook = scm_make_hook(SCM_MAKINUM(0)); ! scm_c_define("dhcp-bind-hook", hook); /* release. */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** dhcp-client-states.c 25 May 2003 03:37:36 -0000 1.33 --- dhcp-client-states.c 17 Jun 2003 07:34:15 -0000 1.34 *************** *** 40,67 **** #include "dhcp-sysconf.h" /*************************** * option list generation * ***************************/ - /* create DHCP RELEASE option list. */ - static list_t *client_build_release_option_list(dhcp_client_control_t *dc) - { - list_t *options; [...1237 lines suppressed...] - client_cache_delete_cache(dc->cache); - - return STATE_DISCOVER_OFFER; - - } else { - - ERROR_MESSAGE("received neither NACK nor ACK -- this should never happen because of higher filters."); - FATAL_MESSAGE("I shouldn't be here. this is a bug report me."); - exit(1); /* get rid of compiler warning. */ - } - } - - /* utility state: call this if reinitializing our client control - * useful when recreating the control (e.g. after a fork). */ - int client_reinitialize(dhcp_client_control_t *dc) - { - client_setup_timers(dc); - return 0; } --- 1040,1042 ---- Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** dhcp-client.c 25 May 2003 16:24:10 -0000 1.29 --- dhcp-client.c 17 Jun 2003 07:34:16 -0000 1.30 *************** *** 78,90 **** /* client state dispatch: index constants in dhcp-client.h */ client_state client_states[] = { ! client_discover_offer, ! client_request_ack, client_setup, ! client_wait, ! client_release, ! client_renew, ! client_rebind, ! client_fatal_error, ! client_do_shutdown, }; --- 78,90 ---- /* client state dispatch: index constants in dhcp-client.h */ client_state client_states[] = { ! client_init, ! client_init_reboot, ! client_requesting, ! client_renewing, ! client_rebinding, client_setup, ! client_bound, ! client_inform, ! client_shutdown, }; *************** *** 108,114 **** { if(client_cache_is_empty(dc->cache)) { ! return STATE_DISCOVER_OFFER; } else /* if not empty we assume we can request the options. */ ! return STATE_REQUEST_ACK; } --- 108,114 ---- { if(client_cache_is_empty(dc->cache)) { ! return STATE_INIT; } else /* if not empty we assume we can request the options. */ ! return STATE_INIT_REBOOT; } *************** *** 214,218 **** case INTERRUPT_TERM: ! state = STATE_DO_SHUTDOWN; break; --- 214,218 ---- case INTERRUPT_TERM: ! state = STATE_SHUTDOWN; break; *************** *** 238,242 **** case TIMER_IP_LEASE: ! state = STATE_DISCOVER_OFFER; break; --- 238,242 ---- case TIMER_IP_LEASE: ! state = STATE_INIT; break; *************** *** 258,265 **** * return here. */ ! if((state == STATE_WAIT) && only_setup) { return state; } state = client_states[state] (dc); --- 258,268 ---- * return here. */ ! if((state == STATE_BOUND) && only_setup) { return state; } + if(state == STATE_USER_INTERRUPT || state == STATE_NO_LEASES || state == STATE_FATAL_ERROR) + state = STATE_SHUTDOWN; + state = client_states[state] (dc); *************** *** 388,392 **** if((dc = dhcp_client_control_create(interface, promiscuous, 1)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting."); ! client_states[STATE_DO_SHUTDOWN] (dc); } --- 391,395 ---- if((dc = dhcp_client_control_create(interface, promiscuous, 1)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting."); ! client_states[STATE_SHUTDOWN] (dc); } *************** *** 426,430 **** * * The only thing we keep is our state which ought to be ! * STATE_WAIT * * Unfortunately destroying the control means valuable --- 429,433 ---- * * The only thing we keep is our state which ought to be ! * STATE_BOUND * * Unfortunately destroying the control means valuable *************** *** 446,450 **** if((dc = dhcp_client_control_create(interface, promiscuous, 0)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting.", interface); ! client_states[STATE_DO_SHUTDOWN] (NULL); } --- 449,453 ---- if((dc = dhcp_client_control_create(interface, promiscuous, 0)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting.", interface); ! client_states[STATE_SHUTDOWN] (NULL); } *************** *** 454,458 **** if(file_create_pid(interface)) { ERROR_MESSAGE("could not create PID file for interface: %s", interface); ! client_states[STATE_DO_SHUTDOWN](NULL); } --- 457,461 ---- if(file_create_pid(interface)) { ERROR_MESSAGE("could not create PID file for interface: %s", interface); ! client_states[STATE_SHUTDOWN](NULL); } Index: dhcp-client.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dhcp-client.h 25 May 2003 03:37:36 -0000 1.16 --- dhcp-client.h 17 Jun 2003 07:34:16 -0000 1.17 *************** *** 71,93 **** /* client commands. */ ! #define DO_VERSION 0 ! #define DO_KILL 1 ! #define DO_WAKE 2 ! #define DO_CLEAR 3 ! #define DO_CLIENT 4 /* DHCP client states. */ ! #define STATE_DISCOVER_OFFER 0 ! #define STATE_REQUEST_ACK 1 ! #define STATE_SETUP 2 ! #define STATE_WAIT 3 ! #define STATE_RELEASE 4 ! #define STATE_RENEW 5 ! #define STATE_REBIND 6 ! #define STATE_FATAL_ERROR 7 ! #define STATE_DO_SHUTDOWN 8 /* timer IDs. */ - enum client_timer_types { TIMER_IP_LEASE = 1, TIMER_REBIND, TIMER_RENEW }; --- 71,82 ---- /* client commands. */ ! enum client_commands { DO_VERSION = 0, DO_KILL, DO_WAKE, DO_CLEAR, DO_CLIENT }; /* DHCP client states. */ ! enum client_states { STATE_INIT = 0, STATE_INIT_REBOOT, STATE_REQUEST, STATE_RENEW, STATE_REBIND, STATE_SETUP, ! STATE_BOUND, STATE_INFORM, STATE_SHUTDOWN, STATE_RELEASE, ! STATE_DECLINE, STATE_FATAL_ERROR, STATE_NO_LEASES, STATE_USER_INTERRUPT }; /* timer IDs. */ enum client_timer_types { TIMER_IP_LEASE = 1, TIMER_REBIND, TIMER_RENEW }; *************** *** 95,107 **** /* client states. */ ! extern int client_discover_offer(dhcp_client_control_t *dc); ! extern int client_request_ack(dhcp_client_control_t *dc); ! extern int client_wait(dhcp_client_control_t *dc); extern int client_release(dhcp_client_control_t *dc); - extern int client_renew(dhcp_client_control_t *dc); - extern int client_rebind(dhcp_client_control_t *dc); extern int client_setup(dhcp_client_control_t *dc); ! extern int client_fatal_error(dhcp_client_control_t *dc); ! extern int client_do_shutdown(dhcp_client_control_t *dc); extern int client_reinitialize(dhcp_client_control_t *dc); --- 84,97 ---- /* client states. */ ! extern int client_init(dhcp_client_control_t *dc); ! extern int client_init_reboot(dhcp_client_control_t *dc); ! extern int client_inform(dhcp_client_control_t *dc); ! extern int client_requesting(dhcp_client_control_t *dc); ! extern int client_rebinding(dhcp_client_control_t *dc); ! extern int client_renewing(dhcp_client_control_t *dc); ! extern int client_bound(dhcp_client_control_t *dc); extern int client_release(dhcp_client_control_t *dc); extern int client_setup(dhcp_client_control_t *dc); ! extern int client_shutdown(dhcp_client_control_t *dc); extern int client_reinitialize(dhcp_client_control_t *dc); Index: dhcp-librawnet.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** dhcp-librawnet.h 8 Jun 2003 22:42:45 -0000 1.15 --- dhcp-librawnet.h 17 Jun 2003 07:34:16 -0000 1.16 *************** *** 111,115 **** dhcp_opt_from_string from_internal_string; /* string to internal. */ ! dhcp_opt_data_destroy destroy; /* destroy option datum. */ } dhcp_opt_attr_t; --- 111,115 ---- dhcp_opt_from_string from_internal_string; /* string to internal. */ ! dhcp_opt_data_destroy destroy; /* destroy option datum. */ } dhcp_opt_attr_t; Index: dhcp-option-convert.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-option-convert.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-option-convert.c 18 May 2003 02:58:25 -0000 1.4 --- dhcp-option-convert.c 17 Jun 2003 07:34:16 -0000 1.5 *************** *** 28,32 **** #define MODULE_NAME "dhcp-option-convert" - #define DHCP_OPTION_MACROS #include "dhcp-local.h" --- 28,31 ---- Index: dhcp-option.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-option.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-option.c 6 May 2003 03:49:16 -0000 1.4 --- dhcp-option.c 17 Jun 2003 07:34:16 -0000 1.5 *************** *** 24,28 **** #define MODULE_NAME "dhcp-option" - #define DHCP_OPTION_MACROS #include "dhcp-local.h" --- 24,27 ---- Index: dhcp-option.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-option.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-option.h 6 May 2003 03:49:16 -0000 1.4 --- dhcp-option.h 17 Jun 2003 07:34:16 -0000 1.5 *************** *** 64,68 **** /* convenience macros. this makes accessing what's under the attr structure easier. */ - #ifdef DHCP_OPTION_MACROS #define DHCP_OPT_GET_TYPE(x) (x->opt_attr->type) --- 64,67 ---- *************** *** 79,87 **** #define DHCP_OPT_TO_USER_STRING(x) (x->opt_attr->to_user_string(x)) #define DHCP_OPT_TO_NETWORK_DATA(x) (x->opt_attr->to_network_data(x)) ! #define DHCP_OPT_TO_INTERNAL_DATA(x) (x->opt_attr->to_host_data(x, retlen)) #define DHCP_OPT_DESTROY(x) (x->opt_attr->destroy(x)) - #endif /* DHCP_OPTION_MACROS */ #endif /* DHCP_OPTION_H */ --- 78,85 ---- #define DHCP_OPT_TO_USER_STRING(x) (x->opt_attr->to_user_string(x)) #define DHCP_OPT_TO_NETWORK_DATA(x) (x->opt_attr->to_network_data(x)) ! #define DHCP_OPT_TO_INTERNAL_DATA(x) (dhcp_opt_get_host_data(x)) #define DHCP_OPT_DESTROY(x) (x->opt_attr->destroy(x)) #endif /* DHCP_OPTION_H */ |