eBPF for Windows
bpf_helpers.h
Go to the documentation of this file.
1 // Copyright (c) eBPF for Windows contributors
2 // SPDX-License-Identifier: MIT
3 #pragma once
4 
5 // Include platform-specific definitions.
6 #include "bpf_helpers_platform.h"
7 #include "ebpf_structs.h"
8 
9 #if !defined(_MSVC_VER)
10 
11 // BTF macros recreated from Linux kernel docs and dumping the BTF of the
12 // compiled ELF files.
13 //
14 // __uint and __type
15 // https://www.kernel.org/doc/html/latest/bpf/btf.html
16 // __array
17 // https://www.kernel.org/doc/html/next/bpf/map_of_maps.html
18 
22 #define __uint(field_name, field_value) int(*field_name)[field_value]
23 
27 #define __type(field_name, field_type) typeof(field_type)* field_name
28 
32 #define __array(field_name, map_template) typeof(map_template)* field_name[]
33 
34 // SEC macro recreated from LLVM docs:
35 // https://clang.llvm.org/docs/AttributeReference.html
36 
40 #define SEC(NAME) __attribute__((section(NAME)))
41 
42 #define bpf_map_def _ebpf_map_definition_in_file
43 #include "ebpf_nethooks.h"
44 
45 #endif
46 
47 #if !defined(NULL)
48 #define NULL ((void*)0)
49 #endif
50 
51 #if !defined(__doxygen)
52 #define EBPF_HELPER(return_type, name, args) typedef return_type(*const name##_t) args
53 #endif
54 
55 #include "bpf_helper_defs.h"
56 
57 #if !defined(_WIN32)
58 #define _WIN32
59 #endif
This file contains platform specific defines used by eBPF programs.
This file contains eBPF definitions common to eBPF programs, core execution engine as well as eBPF AP...