]>
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 | |
c740f7d3 RW |
41 | ldp_vty_debug(struct vty *vty, int disable, const char *type_str, |
42 | const char *dir_str, int all) | |
eac6e3f0 | 43 | { |
eac6e3f0 | 44 | if (strcmp(type_str, "discovery") == 0) { |
eac6e3f0 | 45 | if (dir_str == NULL) |
f1a05de9 | 46 | return (CMD_WARNING_CONFIG_FAILED); |
eac6e3f0 RW |
47 | |
48 | if (dir_str[0] == 'r') { | |
49 | if (disable) | |
50 | DEBUG_OFF(hello, HELLO_RECV); | |
51 | else | |
52 | DEBUG_ON(hello, HELLO_RECV); | |
53 | } else { | |
54 | if (disable) | |
55 | DEBUG_OFF(hello, HELLO_SEND); | |
56 | else | |
57 | DEBUG_ON(hello, HELLO_SEND); | |
58 | } | |
59 | } else if (strcmp(type_str, "errors") == 0) { | |
60 | if (disable) | |
61 | DEBUG_OFF(errors, ERRORS); | |
62 | else | |
63 | DEBUG_ON(errors, ERRORS); | |
64 | } else if (strcmp(type_str, "event") == 0) { | |
65 | if (disable) | |
66 | DEBUG_OFF(event, EVENT); | |
67 | else | |
68 | DEBUG_ON(event, EVENT); | |
7d3d7491 | 69 | } else if (strcmp(type_str, "messages") == 0) { |
eac6e3f0 | 70 | if (dir_str == NULL) |
f1a05de9 | 71 | return (CMD_WARNING_CONFIG_FAILED); |
eac6e3f0 RW |
72 | |
73 | if (dir_str[0] == 'r') { | |
74 | if (disable) { | |
75 | DEBUG_OFF(msg, MSG_RECV); | |
76 | DEBUG_OFF(msg, MSG_RECV_ALL); | |
77 | } else { | |
78 | DEBUG_ON(msg, MSG_RECV); | |
79 | if (all) | |
80 | DEBUG_ON(msg, MSG_RECV_ALL); | |
81 | } | |
82 | } else { | |
83 | if (disable) { | |
84 | DEBUG_OFF(msg, MSG_SEND); | |
85 | DEBUG_OFF(msg, MSG_SEND_ALL); | |
86 | } else { | |
87 | DEBUG_ON(msg, MSG_SEND); | |
88 | if (all) | |
89 | DEBUG_ON(msg, MSG_SEND_ALL); | |
90 | } | |
91 | } | |
7d3d7491 | 92 | } else if (strcmp(type_str, "zebra") == 0) { |
eac6e3f0 RW |
93 | if (disable) |
94 | DEBUG_OFF(zebra, ZEBRA); | |
95 | else | |
96 | DEBUG_ON(zebra, ZEBRA); | |
97 | } | |
98 | ||
99 | main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, | |
100 | sizeof(ldp_debug)); | |
101 | ||
102 | return (CMD_SUCCESS); | |
103 | } | |
104 | ||
105 | int | |
c740f7d3 | 106 | ldp_vty_show_debugging(struct vty *vty) |
eac6e3f0 | 107 | { |
5c7571d4 | 108 | vty_out (vty, "LDP debugging status:\n"); |
eac6e3f0 RW |
109 | |
110 | if (LDP_DEBUG(hello, HELLO_RECV)) | |
5c7571d4 | 111 | vty_out (vty," LDP discovery debugging is on (inbound)\n"); |
eac6e3f0 | 112 | if (LDP_DEBUG(hello, HELLO_SEND)) |
5c7571d4 | 113 | vty_out (vty," LDP discovery debugging is on (outbound)\n"); |
eac6e3f0 | 114 | if (LDP_DEBUG(errors, ERRORS)) |
5c7571d4 | 115 | vty_out (vty, " LDP errors debugging is on\n"); |
eac6e3f0 | 116 | if (LDP_DEBUG(event, EVENT)) |
5c7571d4 | 117 | vty_out (vty, " LDP events debugging is on\n"); |
eac6e3f0 | 118 | if (LDP_DEBUG(msg, MSG_RECV_ALL)) |
181039f3 DL |
119 | vty_out (vty, |
120 | " LDP detailed messages debugging is on (inbound)\n"); | |
eac6e3f0 | 121 | else if (LDP_DEBUG(msg, MSG_RECV)) |
5c7571d4 | 122 | vty_out (vty," LDP messages debugging is on (inbound)\n"); |
eac6e3f0 | 123 | if (LDP_DEBUG(msg, MSG_SEND_ALL)) |
181039f3 DL |
124 | vty_out (vty, |
125 | " LDP detailed messages debugging is on (outbound)\n"); | |
eac6e3f0 | 126 | else if (LDP_DEBUG(msg, MSG_SEND)) |
5c7571d4 | 127 | vty_out (vty," LDP messages debugging is on (outbound)\n"); |
eac6e3f0 | 128 | if (LDP_DEBUG(zebra, ZEBRA)) |
5c7571d4 | 129 | vty_out (vty, " LDP zebra debugging is on\n"); |
6d3c2ed4 | 130 | vty_out (vty, "\n"); |
eac6e3f0 RW |
131 | |
132 | return (CMD_SUCCESS); | |
133 | } | |
134 | ||
135 | int | |
136 | ldp_debug_config_write(struct vty *vty) | |
137 | { | |
138 | int write = 0; | |
139 | ||
140 | if (CONF_LDP_DEBUG(hello, HELLO_RECV)) { | |
5c7571d4 | 141 | vty_out (vty,"debug mpls ldp discovery hello recv\n"); |
eac6e3f0 RW |
142 | write = 1; |
143 | } | |
144 | ||
145 | if (CONF_LDP_DEBUG(hello, HELLO_SEND)) { | |
5c7571d4 | 146 | vty_out (vty,"debug mpls ldp discovery hello sent\n"); |
eac6e3f0 RW |
147 | write = 1; |
148 | } | |
149 | ||
150 | if (CONF_LDP_DEBUG(errors, ERRORS)) { | |
5c7571d4 | 151 | vty_out (vty, "debug mpls ldp errors\n"); |
eac6e3f0 RW |
152 | write = 1; |
153 | } | |
154 | ||
155 | if (CONF_LDP_DEBUG(event, EVENT)) { | |
5c7571d4 | 156 | vty_out (vty, "debug mpls ldp event\n"); |
eac6e3f0 RW |
157 | write = 1; |
158 | } | |
159 | ||
160 | if (CONF_LDP_DEBUG(msg, MSG_RECV_ALL)) { | |
5c7571d4 | 161 | vty_out (vty, "debug mpls ldp messages recv all\n"); |
eac6e3f0 RW |
162 | write = 1; |
163 | } else if (CONF_LDP_DEBUG(msg, MSG_RECV)) { | |
5c7571d4 | 164 | vty_out (vty, "debug mpls ldp messages recv\n"); |
eac6e3f0 RW |
165 | write = 1; |
166 | } | |
167 | ||
168 | if (CONF_LDP_DEBUG(msg, MSG_SEND_ALL)) { | |
5c7571d4 | 169 | vty_out (vty, "debug mpls ldp messages sent all\n"); |
eac6e3f0 RW |
170 | write = 1; |
171 | } else if (CONF_LDP_DEBUG(msg, MSG_SEND)) { | |
5c7571d4 | 172 | vty_out (vty, "debug mpls ldp messages sent\n"); |
eac6e3f0 RW |
173 | write = 1; |
174 | } | |
175 | ||
176 | if (CONF_LDP_DEBUG(zebra, ZEBRA)) { | |
5c7571d4 | 177 | vty_out (vty, "debug mpls ldp zebra\n"); |
eac6e3f0 RW |
178 | write = 1; |
179 | } | |
180 | ||
181 | return (write); | |
182 | } |