- Use the target hardware address to find the correct DHCP_ADAPTER for the received packet

svn path=/trunk/; revision=41838
This commit is contained in:
Cameron Gutman 2009-07-10 01:15:51 +00:00
parent 2dbd55ac66
commit 4af59e7e33
3 changed files with 29 additions and 1 deletions

View file

@ -355,6 +355,23 @@ PDHCP_ADAPTER AdapterFindInfo( struct interface_info *ip ) {
return NULL;
}
PDHCP_ADAPTER AdapterFindByHardwareAddress( u_int8_t haddr[16], u_int8_t hlen ) {
PDHCP_ADAPTER Adapter;
PLIST_ENTRY ListEntry;
for(ListEntry = AdapterList.Flink;
ListEntry != &AdapterList;
ListEntry = ListEntry->Flink) {
Adapter = CONTAINING_RECORD( ListEntry, DHCP_ADAPTER, ListEntry );
if (Adapter->DhclientInfo.hw_address.hlen == hlen &&
!memcmp(Adapter->DhclientInfo.hw_address.haddr,
haddr,
hlen)) return Adapter;
}
return NULL;
}
PDHCP_ADAPTER AdapterGetFirst() {
if( IsListEmpty( &AdapterList ) ) return NULL; else {
return CONTAINING_RECORD

View file

@ -231,6 +231,7 @@ got_one(struct protocol *l)
struct dhcp_packet packet;
} u;
struct interface_info *ip = l->local;
PDHCP_ADAPTER adapter;
if ((result = receive_packet(ip, u.packbuf, sizeof(u), &from,
&hfrom)) == -1) {
@ -257,7 +258,16 @@ got_one(struct protocol *l)
ifrom.len = 4;
memcpy(ifrom.iabuf, &from.sin_addr, ifrom.len);
(*bootp_packet_handler)(ip, &u.packet, result,
adapter = AdapterFindByHardwareAddress(u.packet.chaddr,
u.packet.hlen);
if (!adapter) {
warning("Discarding packet with a non-matching target physical address\n");
return;
}
(*bootp_packet_handler)(&adapter->DhclientInfo, &u.packet, result,
from.sin_port, ifrom, &hfrom);
}
}

View file

@ -76,6 +76,7 @@ extern PDHCP_ADAPTER AdapterGetFirst();
extern PDHCP_ADAPTER AdapterGetNext(PDHCP_ADAPTER);
extern PDHCP_ADAPTER AdapterFindIndex( unsigned int AdapterIndex );
extern PDHCP_ADAPTER AdapterFindInfo( struct interface_info *info );
extern PDHCP_ADAPTER AdapterFindByHardwareAddress( u_int8_t haddr[16], u_int8_t hlen );
extern VOID ApiInit();
extern VOID ApiLock();
extern VOID ApiUnlock();