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