Thread: [Dhcp-agent-commits] CVS: dhcp-agent dhcp-daemon.c,1.2,1.3 dhcp-files.c,1.2,1.3 dhcp-interface.c,1.8
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-02-05 13:47:41
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv16730 Modified Files: dhcp-daemon.c dhcp-files.c dhcp-interface.c dhcp-ip.c dhcp-rtt.c Log Message: fixed up magic numbers in dhcp-ip.c; fixed small bug in dhcp-rtt.c; added more comments and clean up; Index: dhcp-daemon.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-daemon.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-daemon.c 2002/02/02 11:55:08 1.2 --- dhcp-daemon.c 2002/02/05 13:47:38 1.3 *************** *** 27,30 **** --- 27,32 ---- #include <dhcp-agent.h> + /* wrap for volatine integers, or proper sig_atomic_t types. */ + #ifdef HAVE_SIG_ATOMIC_T *************** *** 53,56 **** --- 55,59 ---- } + /* setup our interrupt handles. */ void setup_interrupt_handlers(void) { *************** *** 66,69 **** --- 69,85 ---- } + /* Our go background routine. + * here. We do all the necessary + * steps to fork completely into + * the background. + * + * Calling this will hose any + * module we're using that + * has descriptors open. + * + * Only call in a pre-initialized state. + * + */ + void go_background(char *dir) { *************** *** 163,171 **** * use them */ ! #ifdef not_yet max_descriptors = sysconf(_SC_OPEN_MAX); #elif MAX_FILES max_descriptors = MAX_FILES; ! #elif not_yet max_descriptors = getrusage(RLIMIT_NOFILES); #else --- 179,187 ---- * use them */ ! #ifdef _SC_OPEN_MAX max_descriptors = sysconf(_SC_OPEN_MAX); #elif MAX_FILES max_descriptors = MAX_FILES; ! #elif RLIMIT_NOFILES max_descriptors = getrusage(RLIMIT_NOFILES); #else *************** *** 201,207 **** open("/dev/null", O_WRONLY); /* stderr */ ! /* Now we're done. */ ! init_log(binname); return; --- 217,224 ---- open("/dev/null", O_WRONLY); /* stderr */ ! /* initialize logging. */ init_log(binname); + + /* Now we're done. */ return; Index: dhcp-files.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-files.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-files.c 2002/02/02 15:28:47 1.2 --- dhcp-files.c 2002/02/05 13:47:38 1.3 *************** *** 189,192 **** --- 189,193 ---- } + /* get pid from file. */ int get_pid_file(char *name, pid_t *pid) { Index: dhcp-interface.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-interface.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-interface.c 2002/02/02 11:55:08 1.8 --- dhcp-interface.c 2002/02/05 13:47:38 1.9 *************** *** 79,84 **** } ! /* Bring an interface up */ ! int interface_up(interface_control_t *ic, char *name, uint32_t addr, uint32_t netmask, int mtu) --- 79,83 ---- } ! /* bring an interface up */ int interface_up(interface_control_t *ic, char *name, uint32_t addr, uint32_t netmask, int mtu) *************** *** 116,119 **** --- 115,119 ---- } + /* take down an interface. */ int interface_down(interface_control_t *ic, char *name) { *************** *** 130,133 **** --- 130,134 ---- } + /* get ip address of an interface. */ int interface_get_ip_addr(interface_control_t *ic, char *name, uint32_t *addr) { Index: dhcp-ip.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-ip.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-ip.c 2002/01/30 16:06:46 1.2 --- dhcp-ip.c 2002/02/05 13:47:38 1.3 *************** *** 141,171 **** *packet = ipvhl; ! packet += 1; ! ! memcpy(packet, &ip->header.ip_tos, 1); ! packet += 1; ! memcpy(packet, &ip->header.ip_len, 2); ! packet += 2; ! memcpy(packet, &ip->header.ip_id, 2); ! packet += 2; ! memcpy(packet, &ip->header.ip_off, 2); ! packet += 2; ! memcpy(packet, &ip->header.ip_ttl, 1); ! packet += 1; ! memcpy(packet, &ip->header.ip_p, 1); ! packet += 1; /* skip checksum field. */ packet += 2; ! memcpy(packet, &ip->header.ip_src, 4); ! packet += 4; ! ! memcpy(packet, &ip->header.ip_dst, 4); return; --- 141,171 ---- *packet = ipvhl; ! packet += sizeof(ipvhl); ! memcpy(packet, &ip->header.ip_tos, sizeof(ip->header.ip_tos)); ! packet += sizeof(ip->header.ip_tos); ! memcpy(packet, &ip->header.ip_len, sizeof(ip->header.ip_len)); ! packet += sizeof(ip->header.ip_len); ! memcpy(packet, &ip->header.ip_id, sizeof(ip->header.ip_id)); ! packet += sizeof(ip->header.ip_id); ! memcpy(packet, &ip->header.ip_off, sizeof(ip->header.ip_off)); ! packet += sizeof(ip->header.ip_off); ! ! memcpy(packet, &ip->header.ip_ttl, sizeof(ip->header.ip_ttl)); ! packet += sizeof(ip->header.ip_ttl); ! memcpy(packet, &ip->header.ip_p, sizeof(ip->header.ip_p)); ! packet += sizeof(ip->header.ip_p); /* skip checksum field. */ packet += 2; ! memcpy(packet, &ip->header.ip_src, IP_ADDR_LEN); ! packet += IP_ADDR_LEN; ! ! memcpy(packet, &ip->header.ip_dst, IP_ADDR_LEN); return; Index: dhcp-rtt.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-rtt.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-rtt.c 2002/02/02 01:07:20 1.3 --- dhcp-rtt.c 2002/02/05 13:47:38 1.4 *************** *** 69,72 **** --- 69,74 ---- if(rand_value < milliseconds) milliseconds -= rand_value; + else + milliseconds += rand_value; } |