eBPF for Windows
Data Structures | Macros | Typedefs | Functions
bpf2c.h File Reference
#include "ebpf_structs.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  _helper_function_entry
 Helper function entry. This structure defines a helper function entry in the metadata table. The address of the helper function is written into the entry during load time. The helper_id and name are used to identify the helper function to bind to when the program is loaded. More...
 
struct  _map_entry
 Map entry. This structure contains the address of the map and the map definition. The address is written into the entry during load time. The map definition is used to initialize the map when the program is loaded. More...
 
struct  _map_initial_values
 Map initial values. This structure contains the initial values for a map. The values are used to initialize the map when the program is loaded. Values are specified as strings and are converted to the appropriate type based on the map definition. Only BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_PROG_ARRAY map types are supported. More...
 
struct  _program_entry
 Program entry. This structure contains the address of the program and additional information about the program. More...
 
struct  _bpf2c_version
 Version information for the bpf2c compiler. This structure contains the version information for the bpf2c compiler that generated the module. It can be used to determine if the module is compatible with the current version of the eBPF for Windows runtime. More...
 
struct  _metadata_table
 Metadata table for a module. This structure is returned by the module's metadata function, get_metadata_table and contains information about the module including the list of programs and maps. More...
 

Macros

#define UBPF_STACK_SIZE   512
 
#define IMMEDIATE(X)   (int32_t) X
 
#define OFFSET(X)   (int16_t) X
 
#define POINTER(X)   (uint64_t)(X)
 
#define htobe16(X)   swap16(X)
 
#define htobe32(X)   swap32(X)
 
#define htobe64(X)   swap64(X)
 
#define htole16(X)   (X)
 
#define htole32(X)   (X)
 
#define htole64(X)   (X)
 

Typedefs

typedef struct _helper_function_entry helper_function_entry_t
 Helper function entry. This structure defines a helper function entry in the metadata table. The address of the helper function is written into the entry during load time. The helper_id and name are used to identify the helper function to bind to when the program is loaded. More...
 
typedef struct _map_entry map_entry_t
 Map entry. This structure contains the address of the map and the map definition. The address is written into the entry during load time. The map definition is used to initialize the map when the program is loaded. More...
 
typedef 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 initialize the map when the program is loaded. Values are specified as strings and are converted to the appropriate type based on the map definition. Only BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_PROG_ARRAY map types are supported. More...
 
typedef struct _program_entry program_entry_t
 Program entry. This structure contains the address of the program and additional information about the program. More...
 
typedef struct _bpf2c_version bpf2c_version_t
 Version information for the bpf2c compiler. This structure contains the version information for the bpf2c compiler that generated the module. It can be used to determine if the module is compatible with the current version of the eBPF for Windows runtime. More...
 
typedef struct _metadata_table metadata_table_t
 Metadata table for a module. This structure is returned by the module's metadata function, get_metadata_table and contains information about the module including the list of programs and maps. More...
 

Functions

uint16_t swap16 (uint16_t value)
 Inline function used to implement the 16 bit EBPF_OP_LE/EBPF_OP_BE instruction. More...
 
uint32_t swap32 (uint32_t value)
 Inline function used to implement the 32 bit EBPF_OP_LE/EBPF_OP_BE instruction. More...
 
uint64_t swap64 (uint64_t value)
 Inline function used to implement the 64 bit EBPF_OP_LE/EBPF_OP_BE instruction. More...
 

Macro Definition Documentation

◆ htobe16

#define htobe16 (   X)    swap16(X)

◆ htobe32

#define htobe32 (   X)    swap32(X)

◆ htobe64

#define htobe64 (   X)    swap64(X)

◆ htole16

#define htole16 (   X)    (X)

◆ htole32

#define htole32 (   X)    (X)

◆ htole64

#define htole64 (   X)    (X)

◆ IMMEDIATE

#define IMMEDIATE (   X)    (int32_t) X

◆ OFFSET

#define OFFSET (   X)    (int16_t) X

◆ POINTER

#define POINTER (   X)    (uint64_t)(X)

◆ UBPF_STACK_SIZE

#define UBPF_STACK_SIZE   512

Typedef Documentation

◆ bpf2c_version_t

Version information for the bpf2c compiler. This structure contains the version information for the bpf2c compiler that generated the module. It can be used to determine if the module is compatible with the current version of the eBPF for Windows runtime.

◆ helper_function_entry_t

Helper function entry. This structure defines a helper function entry in the metadata table. The address of the helper function is written into the entry during load time. The helper_id and name are used to identify the helper function to bind to when the program is loaded.

◆ map_entry_t

typedef struct _map_entry map_entry_t

Map entry. This structure contains the address of the map and the map definition. The address is written into the entry during load time. The map definition is used to initialize the map when the program is loaded.

◆ map_initial_values_t

Map initial values. This structure contains the initial values for a map. The values are used to initialize the map when the program is loaded. Values are specified as strings and are converted to the appropriate type based on the map definition. Only BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_PROG_ARRAY map types are supported.

◆ metadata_table_t

Metadata table for a module. This structure is returned by the module's metadata function, get_metadata_table and contains information about the module including the list of programs and maps.

◆ program_entry_t

Program entry. This structure contains the address of the program and additional information about the program.

Function Documentation

◆ swap16()

uint16_t swap16 ( uint16_t  value)
inline

Inline function used to implement the 16 bit EBPF_OP_LE/EBPF_OP_BE instruction.

Parameters
[in]valueThe value to swap.
Returns
The swapped value.

◆ swap32()

uint32_t swap32 ( uint32_t  value)
inline

Inline function used to implement the 32 bit EBPF_OP_LE/EBPF_OP_BE instruction.

Parameters
[in]valueThe value to swap.
Returns
The swapped value.

◆ swap64()

uint64_t swap64 ( uint64_t  value)
inline

Inline function used to implement the 64 bit EBPF_OP_LE/EBPF_OP_BE instruction.

Parameters
[in]valueThe value to swap.
Returns
The swapped value.