summaryrefslogtreecommitdiff
path: root/babeld
diff options
context:
space:
mode:
authorMatthieu Boutier <boutier@pps.jussieu.fr>2012-01-20 00:19:35 +0100
committerPaul Jakma <paul@quagga.net>2012-03-25 17:06:52 +0100
commitf1305cbfbed050ed4f389fa282bef49917ffd638 (patch)
tree5b2b264b5d4be7619b90f28225d157ed28232d27 /babeld
parentb5d43c939476b49106b1ab80b61609aba43c915d (diff)
babeld: add command (config) to set debug flags.
Diffstat (limited to 'babeld')
-rw-r--r--babeld/babel_zebra.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c
index 7ba1adfe..e68c2b70 100644
--- a/babeld/babel_zebra.c
+++ b/babeld/babel_zebra.c
@@ -46,6 +46,7 @@ THE SOFTWARE.
#include "babel_zebra.h"
#include "babel_interface.h"
#include "xroute.h"
+#include "util.h"
void babelz_zebra_init(void);
@@ -67,6 +68,22 @@ static struct {
{0, 0, NULL}
};
+/* Debug types */
+static struct {
+ int type;
+ int str_min_len;
+ const char *str;
+} debug_type[] = {
+ {BABEL_DEBUG_COMMON, 1, "common"},
+ {BABEL_DEBUG_KERNEL, 1, "kernel"},
+ {BABEL_DEBUG_FILTER, 1, "filter"},
+ {BABEL_DEBUG_TIMEOUT, 1, "timeout"},
+ {BABEL_DEBUG_IF, 1, "interface"},
+ {BABEL_DEBUG_ROUTE, 1, "route"},
+ {BABEL_DEBUG_ALL, 1, "all"},
+ {0, 0, NULL}
+};
+
/* Zebra node structure. */
struct cmd_node zebra_node =
{
@@ -252,6 +269,64 @@ DEFUN (no_babel_redistribute_type,
return CMD_WARNING;
}
+#ifndef NO_DEBUG
+/* [Babel Command] */
+DEFUN (babel_debug,
+ babel_debug_cmd,
+ "debug (common|kernel|filter|timeout|interface|route|all)",
+ "Enable debug messages for specific or all part.\n"
+ "Common messages (default)\n"
+ "Kernel messages\n"
+ "Filter messages\n"
+ "Timeout messages\n"
+ "Interface messages\n"
+ "Route messages\n"
+ "All messages\n")
+{
+ int i;
+
+ for(i = 0; debug_type[i].str != NULL; i++) {
+ if (strncmp (debug_type[i].str, argv[0],
+ debug_type[i].str_min_len) == 0) {
+ debug |= debug_type[i].type;
+ return CMD_SUCCESS;
+ }
+ }
+
+ vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
+
+ return CMD_WARNING;
+}
+
+/* [Babel Command] */
+DEFUN (no_babel_debug,
+ no_babel_debug_cmd,
+ "no debug (common|kernel|filter|timeout|interface|route|all)",
+ NO_STR
+ "Disable debug messages for specific or all part.\n"
+ "Common messages (default)\n"
+ "Kernel messages\n"
+ "Filter messages\n"
+ "Timeout messages\n"
+ "Interface messages\n"
+ "Route messages\n"
+ "All messages\n")
+{
+ int i;
+
+ for (i = 0; debug_type[i].str; i++) {
+ if (strncmp(debug_type[i].str, argv[0],
+ debug_type[i].str_min_len) == 0) {
+ debug &= ~debug_type[i].type;
+ }
+ }
+
+ vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
+
+ return CMD_WARNING;
+}
+#endif /* NO_DEBUG */
+
void babelz_zebra_init(void)
{
@@ -272,6 +347,8 @@ void babelz_zebra_init(void)
install_node (&zebra_node, zebra_config_write);
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
install_element(BABEL_NODE, &no_babel_redistribute_type_cmd);
+ install_element(BABEL_NODE, &babel_debug_cmd);
+ install_element(BABEL_NODE, &no_babel_debug_cmd);
}
static int