P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf_runtime_ubpf.h
1/*
2Copyright 2020 Orange
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef P4C_EBPF_RUNTIME_UBPF_H
18#define P4C_EBPF_RUNTIME_UBPF_H
19
20#include <stdint.h>
21#include "../../ebpf/runtime/pcap_util.h"
22#include "../../ebpf/runtime/ebpf_registry.h"
23#include "ubpf_test.h"
24
25struct standard_metadata;
26
27extern uint64_t entry(void *, struct standard_metadata *);
28typedef uint64_t (*packet_filter)(void *dp, struct standard_metadata *std_meta);
29
30void *run_and_record_output(packet_filter entry, const char *pcap_base, pcap_list_t *pkt_list, int debug);
31
32static void inline init_ubpf_table_test(char *name, unsigned int key_size, unsigned int value_size) {
33 struct bpf_table tbl = {
34 .name = name,
35 .type = 0,
36 .key_size = key_size,
37 .value_size = value_size,
38 .bpf_map = NULL
39 };
40 registry_add(&tbl);
41}
42
43
44#define ubpf_printf(fmt, args) \
45 ubpf_printf_test(fmt, args)
46#define ubpf_packet_data(ctx) \
47 ubpf_packet_data_test(ctx)
48#define ubpf_adjust_head(ctx, ofs) \
49 ubpf_adjust_head_test(ctx, ofs)
50#define ubpf_truncate_packet(ctx, maxlen) \
51 ubpf_truncate_packet_test(ctx, maxlen)
52#define ubpf_map_lookup(table, key) \
53 registry_lookup_table_elem(#table, key)
54#define ubpf_map_update(table, key, value) \
55 registry_update_table(#table, key, value, 0)
56
57#define INIT_UBPF_TABLE(name, key_size, value_size) init_ubpf_table_test("&"name, key_size, value_size)
58
59#define RUN(entry, pcap_base, num_pcaps, input_list, debug) \
60 run_and_record_output(entry, pcap_base, input_list, debug)
61#define INIT_EBPF_TABLES(debug)
62#define DELETE_EBPF_TABLES(debug)
63
64
65#endif //P4C_EBPF_RUNTIME_UBPF_H
A helper structure used to describe attributes.
Definition ebpf_registry.h:36