mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-28 09:19:53 +00:00
Moved ethernet_input from tcpip.c to etharp.c so all netifs (or ports) can use it.
This commit is contained in:
parent
79c00be516
commit
cb71d6d393
@ -19,6 +19,10 @@ HISTORY
|
||||
|
||||
++ New features:
|
||||
|
||||
2007-10-05 Simon Goldschmidt
|
||||
* tcpip.c, etharp.h, etharp.c: moved ethernet_input from tcpip.c to etharp.c so
|
||||
all netifs (or ports) can use it.
|
||||
|
||||
2007-10-05 Frédéric Bernon
|
||||
* netifapi.h, netifapi.c: add function netifapi_netif_set_default. Change the
|
||||
common function to reduce a little bit the footprint (for all functions using
|
||||
|
@ -202,66 +202,6 @@ igmp_timer(void *arg)
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
#if LWIP_ARP
|
||||
/**
|
||||
* Process received ethernet frames. Using this function instead of directly
|
||||
* calling ip_input and passing ARP frames through etharp in ethernetif_input,
|
||||
* the ARP cache is protected from concurrent access.
|
||||
*
|
||||
* @param p the recevied packet, p->payload pointing to the ethernet header
|
||||
* @param netif the network interface on which the packet was received
|
||||
*/
|
||||
static err_t
|
||||
ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
{
|
||||
struct eth_hdr* ethhdr;
|
||||
|
||||
/* points to packet payload, which starts with an Ethernet header */
|
||||
ethhdr = p->payload;
|
||||
|
||||
switch (htons(ethhdr->type)) {
|
||||
/* IP packet? */
|
||||
case ETHTYPE_IP:
|
||||
#if ETHARP_TRUST_IP_MAC
|
||||
/* update ARP table */
|
||||
etharp_ip_input( netif, p);
|
||||
#endif /* ETHARP_TRUST_IP_MAC */
|
||||
/* skip Ethernet header */
|
||||
if(pbuf_header(p, -(s16_t)sizeof(struct eth_hdr))) {
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
} else {
|
||||
/* pass to IP layer */
|
||||
ip_input(p, netif);
|
||||
}
|
||||
break;
|
||||
|
||||
case ETHTYPE_ARP:
|
||||
/* pass p to ARP module */
|
||||
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p);
|
||||
break;
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */
|
||||
pppoe_disc_input(netif, p);
|
||||
break;
|
||||
|
||||
case ETHTYPE_PPPOE: /* PPP Over Ethernet Session Stage */
|
||||
pppoe_data_input(netif, p);
|
||||
break;
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
default:
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ERR_OK; /* return value ignored */
|
||||
}
|
||||
#endif /* LWIP_ARP */
|
||||
|
||||
/**
|
||||
* The main lwIP thread. This thread has exclusive access to lwIP core functions
|
||||
* (unless access to them is not locked). Other threads communicate with this
|
||||
|
@ -152,6 +152,8 @@ err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr)
|
||||
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
|
||||
err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
|
||||
|
||||
err_t ethernet_input(struct pbuf *p, struct netif *netif);
|
||||
|
||||
#if LWIP_AUTOIP
|
||||
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
|
||||
const struct eth_addr *ethdst_addr,
|
||||
|
@ -1084,4 +1084,63 @@ etharp_request(struct netif *netif, struct ip_addr *ipaddr)
|
||||
ipaddr, ARP_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process received ethernet frames. Using this function instead of directly
|
||||
* calling ip_input and passing ARP frames through etharp in ethernetif_input,
|
||||
* the ARP cache is protected from concurrent access.
|
||||
*
|
||||
* @param p the recevied packet, p->payload pointing to the ethernet header
|
||||
* @param netif the network interface on which the packet was received
|
||||
*/
|
||||
err_t
|
||||
ethernet_input(struct pbuf *p, struct netif *netif)
|
||||
{
|
||||
struct eth_hdr* ethhdr;
|
||||
|
||||
/* points to packet payload, which starts with an Ethernet header */
|
||||
ethhdr = p->payload;
|
||||
|
||||
switch (htons(ethhdr->type)) {
|
||||
/* IP packet? */
|
||||
case ETHTYPE_IP:
|
||||
#if ETHARP_TRUST_IP_MAC
|
||||
/* update ARP table */
|
||||
etharp_ip_input(netif, p);
|
||||
#endif /* ETHARP_TRUST_IP_MAC */
|
||||
/* skip Ethernet header */
|
||||
if(pbuf_header(p, -(s16_t)sizeof(struct eth_hdr))) {
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
} else {
|
||||
/* pass to IP layer */
|
||||
ip_input(p, netif);
|
||||
}
|
||||
break;
|
||||
|
||||
case ETHTYPE_ARP:
|
||||
/* pass p to ARP module */
|
||||
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p);
|
||||
break;
|
||||
|
||||
#if PPPOE_SUPPORT
|
||||
case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */
|
||||
pppoe_disc_input(netif, p);
|
||||
break;
|
||||
|
||||
case ETHTYPE_PPPOE: /* PPP Over Ethernet Session Stage */
|
||||
pppoe_data_input(netif, p);
|
||||
break;
|
||||
#endif /* PPPOE_SUPPORT */
|
||||
|
||||
default:
|
||||
pbuf_free(p);
|
||||
p = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* This means the pbuf is freed or consumed,
|
||||
so the caller doesn't have to free it again */
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* LWIP_ARP */
|
||||
|
Loading…
Reference in New Issue
Block a user