Cleanup etharp_arp_input() signature to match the sig of other input functions (pbuf, netif). Rename to etharp_input()

This commit is contained in:
Dirk Ziegelmeier 2016-08-23 17:03:51 +02:00
parent 979bee386c
commit 6caa7b9927
4 changed files with 15 additions and 16 deletions

View File

@ -447,7 +447,7 @@ autoip_tmr(void)
} }
/** /**
* Handles every incoming ARP Packet, called by etharp_arp_input. * Handles every incoming ARP Packet, called by etharp_input().
* *
* @param netif network interface to use for autoip processing * @param netif network interface to use for autoip processing
* @param hdr Incoming ARP packet * @param hdr Incoming ARP packet

View File

@ -623,16 +623,15 @@ etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_a
* Should be called for incoming ARP packets. The pbuf in the argument * Should be called for incoming ARP packets. The pbuf in the argument
* is freed by this function. * is freed by this function.
* *
* @param netif The lwIP network interface on which the ARP packet pbuf arrived.
* @param ethaddr Ethernet address of netif.
* @param p The ARP packet that arrived on netif. Is freed by this function. * @param p The ARP packet that arrived on netif. Is freed by this function.
* @param netif The lwIP network interface on which the ARP packet pbuf arrived.
* *
* @return NULL * @return NULL
* *
* @see pbuf_free() * @see pbuf_free()
*/ */
void void
etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) etharp_input(struct pbuf *p, struct netif *netif)
{ {
struct etharp_hdr *hdr; struct etharp_hdr *hdr;
struct eth_hdr *ethhdr; struct eth_hdr *ethhdr;
@ -649,7 +648,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
since a struct etharp_hdr is pointed to p->payload, so it musn't be chained! */ since a struct etharp_hdr is pointed to p->payload, so it musn't be chained! */
if (p->len < SIZEOF_ETHARP_PACKET) { if (p->len < SIZEOF_ETHARP_PACKET) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("etharp_arp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len, ("etharp_input: packet dropped, too short (%"S16_F"/%"S16_F")\n", p->tot_len,
(s16_t)SIZEOF_ETHARP_PACKET)); (s16_t)SIZEOF_ETHARP_PACKET));
ETHARP_STATS_INC(etharp.lenerr); ETHARP_STATS_INC(etharp.lenerr);
ETHARP_STATS_INC(etharp.drop); ETHARP_STATS_INC(etharp.drop);
@ -671,7 +670,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
(hdr->protolen != sizeof(ip4_addr_t)) || (hdr->protolen != sizeof(ip4_addr_t)) ||
(hdr->proto != PP_HTONS(ETHTYPE_IP))) { (hdr->proto != PP_HTONS(ETHTYPE_IP))) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n", ("etharp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n",
hdr->hwtype, (u16_t)hdr->hwlen, hdr->proto, (u16_t)hdr->protolen)); hdr->hwtype, (u16_t)hdr->hwlen, hdr->proto, (u16_t)hdr->protolen));
ETHARP_STATS_INC(etharp.proterr); ETHARP_STATS_INC(etharp.proterr);
ETHARP_STATS_INC(etharp.drop); ETHARP_STATS_INC(etharp.drop);
@ -716,11 +715,11 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
* reply. In any case, we time-stamp any existing ARP entry, * reply. In any case, we time-stamp any existing ARP entry,
* and possibly send out an IP packet that was queued on it. */ * and possibly send out an IP packet that was queued on it. */
LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP request\n")); LWIP_DEBUGF (ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: incoming ARP request\n"));
/* ARP request for our address? */ /* ARP request for our address? */
if (for_us) { if (for_us) {
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n")); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: replying to ARP request for our IP address\n"));
/* Re-use pbuf to send ARP reply. /* Re-use pbuf to send ARP reply.
Since we are re-using an existing pbuf, we can't call etharp_raw since Since we are re-using an existing pbuf, we can't call etharp_raw since
that would allocate a new pbuf. */ that would allocate a new pbuf. */
@ -744,8 +743,8 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
#else /* LWIP_AUTOIP */ #else /* LWIP_AUTOIP */
ETHADDR16_COPY(&ethhdr->dest, &hdr->shwaddr); ETHADDR16_COPY(&ethhdr->dest, &hdr->shwaddr);
#endif /* LWIP_AUTOIP */ #endif /* LWIP_AUTOIP */
ETHADDR16_COPY(&hdr->shwaddr, ethaddr); ETHADDR16_COPY(&hdr->shwaddr, netif->hwaddr);
ETHADDR16_COPY(&ethhdr->src, ethaddr); ETHADDR16_COPY(&ethhdr->src, netif->hwaddr);
/* hwtype, hwaddr_len, proto, protolen and the type in the ethernet header /* hwtype, hwaddr_len, proto, protolen and the type in the ethernet header
are already correct, we tested that before */ are already correct, we tested that before */
@ -755,16 +754,16 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* we are not configured? */ /* we are not configured? */
} else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) { } else if (ip4_addr_isany_val(*netif_ip4_addr(netif))) {
/* { for_us == 0 and netif->ip_addr.addr == 0 } */ /* { for_us == 0 and netif->ip_addr.addr == 0 } */
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n")); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: we are unconfigured, ARP request ignored.\n"));
/* request was not directed to us */ /* request was not directed to us */
} else { } else {
/* { for_us == 0 and netif->ip_addr.addr != 0 } */ /* { for_us == 0 and netif->ip_addr.addr != 0 } */
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n")); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: ARP request was not for us.\n"));
} }
break; break;
case PP_HTONS(ARP_REPLY): case PP_HTONS(ARP_REPLY):
/* ARP reply. We already updated the ARP cache earlier. */ /* ARP reply. We already updated the ARP cache earlier. */
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: incoming ARP reply\n"));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
/* DHCP wants to know about ARP replies from any host with an /* DHCP wants to know about ARP replies from any host with an
* IP address also offered to us by the DHCP server. We do not * IP address also offered to us by the DHCP server. We do not
@ -774,7 +773,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
#endif /* (LWIP_DHCP && DHCP_DOES_ARP_CHECK) */ #endif /* (LWIP_DHCP && DHCP_DOES_ARP_CHECK) */
break; break;
default: default:
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode))); LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_input: ARP unknown opcode type %"S16_F"\n", htons(hdr->opcode)));
ETHARP_STATS_INC(etharp.err); ETHARP_STATS_INC(etharp.err);
break; break;
} }

View File

@ -102,7 +102,7 @@ err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr);
#endif /* LWIP_IPV4 && LWIP_ARP */ #endif /* LWIP_IPV4 && LWIP_ARP */
void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p); void etharp_input(struct pbuf *p, struct netif *netif);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -175,7 +175,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
goto free_and_return; goto free_and_return;
} }
/* pass p to ARP module */ /* pass p to ARP module */
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p); etharp_input(p, netif);
break; break;
#endif /* LWIP_IPV4 && LWIP_ARP */ #endif /* LWIP_IPV4 && LWIP_ARP */
#if PPPOE_SUPPORT #if PPPOE_SUPPORT