From 6e36a6f14c620901116a12f4c3b7bed1f55294be Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Thu, 13 Apr 2023 23:32:59 +0800 Subject: [PATCH] ethernet: add ETHERTYPE define adapts to third-party code compilation. in the process of porting ConnMan, we encounter some situations where the structure is not defined, or the returned data types do not match the expectations. Refer to the common implementation of other systems and add relevant definitions. Signed-off-by: zhanghongyu --- include/net/ethernet.h | 13 +++++++++++++ include/nuttx/net/ethernet.h | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/net/ethernet.h b/include/net/ethernet.h index 16f8eaa7662..a127c67c390 100644 --- a/include/net/ethernet.h +++ b/include/net/ethernet.h @@ -33,6 +33,19 @@ #define ETHER_ADDR_LEN 6 +/* Ethernet protocol ID's */ +#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */ +#define ETHERTYPE_SPRITE 0x0500 /* Sprite */ +#define ETHERTYPE_IP 0x0800 /* IP */ +#define ETHERTYPE_ARP 0x0806 /* Address resolution */ +#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ +#define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ +#define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ +#define ETHERTYPE_IPX 0x8137 /* IPX */ +#define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */ +#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ + /**************************************************************************** * Public Type Definitions ****************************************************************************/ diff --git a/include/nuttx/net/ethernet.h b/include/nuttx/net/ethernet.h index be995a14cb9..d35f4d0ac56 100644 --- a/include/nuttx/net/ethernet.h +++ b/include/nuttx/net/ethernet.h @@ -55,9 +55,9 @@ /* Recognized values of the type bytes in the Ethernet header */ -#define ETHTYPE_ARP 0x0806 /* Address resolution protocol */ -#define ETHTYPE_IP 0x0800 /* IP protocol */ -#define ETHTYPE_IP6 0x86dd /* IP protocol version 6 */ +#define ETHTYPE_ARP ETHERTYPE_ARP /* Address resolution protocol */ +#define ETHTYPE_IP ETHERTYPE_IP /* IP protocol */ +#define ETHTYPE_IP6 ETHERTYPE_IPV6 /* IP protocol version 6 */ /* Tag protocol identifier (TPID) of 0x8100 identifies the frame as an * IEEE 802.1Q-tagged frame. This field is located at the same position as @@ -65,7 +65,7 @@ * distinguish the frame from untagged frames. */ -#define TPID_8021QVLAN 0x8100 +#define TPID_8021QVLAN ETHERTYPE_VLAN /* These are some of the types associated with QVLAN tagged * Ethernet packets.