Skip to content

Commit

Permalink
Add testing for scanf/printf in python, deprecate table_update
Browse files Browse the repository at this point in the history
Signed-off-by: Brenden Blanco <[email protected]>
  • Loading branch information
Brenden Blanco committed Aug 12, 2015
1 parent f8ee5bf commit 2582ecf
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 151 deletions.
30 changes: 12 additions & 18 deletions src/cc/bpf_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ size_t bpf_num_tables(void *program) {
return mod->num_tables();
}

size_t bpf_table_id(void *program, const char *table_name) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return ~0ull;
return mod->table_id(table_name);
}

int bpf_table_fd(void *program, const char *table_name) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return -1;
Expand Down Expand Up @@ -170,38 +176,26 @@ size_t bpf_table_leaf_size_id(void *program, size_t id) {
return mod->table_leaf_size(id);
}

int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_update(table_name, key, leaf);
}

int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_update(id, key, leaf);
}

int bpf_table_key_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *key) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
if (!mod) return -1;
return mod->table_key_printf(id, buf, buflen, key);
}
int bpf_table_leaf_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_key_printf(id, buf, buflen, leaf);
if (!mod) return -1;
return mod->table_leaf_printf(id, buf, buflen, leaf);
}

int bpf_table_key_sscanf(void *program, size_t id, const char *buf, void *key) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
if (!mod) return -1;
return mod->table_key_scanf(id, buf, key);
}
int bpf_table_leaf_sscanf(void *program, size_t id, const char *buf, void *leaf) {
auto mod = static_cast<ebpf::BPFModule *>(program);
if (!mod) return 0;
return mod->table_key_scanf(id, buf, leaf);
if (!mod) return -1;
return mod->table_leaf_scanf(id, buf, leaf);
}

}
3 changes: 1 addition & 2 deletions src/cc/bpf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void * bpf_function_start(void *program, const char *name);
size_t bpf_function_size_id(void *program, size_t id);
size_t bpf_function_size(void *program, const char *name);
size_t bpf_num_tables(void *program);
size_t bpf_table_id(void *program, const char *table_name);
int bpf_table_fd(void *program, const char *table_name);
int bpf_table_fd_id(void *program, size_t id);
const char * bpf_table_name(void *program, size_t id);
Expand All @@ -52,8 +53,6 @@ int bpf_table_key_snprintf(void *program, size_t id, char *buf, size_t buflen, c
int bpf_table_leaf_snprintf(void *program, size_t id, char *buf, size_t buflen, const void *leaf);
int bpf_table_key_sscanf(void *program, size_t id, const char *buf, void *key);
int bpf_table_leaf_sscanf(void *program, size_t id, const char *buf, void *leaf);
int bpf_table_update(void *program, const char *table_name, const char *key, const char *leaf);
int bpf_table_update_id(void *program, size_t id, const char *key, const char *leaf);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 2582ecf

Please sign in to comment.