eBPF for Windows
Macros | Functions
ebpf_helpers.h File Reference
#include <stdint.h>
#include "ebpf_structs.h"

Go to the source code of this file.

Macros

#define MAX_TAIL_CALL_CNT   32
 
#define bpf_map   _ebpf_map_definition_in_file
 
#define SEC(name)   __attribute__((section(name), used))
 

Functions

void * bpf_map_lookup_elem (struct _ebpf_map_definition_in_file *map, void *key)
 Get a pointer to an entry in the map. More...
 
int64_t bpf_map_update_elem (struct _ebpf_map_definition_in_file *map, void *key, void *value, uint64_t flags)
 Insert or update an entry in the map. More...
 
int64_t bpf_map_delete_elem (struct _ebpf_map_definition_in_file *map, void *key)
 Remove an entry from the map. More...
 
int64_t bpf_tail_call (void *ctx, struct _ebpf_map_definition_in_file *prog_array_map, uint32_t index)
 Perform a tail call into another eBPF program. More...
 
uint32_t bpf_get_prandom_u32 ()
 Get a pseudo-random number. More...
 
uint64_t bpf_ktime_get_boot_ns ()
 Return time elapsed since boot in nanoseconds. More...
 
uint64_t bpf_get_smp_processor_id ()
 Return SMP id of the processor running the program. More...
 

Macro Definition Documentation

◆ bpf_map

#define bpf_map   _ebpf_map_definition_in_file

◆ MAX_TAIL_CALL_CNT

#define MAX_TAIL_CALL_CNT   32

◆ SEC

#define SEC (   name)    __attribute__((section(name), used))

Function Documentation

◆ bpf_get_prandom_u32()

uint32_t bpf_get_prandom_u32 ( )

Get a pseudo-random number.

Returns
A random 32-bit unsigned value.

◆ bpf_get_smp_processor_id()

uint64_t bpf_get_smp_processor_id ( )

Return SMP id of the processor running the program.

Returns
SMP id of the processor running the program.

◆ bpf_ktime_get_boot_ns()

uint64_t bpf_ktime_get_boot_ns ( )

Return time elapsed since boot in nanoseconds.

Returns
Time elapsed since boot in nanosecond units.

◆ bpf_map_delete_elem()

int64_t bpf_map_delete_elem ( struct _ebpf_map_definition_in_file map,
void *  key 
)

Remove an entry from the map.

Parameters
[in]mapMap to update.
[in]keyKey to use when searching and updating the map.
Return values
EBPF_SUCCESSThe operation was successful.
-EBPF_INVALID_ARGUMENTOne or more parameters are invalid.

◆ bpf_map_lookup_elem()

void* bpf_map_lookup_elem ( struct _ebpf_map_definition_in_file map,
void *  key 
)

Get a pointer to an entry in the map.

Parameters
[in]mapMap to search.
[in]keyKey to use when searching map.
Returns
Pointer to the value if found or NULL.

◆ bpf_map_update_elem()

int64_t bpf_map_update_elem ( struct _ebpf_map_definition_in_file map,
void *  key,
void *  value,
uint64_t  flags 
)

Insert or update an entry in the map.

Parameters
[in]mapMap to update.
[in]keyKey to use when searching and updating the map.
[in]valueValue to insert into the map.
[in]flagsMap flags.
Return values
EBPF_SUCCESSThe operation was successful.
-EBPF_NO_MEMORYUnable to allocate resources for this entry.

◆ bpf_tail_call()

int64_t bpf_tail_call ( void *  ctx,
struct _ebpf_map_definition_in_file prog_array_map,
uint32_t  index 
)

Perform a tail call into another eBPF program.

Parameters
[in]ctxContext to pass to the called program.
[in]prog_array_mapMap of program fds.
[in]indexIndex in map of program to call.
Return values
EBPF_SUCCESSThe operation was successful.
-EBPF_INVALID_ARGUMENTOne or more parameters are invalid.