]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
Switch to using syslog for logging as the default
[mirror_frr.git] / pimd / pim_vty.c
1 /*
2 * PIM for Quagga
3 * Copyright (C) 2008 Everton da Silva Marques
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include <zebra.h>
21
22 #include "if.h"
23 #include "linklist.h"
24 #include "prefix.h"
25 #include "vty.h"
26 #include "vrf.h"
27 #include "plist.h"
28
29 #include "pimd.h"
30 #include "pim_vty.h"
31 #include "pim_iface.h"
32 #include "pim_cmd.h"
33 #include "pim_str.h"
34 #include "pim_ssmpingd.h"
35 #include "pim_pim.h"
36 #include "pim_oil.h"
37 #include "pim_static.h"
38 #include "pim_rp.h"
39 #include "pim_msdp.h"
40 #include "pim_ssm.h"
41 #include "pim_bfd.h"
42
43 int pim_debug_config_write(struct vty *vty)
44 {
45 int writes = 0;
46
47 if (PIM_DEBUG_MSDP_EVENTS) {
48 vty_out(vty, "debug msdp events\n");
49 ++writes;
50 }
51 if (PIM_DEBUG_MSDP_PACKETS) {
52 vty_out(vty, "debug msdp packets\n");
53 ++writes;
54 }
55 if (PIM_DEBUG_MSDP_INTERNAL) {
56 vty_out(vty, "debug msdp internal\n");
57 ++writes;
58 }
59 if (PIM_DEBUG_IGMP_EVENTS) {
60 vty_out(vty, "debug igmp events\n");
61 ++writes;
62 }
63 if (PIM_DEBUG_IGMP_PACKETS) {
64 vty_out(vty, "debug igmp packets\n");
65 ++writes;
66 }
67 if (PIM_DEBUG_IGMP_TRACE) {
68 vty_out(vty, "debug igmp trace\n");
69 ++writes;
70 }
71 if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
72 vty_out(vty, "debug igmp trace detail\n");
73 ++writes;
74 }
75
76 if (PIM_DEBUG_MROUTE) {
77 vty_out(vty, "debug mroute\n");
78 ++writes;
79 }
80
81 if (PIM_DEBUG_MROUTE_DETAIL) {
82 vty_out(vty, "debug mroute detail\n");
83 ++writes;
84 }
85
86 if (PIM_DEBUG_PIM_EVENTS) {
87 vty_out(vty, "debug pim events\n");
88 ++writes;
89 }
90 if (PIM_DEBUG_PIM_PACKETS) {
91 vty_out(vty, "debug pim packets\n");
92 ++writes;
93 }
94 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
95 vty_out(vty, "debug pim packet-dump send\n");
96 ++writes;
97 }
98 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
99 vty_out(vty, "debug pim packet-dump receive\n");
100 ++writes;
101 }
102
103 if (PIM_DEBUG_PIM_TRACE) {
104 vty_out(vty, "debug pim trace\n");
105 ++writes;
106 }
107 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
108 vty_out(vty, "debug pim trace detail\n");
109 ++writes;
110 }
111
112 if (PIM_DEBUG_ZEBRA) {
113 vty_out(vty, "debug pim zebra\n");
114 ++writes;
115 }
116
117 if (PIM_DEBUG_SSMPINGD) {
118 vty_out(vty, "debug ssmpingd\n");
119 ++writes;
120 }
121
122 if (PIM_DEBUG_PIM_HELLO) {
123 vty_out(vty, "debug pim packets hello\n");
124 ++writes;
125 }
126
127 if (PIM_DEBUG_PIM_J_P) {
128 vty_out(vty, "debug pim packets joins\n");
129 ++writes;
130 }
131
132 if (PIM_DEBUG_PIM_REG) {
133 vty_out(vty, "debug pim packets register\n");
134 ++writes;
135 }
136
137 if (PIM_DEBUG_STATIC) {
138 vty_out(vty, "debug pim static\n");
139 ++writes;
140 }
141
142 return writes;
143 }
144
145 int pim_global_config_write(struct vty *vty)
146 {
147 int writes = 0;
148 struct pim_ssm *ssm = pimg->ssm_info;
149
150 writes += pim_msdp_config_write(vty);
151
152 if (!pimg->send_v6_secondary) {
153 vty_out(vty, "no ip pim send-v6-secondary\n");
154 ++writes;
155 }
156
157 writes += pim_rp_config_write(vty);
158
159 if (qpim_register_suppress_time
160 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
161 vty_out(vty, "ip pim register-suppress-time %d\n",
162 qpim_register_suppress_time);
163 ++writes;
164 }
165 if (qpim_t_periodic != PIM_DEFAULT_T_PERIODIC) {
166 vty_out(vty, "ip pim join-prune-interval %d\n",
167 qpim_t_periodic);
168 ++writes;
169 }
170 if (qpim_keep_alive_time != PIM_KEEPALIVE_PERIOD) {
171 vty_out(vty, "ip pim keep-alive-timer %d\n",
172 qpim_keep_alive_time);
173 ++writes;
174 }
175 if (qpim_packet_process != PIM_DEFAULT_PACKET_PROCESS) {
176 vty_out(vty, "ip pim packets %d\n", qpim_packet_process);
177 ++writes;
178 }
179 if (ssm->plist_name) {
180 vty_out(vty, "ip pim ssm prefix-list %s\n", ssm->plist_name);
181 ++writes;
182 }
183 if (pimg->spt.switchover == PIM_SPT_INFINITY) {
184 if (pimg->spt.plist)
185 vty_out(vty,
186 "ip pim spt-switchover infinity-and-beyond prefix-list %s\n",
187 pimg->spt.plist);
188 else
189 vty_out(vty,
190 "ip pim spt-switchover infinity-and-beyond\n");
191 ++writes;
192 }
193 if (qpim_ecmp_rebalance_enable) {
194 vty_out(vty, "ip pim ecmp rebalance\n");
195 ++writes;
196 } else if (qpim_ecmp_enable) {
197 vty_out(vty, "ip pim ecmp\n");
198 ++writes;
199 }
200 if (qpim_ssmpingd_list) {
201 struct listnode *node;
202 struct ssmpingd_sock *ss;
203 vty_out(vty, "!\n");
204 ++writes;
205 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
206 char source_str[INET_ADDRSTRLEN];
207 pim_inet4_dump("<src?>", ss->source_addr, source_str,
208 sizeof(source_str));
209 vty_out(vty, "ip ssmpingd %s\n", source_str);
210 ++writes;
211 }
212 }
213
214 return writes;
215 }
216
217 int pim_interface_config_write(struct vty *vty)
218 {
219 int writes = 0;
220 struct listnode *node;
221 struct interface *ifp;
222
223 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
224
225 /* IF name */
226 vty_out(vty, "interface %s\n", ifp->name);
227 ++writes;
228
229 if (ifp->info) {
230 struct pim_interface *pim_ifp = ifp->info;
231
232 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
233 vty_out(vty, " ip pim sm\n");
234 ++writes;
235 }
236
237 /* IF ip pim drpriority */
238 if (pim_ifp->pim_dr_priority
239 != PIM_DEFAULT_DR_PRIORITY) {
240 vty_out(vty, " ip pim drpriority %u\n",
241 pim_ifp->pim_dr_priority);
242 ++writes;
243 }
244
245 /* IF ip pim hello */
246 if (pim_ifp->pim_hello_period
247 != PIM_DEFAULT_HELLO_PERIOD) {
248 vty_out(vty, " ip pim hello %d",
249 pim_ifp->pim_hello_period);
250 if (pim_ifp->pim_default_holdtime != -1)
251 vty_out(vty, " %d",
252 pim_ifp->pim_default_holdtime);
253 vty_out(vty, "\n");
254 }
255
256 /* update source */
257 if (PIM_INADDR_ISNOT_ANY(pim_ifp->update_source)) {
258 char src_str[INET_ADDRSTRLEN];
259 pim_inet4_dump("<src?>", pim_ifp->update_source,
260 src_str, sizeof(src_str));
261 vty_out(vty, " ip pim use-source %s\n",
262 src_str);
263 ++writes;
264 }
265
266 /* IF ip igmp */
267 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
268 vty_out(vty, " ip igmp\n");
269 ++writes;
270 }
271
272 /* ip igmp version */
273 if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION) {
274 vty_out(vty, " ip igmp version %d\n",
275 pim_ifp->igmp_version);
276 ++writes;
277 }
278
279 /* IF ip igmp query-interval */
280 if (pim_ifp->igmp_default_query_interval
281 != IGMP_GENERAL_QUERY_INTERVAL) {
282 vty_out(vty, " ip igmp query-interval %d\n",
283 pim_ifp->igmp_default_query_interval);
284 ++writes;
285 }
286
287 /* IF ip igmp query-max-response-time */
288 if (pim_ifp->igmp_query_max_response_time_dsec
289 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) {
290 vty_out(vty,
291 " ip igmp query-max-response-time %d\n",
292 pim_ifp->igmp_query_max_response_time_dsec);
293 ++writes;
294 }
295
296 /* IF ip igmp join */
297 if (pim_ifp->igmp_join_list) {
298 struct listnode *node;
299 struct igmp_join *ij;
300 for (ALL_LIST_ELEMENTS_RO(
301 pim_ifp->igmp_join_list, node,
302 ij)) {
303 char group_str[INET_ADDRSTRLEN];
304 char source_str[INET_ADDRSTRLEN];
305 pim_inet4_dump("<grp?>", ij->group_addr,
306 group_str,
307 sizeof(group_str));
308 inet_ntop(AF_INET, &ij->source_addr,
309 source_str,
310 sizeof(source_str));
311 vty_out(vty, " ip igmp join %s %s\n",
312 group_str, source_str);
313 ++writes;
314 }
315 }
316
317 writes += pim_static_write_mroute(vty, ifp);
318 }
319 vty_out(vty, "!\n");
320 ++writes;
321 /* PIM BFD write */
322 pim_bfd_write_config(vty, ifp);
323 }
324
325 return writes;
326 }