]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
9cf5c30469a8bdf9e76931a63c5a81e88bbde9bc
[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
42 int
43 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%s", VTY_NEWLINE);
49 ++writes;
50 }
51 if (PIM_DEBUG_MSDP_PACKETS) {
52 vty_out(vty, "debug msdp packets%s", VTY_NEWLINE);
53 ++writes;
54 }
55 if (PIM_DEBUG_MSDP_INTERNAL) {
56 vty_out(vty, "debug msdp internal%s", VTY_NEWLINE);
57 ++writes;
58 }
59 if (PIM_DEBUG_IGMP_EVENTS) {
60 vty_out(vty, "debug igmp events%s", VTY_NEWLINE);
61 ++writes;
62 }
63 if (PIM_DEBUG_IGMP_PACKETS) {
64 vty_out(vty, "debug igmp packets%s", VTY_NEWLINE);
65 ++writes;
66 }
67 if (PIM_DEBUG_IGMP_TRACE) {
68 vty_out(vty, "debug igmp trace%s", VTY_NEWLINE);
69 ++writes;
70 }
71 if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
72 vty_out(vty, "debug igmp trace detail%s", VTY_NEWLINE);
73 ++writes;
74 }
75
76 if (PIM_DEBUG_MROUTE) {
77 vty_out(vty, "debug mroute%s", VTY_NEWLINE);
78 ++writes;
79 }
80
81 if (PIM_DEBUG_MROUTE_DETAIL) {
82 vty_out (vty, "debug mroute detail%s", VTY_NEWLINE);
83 ++writes;
84 }
85
86 if (PIM_DEBUG_PIM_EVENTS) {
87 vty_out(vty, "debug pim events%s", VTY_NEWLINE);
88 ++writes;
89 }
90 if (PIM_DEBUG_PIM_PACKETS) {
91 vty_out(vty, "debug pim packets%s", VTY_NEWLINE);
92 ++writes;
93 }
94 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
95 vty_out(vty, "debug pim packet-dump send%s", VTY_NEWLINE);
96 ++writes;
97 }
98 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
99 vty_out(vty, "debug pim packet-dump receive%s", VTY_NEWLINE);
100 ++writes;
101 }
102
103 if (PIM_DEBUG_PIM_TRACE) {
104 vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
105 ++writes;
106 }
107 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
108 vty_out(vty, "debug pim trace detail%s", VTY_NEWLINE);
109 ++writes;
110 }
111
112 if (PIM_DEBUG_ZEBRA) {
113 vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
114 ++writes;
115 }
116
117 if (PIM_DEBUG_SSMPINGD) {
118 vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
119 ++writes;
120 }
121
122 if (PIM_DEBUG_PIM_HELLO) {
123 vty_out (vty, "debug pim packets hello%s", VTY_NEWLINE);
124 ++writes;
125 }
126
127 if (PIM_DEBUG_PIM_J_P) {
128 vty_out (vty, "debug pim packets joins%s", VTY_NEWLINE);
129 ++writes;
130 }
131
132 if (PIM_DEBUG_PIM_REG) {
133 vty_out (vty, "debug pim packets register%s", VTY_NEWLINE);
134 ++writes;
135 }
136
137 if (PIM_DEBUG_STATIC) {
138 vty_out (vty, "debug pim static%s", VTY_NEWLINE);
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 {
154 vty_out (vty, "no ip pim send-v6-secondary%s", VTY_NEWLINE);
155 ++writes;
156 }
157
158 writes += pim_rp_config_write (vty);
159
160 if (qpim_register_suppress_time != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT)
161 {
162 vty_out (vty, "ip pim register-suppress-time %d%s",
163 qpim_register_suppress_time, VTY_NEWLINE);
164 ++writes;
165 }
166 if (qpim_t_periodic != PIM_DEFAULT_T_PERIODIC)
167 {
168 vty_out (vty, "ip pim join-prune-interval %d%s",
169 qpim_t_periodic, VTY_NEWLINE);
170 ++writes;
171 }
172 if (qpim_keep_alive_time != PIM_KEEPALIVE_PERIOD)
173 {
174 vty_out (vty, "ip pim keep-alive-timer %d%s",
175 qpim_keep_alive_time, VTY_NEWLINE);
176 ++writes;
177 }
178 if (qpim_packet_process != PIM_DEFAULT_PACKET_PROCESS)
179 {
180 vty_out (vty, "ip pim packets %d%s",
181 qpim_packet_process, VTY_NEWLINE);
182 ++writes;
183 }
184 if (ssm->plist_name)
185 {
186 vty_out (vty, "ip pim ssm prefix-list %s%s",
187 ssm->plist_name, VTY_NEWLINE);
188 ++writes;
189 }
190 if (pimg->spt.switchover == PIM_SPT_INFINITY)
191 {
192 if (pimg->spt.plist)
193 vty_out (vty, "ip pim spt-switchover infinity-and-beyond prefix-list %s%s",
194 pimg->spt.plist, VTY_NEWLINE);
195 else
196 vty_out (vty, "ip pim spt-switchover infinity-and-beyond%s",
197 VTY_NEWLINE);
198 ++writes;
199 }
200 if (qpim_ecmp_rebalance_enable)
201 {
202 vty_out (vty, "ip pim ecmp rebalance%s", VTY_NEWLINE);
203 ++writes;
204 }
205 else if (qpim_ecmp_enable)
206 {
207 vty_out (vty, "ip pim ecmp%s", VTY_NEWLINE);
208 ++writes;
209 }
210 if (qpim_ssmpingd_list) {
211 struct listnode *node;
212 struct ssmpingd_sock *ss;
213 vty_out(vty, "!%s", VTY_NEWLINE);
214 ++writes;
215 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
216 char source_str[INET_ADDRSTRLEN];
217 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
218 vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
219 ++writes;
220 }
221 }
222
223 return writes;
224 }
225
226 int pim_interface_config_write(struct vty *vty)
227 {
228 int writes = 0;
229 struct listnode *node;
230 struct interface *ifp;
231
232 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
233
234 /* IF name */
235 vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
236 ++writes;
237
238 if (ifp->info) {
239 struct pim_interface *pim_ifp = ifp->info;
240
241 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
242 vty_out(vty, " ip pim sm%s", VTY_NEWLINE);
243 ++writes;
244 }
245
246 /* IF ip pim drpriority */
247 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
248 vty_out(vty, " ip pim drpriority %u%s", pim_ifp->pim_dr_priority,
249 VTY_NEWLINE);
250 ++writes;
251 }
252
253 /* IF ip pim hello */
254 if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
255 vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period);
256 if (pim_ifp->pim_default_holdtime != -1)
257 vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
258 vty_out(vty, "%s", VTY_NEWLINE);
259 }
260
261 /* update source */
262 if (PIM_INADDR_ISNOT_ANY(pim_ifp->update_source)) {
263 char src_str[INET_ADDRSTRLEN];
264 pim_inet4_dump("<src?>", pim_ifp->update_source, src_str,
265 sizeof(src_str));
266 vty_out(vty, " ip pim use-source %s%s", src_str, VTY_NEWLINE);
267 ++writes;
268 }
269
270 /* IF ip igmp */
271 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
272 vty_out(vty, " ip igmp%s", VTY_NEWLINE);
273 ++writes;
274 }
275
276 /* ip igmp version */
277 if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION)
278 {
279 vty_out(vty, " ip igmp version %d%s",
280 pim_ifp->igmp_version,
281 VTY_NEWLINE);
282 ++writes;
283 }
284
285 /* IF ip igmp query-interval */
286 if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL)
287 {
288 vty_out(vty, " ip igmp query-interval %d%s",
289 pim_ifp->igmp_default_query_interval,
290 VTY_NEWLINE);
291 ++writes;
292 }
293
294 /* IF ip igmp query-max-response-time */
295 if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC)
296 {
297 vty_out(vty, " ip igmp query-max-response-time %d%s",
298 pim_ifp->igmp_query_max_response_time_dsec,
299 VTY_NEWLINE);
300 ++writes;
301 }
302
303 /* IF ip igmp join */
304 if (pim_ifp->igmp_join_list) {
305 struct listnode *node;
306 struct igmp_join *ij;
307 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, node, ij)) {
308 char group_str[INET_ADDRSTRLEN];
309 char source_str[INET_ADDRSTRLEN];
310 pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
311 inet_ntop(AF_INET, &ij->source_addr, source_str, sizeof(source_str));
312 vty_out(vty, " ip igmp join %s %s%s",
313 group_str, source_str,
314 VTY_NEWLINE);
315 ++writes;
316 }
317 }
318
319 writes += pim_static_write_mroute (vty, ifp);
320 }
321 vty_out(vty, "!%s", VTY_NEWLINE);
322 ++writes;
323 }
324
325 return writes;
326 }