Skip to content

Commit

Permalink
refactor: rename struct args into struct config
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <[email protected]>
  • Loading branch information
leodido committed Jun 1, 2022
1 parent 3095206 commit f4e70fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/api.$progname.h.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "${PROGNAME}.skel.h"

#include <errno.h>
int ${OPERATION}${PROGNAME}(struct args *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb)
int ${OPERATION}${PROGNAME}(struct config *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb)
{
int err;
char buf[100];
Expand Down
10 changes: 5 additions & 5 deletions api/api.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum program {${PROGRAMS_AS_SYMBOLS}};

typedef enum program program_t;

struct args
struct config
{
bool verbose;
char ifname[IF_NAMESIZE];
Expand All @@ -35,7 +35,7 @@ typedef int (*bpf_obj_fn_t)(void *obj);

typedef int (*after_attach_fn_t)(struct bpf_tc_hook hook, struct bpf_tc_opts opts);

typedef int (*attach_fn_t)(struct args *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb);
typedef int (*attach_fn_t)(struct config *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb);

/// logging
int print_log(FILE *f, bool verbosity, bool prefix, const char *fmt, va_list argptr)
Expand All @@ -55,15 +55,15 @@ int print_log(FILE *f, bool verbosity, bool prefix, const char *fmt, va_list arg
return res;
}

void log_err(struct args *cfg, const char *fmt, ...)
void log_err(struct config *cfg, const char *fmt, ...)
{
va_list argptr;
va_start(argptr, fmt);
print_log(cfg->err_stream, cfg->verbose, true, fmt, argptr);
va_end(argptr);
}

void log_out(struct args *cfg, const char *fmt, ...)
void log_out(struct config *cfg, const char *fmt, ...)
{
va_list argptr;
va_start(argptr, fmt);
Expand All @@ -88,7 +88,7 @@ ${API}
/// dispatch
attach_fn_t attach_fn[NUM_PROGRAMS] = { ${PROGRAMS_OPS_AS_SYMBOLS} };

int attach(struct args *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb)
int attach(struct config *conf, after_attach_fn_t cb, bpf_obj_fn_t obj_cb)
{
attach_fn_t fn = attach_fn[conf->program];
if (fn) {
Expand Down
2 changes: 1 addition & 1 deletion traffico-cni.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int add_command()
err.msg = "";
err.details = "";

struct args config = {
struct config config = {
.verbose = false,
.cleanup_on_exit = false,
};
Expand Down
2 changes: 1 addition & 1 deletion traffico.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const struct argp_option argp_opts[] = {

};

static struct args g_config;
static struct config g_config;

#define log_erro(fmt, ...) \
log_err(&g_config, fmt, ##__VA_ARGS__);
Expand Down

0 comments on commit f4e70fd

Please sign in to comment.