505 |
* |
* |
506 |
* If ARP failed to allocate resources, NULL is returned. |
* If ARP failed to allocate resources, NULL is returned. |
507 |
* |
* |
508 |
* 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. |
|
509 |
* |
* |
510 |
* @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. |
511 |
* @param ipaddr The IP address of the packet destination. |
* @param ipaddr The IP address of the packet destination. |
512 |
* @param pbuf The pbuf(s) containing the IP packet to be sent. |
* @param pbuf The pbuf(s) containing the IP packet to be sent. |
513 |
* |
* |
514 |
* @return If non-NULL, a packet ready to be sent. |
* @return If non-NULL, a packet ready to be sent. |
|
* @see etharp_output_sent() |
|
515 |
*/ |
*/ |
516 |
struct pbuf * |
struct pbuf * |
517 |
etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) |
etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) |
638 |
* @note Might be used in the future by manual IP configuration |
* @note Might be used in the future by manual IP configuration |
639 |
* as well. |
* as well. |
640 |
* |
* |
|
* 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. |
|
641 |
* 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, |
642 |
* possibly retry. |
* possibly retry. |
643 |
*/ |
*/ |
649 |
err_t result = ERR_OK; |
err_t result = ERR_OK; |
650 |
u8_t i; |
u8_t i; |
651 |
u8_t perform_arp_request = 1; |
u8_t perform_arp_request = 1; |
652 |
/* prevent warning if ARP_QUEUEING == 0 */ |
/* prevent 'unused argument' warning if ARP_QUEUEING == 0 */ |
653 |
if (q); |
(void)q; |
|
|
|
654 |
srcaddr = (struct eth_addr *)netif->hwaddr; |
srcaddr = (struct eth_addr *)netif->hwaddr; |
655 |
/* bail out if this IP address is pending */ |
/* bail out if this IP address is pending */ |
656 |
for(i = 0; i < ARP_TABLE_SIZE; ++i) { |
for (i = 0; i < ARP_TABLE_SIZE; ++i) { |
657 |
if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { |
if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { |
658 |
if (arp_table[i].state == ETHARP_STATE_PENDING) { |
if (arp_table[i].state == ETHARP_STATE_PENDING) { |
659 |
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i)); |
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i)); |