Work on bug #48824: ethernet.c extensions: Implement hook for unknown ethernet protocols

This commit is contained in:
Dirk Ziegelmeier 2016-08-23 10:48:38 +02:00
parent bae4d6398c
commit f170dde1c6
2 changed files with 20 additions and 4 deletions

View File

@ -2529,6 +2529,15 @@
#ifdef __DOXYGEN__
#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type)
#endif
/**
* LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif):
* Called from ethernet_input() when an unknown eth type is encountered.
* Return ERR_OK if packet is accepted, any error code otherwise.
*/
#ifdef __DOXYGEN__
#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif)
#endif
/**
* @}
*/

View File

@ -208,10 +208,17 @@ ethernet_input(struct pbuf *p, struct netif *netif)
#endif /* LWIP_IPV6 */
default:
ETHARP_STATS_INC(etharp.proterr);
ETHARP_STATS_INC(etharp.drop);
MIB2_STATS_NETIF_INC(netif, ifinunknownprotos);
goto free_and_return;
#ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
if(LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(p, netif) != ERR_OK) {
#endif
ETHARP_STATS_INC(etharp.proterr);
ETHARP_STATS_INC(etharp.drop);
MIB2_STATS_NETIF_INC(netif, ifinunknownprotos);
goto free_and_return;
#ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
}
break;
#endif
}
/* This means the pbuf is freed or consumed,