1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

Merge pull request #14605 from JannesVolkens/ethertype_custom

sys/include/net: Add possibility to define custom ethertype
This commit is contained in:
Peter Kietzmann 2020-08-06 18:05:45 +02:00 committed by GitHub
commit 01e6b62667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -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

View File

@ -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;