eBPF for Windows
Macros
bpf_endian.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define ___bpf_mvb(x, b, n, m)   ((__u##b)(x) << (b - (n + 1) * 8) >> (b - 8) << (m * 8))
 
#define ___bpf_swab16(x)   ((__u16)(___bpf_mvb(x, 16, 0, 1) | ___bpf_mvb(x, 16, 1, 0)))
 
#define ___bpf_swab32(x)    ((__u32)(___bpf_mvb(x, 32, 0, 3) | ___bpf_mvb(x, 32, 1, 2) | ___bpf_mvb(x, 32, 2, 1) | ___bpf_mvb(x, 32, 3, 0)))
 
#define ___bpf_swab64(x)
 
#define __bpf_ntohs(x)   __builtin_bswap16(x)
 
#define __bpf_htons(x)   __builtin_bswap16(x)
 
#define __bpf_constant_ntohs(x)   ___bpf_swab16(x)
 
#define __bpf_constant_htons(x)   ___bpf_swab16(x)
 
#define __bpf_ntohl(x)   __builtin_bswap32(x)
 
#define __bpf_htonl(x)   __builtin_bswap32(x)
 
#define __bpf_constant_ntohl(x)   ___bpf_swab32(x)
 
#define __bpf_constant_htonl(x)   ___bpf_swab32(x)
 
#define __bpf_be64_to_cpu(x)   __builtin_bswap64(x)
 
#define __bpf_cpu_to_be64(x)   __builtin_bswap64(x)
 
#define __bpf_constant_be64_to_cpu(x)   ___bpf_swab64(x)
 
#define __bpf_constant_cpu_to_be64(x)   ___bpf_swab64(x)
 
#define bpf_htons(x)   (__builtin_constant_p(x) ? __bpf_constant_htons(x) : __bpf_htons(x))
 
#define bpf_ntohs(x)   (__builtin_constant_p(x) ? __bpf_constant_ntohs(x) : __bpf_ntohs(x))
 
#define bpf_htonl(x)   (__builtin_constant_p(x) ? __bpf_constant_htonl(x) : __bpf_htonl(x))
 
#define bpf_ntohl(x)   (__builtin_constant_p(x) ? __bpf_constant_ntohl(x) : __bpf_ntohl(x))
 
#define bpf_cpu_to_be64(x)   (__builtin_constant_p(x) ? __bpf_constant_cpu_to_be64(x) : __bpf_cpu_to_be64(x))
 
#define bpf_be64_to_cpu(x)   (__builtin_constant_p(x) ? __bpf_constant_be64_to_cpu(x) : __bpf_be64_to_cpu(x))
 
#define ntohs   bpf_ntohs
 
#define htons   bpf_htons
 
#define ntohl   bpf_ntohl
 
#define htonl   bpf_htonl
 

Macro Definition Documentation

◆ ___bpf_mvb

#define ___bpf_mvb (   x,
  b,
  n,
 
)    ((__u##b)(x) << (b - (n + 1) * 8) >> (b - 8) << (m * 8))

◆ ___bpf_swab16

#define ___bpf_swab16 (   x)    ((__u16)(___bpf_mvb(x, 16, 0, 1) | ___bpf_mvb(x, 16, 1, 0)))

◆ ___bpf_swab32

#define ___bpf_swab32 (   x)     ((__u32)(___bpf_mvb(x, 32, 0, 3) | ___bpf_mvb(x, 32, 1, 2) | ___bpf_mvb(x, 32, 2, 1) | ___bpf_mvb(x, 32, 3, 0)))

◆ ___bpf_swab64

#define ___bpf_swab64 (   x)
Value:
((__u64)(___bpf_mvb(x, 64, 0, 7) | ___bpf_mvb(x, 64, 1, 6) | ___bpf_mvb(x, 64, 2, 5) | ___bpf_mvb(x, 64, 3, 4) | \
___bpf_mvb(x, 64, 4, 3) | ___bpf_mvb(x, 64, 5, 2) | ___bpf_mvb(x, 64, 6, 1) | ___bpf_mvb(x, 64, 7, 0)))
#define ___bpf_mvb(x, b, n, m)
Definition: bpf_endian.h:20
uint64_t __u64
Definition: types.h:7

◆ __bpf_be64_to_cpu

#define __bpf_be64_to_cpu (   x)    __builtin_bswap64(x)

◆ __bpf_constant_be64_to_cpu

#define __bpf_constant_be64_to_cpu (   x)    ___bpf_swab64(x)

◆ __bpf_constant_cpu_to_be64

#define __bpf_constant_cpu_to_be64 (   x)    ___bpf_swab64(x)

◆ __bpf_constant_htonl

#define __bpf_constant_htonl (   x)    ___bpf_swab32(x)

◆ __bpf_constant_htons

#define __bpf_constant_htons (   x)    ___bpf_swab16(x)

◆ __bpf_constant_ntohl

#define __bpf_constant_ntohl (   x)    ___bpf_swab32(x)

◆ __bpf_constant_ntohs

#define __bpf_constant_ntohs (   x)    ___bpf_swab16(x)

◆ __bpf_cpu_to_be64

#define __bpf_cpu_to_be64 (   x)    __builtin_bswap64(x)

◆ __bpf_htonl

#define __bpf_htonl (   x)    __builtin_bswap32(x)

◆ __bpf_htons

#define __bpf_htons (   x)    __builtin_bswap16(x)

◆ __bpf_ntohl

#define __bpf_ntohl (   x)    __builtin_bswap32(x)

◆ __bpf_ntohs

#define __bpf_ntohs (   x)    __builtin_bswap16(x)

◆ bpf_be64_to_cpu

#define bpf_be64_to_cpu (   x)    (__builtin_constant_p(x) ? __bpf_constant_be64_to_cpu(x) : __bpf_be64_to_cpu(x))

◆ bpf_cpu_to_be64

#define bpf_cpu_to_be64 (   x)    (__builtin_constant_p(x) ? __bpf_constant_cpu_to_be64(x) : __bpf_cpu_to_be64(x))

◆ bpf_htonl

#define bpf_htonl (   x)    (__builtin_constant_p(x) ? __bpf_constant_htonl(x) : __bpf_htonl(x))

◆ bpf_htons

#define bpf_htons (   x)    (__builtin_constant_p(x) ? __bpf_constant_htons(x) : __bpf_htons(x))

◆ bpf_ntohl

#define bpf_ntohl (   x)    (__builtin_constant_p(x) ? __bpf_constant_ntohl(x) : __bpf_ntohl(x))

◆ bpf_ntohs

#define bpf_ntohs (   x)    (__builtin_constant_p(x) ? __bpf_constant_ntohs(x) : __bpf_ntohs(x))

◆ htonl

#define htonl   bpf_htonl

◆ htons

#define htons   bpf_htons

◆ ntohl

#define ntohl   bpf_ntohl

◆ ntohs

#define ntohs   bpf_ntohs