Thread: [Dhcp-agent-commits] CVS: dhcp-agent Makefile.am,1.7,1.8 Makefile.in,1.7,1.8 TODO,1.4,1.5 dhcp-agent
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-02-09 15:50:34
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv24534 Modified Files: Makefile.am Makefile.in TODO dhcp-agent.h dhcp-client-control.c dhcp-convert.c dhcp-sysconf.c dhcp-util.c Log Message: added splice_many_strings for things like class-id; Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.am 8 Feb 2002 17:04:32 -0000 1.7 --- Makefile.am 9 Feb 2002 15:50:30 -0000 1.8 *************** *** 22,26 **** dhcp-sysconf.c dhcp-rtt.c ! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence noinst_HEADERS = dhcp-agent.h config.h --- 22,26 ---- dhcp-sysconf.c dhcp-rtt.c ! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ noinst_HEADERS = dhcp-agent.h config.h Index: Makefile.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.in,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.in 8 Feb 2002 17:04:32 -0000 1.7 --- Makefile.in 9 Feb 2002 15:50:30 -0000 1.8 *************** *** 86,90 **** ! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence noinst_HEADERS = dhcp-agent.h config.h --- 86,90 ---- ! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ noinst_HEADERS = dhcp-agent.h config.h Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TODO 8 Feb 2002 18:15:52 -0000 1.4 --- TODO 9 Feb 2002 15:50:30 -0000 1.5 *************** *** 26,36 **** -- good idea to add config file handlers in sysconf array so config files can be handled. instead of doing it explicitly. - -- do_sysconf() is jumping hoops serializing and unserializing, - best to load up the strings and pass them in their serialized - state. -- proper error handling in packet objects. possibly generic codes with an error buff (?). - -- clean up code and document more. - -- fixup all magic numbers. -- make splice_string better: make it use stdarg -- fix rawnet so it doesn't hardcode ports. --- 26,31 ---- Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** dhcp-agent.h 8 Feb 2002 18:15:52 -0000 1.19 --- dhcp-agent.h 9 Feb 2002 15:50:30 -0000 1.20 *************** *** 527,530 **** --- 527,531 ---- extern void info_message(char *fmt, ...); extern char *splice_string(char *s1, char *s2); + extern char *splice_many_strings(int num, char *s, ...); extern void trim_string(char *s); extern int string_matches(char *s1, char *s2); Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-control.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-client-control.c 8 Feb 2002 01:37:29 -0000 1.9 --- dhcp-client-control.c 9 Feb 2002 15:50:30 -0000 1.10 *************** *** 160,167 **** dhcp_client_reset_secs(dc); dhcp_client_update_secs(dc); - #ifdef HAVE_UNAME uname(&utsname); ! dc->class_id = splice_string(utsname.sysname, utsname.release); #else /* HAVE_UNAME */ dc->class_id = strdup("Unknown"); --- 160,166 ---- dhcp_client_reset_secs(dc); dhcp_client_update_secs(dc); #ifdef HAVE_UNAME uname(&utsname); ! dc->class_id = splice_many_strings(4, utsname.sysname, utsname.nodename, utsname.release, utsname.version, utsname.machine); #else /* HAVE_UNAME */ dc->class_id = strdup("Unknown"); Index: dhcp-convert.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-convert.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-convert.c 8 Feb 2002 17:04:32 -0000 1.5 --- dhcp-convert.c 9 Feb 2002 15:50:30 -0000 1.6 *************** *** 639,650 **** case sizeof(int32_t): ! *(int32_t *)val = strtol(s, NULL, 10); break; case sizeof(int16_t): ! *(int16_t *)val = (uint16_t)atoi(s); /* this is safe ! * because we're always getting our ! * own serialized values. they should decay fine. ! * don't use this on strings gotten from the network. */ break; default: --- 639,650 ---- case sizeof(int32_t): ! *(int32_t *)val = (int32_t)strtol(s, NULL, 10); break; case sizeof(int16_t): ! *(int16_t *)val = (int16_t)atoi(s); /* this is safe ! * because we're always getting our ! * own serialized values. they should decay fine. ! * don't use this on strings gotten from the network. */ break; default: *************** *** 659,663 **** case sizeof(uint32_t): ! *(uint32_t *)val = strtoul(s, NULL, 10); break; --- 659,663 ---- case sizeof(uint32_t): ! *(uint32_t *)val = (uint32_t)strtoul(s, NULL, 10); break; Index: dhcp-sysconf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-sysconf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-sysconf.c 8 Feb 2002 17:04:32 -0000 1.5 --- dhcp-sysconf.c 9 Feb 2002 15:50:30 -0000 1.6 *************** *** 28,32 **** sysconf_handler sysconf_handlers[] = { ! { NULL, }, /* 0 */ { NULL, }, /* 1 */ /* Subnet mask -- don't handle here.*/ { NULL, }, /* 2 */ /* time offset. */ --- 28,32 ---- sysconf_handler sysconf_handlers[] = { ! { NULL, }, /* 0 */ /* Pad -- don't handle here. */ { NULL, }, /* 1 */ /* Subnet mask -- don't handle here.*/ { NULL, }, /* 2 */ /* time offset. */ *************** *** 72,92 **** { NULL, }, /* 43 */ /* netbios over tcp/ip */ { NULL, }, /* 44 */ ! { NULL, }, /* 45 */ ! { NULL, }, /* 46 */ ! { NULL, }, /* 47 */ ! { NULL, }, /* 48 */ ! { NULL, }, /* 49 */ ! { NULL, }, /* 50 */ ! { NULL, }, /* 51 */ ! { NULL, }, /* 52 */ ! { NULL, }, /* 53 */ ! { NULL, }, /* 54 */ ! { NULL, }, /* 55 */ ! { NULL, }, /* 56 */ ! { NULL, }, /* 57 */ ! { NULL, }, /* 58 */ ! { NULL, }, /* 59 */ ! { NULL, }, /* 60 */ ! { NULL, }, /* 61 */ }; --- 72,92 ---- { NULL, }, /* 43 */ /* netbios over tcp/ip */ { NULL, }, /* 44 */ ! { NULL, }, /* 45 */ ! { NULL, }, /* 46 */ ! { NULL, }, /* 47 */ ! { NULL, }, /* 48 */ ! { NULL, }, /* 49 */ ! { NULL, }, /* 50 */ ! { NULL, }, /* 51 */ ! { NULL, }, /* 52 */ ! { NULL, }, /* 53 */ ! { NULL, }, /* 54 */ ! { NULL, }, /* 55 */ ! { NULL, }, /* 56 */ ! { NULL, }, /* 57 */ ! { NULL, }, /* 58 */ ! { NULL, }, /* 59 */ ! { NULL, }, /* 60 */ ! { NULL, }, /* 61 */ }; Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-util.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-util.c 8 Feb 2002 17:04:32 -0000 1.7 --- dhcp-util.c 9 Feb 2002 15:50:30 -0000 1.8 *************** *** 272,279 **** * Splice two strings together. * - * XXX: todo see if we can get this to work - * with stdarg so that an infinite amount - * of strings can be passed. - * */ --- 272,275 ---- *************** *** 295,298 **** --- 291,321 ---- } + /* interface to splice_string. */ + + char *splice_many_strings(int num, char *string, ...) + { + va_list ap; + char *s, *tmp; + char *new_string; + + new_string = strdup(string); + + if(num <= 1) + return new_string; /* be nice to stupid callers. */ + + va_start(ap, string); + + while(num--) { + s = va_arg(ap, char *); + tmp = new_string; + new_string = splice_string(new_string, s); + xfree(tmp); + } + + va_end(ap); + + return new_string; + } + /* trim preprending and trailing space. also get rid of newlines. */ void trim_string(char *s) |