-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimal_syscall_server.cpp
29 lines (26 loc) · 1.01 KB
/
minimal_syscall_server.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "attach_manager.hpp"
#include "nginx_module_attach_impl.hpp"
#include <cassert>
#include <memory>
#include <optional>
using namespace bpftime;
static std::optional<std::unique_ptr<bpftime::attach_manager>> manager;
extern "C" int bpftime__initialize_nginx_handler() {
manager = std::make_unique<bpftime::attach_manager>();
auto &man = *manager;
man->register_attach_impl(bpftime::attach_target_type::NGINX_URL_HANDLER,
std::make_unique<nginx_module_attach_impl>());
auto &provider = *man->get_event_provider();
uint64_t insn = 0;
int prog_id = provider.create_bpftime_program(&insn, 1, "my_prog", 0);
assert(prog_id >= 0);
int target_id = provider.create_nginx_url_handler_attach_target();
assert(target_id >= 0);
int link_id = provider.attach_bpftime_program_at(prog_id, target_id);
assert(link_id >= 0);
provider.enable_attach_link(link_id);
return 0;
}
extern "C" int bpftime__instantiate_attaches() {
return (*manager)->get_event_provider()->instantiate_attach();
}