[dhcp-agent-commits] dhcp-agent/src dhcp-align.c,1.2,1.3 dhcp-align.h,1.1,1.2 dhcp-arp-discovery.c,1
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory usw-pr-cvs1:/tmp/cvs-serv31010/src Modified Files: dhcp-align.c dhcp-align.h dhcp-arp-discovery.c dhcp-arp.c dhcp-cache-entry.c dhcp-cache-entry.h dhcp-client-cache.c dhcp-client-cache.h dhcp-client-conf.c dhcp-client-conf.h dhcp-client-control.c dhcp-client-states.c dhcp-client.c dhcp-client.h dhcp-com.c dhcp-convert.c dhcp-convert.h dhcp-daemon.c dhcp-daemon.h dhcp-eth.c dhcp-files.c dhcp-globconf.c dhcp-globconf.h dhcp-icmp-discovery.c dhcp-icmp.c dhcp-interface.c dhcp-interface.h dhcp-interrupt.c dhcp-ip.c dhcp-librawnet.h dhcp-libutil.h dhcp-limits.h dhcp-list.c dhcp-local.h dhcp-log.c dhcp-log.h dhcp-options-strings.c dhcp-options-strings.h dhcp-packet-build.c dhcp-parser.c dhcp-parser.h dhcp-print.c dhcp-print.h dhcp-rawnet.c dhcp-route.c dhcp-rtt.c dhcp-sniff.c dhcp-sniffer-ohandlers.c dhcp-snprintf.c dhcp-stringbuffer.c dhcp-sysconf.c dhcp-sysconf.h dhcp-udp.c dhcp-util.c dhcp-varfile.c Log Message: now with automatic indentation Index: dhcp-align.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-align.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-align.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-align.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 40,44 **** { unsigned char vhl; ! vhl = *data; --- 40,44 ---- { unsigned char vhl; ! vhl = *data; *************** *** 104,109 **** } ! void align_dhcphdr(const unsigned char *data, ! dhcphdr *dhcp) { memcpy(&dhcp->op, data, sizeof(dhcp->op)); --- 104,108 ---- } ! void align_dhcphdr(const unsigned char *data, dhcphdr * dhcp) { memcpy(&dhcp->op, data, sizeof(dhcp->op)); *************** *** 155,164 **** memcpy(&header->eth_dst, data, ETH_ADDR_LEN); data += ETH_ADDR_LEN; ! memcpy(&header->eth_src, data, ETH_ADDR_LEN); data += ETH_ADDR_LEN; ! memcpy(&header->eth_type, data, ETH_TYPE_LEN); ! return; } --- 154,163 ---- memcpy(&header->eth_dst, data, ETH_ADDR_LEN); data += ETH_ADDR_LEN; ! memcpy(&header->eth_src, data, ETH_ADDR_LEN); data += ETH_ADDR_LEN; ! memcpy(&header->eth_type, data, ETH_TYPE_LEN); ! return; } Index: dhcp-align.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-align.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-align.h 10 Nov 2002 15:46:40 -0000 1.1 --- dhcp-align.h 16 Nov 2002 00:23:42 -0000 1.2 *************** *** 29,33 **** extern void align_ip(const unsigned char *data, struct ip_hdr *iphdr); extern void align_udp(const unsigned char *data, struct udp_hdr *udp); ! extern void align_dhcphdr(const unsigned char *data, dhcphdr *dhcp); extern void align_eth(const unsigned char *data, struct eth_hdr *header); extern void align_icmp(const unsigned char *data, struct icmp_hdr *header); --- 29,33 ---- extern void align_ip(const unsigned char *data, struct ip_hdr *iphdr); extern void align_udp(const unsigned char *data, struct udp_hdr *udp); ! extern void align_dhcphdr(const unsigned char *data, dhcphdr * dhcp); extern void align_eth(const unsigned char *data, struct eth_hdr *header); extern void align_icmp(const unsigned char *data, struct icmp_hdr *header); *************** *** 37,39 **** extern void align_arp_data(const unsigned char *data, struct arp_ethip *arp_data); ! #endif /* DHCP_ALIGN_H */ --- 37,39 ---- extern void align_arp_data(const unsigned char *data, struct arp_ethip *arp_data); ! #endif /* DHCP_ALIGN_H */ Index: dhcp-arp-discovery.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-arp-discovery.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-arp-discovery.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-arp-discovery.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 68,72 **** } ! int arp_discover_hardware_address(rawnet_t *net, int retries, uint32_t address, eth_addr_t *mac_addr) { list_t *arg_list = NULL; --- 68,73 ---- } ! int arp_discover_hardware_address(rawnet_t *net, int retries, uint32_t address, ! eth_addr_t *mac_addr) { list_t *arg_list = NULL; *************** *** 80,123 **** * hardware address so we get a reply back. */ ! build_arp_request(net, net->cip_addr, address, net->chw_addr); while(retries--) { ! retval = rawnet_packet_transact(net, arg_list, NULL, check_for_arp_reply, RECOMMENDED_MAX_SECS_WAIT); ! switch(retval) { ! case RAWNET_TIMEOUT: ! /* we timed out. retry. */ ! break; ! case RAWNET_OK: ! ! /* Yummy! We got a valid reply! */ ! ! sender_addr = arp_get_sender_hardware_address(net->arp_p); ! memcpy(mac_addr->data, sender_addr, ETH_ADDR_LEN); ! /* just free up pair. FIXME: this isn't good because we're ! * breaking the list blackbox. we need a better way to do this. ! * the datums don't need to be freed since we keep them on the stack. */ ! xfree(arg_list->next); ! xfree(arg_list); ! return 0; ! case RAWNET_ERROR: ! /* wops error. this is bad. */ ! ERROR_MESSAGE("received error from raw network handler."); ! return 1; default: /* not good. */ FATAL_MESSAGE("invalid return from rawnet_transact. this a bug report it."); ! } } ! /* FIXME: ditto (see above) */ xfree(arg_list->next); --- 81,126 ---- * hardware address so we get a reply back. */ ! build_arp_request(net, net->cip_addr, address, net->chw_addr); while(retries--) { ! retval = ! rawnet_packet_transact(net, arg_list, NULL, check_for_arp_reply, ! RECOMMENDED_MAX_SECS_WAIT); ! switch (retval) { ! case RAWNET_TIMEOUT: ! /* we timed out. retry. */ ! break; ! case RAWNET_OK: ! /* Yummy! We got a valid reply! */ ! sender_addr = arp_get_sender_hardware_address(net->arp_p); ! memcpy(mac_addr->data, sender_addr, ETH_ADDR_LEN); ! /* just free up pair. FIXME: this isn't good because we're ! * breaking the list blackbox. we need a better way to do this. ! * the datums don't need to be freed since we keep them on the stack. */ ! xfree(arg_list->next); ! xfree(arg_list); ! ! return 0; ! ! case RAWNET_ERROR: ! /* wops error. this is bad. */ ! ERROR_MESSAGE("received error from raw network handler."); ! return 1; default: /* not good. */ FATAL_MESSAGE("invalid return from rawnet_transact. this a bug report it."); ! } } ! /* FIXME: ditto (see above) */ xfree(arg_list->next); Index: dhcp-arp.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-arp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-arp.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-arp.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 35,46 **** { arp_obj *arp; ! arp = xmalloc(sizeof(arp_obj)); ! return arp; } /* destructor */ ! void arp_destroy(arp_obj *arp) { xfree(arp); --- 35,46 ---- { arp_obj *arp; ! arp = xmalloc(sizeof(arp_obj)); ! return arp; } /* destructor */ ! void arp_destroy(arp_obj * arp) { xfree(arp); *************** *** 49,53 **** /* set routines. */ ! void arp_set_hardware_type(arp_obj *arp, uint16_t hdr_addr) { arp->header.ar_hrd = htons(hdr_addr); --- 49,53 ---- /* set routines. */ ! void arp_set_hardware_type(arp_obj * arp, uint16_t hdr_addr) { arp->header.ar_hrd = htons(hdr_addr); *************** *** 55,59 **** } ! void arp_set_protocol_type(arp_obj *arp, uint16_t pro) { arp->header.ar_pro = htons(pro); --- 55,59 ---- } ! void arp_set_protocol_type(arp_obj * arp, uint16_t pro) { arp->header.ar_pro = htons(pro); *************** *** 61,70 **** } ! void arp_set_hardware_len(arp_obj *arp, uint8_t len) { arp->header.ar_hln = len; return; } ! void arp_set_protocol_len(arp_obj *arp, uint8_t len) { arp->header.ar_pln = len; --- 61,70 ---- } ! void arp_set_hardware_len(arp_obj * arp, uint8_t len) { arp->header.ar_hln = len; return; } ! void arp_set_protocol_len(arp_obj * arp, uint8_t len) { arp->header.ar_pln = len; *************** *** 72,76 **** } ! void arp_set_op(arp_obj *arp, uint16_t op) { arp->header.ar_op = htons(op); --- 72,76 ---- } ! void arp_set_op(arp_obj * arp, uint16_t op) { arp->header.ar_op = htons(op); *************** *** 78,82 **** } ! void arp_set_sender_hardware_address(arp_obj *arp, eth_addr_t addr) { memcpy(&arp->arp_data.ar_sha, &addr.data, ETH_ADDR_LEN); --- 78,82 ---- } ! void arp_set_sender_hardware_address(arp_obj * arp, eth_addr_t addr) { memcpy(&arp->arp_data.ar_sha, &addr.data, ETH_ADDR_LEN); *************** *** 84,88 **** } ! void arp_set_sender_protocol_address(arp_obj *arp, uint32_t addr) { memcpy(&arp->arp_data.ar_spa, &addr, IP_ADDR_LEN); --- 84,88 ---- } ! void arp_set_sender_protocol_address(arp_obj * arp, uint32_t addr) { memcpy(&arp->arp_data.ar_spa, &addr, IP_ADDR_LEN); *************** *** 90,94 **** } ! void arp_set_target_hardware_address(arp_obj *arp, eth_addr_t addr) { memcpy(&arp->arp_data.ar_tha, &addr.data, ETH_ADDR_LEN); --- 90,94 ---- } ! void arp_set_target_hardware_address(arp_obj * arp, eth_addr_t addr) { memcpy(&arp->arp_data.ar_tha, &addr.data, ETH_ADDR_LEN); *************** *** 96,100 **** } ! void arp_set_target_protocol_address(arp_obj *arp, uint32_t addr) { memcpy(&arp->arp_data.ar_tpa, &addr, IP_ADDR_LEN); --- 96,100 ---- } ! void arp_set_target_protocol_address(arp_obj * arp, uint32_t addr) { memcpy(&arp->arp_data.ar_tpa, &addr, IP_ADDR_LEN); *************** *** 104,148 **** /* get routines. */ ! uint16_t arp_get_op(arp_obj *arp) { ! return(ntohs(arp->header.ar_op)); } ! uint16_t arp_get_hardware_type(arp_obj *arp) { ! return(ntohs(arp->header.ar_hrd)); } ! uint16_t arp_get_protocol_type(arp_obj *arp) { ! return(ntohs(arp->header.ar_pro)); } ! uint8_t arp_get_hardware_len(arp_obj *arp) { ! return(arp->header.ar_hln); } ! uint8_t arp_get_protocol_len(arp_obj *arp) { ! return(arp->header.ar_pln); } ! unsigned char *arp_get_sender_hardware_address(arp_obj *arp) { ! return(arp->arp_data.ar_sha); } ! unsigned char *arp_get_sender_protocol_address(arp_obj *arp) { ! return(arp->arp_data.ar_spa); } /* dump image to packet. */ ! void arp_write_packet_image(arp_obj *arp, unsigned char *packet) { memcpy(packet, &arp->header.ar_hrd, sizeof(arp->header.ar_hrd)); packet += sizeof(arp->header.ar_hrd); ! memcpy(packet, &arp->header.ar_pro, sizeof(arp->header.ar_pro)); packet += sizeof(arp->header.ar_pro); --- 104,148 ---- /* get routines. */ ! uint16_t arp_get_op(arp_obj * arp) { ! return (ntohs(arp->header.ar_op)); } ! uint16_t arp_get_hardware_type(arp_obj * arp) { ! return (ntohs(arp->header.ar_hrd)); } ! uint16_t arp_get_protocol_type(arp_obj * arp) { ! return (ntohs(arp->header.ar_pro)); } ! uint8_t arp_get_hardware_len(arp_obj * arp) { ! return (arp->header.ar_hln); } ! uint8_t arp_get_protocol_len(arp_obj * arp) { ! return (arp->header.ar_pln); } ! unsigned char *arp_get_sender_hardware_address(arp_obj * arp) { ! return (arp->arp_data.ar_sha); } ! unsigned char *arp_get_sender_protocol_address(arp_obj * arp) { ! return (arp->arp_data.ar_spa); } /* dump image to packet. */ ! void arp_write_packet_image(arp_obj * arp, unsigned char *packet) { memcpy(packet, &arp->header.ar_hrd, sizeof(arp->header.ar_hrd)); packet += sizeof(arp->header.ar_hrd); ! memcpy(packet, &arp->header.ar_pro, sizeof(arp->header.ar_pro)); packet += sizeof(arp->header.ar_pro); *************** *** 150,160 **** memcpy(packet, &arp->header.ar_hln, sizeof(arp->header.ar_hln)); packet += sizeof(arp->header.ar_hln); ! memcpy(packet, &arp->header.ar_pln, sizeof(arp->header.ar_pln)); packet += sizeof(arp->header.ar_pln); ! memcpy(packet, &arp->header.ar_op, sizeof(arp->header.ar_op)); packet += sizeof(arp->header.ar_op); ! memcpy(packet, &arp->arp_data.ar_sha, sizeof(arp->arp_data.ar_sha)); packet += sizeof(arp->arp_data.ar_sha); --- 150,160 ---- memcpy(packet, &arp->header.ar_hln, sizeof(arp->header.ar_hln)); packet += sizeof(arp->header.ar_hln); ! memcpy(packet, &arp->header.ar_pln, sizeof(arp->header.ar_pln)); packet += sizeof(arp->header.ar_pln); ! memcpy(packet, &arp->header.ar_op, sizeof(arp->header.ar_op)); packet += sizeof(arp->header.ar_op); ! memcpy(packet, &arp->arp_data.ar_sha, sizeof(arp->arp_data.ar_sha)); packet += sizeof(arp->arp_data.ar_sha); *************** *** 162,175 **** memcpy(packet, &arp->arp_data.ar_spa, sizeof(arp->arp_data.ar_spa)); packet += sizeof(arp->arp_data.ar_spa); ! memcpy(packet, &arp->arp_data.ar_tha, sizeof(arp->arp_data.ar_tha)); packet += sizeof(arp->arp_data.ar_tha); memcpy(packet, &arp->arp_data.ar_tpa, sizeof(arp->arp_data.ar_tpa)); ! return; } ! int arp_read_packet_image(arp_obj *arp, const unsigned char *packet, int len) { if(len < (ARP_HDR_LEN + ARP_ETHIP_LEN)) --- 162,175 ---- memcpy(packet, &arp->arp_data.ar_spa, sizeof(arp->arp_data.ar_spa)); packet += sizeof(arp->arp_data.ar_spa); ! memcpy(packet, &arp->arp_data.ar_tha, sizeof(arp->arp_data.ar_tha)); packet += sizeof(arp->arp_data.ar_tha); memcpy(packet, &arp->arp_data.ar_tpa, sizeof(arp->arp_data.ar_tpa)); ! return; } ! int arp_read_packet_image(arp_obj * arp, const unsigned char *packet, int len) { if(len < (ARP_HDR_LEN + ARP_ETHIP_LEN)) Index: dhcp-cache-entry.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-cache-entry.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-cache-entry.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-cache-entry.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 38,46 **** { cache_entry_t *cache; ! cache = xmalloc(sizeof(cache_entry_t)); cache->name = xstrdup(name); cache->value = xstrdup(value); ! return cache; } --- 38,46 ---- { cache_entry_t *cache; ! cache = xmalloc(sizeof(cache_entry_t)); cache->name = xstrdup(name); cache->value = xstrdup(value); ! return cache; } *************** *** 51,55 **** xfree(cache->value); xfree(cache); ! return; } --- 51,55 ---- xfree(cache->value); xfree(cache); ! return; } Index: dhcp-cache-entry.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-cache-entry.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-cache-entry.h 10 Nov 2002 15:46:40 -0000 1.1 --- dhcp-cache-entry.h 16 Nov 2002 00:23:42 -0000 1.2 *************** *** 35,37 **** extern void cache_entry_purge_list(list_t *cache_list); ! #endif /* DHCP_CACHE_ENTRY_H */ --- 35,37 ---- extern void cache_entry_purge_list(list_t *cache_list); ! #endif /* DHCP_CACHE_ENTRY_H */ Index: dhcp-client-cache.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-cache.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-client-cache.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-client-cache.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 40,48 **** { client_cache_t *cc; ! cc = xmalloc(sizeof(client_cache_t)); cc->interface = interface; /* don't copy just point. */ cc->vars = NULL; ! return cc; } --- 40,48 ---- { client_cache_t *cc; ! cc = xmalloc(sizeof(client_cache_t)); cc->interface = interface; /* don't copy just point. */ cc->vars = NULL; ! return cc; } *************** *** 53,63 **** list_t *list_ptr, *tmp; cache_entry_t *ce; ! list_ptr = cc->vars; ! while(list_ptr) { ! tmp = list_ptr; list_ptr = list_ptr->next; ! ce = tmp->data; destroy_cache_entry(ce); --- 53,63 ---- list_t *list_ptr, *tmp; cache_entry_t *ce; ! list_ptr = cc->vars; ! while(list_ptr) { ! tmp = list_ptr; list_ptr = list_ptr->next; ! ce = tmp->data; destroy_cache_entry(ce); *************** *** 74,78 **** if(cc->vars) purge_cache(cc); ! xfree(cc); return; --- 74,78 ---- if(cc->vars) purge_cache(cc); ! xfree(cc); return; *************** *** 86,94 **** retval = varfile_get_next_var(varfile); ! switch(retval) { ! case VARFILE_PARSE_ERROR: ! ERROR_MESSAGE("parser error in cache: %s : %d", varfile_get_filename(varfile), varfile_get_lineno(varfile)); ! return NULL; case VARFILE_EOF: --- 86,95 ---- retval = varfile_get_next_var(varfile); ! switch (retval) { ! case VARFILE_PARSE_ERROR: ! ERROR_MESSAGE("parser error in cache: %s : %d", varfile_get_filename(varfile), ! varfile_get_lineno(varfile)); ! return NULL; case VARFILE_EOF: *************** *** 159,165 **** char *fname; int retval; ! purge_cache(cc); ! if(use_tmp) fname = get_fname_tmp(cc); --- 160,166 ---- char *fname; int retval; ! purge_cache(cc); ! if(use_tmp) fname = get_fname_tmp(cc); *************** *** 169,173 **** retval = load_client_cache_proc(cc, fname); xfree(fname); ! return retval; } --- 170,174 ---- retval = load_client_cache_proc(cc, fname); xfree(fname); ! return retval; } *************** *** 185,194 **** int retval = 0; char *fname; ! fname = get_fname(cc); if(file_exists(fname)) retval = 1; xfree(fname); ! return retval; } --- 186,195 ---- int retval = 0; char *fname; ! fname = get_fname(cc); if(file_exists(fname)) retval = 1; xfree(fname); ! return retval; } *************** *** 200,212 **** dhcp_option_t *opt; unsigned char len; ! if(option_convert_handlers[tag].serialize_to_network == NULL) return NULL; ! data = option_convert_handlers[tag].serialize_to_network(string, &len); ! if(data == NULL) { WARN_MESSAGE("option: %s may be malformed. I'll ignore and carry on.", ! dhcp_options_strings[tag]); return NULL; } --- 201,213 ---- dhcp_option_t *opt; unsigned char len; ! if(option_convert_handlers[tag].serialize_to_network == NULL) return NULL; ! data = option_convert_handlers[tag].serialize_to_network(string, &len); ! if(data == NULL) { WARN_MESSAGE("option: %s may be malformed. I'll ignore and carry on.", ! dhcp_options_strings[tag]); return NULL; } *************** *** 222,227 **** * */ ! static list_t *get_cache_options_list_proc(client_cache_t *cc, ! void* (*convert_func)(unsigned char tag, char *string)) { list_t *options = NULL; --- 223,228 ---- * */ ! static list_t *get_cache_options_list_proc(client_cache_t *cc, ! void *(*convert_func) (unsigned char tag, char *string)) { list_t *options = NULL; *************** *** 231,243 **** void *data; ! for(cache = cc->vars;cache;cache = cache->next) { ! ce = cache->data; - - for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { ! if(string_matches(dhcp_options_strings[i], ce->name)) { ! if(convert_func) { data = convert_func(i, ce->value); if(data == NULL) --- 232,244 ---- void *data; ! for(cache = cc->vars; cache; cache = cache->next) { ! ce = cache->data; ! for(i = 0; i < MAX_OPTIONS_HANDLED; i++) { ! if(string_matches(dhcp_options_strings[i], ce->name)) { ! ! if(convert_func) { data = convert_func(i, ce->value); if(data == NULL) *************** *** 254,258 **** } } ! return options; } --- 255,259 ---- } } ! return options; } *************** *** 261,266 **** * we always do this to the temp file. */ ! int client_cache_dump_options(client_cache_t *cc, ! list_t *options) { FILE *fp; --- 262,266 ---- * we always do this to the temp file. */ ! int client_cache_dump_options(client_cache_t *cc, list_t *options) { FILE *fp; *************** *** 277,285 **** return -1; ! for(list_ptr = options;list_ptr;list_ptr = list_ptr->next) { ! /* Run coversion routines to store internally in * serialized (string) state. */ ! opt = list_ptr->data; --- 277,285 ---- return -1; ! for(list_ptr = options; list_ptr; list_ptr = list_ptr->next) { ! /* Run coversion routines to store internally in * serialized (string) state. */ ! opt = list_ptr->data; *************** *** 296,300 **** */ ! if(val == NULL) { WARN_MESSAGE("option %s appear malformed. skipping.."); continue; --- 296,300 ---- */ ! if(val == NULL) { WARN_MESSAGE("option %s appear malformed. skipping.."); continue; *************** *** 311,317 **** /* work horse load options routine. */ static list_t *client_cache_load_options_list_proc(client_cache_t *cc, unsigned char use_tmp, ! void* (*convert_func)(unsigned char tag, char *string)) { ! list_t *options; --- 311,318 ---- /* work horse load options routine. */ static list_t *client_cache_load_options_list_proc(client_cache_t *cc, unsigned char use_tmp, ! void *(*convert_func) (unsigned char tag, ! char *string)) { ! list_t *options; *************** *** 328,337 **** list_t *client_cache_load_option_network_list(client_cache_t *cc, unsigned char use_tmp) { ! return(client_cache_load_options_list_proc(cc, use_tmp, convert_to_network)); } /* load options and return serialized list. */ list_t *client_cache_load_option_string_list(client_cache_t *cc, unsigned char use_tmp) { ! return(client_cache_load_options_list_proc(cc, use_tmp, NULL)); } --- 329,339 ---- list_t *client_cache_load_option_network_list(client_cache_t *cc, unsigned char use_tmp) { ! return (client_cache_load_options_list_proc(cc, use_tmp, convert_to_network)); } + /* load options and return serialized list. */ list_t *client_cache_load_option_string_list(client_cache_t *cc, unsigned char use_tmp) { ! return (client_cache_load_options_list_proc(cc, use_tmp, NULL)); } *************** *** 340,347 **** { char *fname_tmp, *fname; ! fname_tmp = get_fname_tmp(cc); fname = get_fname(cc); ! move_file(fname_tmp, fname); --- 342,349 ---- { char *fname_tmp, *fname; ! fname_tmp = get_fname_tmp(cc); fname = get_fname(cc); ! move_file(fname_tmp, fname); *************** *** 359,363 **** delete_file(fname); xfree(fname); ! return; } --- 361,365 ---- delete_file(fname); xfree(fname); ! return; } *************** *** 370,374 **** delete_file(fname); xfree(fname); ! return; } --- 372,376 ---- delete_file(fname); xfree(fname); ! return; } Index: dhcp-client-cache.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-cache.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-client-cache.h 10 Nov 2002 15:46:40 -0000 1.1 --- dhcp-client-cache.h 16 Nov 2002 00:23:42 -0000 1.2 *************** *** 28,32 **** /* data structures. */ typedef struct { ! const char *interface; /* points to dhcp_client_control->interface */ list_t *vars; } client_cache_t; --- 28,32 ---- /* data structures. */ typedef struct { ! const char *interface; /* points to dhcp_client_control->interface */ list_t *vars; } client_cache_t; *************** *** 46,48 **** extern void client_cache_delete_cache(client_cache_t *cc); ! #endif /* DHCP_CLIENT_CACHE_H */ --- 46,48 ---- extern void client_cache_delete_cache(client_cache_t *cc); ! #endif /* DHCP_CLIENT_CACHE_H */ Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-client-conf.c 10 Nov 2002 15:46:40 -0000 1.2 --- dhcp-client-conf.c 16 Nov 2002 00:23:42 -0000 1.3 *************** *** 40,54 **** * Here we keep the options we want by default. */ ! static const int default_config_options[] = { ! TAG_DHCP_SUBNET_MASK, /* Subnet Mask */ ! TAG_DHCP_ROUTER, /* Routers. */ ! TAG_DHCP_INTERFACE_MTU, /* Interface MTU */ ! TAG_DHCP_DOMAIN_NAME_SERVER, /* Domain Name Servers. */ ! TAG_DHCP_DOMAIN_NAME, /* Domain Name. */ ! TAG_DHCP_REQUESTED_IP_ADDRESS, /* Requested IP Address. */ ! TAG_DHCP_IP_ADDRESS_LEASE_TIME, /* IP Address lease time. */ ! TAG_DHCP_RENEWAL_TIME, /* Renewal time. */ ! TAG_DHCP_REBINDING_TIME, /* Rebinding time. */ ! TAG_DHCP_SERVER_IDENTIFIER, /* Server Identifier. */ }; --- 40,54 ---- * Here we keep the options we want by default. */ ! static const int default_config_options[] = { ! TAG_DHCP_SUBNET_MASK, /* Subnet Mask */ ! TAG_DHCP_ROUTER, /* Routers. */ ! TAG_DHCP_INTERFACE_MTU, /* Interface MTU */ ! TAG_DHCP_DOMAIN_NAME_SERVER, /* Domain Name Servers. */ ! TAG_DHCP_DOMAIN_NAME, /* Domain Name. */ ! TAG_DHCP_REQUESTED_IP_ADDRESS, /* Requested IP Address. */ ! TAG_DHCP_IP_ADDRESS_LEASE_TIME, /* IP Address lease time. */ ! TAG_DHCP_RENEWAL_TIME, /* Renewal time. */ ! TAG_DHCP_REBINDING_TIME, /* Rebinding time. */ ! TAG_DHCP_SERVER_IDENTIFIER, /* Server Identifier. */ }; *************** *** 61,65 **** { client_conf_t *cc; ! cc = xmalloc(sizeof(client_conf_t)); client_conf_reset_options(cc); --- 61,65 ---- { client_conf_t *cc; ! cc = xmalloc(sizeof(client_conf_t)); client_conf_reset_options(cc); *************** *** 70,74 **** void client_conf_destroy(client_conf_t *cc) { ! xfree(cc); } --- 70,74 ---- void client_conf_destroy(client_conf_t *cc) { ! xfree(cc); } *************** *** 89,93 **** int i; FILE *fp; ! fp = file_open_or_create_safe(fname, "a+"); --- 89,93 ---- int i; FILE *fp; ! fp = file_open_or_create_safe(fname, "a+"); *************** *** 95,101 **** return -1; ! for(i = 0;i < DEFAULT_CONFIG_OPTIONS_LEN; i++) { ! ! if(fprintf(fp, "\"%s\"\n",dhcp_options_strings[default_config_options[i]]) < 0) { WARN_MESSAGE("could not dump options to file. I'm going to continue anyway."); fclose(fp); --- 95,101 ---- return -1; ! for(i = 0; i < DEFAULT_CONFIG_OPTIONS_LEN; i++) { ! ! if(fprintf(fp, "\"%s\"\n", dhcp_options_strings[default_config_options[i]]) < 0) { WARN_MESSAGE("could not dump options to file. I'm going to continue anyway."); fclose(fp); *************** *** 103,107 **** } } ! fclose(fp); return 0; --- 103,107 ---- } } ! fclose(fp); return 0; *************** *** 112,119 **** int i; ! for(i = 0;i < DEFAULT_CONFIG_OPTIONS_LEN; i++) { cc->options[default_config_options[i]] = 1; } ! return; } --- 112,119 ---- int i; ! for(i = 0; i < DEFAULT_CONFIG_OPTIONS_LEN; i++) { cc->options[default_config_options[i]] = 1; } ! return; } *************** *** 132,163 **** return -1; } ! while(1) { ! retval = varfile_get_next_var(varfile); ! switch(retval) { ! case VARFILE_SUCCESS: ! match = 0; ! for(i = 0;i < MAX_OPTIONS_HANDLED;i++) { ! /* as long as no error was returned from file_parse_string ! * we can just do a file_get_var_name() safely. */ ! if(string_matches(dhcp_options_strings[i], ! varfile_get_name(varfile))) { ! cc->options[i] = 1; ! match = 1; ! break; ! } ! ! } ! if(match != 1) ! WARN_MESSAGE("encountered illegal DHCP option in %s: %s : %d", fname, varfile_get_name(varfile), ! varfile_get_lineno(varfile)); ! break; case VARFILE_EOF: --- 132,162 ---- return -1; } ! while(1) { ! retval = varfile_get_next_var(varfile); ! switch (retval) { ! case VARFILE_SUCCESS: ! match = 0; ! for(i = 0; i < MAX_OPTIONS_HANDLED; i++) { ! /* as long as no error was returned from file_parse_string ! * we can just do a file_get_var_name() safely. */ ! if(string_matches(dhcp_options_strings[i], varfile_get_name(varfile))) { ! cc->options[i] = 1; ! match = 1; ! break; ! } ! } ! ! if(match != 1) ! WARN_MESSAGE("encountered illegal DHCP option in %s: %s : %d", fname, ! varfile_get_name(varfile), varfile_get_lineno(varfile)); ! break; case VARFILE_EOF: *************** *** 166,172 **** case VARFILE_PARSE_ERROR: ! ERROR_MESSAGE("parse error in opts file: %s : %d", varfile_get_filename(varfile), varfile_get_lineno(varfile)); ! return -1; default: --- 165,171 ---- case VARFILE_PARSE_ERROR: ! ERROR_MESSAGE("parse error in opts file: %s : %d", varfile_get_filename(varfile), varfile_get_lineno(varfile)); ! return -1; default: *************** *** 179,190 **** 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); --- 178,190 ---- 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); *************** *** 201,205 **** int load_client_conf(client_conf_t *cc) { ! char *fname; int retval; --- 201,205 ---- int load_client_conf(client_conf_t *cc) { ! char *fname; int retval; *************** *** 210,217 **** /* 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); } --- 210,217 ---- /* 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-conf.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-conf.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-client-conf.h 10 Nov 2002 15:46:40 -0000 1.1 --- dhcp-client-conf.h 16 Nov 2002 00:23:42 -0000 1.2 *************** *** 30,35 **** typedef struct { char *conf_file; ! const char *interface; /* points to dhcp_client_control->interface */ ! /* specific configurations */ --- 30,35 ---- typedef struct { char *conf_file; ! const char *interface; /* points to dhcp_client_control->interface */ ! /* specific configurations */ *************** *** 41,43 **** extern int load_client_conf(client_conf_t *cc); ! #endif /* DHCP_CLIENT_CONF_H */ --- 41,43 ---- extern int load_client_conf(client_conf_t *cc); ! #endif /* DHCP_CLIENT_CONF_H */ Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-client-control.c 15 Nov 2002 21:19:35 -0000 1.3 --- dhcp-client-control.c 16 Nov 2002 00:23:42 -0000 1.4 *************** *** 69,72 **** --- 69,73 ---- 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) *************** *** 78,87 **** *s = DLT_EN10MB; s++; ! if(hex_string_to_value(mac_string, mac_add)) { ERROR_MESSAGE("malformed mac string %s", mac_string); return NULL; } ! memcpy(s, mac_add, ETH_ADDR_LEN); s--; --- 79,88 ---- *s = DLT_EN10MB; s++; ! if(hex_string_to_value(mac_string, mac_add)) { ERROR_MESSAGE("malformed mac string %s", mac_string); return NULL; } ! memcpy(s, mac_add, ETH_ADDR_LEN); s--; *************** *** 94,98 **** { unsigned char *s; ! s = xmalloc(1 + ETH_ADDR_LEN); *s = DLT_EN10MB; --- 95,99 ---- { unsigned char *s; ! s = xmalloc(1 + ETH_ADDR_LEN); *s = DLT_EN10MB; *************** *** 100,104 **** memcpy(s, interface_address.data, ETH_ADDR_LEN); s--; ! return s; } --- 101,105 ---- memcpy(s, interface_address.data, ETH_ADDR_LEN); s--; ! return s; } *************** *** 108,116 **** { dhcp_client_control_t *dc; ! dc = xmalloc(sizeof(dhcp_client_control_t)); memset(dc, 0, sizeof(dhcp_client_control_t)); dc->interface = xstrdup(interface); ! return dc; } --- 109,117 ---- { dhcp_client_control_t *dc; ! dc = xmalloc(sizeof(dhcp_client_control_t)); memset(dc, 0, sizeof(dhcp_client_control_t)); dc->interface = xstrdup(interface); ! return dc; } *************** *** 132,139 **** #ifdef HAVE_UNAME struct utsname utsname; ! #endif /* HAVE_UNAME */ dc = xcalloc(sizeof(dhcp_client_control_t)); ! dc->state = 0; dc->interface = xstrdup(interface); --- 133,140 ---- #ifdef HAVE_UNAME struct utsname utsname; ! #endif /* HAVE_UNAME */ dc = xcalloc(sizeof(dhcp_client_control_t)); ! dc->state = 0; dc->interface = xstrdup(interface); *************** *** 148,152 **** } ! if(load_client_cache(dc->cache, 0) < 0) { ERROR_MESSAGE("could not read client cache."); destroy_dhcp_client_control(dc); --- 149,153 ---- } ! if(load_client_cache(dc->cache, 0) < 0) { ERROR_MESSAGE("could not read client cache."); destroy_dhcp_client_control(dc); *************** *** 161,168 **** dport = ntohs(dport); sport = ntohs(sport); - - if(dport == -1 || sport == -1) { ! WARN_MESSAGE("could not lookup dhcp services in service db (%s) will use reasonable defaults."); sport = BOOTP_CLIENT; --- 162,170 ---- dport = ntohs(dport); sport = ntohs(sport); ! if(dport == -1 || sport == -1) { ! ! WARN_MESSAGE ! ("could not lookup dhcp services in service db (%s) will use reasonable defaults."); sport = BOOTP_CLIENT; *************** *** 176,180 **** 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); --- 178,184 ---- 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); *************** *** 185,192 **** /* Additional fields. */ ! /* xid setting */ dhcp_client_update_xid(dc); ! /* secs settings. */ dhcp_client_reset_secs(dc); --- 189,196 ---- /* Additional fields. */ ! /* xid setting */ dhcp_client_update_xid(dc); ! /* secs settings. */ dhcp_client_reset_secs(dc); *************** *** 198,207 **** #ifdef HAVE_UNAME uname(&utsname); ! dc->class_id = splice_many_strings(4, utsname.sysname, utsname.nodename, utsname.release, utsname.version, utsname.machine); ! #else /* HAVE_UNAME */ dc->class_id = xstrdup("Unknown"); ! #endif /* HAVE_UNAME */ ! if(rawnet_get_hw_addr(dc->rawnet, &interface_addr)) { ERROR_MESSAGE("could not acquire interface address."); return NULL; --- 202,213 ---- #ifdef HAVE_UNAME uname(&utsname); ! dc->class_id = ! splice_many_strings(4, utsname.sysname, utsname.nodename, utsname.release, utsname.version, ! utsname.machine); ! #else /* HAVE_UNAME */ dc->class_id = xstrdup("Unknown"); ! #endif /* HAVE_UNAME */ ! if(rawnet_get_hw_addr(dc->rawnet, &interface_addr)) { ERROR_MESSAGE("could not acquire interface address."); return NULL; *************** *** 218,226 **** { char *new_client_id = create_fake_client_id(fake_hw_addr); ! if(dc->client_id != NULL) ! xfree(dc->client_id); dc->client_id = new_client_id; ! rawnet_use_fake_hw_addr(dc->rawnet, fake_hw_addr); return; --- 224,232 ---- { char *new_client_id = create_fake_client_id(fake_hw_addr); ! if(dc->client_id != NULL) ! xfree(dc->client_id); dc->client_id = new_client_id; ! rawnet_use_fake_hw_addr(dc->rawnet, fake_hw_addr); return; *************** *** 235,240 **** if(dc->cache) client_cache_destroy(dc->cache); ! ! if(dc->conf) client_conf_destroy(dc->conf); --- 241,246 ---- if(dc->cache) client_cache_destroy(dc->cache); ! ! if(dc->conf) client_conf_destroy(dc->conf); *************** *** 247,251 **** if(dc->class_id) xfree(dc->class_id); ! if(dc->client_id) xfree(dc->client_id); --- 253,257 ---- if(dc->class_id) xfree(dc->class_id); ! if(dc->client_id) xfree(dc->client_id); Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-client-states.c 15 Nov 2002 21:06:47 -0000 1.3 --- dhcp-client-states.c 16 Nov 2002 00:23:42 -0000 1.4 *************** *** 53,57 **** option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1)); options = add_to_list(options, option); ! /* dhcp message type. */ option = dhcp_build_message_type(DHCP_RELEASE_TM); --- 53,57 ---- option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1)); options = add_to_list(options, option); ! /* dhcp message type. */ option = dhcp_build_message_type(DHCP_RELEASE_TM); *************** *** 69,83 **** char *hostname; ! if(opts != NULL) { /* parameter_request_list */ ! option = dhcp_build_parameter_request_list_option(opts); options = add_to_list(options, option); ! } ! /* dhcp max DHCP message size: * should go into globconf. */ option = dhcp_build_max_message_size_option(MAX_MESSAGE_SIZE); options = add_to_list(options, option); ! /* client_id */ option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1)); --- 69,83 ---- char *hostname; ! if(opts != NULL) { /* parameter_request_list */ ! option = dhcp_build_parameter_request_list_option(opts); options = add_to_list(options, option); ! } ! /* dhcp max DHCP message size: * should go into globconf. */ option = dhcp_build_max_message_size_option(MAX_MESSAGE_SIZE); options = add_to_list(options, option); ! /* client_id */ option = dhcp_build_client_id(dc->client_id, (ETH_ADDR_LEN + 1)); *************** *** 90,94 **** /* hostname if available */ hostname = glob_conf_get_val(CLIENT_HOSTNAME); ! if(hostname != NULL) { /* if we have one set it. */ option = dhcp_build_hostname(hostname); --- 90,94 ---- /* hostname if available */ hostname = glob_conf_get_val(CLIENT_HOSTNAME); ! if(hostname != NULL) { /* if we have one set it. */ option = dhcp_build_hostname(hostname); *************** *** 145,154 **** if(string_matches(policy, "exact")) ! return(dhcp_have_exact_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); else if(string_matches(policy, "atleast")) ! return(dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); ! else /* bad policy : warn and use atleast */ { WARN_MESSAGE("%s : set to bad value %s : going to use \"atleast\""); ! return(dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); } --- 145,155 ---- if(string_matches(policy, "exact")) ! return (dhcp_have_exact_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); else if(string_matches(policy, "atleast")) ! return (dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); ! else { /* bad policy : warn and use atleast */ ! WARN_MESSAGE("%s : set to bad value %s : going to use \"atleast\""); ! return (dhcp_have_atleast_requested_options(dc->rawnet->dhcp_p, dc->conf->options)); } *************** *** 167,172 **** if((!rawnet_is_valid(dc->rawnet)) || ! dc->rawnet->type != RAWNET_DHCP || ! (dhcp_get_xid(dc->rawnet->dhcp_p) != dc->xid)) return 0; --- 168,172 ---- if((!rawnet_is_valid(dc->rawnet)) || ! dc->rawnet->type != RAWNET_DHCP || (dhcp_get_xid(dc->rawnet->dhcp_p) != dc->xid)) return 0; *************** *** 184,194 **** if(client_check_dhcp(dc) && - /* check that the type is an offer. */ - dhcp_is_type(dc->rawnet->dhcp_p, DHCP_OFFER_TM) && - /* check if the requested options match what we want. */ - client_check_requested_options(dc)) return 1; --- 184,190 ---- *************** *** 281,285 **** options = client_build_discover_option_list(dc->conf->options, dc); ! /* when we begin transmitting discover_offer we setup our secs field. * this is because relay agents and dhcp servers use this to see how --- 277,281 ---- options = client_build_discover_option_list(dc->conf->options, dc); ! /* when we begin transmitting discover_offer we setup our secs field. * this is because relay agents and dhcp servers use this to see how *************** *** 289,293 **** dhcp_client_update_secs(dc); ! /* update new xid per start of discovery .*/ dhcp_client_update_xid(dc); --- 285,289 ---- dhcp_client_update_secs(dc); ! /* update new xid per start of discovery . */ dhcp_client_update_xid(dc); *************** *** 300,342 **** client_check_discover, RECOMMENDED_MAX_SECS_WAIT); ! switch(retval) { ! case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeout on DHCP discover."); ! return STATE_FATAL_ERROR; ! case RAWNET_OK: ! break; ! case RAWNET_ERROR: ! ERROR_MESSAGE("received error from raw network handler."); ! return STATE_FATAL_ERROR; ! default: ! FATAL_MESSAGE("invalid return value from raw network handler -- this a bug report it."); } /* Check for two options before inserting them ourselves. * The server may have decided to be nice to us. */ ! if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_REQUESTED_IP_ADDRESS)) ! dc->rawnet->dhcp_p->options = ! add_to_list(dc->rawnet->dhcp_p->options, ! dhcp_build_requested_ip_address(dhcp_get_yiaddr(dc->rawnet->dhcp_p))); ! if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_SERVER_IDENTIFIER)) ! dc->rawnet->dhcp_p->options = ! add_to_list(dc->rawnet->dhcp_p->options, ! dhcp_build_server_identifier(dhcp_get_siaddr(dc->rawnet->dhcp_p))); /* dump cache file. */ ! if(client_cache_dump_options(dc->cache, dc->rawnet->dhcp_p->options)) { ERROR_MESSAGE("could not create temporary cache."); return STATE_FATAL_ERROR; } ! client_cache_update(dc->cache); ! return STATE_REQUEST_ACK; } --- 296,338 ---- client_check_discover, RECOMMENDED_MAX_SECS_WAIT); ! switch (retval) { ! case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeout on DHCP discover."); ! return STATE_FATAL_ERROR; ! case RAWNET_OK: ! break; ! case RAWNET_ERROR: ! ERROR_MESSAGE("received error from raw network handler."); ! return STATE_FATAL_ERROR; ! default: ! FATAL_MESSAGE("invalid return value from raw network handler -- this a bug report it."); } /* Check for two options before inserting them ourselves. * The server may have decided to be nice to us. */ ! if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_REQUESTED_IP_ADDRESS)) ! dc->rawnet->dhcp_p->options = ! add_to_list(dc->rawnet->dhcp_p->options, ! dhcp_build_requested_ip_address(dhcp_get_yiaddr(dc->rawnet->dhcp_p))); ! if(!dhcp_have_option(dc->rawnet->dhcp_p, TAG_DHCP_SERVER_IDENTIFIER)) ! dc->rawnet->dhcp_p->options = ! add_to_list(dc->rawnet->dhcp_p->options, ! dhcp_build_server_identifier(dhcp_get_siaddr(dc->rawnet->dhcp_p))); /* dump cache file. */ ! if(client_cache_dump_options(dc->cache, dc->rawnet->dhcp_p->options)) { ERROR_MESSAGE("could not create temporary cache."); return STATE_FATAL_ERROR; } ! client_cache_update(dc->cache); ! return STATE_REQUEST_ACK; } *************** *** 349,385 **** /* Build options along with the options in our cache. */ ! options = client_build_request_option_list(NULL, dc); cache_options = client_cache_load_option_network_list(dc->cache, 0); ! if(cache_options == NULL) { ERROR_MESSAGE("could not load cache."); return STATE_FATAL_ERROR; } ! options = join_lists(options, cache_options); /* Our options cleared by build_* since they are passed * down and later purged. */ ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, options); ! retval = rawnet_packet_transact(dc->rawnet, dc, NULL, client_check_request, RECOMMENDED_MAX_SECS_WAIT); ! switch(retval) { ! case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeout on DHCP discover."); ! return STATE_FATAL_ERROR; ! case RAWNET_OK: ! break; ! case RAWNET_ERROR: ! ERROR_MESSAGE("received error from raw network handler."); ! return STATE_FATAL_ERROR; ! default: ! FATAL_MESSAGE("dhcp-client-states: invalid return value from raw network handler -- this a bug report it."); } --- 345,384 ---- /* Build options along with the options in our cache. */ ! options = client_build_request_option_list(NULL, dc); cache_options = client_cache_load_option_network_list(dc->cache, 0); ! if(cache_options == NULL) { ERROR_MESSAGE("could not load cache."); return STATE_FATAL_ERROR; } ! options = join_lists(options, cache_options); /* Our options cleared by build_* since they are passed * down and later purged. */ ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, options); ! retval = ! rawnet_packet_transact(dc->rawnet, dc, NULL, client_check_request, ! RECOMMENDED_MAX_SECS_WAIT); ! switch (retval) { ! case RAWNET_TIMEOUT: ! ERROR_MESSAGE("timeout on DHCP discover."); ! return STATE_FATAL_ERROR; ! case RAWNET_OK: ! break; ! case RAWNET_ERROR: ! ERROR_MESSAGE("received error from raw network handler."); ! return STATE_FATAL_ERROR; ! default: ! FATAL_MESSAGE ! ("dhcp-client-states: invalid return value from raw network handler -- this a bug report it."); } *************** *** 408,413 **** build_dhcp_release(dc->rawnet, dc->xid, options, dc->sip_addr, dc->shw_addr); ! ! if(rawnet_send_packet(dc->rawnet) < 0) { ERROR_MESSAGE("could not send release."); return STATE_FATAL_ERROR; --- 407,412 ---- build_dhcp_release(dc->rawnet, dc->xid, options, dc->sip_addr, dc->shw_addr); ! ! if(rawnet_send_packet(dc->rawnet) < 0) { ERROR_MESSAGE("could not send release."); return STATE_FATAL_ERROR; *************** *** 425,433 **** /* since we're releasing the lease we should down the interface */ dhcp_client_interface_down(dc); ! /* called from do_shutdown() so no real state returned. * however if we do take the return value into consideration * we should handle it as an error. */ ! return STATE_FATAL_ERROR; } --- 424,432 ---- /* since we're releasing the lease we should down the interface */ dhcp_client_interface_down(dc); ! /* called from do_shutdown() so no real state returned. * however if we do take the return value into consideration * we should handle it as an error. */ ! return STATE_FATAL_ERROR; } *************** *** 438,442 **** options = client_cache_load_option_string_list(dc->cache, 0); ! if(options == NULL) { ERROR_MESSAGE("received empty configuration cache! cannot configure host"); return STATE_FATAL_ERROR; --- 437,441 ---- options = client_cache_load_option_string_list(dc->cache, 0); ! if(options == NULL) { ERROR_MESSAGE("received empty configuration cache! cannot configure host"); return STATE_FATAL_ERROR; *************** *** 470,481 **** if(timer_set_next(dc->timer)) { ! FATAL_MESSAGE("no timers set. we should have at least one for lease expiry sent to us from the server."); } /* wait for any interrupts. */ suspend_for_interrupts(); ! rawnet_up(dc->rawnet); ! /* Update our DHCP secs datum since we're renewing after this. */ --- 469,481 ---- if(timer_set_next(dc->timer)) { ! FATAL_MESSAGE ! ("no timers set. we should have at least one for lease expiry sent to us from the server."); } /* wait for any interrupts. */ suspend_for_interrupts(); ! rawnet_up(dc->rawnet); ! /* Update our DHCP secs datum since we're renewing after this. */ *************** *** 506,510 **** /* load what we can from the cache. */ ! cached_options = client_cache_load_option_string_list(dc->cache, 0); if(cached_options != NULL) do_sysconf_cleanup(cached_options, dc); --- 506,510 ---- /* load what we can from the cache. */ ! cached_options = client_cache_load_option_string_list(dc->cache, 0); if(cached_options != NULL) do_sysconf_cleanup(cached_options, dc); Index: dhcp-client.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-client.c 15 Nov 2002 21:19:35 -0000 1.4 --- dhcp-client.c 16 Nov 2002 00:23:42 -0000 1.5 *************** *** 52,60 **** /* table of functions indexed by command codes. */ client_command commands[] = { ! do_version, /* print out version information. */ ! do_kill_client, /* kill client. */ ! do_wake_client, /* wake client. */ ! do_clear_cache, /* clear cache. */ ! do_client, /* initialize and run client. */ }; --- 52,60 ---- /* table of functions indexed by command codes. */ client_command commands[] = { ! do_version, /* print out version information. */ ! do_kill_client, /* kill client. */ ! do_wake_client, /* wake client. */ ! do_clear_cache, /* clear cache. */ ! do_client, /* initialize and run client. */ }; *************** *** 69,77 **** interface_lister get_interface[] = { ! NULL, /* version output needs nothing. */ ! interface_get_active, /* kill client. */ ! interface_get_active, /* wake client. */ ! interface_get_active, /* clear cache. */ ! interface_get_inactive, /* run client. */ }; --- 69,77 ---- interface_lister get_interface[] = { ! NULL, /* version output needs nothing. */ ! interface_get_active, /* kill client. */ ! interface_get_active, /* wake client. */ ! interface_get_active, /* clear cache. */ ! interface_get_inactive, /* run client. */ }; *************** *** 87,104 **** }; ! /* global vars affecting other code. */ ! int interactive = 1; /* by default we begin interactive (messages on stdout/stderr). */ char *work_dir = CLIENT_WORK_DIR; /* our default working directory */ #if !defined(HAVE_PROGNAME) const char *__progname; ! #endif /* HAVE_PROGNAME */ /* local vars for dhcpclient. */ ! static char *interface = NULL; /* the interface we're concerned with. */ static unsigned char want_background = 1; /* whether we should go into the background. */ ! static char *fake_hw_addr = NULL; /* if using fake hardware address set here. */ ! static int promiscuous = 0; /* whether or not we're running in promiscious mode. */ /* Utility routines. */ --- 87,104 ---- }; ! /* global vars affecting other code. */ ! int interactive = 1; /* by default we begin interactive (messages on stdout/stderr). */ char *work_dir = CLIENT_WORK_DIR; /* our default working directory */ #if !defined(HAVE_PROGNAME) const char *__progname; ! #endif /* HAVE_PROGNAME */ /* local vars for dhcpclient. */ ! static char *interface = NULL; /* the interface we're concerned with. */ static unsigned char want_background = 1; /* whether we should go into the background. */ ! static char *fake_hw_addr = NULL; /* if using fake hardware address set here. */ ! static int promiscuous = 0; /* whether or not we're running in promiscious mode. */ /* Utility routines. */ *************** *** 113,117 **** if(init_glob_conf(stringbuffer_getstring(sb))) { ! FATAL_MESSAGE("could not read nor create global configuration file: %s", stringbuffer_getstring(sb)); } --- 113,118 ---- if(init_glob_conf(stringbuffer_getstring(sb))) { ! FATAL_MESSAGE("could not read nor create global configuration file: %s", ! stringbuffer_getstring(sb)); } *************** *** 123,127 **** static int initialize_client_state(dhcp_client_control_t *dc) { ! if(client_cache_is_empty(dc->cache)) { return STATE_DISCOVER_OFFER; } else /* if not empty we assume we can request the options. */ --- 124,128 ---- static int initialize_client_state(dhcp_client_control_t *dc) { ! if(client_cache_is_empty(dc->cache)) { return STATE_DISCOVER_OFFER; } else /* if not empty we assume we can request the options. */ *************** *** 149,154 **** pid_t pid; ! if(!get_pid_file(interface, &pid)) ! return 0; /* no pid file -- therefore no process. */ #if !defined(KILL_SIGNAL_DETECT) --- 150,155 ---- pid_t pid; ! if(!get_pid_file(interface, &pid)) ! return 0; /* no pid file -- therefore no process. */ #if !defined(KILL_SIGNAL_DETECT) *************** *** 156,169 **** /* if we can't detect it assume it is up since the PID file exists :| * issue warning though. */ ! WARN_MESSAGE("%s PID file exists please delete and kill process.", getprogname()); ! return 0; #else ! if(!kill(pid, 0)) ! return 1; ! else { ! delete_pid_file(interface); ! return 0; ! } #endif --- 157,170 ---- /* if we can't detect it assume it is up since the PID file exists :| * issue warning though. */ ! WARN_MESSAGE("%s PID file exists please delete and kill process.", getprogname()); ! return... [truncated message content] |