22#ifndef BACKENDS_EBPF_RUNTIME_EBPF_USER_H_
23#define BACKENDS_EBPF_RUNTIME_EBPF_USER_H_
25#include "ebpf_registry.h"
26#include "ebpf_common.h"
32#define htonll(x) htobe64(x)
33#define ntohll(x) be64toh(x)
35#define bpf_htons(x) htobe16(x)
36#define bpf_ntohs(x) be16toh(x)
37#define bpf_htonl(x) htobe32(x)
38#define bpf_ntohl(x) be32toh(x)
39#define bpf_cpu_to_be64(x) htobe64(x)
40#define bpf_be64_to_cpu(x) be64toh(x)
42#define load_byte(data, b) (*(((u8*)(data)) + (b)))
43#define load_half(data, b) bpf_ntohs(*(u16 *)((u8*)(data) + (b)))
44#define load_word(data, b) bpf_ntohl(*(u32 *)((u8*)(data) + (b)))
45#define load_dword(data, b) bpf_be64_to_cpu(*(u64 *)((u8*)(data) + (b)))
49#define bpf_printk(fmt, ...) \
51 char ____fmt[] = fmt; \
52 printf(____fmt, sizeof(____fmt), \
83#define SK_BUFF struct sk_buff
84#define REGISTER_START() \
85struct bpf_table tables[] = {
86#define REGISTER_TABLE(NAME, TYPE, KEY_SIZE, VALUE_SIZE, MAX_ENTRIES) \
87 { MAP_PATH"/"#NAME, TYPE, KEY_SIZE, VALUE_SIZE, MAX_ENTRIES, NULL },
88#define REGISTER_END() \
92#define BPF_MAP_LOOKUP_ELEM(table, key) \
93 registry_lookup_table_elem(MAP_PATH"/"#table, key)
94#define BPF_MAP_UPDATE_ELEM(table, key, value, flags) \
95 registry_update_table(MAP_PATH"/"#table, key, value, flags)
96#define BPF_MAP_DELETE_ELEM(table, key) \
97 registry_delete_table_elem(MAP_PATH"/"#table, key)
98#define BPF_USER_MAP_UPDATE_ELEM(index, key, value, flags)\
99 registry_update_table_id(index, key, value, flags)
100#define BPF_OBJ_PIN(table, name) registry_add(table)
101#define BPF_OBJ_GET(name) registry_get_id(name)
106extern int ebpf_filter(
struct sk_buff *skb);
110static inline void print_n_bytes(
void *receiveBuffer,
int num) {
111 for (
int i = 0; i < num; i++)
112 printf(
"%02x", ((
unsigned char *)receiveBuffer)[i]);
A helper structure used to describe attributes.
Definition ebpf_registry.h:36
simple descriptor which replaces the kernel sk_buff structure.
Definition ebpf_test.h:63