2 * Copyright (C) 2016 by Open Source Routing.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26 #include "ldp_debug.h"
29 struct ldp_debug conf_ldp_debug
;
30 struct ldp_debug ldp_debug
;
32 static int ldp_debug_config_write(struct vty
*);
35 struct cmd_node ldp_debug_node
= {
39 .config_write
= ldp_debug_config_write
,
43 ldp_vty_debug(struct vty
*vty
, const char *negate
, const char *type_str
,
44 const char *dir_str
, const char *all
)
47 return (CMD_WARNING_CONFIG_FAILED
);
49 if (strcmp(type_str
, "discovery") == 0) {
51 return (CMD_WARNING_CONFIG_FAILED
);
53 if (dir_str
[0] == 'r') {
55 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_RECV
);
57 DEBUG_ON(hello
, LDP_DEBUG_HELLO_RECV
);
60 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_SEND
);
62 DEBUG_ON(hello
, LDP_DEBUG_HELLO_SEND
);
64 } else if (strcmp(type_str
, "errors") == 0) {
66 DEBUG_OFF(errors
, LDP_DEBUG_ERRORS
);
68 DEBUG_ON(errors
, LDP_DEBUG_ERRORS
);
69 } else if (strcmp(type_str
, "event") == 0) {
71 DEBUG_OFF(event
, LDP_DEBUG_EVENT
);
73 DEBUG_ON(event
, LDP_DEBUG_EVENT
);
74 } else if (strcmp(type_str
, "labels") == 0) {
76 DEBUG_OFF(labels
, LDP_DEBUG_LABELS
);
78 DEBUG_ON(labels
, LDP_DEBUG_LABELS
);
79 } else if (strcmp(type_str
, "messages") == 0) {
81 return (CMD_WARNING_CONFIG_FAILED
);
83 if (dir_str
[0] == 'r') {
85 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV
);
86 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV_ALL
);
88 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV
);
90 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV_ALL
);
94 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND
);
95 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND_ALL
);
97 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND
);
99 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND_ALL
);
102 } else if (strcmp(type_str
, "sync") == 0) {
104 DEBUG_OFF(sync
, LDP_DEBUG_SYNC
);
106 DEBUG_ON(sync
, LDP_DEBUG_SYNC
);
107 } else if (strcmp(type_str
, "zebra") == 0) {
109 DEBUG_OFF(zebra
, LDP_DEBUG_ZEBRA
);
111 DEBUG_ON(zebra
, LDP_DEBUG_ZEBRA
);
114 main_imsg_compose_both(IMSG_DEBUG_UPDATE
, &ldp_debug
,
117 return (CMD_SUCCESS
);
121 ldp_vty_show_debugging(struct vty
*vty
)
123 vty_out (vty
, "LDP debugging status:\n");
125 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
))
126 vty_out (vty
," LDP discovery debugging is on (inbound)\n");
127 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
))
128 vty_out (vty
," LDP discovery debugging is on (outbound)\n");
129 if (LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
))
130 vty_out (vty
, " LDP errors debugging is on\n");
131 if (LDP_DEBUG(event
, LDP_DEBUG_EVENT
))
132 vty_out (vty
, " LDP events debugging is on\n");
133 if (LDP_DEBUG(labels
, LDP_DEBUG_LABELS
))
134 vty_out (vty
, " LDP labels debugging is on\n");
135 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
))
137 " LDP detailed messages debugging is on (inbound)\n");
138 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
))
139 vty_out (vty
," LDP messages debugging is on (inbound)\n");
140 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
))
142 " LDP detailed messages debugging is on (outbound)\n");
143 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
))
144 vty_out (vty
," LDP messages debugging is on (outbound)\n");
145 if (LDP_DEBUG(sync
, LDP_DEBUG_SYNC
))
146 vty_out (vty
, " LDP sync debugging is on\n");
147 if (LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
))
148 vty_out (vty
, " LDP zebra debugging is on\n");
151 return (CMD_SUCCESS
);
155 ldp_debug_config_write(struct vty
*vty
)
159 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
)) {
160 vty_out (vty
,"debug mpls ldp discovery hello recv\n");
164 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
)) {
165 vty_out (vty
,"debug mpls ldp discovery hello sent\n");
169 if (CONF_LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
)) {
170 vty_out (vty
, "debug mpls ldp errors\n");
174 if (CONF_LDP_DEBUG(event
, LDP_DEBUG_EVENT
)) {
175 vty_out (vty
, "debug mpls ldp event\n");
179 if (CONF_LDP_DEBUG(labels
, LDP_DEBUG_LABELS
)) {
180 vty_out (vty
, "debug mpls ldp labels\n");
184 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
)) {
185 vty_out (vty
, "debug mpls ldp messages recv all\n");
187 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
)) {
188 vty_out (vty
, "debug mpls ldp messages recv\n");
192 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
)) {
193 vty_out (vty
, "debug mpls ldp messages sent all\n");
195 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
)) {
196 vty_out (vty
, "debug mpls ldp messages sent\n");
200 if (CONF_LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
)) {
201 vty_out (vty
, "debug mpls ldp zebra\n");
205 if (CONF_LDP_DEBUG(sync
, LDP_DEBUG_SYNC
)) {
206 vty_out (vty
, "debug mpls ldp sync\n");