diff --git a/sys/include/net/ethertype.h b/sys/include/net/ethertype.h index 5fb7b727b4..b35fb0152b 100644 --- a/sys/include/net/ethertype.h +++ b/sys/include/net/ethertype.h @@ -38,6 +38,23 @@ extern "C" { #define ETHERTYPE_NDN (0x8624) /**< NDN Protocol (http://named-data.net/) */ #define ETHERTYPE_IPV6 (0x86dd) /**< Internet protocol version 6 */ #define ETHERTYPE_6LOENC (0xa0ed) /**< 6LoWPAN encapsulation */ + +/** + * @defgroup net_ethertype_custom_config Custom ethertype + * @ingroup config + * @brief Custom ethertype definition + * @warning Do not use a IANA assigned number + * @see https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml + * + * @{ + */ +#ifndef ETHERTYPE_CUSTOM +#define ETHERTYPE_CUSTOM (0x0101) /**< Custom ethertype */ +#endif +/** + * @} + */ + #define ETHERTYPE_UNKNOWN (0xffff) /**< Reserved (no protocol specified) */ #ifdef __cplusplus diff --git a/sys/include/net/gnrc/nettype.h b/sys/include/net/gnrc/nettype.h index af2f7d729f..0297634c99 100644 --- a/sys/include/net/gnrc/nettype.h +++ b/sys/include/net/gnrc/nettype.h @@ -90,6 +90,17 @@ typedef enum { * @} */ + /** + * @{ + * @name Link layer + */ +#if IS_USED(MODULE_GNRC_NETTYPE_CUSTOM) || defined(DOXYGEN) + GNRC_NETTYPE_CUSTOM, /**< Custom ethertype */ +#endif + /** + * @} + */ + /** * @{ * @name Network layer @@ -177,6 +188,10 @@ static inline gnrc_nettype_t gnrc_nettype_from_ethertype(uint16_t type) #if IS_USED(MODULE_GNRC_SIXLOENC) && IS_USED(MODULE_GNRC_NETTYPE_SIXLOWPAN) case ETHERTYPE_6LOENC: return GNRC_NETTYPE_SIXLOWPAN; +#endif +#if IS_USED(MODULE_GNRC_NETTYPE_CUSTOM) + case ETHERTYPE_CUSTOM: + return GNRC_NETTYPE_CUSTOM; #endif default: return GNRC_NETTYPE_UNDEF; @@ -211,6 +226,10 @@ static inline uint16_t gnrc_nettype_to_ethertype(gnrc_nettype_t type) #if IS_USED(MODULE_GNRC_NETTYPE_NDN) case GNRC_NETTYPE_NDN: return ETHERTYPE_NDN; +#endif +#if IS_USED(MODULE_GNRC_NETTYPE_CUSTOM) + case GNRC_NETTYPE_CUSTOM: + return ETHERTYPE_CUSTOM; #endif default: return ETHERTYPE_UNKNOWN;