Add basic class along with exception and attach

Signed-off-by: varun-r-mallya <varunrmallya@gmail.com>
This commit is contained in:
2025-09-21 14:27:07 +05:30
parent ecefff6b81
commit 3c8c6deb68
8 changed files with 156 additions and 53 deletions

29
src/core/bpf_program.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef PYLIBBPF_BPF_PROGRAM_H
#define PYLIBBPF_BPF_PROGRAM_H
#include "libbpf.h"
#include <pybind11/stl.h>
#include <string>
namespace py = pybind11;
class BpfProgram {
private:
struct bpf_object* obj_;
struct bpf_program* prog_;
struct bpf_link* link_;
std::string object_path_;
std::string program_name_;
public:
explicit BpfProgram(const std::string& object_path, const std::string& program_name = "");
~BpfProgram();
bool load();
bool attach();
bool is_loaded() const { return obj_ != nullptr; }
bool is_attached() const { return link_ != nullptr; }
};
#endif //PYLIBBPF_BPF_PROGRAM_H