[dhcp-agent-commits] dhcp-agent/src dhcp-client-control.c,1.11,1.12 dhcp-client-states.c,1.19,1.20 d
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv9562 Modified Files: dhcp-client-control.c dhcp-client-states.c dhcp-client.h dhcp-eth.c dhcp-interface.c dhcp-interface.h dhcp-ip.c dhcp-print.c dhcp-rawnet.c Log Message: now force clearing the ip address on the interface -- dhcp-sniff is thus broken Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-control.c 24 Dec 2002 03:03:28 -0000 1.11 --- dhcp-client-control.c 27 Dec 2002 02:53:45 -0000 1.12 *************** *** 289,298 **** /* get the server address. */ ! ip_addr_t dhcp_client_get_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr) { return dc->sip_addr; } ! eth_addr_t dhcp_client_get_server_hw_address(dhcp_client_control_t *dc, eth_addr_t eth_addr) { return dc->shw_addr; --- 289,298 ---- /* get the server address. */ ! ip_addr_t dhcp_client_get_server_ip_address(dhcp_client_control_t *dc) { return dc->sip_addr; } ! eth_addr_t dhcp_client_get_server_hw_address(dhcp_client_control_t *dc) { return dc->shw_addr; Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** dhcp-client-states.c 24 Dec 2002 03:03:28 -0000 1.19 --- dhcp-client-states.c 27 Dec 2002 02:53:45 -0000 1.20 *************** *** 176,185 **** /* get the mac address, and ip address from the packet. */ ! ip_addr = ip_get_source_addr(dc->rawnet->ip_p); ! eth_addr = eth_get_src_address(dc->rawnet->ether_p); ! ! /* make the strings of the addresses. */ ! eth_addr_string = eth_addr_to_string(eth_addr); ! ip_addr_string = ip_addr_to_string(ip_addr); /* build our received options array. */ --- 176,181 ---- /* get the mac address, and ip address from the packet. */ ! ip_addr = ip_get_src_addr(dc->rawnet->ip_p); ! eth_addr = eth_get_src_addr(dc->rawnet->ether_p); /* build our received options array. */ *************** *** 206,209 **** --- 202,210 ---- if(required_options[i] && !received_options[i]) { + + /* make the strings of the addresses. */ + eth_addr_string = eth_addr_to_string(eth_addr); + ip_addr_string = ip_addr_to_string(ip_addr); + WARN_MESSAGE("ignoring offer from server (%s : %s) : failed to supply required option: %s", ip_addr_string, eth_addr_string, dhcp_option_printable_string_get(i)); *************** *** 216,221 **** } - xfree(ip_addr_string); - xfree(eth_addr_string); return 1; } --- 217,220 ---- *************** *** 410,418 **** INFO_MESSAGE("attempting DHCP DISCOVER"); options = client_build_discover_option_list(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 ! * bad off we are. */ dhcp_client_reset_secs(dc); --- 409,418 ---- INFO_MESSAGE("attempting DHCP DISCOVER"); + /* build discovery option list. */ options = client_build_discover_option_list(dc); ! /* when we begin transmitting discover_offer we setup our ! * secs field. this is because relay agents and dhcp servers ! * can use this to see how bad off we are. */ dhcp_client_reset_secs(dc); *************** *** 448,451 **** --- 448,458 ---- } + /* get the actual physical addresses of whoever gave us this + * information. we don't really need to make any assumptions + * here since we could be talking to a relay agent. */ + + dhcp_client_set_server_ip_address(dc, ip_get_src_addr(dc->rawnet->ip_p)); + dhcp_client_set_server_hw_address(dc, eth_get_src_addr(dc->rawnet->ether_p)); + /* Check for two options before inserting them ourselves. * The server may have decided to be nice to us. */ *************** *** 495,499 **** * down and later purged. */ ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, options); retval = --- 502,506 ---- * down and later purged. */ ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, 0, 0, options); retval = *************** *** 524,529 **** /* save hardware and ip address of server. we need these later. */ ! dhcp_client_set_server_ip_address(dc, ip_get_source_addr(dc->rawnet->ip_p)); ! dhcp_client_set_server_hw_address(dc, eth_get_src_address(dc->rawnet->ether_p)); return STATE_SETUP; --- 531,536 ---- /* save hardware and ip address of server. we need these later. */ ! dhcp_client_set_server_ip_address(dc, ip_get_src_addr(dc->rawnet->ip_p)); ! dhcp_client_set_server_hw_address(dc, eth_get_src_addr(dc->rawnet->ether_p)); return STATE_SETUP; *************** *** 761,765 **** options = client_build_rebind_option_list(dc); ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, options); retval = --- 768,772 ---- options = client_build_rebind_option_list(dc); ! build_dhcp_request_broadcast(dc->rawnet, dc->xid, dc->secs, 0, 0, options); retval = *************** *** 789,794 **** /* since we did a rebind our server's ip address and mac address may be different. */ ! dhcp_client_set_server_ip_address(dc, ip_get_source_addr(dc->rawnet->ip_p)); ! dhcp_client_set_server_hw_address(dc, eth_get_src_address(dc->rawnet->ether_p)); } --- 796,801 ---- /* since we did a rebind our server's ip address and mac address may be different. */ ! dhcp_client_set_server_ip_address(dc, ip_get_src_addr(dc->rawnet->ip_p)); ! dhcp_client_set_server_hw_address(dc, eth_get_src_addr(dc->rawnet->ether_p)); } Index: dhcp-client.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-client.h 24 Dec 2002 03:03:29 -0000 1.9 --- dhcp-client.h 27 Dec 2002 02:53:45 -0000 1.10 *************** *** 46,51 **** int discover_offer_retries; /* counter for retries on discover_offer */ ! ip_addr_t sip_addr; /* server's ip address. */ ! eth_addr_t shw_addr; /* server's hardware address. */ uint16_t server_port; /* port to expect UDP packets from. */ --- 46,60 ---- int discover_offer_retries; /* counter for retries on discover_offer */ ! /* use these for unicasting. */ ! ip_addr_t sip_addr; /* server or relay agent ip address */ ! eth_addr_t shw_addr; /* server or relay agent hardware address. */ ! ! /* use these when filling in dhcp headers. */ ! ip_addr_t yiaddr; /* our assigned ip address. */ ! ip_addr_t siaddr; /* server ip address. */ ! ip_addr_t giaddr; /* relay agent ip address. */ ! ip_addr_t ciaddr; /* client ip address. */ ! ! /* use this for validation purposes. */ uint16_t server_port; /* port to expect UDP packets from. */ *************** *** 105,110 **** --- 114,122 ---- extern void dhcp_client_interface_down(dhcp_client_control_t *dc); + extern void dhcp_client_set_server_ip_address(dhcp_client_control_t *dc, ip_addr_t ip_addr); extern void dhcp_client_set_server_hw_address(dhcp_client_control_t *dc, eth_addr_t eth_addr); + extern ip_addr_t dhcp_client_get_server_ip_address(dhcp_client_control_t *dc); + extern eth_addr_t dhcp_client_get_server_hw_address(dhcp_client_control_t *dc); #endif /* DHCP_CLIENT_H */ Index: dhcp-eth.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-eth.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-eth.c 16 Nov 2002 00:23:43 -0000 1.3 --- dhcp-eth.c 27 Dec 2002 02:53:45 -0000 1.4 *************** *** 48,57 **** } ! eth_addr_t eth_get_src_address(eth_obj * eth) { return (eth->header.eth_src); } ! eth_addr_t eth_get_dst_address(eth_obj * eth) { return (eth->header.eth_dst); --- 48,57 ---- } ! eth_addr_t eth_get_src_addr(eth_obj * eth) { return (eth->header.eth_src); } ! eth_addr_t eth_get_dst_addr(eth_obj * eth) { return (eth->header.eth_dst); *************** *** 63,67 **** } ! void eth_set_src_address(eth_obj * eth, eth_addr_t addr) { memcpy(ð->header.eth_src.data, &addr.data, ETH_ADDR_LEN); --- 63,67 ---- } ! void eth_set_src_addr(eth_obj * eth, eth_addr_t addr) { memcpy(ð->header.eth_src.data, &addr.data, ETH_ADDR_LEN); *************** *** 69,73 **** } ! void eth_set_dst_address(eth_obj * eth, eth_addr_t addr) { memcpy(ð->header.eth_dst.data, &addr.data, ETH_ADDR_LEN); --- 69,73 ---- } ! void eth_set_dst_addr(eth_obj * eth, eth_addr_t addr) { memcpy(ð->header.eth_dst.data, &addr.data, ETH_ADDR_LEN); Index: dhcp-interface.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-interface.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-interface.c 16 Nov 2002 00:23:43 -0000 1.3 --- dhcp-interface.c 27 Dec 2002 02:53:45 -0000 1.4 *************** *** 98,102 **** /* bring an interface up */ ! int interface_up(interface_control_t *ic, uint32_t addr, uint32_t netmask, int mtu) { if(interface_get_info(ic)) { --- 98,102 ---- /* bring an interface up */ ! int interface_up(interface_control_t *ic, ip_addr_t addr, uint32_t netmask, int mtu, uint8_t set_addr) { if(interface_get_info(ic)) { *************** *** 106,115 **** } ! /* Set address if needed. */ ! ! if(addr != 0) { ! ic->interface_entry->intf_addr.addr_type = ADDR_TYPE_IP; ! addr_mtob(&netmask, IP_ADDR_LEN, &ic->interface_entry->intf_addr.addr_bits); ! memcpy(&ic->interface_entry->intf_addr.addr_ip, &addr, IP_ADDR_LEN); } --- 106,117 ---- } ! if(set_addr) /* set an address as we bring this up. */ { ! if(addr == 0) { ! ic->interface_entry->intf_addr.addr_type = ADDR_TYPE_NONE; ! } else { ! ic->interface_entry->intf_addr.addr_type = ADDR_TYPE_IP; ! addr_mtob(&netmask, IP_ADDR_LEN, &ic->interface_entry->intf_addr.addr_bits); ! memcpy(&ic->interface_entry->intf_addr.addr_ip, &addr, IP_ADDR_LEN); ! } } Index: dhcp-interface.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-interface.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-interface.h 16 Nov 2002 00:23:43 -0000 1.2 --- dhcp-interface.h 27 Dec 2002 02:53:45 -0000 1.3 *************** *** 28,32 **** extern interface_control_t *create_interface_control(char *name); extern void destroy_interface_control(interface_control_t *ic); ! extern int interface_up(interface_control_t *ic, uint32_t addr, uint32_t netmask, int mtu); extern int interface_down(interface_control_t *ic); extern int interface_get_ip_addr(interface_control_t *ic, uint32_t *addr); --- 28,32 ---- extern interface_control_t *create_interface_control(char *name); extern void destroy_interface_control(interface_control_t *ic); ! extern int interface_up(interface_control_t *ic, ip_addr_t addr, uint32_t netmask, int mtu, uint8_t set_addr); extern int interface_down(interface_control_t *ic); extern int interface_get_ip_addr(interface_control_t *ic, uint32_t *addr); Index: dhcp-ip.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-ip.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-ip.c 19 Dec 2002 03:11:45 -0000 1.4 --- dhcp-ip.c 27 Dec 2002 02:53:45 -0000 1.5 *************** *** 48,57 **** } ! ip_addr_t ip_get_source_addr(ip_obj * ip) { return (ip->header.ip_src); } ! ip_addr_t ip_get_dest_addr(ip_obj * ip) { return (ip->header.ip_dst); --- 48,57 ---- } ! ip_addr_t ip_get_src_addr(ip_obj * ip) { return (ip->header.ip_src); } ! ip_addr_t ip_get_dst_addr(ip_obj * ip) { return (ip->header.ip_dst); *************** *** 68,72 **** } ! void ip_set_source_addr(ip_obj * ip, uint32_t ip_src) { ip->header.ip_src = ip_src; --- 68,72 ---- } ! void ip_set_src_addr(ip_obj * ip, uint32_t ip_src) { ip->header.ip_src = ip_src; *************** *** 74,78 **** } ! void ip_set_dest_addr(ip_obj * ip, uint32_t ip_dst) { ip->header.ip_dst = ip_dst; --- 74,78 ---- } ! void ip_set_dst_addr(ip_obj * ip, uint32_t ip_dst) { ip->header.ip_dst = ip_dst; Index: dhcp-print.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-print.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-print.c 16 Dec 2002 07:20:42 -0000 1.4 --- dhcp-print.c 27 Dec 2002 02:53:45 -0000 1.5 *************** *** 699,706 **** struct in_addr in; ! in.s_addr = ip_get_source_addr(ip); printf("srcip: %s ", inet_ntoa(in)); ! in.s_addr = ip_get_dest_addr(ip); printf("dstip: %s ", inet_ntoa(in)); return; --- 699,706 ---- struct in_addr in; ! in.s_addr = ip_get_src_addr(ip); printf("srcip: %s ", inet_ntoa(in)); ! in.s_addr = ip_get_dst_addr(ip); printf("dstip: %s ", inet_ntoa(in)); return; *************** *** 714,722 **** printf("-------------------------------IP HDR--------------------------------\n"); ! in.s_addr = ip_get_source_addr(ip); printf("Source: %-17s", inet_ntoa(in)); printf(" "); ! in.s_addr = ip_get_dest_addr(ip); printf("Destination: %-17s\n", inet_ntoa(in)); --- 714,722 ---- printf("-------------------------------IP HDR--------------------------------\n"); ! in.s_addr = ip_get_src_addr(ip); printf("Source: %-17s", inet_ntoa(in)); printf(" "); ! in.s_addr = ip_get_dst_addr(ip); printf("Destination: %-17s\n", inet_ntoa(in)); *************** *** 763,768 **** eth_addr_t dst_eth_addr; ! src_eth_addr = eth_get_src_address(eth); ! dst_eth_addr = eth_get_dst_address(eth); printf("smac: %x:%x:%x:%x:%x:%x ", src_eth_addr.data[0], src_eth_addr.data[1], --- 763,768 ---- eth_addr_t dst_eth_addr; ! src_eth_addr = eth_get_src_addr(eth); ! dst_eth_addr = eth_get_dst_addr(eth); printf("smac: %x:%x:%x:%x:%x:%x ", src_eth_addr.data[0], src_eth_addr.data[1], *************** *** 777,782 **** { eth_addr_t src_eth_addr, dst_eth_addr; ! src_eth_addr = eth_get_src_address(eth); ! dst_eth_addr = eth_get_dst_address(eth); printf("--------------------------Ethernet Header-----------------------------\n"); --- 777,782 ---- { eth_addr_t src_eth_addr, dst_eth_addr; ! src_eth_addr = eth_get_src_addr(eth); ! dst_eth_addr = eth_get_dst_addr(eth); printf("--------------------------Ethernet Header-----------------------------\n"); Index: dhcp-rawnet.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-rawnet.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-rawnet.c 16 Nov 2002 00:23:44 -0000 1.3 --- dhcp-rawnet.c 27 Dec 2002 02:53:45 -0000 1.4 *************** *** 98,102 **** { ! if(interface_up(net->intf_handle, addr, netmask, mtu)) { ERROR_MESSAGE("could not bring interface up."); return -1; --- 98,102 ---- { ! if(interface_up(net->intf_handle, addr, netmask, mtu, 1)) { ERROR_MESSAGE("could not bring interface up."); return -1; *************** *** 225,229 **** /* interface down */ /* bring it up with dum values. */ ! if(rawnet_interface_up(net, 0, 0xffffff, -1)) { ERROR_MESSAGE("error trying to bring device up: %s", device); rawnet_destroy(net); --- 225,229 ---- /* interface down */ /* bring it up with dum values. */ ! if(rawnet_interface_up(net, 0, 0, -1)) { ERROR_MESSAGE("error trying to bring device up: %s", device); rawnet_destroy(net); |