Move common BPF includes to top of header file.
This commit is contained in:
38
src/xdpfw.h
38
src/xdpfw.h
@@ -6,6 +6,24 @@
|
|||||||
#define MAX_FILTERS 100
|
#define MAX_FILTERS 100
|
||||||
#define MAX_TRACK_IPS 100000
|
#define MAX_TRACK_IPS 100000
|
||||||
|
|
||||||
|
#ifdef __BPF__
|
||||||
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
|
#define htons(x) ((__be16)___constant_swab16((x)))
|
||||||
|
#define ntohs(x) ((__be16)___constant_swab16((x)))
|
||||||
|
#define htonl(x) ((__be32)___constant_swab32((x)))
|
||||||
|
#define ntohl(x) ((__be32)___constant_swab32((x)))
|
||||||
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
|
#define htons(x) (x)
|
||||||
|
#define ntohs(X) (x)
|
||||||
|
#define htonl(x) (x)
|
||||||
|
#define ntohl(x) (x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define uint128_t __uint128_t
|
||||||
|
#endif
|
||||||
|
|
||||||
struct tcpopts
|
struct tcpopts
|
||||||
{
|
{
|
||||||
unsigned int enabled : 1;
|
unsigned int enabled : 1;
|
||||||
@@ -111,22 +129,4 @@ struct ip_stats
|
|||||||
__u64 pps;
|
__u64 pps;
|
||||||
__u64 bps;
|
__u64 bps;
|
||||||
__u64 tracking;
|
__u64 tracking;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __BPF__
|
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
||||||
#define htons(x) ((__be16)___constant_swab16((x)))
|
|
||||||
#define ntohs(x) ((__be16)___constant_swab16((x)))
|
|
||||||
#define htonl(x) ((__be32)___constant_swab32((x)))
|
|
||||||
#define ntohl(x) ((__be32)___constant_swab32((x)))
|
|
||||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
||||||
#define htons(x) (x)
|
|
||||||
#define ntohs(X) (x)
|
|
||||||
#define htonl(x) (x)
|
|
||||||
#define ntohl(x) (x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define uint128_t __uint128_t
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user