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
;
33 struct cmd_node ldp_debug_node
=
41 ldp_vty_debug(struct vty
*vty
, const char *negate
, const char *type_str
,
42 const char *dir_str
, const char *all
)
45 return (CMD_WARNING_CONFIG_FAILED
);
47 if (strcmp(type_str
, "discovery") == 0) {
49 return (CMD_WARNING_CONFIG_FAILED
);
51 if (dir_str
[0] == 'r') {
53 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_RECV
);
55 DEBUG_ON(hello
, LDP_DEBUG_HELLO_RECV
);
58 DEBUG_OFF(hello
, LDP_DEBUG_HELLO_SEND
);
60 DEBUG_ON(hello
, LDP_DEBUG_HELLO_SEND
);
62 } else if (strcmp(type_str
, "errors") == 0) {
64 DEBUG_OFF(errors
, LDP_DEBUG_ERRORS
);
66 DEBUG_ON(errors
, LDP_DEBUG_ERRORS
);
67 } else if (strcmp(type_str
, "event") == 0) {
69 DEBUG_OFF(event
, LDP_DEBUG_EVENT
);
71 DEBUG_ON(event
, LDP_DEBUG_EVENT
);
72 } else if (strcmp(type_str
, "labels") == 0) {
74 DEBUG_OFF(labels
, LDP_DEBUG_LABELS
);
76 DEBUG_ON(labels
, LDP_DEBUG_LABELS
);
77 } else if (strcmp(type_str
, "messages") == 0) {
79 return (CMD_WARNING_CONFIG_FAILED
);
81 if (dir_str
[0] == 'r') {
83 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV
);
84 DEBUG_OFF(msg
, LDP_DEBUG_MSG_RECV_ALL
);
86 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV
);
88 DEBUG_ON(msg
, LDP_DEBUG_MSG_RECV_ALL
);
92 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND
);
93 DEBUG_OFF(msg
, LDP_DEBUG_MSG_SEND_ALL
);
95 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND
);
97 DEBUG_ON(msg
, LDP_DEBUG_MSG_SEND_ALL
);
100 } else if (strcmp(type_str
, "zebra") == 0) {
102 DEBUG_OFF(zebra
, LDP_DEBUG_ZEBRA
);
104 DEBUG_ON(zebra
, LDP_DEBUG_ZEBRA
);
107 main_imsg_compose_both(IMSG_DEBUG_UPDATE
, &ldp_debug
,
110 return (CMD_SUCCESS
);
114 ldp_vty_show_debugging(struct vty
*vty
)
116 vty_out (vty
, "LDP debugging status:\n");
118 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
))
119 vty_out (vty
," LDP discovery debugging is on (inbound)\n");
120 if (LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
))
121 vty_out (vty
," LDP discovery debugging is on (outbound)\n");
122 if (LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
))
123 vty_out (vty
, " LDP errors debugging is on\n");
124 if (LDP_DEBUG(event
, LDP_DEBUG_EVENT
))
125 vty_out (vty
, " LDP events debugging is on\n");
126 if (LDP_DEBUG(labels
, LDP_DEBUG_LABELS
))
127 vty_out (vty
, " LDP labels debugging is on\n");
128 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
))
130 " LDP detailed messages debugging is on (inbound)\n");
131 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
))
132 vty_out (vty
," LDP messages debugging is on (inbound)\n");
133 if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
))
135 " LDP detailed messages debugging is on (outbound)\n");
136 else if (LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
))
137 vty_out (vty
," LDP messages debugging is on (outbound)\n");
138 if (LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
))
139 vty_out (vty
, " LDP zebra debugging is on\n");
142 return (CMD_SUCCESS
);
146 ldp_debug_config_write(struct vty
*vty
)
150 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_RECV
)) {
151 vty_out (vty
,"debug mpls ldp discovery hello recv\n");
155 if (CONF_LDP_DEBUG(hello
, LDP_DEBUG_HELLO_SEND
)) {
156 vty_out (vty
,"debug mpls ldp discovery hello sent\n");
160 if (CONF_LDP_DEBUG(errors
, LDP_DEBUG_ERRORS
)) {
161 vty_out (vty
, "debug mpls ldp errors\n");
165 if (CONF_LDP_DEBUG(event
, LDP_DEBUG_EVENT
)) {
166 vty_out (vty
, "debug mpls ldp event\n");
170 if (CONF_LDP_DEBUG(labels
, LDP_DEBUG_LABELS
)) {
171 vty_out (vty
, "debug mpls ldp labels\n");
175 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV_ALL
)) {
176 vty_out (vty
, "debug mpls ldp messages recv all\n");
178 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_RECV
)) {
179 vty_out (vty
, "debug mpls ldp messages recv\n");
183 if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND_ALL
)) {
184 vty_out (vty
, "debug mpls ldp messages sent all\n");
186 } else if (CONF_LDP_DEBUG(msg
, LDP_DEBUG_MSG_SEND
)) {
187 vty_out (vty
, "debug mpls ldp messages sent\n");
191 if (CONF_LDP_DEBUG(zebra
, LDP_DEBUG_ZEBRA
)) {
192 vty_out (vty
, "debug mpls ldp zebra\n");