8typedef signed char int8_t;
11typedef long long int64_t;
12typedef unsigned char uint8_t;
13typedef unsigned short uint16_t;
14typedef unsigned int uint32_t;
15typedef unsigned long long uint64_t;
19#define UINT32_MAX ((uint32_t)0xFFFFFFFF)
32#define UBPF_STACK_SIZE 512
34#define IMMEDIATE(X) (int32_t) X
35#define OFFSET(X) (int16_t) X
36#define POINTER(X) (uint64_t)(X)
39#define htobe16(X) swap16(X)
40#define htobe32(X) swap32(X)
41#define htobe64(X) swap64(X)
48#if !defined(UNREFERENCED_PARAMETER)
49#define UNREFERENCED_PARAMETER(P) (P)
52 typedef uint64_t (*
helper_function_t)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t,
void*);
183 _Out_
size_t* count);
186 _Out_
size_t* count);
188 _Outptr_result_buffer_maybenull_(*
size)
const uint8_t**
hash,
193 _Out_
size_t* count);
196 _Out_
size_t* count);
208 return value << 8 | value >> 8;
220 return swap16(value >> 16) | ((uint32_t)
swap16(value & ((1 << 16) - 1))) << 16;
232 return swap32(value >> 32) | ((uint64_t)
swap32(value & ((1ull << 32ull) - 1))) << 32;
235#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION 1
236#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(helper_function_entry_t, name)
237#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(helper_function_entry_t)
238#define EBPF_NATIVE_HELPER_FUNCTION_ENTRY_HEADER \
239 {EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION, \
240 EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_SIZE, \
241 EBPF_NATIVE_HELPER_FUNCTION_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
243#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION 1
244#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_SIZE \
245 EBPF_SIZE_INCLUDING_FIELD(helper_function_data_t, tail_call)
246#define EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(helper_function_data_t)
247#define EBPF_NATIVE_HELPER_FUNCTION_DATA_HEADER \
248 {EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION, \
249 EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_SIZE, \
250 EBPF_NATIVE_HELPER_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE}
252#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION 1
253#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_entry_t, name)
254#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(map_entry_t)
255#define EBPF_NATIVE_MAP_ENTRY_HEADER \
256 {EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION, \
257 EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE, \
258 EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
260#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION 1
261#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_data_t, address)
262#define EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(map_data_t)
263#define EBPF_NATIVE_MAP_DATA_HEADER \
264 {EBPF_NATIVE_MAP_DATA_CURRENT_VERSION, \
265 EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_SIZE, \
266 EBPF_NATIVE_MAP_DATA_CURRENT_VERSION_TOTAL_SIZE}
268#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION 1
269#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_SIZE \
270 EBPF_SIZE_INCLUDING_FIELD(program_entry_t, program_info_hash_type)
271#define EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(program_entry_t)
272#define EBPF_NATIVE_PROGRAM_ENTRY_HEADER \
273 {EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION, \
274 EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_SIZE, \
275 EBPF_NATIVE_PROGRAM_ENTRY_CURRENT_VERSION_TOTAL_SIZE}
277#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION 1
278#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_SIZE \
279 EBPF_SIZE_INCLUDING_FIELD(program_runtime_context_t, map_data)
280#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_TOTAL_SIZE sizeof(program_runtime_context_t)
281#define EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_HEADER \
282 {EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION, \
283 EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_SIZE, \
284 EBPF_NATIVE_PROGRAM_RUNTIME_CONTEXT_CURRENT_VERSION_TOTAL_SIZE}
286#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION 1
287#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_initial_values_t, values)
288#define EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_TOTAL_SIZE sizeof(map_initial_values_t)
289#define EBPF_NATIVE_MAP_INITIAL_VALUES_HEADER \
290 {EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION, \
291 EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_SIZE, \
292 EBPF_NATIVE_MAP_INITIAL_VALUES_CURRENT_VERSION_TOTAL_SIZE}
294#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION 1
295#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_SIZE \
296 EBPF_SIZE_INCLUDING_FIELD(global_variable_section_info_t, initial_data)
297#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_TOTAL_SIZE sizeof(global_variable_section_info_t)
298#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_HEADER \
299 {EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION, \
300 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_SIZE, \
301 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_INFO_CURRENT_VERSION_TOTAL_SIZE}
303#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION 1
304#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_SIZE \
305 EBPF_SIZE_INCLUDING_FIELD(global_variable_section_data_t, address_of_map_value)
306#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_TOTAL_SIZE sizeof(global_variable_section_data_t)
307#define EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_HEADER \
308 {EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION, \
309 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_SIZE, \
310 EBPF_NATIVE_GLOBAL_VARIABLE_SECTION_DATA_CURRENT_VERSION_TOTAL_SIZE}
312#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION 1
313#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(metadata_table_t, map_initial_values)
314#define EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_TOTAL_SIZE sizeof(metadata_table_t)
315#define EBPF_NATIVE_METADATA_TABLE_HEADER \
316 {EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION, \
317 EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_SIZE, \
318 EBPF_NATIVE_METADATA_TABLE_CURRENT_VERSION_TOTAL_SIZE}
struct _program_runtime_context program_runtime_context_t
struct _global_variable_section_info global_variable_section_info_t
struct _helper_function_data helper_function_data_t
uint64_t swap64(uint64_t value)
Inline function used to implement the 64 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:230
uint64_t(* helper_function_t)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, void *)
Definition bpf2c.h:52
struct _map_initial_values map_initial_values_t
Map initial values. This structure contains the initial values for a map. The values are used to init...
struct _map_entry map_entry_t
Map entry. This structure contains the address of the map and the map definition. The address is writ...
struct _helper_function_entry helper_function_entry_t
Helper function entry. This structure defines a helper function entry in the metadata table....
uint32_t swap32(uint32_t value)
Inline function used to implement the 32 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:218
struct _global_variable_section_data global_variable_section_data_t
uint16_t swap16(uint16_t value)
Inline function used to implement the 16 bit EBPF_OP_LE/EBPF_OP_BE instruction.
Definition bpf2c.h:206
struct _program_entry program_entry_t
Program entry. This structure contains the address of the program and additional information about th...
struct _bpf2c_version bpf2c_version_t
Version information for the bpf2c compiler. This structure contains the version information for the b...
struct _metadata_table metadata_table_t
Metadata table for a module. This structure is returned by the module's metadata function,...
struct _map_data map_data_t
This file contains eBPF definitions common to eBPF programs, core execution engine as well as eBPF AP...
GUID ebpf_attach_type_t
Definition ebpf_windows.h:62
GUID ebpf_program_type_t
Definition ebpf_windows.h:61
Version information for the bpf2c compiler. This structure contains the version information for the b...
Definition bpf2c.h:167
uint32_t major
Definition bpf2c.h:168
uint32_t revision
Definition bpf2c.h:170
uint32_t minor
Definition bpf2c.h:169
eBPF Map Definition as it appears in the maps section of an ELF file.
Definition ebpf_structs.h:119
unsigned char * address_of_map_value
Definition bpf2c.h:122
ebpf_native_module_header_t header
Definition bpf2c.h:121
size_t size
Definition bpf2c.h:115
const void * initial_data
Definition bpf2c.h:116
const char * name
Definition bpf2c.h:114
ebpf_native_module_header_t header
Definition bpf2c.h:113
bool tail_call
Definition bpf2c.h:71
helper_function_t address
Definition bpf2c.h:70
ebpf_native_module_header_t header
Definition bpf2c.h:69
Helper function entry. This structure defines a helper function entry in the metadata table....
Definition bpf2c.h:61
const char * name
Definition bpf2c.h:64
uint32_t helper_id
Definition bpf2c.h:63
ebpf_native_module_header_t header
Definition bpf2c.h:62
uintptr_t address
Definition bpf2c.h:94
ebpf_native_module_header_t header
Definition bpf2c.h:93
Map entry. This structure contains the address of the map and the map definition. The address is writ...
Definition bpf2c.h:80
ebpf_map_definition_in_file_t definition
Definition bpf2c.h:87
uint64_t zero_marker[2]
Definition bpf2c.h:84
ebpf_native_module_header_t header
Definition bpf2c.h:86
const char * name
Definition bpf2c.h:88
Map initial values. This structure contains the initial values for a map. The values are used to init...
Definition bpf2c.h:104
const char ** values
Definition bpf2c.h:108
size_t count
Definition bpf2c.h:107
ebpf_native_module_header_t header
Definition bpf2c.h:105
const char * name
Definition bpf2c.h:106
Program entry. This structure contains the address of the program and additional information about th...
Definition bpf2c.h:138
uint16_t helper_count
Number of helper functions used by the program.
Definition bpf2c.h:152
uint64_t zero
Definition bpf2c.h:142
const char * program_info_hash_type
Type of the program info hash.
Definition bpf2c.h:158
uint16_t referenced_map_count
Number of maps referenced by the program.
Definition bpf2c.h:150
const char * program_name
Name of the program.
Definition bpf2c.h:148
size_t bpf_instruction_count
Number of BPF instructions in the program.
Definition bpf2c.h:153
uint64_t(* function)(void *, const program_runtime_context_t *)
Address of the program.
Definition bpf2c.h:145
ebpf_native_module_header_t header
Definition bpf2c.h:144
size_t program_info_hash_length
Length of the program info hash.
Definition bpf2c.h:157
uint16_t * referenced_map_indices
List of map indices referenced by the program.
Definition bpf2c.h:149
ebpf_attach_type_t * expected_attach_type
Expected attach type of the program.
Definition bpf2c.h:155
const char * pe_section_name
Name of the PE section containing the program.
Definition bpf2c.h:146
const uint8_t * program_info_hash
Hash of the program info.
Definition bpf2c.h:156
const char * section_name
Name of the section containing the program.
Definition bpf2c.h:147
ebpf_program_type_t * program_type
Type of the program.
Definition bpf2c.h:154
helper_function_entry_t * helpers
List of helper functions used by the program.
Definition bpf2c.h:151
map_data_t * map_data
Definition bpf2c.h:129
global_variable_section_data_t * global_variable_section_data
Definition bpf2c.h:130
helper_function_data_t * helper_data
Definition bpf2c.h:128
ebpf_native_module_header_t header
Definition bpf2c.h:127