[Dhcp-agent-commits] dhcp-agent TODO,1.26,1.27 dhcp-agent.h,1.56,1.57 dhcp-client-states.c,1.25,1.26
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv13516 Modified Files: TODO dhcp-agent.h dhcp-client-states.c dhcp-client.c dhcp-com.c dhcp-globconf.c dhcp-globconf.h dhcpclient.1 Log Message: added hostname option to client as well as adding it to command line and globconf code. Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** TODO 15 Jun 2002 14:59:20 -0000 1.26 --- TODO 15 Jun 2002 18:23:28 -0000 1.27 *************** *** 89,90 **** --- 89,100 ---- -- fix stringbuffer trimwhitespace to use last_occurance routine, and add first occurance for finding initial whitespace too. + -- we may need to change the dhcp_build_* routines to use the + dhcp-convert driver to generate the network data. it's not an + issue in the client since our option generation is minimal but + will be in the server where we'll have lots of internal data + to pack into the dhcp responses. right now we have a handful of + routines that do. we need an array of generic routines to call + the applicable dhcp-convert and then build the option wirh + create_dhcp_option(data, len, tag) + + Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** dhcp-agent.h 15 Jun 2002 14:59:20 -0000 1.56 --- dhcp-agent.h 15 Jun 2002 18:23:28 -0000 1.57 *************** *** 411,414 **** --- 411,415 ---- # define TAG_DHCP_SUBNET_MASK 1 + # define TAG_DHCP_HOSTNAME 12 # define TAG_DHCP_REQUEST_IP_ADDRESS 50 # define TAG_DHCP_OPTION_OVERLOAD 52 *************** *** 662,665 **** --- 663,667 ---- extern dhcp_option_t *dhcp_build_requested_ip_address(uint32_t address); extern dhcp_option_t *dhcp_build_server_identifier(uint32_t address); + extern dhcp_option_t *dhcp_build_hostname(char *hostname); extern uint32_t dhcp_gen_xid(void); Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-states.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** dhcp-client-states.c 11 Jun 2002 21:36:40 -0000 1.25 --- dhcp-client-states.c 15 Jun 2002 18:23:28 -0000 1.26 *************** *** 29,32 **** --- 29,33 ---- #include <dhcp-util.h> #include <dhcp-sysconf.h> + #include <dhcp-globconf.h> /* alarm handling routine and variable. */ *************** *** 58,61 **** --- 59,63 ---- list_t *options = NULL; dhcp_option_t *option; + char *hostname; if(opts != NULL) { *************** *** 83,87 **** option = dhcp_build_class_id(class_id); options = add_to_list(options, option); ! return options; } --- 85,97 ---- option = dhcp_build_class_id(class_id); options = add_to_list(options, option); ! ! /* hostname if available */ ! hostname = glob_conf_get_val(CLIENT_HOSTNAME); ! if(hostname != NULL) { ! /* if we have one set it. */ ! option = dhcp_build_hostname(hostname); ! options = add_to_list(options, option); ! } ! return options; } Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** dhcp-client.c 13 Jun 2002 15:25:36 -0000 1.27 --- dhcp-client.c 15 Jun 2002 18:23:28 -0000 1.28 *************** *** 355,359 **** dhcp_client_control_t *dc; int state; ! info_message("starting for interface %s", interface); --- 355,359 ---- dhcp_client_control_t *dc; int state; ! info_message("starting for interface %s", interface); *************** *** 449,453 **** info_message(" "); ! while((c = getopt(argc, argv, "gcdavi:m:kwh:l:")) != -1) { switch(c) { --- 449,453 ---- info_message(" "); ! while((c = getopt(argc, argv, "gcdavi:m:kwh:l:H:")) != -1) { switch(c) { *************** *** 499,502 **** --- 499,507 ---- case 'p': promiscuous = 1; + break; + + /* dhcp options which can be set on the command line. */ + case 'H': + glob_conf_set_val(optarg, CLIENT_HOSTNAME); break; Index: dhcp-com.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-com.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dhcp-com.c 11 Jun 2002 03:06:39 -0000 1.7 --- dhcp-com.c 15 Jun 2002 18:23:28 -0000 1.8 *************** *** 28,32 **** static const unsigned char dhcp_magic_cookie[4] = { 99, 130, 83, 99 }; ! /* create new dhcp object. */ --- 28,32 ---- static const unsigned char dhcp_magic_cookie[4] = { 99, 130, 83, 99 }; ! /* create new dhcp object. */ *************** *** 556,559 **** --- 556,564 ---- { return(create_dhcp_option((unsigned char *)&address, IP_ADDR_LEN, TAG_DHCP_SERVER_IDENTIFIER)); + } + + dhcp_option_t *dhcp_build_hostname(char *hostname) + { + return(create_dhcp_option((unsigned char *)hostname, (strlen(hostname) + 1), TAG_DHCP_HOSTNAME)); } Index: dhcp-globconf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-globconf.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-globconf.c 15 Jun 2002 17:07:08 -0000 1.5 --- dhcp-globconf.c 15 Jun 2002 18:23:28 -0000 1.6 *************** *** 123,129 **** --- 123,136 ---- match = 0; for(i = 0;i < GLOBAL_OPTIONS_LEN;i++) { + if(string_matches(global_config_options[i].name, varfile_get_name(varfile))) { /* we have a match. */ match = 1; + + /* skip options which have been set, since some of these may be set + on the command line. */ + if(global_config_options[i].val != NULL) + break; + global_config_options[i].val = global_config_options[i].convert_option_to_internal(varfile_get_val(varfile)); *************** *** 157,158 **** --- 164,169 ---- } + void glob_conf_set_val(void *val, int option) + { + global_config_options[option].val = global_config_options[option].convert_option_to_internal(val); + } Index: dhcp-globconf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-globconf.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-globconf.h 15 Jun 2002 17:07:08 -0000 1.2 --- dhcp-globconf.h 15 Jun 2002 18:23:28 -0000 1.3 *************** *** 39,42 **** --- 39,43 ---- extern int init_glob_conf(unsigned char *filename); extern void *glob_conf_get_val(int val_index); + extern void glob_conf_set_val(void *val, int option); /* indexes to values. */ Index: dhcpclient.1 =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcpclient.1,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcpclient.1 7 Jun 2002 13:14:47 -0000 1.9 --- dhcpclient.1 15 Jun 2002 18:23:28 -0000 1.10 *************** *** 12,15 **** --- 12,16 ---- .Op Fl l Ar level .Op Fl m Ar mac_addr + .Op Fl H Ar hostname .Sh DESCRIPTION .Nm *************** *** 58,61 **** --- 59,67 ---- downed ethernet interface it finds, or the first ethernet interface it finds. + .It Fl H Ar hostname + Use + .Ar hostname , + for hostname option in query otherwise no hostname is passed. + This may be needed for @home DHCP servers. .It Fl k Kill |