Thread: [Dhcp-agent-commits] CVS: dhcp-agent TODO,1.13,1.14 dhcp-agent.h,1.35,1.36 dhcp-com.c,1.4,1.5 dhcp-i
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-05-19 20:16:58
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv12223 Modified Files: TODO dhcp-agent.h dhcp-com.c dhcp-icmp-discovery.c dhcp-util.c Log Message: now using libdnet's random number generator Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TODO 18 May 2002 18:17:59 -0000 1.13 --- TODO 19 May 2002 20:16:55 -0000 1.14 *************** *** 48,61 **** clean up in areas where it seems prudent. or come up with guidelines we can stick to. - -- fixup error messages to use "name : name : name : error" - convention where name could be the name of the process, - module, or function. -- rawnet and the dhcp client control are foobared by a fake mac address. check, fix, clean. -- clean up dhcp-packet-build.c - -- need a proper rtt featured re/send/accept routine for raw packets. - -- in arp discovery we're using a list to pass two arguments. we - should use something else, or have list routines specific to - this. -- the rawnet routines should be a shared library due to too many dependencies. the sniffer for example, only needs the packet --- 48,54 ---- *************** *** 68,73 **** by using devices like /dev/urandom explicitly if available. -- fix overflow issue in dhcp-icmp-discovery (icmp_do_echo) - -- check if pcap prefixes its error messages if so remove pcap prefixes. - -- we need a proper error passing scheme for error strings so - that we wind up with a single string in the end. --- 61,63 ---- Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** dhcp-agent.h 19 May 2002 17:53:28 -0000 1.35 --- dhcp-agent.h 19 May 2002 20:16:55 -0000 1.36 *************** *** 591,595 **** extern int hex_string_to_value(char *string, unsigned char *dst); extern int is_string(const char *string, int len); ! extern int get_random(void); extern struct timeval timeval_diff(struct timeval begin, struct timeval end); --- 591,596 ---- extern int hex_string_to_value(char *string, unsigned char *dst); extern int is_string(const char *string, int len); ! extern uint16_t get_random_uint16(void); ! extern uint32_t get_random_uint32(void); extern struct timeval timeval_diff(struct timeval begin, struct timeval end); Index: dhcp-com.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-com.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-com.c 8 Feb 2002 18:15:52 -0000 1.4 --- dhcp-com.c 19 May 2002 20:16:55 -0000 1.5 *************** *** 792,795 **** uint32_t dhcp_gen_xid(void) { ! return(get_random()); } --- 792,795 ---- uint32_t dhcp_gen_xid(void) { ! return(get_random_uint32()); } Index: dhcp-icmp-discovery.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-icmp-discovery.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-icmp-discovery.c 19 May 2002 17:53:28 -0000 1.4 --- dhcp-icmp-discovery.c 19 May 2002 20:16:55 -0000 1.5 *************** *** 100,105 **** int latency; ! id = get_random(); ! seq = get_random(); build_icmp_echo_request(net, net->ip_addr, dest_addr, net->hw_addr, dest_mac, id, seq); --- 100,105 ---- int latency; ! id = get_random_uint32(); ! seq = get_random_uint32(); build_icmp_echo_request(net, net->ip_addr, dest_addr, net->hw_addr, dest_mac, id, seq); Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-util.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-util.c 18 May 2002 18:10:09 -0000 1.10 --- dhcp-util.c 19 May 2002 20:16:55 -0000 1.11 *************** *** 421,440 **** } /* initialize random seed. */ static void init_rand(void) { ! srandom(getpid() + time(NULL)); } ! int get_random(void) { ! static unsigned char have_init_random = 0; ! ! if(!have_init_random) { ! init_rand(); ! have_init_random = 1; ! } ! ! return(random()); } --- 421,448 ---- } + static rand_t *ran_gen = NULL; + /* initialize random seed. */ static void init_rand(void) { ! static rand_t *ran_gen = NULL; ! ! if(ran_gen == NULL) ! if((ran_gen = rand_open()) == NULL) ! fatal_error("unable to access random number generator"); ! ! return; } ! uint16_t get_random_uint16(void) { ! init_rand(); /* reinit if needed. */ ! return(rand_uint16(ran_gen)); ! } ! ! uint32_t get_random_uint32(void) ! { ! init_rand(); /* reinit if needed. */ ! return(rand_uint32(ran_gen)); } |