]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/ldp_debug.c
Merge branch 'master' into docs-user
[mirror_frr.git] / ldpd / ldp_debug.c
index 7915fb709d57be8e49d9459cec9c50715ef4b6e9..39e20ef7c84d467d2b2081af8823653be3a0df29 100644 (file)
@@ -38,62 +38,67 @@ struct cmd_node ldp_debug_node =
 };
 
 int
-ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
-    const char *dir_str, int all)
+ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
+    const char *dir_str, const char *all)
 {
        if (strcmp(type_str, "discovery") == 0) {
                if (dir_str == NULL)
-                       return (CMD_WARNING);
+                       return (CMD_WARNING_CONFIG_FAILED);
 
                if (dir_str[0] == 'r') {
-                       if (disable)
-                               DEBUG_OFF(hello, HELLO_RECV);
+                       if (negate)
+                               DEBUG_OFF(hello, LDP_DEBUG_HELLO_RECV);
                        else
-                               DEBUG_ON(hello, HELLO_RECV);
+                               DEBUG_ON(hello, LDP_DEBUG_HELLO_RECV);
                } else {
-                       if (disable)
-                               DEBUG_OFF(hello, HELLO_SEND);
+                       if (negate)
+                               DEBUG_OFF(hello, LDP_DEBUG_HELLO_SEND);
                        else
-                               DEBUG_ON(hello, HELLO_SEND);
+                               DEBUG_ON(hello, LDP_DEBUG_HELLO_SEND);
                }
        } else if (strcmp(type_str, "errors") == 0) {
-               if (disable)
-                       DEBUG_OFF(errors, ERRORS);
+               if (negate)
+                       DEBUG_OFF(errors, LDP_DEBUG_ERRORS);
                else
-                       DEBUG_ON(errors, ERRORS);
+                       DEBUG_ON(errors, LDP_DEBUG_ERRORS);
        } else if (strcmp(type_str, "event") == 0) {
-               if (disable)
-                       DEBUG_OFF(event, EVENT);
+               if (negate)
+                       DEBUG_OFF(event, LDP_DEBUG_EVENT);
                else
-                       DEBUG_ON(event, EVENT);
+                       DEBUG_ON(event, LDP_DEBUG_EVENT);
+       } else if (strcmp(type_str, "labels") == 0) {
+               if (negate)
+                       DEBUG_OFF(labels, LDP_DEBUG_LABELS);
+               else
+                       DEBUG_ON(labels, LDP_DEBUG_LABELS);
        } else if (strcmp(type_str, "messages") == 0) {
                if (dir_str == NULL)
-                       return (CMD_WARNING);
+                       return (CMD_WARNING_CONFIG_FAILED);
 
                if (dir_str[0] == 'r') {
-                       if (disable) {
-                               DEBUG_OFF(msg, MSG_RECV);
-                               DEBUG_OFF(msg, MSG_RECV_ALL);
+                       if (negate) {
+                               DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV);
+                               DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV_ALL);
                        } else {
-                               DEBUG_ON(msg, MSG_RECV);
+                               DEBUG_ON(msg, LDP_DEBUG_MSG_RECV);
                                if (all)
-                                       DEBUG_ON(msg, MSG_RECV_ALL);
+                                       DEBUG_ON(msg, LDP_DEBUG_MSG_RECV_ALL);
                        }
                } else {
-                       if (disable) {
-                               DEBUG_OFF(msg, MSG_SEND);
-                               DEBUG_OFF(msg, MSG_SEND_ALL);
+                       if (negate) {
+                               DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND);
+                               DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND_ALL);
                        } else {
-                               DEBUG_ON(msg, MSG_SEND);
+                               DEBUG_ON(msg, LDP_DEBUG_MSG_SEND);
                                if (all)
-                                       DEBUG_ON(msg, MSG_SEND_ALL);
+                                       DEBUG_ON(msg, LDP_DEBUG_MSG_SEND_ALL);
                        }
                }
        } else if (strcmp(type_str, "zebra") == 0) {
-               if (disable)
-                       DEBUG_OFF(zebra, ZEBRA);
+               if (negate)
+                       DEBUG_OFF(zebra, LDP_DEBUG_ZEBRA);
                else
-                       DEBUG_ON(zebra, ZEBRA);
+                       DEBUG_ON(zebra, LDP_DEBUG_ZEBRA);
        }
 
        main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
