DEBUGJSON commands require an own handler, since they may have their own parameters. So far there is currently only the help parameter, but more can be added in future.
Signed-off-by: Alexander Sarmanow asarmanow@gmail.com --- debug.c | 29 +++++++++++++++++++++++++++++ debug.h | 5 +++++ 2 files changed, 34 insertions(+)
diff --git a/debug.c b/debug.c index 458c137..20467c7 100644 --- a/debug.c +++ b/debug.c @@ -42,6 +42,14 @@ static void debug_table_usage(struct state *state) fprintf(stderr, " \t -m print multicast mac addresses only\n"); }
+static void debug_json_usage(struct state *state) +{ + fprintf(stderr, "Usage: batctl [options] %s|%s [parameters]\n", + state->cmd->name, state->cmd->abbr); + fprintf(stderr, "parameters:\n"); + fprintf(stderr, " \t -h print this help\n"); +} + int handle_debug_table(struct state *state, int argc, char **argv) { struct debug_table_data *debug_table = state->cmd->arg; @@ -148,3 +156,24 @@ int handle_debug_table(struct state *state, int argc, char **argv) orig_timeout, watch_interval); return err; } + +int handle_debug_json(struct state *state, int argc, char **argv) +{ + struct debug_json_data *debug_json = state->cmd->arg; + int optchar; + int err; + + while ((optchar = getopt(argc, argv, "h")) != -1) { + switch (optchar) { + case 'h': + debug_json_usage(state); + return EXIT_SUCCESS; + } + } + + check_root_or_die("batctl"); + + err = debug_json->netlink_fn(state); + + return err; +} diff --git a/debug.h b/debug.h index bfc6224..90f2e68 100644 --- a/debug.h +++ b/debug.h @@ -21,6 +21,11 @@ struct debug_table_data { unsigned int option_orig_iface:1; };
+struct debug_json_data { + int (*netlink_fn)(struct state *state); +}; + int handle_debug_table(struct state *state, int argc, char **argv); +int handle_debug_json(struct state *state, int argc, char **argv);
#endif