dhcp-agent-commits Mailing List for dhcp-agent (Page 23)
Status: Alpha
Brought to you by:
actmodern
You can subscribe to this list here.
2002 |
Jan
|
Feb
(33) |
Mar
|
Apr
|
May
(19) |
Jun
(61) |
Jul
(12) |
Aug
|
Sep
(5) |
Oct
(31) |
Nov
(24) |
Dec
(56) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(9) |
Feb
|
Mar
(16) |
Apr
(4) |
May
(68) |
Jun
(70) |
Jul
(100) |
Aug
(54) |
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(7) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(8) |
Oct
(5) |
Nov
(6) |
Dec
(4) |
2008 |
Jan
(9) |
Feb
(20) |
Mar
(32) |
Apr
(18) |
May
(19) |
Jun
(12) |
Jul
(23) |
Aug
(7) |
Sep
(15) |
Oct
(22) |
Nov
(50) |
Dec
(68) |
2009 |
Jan
(63) |
Feb
(23) |
Mar
(43) |
Apr
(50) |
May
(110) |
Jun
(103) |
Jul
(71) |
Aug
(26) |
Sep
(16) |
Oct
(31) |
Nov
(8) |
Dec
(13) |
2010 |
Jan
(6) |
Feb
(6) |
Mar
(36) |
Apr
(57) |
May
(67) |
Jun
(70) |
Jul
(44) |
Aug
(46) |
Sep
(27) |
Oct
(2) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: <act...@us...> - 2002-12-21 18:14:02
|
Update of /cvsroot/dhcp-agent/dhcp-agent/conf In directory sc8-pr-cvs1:/tmp/cvs-serv19755/conf Modified Files: networking-basic.conf Log Message: added enable do-find-best-router-icmp Index: networking-basic.conf =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/conf/networking-basic.conf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** networking-basic.conf 19 Dec 2002 03:55:54 -0000 1.1 --- networking-basic.conf 21 Dec 2002 18:13:59 -0000 1.2 *************** *** 4,9 **** # We only ask for network setup parameters. # - # Thamer Alharbash <tm...@wh...> - # # This will setup dhcp to accept the following configuration --- 4,7 ---- *************** *** 59,61 **** # ! # set do-icmp-find-best-router = no; --- 57,59 ---- # ! enable do-find-best-router-icmp = yes; |
From: <act...@us...> - 2002-12-21 18:13:13
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv19523/src Modified Files: dhcp-client-conf.h dhcp-client-conf.c dhcp-conf.c Log Message: new keyword enable Index: dhcp-client-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-client-conf.h 19 Dec 2002 06:50:59 -0000 1.7 --- dhcp-client-conf.h 21 Dec 2002 18:13:10 -0000 1.8 *************** *** 48,52 **** int default_interface_mtu; /* our default interface mtu. */ ! uint8_t do_icmp_router_discovery; /* perform router discovery via icmp. */ list_t *lower_params; /* linked list to child parameters. */ --- 48,52 ---- int default_interface_mtu; /* our default interface mtu. */ ! uint8_t do_measure_router_latency_icmp; /* perform router latency discovery via icmp. */ list_t *lower_params; /* linked list to child parameters. */ *************** *** 61,74 **** } client_conf_t; typedef int (*directive_handler_t)(conf_params_t *param, void *directive_data, directive_group_t group_type, void *group_data); ! enum directive_types { DIRECTIVE_GROUP = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST, DIRECTIVE_REQUIRE, DIRECTIVE_SERVER_GROUP }; /* symbols for variable substitution. */ enum var_symbols { CLIENT_VAR_HOSTNAME = 0, CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, CLIENT_VAR_INTERFACE_MTU }; enum server_symbols { CLIENT_SERVER_IP = 0, CLIENT_SERVER_MAC }; enum directive_group_t { DIRECTIVE_GROUP_NULL = 0, DIRECTIVE_GROUP_IP_ADDRESS, DIRECTIVE_GROUP_MAC_ADDRESS }; --- 61,80 ---- } client_conf_t; + /* typedef of directive handler. */ typedef int (*directive_handler_t)(conf_params_t *param, void *directive_data, directive_group_t group_type, void *group_data); ! /* directive types. */ ! enum directive_types { DIRECTIVE_SET_BOOLEAN = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST, DIRECTIVE_REQUIRE, DIRECTIVE_SERVER_GROUP }; /* symbols for variable substitution. */ enum var_symbols { CLIENT_VAR_HOSTNAME = 0, CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, CLIENT_VAR_INTERFACE_MTU }; + /* symbols for boolean variable substitution */ + enum var_boolean_symbols { CLIENT_VAR_DO_MEASURE_ROUTER_LATENCY_ICMP = 0 }; + /* server symbol substitution. */ enum server_symbols { CLIENT_SERVER_IP = 0, CLIENT_SERVER_MAC }; + /* directive groups. */ enum directive_group_t { DIRECTIVE_GROUP_NULL = 0, DIRECTIVE_GROUP_IP_ADDRESS, DIRECTIVE_GROUP_MAC_ADDRESS }; Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-client-conf.c 21 Dec 2002 17:06:20 -0000 1.12 --- dhcp-client-conf.c 21 Dec 2002 18:13:10 -0000 1.13 *************** *** 51,54 **** --- 51,58 ---- }; + static const char *var_boolean_strings[] = { + "do-find-best-router-icmp", + }; + /* strings for ip address or mac address with server command. */ static const char *server_strings[] = { *************** *** 72,77 **** --- 76,89 ---- }; + static const arg_symbol_t var_boolean_symbols[] = { + CLIENT_VAR_DO_MEASURE_ROUTER_LATENCY_ICMP, + }; + /* argument types, string array pointers, and symbol array pointers */ + static const arg_type_t var_boolean_arg_types[] = { CONF_IDENTIFIER, CONF_ASSIGNMENT, CONF_BOOLEAN }; + static const char **var_boolean_arg_strings[] = { var_boolean_strings, NULL, NULL }; + static const arg_symbol_t *var_boolean_arg_symbols[] = { var_boolean_symbols, NULL, NULL }; + static const arg_type_t var_arg_types[] = { CONF_IDENTIFIER, CONF_ASSIGNMENT, CONF_STRING }; static const char **var_arg_strings[] = { var_strings, NULL, NULL }; *************** *** 102,105 **** --- 114,127 ---- }; + /* set command with boolean. */ + static const command_t command_set_boolean = { + DIRECTIVE_SET_BOOLEAN, + "enable", + 3, + var_boolean_arg_strings, + var_boolean_arg_types, + var_boolean_arg_symbols, + }; + /* request command. */ static const command_t command_request = { *************** *** 133,136 **** --- 155,159 ---- static const command_t *commands[] = { + &command_set_boolean, &command_set, &command_request, *************** *** 157,169 **** /* forward declaration of directive handlers. */ ! static int directive_group_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_set_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_request_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_require_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_server_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); /* indexed by directive types in dhcp-client-conf.h . */ directive_handler_t directive_handlers[] = { ! directive_group_handler, directive_set_handler, directive_request_handler, --- 180,193 ---- /* forward declaration of directive handlers. */ ! static int directive_group_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_set_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_set_boolean_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_request_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data); ! 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); /* indexed by directive types in dhcp-client-conf.h . */ directive_handler_t directive_handlers[] = { ! directive_set_boolean_handler, directive_set_handler, directive_request_handler, *************** *** 273,276 **** --- 297,317 ---- } + static int client_conf_set_variable_boolean(conf_params_t *params, arg_symbol_t var_symbol, uint8_t bool_val) + { + + switch(var_symbol) { + + case CLIENT_VAR_DO_MEASURE_ROUTER_LATENCY_ICMP: + params->do_measure_router_latency_icmp = bool_val; + break; + + default: + return 1; + + } + + return 0; + } + static char *get_conf_options_fname(client_conf_t *cc) { *************** *** 448,451 **** --- 489,512 ---- params->lower_params = add_to_list(params->lower_params, new_params); + + return 0; + } + + static int directive_set_boolean_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data) + { + directive_t *directive = directive_data; + list_t *args; + arg_symbol_t *var_symbol; + uint8_t *var_value; + + args = directive->arguments; + + var_symbol = args->data; + var_value = args->next->next->data; + + if(client_conf_set_variable_boolean(params, *var_symbol, *var_value)) { + ERROR_MESSAGE("configuration: error unable to set boolean variable %s", var_strings[*var_symbol], var_value); + return 1; + } return 0; Index: dhcp-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-conf.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-conf.c 21 Dec 2002 17:06:20 -0000 1.6 --- dhcp-conf.c 21 Dec 2002 18:13:10 -0000 1.7 *************** *** 422,427 **** directive = compile_command(conf, command); if(command == NULL) ! continue; /* try to compile any other matching command: ! this lets us set the same command name with different arguments. */ return directive; --- 422,426 ---- directive = compile_command(conf, command); if(command == NULL) ! break; return directive; |
From: <act...@us...> - 2002-12-21 17:13:18
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv3931 Modified Files: dhcp-client.c Log Message: correctly gives error for work_directory problems Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** dhcp-client.c 21 Dec 2002 16:17:52 -0000 1.14 --- dhcp-client.c 21 Dec 2002 17:13:14 -0000 1.15 *************** *** 337,356 **** /* Switch into our work directory */ - if(chdir(work_dir) < 0) { ! /* If it isn't there create it. ! * Since we're not setuid we ! * assume the root user knows what he's ! * doing and that it's ! * safe to create this directory. ! * ! */ if(mkdir(work_dir, S_IRWXU) < 0) FATAL_MESSAGE("cannot create work directory", strerror(errno)); - - if(chdir(work_dir) < 0) - FATAL_MESSAGE("cannot enter work directory", work_dir); } return; --- 337,357 ---- /* Switch into our work directory */ ! /* If it isn't there create it. ! * Since we're not setuid we ! * assume the root user knows what he's ! * doing and that it's ! * safe to create this directory. ! * ! */ ! ! if(!file_exists(work_dir)) { if(mkdir(work_dir, S_IRWXU) < 0) FATAL_MESSAGE("cannot create work directory", strerror(errno)); } + + if(chdir(work_dir) < 0) + FATAL_MESSAGE("cannot enter work directory", work_dir); return; |
From: <act...@us...> - 2002-12-21 17:12:38
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv3632 Modified Files: dhcp-files.c Log Message: using stat for file_exists Index: dhcp-files.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-files.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-files.c 16 Nov 2002 00:23:43 -0000 1.3 --- dhcp-files.c 21 Dec 2002 17:12:34 -0000 1.4 *************** *** 87,99 **** int file_exists(const char *fname) { ! FILE *fp; ! /* use stdio. fixme: should we stat()? */ ! fp = fopen(fname, "r"); ! if(fp != NULL) { ! fclose(fp); ! return 1; ! } else return 0; } --- 87,97 ---- int file_exists(const char *fname) { ! struct stat stat_buf; ! if(stat(fname, &stat_buf)) { return 0; + } + + return 1; } |
From: <act...@us...> - 2002-12-21 17:06:27
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1626 Modified Files: dhcp-client-conf.c dhcp-conf.c Log Message: more error messages at conf parser level Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-conf.c 21 Dec 2002 16:26:56 -0000 1.11 --- dhcp-client-conf.c 21 Dec 2002 17:06:20 -0000 1.12 *************** *** 293,297 **** if(conf_compile_directives(conf) == CONF_ERROR) { ! ERROR_MESSAGE("error reading conf file: %s at line %s", cc->conf_file, conf_get_line_no(conf)); conf_destroy(conf); return 1; --- 293,297 ---- if(conf_compile_directives(conf) == CONF_ERROR) { ! ERROR_MESSAGE("error reading conf file: %s at line %d", cc->conf_file, conf_get_line_no(conf)); conf_destroy(conf); return 1; Index: dhcp-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-conf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-conf.c 21 Dec 2002 16:26:56 -0000 1.5 --- dhcp-conf.c 21 Dec 2002 17:06:20 -0000 1.6 *************** *** 209,212 **** --- 209,215 ---- } + if(identifier_symbol == NULL) + ERROR_MESSAGE("unknown identifier: %s\n", string); + return identifier_symbol; } *************** *** 240,243 **** --- 243,247 ---- } else { + ERROR_MESSAGE("unable to parse: %s into address", string); return NULL; } *************** *** 289,292 **** --- 293,297 ---- } else { + ERROR_MESSAGE("%s is not a boolean value as expected. legal boolean values are \"yes\" and \"no\""); bool_val = NULL; } *************** *** 327,331 **** if(string == NULL) { ! purge_list(string_list, NULL); return NULL; --- 332,337 ---- if(string == NULL) { ! ! ERROR_MESSAGE("no string list found at %d\n", conf_get_line_no(conf)); purge_list(string_list, NULL); return NULL; *************** *** 371,374 **** --- 377,381 ---- command->argument_symbols[i]); if(args == NULL) { + ERROR_MESSAGE("unable to compile directive at line %d\n", conf_get_line_no(conf)); directive_destroy(directive); return NULL; *************** *** 384,387 **** --- 391,395 ---- atom = get_next_atom_ignore_newlines(conf->parser); if(atom != PARSER_ATOM_SEMICOLON) { + ERROR_MESSAGE("semi colon terminator not present where expected at line: %d\n", conf_get_line_no(conf)); directive_destroy(directive); return NULL; |
From: <act...@us...> - 2002-12-21 16:51:56
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv30548 Modified Files: dhcp-client-control.c dhcp-libutil.h dhcp-stringbuffer.c dhcp-util.c Log Message: fixed up error message handling Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-client-control.c 19 Dec 2002 03:11:45 -0000 1.8 --- dhcp-client-control.c 21 Dec 2002 16:51:53 -0000 1.9 *************** *** 143,147 **** dc->conf = create_client_conf(dc->interface); if(dc->conf == NULL) { ! ERROR_MESSAGE("could not read client conf."); dhcp_client_control_destroy(dc); return NULL; --- 143,147 ---- dc->conf = create_client_conf(dc->interface); if(dc->conf == NULL) { ! ERROR_MESSAGE("while reading client conf."); dhcp_client_control_destroy(dc); return NULL; Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** dhcp-libutil.h 21 Dec 2002 16:26:56 -0000 1.14 --- dhcp-libutil.h 21 Dec 2002 16:51:53 -0000 1.15 *************** *** 212,216 **** extern void stringbuffer_clear(stringbuffer * sb); extern const char *stringbuffer_getnextline(stringbuffer * sb, const char *cptr); ! extern void stringbuffer_marknewlines(stringbuffer * sb); extern void stringbuffer_set(stringbuffer * dest, const char *s); extern void stringbuffer_align(stringbuffer * sb, int begin, int end); --- 212,216 ---- extern void stringbuffer_clear(stringbuffer * sb); extern const char *stringbuffer_getnextline(stringbuffer * sb, const char *cptr); ! extern int stringbuffer_marknewlines(stringbuffer * sb); extern void stringbuffer_set(stringbuffer * dest, const char *s); extern void stringbuffer_align(stringbuffer * sb, int begin, int end); *************** *** 289,293 **** /* Line length for messages before breaking into a new line. */ ! #define MESSAGE_LINE_LENGTH 60 /* timeout as per rfc2131 */ --- 289,293 ---- /* Line length for messages before breaking into a new line. */ ! #define MESSAGE_LINE_LENGTH 70 /* timeout as per rfc2131 */ Index: dhcp-stringbuffer.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-stringbuffer.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-stringbuffer.c 19 Dec 2002 17:20:23 -0000 1.7 --- dhcp-stringbuffer.c 21 Dec 2002 16:51:53 -0000 1.8 *************** *** 424,430 **** * null terminators inside of them. */ ! void stringbuffer_marknewlines(stringbuffer * sb) { char *c; /* first append one null termination to the end --- 424,431 ---- * null terminators inside of them. */ ! int stringbuffer_marknewlines(stringbuffer * sb) { char *c; + int newline_count = 0; /* first append one null termination to the end *************** *** 436,441 **** while(1) { ! if(*c == '\n') *c = 0; c++; --- 437,444 ---- while(1) { ! if(*c == '\n') { ! newline_count++; *c = 0; + } c++; *************** *** 444,448 **** } ! return; } --- 447,451 ---- } ! return newline_count; /* return our line count. */ } Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-util.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-util.c 19 Dec 2002 03:11:45 -0000 1.9 --- dhcp-util.c 21 Dec 2002 16:51:53 -0000 1.10 *************** *** 86,98 **** stringbuffer_avprintf(msg_sb, fmt, ap); ! stringbuffer_align(msg_sb, 0, MESSAGE_LINE_LENGTH - stringbuffer_getlen(prefix_sb)); stringbuffer_marknewlines(msg_sb); if(interactive == 1) { while((ptr = stringbuffer_getnextline(msg_sb, ptr)) != NULL) ! fprintf(stderr, "%s : %s%s\n", getprogname(), stringbuffer_getstring(prefix_sb), ptr); } else { while((ptr = stringbuffer_getnextline(msg_sb, ptr)) != NULL) error_log(ptr); } --- 86,105 ---- stringbuffer_avprintf(msg_sb, fmt, ap); ! stringbuffer_align(msg_sb, 10, MESSAGE_LINE_LENGTH - strlen(getprogname())); stringbuffer_marknewlines(msg_sb); if(interactive == 1) { + + if(stringbuffer_getlen(prefix_sb)) /* only print prefix on first line if it is available. */ + fprintf(stderr, "%s : %s\n", getprogname(), stringbuffer_getstring(prefix_sb)); + while((ptr = stringbuffer_getnextline(msg_sb, ptr)) != NULL) ! fprintf(stderr, "%s : %s\n", getprogname(), ptr); ! } else { + while((ptr = stringbuffer_getnextline(msg_sb, ptr)) != NULL) error_log(ptr); + } |
From: <act...@us...> - 2002-12-21 16:26:58
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv22285 Modified Files: dhcp-conf.c dhcp-libutil.h dhcp-client-conf.c Log Message: added ded more error messages Index: dhcp-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-conf.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-conf.c 18 Dec 2002 05:40:38 -0000 1.4 --- dhcp-conf.c 21 Dec 2002 16:26:56 -0000 1.5 *************** *** 526,527 **** --- 526,532 ---- return conf->directives; } + + int conf_get_line_no(conf_t *conf) + { + return parser_get_line_no(conf->parser); + } Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dhcp-libutil.h 19 Dec 2002 17:20:36 -0000 1.13 --- dhcp-libutil.h 21 Dec 2002 16:26:56 -0000 1.14 *************** *** 272,275 **** --- 272,276 ---- extern int conf_compile_directives(conf_t *conf); extern list_t *conf_get_directives(conf_t *conf); + extern int conf_get_line_no(conf_t *conf); /* constants. */ Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-client-conf.c 19 Dec 2002 06:50:59 -0000 1.10 --- dhcp-client-conf.c 21 Dec 2002 16:26:56 -0000 1.11 *************** *** 224,229 **** } ! if(i > MAX_OPTIONS_HANDLED) return 1; } --- 224,231 ---- } ! if(i > MAX_OPTIONS_HANDLED) { ! ERROR_MESSAGE("specified unknown option: %s", option_string); return 1; + } } *************** *** 291,294 **** --- 293,297 ---- if(conf_compile_directives(conf) == CONF_ERROR) { + ERROR_MESSAGE("error reading conf file: %s at line %s", cc->conf_file, conf_get_line_no(conf)); conf_destroy(conf); return 1; *************** *** 364,367 **** --- 367,371 ---- if(client_conf_set_variable(params, *var_symbol, var_value)) { + ERROR_MESSAGE("configuration: error unable to set variable %s to %s", var_strings[*var_symbol], var_value); return 1; } |
From: <act...@us...> - 2002-12-21 16:17:55
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv19452 Modified Files: dhcp-client-states.c dhcp-client.c Log Message: fixed up alarm handling Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dhcp-client-states.c 19 Dec 2002 18:00:30 -0000 1.16 --- dhcp-client-states.c 21 Dec 2002 16:17:52 -0000 1.17 *************** *** 602,608 **** next_timer = timer_peek_next_timer(dc->timer); - time_before = time(NULL); if(timer_set_next(dc->timer)) { FATAL_MESSAGE --- 602,608 ---- next_timer = timer_peek_next_timer(dc->timer); time_before = time(NULL); + /* now fire off the next timer. */ if(timer_set_next(dc->timer)) { FATAL_MESSAGE *************** *** 618,629 **** * difference. */ - time_after = time(NULL); - time_interval = time_after - time_before; /* number of seconds elapsed. */ - if(peek_interrupt_type() != INTERRUPT_ALARM) { if(time_interval < 0) { /* someone has been b0rking the system clock. */ WARN_MESSAGE("the system clock is skewed or you've been messing with it. i'm going to just use the next timer and hope for the best."); } else { --- 618,631 ---- * difference. */ if(peek_interrupt_type() != INTERRUPT_ALARM) { + time_after = time(NULL); + time_interval = time_after - time_before; /* number of seconds elapsed. */ + if(time_interval < 0) { + /* someone has been b0rking the system clock. */ WARN_MESSAGE("the system clock is skewed or you've been messing with it. i'm going to just use the next timer and hope for the best."); + } else { *************** *** 637,644 **** next_timer = 1; /* give at least one second. */ timer_add_trigger(dc->timer, next_timer, timer_get_current_id(dc->timer)); } } ! /* bring the raw network devices back up. we'll probably * need them: FIXME, revamp into one network module that uses --- 639,653 ---- next_timer = 1; /* give at least one second. */ + /* we just set our next timer to atleast one. this + * has one implication. if we're firing off other + * signals to the daemon (HUP for example) all the + * time it will never get the alarm. opinion: you + * shouldn't HUP your daemon constantly. otherwise + * we at most lag by one second which is not bad. */ + timer_add_trigger(dc->timer, next_timer, timer_get_current_id(dc->timer)); } } ! /* bring the raw network devices back up. we'll probably * need them: FIXME, revamp into one network module that uses Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dhcp-client.c 19 Dec 2002 18:00:31 -0000 1.13 --- dhcp-client.c 21 Dec 2002 16:17:52 -0000 1.14 *************** *** 210,213 **** --- 210,214 ---- case INTERRUPT_NONE: + /* no more interrupts. we're done. */ break; *************** *** 227,230 **** --- 228,233 ---- case INTERRUPT_ALARM: + + /* if alarm then check for timer type so we can set our state accordingly. */ switch (timer_get_current_id(dc->timer)) { |
From: <act...@us...> - 2002-12-19 18:04:03
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv14156 Modified Files: config.h.in Added Files: configure.ac Removed Files: configure.in Log Message: now using configure.ac and not configure.in --- NEW FILE: configure.ac --- dnl $Header: /cvsroot/dhcp-agent/dhcp-agent/configure.ac,v 1.1 2002/12/19 18:00:26 actmodern Exp $ dnl dnl Second try at writing a more coherent configure script. dnl We've layed it out per the gnu autoconf manual dnl Please look at: dnl http://www.gnu.org/manual/autoconf/html_node/configure.ac-Layout.html#configure.ac%20Layout dnl before making any changes. dnl dnl -- tm...@wh... dnl dnl init dnl AC_PREREQ(2.53) AC_INIT(dhcp-agent, 0.38, tm...@wh...) AM_INIT_AUTOMAKE(dhcp-agent, 0.38) AC_CONFIG_SRCDIR(src/dhcp-client.c) dnl dnl additional arguments to autoconf dnl AC_ARG_WITH(libdnet-prefix,[ --with-libdnet-prefix=PREFIX Prefix where libdnet is installed (optional)], dnet_prefix="$withval", dnet_prefix="") AC_ARG_WITH(libpcap-prefix,[ --with-libpcap-prefix=PREFIX Prefix where libpcap is installed (optional)], pcap_prefix="$withval", pcap_prefix="") AC_ARG_WITH(libpcap-prefix,[ --client-work-dir=WORK_DIR Default dhcpclient work dir (optional)], client_work_dir="$withval", client_work_dir="/etc/dhcp-client") dnl check for CC, INSTALL, and sane make AC_PROG_CC AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LIBTOOL dnl check header files we should have AC_HEADER_STDC AC_CHECK_HEADERS(inttypes.h signal.h varargs.h stdarg.h sys/utsname.h getopt.h) dnl dnl check for types dnl AC_CHECK_TYPE(sig_atomic_t, [AC_DEFINE(HAVE_SIG_ATOMIC_T, 1, [have sigatomic_t])], [], [#include <signal.h>]) AC_CHECK_TYPE(struct bpf_timeval, [AC_DEFINE(HAVE_BPF_TIMEVAL, 1, [have struct bpf_timeval])], [], [#include <sys/types.h> #include <sys/time.h> #include <sys/ioctl.h> #include <net/bpf.h> ]) dnl try finding or generating our own C99 stdint macros AC_WF_TRY_PRI_MACROS if test -z "$have_primacros"; then echo -n "attempting to generate stdint conversion macros..." AC_WF_GET_PRI_MACROS AC_DEFINE(HAVE_PRIMACROS_H, 1, [ generated our own primacros ]) echo " done!" fi AC_TYPE_SIGNAL dnl check for functions AC_CHECK_FUNCS(strdup uname calloc daemon rename sysconf getrusage getprogname) dnl other checks dnl check if kill(pid, 0) can be used to detect a process AC_WF_CHECK_KILL_SIGNAL_DETECT dnl check for BPF_IMMEDIATE flag AC_WF_CHECK_BPF_IMMEDIATE dnl check for __progname AC_MSG_CHECKING(for __progname) AC_TRY_LINK([ #include <stdlib.h> #include <stdio.h> extern const char *__progname; ], [ __progname = 0; ], [ have_progname="yes" ], [ have_progname="no" ]) if test $have_progname = "yes"; then AC_DEFINE(HAVE_PROGNAME, 1, [have __progname var ]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi dnl pcap sifting if test -z "$pcap_prefix"; then dnl excessive pcap sifting AC_WF_CHECK_PCAP_LIB_DIR PCAP_LIB="-L$ac_pcap_lib_dir -lpcap" AC_WF_CHECK_PCAP_HEADER_DIR PCAP_INC="-I$ac_pcap_header_dir" else dnl if we've been passed the correct options just force a set. PCAP_INC="-I$pcap_prefix/include" PCAP_LIB="-L$pcap_prefix/lib -lpcap" fi dnl dnl libdnet sifting; actually it's a lot more well behaved dnl than pcap. dnl begin by looking for dnet-config if we find it, then dnl just use it to get the include and lib dirs. dnl if test -z "$dnet_prefix"; then AC_PATH_PROGS(DNET_PATH, dnet-config, [ "no" ]) if test $DNET_PATH = "no"; then dnl try linking by default path AC_CHECK_LIB(dnet, eth_open, DNET_LIB="-ldnet", AC_MSG_ERROR(`libdnet not found http://libdnet.sourceforge.net/ to get a copy', 1)) DNET_INC="" else DNET_LIB="`dnet-config --libs`" DNET_INC="`dnet-config --cflags`" fi else DNET_LIB="-L$dnet_prefix/lib -ldnet" DNET_INC="-I$dnet_prefix/include" fi AC_SUBST(PCAP_LIB) AC_SUBST(PCAP_INC) AC_SUBST(DNET_LIB) AC_SUBST(DNET_INC) AC_DEFINE_UNQUOTED(CLIENT_WORK_DIR, "$client_work_dir", [ default client work directory]) dnl kill defs DEFS="" AC_SUBST(DEFS) AM_CONFIG_HEADER(config.h) AC_OUTPUT([Makefile src/Makefile man/Makefile]) echo echo "DHCP Agent build configuration successful!" echo Index: config.h.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/config.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config.h.in 30 Oct 2002 05:00:46 -0000 1.2 --- config.h.in 19 Dec 2002 18:00:25 -0000 1.3 *************** *** 1,3 **** ! /* config.h.in. Generated from configure.in by autoheader. */ /* default client work directory */ --- 1,3 ---- ! /* config.h.in. Generated from configure.ac by autoheader. */ /* default client work directory */ --- configure.in DELETED --- |
From: <act...@us...> - 2002-12-19 18:02:44
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv11843 Modified Files: TODO Log Message: more todo Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TODO 18 Dec 2002 05:46:34 -0000 1.3 --- TODO 19 Dec 2002 17:57:16 -0000 1.4 *************** *** 114,115 **** --- 114,117 ---- -- cache code needs to escape what it saves to '"' or the '\' since both are interpreted by our lower level parser. + + -- check for race condition -- even if it is tiny -- in client_wait |
From: <act...@us...> - 2002-12-19 18:02:37
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv14156/src Modified Files: dhcp-client-states.c dhcp-client.c Log Message: now using configure.ac and not configure.in Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** dhcp-client-states.c 19 Dec 2002 17:20:36 -0000 1.15 --- dhcp-client-states.c 19 Dec 2002 18:00:30 -0000 1.16 *************** *** 619,623 **** time_after = time(NULL); - time_interval = time_after - time_before; /* number of seconds elapsed. */ --- 619,622 ---- *************** *** 628,632 **** WARN_MESSAGE("the system clock is skewed or you've been messing with it. i'm going to just use the next timer and hope for the best."); } else { - /* we did not receive a timer interrupt. --- 627,630 ---- Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-client.c 19 Dec 2002 17:20:36 -0000 1.12 --- dhcp-client.c 19 Dec 2002 18:00:31 -0000 1.13 *************** *** 520,524 **** do_change_work_dir(); - /* get interface if not specified. */ if(interface == NULL) { --- 520,523 ---- |
From: <act...@us...> - 2002-12-19 17:58:03
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv12387 Modified Files: Makefile.am Log Message: added conf with dist-hook Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.am 29 Oct 2002 17:11:02 -0000 1.1.1.1 --- Makefile.am 19 Dec 2002 17:57:59 -0000 1.2 *************** *** 6,8 **** AUTOMAKE_OPTIONS = foreign SUBDIRS = src man ! EXTRA_DIST = CAVEATS LICENSE README THANKS TODO UPGRADING doc --- 6,11 ---- AUTOMAKE_OPTIONS = foreign SUBDIRS = src man ! EXTRA_DIST = CAVEATS LICENSE README THANKS TODO UPGRADING conf ! ! dist-hook: ! rm -rf `find $(distdir)/conf -name CVS` |
From: <act...@us...> - 2002-12-19 17:20:39
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv17707 Modified Files: dhcp-client-states.c dhcp-client.c dhcp-interrupt.c dhcp-libutil.h dhcp-timer.c Log Message: fixed bug in alarm/hup handling Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** dhcp-client-states.c 19 Dec 2002 06:50:59 -0000 1.14 --- dhcp-client-states.c 19 Dec 2002 17:20:36 -0000 1.15 *************** *** 317,321 **** } ! time_t compensate_timeout_with_timer(dhcp_client_control_t *dc) { uint32_t next_timer; --- 317,321 ---- } ! static time_t compensate_timeout_with_timer(dhcp_client_control_t *dc) { uint32_t next_timer; *************** *** 590,593 **** --- 590,596 ---- int client_wait(dhcp_client_control_t *dc) { + uint32_t next_timer; + time_t time_before, time_after, time_interval; + INFO_MESSAGE("entering wait stage"); *************** *** 595,600 **** rawnet_down(dc->rawnet); ! /* Ask our internal timer to setup our next alarm: this is ! * for rebind, renewal, and expiry in that order. */ if(timer_set_next(dc->timer)) { --- 598,607 ---- rawnet_down(dc->rawnet); ! /* peek and store our next timer in case we get an interrupt ! * which is not a timer interrupt. */ ! ! next_timer = timer_peek_next_timer(dc->timer); ! ! time_before = time(NULL); if(timer_set_next(dc->timer)) { *************** *** 606,609 **** --- 613,646 ---- suspend_for_interrupts(); + /* at this point we may or may not have received a timer + * interrupt. if we have not then setup a timer to go off + * once we return by storing a new timer with the time + * difference. */ + + time_after = time(NULL); + + time_interval = time_after - time_before; /* number of seconds elapsed. */ + + if(peek_interrupt_type() != INTERRUPT_ALARM) { + + if(time_interval < 0) { + /* someone has been b0rking the system clock. */ + WARN_MESSAGE("the system clock is skewed or you've been messing with it. i'm going to just use the next timer and hope for the best."); + } else { + + + /* we did not receive a timer interrupt. + * put the difference as the next timer to go off. */ + + next_timer -= time_interval; /* this is safe since we're promoting the type + * and it can never be < 0 */ + + if(next_timer == 0) + next_timer = 1; /* give at least one second. */ + + timer_add_trigger(dc->timer, next_timer, timer_get_current_id(dc->timer)); + } + } + /* bring the raw network devices back up. we'll probably * need them: FIXME, revamp into one network module that uses Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client.c 19 Dec 2002 06:50:59 -0000 1.11 --- dhcp-client.c 19 Dec 2002 17:20:36 -0000 1.12 *************** *** 204,252 **** * Handle any interrupts here. */ ! check_for_interrupts(); ! switch (got_interrupt_type()) { ! case INTERRUPT_NONE: ! break; ! case INTERRUPT_TERM: ! state = STATE_DO_SHUTDOWN; ! break; ! 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; ! case INTERRUPT_ALARM: ! switch (timer_get_current_id(dc->timer)) { ! case TIMER_RENEW: ! state = STATE_RENEW; ! break; ! case TIMER_IP_LEASE: ! state = STATE_DISCOVER_OFFER; ! break; ! case TIMER_REBIND: ! state = STATE_REBIND; break; default: ! FATAL_MESSAGE("invalid timer type caught. this is a bug. report me."); } - break; - - default: - FATAL_MESSAGE("invalid interrupt type caught. this is a bug. report me."); } --- 204,253 ---- * Handle any interrupts here. */ ! while(check_for_interrupts()) { ! switch (got_interrupt_type()) { ! case INTERRUPT_NONE: ! break; ! case INTERRUPT_TERM: ! state = STATE_DO_SHUTDOWN; ! break; ! 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; ! case INTERRUPT_ALARM: ! switch (timer_get_current_id(dc->timer)) { ! case TIMER_RENEW: ! state = STATE_RENEW; ! break; ! case TIMER_IP_LEASE: ! state = STATE_DISCOVER_OFFER; ! break; ! case TIMER_REBIND: ! state = STATE_REBIND; ! break; ! ! default: ! FATAL_MESSAGE("invalid timer type caught. this is a bug. report me."); ! } break; default: ! FATAL_MESSAGE("invalid interrupt type caught. this is a bug. report me."); } } Index: dhcp-interrupt.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-interrupt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-interrupt.c 16 Nov 2002 00:23:43 -0000 1.2 --- dhcp-interrupt.c 19 Dec 2002 17:20:36 -0000 1.3 *************** *** 69,72 **** --- 69,86 ---- } + int peek_interrupt_type(void) + { + if(have_alarm) + return INTERRUPT_ALARM; + + if(have_hup) + return INTERRUPT_HUP; + + if(have_shutdown) + return INTERRUPT_TERM; + + return INTERRUPT_NONE; + } + /* check which variables ere setup and return. * clear before returning. */ *************** *** 160,164 **** sigprocmask(SIG_SETMASK, &o_mask, NULL); ! return 0; } --- 174,181 ---- sigprocmask(SIG_SETMASK, &o_mask, NULL); ! if(have_shutdown || have_alarm || have_hup) ! return 1; ! else ! return 0; } Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-libutil.h 19 Dec 2002 03:11:45 -0000 1.12 --- dhcp-libutil.h 19 Dec 2002 17:20:36 -0000 1.13 *************** *** 153,156 **** --- 153,157 ---- extern void add_interrupt_handler(int sigtype, void (*sighandler) (int)); extern void remove_interrupt(int sig); + extern int peek_interrupt_type(void); /* alarm handlers. */ Index: dhcp-timer.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-timer.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-timer.c 24 Nov 2002 01:12:12 -0000 1.6 --- dhcp-timer.c 19 Dec 2002 17:20:36 -0000 1.7 *************** *** 34,38 **** #include "dhcp-libutil.h" ! /* compare triggers by returning shortest time as highest. */ static int compare_triggers_shortest(void *trigger1_p, void *trigger2_p) { --- 34,38 ---- #include "dhcp-libutil.h" ! /* compare triggers by returning smallest id as highest. */ static int compare_triggers_shortest(void *trigger1_p, void *trigger2_p) { *************** *** 42,49 **** trigger2 = trigger2_p; ! if(trigger1->seconds > trigger2->seconds) return 1; ! if(trigger1->seconds < trigger2->seconds) return -1; --- 42,49 ---- trigger2 = trigger2_p; ! if(trigger1->id < trigger2->id) return 1; ! if(trigger1->id > trigger2->id) return -1; |
From: <act...@us...> - 2002-12-19 17:20:26
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv17590 Modified Files: dhcp-stringbuffer.c Log Message: added fixmes Index: dhcp-stringbuffer.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-stringbuffer.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-stringbuffer.c 15 Dec 2002 04:59:23 -0000 1.6 --- dhcp-stringbuffer.c 19 Dec 2002 17:20:23 -0000 1.7 *************** *** 71,74 **** --- 71,75 ---- } + /* FIXME: get rid of pesky strlen() */ /* used in aligning -- we try to get words up to end. */ static char *get_string_align(char *s, int end, int *len) *************** *** 134,138 **** { sb->len = 0; ! sb->buf[sb->len] = 0; } --- 135,139 ---- { sb->len = 0; ! sb->buf[0] = 0; } *************** *** 155,159 **** int len = strlen(s); ! /* increase capacity. */ if(sb->capacity <= (len + sb->len)) { --- 156,160 ---- int len = strlen(s); ! /* increase capacity if needed. */ if(sb->capacity <= (len + sb->len)) { *************** *** 183,186 **** --- 184,188 ---- } + /* FIXME: use memcpy() */ /* remove whitespace (including tabs) */ stringbuffer *stringbuffer_trim_whitespace(stringbuffer * sb) |
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 ---- |
From: <act...@us...> - 2002-12-19 03:55:58
|
Update of /cvsroot/dhcp-agent/dhcp-agent/conf In directory sc8-pr-cvs1:/tmp/cvs-serv6629/conf Added Files: README networking-basic.conf Log Message: conf files --- NEW FILE: README --- $Header: /cvsroot/dhcp-agent/dhcp-agent/conf/README,v 1.1 2002/12/19 03:55:54 actmodern Exp $ Example configuration files. Copy these over to /etc/dhcp-client/[interface-name].conf where [interface-name] is the name of the interface you are configuring for. If the interface is called "eth0" you would do, as root: > cp conf-file /etc/dhcp-client/eth0.conf In addition to this please note that the directory is whatever the default directory for the client is. The example configuration files: basic-networking : basic networking. ip, dns, and router setup. Thamer Alharbash <tm...@wh...> --- NEW FILE: networking-basic.conf --- # $Header: /cvsroot/dhcp-agent/dhcp-agent/conf/networking-basic.conf,v 1.1 2002/12/19 03:55:54 actmodern Exp $ # # Basic DHCP client configuration script. # We only ask for network setup parameters. # # Thamer Alharbash <tm...@wh...> # # This will setup dhcp to accept the following configuration # parameters from any dhcp server: # # ip-address, subnet mask, lease time, renewal time, rebinding time, # interface mtu, domain name, dns server # # It will require all of the above. Otherwise uncomment below to be # more flexible # # # IP address requests are implicit we just ask for the other options below. # request subnet-mask, ip-address-lease-time, renewal-time, rebinding-time, domain-name-servers, domain-name, interface-mtu; # # The require directive makes us ignore servers which do not return # all the options we ask for. Uncomment this to accept as # much as we get. # require subnet-mask, ip-address-lease-time, renewal-time, rebinding-time, domain-name-servers, domain-name; # # Additional variable settings. # # Interface MTU # Set up our default interface mtu in case the server does not # give us one. set interface-mtu = 1500; # # DHCP -- try up to three times before giving up. # set dhcp-retries = 3; # # ICMP -- when doing ICMP retry up to three times. # set icmp-retries = 3; # # Router discovery -- should we use ICMP to find the best router? # # set do-icmp-find-best-router = no; |
From: <act...@us...> - 2002-12-19 03:50:44
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv4318 Modified Files: dhcp-client-states.c Log Message: fix to warning message about empty parameter list Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-client-states.c 19 Dec 2002 03:30:15 -0000 1.12 --- dhcp-client-states.c 19 Dec 2002 03:50:41 -0000 1.13 *************** *** 101,106 **** option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! if(option != NULL) { WARN_MESSAGE("sending with empty parameter request list"); options = add_to_list(options, option); } --- 101,107 ---- option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! if(option == NULL) { WARN_MESSAGE("sending with empty parameter request list"); + } else { options = add_to_list(options, option); } |
From: <act...@us...> - 2002-12-19 03:30:20
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv28614 Modified Files: dhcp-client-states.c dhcp-com.c dhcp-convert.c Log Message: fixes to conversion and parameter list handling Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-states.c 19 Dec 2002 03:11:45 -0000 1.11 --- dhcp-client-states.c 19 Dec 2002 03:30:15 -0000 1.12 *************** *** 101,107 **** option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! if(option != NULL) options = add_to_list(options, option); ! /* dhcp message type. */ --- 101,108 ---- option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! if(option != NULL) { ! WARN_MESSAGE("sending with empty parameter request list"); options = add_to_list(options, option); ! } /* dhcp message type. */ Index: dhcp-com.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-com.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-com.c 16 Dec 2002 07:20:42 -0000 1.5 --- dhcp-com.c 19 Dec 2002 03:30:15 -0000 1.6 *************** *** 527,531 **** if(len == 0) { ! WARN_MESSAGE("empty parameter list built!"); return NULL; } --- 527,531 ---- if(len == 0) { ! /* no parameter list. return empty list. */ return NULL; } Index: dhcp-convert.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-convert.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-convert.c 16 Dec 2002 07:20:42 -0000 1.5 --- dhcp-convert.c 19 Dec 2002 03:30:15 -0000 1.6 *************** *** 227,232 **** strdup_wrap_net, xfree} , /* 56 *//* Message */ ! {network_uint16_list_to_string, string_to_uint16_list, ! string_uint16_list_to_network, purge_list_internal} , /* 57 *//* Maximum DHCP message size. */ {network_uint32_to_string, string_to_uint32, --- 227,232 ---- strdup_wrap_net, xfree} , /* 56 *//* Message */ ! {network_uint16_to_string, string_to_uint16, ! string_uint16_to_network, xfree} , /* 57 *//* Maximum DHCP message size. */ {network_uint32_to_string, string_to_uint32, *************** *** 611,615 **** { int16_t tmp; ! tmp = ntohl(*(int16_t *)data); string = int_to_string((void *)&tmp, data_len, size, si); break; --- 611,615 ---- { int16_t tmp; ! tmp = ntohs(*(int16_t *)data); string = int_to_string((void *)&tmp, data_len, size, si); break; *************** *** 638,642 **** { uint16_t tmp; ! tmp = ntohl(*(uint16_t *)data); string = int_to_string((void *)&tmp, data_len, size, si); break; --- 638,642 ---- { uint16_t tmp; ! tmp = ntohs(*(uint16_t *)data); string = int_to_string((void *)&tmp, data_len, size, si); break; |
From: <act...@us...> - 2002-12-19 03:19:12
|
Update of /cvsroot/dhcp-agent/dhcp-agent/conf In directory sc8-pr-cvs1:/tmp/cvs-serv24276/conf Log Message: Directory /cvsroot/dhcp-agent/dhcp-agent/conf added to the repository |
From: <act...@us...> - 2002-12-19 03:18:56
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv24190 Modified Files: configure.in Log Message: now using dhcp-client as directory Index: configure.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** configure.in 30 Oct 2002 05:00:46 -0000 1.2 --- configure.in 19 Dec 2002 03:18:53 -0000 1.3 *************** *** 27,31 **** pcap_prefix="$withval", pcap_prefix="") AC_ARG_WITH(libpcap-prefix,[ --client-work-dir=WORK_DIR Default dhcpclient work dir (optional)], ! client_work_dir="$withval", client_work_dir="/etc/dhcpclient") dnl check for CC, INSTALL, and sane make --- 27,31 ---- pcap_prefix="$withval", pcap_prefix="") AC_ARG_WITH(libpcap-prefix,[ --client-work-dir=WORK_DIR Default dhcpclient work dir (optional)], ! client_work_dir="$withval", client_work_dir="/etc/dhcp-client") dnl check for CC, INSTALL, and sane make |
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv22514 Modified Files: dhcp-client-conf.c dhcp-client-conf.h dhcp-client-control.c dhcp-client-states.c dhcp-ip.c dhcp-librawnet.h dhcp-libutil.h dhcp-util.c Log Message: more stuff Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-client-conf.c 18 Dec 2002 05:40:38 -0000 1.8 --- dhcp-client-conf.c 19 Dec 2002 03:11:45 -0000 1.9 *************** *** 23,28 **** */ - /* THIS ENTIRE THING NEEDS TO BE REDONE. */ - #define MODULE_NAME "dhcp-client-conf" --- 23,26 ---- *************** *** 50,54 **** "dhcp-retries", "icmp-retries", ! "do-icmp-router-discovery", }; --- 48,52 ---- "dhcp-retries", "icmp-retries", ! "interface-mtu", }; *************** *** 66,70 **** CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, ! CLIENT_VAR_DO_ICMP_ROUTER_DISCOVERY, }; --- 64,68 ---- CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, ! CLIENT_VAR_INTERFACE_MTU, }; *************** *** 183,186 **** --- 181,190 ---- } + uint8_t *client_conf_get_opt_required_bit_array(client_conf_t *cc, ip_addr_t ip_addr, eth_addr_t eth_addr) + { + /* FIXME: search lower groups too. */ + return cc->parameters.required_options; + } + int client_conf_get_dhcp_retries(client_conf_t *cc) { *************** *** 253,256 **** --- 257,265 ---- params->icmp_retries = atoi(var_value); + break; + + case CLIENT_VAR_INTERFACE_MTU: + + params->default_interface_mtu = atoi(var_value); break; Index: dhcp-client-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-client-conf.h 18 Dec 2002 05:40:38 -0000 1.5 --- dhcp-client-conf.h 19 Dec 2002 03:11:45 -0000 1.6 *************** *** 43,48 **** --- 43,51 ---- char *client_hostname; /* setting for the hostname option. */ + int dhcp_retries; /* amount of times we should retry dhcp operations. */ int icmp_retries; /* amount of times we should retry icmp operations. */ + int default_interface_mtu; /* our default interface mtu. */ + uint8_t do_icmp_router_discovery; /* perform router discovery via icmp. */ *************** *** 63,68 **** /* symbols for variable substitution. */ ! enum var_symbols { CLIENT_VAR_HOSTNAME = 0, CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, ! CLIENT_VAR_DO_ICMP_ROUTER_DISCOVERY }; enum server_symbols { CLIENT_SERVER_IP = 0, CLIENT_SERVER_MAC }; --- 66,71 ---- /* symbols for variable substitution. */ ! enum var_symbols { CLIENT_VAR_HOSTNAME = 0, CLIENT_VAR_DHCP_RETRIES, CLIENT_VAR_ICMP_RETRIES, CLIENT_VAR_INTERFACE_MTU }; ! enum server_symbols { CLIENT_SERVER_IP = 0, CLIENT_SERVER_MAC }; *************** *** 75,78 **** --- 78,83 ---- extern uint8_t *client_conf_get_opt_bit_array(client_conf_t *cc); + 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 int client_conf_get_dhcp_retries(client_conf_t *cc); extern int client_conf_get_icmp_retries(client_conf_t *cc); Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-client-control.c 16 Dec 2002 10:14:31 -0000 1.7 --- dhcp-client-control.c 19 Dec 2002 03:11:45 -0000 1.8 *************** *** 282,283 **** --- 282,295 ---- return; } + + /* get the server address. */ + + ip_addr_t dhcp_client_get_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr) + { + return dc->sip_addr; + } + + eth_addr_t dhcp_client_get_server_hw_address(dhcp_client_control_t *dc, eth_addr_t eth_addr) + { + return dc->shw_addr; + } Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-client-states.c 18 Dec 2002 05:40:38 -0000 1.10 --- dhcp-client-states.c 19 Dec 2002 03:11:45 -0000 1.11 *************** *** 33,36 **** --- 33,37 ---- #include "dhcp-librawnet.h" + #include "dhcp-options-strings.h" #include "dhcp-client-conf.h" #include "dhcp-cache-entry.h" *************** *** 40,44 **** /*************************** ! * Option List Generation. * ***************************/ --- 41,45 ---- /*************************** ! * option list generation * ***************************/ *************** *** 156,168 **** /****************** ! * Check Routines * ******************/ ! /* check the requested options. ! * we use the globconf option. */ ! static int client_check_requested_options(dhcp_client_control_t *dc) { ! /* FIXME: we default to at least. we need an actual policy in client_conf though. */ return 1; } --- 157,218 ---- /****************** ! * check routines * ******************/ ! /* check the requested options */ static int client_check_requested_options(dhcp_client_control_t *dc) { ! eth_addr_t eth_addr; ! ip_addr_t ip_addr; ! char *eth_addr_string; ! char *ip_addr_string; ! uint8_t *required_options; ! uint8_t received_options[MAX_OPTIONS_HANDLED + 1]; ! dhcp_option_t *dhcp_option; ! int i; ! ! /* get the mac address, and ip address from the packet. */ ! ! ip_addr = ip_get_source_addr(dc->rawnet->ip_p); ! eth_addr = eth_get_src_address(dc->rawnet->ether_p); ! ! eth_addr_string = eth_addr_to_string(eth_addr); ! ip_addr_string = ip_addr_to_string(ip_addr); ! ! /* build our received options array. */ ! ! memset(received_options, 0, sizeof(received_options)); ! dhcp_reset_option_seek(dc->rawnet->dhcp_p); ! ! while((dhcp_option = dhcp_get_next_option(dc->rawnet->dhcp_p)) != NULL) { ! ! /* if it's in our range fill it in or ignore it and give a warning. */ ! if(dhcp_option->tag > MAX_OPTIONS_HANDLED) { ! WARN_MESSAGE("ignoring received option tag which is out of our range: %d", dhcp_option->tag); ! continue; ! } ! ! received_options[dhcp_option->tag] = 1; ! } ! ! /* now ask client-conf if we have the required options. */ ! required_options = client_conf_get_opt_required_bit_array(dc->conf, ip_addr, eth_addr); ! ! /* make sure everything in our required option list is in our requested option list. */ ! for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { ! ! if(required_options[i] && !received_options[i]) { ! WARN_MESSAGE("ignoring offer from server (%s : %s) : failed to supply required option: %s", ! ip_addr_string, eth_addr_string, dhcp_option_printable_string_get(i)); ! ! xfree(ip_addr_string); ! xfree(eth_addr_string); ! ! return 0; ! } ! } ! ! xfree(ip_addr_string); ! xfree(eth_addr_string); return 1; } *************** *** 192,202 **** if(client_check_dhcp(dc) && /* check that the type is an offer. */ dhcp_is_type(dc->rawnet->dhcp_p, DHCP_OFFER_TM) && /* check if the requested options match what we want. */ ! client_check_requested_options(dc)) return 1; ! else return 0; } --- 242,255 ---- if(client_check_dhcp(dc) && + /* check that the type is an offer. */ dhcp_is_type(dc->rawnet->dhcp_p, DHCP_OFFER_TM) && + /* check if the requested options match what we want. */ ! client_check_requested_options(dc)) { return 1; ! } else { return 0; + } } *************** *** 231,235 **** /************* ! * Utilities * *************/ --- 284,288 ---- /************* ! * utilities * *************/ *************** *** 333,337 **** /****************************** ! * DHCP client state routines.* ******************************/ --- 386,390 ---- /****************************** ! * DHCP client state routines * ******************************/ Index: dhcp-ip.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-ip.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-ip.c 16 Nov 2002 00:23:43 -0000 1.3 --- dhcp-ip.c 19 Dec 2002 03:11:45 -0000 1.4 *************** *** 48,57 **** } ! uint32_t ip_get_source_addr(ip_obj * ip) { return (ip->header.ip_src); } ! uint32_t ip_get_dest_addr(ip_obj * ip) { return (ip->header.ip_dst); --- 48,57 ---- } ! ip_addr_t ip_get_source_addr(ip_obj * ip) { return (ip->header.ip_src); } ! ip_addr_t ip_get_dest_addr(ip_obj * ip) { return (ip->header.ip_dst); Index: dhcp-librawnet.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-librawnet.h 16 Dec 2002 07:20:42 -0000 1.5 --- dhcp-librawnet.h 19 Dec 2002 03:11:45 -0000 1.6 *************** *** 465,470 **** extern void ip_write_packet_image(ip_obj * ip, unsigned char *packet); ! extern uint32_t ip_get_source_addr(ip_obj * ip); ! extern uint32_t ip_get_dest_addr(ip_obj * ip); extern unsigned char ip_get_hl(ip_obj * ip); extern uint8_t ip_get_proto(ip_obj * ip); --- 465,470 ---- extern void ip_write_packet_image(ip_obj * ip, unsigned char *packet); ! extern ip_addr_t ip_get_source_addr(ip_obj * ip); ! extern ip_addr_t ip_get_dest_addr(ip_obj * ip); extern unsigned char ip_get_hl(ip_obj * ip); extern uint8_t ip_get_proto(ip_obj * ip); Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-libutil.h 16 Dec 2002 07:20:42 -0000 1.11 --- dhcp-libutil.h 19 Dec 2002 03:11:45 -0000 1.12 *************** *** 179,182 **** --- 179,184 ---- extern ip_addr_t *string_ip_to_ip_addr(const char *string_ip); extern eth_addr_t *string_eth_addr_to_eth_addr(const char *eth_ip); + extern char *eth_addr_to_string(eth_addr_t eth_addr); + extern char *ip_addr_to_string(ip_addr_t ip_addr); extern int is_seven_bit_clean(const char *data, int len); *************** *** 222,226 **** /* interactive mode switch. */ ! void set_interactive(uint8_t interactive_arg); /* timer object. */ --- 224,228 ---- /* interactive mode switch. */ ! extern void set_interactive(uint8_t interactive_arg); /* timer object. */ Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-util.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-util.c 15 Dec 2002 00:22:02 -0000 1.8 --- dhcp-util.c 19 Dec 2002 03:11:45 -0000 1.9 *************** *** 526,527 **** --- 526,560 ---- return eth; } + + /* convert an ethernet address to a string and return a copy. */ + char *eth_addr_to_string(eth_addr_t eth_addr) + { + char *string; + stringbuffer *sb; + + sb = create_stringbuffer(); + stringbuffer_aprintf(sb, "%x:%x:%x:%x:%x:%x", eth_addr.data[0], eth_addr.data[1], + eth_addr.data[2], eth_addr.data[3], eth_addr.data[4], eth_addr.data[5]); + + string = xstrdup(stringbuffer_getstring(sb)); + + destroy_stringbuffer(sb); + return string; + + } + + /* convert an ip address to a string and return a copy. */ + char *ip_addr_to_string(ip_addr_t ip_addr) + { + char *string; + char *ip_string; + struct in_addr in_addr; + + in_addr.s_addr = ip_addr; + ip_string = inet_ntoa(in_addr); + string = xstrdup(ip_string); + + return string; + + } + |
From: <act...@us...> - 2002-12-18 05:46:37
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv25335 Modified Files: TODO Log Message: more stuff to do Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TODO 19 Nov 2002 19:44:43 -0000 1.2 --- TODO 18 Dec 2002 05:46:34 -0000 1.3 *************** *** 106,107 **** --- 106,115 ---- -- conversion routines are taking too long to access. walks through the table can be shortened by direct indexing. + + -- delete resolv in dhcp-util.c since we're not using it. + + -- purge_list only accepts one destructor. we need a way of destroying a list + with differnet data types. + + -- cache code needs to escape what it saves to '"' or the '\' + since both are interpreted by our lower level parser. |
From: <act...@us...> - 2002-12-18 05:40:41
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23391 Modified Files: dhcp-client-conf.c dhcp-client-conf.h dhcp-client-states.c dhcp-conf.c dhcp-options-strings.c Log Message: more code; more fun Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-client-conf.c 16 Dec 2002 07:20:41 -0000 1.7 --- dhcp-client-conf.c 18 Dec 2002 05:40:38 -0000 1.8 *************** *** 53,56 **** --- 53,62 ---- }; + /* strings for ip address or mac address with server command. */ + static const char *server_strings[] = { + "ip-address", + "mac-address", + }; + /* symbol arrays. */ *************** *** 63,66 **** --- 69,77 ---- }; + static const arg_symbol_t server_symbols[] = { + CLIENT_SERVER_IP, + CLIENT_SERVER_MAC, + }; + /* argument types, string array pointers, and symbol array pointers */ *************** *** 73,76 **** --- 84,95 ---- static const arg_symbol_t *request_arg_symbols[] = { NULL }; + static const arg_type_t require_arg_types[] = { CONF_STRING_LIST }; + static const char **require_arg_strings[] = { NULL }; + static const arg_symbol_t *require_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 }; + static const arg_symbol_t *server_arg_symbols[] = { server_symbols, NULL, NULL }; + /* command structures. */ *************** *** 95,101 **** --- 114,142 ---- }; + /* request command. */ + static const command_t command_require = { + DIRECTIVE_REQUIRE, + "require", + 1, + require_arg_strings, + require_arg_types, + require_arg_symbols, + }; + + /* server command. */ + static const command_t command_server = { + DIRECTIVE_SERVER_GROUP, + "server", + 3, + server_arg_strings, + server_arg_types, + server_arg_symbols, + }; + static const command_t *commands[] = { &command_set, &command_request, + &command_require, + &command_server, NULL, }; *************** *** 105,109 **** * passed us by the user. */ - static const int default_config_options[] = { TAG_DHCP_SUBNET_MASK, /* Subnet Mask */ --- 146,149 ---- *************** *** 119,125 **** /* forward declaration of directive handlers. */ ! static int directive_group_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data); ! static int directive_set_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data); ! static int directive_request_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data); /* indexed by directive types in dhcp-client-conf.h . */ --- 159,167 ---- /* forward declaration of directive handlers. */ ! static int directive_group_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_set_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_request_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_require_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); ! static int directive_server_handler(conf_params_t *cc, void *directive_data, directive_group_t group_type, void *group_data); /* indexed by directive types in dhcp-client-conf.h . */ *************** *** 128,131 **** --- 170,175 ---- directive_set_handler, directive_request_handler, + directive_require_handler, + directive_server_handler, }; *************** *** 136,155 **** uint8_t *client_conf_get_opt_bit_array(client_conf_t *cc) { ! return cc->options; } int client_conf_get_dhcp_retries(client_conf_t *cc) { ! return cc->dhcp_retries; } int client_conf_get_icmp_retries(client_conf_t *cc) { ! return cc->icmp_retries; } const char *client_conf_get_hostname(client_conf_t *cc) { ! return cc->client_hostname; } --- 180,199 ---- uint8_t *client_conf_get_opt_bit_array(client_conf_t *cc) { ! return cc->parameters.request_options; } int client_conf_get_dhcp_retries(client_conf_t *cc) { ! return cc->parameters.dhcp_retries; } int client_conf_get_icmp_retries(client_conf_t *cc) { ! return cc->parameters.icmp_retries; } const char *client_conf_get_hostname(client_conf_t *cc) { ! return cc->parameters.client_hostname; } *************** *** 158,162 **** * * * * * * * * * * */ ! static int client_conf_set_variable(client_conf_t *cc, arg_symbol_t var_symbol, const char *var_value) { --- 202,232 ---- * * * * * * * * * * */ ! static int fill_option_bit_array_from_string_list(list_t *strings, uint8_t *option_bit_array) ! { ! char *option_string; ! const char **option_strings = dhcp_option_conf_string_get_array(); ! int i; ! ! for(;strings; strings = strings->next) { ! ! option_string = strings->data; ! ! for(i = 0; i <= MAX_OPTIONS_HANDLED; i++) { ! ! if(!strcmp(option_strings[i], option_string)) { ! option_bit_array[i] = 1; ! break; ! } ! } ! ! if(i > MAX_OPTIONS_HANDLED) ! return 1; ! } ! ! return 0; ! } ! ! ! static int client_conf_set_variable(conf_params_t *params, arg_symbol_t var_symbol, const char *var_value) { *************** *** 166,175 **** case CLIENT_VAR_HOSTNAME: ! if(cc->client_hostname != NULL) { ! xfree(cc->client_hostname); ! cc->client_hostname = NULL; } ! cc->client_hostname = xstrdup(var_value); break; --- 236,245 ---- case CLIENT_VAR_HOSTNAME: ! if(params->client_hostname != NULL) { ! xfree(params->client_hostname); ! params->client_hostname = NULL; } ! params->client_hostname = xstrdup(var_value); break; *************** *** 177,186 **** case CLIENT_VAR_DHCP_RETRIES: ! cc->dhcp_retries = atoi(var_value); break; case CLIENT_VAR_ICMP_RETRIES: ! cc->icmp_retries = atoi(var_value); break; --- 247,256 ---- case CLIENT_VAR_DHCP_RETRIES: ! params->dhcp_retries = atoi(var_value); break; case CLIENT_VAR_ICMP_RETRIES: ! params->icmp_retries = atoi(var_value); break; *************** *** 192,201 **** } - /* reset requested options. */ - static void client_conf_reset_options(client_conf_t *cc) - { - memset(cc->options, 0, sizeof(cc->options)); - } - static char *get_conf_options_fname(client_conf_t *cc) { --- 262,265 ---- *************** *** 210,230 **** } - static int client_conf_apply_directives(client_conf_t *cc, list_t *directives) - { - list_t *directive_list_ptr; - directive_t *directive; - - for(directive_list_ptr = directives; directive_list_ptr; - directive_list_ptr = directive_list_ptr->next) { - - directive = directive_list_ptr->data; - - if(directive_handlers[directive->command_code](cc, directive, GROUP_DIRECTIVE_NULL, NULL)) - return 1; - } - - return 0; - } - static int client_conf_load_options(client_conf_t *cc) { --- 274,277 ---- *************** *** 246,250 **** /* read compiled directives. */ ! if(client_conf_apply_directives(cc, conf->directives)) { conf_destroy(conf); return 1; --- 293,297 ---- /* read compiled directives. */ ! if(directive_group_handler(&cc->parameters, conf->directives, DIRECTIVE_GROUP_NULL, NULL)) { conf_destroy(conf); return 1; *************** *** 258,271 **** * * * * * * * * * * * */ ! static int directive_group_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data) { ! /* we ignore group_type and group_data for now. we don't support nested groups just yet. */ - /* FIXME: todo. */ return 0; } ! static int directive_set_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data) { list_t *args; arg_symbol_t *var_symbol; --- 305,350 ---- * * * * * * * * * * * */ ! static int directive_group_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data) { ! list_t *directive_list; ! directive_t *directive; ! ! /* setup group before handling directives under it. */ ! params->group_type = group_type; ! ! /* copy over data if applicable. */ ! switch(group_type) { ! ! case DIRECTIVE_GROUP_IP_ADDRESS: ! ! memcpy(¶ms->server_ip, group_data, IP_ADDR_LEN); ! break; ! ! case DIRECTIVE_GROUP_MAC_ADDRESS: ! ! memcpy(¶ms->server_hw_addr, group_data, ETH_ADDR_LEN); ! break; ! ! case DIRECTIVE_GROUP_NULL: /* fall through. */ ! default: ! break; ! ! } ! ! /* now process group. */ ! for(directive_list = directive_data; ! directive_list;directive_list = directive_list->next) { ! ! directive = directive_list->data; ! if(directive_handlers[directive->command_code](params, directive, group_type, group_data)) ! return 1; ! } return 0; } ! static int directive_set_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data) { + directive_t *directive = directive_data; list_t *args; arg_symbol_t *var_symbol; *************** *** 277,281 **** var_value = args->next->next->data; ! if(client_conf_set_variable(cc, *var_symbol, var_value)) { return 1; } --- 356,360 ---- var_value = args->next->next->data; ! if(client_conf_set_variable(params, *var_symbol, var_value)) { return 1; } *************** *** 284,312 **** } ! static int directive_request_handler(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data) { list_t *args; list_t *string_list; - const char **option_strings = dhcp_option_conf_string_get_array(); - char *option_requested; - uint8_t i; args = directive->arguments; ! for(string_list = args->data; string_list; string_list = string_list->next) { ! option_requested = string_list->data; ! for(i = 0; i <= MAX_OPTIONS_HANDLED; i++) { ! if(!strcmp(option_strings[i], option_requested)) { ! cc->options[i] = 1; ! break; ! } ! } ! if(i == MAX_OPTIONS_HANDLED) ! return 1; } return 0; } --- 363,441 ---- } ! static int directive_request_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 = args->data; ! if(fill_option_bit_array_from_string_list(string_list, params->request_options)) ! return 1; ! return 0; ! } ! static int directive_require_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 = args->data; ! ! if(fill_option_bit_array_from_string_list(string_list, params->required_options)) ! return 1; ! ! return 0; ! } ! ! static int directive_server_handler(conf_params_t *params, void *directive_data, directive_group_t group_type, void *group_data) ! { ! list_t *args; ! const arg_symbol_t *server_symbol; ! void *address_data; ! void *directives; ! conf_params_t *new_params; ! directive_group_t new_group_type; ! ! /* FIXME: check for the same group specified twice. ! * this gives us a bit of compression in the unlikely ! * case of a broken config file. */ ! ! args = directive_data; ! server_symbol = args->data; ! ! switch(*server_symbol) { ! ! case CLIENT_SERVER_IP: ! /* ip address. */ ! ! new_group_type = DIRECTIVE_GROUP_IP_ADDRESS; ! break; ! ! ! case CLIENT_SERVER_MAC: ! /* mac address. */ ! ! new_group_type = DIRECTIVE_GROUP_MAC_ADDRESS; ! break; ! ! default: ! FATAL_MESSAGE("illegal server directive group type. this is a bug report me."); ! exit(1); /* get rid of pesky compiler warnings. */ } + address_data = args->next->data; + directives = args->next->next->data; + new_params = xcalloc(sizeof(conf_params_t)); + + if(directive_group_handler(new_params, directives, new_group_type, address_data) < 0) + return 1; + + params->lower_params = add_to_list(params->lower_params, new_params); + return 0; } *************** *** 320,326 **** client_conf_t *cc; ! cc = xmalloc(sizeof(client_conf_t)); cc->interface = interface; ! client_conf_reset_options(cc); if(client_conf_load_options(cc)) { --- 449,455 ---- client_conf_t *cc; ! cc = xcalloc(sizeof(client_conf_t)); cc->interface = interface; ! cc->parameters.group_type = DIRECTIVE_GROUP_NULL; /* set top level to catchall group. */ if(client_conf_load_options(cc)) { *************** *** 334,337 **** --- 463,467 ---- void client_conf_destroy(client_conf_t *cc) { + /* FIXME: more to cleanup. */ xfree(cc); } Index: dhcp-client-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-client-conf.h 16 Dec 2002 07:20:41 -0000 1.4 --- dhcp-client-conf.h 18 Dec 2002 05:40:38 -0000 1.5 *************** *** 33,55 **** typedef struct { - char *conf_file; - const char *interface; /* points to dhcp_client_control->interface */ ! /* specific configurations */ ! unsigned char options[MAX_OPTIONS_HANDLED]; /* which options should we handle. */ ! /* the option variables. */ char *client_hostname; /* setting for the hostname option. */ int dhcp_retries; /* amount of times we should retry dhcp operations. */ int icmp_retries; /* amount of times we should retry icmp operations. */ ! uint8_t do_icmp_router_discovery; /* perform router discovery via icmp. */ } client_conf_t; ! typedef int (*directive_handler_t)(client_conf_t *cc, directive_t *directive, directive_group_t group_type, void *group_data); ! enum directive_types { DIRECTIVE_GROUP = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST}; /* symbols for variable substitution. */ --- 33,64 ---- typedef struct { ! directive_group_t group_type; ! ip_addr_t server_ip; ! eth_addr_t server_hw_addr; ! uint8_t request_options[MAX_OPTIONS_HANDLED + 1]; /* which options we request. */ ! uint8_t required_options[MAX_OPTIONS_HANDLED + 1]; /* which options we require. */ char *client_hostname; /* setting for the hostname option. */ int dhcp_retries; /* amount of times we should retry dhcp operations. */ int icmp_retries; /* amount of times we should retry icmp operations. */ ! uint8_t do_icmp_router_discovery; /* perform router discovery via icmp. */ + list_t *lower_params; /* linked list to child parameters. */ + + } conf_params_t; + + typedef struct { + char *conf_file; + const char *interface; /* points to dhcp_client_control->interface */ + + conf_params_t parameters; } client_conf_t; ! typedef int (*directive_handler_t)(conf_params_t *param, void *directive_data, directive_group_t group_type, void *group_data); ! enum directive_types { DIRECTIVE_GROUP = 0, DIRECTIVE_SET, DIRECTIVE_REQUEST, DIRECTIVE_REQUIRE, DIRECTIVE_SERVER_GROUP }; /* symbols for variable substitution. */ *************** *** 57,61 **** CLIENT_VAR_DO_ICMP_ROUTER_DISCOVERY }; ! enum directive_group_t { GROUP_DIRECTIVE_NULL = 0, DIRECTIVE_GROUP_IP_ADDRESS, DIRECTIVE_GROUP_ETH_ADDRESS }; /* prototypes. */ --- 66,72 ---- CLIENT_VAR_DO_ICMP_ROUTER_DISCOVERY }; ! enum server_symbols { CLIENT_SERVER_IP = 0, CLIENT_SERVER_MAC }; ! ! enum directive_group_t { DIRECTIVE_GROUP_NULL = 0, DIRECTIVE_GROUP_IP_ADDRESS, DIRECTIVE_GROUP_MAC_ADDRESS }; /* prototypes. */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-client-states.c 16 Dec 2002 10:14:31 -0000 1.9 --- dhcp-client-states.c 18 Dec 2002 05:40:38 -0000 1.10 *************** *** 100,104 **** option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! options = add_to_list(options, option); /* dhcp message type. */ --- 100,106 ---- option = dhcp_build_parameter_request_list_option(client_conf_get_opt_bit_array(dc->conf)); ! if(option != NULL) ! options = add_to_list(options, option); ! /* dhcp message type. */ *************** *** 163,182 **** { /* FIXME: we default to at least. we need an actual policy in client_conf though. */ - const char *policy = NULL; - return 1; - if(policy == NULL) - policy = "atleast"; - - if(string_matches(policy, "exact")) - return (dhcp_have_exact_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); - else if(string_matches(policy, "atleast")) - return (dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); - else { /* bad policy : warn and use atleast */ - - WARN_MESSAGE("%s : set to bad value %s : going to use \"atleast\""); - return (dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); - } - } --- 165,169 ---- Index: dhcp-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-conf.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-conf.c 16 Dec 2002 07:20:42 -0000 1.3 --- dhcp-conf.c 18 Dec 2002 05:40:38 -0000 1.4 *************** *** 485,489 **** list_t *list = data; ! purge_list(list, directive_destroy_l); return; --- 485,489 ---- list_t *list = data; ! purge_list(list, directive_destroy_l); /* free up a list of directives. */ return; Index: dhcp-options-strings.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-options-strings.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-options-strings.c 16 Dec 2002 07:20:42 -0000 1.5 --- dhcp-options-strings.c 18 Dec 2002 05:40:38 -0000 1.6 *************** *** 79,83 **** "X-Windows Font Servers", /* 48 */ "X-Windows System Display Manager", /* 49 */ ! "Request IP Address", /* 50 */ "IP Address Lease Time", /* 51 */ "Option Overload", /* 52 */ --- 79,83 ---- "X-Windows Font Servers", /* 48 */ "X-Windows System Display Manager", /* 49 */ ! "Requested IP Address", /* 50 */ "IP Address Lease Time", /* 51 */ "Option Overload", /* 52 */ *************** *** 158,162 **** "x-windows-font-servers", /* 48 */ "x-windows-system-display-manager", /* 49 */ ! "request-ip-address", /* 50 */ "ip-address-lease-time", /* 51 */ "option-overload", /* 52 */ --- 158,162 ---- "x-windows-font-servers", /* 48 */ "x-windows-system-display-manager", /* 49 */ ! "requested-ip-address", /* 50 */ "ip-address-lease-time", /* 51 */ "option-overload", /* 52 */ *************** *** 186,190 **** /* accessors. */ - const char *dhcp_option_printable_string_get(int index) { --- 186,189 ---- |
From: <act...@us...> - 2002-12-16 10:14:34
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv7500 Modified Files: dhcp-client-control.c dhcp-client-states.c dhcp-client.c dhcp-client.h Log Message: fixed client_control cache hack and did some renaming Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-client-control.c 16 Dec 2002 07:20:41 -0000 1.6 --- dhcp-client-control.c 16 Dec 2002 10:14:31 -0000 1.7 *************** *** 105,109 **** /* dummy routine. we use this to manipulate conf/cache. */ ! dhcp_client_control_t *create_dhcp_client_control_dummy(char *interface) { dhcp_client_control_t *dc; --- 105,109 ---- /* dummy routine. we use this to manipulate conf/cache. */ ! dhcp_client_control_t *dhcp_client_control_create_dummy(char *interface) { dhcp_client_control_t *dc; *************** *** 123,127 **** /* create client control object */ ! dhcp_client_control_t *create_dhcp_client_control(char *interface, int promiscuous) { dhcp_client_control_t *dc; --- 123,127 ---- /* create client control object */ ! dhcp_client_control_t *dhcp_client_control_create(char *interface, int promiscuous) { dhcp_client_control_t *dc; *************** *** 144,148 **** if(dc->conf == NULL) { ERROR_MESSAGE("could not read client conf."); ! destroy_dhcp_client_control(dc); return NULL; } --- 144,148 ---- if(dc->conf == NULL) { ERROR_MESSAGE("could not read client conf."); ! dhcp_client_control_destroy(dc); return NULL; } *************** *** 175,179 **** promiscuous)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); ! destroy_dhcp_client_control(dc); return NULL; } --- 175,179 ---- promiscuous)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); ! dhcp_client_control_destroy(dc); return NULL; } *************** *** 214,218 **** /* use fake address in 0x:0x:0x:0x:0x we need to notify rawnet about this. * achtung: all packets _except_ dhcp packets will still use the real hardware address. */ ! void dhcp_control_use_fake_hw_addr(dhcp_client_control_t *dc, char *fake_hw_addr) { char *new_client_id = create_fake_client_id(fake_hw_addr); --- 214,218 ---- /* use fake address in 0x:0x:0x:0x:0x we need to notify rawnet about this. * achtung: all packets _except_ dhcp packets will still use the real hardware address. */ ! void dhcp_client_control_use_fake_hw_addr(dhcp_client_control_t *dc, char *fake_hw_addr) { char *new_client_id = create_fake_client_id(fake_hw_addr); *************** *** 227,231 **** /* destructor. */ ! void destroy_dhcp_client_control(dhcp_client_control_t *dc) { if(dc->rawnet) --- 227,231 ---- /* destructor. */ ! void dhcp_client_control_destroy(dhcp_client_control_t *dc) { if(dc->rawnet) *************** *** 253,265 **** } ! /* Utility routine to bring down interface. ! * we need this because we have to be explicit ! * about it. We can't do this at the time we ! * destroy the control object -- for example ! * we destroy the control object through forks ! * to clean out our environment but we don't want ! * to down the interface (necessarily) then. ! * this routine just makes it explicit so we call ! * it when we mean it. */ void dhcp_client_interface_down(dhcp_client_control_t *dc) --- 253,263 ---- } ! /* Utility routine to bring down interface. we need this because ! * we have to be explicit about bringing down the interface. We ! * can't do this at the time we destroy the control object -- for ! * example we destroy the control object through forks to clean ! * out our environment but we don't want to down the interface ! * necessarily. This routine just makes it explicit so we call it ! * when we mean it. */ void dhcp_client_interface_down(dhcp_client_control_t *dc) *************** *** 269,274 **** } ! /* set and clear server address. ! * this is useful for unicasting and for RELEASE. */ void dhcp_client_set_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr) --- 267,271 ---- } ! /* set the server address. */ void dhcp_client_set_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr) Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-client-states.c 16 Dec 2002 07:20:41 -0000 1.8 --- dhcp-client-states.c 16 Dec 2002 10:14:31 -0000 1.9 *************** *** 602,606 **** client_release(dc); delete_pid_file(dc->interface); ! destroy_dhcp_client_control(dc); } --- 602,606 ---- client_release(dc); delete_pid_file(dc->interface); ! dhcp_client_control_destroy(dc); } Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-client.c 16 Dec 2002 07:20:42 -0000 1.9 --- dhcp-client.c 16 Dec 2002 10:14:31 -0000 1.10 *************** *** 306,310 **** { pid_t pid; - dhcp_client_control_t *dc; client_cache_t *cc; --- 306,309 ---- *************** *** 315,327 **** } ! /* As long as no client is running we can go ahead and delete ! * the cache. We need a client cache structure though, pass ! * it a dummy structure with the interface. That's all it ! * needs. (this a hack). ! */ ! ! /* begin hack. */ ! dc = create_dhcp_client_control_dummy(interface); ! cc = client_cache_create(dc->interface); /* now delete. */ --- 314,318 ---- } ! cc = client_cache_create(interface); /* now delete. */ *************** *** 329,337 **** client_cache_delete_tmp_cache(cc); - /* all done. */ - destroy_dhcp_client_control(dc); - client_cache_destroy(cc); - - /* end hack: XXX -- FIXME: get rid of this hack. */ return; } --- 320,323 ---- *************** *** 400,404 **** setup_interrupt_handlers(); /* setup signal handling */ ! if((dc = create_dhcp_client_control(interface, promiscuous)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting."); client_states[STATE_DO_SHUTDOWN] (dc); --- 386,390 ---- setup_interrupt_handlers(); /* setup signal handling */ ! if((dc = dhcp_client_control_create(interface, promiscuous)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting."); client_states[STATE_DO_SHUTDOWN] (dc); *************** *** 406,410 **** if(fake_hw_addr) /* Marla, you liar, you big tourist, I need this. Now get out! */ ! dhcp_control_use_fake_hw_addr(dc, fake_hw_addr); /* We're good to go. Look up state. */ --- 392,396 ---- if(fake_hw_addr) /* Marla, you liar, you big tourist, I need this. Now get out! */ ! dhcp_client_control_use_fake_hw_addr(dc, fake_hw_addr); /* We're good to go. Look up state. */ *************** *** 423,427 **** * ... otherwise ... */ ! destroy_dhcp_client_control(dc); interactive = 0; --- 409,413 ---- * ... otherwise ... */ ! dhcp_client_control_destroy(dc); interactive = 0; *************** *** 430,434 **** * we lose them after we fork in go_background. */ ! if((dc = create_dhcp_client_control(interface, promiscuous)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting.", interface); client_states[STATE_DO_SHUTDOWN] (NULL); --- 416,420 ---- * we lose them after we fork in go_background. */ ! if((dc = dhcp_client_control_create(interface, promiscuous)) == NULL) { ERROR_MESSAGE("encountered a fatal error. I'm exiting.", interface); client_states[STATE_DO_SHUTDOWN] (NULL); *************** *** 441,445 **** if(fake_hw_addr) /* Marla, you liar, you big tourist, I need this. Now get out! */ ! dhcp_control_use_fake_hw_addr(dc, fake_hw_addr); } --- 427,431 ---- if(fake_hw_addr) /* Marla, you liar, you big tourist, I need this. Now get out! */ ! dhcp_client_control_use_fake_hw_addr(dc, fake_hw_addr); } Index: dhcp-client.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-client.h 24 Nov 2002 01:10:00 -0000 1.6 --- dhcp-client.h 16 Dec 2002 10:14:31 -0000 1.7 *************** *** 93,105 **** /* client control. */ extern void dhcp_client_update_secs(dhcp_client_control_t *dc); extern void dhcp_client_reset_secs(dhcp_client_control_t *dc); extern void dhcp_client_reset_discover_offer_retries(dhcp_client_control_t *dc); ! extern int dhcp_client_discover_offer_can_retry(dhcp_client_control_t *dc); ! extern dhcp_client_control_t *create_dhcp_client_control_dummy(char *interface); extern void dhcp_client_update_xid(dhcp_client_control_t *dc); ! extern dhcp_client_control_t *create_dhcp_client_control(char *interface, int promiscuous); ! extern void dhcp_control_use_fake_hw_addr(dhcp_client_control_t *dc, char *fake_hw_addr); ! extern void destroy_dhcp_client_control(dhcp_client_control_t *dc); extern void dhcp_client_interface_down(dhcp_client_control_t *dc); extern void dhcp_client_set_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr); --- 93,107 ---- /* client control. */ + extern dhcp_client_control_t *dhcp_client_control_create(char *interface, int promiscuous); + extern dhcp_client_control_t *dhcp_client_control_create_dummy(char *interface); + extern void dhcp_client_control_destroy(dhcp_client_control_t *dc); + extern void dhcp_client_update_secs(dhcp_client_control_t *dc); extern void dhcp_client_reset_secs(dhcp_client_control_t *dc); extern void dhcp_client_reset_discover_offer_retries(dhcp_client_control_t *dc); ! extern int dhcp_client_discover_offer_can_retry(dhcp_client_control_t *dc); extern void dhcp_client_update_xid(dhcp_client_control_t *dc); ! extern void dhcp_client_control_use_fake_hw_addr(dhcp_client_control_t *dc, char *fake_hw_addr); ! extern void dhcp_client_interface_down(dhcp_client_control_t *dc); extern void dhcp_client_set_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr); |
From: <act...@us...> - 2002-12-16 10:04:37
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv4499 Modified Files: dhcp-cache-entry.c dhcp-cache-entry.h Log Message: renamed with proper convention Index: dhcp-cache-entry.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-cache-entry.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-cache-entry.c 22 Nov 2002 15:30:37 -0000 1.4 --- dhcp-cache-entry.c 16 Dec 2002 10:04:32 -0000 1.5 *************** *** 34,38 **** #include "dhcp-cache-entry.h" ! /* constructors. */ cache_entry_t *create_cache_entry(uint8_t tag, const char *name, const char *value) { --- 34,41 ---- #include "dhcp-cache-entry.h" ! /* * * * * * * * * * * * * * * ! * constructors/destructors * ! * * * * * * * * * * * * * * */ ! cache_entry_t *create_cache_entry(uint8_t tag, const char *name, const char *value) { *************** *** 47,51 **** } ! void destroy_cache_entry(cache_entry_t *cache) { xfree(cache->name); --- 50,54 ---- } ! void cache_entry_destroy(cache_entry_t *cache) { xfree(cache->name); *************** *** 57,63 **** /* use alongside purge_list or similar routines. */ ! static void destroy_cache_entry_in_list(void *data) { ! destroy_cache_entry(data); } --- 60,66 ---- /* use alongside purge_list or similar routines. */ ! static void cache_entry_destroy_l(void *data) { ! cache_entry_destroy(data); } *************** *** 65,69 **** void cache_entry_purge_list(list_t *cache_list) { ! purge_list(cache_list, destroy_cache_entry_in_list); return; } --- 68,72 ---- void cache_entry_purge_list(list_t *cache_list) { ! purge_list(cache_list, cache_entry_destroy_l); return; } Index: dhcp-cache-entry.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-cache-entry.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-cache-entry.h 22 Nov 2002 15:30:37 -0000 1.3 --- dhcp-cache-entry.h 16 Dec 2002 10:04:33 -0000 1.4 *************** *** 33,37 **** extern cache_entry_t *create_cache_entry(uint8_t tag, const char *name, const char *value); ! extern void destroy_cache_entry(cache_entry_t *cache); extern void cache_entry_purge_list(list_t *cache_list); --- 33,37 ---- extern cache_entry_t *create_cache_entry(uint8_t tag, const char *name, const char *value); ! extern void cache_entry_destroy(cache_entry_t *cache); extern void cache_entry_purge_list(list_t *cache_list); |