2 |
* @file |
* @file |
3 |
* Address Resolution Protocol module for IP over Ethernet |
* Address Resolution Protocol module for IP over Ethernet |
4 |
* |
* |
5 |
|
* Functionally, ARP is divided into two parts. The first maps an IP address |
6 |
|
* to a physical address when sending a packet, and the second part answers |
7 |
|
* requests from other machines. |
8 |
|
* |
9 |
*/ |
*/ |
10 |
|
|
11 |
/* |
/* |
213 |
j = i; |
j = i; |
214 |
} |
} |
215 |
} |
} |
216 |
|
if (j != ARP_TABLE_SIZE) { |
217 |
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found oldest stable entry %u\n", j)); |
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found oldest stable entry %u\n", j)); |
218 |
|
} else { |
219 |
|
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: no replacable entry could be found\n")); |
220 |
|
} |
221 |
i = j; |
i = j; |
222 |
} |
} |
223 |
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: returning %u, state %u\n", i, arp_table[i].state)); |
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: returning %u, state %u\n", i, arp_table[i].state)); |
503 |
* |
* |
504 |
* If ARP failed to allocate resources, NULL is returned. |
* If ARP failed to allocate resources, NULL is returned. |
505 |
* |
* |
506 |
* A returned non-NULL packet should be sent by the caller and |
* A returned non-NULL packet should be sent by the caller. |
|
* etharp_output_sent() must be called afterwards to free any ARP |
|
|
* request. |
|
507 |
* |
* |
508 |
* @param netif The lwIP network interface which the IP packet will be sent on. |
* @param netif The lwIP network interface which the IP packet will be sent on. |
509 |
* @param ipaddr The IP address of the packet destination. |
* @param ipaddr The IP address of the packet destination. |
510 |
* @param pbuf The pbuf(s) containing the IP packet to be sent. |
* @param pbuf The pbuf(s) containing the IP packet to be sent. |
511 |
* |
* |
512 |
* @return If non-NULL, a packet ready to be sent. |
* @return If non-NULL, a packet ready to be sent. |
|
* @see etharp_output_sent() |
|
513 |
*/ |
*/ |
514 |
struct pbuf * |
struct pbuf * |
515 |
etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) |
etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) |
636 |
* @note Might be used in the future by manual IP configuration |
* @note Might be used in the future by manual IP configuration |
637 |
* as well. |
* as well. |
638 |
* |
* |
|
* TODO: enqueue q here if possible (BEWARE: possible other packet already |
|
|
* queued. |
|
|
* TODO: The host requirements RFC states that ARP should save at least one |
|
|
* packet, and this should be the _latest_ packet. |
|
639 |
* TODO: use the ctime field to see how long ago an ARP request was sent, |
* TODO: use the ctime field to see how long ago an ARP request was sent, |
640 |
* possibly retry. |
* possibly retry. |
641 |
*/ |
*/ |
644 |
struct eth_addr *srcaddr; |
struct eth_addr *srcaddr; |
645 |
struct etharp_hdr *hdr; |
struct etharp_hdr *hdr; |
646 |
struct pbuf *p; |
struct pbuf *p; |
647 |
err_t result; |
err_t result = ERR_OK; |
648 |
u8_t i; |
u8_t i; |
649 |
/* prevent warning if ARP_QUEUEING == 0 */ |
/* prevent warning if ARP_QUEUEING == 0 */ |
650 |
if (q); |
if (q); |