Corrected some comments. Strongened assertions. Preparation for gratuitous ARP sending.

This commit is contained in:
likewise 2004-01-22 20:41:22 +00:00
parent 9ac8e17203
commit 2d6c314c64

View File

@ -372,20 +372,22 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
#if ARP_QUEUEING
/* get the first packet on the queue (if any) */
p = arp_table[i].p;
/* queued packet present? */
/* (another) queued packet present? */
while (p != NULL) {
struct pbuf *q, *n;
/* search for second packet on queue (n) */
q = p;
while (q->tot_len > q->len) {
LWIP_ASSERT("q->next != NULL (while q->tot_len > q->len)", q->next != NULL);
/* proceed to next pbuf of this packet */
LWIP_ASSERT("q->next ! NULL", q->next != NULL);
q = q->next;
}
/* { q = last pbuf of first packet, q->tot_len = q->len } */
/* { q = last pbuf of this packet, q->tot_len == q->len } */
LWIP_ASSERT("q->tot_len == q->len", q->tot_len == q->len);
/* remember next packet on queue */
n = q->next;
/* { n = first pbuf of 2nd packet, or NULL if no 2nd packet } */
/* terminate the first packet pbuf chain */
/* { n = first pbuf of next packet, or NULL if no next packet } */
/* terminate this packet pbuf chain */
q->next = NULL;
/* fill-in Ethernet header */
ethhdr = p->payload;
@ -405,10 +407,11 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
/* NULL attached buffer*/
arp_table[i].p = NULL;
#endif
/* IP addresses should only occur once in the ARP entry, we are done */
return NULL;
}
} /* if */
} /* for */
} /* if STABLE */
} /* for all ARP entries */
/* no matching ARP entry was found */
LWIP_ASSERT("update_arp_entry: i == ARP_TABLE_SIZE", i == ARP_TABLE_SIZE);
@ -521,6 +524,8 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
for_us = ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr));
}
/* first, let's answer */
switch (htons(hdr->opcode)) {
/* ARP request? */
case ARP_REQUEST:
@ -571,7 +576,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* ARP reply. We insert or update the ARP table later. */
LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
/* DHCP needs to know about ARP replies to our address */
/* DHCP wants to know about ARP replies to our wanna-have-address */
if (for_us) dhcp_arp_reply(netif, &hdr->sipaddr);
#endif
break;
@ -584,7 +589,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* 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 */
/* request was not directed to us, but snoop for updates anyway */
} else {
/* update or insert the source IP address in the cache */
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0);