[dhcp-agent-commits] dhcp-agent/src dhcp-client-conf.c,1.9,1.10 dhcp-client-conf.h,1.6,1.7 dhcp-clie
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2002-12-19 06:51:03
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv6136/src Modified Files: dhcp-client-conf.c dhcp-client-conf.h dhcp-client-states.c dhcp-client.c dhcp-client.h Log Message: HUPing now rereads config Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-client-conf.c 19 Dec 2002 03:11:45 -0000 1.9 --- dhcp-client-conf.c 19 Dec 2002 06:50:59 -0000 1.10 *************** *** 285,295 **** static int client_conf_load_options(client_conf_t *cc) { - char *fname; conf_t *conf; list_t *directives; ! fname = get_conf_options_fname(cc); ! ! conf = conf_create(commands, fname); if(conf_compile_directives(conf) == CONF_ERROR) { --- 285,292 ---- static int client_conf_load_options(client_conf_t *cc) { conf_t *conf; list_t *directives; ! conf = conf_create(commands, cc->conf_file); if(conf_compile_directives(conf) == CONF_ERROR) { *************** *** 307,310 **** --- 304,308 ---- } + conf_destroy(conf); return 0; } *************** *** 460,463 **** --- 458,463 ---- cc = xcalloc(sizeof(client_conf_t)); cc->interface = interface; + cc->conf_file = get_conf_options_fname(cc); + cc->parameters.group_type = DIRECTIVE_GROUP_NULL; /* set top level to catchall group. */ *************** *** 470,476 **** } void client_conf_destroy(client_conf_t *cc) { ! /* FIXME: more to cleanup. */ xfree(cc); } --- 470,513 ---- } + static void params_destroy(conf_params_t *params, uint8_t topflag) + { + list_t *params_list; + conf_params_t *lower_params; + + for(params_list = params->lower_params; + params_list; params_list = params_list->next) { + + lower_params = params_list->data; + params_destroy(lower_params, 0); + + } + + if(params->client_hostname) + xfree(params->client_hostname); + + if(!topflag) + xfree(params); + } + void client_conf_destroy(client_conf_t *cc) { ! /* recursively kill all the parameters we've collected. */ ! ! params_destroy(&cc->parameters, 1); ! ! /* free up the client conf structure. */ ! xfree(cc->conf_file); xfree(cc); + + return; + + } + + int client_conf_reread(client_conf_t *cc) + { + if(client_conf_load_options(cc)){ + return 1; + } + + return 0; } Index: dhcp-client-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-client-conf.h 19 Dec 2002 03:11:45 -0000 1.6 --- dhcp-client-conf.h 19 Dec 2002 06:50:59 -0000 1.7 *************** *** 84,86 **** --- 84,88 ---- extern const char *client_conf_get_hostname(client_conf_t *cc); + extern int client_conf_reread(client_conf_t *cc); + #endif /* DHCP_CLIENT_CONF_H */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dhcp-client-states.c 19 Dec 2002 03:50:41 -0000 1.13 --- dhcp-client-states.c 19 Dec 2002 06:50:59 -0000 1.14 *************** *** 613,620 **** rawnet_up(dc->rawnet); ! return STATE_FATAL_ERROR; /* it doesn't matter what we return here really. ! * since we're supposed to detect an interrupt ! * as soon as we get back. set as fatal error ! * to catch any bugs. */ } --- 613,617 ---- rawnet_up(dc->rawnet); ! return STATE_WAIT; /* we want to return back to this state if the interrupt wasn't an alarm. */ } *************** *** 630,634 **** list_t *cached_options; ! INFO_MESSAGE("shutting down."); if(dc) { /* only do clean up if we can. */ --- 627,631 ---- list_t *cached_options; ! INFO_MESSAGE("shutting down"); if(dc) { /* only do clean up if we can. */ *************** *** 744,745 **** --- 741,743 ---- return STATE_WAIT; } + Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-client.c 16 Dec 2002 10:14:31 -0000 1.10 --- dhcp-client.c 19 Dec 2002 06:50:59 -0000 1.11 *************** *** 217,222 **** case INTERRUPT_HUP: ! /* for now shutdown. */ ! state = STATE_DO_SHUTDOWN; break; --- 217,227 ---- case INTERRUPT_HUP: ! /* re-read configuration. */ ! ! INFO_MESSAGE("re-reading configuration"); ! if(client_conf_reread(dc->conf)) { ! WARN_MESSAGE("could not read configuration. using previous configuration."); ! } ! break; *************** *** 373,377 **** * * Read the cache, and initialize our state. ! * Read configuration info, or initialize it if needed. * Acquire a handle on the interface control. * Acquire a handle on the rawnet driver. --- 378,382 ---- * * Read the cache, and initialize our state. ! * Read our configuration. * Acquire a handle on the interface control. * Acquire a handle on the rawnet driver. Index: dhcp-client.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-client.h 16 Dec 2002 10:14:31 -0000 1.7 --- dhcp-client.h 19 Dec 2002 06:50:59 -0000 1.8 *************** *** 63,67 **** /* DHCP client states. */ - #define STATE_DISCOVER_OFFER 0 #define STATE_REQUEST_ACK 1 --- 63,66 ---- |