[Dhcp-agent-commits] CVS: dhcp-agent CAVEATS,1.2,1.3 COST,1.2,1.3 TODO,1.6,1.7 dhcp-agent.h,1.22,1.2
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-02-11 18:02:28
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv6998 Modified Files: CAVEATS COST TODO dhcp-agent.h dhcp-client-conf.c dhcp-client-control.c dhcp-client.c dhcpclient.1 Log Message: added promiscious mode option; fixed up config code a bit for more things to come; updated man page Index: CAVEATS =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/CAVEATS,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CAVEATS 1 Feb 2002 18:31:17 -0000 1.2 --- CAVEATS 11 Feb 2002 18:02:24 -0000 1.3 *************** *** 1,9 **** -- dhcpclient may act funny with interfaces with mtu's larger or ! smaller than 1500. this will be fixed in future releases. -- dhcpclient may exceed the recommended udp size of 576 bytes. this ! needs to be fixed. It currently does not overload bootp fields to ! make up for this. -- dhcpclient spoofing mac address may not work on all systems or NICs. test to be sure. --- 1,14 ---- + Sorry folks, still lots of caveats to watch out for. + -- dhcpclient may act funny with interfaces with mtu's larger or ! smaller than 1500. this will be fixed in future releases. -- dhcpclient may exceed the recommended udp size of 576 bytes. this ! needs to be fixed. It currently does not overload bootp fields to ! make up for this. -- dhcpclient spoofing mac address may not work on all systems or NICs. test to be sure. + + -- dhcpclient's icmp mask discovery has not been tested. Please report + success if you use this feature (send me a patch too for any bugs). Index: COST =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/COST,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** COST 5 Feb 2002 02:00:59 -0000 1.2 --- COST 11 Feb 2002 18:02:24 -0000 1.3 *************** *** 1,7 **** In writing dhcp-agent I suffered the following: ! Feb - March 2001 ! [ todo ] Jan - Feb 2001 --- 1,9 ---- In writing dhcp-agent I suffered the following: ! Feb - March 2001 (Current values as of the Feb 9) ! 18 pots of coffee; 86 camel filter cigarettes; 8 diet cokes ! (cutting down); 845 mp3s (thanks stephanie); 12 historical trips ! to the wash room; 10 showers; one pretty geekette; Jan - Feb 2001 Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TODO 9 Feb 2002 16:34:42 -0000 1.6 --- TODO 11 Feb 2002 18:02:24 -0000 1.7 *************** *** 1,8 **** - - highest priority: - - get the client to be unconditionaly compliant with rfc2131. - under-engineer the client. too much code and too many code-features. - Things that need to be done for RFC compliance: --- 1,2 ---- Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** dhcp-agent.h 9 Feb 2002 23:29:37 -0000 1.22 --- dhcp-agent.h 11 Feb 2002 18:02:24 -0000 1.23 *************** *** 218,221 **** --- 218,225 ---- } dhcp_obj; + /* default configuration */ + + #define DISCOVER_OFFER_RETRIES 3 + /* * Other packet objects. *************** *** 317,321 **** unsigned char options[MAX_OPTIONS_HANDLED]; /* which options should we handle. */ ! } client_conf_t; --- 321,325 ---- unsigned char options[MAX_OPTIONS_HANDLED]; /* which options should we handle. */ ! int discover_offer_retries; /* amount of times we're willing to keep rediscovering before giving up. */ } client_conf_t; *************** *** 344,347 **** --- 348,352 ---- unsigned char *client_hw_addr; int state; + int discover_offer_retries; } dhcp_client_control_t; *************** *** 764,768 **** /* dhcp client control */ ! extern dhcp_client_control_t *create_dhcp_client_control(char *interface); extern void destroy_dhcp_client_control(dhcp_client_control_t *dc); extern void dhcp_client_update_secs(dhcp_client_control_t *dc); --- 769,773 ---- /* dhcp client control */ ! extern dhcp_client_control_t *create_dhcp_client_control(char *interface, int promiscious); extern void destroy_dhcp_client_control(dhcp_client_control_t *dc); extern void dhcp_client_update_secs(dhcp_client_control_t *dc); Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-conf.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-client-conf.c 8 Feb 2002 01:37:29 -0000 1.4 --- dhcp-client-conf.c 11 Feb 2002 18:02:24 -0000 1.5 *************** *** 53,57 **** client_conf_reset_options(cc); cc->interface = dc->interface; ! return cc; } --- 53,57 ---- client_conf_reset_options(cc); cc->interface = dc->interface; ! cc->discover_offer_retries = DISCOVER_OFFER_RETRIES; return cc; } *************** *** 67,79 **** } ! static int dump_config_options(client_conf_t *cc) { int i; FILE *fp; - char *fname; - fname = get_conf_options_fname(cc); fp = file_open_or_create_safe(fname, "w"); - xfree(fname); if(fp == NULL) --- 67,76 ---- } ! static int dump_config_options(client_conf_t *cc, char *fname) { int i; FILE *fp; fp = file_open_or_create_safe(fname, "w"); if(fp == NULL) *************** *** 105,117 **** } ! static int client_conf_load_options(client_conf_t *cc) { - char *fname; FILE *fp; int i; - fname = get_conf_options_fname(cc); fp = file_open_or_create_safe(fname, "r"); - xfree(fname); if(fp == NULL) --- 102,111 ---- } ! static int client_conf_load_options(client_conf_t *cc, char *fname) { FILE *fp; int i; fp = file_open_or_create_safe(fname, "r"); if(fp == NULL) *************** *** 143,146 **** --- 137,163 ---- } + /* load configuration file or call applicable default setter, + also call dump_defaults if file does not exist */ + + static int load_client_conf_proc(char *fname, + client_conf_t *cc, int (*load_conf)(client_conf_t *cc, char *fname), + void (*use_defaults)(client_conf_t *cc), + int (*dump_defaults)(client_conf_t *cc, char *fname)) + { + int retval; + + if(!file_exists(fname)) { + /* it doesn't exist. strap default. */ + use_defaults(cc); + /* and dump to file. */ + retval = dump_config_options(cc, fname); + } else { + /* read conf data from file. */ + retval = load_conf(cc, fname); + } + + return retval; + } + int load_client_conf(client_conf_t *cc) { *************** *** 149,167 **** int retval; client_conf_reset_options(cc); /* check for options file. */ fname = get_conf_options_fname(cc); ! ! if(!file_exists(fname)) { ! /* it doesn't exist. use default options. */ ! use_default_options(cc); ! /* and dump it to file. */ ! retval = dump_config_options(cc); ! } else { ! /* read options file. */ ! retval = client_conf_load_options(cc); ! } ! xfree(fname); ! return retval; } --- 166,177 ---- int retval; + /* load up options file. */ + client_conf_reset_options(cc); /* check for options file. */ fname = get_conf_options_fname(cc); ! retval = load_client_conf_proc(fname, cc, client_conf_load_options, use_default_options, dump_config_options); xfree(fname); ! ! return(retval); } Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-control.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-control.c 9 Feb 2002 16:34:42 -0000 1.11 --- dhcp-client-control.c 11 Feb 2002 18:02:24 -0000 1.12 *************** *** 24,27 **** --- 24,29 ---- #include <dhcp-agent.h> + /* Utility routines to update counters and time stamps. */ + /* Update seconds field for dhcp discover packets. */ void dhcp_client_update_secs(dhcp_client_control_t *dc) *************** *** 38,42 **** } ! /* create client id from a string in the format of 0x:0x:0x:0x:0x:0x */ static unsigned char *create_fake_client_id(unsigned char *mac_string) { --- 40,59 ---- } ! /* dhcp reset discover offer retries. */ ! void dhcp_client_reset_discover_offer_retries(dhcp_client_control_t *dc) ! { ! dc->discover_offer_retries = 0; ! } ! ! /* dhcp increment and check whether we should give up on discover offer retries. */ ! int dhcp_client_discover_offer_can_retry(dhcp_client_control_t *dc) ! { ! dc->discover_offer_retries++; ! if(dc->discover_offer_retries > dc->conf->discover_offer_retries) ! return 1; ! ! return 0; ! } ! /* create client id from a string in the format of xx:xx:xx:xx:xx:xx */ static unsigned char *create_fake_client_id(unsigned char *mac_string) { *************** *** 90,94 **** /* create client control object */ ! dhcp_client_control_t *create_dhcp_client_control(char *interface) { dhcp_client_control_t *dc; --- 107,111 ---- /* create client control object */ ! dhcp_client_control_t *create_dhcp_client_control(char *interface, int promiscious) { dhcp_client_control_t *dc; *************** *** 147,151 **** dport, sport); ! if((dc->rawnet = net_create(interface, filter_buff, sport, dport, 0)) == NULL) { destroy_dhcp_client_control(dc); return NULL; --- 164,168 ---- dport, sport); ! if((dc->rawnet = net_create(interface, filter_buff, sport, dport, promiscious)) == NULL) { destroy_dhcp_client_control(dc); return NULL; *************** *** 160,163 **** --- 177,184 ---- dhcp_client_reset_secs(dc); dhcp_client_update_secs(dc); + + /* discover offer retries. */ + dhcp_client_reset_discover_offer_retries(dc); + #ifdef HAVE_UNAME uname(&utsname); *************** *** 174,178 **** dc->client_id = create_client_id(interface_addr); ! return dc; } --- 195,199 ---- dc->client_id = create_client_id(interface_addr); ! dc->discover_offer_retries = 0; /* reset discover offer. */ return dc; } Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dhcp-client.c 8 Feb 2002 17:04:32 -0000 1.13 --- dhcp-client.c 11 Feb 2002 18:02:24 -0000 1.14 *************** *** 177,181 **** /* A race condition exists between the discover and request state. * So we can't hup the client and tell it the cache has been deleted. */ ! error_message("dhcpclient already running. i won't delete cache until it's shutdown."); return; } --- 177,182 ---- /* A race condition exists between the discover and request state. * So we can't hup the client and tell it the cache has been deleted. */ ! error_message("dhcpclient already running."); ! error_message("i won't delete cache until it's shutdown."); return; } *************** *** 222,226 **** int state; unsigned char want_background = 1; ! static char *fake_hw_addr = NULL; while((c = getopt(argc, argv, "gcdavim:kwh:l:")) != -1) { --- 223,228 ---- int state; unsigned char want_background = 1; ! char *fake_hw_addr = NULL; ! int promiscious = 0; while((c = getopt(argc, argv, "gcdavim:kwh:l:")) != -1) { *************** *** 263,267 **** exit(0); ! case 'l': if(set_verbosity_level(atoi(optarg))) { --- 265,269 ---- exit(0); ! case 'l': if(set_verbosity_level(atoi(optarg))) { *************** *** 272,275 **** --- 274,282 ---- break; + case 'p': + + promiscious = 1; + break; + case 'h': /* fall through. */ default: *************** *** 327,331 **** setup_interrupt_handlers(); /* setup signal handling */ ! if((dc = create_dhcp_client_control(interface)) == NULL) { error_message("encountered fatal error. cannot continue. exiting"); do_shutdown(dc); --- 334,338 ---- setup_interrupt_handlers(); /* setup signal handling */ ! if((dc = create_dhcp_client_control(interface, promiscious)) == NULL) { error_message("encountered fatal error. cannot continue. exiting"); do_shutdown(dc); *************** *** 356,360 **** * we lose them after we fork in go_background. */ ! if((dc = create_dhcp_client_control(interface)) == NULL) { error_message("encountered a fatal error. cannot continue. exiting"); do_shutdown(dc); --- 363,367 ---- * we lose them after we fork in go_background. */ ! if((dc = create_dhcp_client_control(interface, promiscious)) == NULL) { error_message("encountered a fatal error. cannot continue. exiting"); do_shutdown(dc); Index: dhcpclient.1 =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcpclient.1,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcpclient.1 7 Feb 2002 18:41:47 -0000 1.7 --- dhcpclient.1 11 Feb 2002 18:02:24 -0000 1.8 *************** *** 21,27 **** safe to run more than one dhcpclient per interface. Currently only the basic networking DHCP options are handled. The interfaces IP ! address, routing, and domain name system are setup. .Sh OPTIONS .Bl -tag .It Op Ar -i interface name Specifies a the name of an interface dhcpsniff will use. otherwise --- 21,32 ---- safe to run more than one dhcpclient per interface. Currently only the basic networking DHCP options are handled. The interfaces IP ! address, the routing table, and the domain name system are setup. .Sh OPTIONS .Bl -tag + .It Op -p + Run in promiscious mode (implicit with -m flag). You should only + use this option if the system you are using dhcpclient on is + sufficiently broken that it needs promiscious mode to receive + packets with libpcap. .It Op Ar -i interface name Specifies a the name of an interface dhcpsniff will use. otherwise |