ikev2: better logging
[vpp.git] / src / plugins / ikev2 / ikev2_cli.c
index 8801793..2ca1a5c 100644 (file)
@@ -584,14 +584,46 @@ VLIB_CLI_COMMAND (ikev2_initiate_command, static) = {
 };
 /* *INDENT-ON* */
 
+void
+ikev2_cli_reference (void)
+{
+}
 
-clib_error_t *
-ikev2_cli_init (vlib_main_t * vm)
+static clib_error_t *
+ikev2_set_log_level_command_fn (vlib_main_t * vm,
+                               unformat_input_t * input,
+                               vlib_cli_command_t * cmd)
 {
-  return 0;
+  unformat_input_t _line_input, *line_input = &_line_input;
+  u8 log_level = IKEV2_LOG_NONE;
+  clib_error_t *error = 0;
+
+  /* Get a line of input. */
+  if (!unformat_user (input, unformat_line_input, line_input))
+    return 0;
+
+  if (!unformat (line_input, "%d", &log_level))
+    {
+      error = clib_error_return (0, "unknown input '%U'",
+                                format_unformat_error, line_input);
+      goto done;
+    }
+  int rc = ikev2_set_log_level (log_level);
+  if (rc < 0)
+    error = clib_error_return (0, "setting log level failed!");
+
+done:
+  unformat_free (line_input);
+  return error;
 }
 
-VLIB_INIT_FUNCTION (ikev2_cli_init);
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (ikev2_set_log_level_command, static) = {
+  .path = "ikev2 set logging level",
+  .function = ikev2_set_log_level_command_fn,
+  .short_help = "ikev2 set logging level <0-5>",
+};
+/* *INDENT-ON* */
 
 /*
  * fd.io coding-style-patch-verification: ON