3 |
* Address Resolution Protocol module for IP over Ethernet |
* Address Resolution Protocol module for IP over Ethernet |
4 |
* |
* |
5 |
* $Log$ |
* $Log$ |
6 |
|
* Revision 1.8 2002/11/13 09:10:19 likewise |
7 |
|
* ARP entries can now be updated (but not added) on any ARP traffic. Set #define ETHARP_SNOOP_UPDATES 1 to enable. |
8 |
|
* |
9 |
* Revision 1.7 2002/11/13 08:56:11 likewise |
* Revision 1.7 2002/11/13 08:56:11 likewise |
10 |
* Implemented conditional insertion of ARP entries to update_arp_entry using ARP_INSERT_FLAG. |
* Implemented conditional insertion of ARP entries to update_arp_entry using ARP_INSERT_FLAG. |
|
* |
|
|
* Revision 1.6 2002/11/11 14:34:29 likewise |
|
|
* Changed static etharp_query() to support queueing packets. This fix missed in last commit. |
|
|
* |
|
|
* Revision 1.5 2002/11/08 22:14:24 likewise |
|
|
* Fixed numerous bugs. Re-used etharp_query() in etharp_output(). Added comments and JavaDoc documentation. |
|
|
* |
|
|
* Revision 1.4 2002/11/08 12:54:43 proff_fs |
|
|
* Added includeds for bpstruct and epstruct. |
|
|
* Ports should update from using PACK_STRUCT_BEGIN and PACK_STRUCT_END to use these includes. |
|
|
* Maybe there should be an PACK_STRUCT_USE_INCLUDES ifdef around these, for ports for which PACK_STRUCT_BEGIN and PACK_STRUCT_END works nicely. |
|
|
* |
|
|
* Revision 1.3 2002/11/06 11:43:21 likewise |
|
|
* find_arp_entry() returned 0 instead of ARP_TABLE_SIZE if full pending cache (bug #1625). |
|
|
* |
|
|
* Revision 1.2 2002/11/04 14:56:40 likewise |
|
|
* Fixed NULL pointer bug (#1493). Fix for memory leak bug (#1601), etharp_output_sent(). Added etharp_query for DHCP. |
|
|
* |
|
11 |
*/ |
*/ |
12 |
|
|
13 |
/* |
/* |
92 |
/** the time an ARP entry stays pending after first request, (2 * 10) seconds = 20 seconds. */ |
/** the time an ARP entry stays pending after first request, (2 * 10) seconds = 20 seconds. */ |
93 |
#define ARP_MAXPENDING 2 |
#define ARP_MAXPENDING 2 |
94 |
|
|
95 |
|
/** dis/enable existing ARP entries updates on any ARP traffic */ |
96 |
|
#define ETHARP_SNOOP_UPDATES 0 |
97 |
|
|
98 |
#define HWTYPE_ETHERNET 1 |
#define HWTYPE_ETHERNET 1 |
99 |
|
|
100 |
/** ARP message types */ |
/** ARP message types */ |
401 |
etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) |
etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) |
402 |
{ |
{ |
403 |
struct etharp_hdr *hdr; |
struct etharp_hdr *hdr; |
404 |
|
struct pbuf *q; |
405 |
u8_t i; |
u8_t i; |
406 |
|
|
407 |
/* drop short ARP packets */ |
/* drop short ARP packets */ |
446 |
/* return ARP reply */ |
/* return ARP reply */ |
447 |
return p; |
return p; |
448 |
} |
} |
449 |
#if 0 |
#if ETHARP_SNOOP_UPDATES |
450 |
/* ARP request, NOT for our address */ |
/* request, NOT for our address */ |
451 |
else |
else { |
452 |
{ |
/* update_arp_entry() can return a pbuf that has previously been |
453 |
|
queued waiting for this IP address to become ARP stable. */ |
454 |
|
q = update_arp_entry(&(hdr->sipaddr), &(hdr->shwaddr), 0); |
455 |
|
pbuf_free(p); |
456 |
|
p = NULL; |
457 |
|
return q; |
458 |
} |
} |
459 |
#endif |
#endif |
460 |
break; |
break; |
462 |
/* ARP reply. We insert or update the ARP table. */ |
/* ARP reply. We insert or update the ARP table. */ |
463 |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: ARP reply\n")); |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: ARP reply\n")); |
464 |
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) |
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) |
465 |
/* DHCP needs to know about ARP replies */ |
/* DHCP needs to know about ARP replies */ |
466 |
dhcp_arp_reply(&hdr->sipaddr); |
dhcp_arp_reply(&hdr->sipaddr); |
467 |
#endif |
#endif |
468 |
/* for our address? */ |
/* for our address? */ |
469 |
if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { |
if(ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { |
|
struct pbuf *q; |
|
470 |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: ARP reply for us\n")); |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: ARP reply for us\n")); |
471 |
/* update_arp_entry() can return a pbuf that has previously been |
/* update_arp_entry() can return a pbuf that has previously been |
472 |
queued waiting for this IP address to become ARP stable. */ |
queued waiting for this IP address to become ARP stable. */ |
476 |
p = NULL; |
p = NULL; |
477 |
return q; |
return q; |
478 |
} |
} |
479 |
#if 0 |
#if ETHARP_SNOOP_UPDATES |
480 |
/* ARP reply, NOT for our address */ |
/* ARP reply, NOT for our address */ |
481 |
else |
else { |
482 |
{ |
/* update_arp_entry() can return a pbuf that has previously been |
483 |
|
queued waiting for this IP address to become ARP stable. */ |
484 |
|
q = update_arp_entry(&(hdr->sipaddr), &(hdr->shwaddr), 0); |
485 |
|
pbuf_free(p); |
486 |
|
p = NULL; |
487 |
|
return q; |
488 |
} |
} |
489 |
#endif |
#endif |
490 |
break; |
break; |
492 |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: unknown type %d\n", htons(hdr->opcode))); |
DEBUGF(ETHARP_DEBUG, ("etharp_arp_input: unknown type %d\n", htons(hdr->opcode))); |
493 |
break; |
break; |
494 |
} |
} |
|
|
|
495 |
pbuf_free(p); |
pbuf_free(p); |
496 |
return NULL; |
return NULL; |
497 |
} |
} |