[dhcp-agent-commits] dhcp-agent/src dhcp-client-control.c,1.10,1.11 dhcp-client-states.c,1.18,1.19 d
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2002-12-24 03:03:32
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv29359 Modified Files: dhcp-client-control.c dhcp-client-states.c dhcp-client.h Log Message: client now only accepts packets from a port designated to a dhcp server Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dhcp-client-control.c 23 Dec 2002 00:51:24 -0000 1.10 --- dhcp-client-control.c 24 Dec 2002 03:03:28 -0000 1.11 *************** *** 168,173 **** filter = stringbuffer_create(); ! stringbuffer_aprintf(filter, "arp or icmp or (udp and (src port %d or dst port %d))", ! dport, sport); if((dc->rawnet = --- 168,173 ---- filter = stringbuffer_create(); ! stringbuffer_aprintf(filter, "arp or icmp or (udp and src port %d)", ! dport); if((dc->rawnet = *************** *** 182,185 **** --- 182,189 ---- /* Additional fields. */ + + /* server port. */ + dc->server_port = dport; /* demoting an integer to an unsigned short * + * -- should be fine for our purposes. */ /* xid setting */ Index: dhcp-client-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-states.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** dhcp-client-states.c 23 Dec 2002 01:21:52 -0000 1.18 --- dhcp-client-states.c 24 Dec 2002 03:03:28 -0000 1.19 *************** *** 179,182 **** --- 179,183 ---- 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); *************** *** 224,232 **** { /* check for generic dhcp response. ! * we check for type, validity and ! * matching xid. */ ! if((!rawnet_is_valid(dc->rawnet)) || ! dc->rawnet->type != RAWNET_DHCP || (dhcp_get_xid(dc->rawnet->dhcp_p) != dc->xid)) return 0; --- 225,243 ---- { /* check for generic dhcp response. ! * we check for type, ! * validity, matching xid, and ! * matching server source port */ ! /* is rawnet happy with the packet? */ ! if(((!rawnet_is_valid(dc->rawnet)) || ! ! /* is it a DHCP packet? */ ! (dc->rawnet->type != RAWNET_DHCP) || ! ! /* does the XID match up? */ ! (dhcp_get_xid(dc->rawnet->dhcp_p) != dc->xid) || ! ! /* is it from a server? */ ! (udp_get_src_port(dc->rawnet->udp_p) != dc->server_port))) return 0; Index: dhcp-client.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-client.h 19 Dec 2002 06:50:59 -0000 1.8 --- dhcp-client.h 24 Dec 2002 03:03:29 -0000 1.9 *************** *** 48,51 **** --- 48,52 ---- 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. */ } dhcp_client_control_t; |