Thread: [Dhcp-agent-commits] dhcp-agent README,1.8,1.9 dhcp-agent.h,1.68,1.69 dhcp-client-control.c,1.26,1.2
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv6203 Modified Files: README dhcp-agent.h dhcp-client-control.c dhcp-client-states.c dhcp-client.c dhcp-net.c dhcp-net.h dhcp-sniff.c Log Message: got rid of some static buffers in favor of stringbuffer Index: README =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/README,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README 11 Sep 2002 23:55:16 -0000 1.8 --- README 14 Oct 2002 15:52:32 -0000 1.9 *************** *** 38,42 **** http://www.tcpdump.org/ ! You will also need Dug Song's libdnet (1.4 or above). http://libdnet.sourceforge.net/ --- 38,42 ---- http://www.tcpdump.org/ ! You will also need Dug Song's libdnet (1.5 or above). http://libdnet.sourceforge.net/ Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** dhcp-agent.h 13 Oct 2002 22:17:13 -0000 1.68 --- dhcp-agent.h 14 Oct 2002 15:52:32 -0000 1.69 *************** *** 108,115 **** # define GENERIC_BUFFSIZE 256 - /* log string buffer */ - - # define MSG_BUFFER_SIZE 256 - /* Snaplen. Use the largest size since DHCP packets could * get pretty big with all the additional options. --- 108,111 ---- Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-control.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** dhcp-client-control.c 12 Oct 2002 22:54:50 -0000 1.26 --- dhcp-client-control.c 14 Oct 2002 15:52:33 -0000 1.27 *************** *** 120,124 **** dhcp_client_control_t *dc; int dport, sport; ! char filter_buff[GENERIC_BUFFSIZE]; eth_addr_t interface_addr; --- 120,124 ---- dhcp_client_control_t *dc; int dport, sport; ! stringbuffer *filter; eth_addr_t interface_addr; *************** *** 164,176 **** /* Create filter. */ ! snprintf(filter_buff, sizeof(filter_buff), ! "arp or icmp or (udp and (src port %d or dst port %d))", ! dport, sport); ! if((dc->rawnet = rawnet_create(interface, filter_buff, sport, dport, promiscuous)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); destroy_dhcp_client_control(dc); return NULL; } /* Additional fields. */ --- 164,178 ---- /* Create filter. */ ! filter = create_stringbuffer(); ! stringbuffer_aprintf(filter, "arp or icmp or (udp and (src port %d or dst port %d))", ! dport, sport); ! if((dc->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), sport, dport, promiscuous)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); destroy_dhcp_client_control(dc); return NULL; } + + destroy_stringbuffer(filter); /* Additional fields. */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-states.c,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** dhcp-client-states.c 12 Oct 2002 22:54:50 -0000 1.39 --- dhcp-client-states.c 14 Oct 2002 15:52:33 -0000 1.40 *************** *** 294,298 **** case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeouton DHCP discover."); return STATE_FATAL_ERROR; --- 294,298 ---- case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeout on DHCP discover."); return STATE_FATAL_ERROR; Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client.c,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** dhcp-client.c 13 Oct 2002 22:17:14 -0000 1.45 --- dhcp-client.c 14 Oct 2002 15:52:33 -0000 1.46 *************** *** 415,419 **** * semicolons) */ ! // setup_interrupt_handlers(); /* setup signal handling */ if((dc = create_dhcp_client_control(interface, promiscuous)) == NULL) { --- 415,419 ---- * semicolons) */ ! setup_interrupt_handlers(); /* setup signal handling */ if((dc = create_dhcp_client_control(interface, promiscuous)) == NULL) { *************** *** 480,484 **** switch(c) { ! /* check for command codes. */ case 'v': /* print version. */ --- 480,484 ---- switch(c) { ! /* check for command codes. */ case 'v': /* print version. */ Index: dhcp-net.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-net.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** dhcp-net.c 12 Oct 2002 22:54:50 -0000 1.33 --- dhcp-net.c 14 Oct 2002 15:52:33 -0000 1.34 *************** *** 188,192 **** /* Create the workhorse network module. */ ! rawnet_t *rawnet_create(char *device, char *filter, int dhcp_src_port, int dhcp_dst_port, int promiscuous) --- 188,192 ---- /* Create the workhorse network module. */ ! rawnet_t *rawnet_create(const char *device, const char *filter, int dhcp_src_port, int dhcp_dst_port, int promiscuous) *************** *** 244,248 **** /* get pcap handler */ ! net->pcap = initialize_pcap_device(device, filter, promiscuous); if(net->pcap == NULL) { ERROR_MESSAGE("could not initialize pcap device for: %s", device); --- 244,248 ---- /* get pcap handler */ ! net->pcap = initialize_pcap_device(net->device, net->pcap_filter, promiscuous); if(net->pcap == NULL) { ERROR_MESSAGE("could not initialize pcap device for: %s", device); Index: dhcp-net.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-net.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-net.h 30 Jun 2002 08:23:45 -0000 1.3 --- dhcp-net.h 14 Oct 2002 15:52:33 -0000 1.4 *************** *** 45,49 **** /* Net/Rawnet routines. */ ! extern rawnet_t *rawnet_create(char *device, char *filter, int sport, int dport, int promiscuous); extern void rawnet_destroy(rawnet_t *net); extern int rawnet_get_packet(rawnet_t *net, struct timeval *tm); --- 45,49 ---- /* Net/Rawnet routines. */ ! extern rawnet_t *rawnet_create(const char *device, const char *filter, int sport, int dport, int promiscuous); extern void rawnet_destroy(rawnet_t *net); extern int rawnet_get_packet(rawnet_t *net, struct timeval *tm); Index: dhcp-sniff.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-sniff.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dhcp-sniff.c 12 Oct 2002 22:54:50 -0000 1.16 --- dhcp-sniff.c 14 Oct 2002 15:52:34 -0000 1.17 *************** *** 52,56 **** int retval; int sport, dport; ! char filter_buff[GENERIC_BUFFSIZE]; print_packet p_packet = print_dhcp_packet_verbose; list_t *available_interfaces; --- 52,56 ---- int retval; int sport, dport; ! stringbuffer *filter; print_packet p_packet = print_dhcp_packet_verbose; list_t *available_interfaces; *************** *** 113,120 **** } ! snprintf(filter_buff, sizeof(filter_buff), "arp or icmp or (udp and (port %d or port %d))", dport, sport); /* It's ok not to set ports since we're not writing any packets. */ ! net = rawnet_create(interface_name, filter_buff, 0, 0, 1); if(net == NULL) { --- 113,123 ---- } ! filter = create_stringbuffer(); ! stringbuffer_aprintf(filter, "arp or icmp or (udp and (port %d or port %d))", dport, sport); /* It's ok not to set ports since we're not writing any packets. */ ! net = rawnet_create(interface_name, stringbuffer_getstring(filter), 0, 0, 1); ! ! destroy_stringbuffer(filter); if(net == NULL) { |