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:
likewise 2004-02-05 18:29:08 +00:00
parent 79e66ac841
commit 3aa6a385da

View File

@ -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;