eBPF for Windows
ebpf_program_types.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation
2 // SPDX-License-Identifier: MIT
3 #pragma once
4 
5 #include "ebpf_base.h"
6 #include "ebpf_result.h"
7 #include "ebpf_windows.h"
8 
9 #define EBPF_MAX_PROGRAM_DESCRIPTOR_NAME_LENGTH 256
10 #define EBPF_MAX_HELPER_FUNCTION_NAME_LENGTH 256
11 
12 // This is the type definition for the eBPF program type descriptor
13 // when version is EBPF_PROGRAM_TYPE_DESCRIPTOR_CURRENT_VERSION.
15 {
17  const char* name;
18  const ebpf_context_descriptor_t* context_descriptor;
20  uint32_t bpf_prog_type;
23 
25 {
28 
29 // This is the type definition for the eBPF helper function prototype
30 // when version is EBPF_HELPER_FUNCTION_PROTOTYPE_CURRENT_VERSION.
32 {
34  uint32_t helper_id;
35  const char* name;
36  ebpf_return_type_t return_type;
37  ebpf_argument_type_t arguments[5];
40 
41 // This is the type definition for the eBPF program information
42 // when version is EBPF_PROGRAM_INFORMATION_CURRENT_VERSION.
43 typedef struct _ebpf_program_info
44 {
52 
53 // This is the type definition for the eBPF helper function addresses
54 // when version is EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION.
56 {
61 
63  _In_reads_bytes_opt_(data_size_in) const uint8_t* data_in,
64  size_t data_size_in,
65  _In_reads_bytes_opt_(context_size_in) const uint8_t* context_in,
66  size_t context_size_in,
67  _Outptr_ void** context);
68 
70  _In_ void* context,
71  _Out_writes_bytes_to_opt_(*data_size_out, *data_size_out) uint8_t* data_out,
72  _Inout_ size_t* data_size_out,
73  _Out_writes_bytes_to_opt_(*context_size_out, *context_size_out) uint8_t* context_out,
74  _Inout_ size_t* context_size_out);
75 
76 // This is the type definition for the eBPF program data
77 // when version is EBPF_PROGRAM_DATA_CURRENT_VERSION.
78 typedef struct _ebpf_program_data
79 {
89  uint8_t required_irql;
91 
92 // This is the type definition for the eBPF program section information
93 // when version is EBPF_PROGRAM_SECTION_INFORMATION_CURRENT_VERSION.
95 {
97  const wchar_t* section_name;
99  const GUID* attach_type;
101  uint32_t bpf_attach_type;
struct _ebpf_program_type_descriptor ebpf_program_type_descriptor_t
ebpf_result_t(* ebpf_program_context_create_t)(_In_reads_bytes_opt_(data_size_in) const uint8_t *data_in, size_t data_size_in, _In_reads_bytes_opt_(context_size_in) const uint8_t *context_in, size_t context_size_in, void **context)
Definition: ebpf_program_types.h:62
struct _ebpf_program_data ebpf_program_data_t
struct _ebpf_helper_function_prototype_flags ebpf_helper_function_prototype_flags_t
void(* ebpf_program_context_destroy_t)(void *context, _Out_writes_bytes_to_opt_(*data_size_out, *data_size_out) uint8_t *data_out, _Inout_ size_t *data_size_out, _Out_writes_bytes_to_opt_(*context_size_out, *context_size_out) uint8_t *context_out, _Inout_ size_t *context_size_out)
Definition: ebpf_program_types.h:69
struct _ebpf_helper_function_prototype ebpf_helper_function_prototype_t
struct _ebpf_helper_function_addresses ebpf_helper_function_addresses_t
struct _ebpf_program_section_info ebpf_program_section_info_t
struct _ebpf_program_info ebpf_program_info_t
enum ebpf_result ebpf_result_t
uint8_t GUID[16]
Definition: ebpf_windows.h:12
Header of an eBPF extension data structure. Every eBPF extension data structure must start with this ...
Definition: ebpf_windows.h:111
Definition: ebpf_program_types.h:56
uint64_t * helper_function_address
Definition: ebpf_program_types.h:59
ebpf_extension_header_t header
Definition: ebpf_program_types.h:57
uint32_t helper_function_count
Definition: ebpf_program_types.h:58
Definition: ebpf_program_types.h:25
bool reallocate_packet
Definition: ebpf_program_types.h:26
Definition: ebpf_program_types.h:32
ebpf_argument_type_t arguments[5]
Definition: ebpf_program_types.h:37
ebpf_return_type_t return_type
Definition: ebpf_program_types.h:36
ebpf_helper_function_prototype_flags_t flags
Definition: ebpf_program_types.h:38
const char * name
Definition: ebpf_program_types.h:35
uint32_t helper_id
Definition: ebpf_program_types.h:34
ebpf_extension_header_t header
Definition: ebpf_program_types.h:33
Definition: ebpf_program_types.h:79
ebpf_extension_header_t header
Definition: ebpf_program_types.h:80
const ebpf_program_info_t * program_info
Pointer to program information.
Definition: ebpf_program_types.h:81
ebpf_program_context_destroy_t context_destroy
Pointer to context destroy function.
Definition: ebpf_program_types.h:88
const ebpf_helper_function_addresses_t * global_helper_function_addresses
Pointer to global helper function addresses being overriden.
Definition: ebpf_program_types.h:86
ebpf_program_context_create_t context_create
Pointer to context create function.
Definition: ebpf_program_types.h:87
const ebpf_helper_function_addresses_t * program_type_specific_helper_function_addresses
Definition: ebpf_program_types.h:83
uint8_t required_irql
IRQL at which the program is invoked.
Definition: ebpf_program_types.h:89
Definition: ebpf_program_types.h:44
const ebpf_program_type_descriptor_t * program_type_descriptor
Definition: ebpf_program_types.h:46
ebpf_extension_header_t header
Definition: ebpf_program_types.h:45
const ebpf_helper_function_prototype_t * global_helper_prototype
Definition: ebpf_program_types.h:50
const ebpf_helper_function_prototype_t * program_type_specific_helper_prototype
Definition: ebpf_program_types.h:48
uint32_t count_of_program_type_specific_helpers
Definition: ebpf_program_types.h:47
uint32_t count_of_global_helpers
Definition: ebpf_program_types.h:49
Definition: ebpf_program_types.h:95
const GUID * attach_type
Definition: ebpf_program_types.h:99
const wchar_t * section_name
Definition: ebpf_program_types.h:97
const GUID * program_type
Definition: ebpf_program_types.h:98
ebpf_extension_header_t header
Definition: ebpf_program_types.h:96
uint32_t bpf_attach_type
Definition: ebpf_program_types.h:101
uint32_t bpf_program_type
Definition: ebpf_program_types.h:100
Definition: ebpf_program_types.h:15
uint32_t bpf_prog_type
Definition: ebpf_program_types.h:20
const char * name
Definition: ebpf_program_types.h:17
GUID program_type
Definition: ebpf_program_types.h:19
char is_privileged
Definition: ebpf_program_types.h:21
ebpf_extension_header_t header
Definition: ebpf_program_types.h:16
const ebpf_context_descriptor_t * context_descriptor
Definition: ebpf_program_types.h:18