1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2016 by Open Source Routing.
12 #include "ldp_debug.h"
15 struct ldp_debug conf_ldp_debug
;
16 struct ldp_debug ldp_debug
;
18 static int ldp_debug_config_write(struct vty
*);
21 struct cmd_node ldp_debug_node
= {
25 .config_write
= ldp_debug_config_write
,
29 ldp_vty_debug(struct vty
*vty
, const char *negate
, const char *type_str
,
30 const char *dir_str
, const char *all
)
33 return (CMD_WARNING_CONFIG_FAILED
);
35 if (strcmp(type_str
, "discovery") == 0) {
37 return (CMD_WARNING_CONFIG_FAILED
);
39 if (dir_str
[0] == 'r') {
41 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_RECV
);
43 DEBUG_ON(hello
, LDP_DEBUG_HELLO_RECV
);
46 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_SEND
);
48 DEBUG_ON(hello
, LDP_DEBUG_HELLO_SEND
);
50 } else if (strcmp(type_str
, "errors") == 0) {
52 DEBUG_OFF(errors
, LDP_DEBUG_ERRORS
);
54 DEBUG_ON(errors
, LDP_DEBUG_ERRORS
);
55 } else if (strcmp(type_str
, "event") == 0) {
57 DEBUG_OFF(event
, LDP_DEBUG_EVENT
);
59 DEBUG_ON(event
, LDP_DEBUG_EVENT
);
60 } else if (strcmp(type_str
, "labels") == 0) {
62 DEBUG_OFF(labels
, LDP_DEBUG_LABELS
);
64 DEBUG_ON(labels
, LDP_DEBUG_LABELS
);
65 } else if (strcmp(type_str
, "messages") == 0) {
67 return (CMD_WARNING_CONFIG_FAILED
);
69 if (dir_str
[0] == 'r') {
71 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV
);
72 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV_ALL
);
74 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV
);
76 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV_ALL
);
80 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND
);
81 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND_ALL
);
83 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND
);
85 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND_ALL
);
88 } else if (strcmp(type_str
, "sync") == 0) {
90 DEBUG_OFF(sync
, LDP_DEBUG_SYNC
);
92 DEBUG_ON(sync
, LDP_DEBUG_SYNC
);
93 } else if (strcmp(type_str
, "zebra") == 0) {
95 DEBUG_OFF(zebra
, LDP_DEBUG_ZEBRA
);
97 DEBUG_ON(zebra
, LDP_DEBUG_ZEBRA
);
100 main_imsg_compose_both(IMSG_DEBUG_UPDATE
, &ldp_debug
,
103 return (CMD_SUCCESS
);
107 ldp_vty_show_debugging(struct vty
*vty
)
109 vty_out (vty
, "LDP debugging status:\n");
111 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
))
112 vty_out (vty
," LDP discovery debugging is on (inbound)\n");
113 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
))
114 vty_out (vty
," LDP discovery debugging is on (outbound)\n");
115 if (LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
))
116 vty_out (vty
, " LDP errors debugging is on\n");
117 if (LDP_DEBUG(event
, LDP_DEBUG_EVENT
))
118 vty_out (vty
, " LDP events debugging is on\n");
119 if (LDP_DEBUG(labels
, LDP_DEBUG_LABELS
))
120 vty_out (vty
, " LDP labels debugging is on\n");
121 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
))
123 " LDP detailed messages debugging is on (inbound)\n");
124 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
))
125 vty_out (vty
," LDP messages debugging is on (inbound)\n");
126 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
))
128 " LDP detailed messages debugging is on (outbound)\n");
129 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
))
130 vty_out (vty
," LDP messages debugging is on (outbound)\n");
131 if (LDP_DEBUG(sync
, LDP_DEBUG_SYNC
))
132 vty_out (vty
, " LDP sync debugging is on\n");
133 if (LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
))
134 vty_out (vty
, " LDP zebra debugging is on\n");
137 return (CMD_SUCCESS
);
141 ldp_debug_config_write(struct vty
*vty
)
145 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
)) {
146 vty_out (vty
,"debug mpls ldp discovery hello recv\n");
150 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
)) {
151 vty_out (vty
,"debug mpls ldp discovery hello sent\n");
155 if (CONF_LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
)) {
156 vty_out (vty
, "debug mpls ldp errors\n");
160 if (CONF_LDP_DEBUG(event
, LDP_DEBUG_EVENT
)) {
161 vty_out (vty
, "debug mpls ldp event\n");
165 if (CONF_LDP_DEBUG(labels
, LDP_DEBUG_LABELS
)) {
166 vty_out (vty
, "debug mpls ldp labels\n");
170 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
)) {
171 vty_out (vty
, "debug mpls ldp messages recv all\n");
173 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
)) {
174 vty_out (vty
, "debug mpls ldp messages recv\n");
178 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
)) {
179 vty_out (vty
, "debug mpls ldp messages sent all\n");
181 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
)) {
182 vty_out (vty
, "debug mpls ldp messages sent\n");
186 if (CONF_LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
)) {
187 vty_out (vty
, "debug mpls ldp zebra\n");
191 if (CONF_LDP_DEBUG(sync
, LDP_DEBUG_SYNC
)) {
192 vty_out (vty
, "debug mpls ldp sync\n");