xref: /openbmc/linux/samples/bpf/net_shared.h (revision e69fe8459552f112d7327dff87953d40202c61f1)
1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef _NET_SHARED_H
3 #define _NET_SHARED_H
4 
5 #define ETH_ALEN 6
6 #define ETH_P_802_3_MIN 0x0600
7 #define ETH_P_8021Q 0x8100
8 #define ETH_P_8021AD 0x88A8
9 #define ETH_P_IP 0x0800
10 #define ETH_P_IPV6 0x86DD
11 #define ETH_P_ARP 0x0806
12 #define IPPROTO_ICMPV6 58
13 
14 #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
15 	__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
16 #define bpf_ntohs(x)		__builtin_bswap16(x)
17 #define bpf_htons(x)		__builtin_bswap16(x)
18 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
19 	__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
20 #define bpf_ntohs(x)		(x)
21 #define bpf_htons(x)		(x)
22 #else
23 # error "Endianness detection needs to be set up for your compiler?!"
24 #endif
25 
26 #endif
27