diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 71a465f0..1abdf294 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -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 /** * @} */ diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c index 57c3f117..b84fcdc7 100644 --- a/src/netif/ethernet.c +++ b/src/netif/ethernet.c @@ -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,