]>
Commit | Line | Data |
---|---|---|
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 | ||
29 | struct ldp_debug conf_ldp_debug; | |
30 | struct ldp_debug ldp_debug; | |
31 | ||
32 | /* Debug node. */ | |
33 | struct cmd_node ldp_debug_node = | |
34 | { | |
35 | DEBUG_NODE, | |
36 | "", | |
37 | 1 | |
38 | }; | |
39 | ||
40 | int | |
1224e5c4 RW |
41 | ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str, |
42 | const char *dir_str, const char *all) | |
eac6e3f0 | 43 | { |
e59294e2 | 44 | if (type_str == NULL) |
45 | return (CMD_WARNING_CONFIG_FAILED); | |
46 | ||
eac6e3f0 | 47 | if (strcmp(type_str, "discovery") == 0) { |
eac6e3f0 | 48 | if (dir_str == NULL) |
f1a05de9 | 49 | return (CMD_WARNING_CONFIG_FAILED); |
eac6e3f0 RW |
50 | |
51 | if (dir_str[0] == 'r') { | |
1224e5c4 | 52 | if (negate) |
77518251 | 53 | DEBUG_OFF(hello, LDP_DEBUG_HELLO_RECV); |
eac6e3f0 | 54 | else |
77518251 | 55 | DEBUG_ON(hello, LDP_DEBUG_HELLO_RECV); |
eac6e3f0 | 56 | } else { |
1224e5c4 | 57 | if (negate) |
77518251 | 58 | DEBUG_OFF(hello, LDP_DEBUG_HELLO_SEND); |
eac6e3f0 | 59 | else |
77518251 | 60 | DEBUG_ON(hello, LDP_DEBUG_HELLO_SEND); |
eac6e3f0 RW |
61 | } |
62 | } else if (strcmp(type_str, "errors") == 0) { | |
1224e5c4 | 63 | if (negate) |
77518251 | 64 | DEBUG_OFF(errors, LDP_DEBUG_ERRORS); |
eac6e3f0 | 65 | else |
77518251 | 66 | DEBUG_ON(errors, LDP_DEBUG_ERRORS); |
eac6e3f0 | 67 | } else if (strcmp(type_str, "event") == 0) { |
1224e5c4 | 68 | if (negate) |
77518251 | 69 | DEBUG_OFF(event, LDP_DEBUG_EVENT); |
eac6e3f0 | 70 | else |
77518251 | 71 | DEBUG_ON(event, LDP_DEBUG_EVENT); |
08e4b244 RW |
72 | } else if (strcmp(type_str, "labels") == 0) { |
73 | if (negate) | |
77518251 | 74 | DEBUG_OFF(labels, LDP_DEBUG_LABELS); |
08e4b244 | 75 | else |
77518251 | 76 | DEBUG_ON(labels, LDP_DEBUG_LABELS); |
7d3d7491 | 77 | } else if (strcmp(type_str, "messages") == 0) { |
eac6e3f0 | 78 | if (dir_str == NULL) |
f1a05de9 | 79 | return (CMD_WARNING_CONFIG_FAILED); |
eac6e3f0 RW |
80 | |
81 | if (dir_str[0] == 'r') { | |
1224e5c4 | 82 | if (negate) { |
77518251 DS |
83 | DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV); |
84 | DEBUG_OFF(msg, LDP_DEBUG_MSG_RECV_ALL); | |
eac6e3f0 | 85 | } else { |
77518251 | 86 | DEBUG_ON(msg, LDP_DEBUG_MSG_RECV); |
eac6e3f0 | 87 | if (all) |
77518251 | 88 | DEBUG_ON(msg, LDP_DEBUG_MSG_RECV_ALL); |
eac6e3f0 RW |
89 | } |
90 | } else { | |
1224e5c4 | 91 | if (negate) { |
77518251 DS |
92 | DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND); |
93 | DEBUG_OFF(msg, LDP_DEBUG_MSG_SEND_ALL); | |
eac6e3f0 | 94 | } else { |
77518251 | 95 | DEBUG_ON(msg, LDP_DEBUG_MSG_SEND); |
eac6e3f0 | 96 | if (all) |
77518251 | 97 | DEBUG_ON(msg, LDP_DEBUG_MSG_SEND_ALL); |
eac6e3f0 RW |
98 | } |
99 | } | |
7d3d7491 | 100 | } else if (strcmp(type_str, "zebra") == 0) { |
1224e5c4 | 101 | if (negate) |
77518251 | 102 | DEBUG_OFF(zebra, LDP_DEBUG_ZEBRA); |
eac6e3f0 | 103 | else |
77518251 | 104 | DEBUG_ON(zebra, LDP_DEBUG_ZEBRA); |
eac6e3f0 RW |
105 | } |
106 | ||
107 | main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, | |
108 | sizeof(ldp_debug)); | |
109 | ||
110 | return (CMD_SUCCESS); | |
111 | } | |
112 | ||
113 | int | |
c740f7d3 | 114 | ldp_vty_show_debugging(struct vty *vty) |
eac6e3f0 | 115 | { |
5c7571d4 | 116 | vty_out (vty, "LDP debugging status:\n"); |
eac6e3f0 | 117 | |
77518251 | 118 | if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) |
5c7571d4 | 119 | vty_out (vty," LDP discovery debugging is on (inbound)\n"); |
77518251 | 120 | if (LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) |
5c7571d4 | 121 | vty_out (vty," LDP discovery debugging is on (outbound)\n"); |
77518251 | 122 | if (LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) |
5c7571d4 | 123 | vty_out (vty, " LDP errors debugging is on\n"); |
77518251 | 124 | if (LDP_DEBUG(event, LDP_DEBUG_EVENT)) |
5c7571d4 | 125 | vty_out (vty, " LDP events debugging is on\n"); |
77518251 | 126 | if (LDP_DEBUG(labels, LDP_DEBUG_LABELS)) |
08e4b244 | 127 | vty_out (vty, " LDP labels debugging is on\n"); |
77518251 | 128 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) |
181039f3 DL |
129 | vty_out (vty, |
130 | " LDP detailed messages debugging is on (inbound)\n"); | |
77518251 | 131 | else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) |
5c7571d4 | 132 | vty_out (vty," LDP messages debugging is on (inbound)\n"); |
77518251 | 133 | if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) |
181039f3 DL |
134 | vty_out (vty, |
135 | " LDP detailed messages debugging is on (outbound)\n"); | |
77518251 | 136 | else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) |
5c7571d4 | 137 | vty_out (vty," LDP messages debugging is on (outbound)\n"); |
77518251 | 138 | if (LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) |
5c7571d4 | 139 | vty_out (vty, " LDP zebra debugging is on\n"); |
6d3c2ed4 | 140 | vty_out (vty, "\n"); |
eac6e3f0 RW |
141 | |
142 | return (CMD_SUCCESS); | |
143 | } | |
144 | ||
145 | int | |
146 | ldp_debug_config_write(struct vty *vty) | |
147 | { | |
148 | int write = 0; | |
149 | ||
77518251 | 150 | if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_RECV)) { |
5c7571d4 | 151 | vty_out (vty,"debug mpls ldp discovery hello recv\n"); |
eac6e3f0 RW |
152 | write = 1; |
153 | } | |
154 | ||
77518251 | 155 | if (CONF_LDP_DEBUG(hello, LDP_DEBUG_HELLO_SEND)) { |
5c7571d4 | 156 | vty_out (vty,"debug mpls ldp discovery hello sent\n"); |
eac6e3f0 RW |
157 | write = 1; |
158 | } | |
159 | ||
77518251 | 160 | if (CONF_LDP_DEBUG(errors, LDP_DEBUG_ERRORS)) { |
5c7571d4 | 161 | vty_out (vty, "debug mpls ldp errors\n"); |
eac6e3f0 RW |
162 | write = 1; |
163 | } | |
164 | ||
77518251 | 165 | if (CONF_LDP_DEBUG(event, LDP_DEBUG_EVENT)) { |
5c7571d4 | 166 | vty_out (vty, "debug mpls ldp event\n"); |
eac6e3f0 RW |
167 | write = 1; |
168 | } | |
169 | ||
77518251 | 170 | if (CONF_LDP_DEBUG(labels, LDP_DEBUG_LABELS)) { |
08e4b244 RW |
171 | vty_out (vty, "debug mpls ldp labels\n"); |
172 | write = 1; | |
173 | } | |
174 | ||
77518251 | 175 | if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL)) { |
5c7571d4 | 176 | vty_out (vty, "debug mpls ldp messages recv all\n"); |
eac6e3f0 | 177 | write = 1; |
77518251 | 178 | } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV)) { |
5c7571d4 | 179 | vty_out (vty, "debug mpls ldp messages recv\n"); |
eac6e3f0 RW |
180 | write = 1; |
181 | } | |
182 | ||
77518251 | 183 | if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL)) { |
5c7571d4 | 184 | vty_out (vty, "debug mpls ldp messages sent all\n"); |
eac6e3f0 | 185 | write = 1; |
77518251 | 186 | } else if (CONF_LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND)) { |
5c7571d4 | 187 | vty_out (vty, "debug mpls ldp messages sent\n"); |
eac6e3f0 RW |
188 | write = 1; |
189 | } | |
190 | ||
77518251 | 191 | if (CONF_LDP_DEBUG(zebra, LDP_DEBUG_ZEBRA)) { |
5c7571d4 | 192 | vty_out (vty, "debug mpls ldp zebra\n"); |
eac6e3f0 RW |
193 | write = 1; |
194 | } | |
195 | ||
196 | return (write); | |
197 | } |