mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-12 09:24:39 +08:00
Was updating ARP cache from a re-cycled ARP reply pbuf in some cases. Fixed.
Reported on lwip-users by Stephen Chen on february 4th 2004.
This commit is contained in:
parent
79e66ac841
commit
3aa6a385da
@ -521,6 +521,20 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
||||
for_us = ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr));
|
||||
}
|
||||
|
||||
/* add or update entries in the ARP cache */
|
||||
if (for_us) {
|
||||
/* insert IP address in ARP cache (assume requester wants to talk to us)
|
||||
* we might even send out a queued packet to this host */
|
||||
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG);
|
||||
/* request was not directed to us, but snoop anyway */
|
||||
} else {
|
||||
/* update or insert the source IP address in the cache */
|
||||
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0);
|
||||
/* update or insert the destination IP address pair in the cache */
|
||||
/** TODO: this might not work for an ARP request! TODO: Check **/
|
||||
update_arp_entry(netif, &(hdr->dipaddr), &(hdr->dhwaddr), 0);
|
||||
}
|
||||
|
||||
switch (htons(hdr->opcode)) {
|
||||
/* ARP request? */
|
||||
case ARP_REQUEST:
|
||||
@ -579,18 +593,6 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));
|
||||
break;
|
||||
}
|
||||
/* add or update entries in the ARP cache */
|
||||
if (for_us) {
|
||||
/* insert IP address in ARP cache (assume requester wants to talk to us)
|
||||
* we might even send out a queued packet to this host */
|
||||
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG);
|
||||
/* request was not directed to us, but snoop anyway */
|
||||
} else {
|
||||
/* update or insert the source IP address in the cache */
|
||||
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0);
|
||||
/* update or insert the destination IP address pair in the cache */
|
||||
update_arp_entry(netif, &(hdr->dipaddr), &(hdr->dhwaddr), 0);
|
||||
}
|
||||
/* free ARP packet */
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user