xref: /openbmc/linux/samples/bpf/net_shared.h (revision 39f555fb)
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 #define IFNAMSIZ 16
21 
22 #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
23 	__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
24 #define bpf_ntohs(x)		__builtin_bswap16(x)
25 #define bpf_htons(x)		__builtin_bswap16(x)
26 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
27 	__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
28 #define bpf_ntohs(x)		(x)
29 #define bpf_htons(x)		(x)
30 #else
31 # error "Endianness detection needs to be set up for your compiler?!"
32 #endif
33 
34 #endif
35