[dhcp-agent-commits] dhcp-agent/src dhcp-librawnet.h,1.16,1.17 dhcp-client-states.c,1.36,1.37 dhcp-p
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2003-06-25 01:54:17
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv13884/src Modified Files: dhcp-librawnet.h dhcp-client-states.c dhcp-packet-build.c dhcp-rawnet.c Log Message: corrected rebind/renew problem with ciaddr Index: dhcp-librawnet.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dhcp-librawnet.h 17 Jun 2003 07:34:16 -0000 1.16 --- dhcp-librawnet.h 25 Jun 2003 01:54:14 -0000 1.17 *************** *** 369,373 **** extern int rawnet_get_hw_addr(rawnet_t *net, eth_addr_t *addr); extern int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr); ! extern int rawnet_get_ip_addr(rawnet_t *net, ip_addr_t *addr); extern int rawnet_send_packet(rawnet_t *net); extern int rawnet_use_fake_hw_addr(rawnet_t *raw, char *mac_string); --- 369,373 ---- extern int rawnet_get_hw_addr(rawnet_t *net, eth_addr_t *addr); extern int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr); ! extern ip_addr_t rawnet_get_ip_addr(rawnet_t *net); extern int rawnet_send_packet(rawnet_t *net); extern int rawnet_use_fake_hw_addr(rawnet_t *raw, char *mac_string); *************** *** 397,405 **** /* dhcp packet routines. */ extern void build_dhcp_discover(rawnet_t *net, uint32_t xid, time_t secs, list_t *options); ! extern void build_dhcp_request_unicast(rawnet_t *net, uint32_t xid, time_t secs, list_t *options, ! ip_addr_t sip_addr, eth_addr_t shw_addr); ! extern void build_dhcp_request_broadcast(rawnet_t *net, uint32_t xid, time_t secs, ip_addr_t cip_addr, ip_addr_t sip_addr, list_t *options); ! extern void build_dhcp_release(rawnet_t *net, uint32_t xid, list_t *options, ip_addr_t sip_addr, ! eth_addr_t shw_addr); /* arp packet routines. */ --- 397,406 ---- /* dhcp packet routines. */ extern void build_dhcp_discover(rawnet_t *net, uint32_t xid, time_t secs, list_t *options); ! extern void build_dhcp_request_unicast(rawnet_t *net, uint32_t xid, time_t secs, list_t *options, ip_addr_t cip_addr, ! ip_addr_t sip_addr, ip_addr_t gip_addr, eth_addr_t shw_addr); ! extern void build_dhcp_request_broadcast(rawnet_t *net, uint32_t xid, time_t secs, ip_addr_t cip_addr, ! ip_addr_t sip_addr, list_t *options); ! extern void build_dhcp_release(rawnet_t *net, uint32_t xid, list_t *options, ip_addr_t cip_addr, ! ip_addr_t sip_addr, eth_addr_t shw_addr); /* arp packet routines. */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** dhcp-client-states.c 23 Jun 2003 06:05:03 -0000 1.36 --- dhcp-client-states.c 25 Jun 2003 01:54:14 -0000 1.37 *************** *** 193,197 **** eth_addr_t client_hw_addr; ! rawnet_get_ip_addr(dc->rawnet, &client_ip_addr); rawnet_get_real_hw_addr(dc->rawnet, &client_hw_addr); --- 193,197 ---- eth_addr_t client_hw_addr; ! client_ip_addr = rawnet_get_ip_addr(dc->rawnet); rawnet_get_real_hw_addr(dc->rawnet, &client_hw_addr); *************** *** 211,215 **** eth_addr_t client_hw_addr; ! rawnet_get_ip_addr(dc->rawnet, &client_ip_addr); rawnet_get_real_hw_addr(dc->rawnet, &client_hw_addr); --- 211,215 ---- eth_addr_t client_hw_addr; ! client_ip_addr = rawnet_get_ip_addr(dc->rawnet); rawnet_get_real_hw_addr(dc->rawnet, &client_hw_addr); *************** *** 320,327 **** dhcp_opt_destroy_option_list(options); ! /* get what our current IP address is. */ ! if(rawnet_get_ip_addr(dc->rawnet, &ip_addr)) { ! FATAL_MESSAGE("could not get ip address from interface."); ! } /* check if we have a real address or not. */ --- 320,324 ---- dhcp_opt_destroy_option_list(options); ! ip_addr = rawnet_get_ip_addr(dc->rawnet); /* check if we have a real address or not. */ *************** *** 360,366 **** * in our lease cache.*/ ! if(rawnet_get_ip_addr(dc->rawnet, &interface_ip)) { ! FATAL_MESSAGE("error retrieving our current IP address."); ! } list_rewind(options); --- 357,361 ---- * in our lease cache.*/ ! interface_ip = rawnet_get_ip_addr(dc->rawnet); list_rewind(options); *************** *** 786,794 **** list_t *options; int retval; INFO_MESSAGE("attempting DHCP REBIND"); options = client_build_rebind_option_list(dc); ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, 0, 0, options); retval = --- 781,792 ---- list_t *options; int retval; + ip_addr_t my_addr; INFO_MESSAGE("attempting DHCP REBIND"); + my_addr = rawnet_get_ip_addr(dc->rawnet); + options = client_build_rebind_option_list(dc); ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, my_addr, 0, options); retval = *************** *** 818,822 **** if(dhcp_is_type(dc->rawnet->dhcp_p, DHCP_DHCPACK_TM)) { ! /* our lease is OK. */ client_setup_timers(dc); return STATE_BOUND; --- 816,820 ---- if(dhcp_is_type(dc->rawnet->dhcp_p, DHCP_DHCPACK_TM)) { ! /* our lease is OK. reconfigure timers. */ client_setup_timers(dc); return STATE_BOUND; *************** *** 847,855 **** list_t *options; int retval; INFO_MESSAGE("attempting DHCP RENEW"); options = client_build_renew_option_list(dc); ! build_dhcp_request_unicast(dc->rawnet, dc->xid, dc->secs, options, dc->context->sip_addr, dc->context->shw_addr); /* find out how much time we have until the next timer. --- 845,859 ---- list_t *options; int retval; + ip_addr_t my_addr; INFO_MESSAGE("attempting DHCP RENEW"); + my_addr = rawnet_get_ip_addr(dc->rawnet); + options = client_build_renew_option_list(dc); ! build_dhcp_request_unicast(dc->rawnet, dc->xid, dc->secs, options, my_addr, ! dhcp_client_get_server_ip_address(dc), ! 0, ! dhcp_client_get_server_hw_address(dc)); /* find out how much time we have until the next timer. *************** *** 884,888 **** if(dhcp_is_type(dc->rawnet->dhcp_p, DHCP_DHCPACK_TM)) { ! /* our lease is OK. run reconfigure in case some values changed. */ client_setup_timers(dc); return STATE_BOUND; --- 888,892 ---- if(dhcp_is_type(dc->rawnet->dhcp_p, DHCP_DHCPACK_TM)) { ! /* our lease is OK. reconfigure timers. */ client_setup_timers(dc); return STATE_BOUND; *************** *** 996,1005 **** { list_t *options; INFO_MESSAGE("sending DHCP RELEASE"); options = client_build_release_option_list(dc); ! build_dhcp_release(dc->rawnet, dc->xid, options, dc->context->sip_addr, dc->context->shw_addr); if(rawnet_send_packet(dc->rawnet) < 0) { --- 1000,1014 ---- { list_t *options; + ip_addr_t my_addr; INFO_MESSAGE("sending DHCP RELEASE"); + my_addr = rawnet_get_ip_addr(dc->rawnet); + options = client_build_release_option_list(dc); ! build_dhcp_release(dc->rawnet, dc->xid, options, my_addr, ! dhcp_client_get_server_ip_address(dc), ! dhcp_client_get_server_hw_address(dc)); if(rawnet_send_packet(dc->rawnet) < 0) { Index: dhcp-packet-build.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-packet-build.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-packet-build.c 8 Jun 2003 22:42:45 -0000 1.6 --- dhcp-packet-build.c 25 Jun 2003 01:54:14 -0000 1.7 *************** *** 405,432 **** void build_dhcp_discover(rawnet_t *net, uint32_t xid, time_t secs, list_t *options) { ! build_dhcp(net, xid, secs, 0, 0, 0, 0, (ip_addr_t)0, eth_null, 1, options, DHCP_BOOTP_REQUEST); } /* Create dhcp request message: unicast */ ! void build_dhcp_request_unicast(rawnet_t *net, uint32_t xid, time_t secs, list_t *options, ! ip_addr_t sip_addr, eth_addr_t shw_addr) { ! build_dhcp(net, xid, secs, net->cip_addr, 0, 0, 0, sip_addr, shw_addr, 0, options, ! DHCP_BOOTP_REQUEST); } /* Create dhcp request message: broadcast */ ! void build_dhcp_request_broadcast(rawnet_t *net, uint32_t xid, time_t secs, ip_addr_t cip_addr, ip_addr_t sip_addr, list_t *options) { ! build_dhcp(net, xid, secs, 0, cip_addr, sip_addr, 0, (ip_addr_t)0, eth_null, 1, options, ! DHCP_BOOTP_REQUEST); } /* Create dhcp release message. */ ! void build_dhcp_release(rawnet_t *net, uint32_t xid, list_t *options, ip_addr_t sip_addr, ! eth_addr_t shw_addr) { ! build_dhcp(net, xid, 0, net->cip_addr, 0, 0, 0, ! sip_addr, shw_addr, 1, options, DHCP_BOOTP_REQUEST); } --- 405,430 ---- void build_dhcp_discover(rawnet_t *net, uint32_t xid, time_t secs, list_t *options) { ! build_dhcp(net, xid, secs, 0, 0, 0, 0, 0, eth_null, 1, options, DHCP_BOOTP_REQUEST); } /* Create dhcp request message: unicast */ ! void build_dhcp_request_unicast(rawnet_t *net, uint32_t xid, time_t secs, list_t *options, ip_addr_t cip_addr, ! ip_addr_t sip_addr, ip_addr_t gip_addr, eth_addr_t shw_addr) { ! build_dhcp(net, xid, secs, cip_addr, 0, sip_addr, gip_addr, sip_addr, shw_addr, ! 0, options, DHCP_BOOTP_REQUEST); } /* Create dhcp request message: broadcast */ ! void build_dhcp_request_broadcast(rawnet_t *net, uint32_t xid, time_t secs, ip_addr_t cip_addr, ! ip_addr_t sip_addr, list_t *options) { ! build_dhcp(net, xid, secs, cip_addr, 0, sip_addr, 0, ip_addr_broadcast, eth_broadcast, 0, options, DHCP_BOOTP_REQUEST); } /* Create dhcp release message. */ ! void build_dhcp_release(rawnet_t *net, uint32_t xid, list_t *options, ip_addr_t cip_addr, ip_addr_t sip_addr, eth_addr_t shw_addr) { ! build_dhcp(net, xid, 0, cip_addr, 0, sip_addr, 0, sip_addr, shw_addr, 0, options, DHCP_BOOTP_REQUEST); } Index: dhcp-rawnet.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-rawnet.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-rawnet.c 9 Jun 2003 02:04:48 -0000 1.9 --- dhcp-rawnet.c 25 Jun 2003 01:54:14 -0000 1.10 *************** *** 39,45 **** /* get IP address. */ ! int rawnet_get_ip_addr(rawnet_t *net, ip_addr_t *addr) { ! return (interface_get_ip_addr(net->intf_handle, addr)); } --- 39,45 ---- /* get IP address. */ ! ip_addr_t rawnet_get_ip_addr(rawnet_t *net) { ! return net->cip_addr; } *************** *** 81,88 **** /* are we using a fake address? */ if(net->fake_hw_addr != NULL) { ! memcpy(addr, net->fake_hw_addr->data, ETH_ADDR_LEN); return 0; } else { ! return (eth_get(net->eth, addr)); } } --- 81,89 ---- /* are we using a fake address? */ if(net->fake_hw_addr != NULL) { ! memcpy(addr, &net->fake_hw_addr, ETH_ADDR_LEN); return 0; } else { ! memcpy(addr, &net->chw_addr, ETH_ADDR_LEN); ! return 0; } } *************** *** 103,108 **** } ! /* now set our address, whether we set it earlier or not. */ ! rawnet_get_ip_addr(net, &net->cip_addr); xfree(net->packet_data); --- 104,108 ---- } ! interface_get_ip_addr(net->intf_handle, &net->cip_addr); xfree(net->packet_data); *************** *** 282,291 **** } ! /* When we first initialize we use a real hardware ! * address. This can be changed later to a fake hardware ! * address if the system supports it. */ ! rawnet_get_hw_addr(net, &net->chw_addr); ! rawnet_get_ip_addr(net, &net->cip_addr); /* Packet handler objects. --- 282,289 ---- } ! /* store a copy of our hardware and ip address. */ ! eth_get(net->eth, &net->chw_addr); ! interface_get_ip_addr(net->intf_handle, &net->cip_addr); /* Packet handler objects. |