add map support

This commit is contained in:
2025-09-21 23:55:10 +05:30
parent 0a27d5a520
commit e5a946a767
9 changed files with 349 additions and 31 deletions

View File

@ -3,7 +3,7 @@
#include <filesystem>
#include <utility>
BpfProgram::BpfProgram(std::string object_path, std::string program_name)
BpfProgram::BpfProgram(std::string object_path, std::string program_name)
: obj_(nullptr), prog_(nullptr), link_(nullptr),
object_path_(std::move(object_path)), program_name_(std::move(program_name)) {
}
@ -15,6 +15,10 @@ BpfProgram::~BpfProgram() {
}
}
struct bpf_object * BpfProgram::get_obj() const {
return obj_;
}
bool BpfProgram::load() {
// Open the eBPF object file
obj_ = bpf_object__open_file(object_path_.c_str(), nullptr);
@ -48,8 +52,7 @@ bool BpfProgram::load() {
}
bool BpfProgram::attach() {
for (auto [prog, link] : programs)
{
for (auto [prog, link]: programs) {
if (!prog) {
throw BpfException("Program not loaded");
}
@ -66,7 +69,7 @@ bool BpfProgram::attach() {
bool BpfProgram::destroy() {
bool success = true;
for (auto [prog, link] : programs) {
for (auto [prog, link]: programs) {
if (!prog) {
throw BpfException("Program not loaded");
}