-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from plumgrid/issue16
Address some of Issue #16
- Loading branch information
Showing
12 changed files
with
265 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,59 @@ | ||
#include "cc/bpf_program.h" | ||
#include "cc/bpf_module.h" | ||
#include "cc/bpf_common.h" | ||
|
||
extern "C" { | ||
void * bpf_program_create(const char *filename, const char *proto_filename, unsigned flags) { | ||
auto prog = new ebpf::BPFProgram(flags); | ||
if (prog->load(filename, proto_filename) != 0) { | ||
delete prog; | ||
void * bpf_module_create(const char *filename, const char *proto_filename, unsigned flags) { | ||
auto mod = new ebpf::BPFModule(flags); | ||
if (mod->load(filename, proto_filename) != 0) { | ||
delete mod; | ||
return nullptr; | ||
} | ||
return prog; | ||
return mod; | ||
} | ||
|
||
void bpf_program_destroy(void *program) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return; | ||
delete prog; | ||
void * bpf_module_create_from_string(const char *text, unsigned flags) { | ||
auto mod = new ebpf::BPFModule(flags); | ||
if (mod->load_string(text) != 0) { | ||
delete mod; | ||
return nullptr; | ||
} | ||
return mod; | ||
} | ||
|
||
void bpf_module_destroy(void *program) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return; | ||
delete mod; | ||
} | ||
|
||
void * bpf_program_start(void *program, const char *name) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return nullptr; | ||
return prog->start(name); | ||
void * bpf_function_start(void *program, const char *name) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return nullptr; | ||
return mod->start(name); | ||
} | ||
|
||
size_t bpf_program_size(void *program, const char *name) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return 0; | ||
return prog->size(name); | ||
size_t bpf_function_size(void *program, const char *name) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return 0; | ||
return mod->size(name); | ||
} | ||
|
||
char * bpf_program_license(void *program) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return nullptr; | ||
return prog->license(); | ||
char * bpf_module_license(void *program) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return nullptr; | ||
return mod->license(); | ||
} | ||
|
||
unsigned bpf_program_kern_version(void *program) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return 0; | ||
return prog->kern_version(); | ||
unsigned bpf_module_kern_version(void *program) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return 0; | ||
return mod->kern_version(); | ||
} | ||
|
||
int bpf_program_table_fd(void *program, const char *table_name) { | ||
auto prog = static_cast<ebpf::BPFProgram *>(program); | ||
if (!prog) return -1; | ||
return prog->table_fd(table_name); | ||
int bpf_table_fd(void *program, const char *table_name) { | ||
auto mod = static_cast<ebpf::BPFModule *>(program); | ||
if (!mod) return -1; | ||
return mod->table_fd(table_name); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.