]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/ldp_debug.c
tools: improve explanation of 'wrap' options
[mirror_frr.git] / ldpd / ldp_debug.c
CommitLineData
eac6e3f0
RW
1/*
2 * Copyright (C) 2016 by Open Source Routing.
3 *
180fc2cd
RW
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.
eac6e3f0 8 *
180fc2cd 9 * This program is distributed in the hope that it will be useful, but
eac6e3f0
RW
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.
13 *
180fc2cd
RW
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,
17 * MA 02110-1301 USA
eac6e3f0
RW
18 */
19
20#include <zebra.h>
21
22#include "command.h"
23#include "vty.h"
24
25#include "ldpd.h"
26#include "ldp_debug.h"
27#include "ldp_vty.h"
28
29struct ldp_debug conf_ldp_debug;
30struct ldp_debug ldp_debug;
31
612c2c15
DL
32static int ldp_debug_config_write(struct vty *);
33
eac6e3f0 34/* Debug node. */
62b346ee 35struct cmd_node ldp_debug_node = {
f4b8291f 36 .name = "debug",
62b346ee
DL
37 .node = DEBUG_NODE,
38 .prompt = "",
612c2c15 39 .config_write = ldp_debug_config_write,
eac6e3f0
RW
40};
41
42int
1224e5c4
RW
43ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
44 const char *dir_str, const char *all)
eac6e3f0 45{
e59294e2 46 if (type_str == NULL)
47 return (CMD_WARNING_CONFIG_FAILED);
48
eac6e3f0 49 if (strcmp(type_str, "discovery") == 0) {
eac6e3f0 50 if (dir_str == NULL)
f1a05de9 51 return (CMD_WARNING_CONFIG_FAILED);
eac6e3f0
RW
52
53 if (dir_str[0] == 'r') {
1224e5c4 54 if (negate)
77518251 55 DEBUG_OFF(hello, LDP_DEBUG_HELLO_RECV);
eac6e3f0 56 else
77518251 57 DEBUG_ON(hello, LDP_DEBUG_HELLO_RECV);
eac6e3f0 58 } else {
1224e5c4 59 if (negate)
77518251 60 DEBUG_OFF(hello, LDP_DEBUG_HELLO_SEND);
eac6e3f0 61 else
77518251 62 DEBUG_ON(hello, LDP_DEBUG_HELLO_SEND);
eac6e3f0
RW
63 }
64 } else if (strcmp(type_str, "errors") == 0) {
1224e5c4 65 if (negate)
77518251 66 DEBUG_OFF(errors, LDP_DEBUG_ERRORS);
eac6e3f0 67 else
77518251 68 DEBUG_ON(errors, LDP_DEBUG_ERRORS);
eac6e3f0 69 } else if (strcmp(type_str, "event") == 0) {
1224e5c4 70 if (negate)
77518251 71 DEBUG_OFF(event, LDP_DEBUG_EVENT);
eac6e3f0 72 else
77518251 73 DEBUG_ON(event, LDP_DEBUG_EVENT);
08e4b244
RW
74 } else if (strcmp(type_str, "labels") == 0) {
75 if (negate)
77518251 76 DEBUG_OFF(labels, LDP_DEBUG_LABELS);
08e4b244 77 else
77518251 78 DEBUG_ON(labels, LDP_DEBUG_LABELS);
7d3d7491 79 } else if (strcmp(type_str, "messages") == 0) {
eac6e3f0 80 if (dir_str == NULL)
f1a05de9 81 return (CMD_WARNING_CONFIG_FAILED);
eac6e3f0
RW
82
83 if (dir_str[0] == 'r') {
1224e5c4 84 if (negate) {
77518251
DS
85 DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV);
86 DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV_ALL);
eac6e3f0 87 } else {
77518251 88 DEBUG_ON(msg, LDP_DEBUG_MSG_RECV);
eac6e3f0 89 if (all)
77518251 90 DEBUG_ON(msg, LDP_DEBUG_MSG_RECV_ALL);
eac6e3f0
RW
91 }
92 } else {
1224e5c4 93 if (negate) {
77518251
DS
94 DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND);
95 DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND_ALL);
eac6e3f0 96 } else {
77518251 97 DEBUG_ON(msg, LDP_DEBUG_MSG_SEND);
eac6e3f0 98 if (all)
77518251 99 DEBUG_ON(msg, LDP_DEBUG_MSG_SEND_ALL);
eac6e3f0
RW
100 }
101 }
e1894ff7
KS
102 } else if (strcmp(type_str, "sync") == 0) {
103 if (negate)
104 DEBUG_OFF(sync, LDP_DEBUG_SYNC);
105 else
106 DEBUG_ON(sync, LDP_DEBUG_SYNC);
7d3d7491 107 } else if (strcmp(type_str, "zebra") == 0) {
1224e5c4 108 if (negate)
77518251 109 DEBUG_OFF(zebra, LDP_DEBUG_ZEBRA);
eac6e3f0 110 else
77518251 111 DEBUG_ON(zebra, LDP_DEBUG_ZEBRA);
eac6e3f0
RW
112 }
113
114 main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
115 sizeof(ldp_debug));
116
117 return (CMD_SUCCESS);
118}
119
120int
c740f7d3 121ldp_vty_show_debugging(struct vty *vty)
eac6e3f0 122{
5c7571d4 123 vty_out (vty, "LDP debugging status:\n");
eac6e3f0 124
77518251 125 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV))
5c7571d4 126 vty_out (vty," LDP discovery debugging is on (inbound)\n");
77518251 127 if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND))
5c7571d4 128 vty_out (vty," LDP discovery debugging is on (outbound)\n");
77518251 129 if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS))
5c7571d4 130 vty_out (vty, " LDP errors debugging is on\n");
77518251 131 if (LDP_DEBUG(event, LDP_DEBUG_EVENT))
5c7571d4 132 vty_out (vty, " LDP events debugging is on\n");
77518251 133 if (LDP_DEBUG(labels, LDP_DEBUG_LABELS))
08e4b244 134 vty_out (vty, " LDP labels debugging is on\n");
77518251 135 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL))
181039f3
DL
136 vty_out (vty,
137 " LDP detailed messages debugging is on (inbound)\n");
77518251 138 else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV))
5c7571d4 139 vty_out (vty," LDP messages debugging is on (inbound)\n");
77518251 140 if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL))
181039f3
DL
141 vty_out (vty,
142 " LDP detailed messages debugging is on (outbound)\n");
77518251 143 else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND))
5c7571d4 144 vty_out (vty," LDP messages debugging is on (outbound)\n");
e1894ff7
KS
145 if (LDP_DEBUG(sync, LDP_DEBUG_SYNC))
146 vty_out (vty, " LDP sync debugging is on\n");
77518251 147 if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA))
5c7571d4 148 vty_out (vty, " LDP zebra debugging is on\n");
6d3c2ed4 149 vty_out (vty, "\n");
eac6e3f0
RW
150
151 return (CMD_SUCCESS);
152}
153
612c2c15 154static int
eac6e3f0
RW
155ldp_debug_config_write(struct vty *vty)
156{
157 int write = 0;
158
77518251 159 if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) {
5c7571d4 160 vty_out (vty,"debug mpls ldp discovery hello recv\n");
eac6e3f0
RW
161 write = 1;
162 }
163
77518251 164 if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) {
5c7571d4 165 vty_out (vty,"debug mpls ldp discovery hello sent\n");
eac6e3f0
RW
166 write = 1;
167 }
168
77518251 169 if (CONF_LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) {
5c7571d4 170 vty_out (vty, "debug mpls ldp errors\n");
eac6e3f0
RW
171 write = 1;
172 }
173
77518251 174 if (CONF_LDP_DEBUG(event, LDP_DEBUG_EVENT)) {
5c7571d4 175 vty_out (vty, "debug mpls ldp event\n");
eac6e3f0
RW
176 write = 1;
177 }
178
77518251 179 if (CONF_LDP_DEBUG(labels, LDP_DEBUG_LABELS)) {
08e4b244
RW
180 vty_out (vty, "debug mpls ldp labels\n");
181 write = 1;
182 }
183
77518251 184 if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) {
5c7571d4 185 vty_out (vty, "debug mpls ldp messages recv all\n");
eac6e3f0 186 write = 1;
77518251 187 } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) {
5c7571d4 188 vty_out (vty, "debug mpls ldp messages recv\n");
eac6e3f0
RW
189 write = 1;
190 }
191
77518251 192 if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) {
5c7571d4 193 vty_out (vty, "debug mpls ldp messages sent all\n");
eac6e3f0 194 write = 1;
77518251 195 } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) {
5c7571d4 196 vty_out (vty, "debug mpls ldp messages sent\n");
eac6e3f0
RW
197 write = 1;
198 }
199
77518251 200 if (CONF_LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) {
5c7571d4 201 vty_out (vty, "debug mpls ldp zebra\n");
eac6e3f0
RW
202 write = 1;
203 }
204
e1894ff7
KS
205 if (CONF_LDP_DEBUG(sync, LDP_DEBUG_SYNC)) {
206 vty_out (vty, "debug mpls ldp sync\n");
207 write = 1;
208 }
209
eac6e3f0
RW
210 return (write);
211}