@@ -105,33 +110,31 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
 int
 ldp_vty_show_debugging(struct vty *vty)
 {
-       vty_out(vty, "LDP debugging status:%s", VTY_NEWLINE);
-
-       if (LDP_DEBUG(hello, HELLO_RECV))
-               vty_out(vty, "  LDP discovery debugging is on (inbound)%s",
-                   VTY_NEWLINE);
-       if (LDP_DEBUG(hello, HELLO_SEND))
-               vty_out(vty, "  LDP discovery debugging is on (outbound)%s",
-                   VTY_NEWLINE);
-       if (LDP_DEBUG(errors, ERRORS))
-               vty_out(vty, "  LDP errors debugging is on%s", VTY_NEWLINE);
-       if (LDP_DEBUG(event, EVENT))
-               vty_out(vty, "  LDP events debugging is on%s", VTY_NEWLINE);
-       if (LDP_DEBUG(msg, MSG_RECV_ALL))
-               vty_out(vty, "  LDP detailed messages debugging is on "
-                   "(inbound)%s", VTY_NEWLINE);
-       else if (LDP_DEBUG(msg, MSG_RECV))
-               vty_out(vty, "  LDP messages debugging is on (inbound)%s",
-                   VTY_NEWLINE);
-       if (LDP_DEBUG(msg, MSG_SEND_ALL))
-               vty_out(vty, "  LDP detailed messages debugging is on "
-                   "(outbound)%s", VTY_NEWLINE);
-       else if (LDP_DEBUG(msg, MSG_SEND))
-               vty_out(vty, "  LDP messages debugging is on (outbound)%s",
-                   VTY_NEWLINE);
-       if (LDP_DEBUG(zebra, ZEBRA))
-               vty_out(vty, "  LDP zebra debugging is on%s", VTY_NEWLINE);
-       vty_out (vty, "%s", VTY_NEWLINE);
+       vty_out (vty, "LDP debugging status:\n");
+
+       if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV))
+               vty_out (vty,"  LDP discovery debugging is on (inbound)\n");
+       if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND))
+               vty_out (vty,"  LDP discovery debugging is on (outbound)\n");
+       if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS))
+               vty_out (vty, "  LDP errors debugging is on\n");
+       if (LDP_DEBUG(event, LDP_DEBUG_EVENT))
+               vty_out (vty, "  LDP events debugging is on\n");
+       if (LDP_DEBUG(labels, LDP_DEBUG_LABELS))
+               vty_out (vty, "  LDP labels debugging is on\n");
+       if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL))
+               vty_out (vty,
+                         "  LDP detailed messages debugging is on (inbound)\n");
+       else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV))
+               vty_out (vty,"  LDP messages debugging is on (inbound)\n");
+       if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL))
+               vty_out (vty,
+                         "  LDP detailed messages debugging is on (outbound)\n");
+       else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND))
+               vty_out (vty,"  LDP messages debugging is on (outbound)\n");
+       if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA))
+               vty_out (vty, "  LDP zebra debugging is on\n");
+       vty_out (vty, "\n");
 
        return (CMD_SUCCESS);
 }
@@ -141,46 +144,49 @@ ldp_debug_config_write(struct vty *vty)
 {
        int write = 0;
 
-       if (CONF_LDP_DEBUG(hello, HELLO_RECV)) {
-               vty_out(vty, "debug mpls ldp discovery hello recv%s",
-                   VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) {
+               vty_out (vty,"debug mpls ldp discovery hello recv\n");
+               write = 1;
+       }
+
+       if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) {
+               vty_out (vty,"debug mpls ldp discovery hello sent\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(hello, HELLO_SEND)) {
-               vty_out(vty, "debug mpls ldp discovery hello sent%s",
-                   VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) {
+               vty_out (vty, "debug mpls ldp errors\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(errors, ERRORS)) {
-               vty_out(vty, "debug mpls ldp errors%s", VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(event, LDP_DEBUG_EVENT)) {
+               vty_out (vty, "debug mpls ldp event\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(event, EVENT)) {
-               vty_out(vty, "debug mpls ldp event%s", VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(labels, LDP_DEBUG_LABELS)) {
+               vty_out (vty, "debug mpls ldp labels\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(msg, MSG_RECV_ALL)) {
-               vty_out(vty, "debug mpls ldp messages recv all%s", VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) {
+               vty_out (vty, "debug mpls ldp messages recv all\n");
                write = 1;
-       } else if (CONF_LDP_DEBUG(msg, MSG_RECV)) {
-               vty_out(vty, "debug mpls ldp messages recv%s", VTY_NEWLINE);
+       } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) {
+               vty_out (vty, "debug mpls ldp messages recv\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(msg, MSG_SEND_ALL)) {
-               vty_out(vty, "debug mpls ldp messages sent all%s", VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) {
+               vty_out (vty, "debug mpls ldp messages sent all\n");
                write = 1;
-       } else if (CONF_LDP_DEBUG(msg, MSG_SEND)) {
-               vty_out(vty, "debug mpls ldp messages sent%s", VTY_NEWLINE);
+       } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) {
+               vty_out (vty, "debug mpls ldp messages sent\n");
                write = 1;
        }
 
-       if (CONF_LDP_DEBUG(zebra, ZEBRA)) {
-               vty_out(vty, "debug mpls ldp zebra%s", VTY_NEWLINE);
+       if (CONF_LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) {
+               vty_out (vty, "debug mpls ldp zebra\n");
                write = 1;
        }