3 * Copyright (C) 2008 Everton da Silva Marques
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.
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.
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
31 #include "pim_iface.h"
34 #include "pim_ssmpingd.h"
37 #include "pim_static.h"
43 #include "pim_vxlan.h"
45 int pim_debug_config_write(struct vty
*vty
)
49 if (PIM_DEBUG_MSDP_EVENTS
) {
50 vty_out(vty
, "debug msdp events\n");
53 if (PIM_DEBUG_MSDP_PACKETS
) {
54 vty_out(vty
, "debug msdp packets\n");
57 if (PIM_DEBUG_MSDP_INTERNAL
) {
58 vty_out(vty
, "debug msdp internal\n");
61 if (PIM_DEBUG_IGMP_EVENTS
) {
62 vty_out(vty
, "debug igmp events\n");
65 if (PIM_DEBUG_IGMP_PACKETS
) {
66 vty_out(vty
, "debug igmp packets\n");
69 if (PIM_DEBUG_IGMP_TRACE
) {
70 vty_out(vty
, "debug igmp trace\n");
73 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
74 vty_out(vty
, "debug igmp trace detail\n");
78 if (PIM_DEBUG_MROUTE
) {
79 vty_out(vty
, "debug mroute\n");
83 if (PIM_DEBUG_MTRACE
) {
84 vty_out(vty
, "debug mtrace\n");
88 if (PIM_DEBUG_MROUTE_DETAIL
) {
89 vty_out(vty
, "debug mroute detail\n");
93 if (PIM_DEBUG_PIM_EVENTS
) {
94 vty_out(vty
, "debug pim events\n");
97 if (PIM_DEBUG_PIM_PACKETS
) {
98 vty_out(vty
, "debug pim packets\n");
101 if (PIM_DEBUG_PIM_PACKETDUMP_SEND
) {
102 vty_out(vty
, "debug pim packet-dump send\n");
105 if (PIM_DEBUG_PIM_PACKETDUMP_RECV
) {
106 vty_out(vty
, "debug pim packet-dump receive\n");
110 if (PIM_DEBUG_PIM_TRACE
) {
111 vty_out(vty
, "debug pim trace\n");
114 if (PIM_DEBUG_PIM_TRACE_DETAIL
) {
115 vty_out(vty
, "debug pim trace detail\n");
119 if (PIM_DEBUG_ZEBRA
) {
120 vty_out(vty
, "debug pim zebra\n");
125 vty_out(vty
, "debug pim bsm\n");
129 if (PIM_DEBUG_VXLAN
) {
130 vty_out(vty
, "debug pim vxlan\n");
134 if (PIM_DEBUG_SSMPINGD
) {
135 vty_out(vty
, "debug ssmpingd\n");
139 if (PIM_DEBUG_PIM_HELLO
) {
140 vty_out(vty
, "debug pim packets hello\n");
144 if (PIM_DEBUG_PIM_J_P
) {
145 vty_out(vty
, "debug pim packets joins\n");
149 if (PIM_DEBUG_PIM_REG
) {
150 vty_out(vty
, "debug pim packets register\n");
154 if (PIM_DEBUG_STATIC
) {
155 vty_out(vty
, "debug pim static\n");
159 if (PIM_DEBUG_PIM_NHT
) {
160 vty_out(vty
, "debug pim nht\n");
167 int pim_global_config_write_worker(struct pim_instance
*pim
, struct vty
*vty
)
170 struct pim_ssm
*ssm
= pim
->ssm_info
;
173 if (pim
->vrf_id
== VRF_DEFAULT
)
174 sprintf(spaces
, "%s", "");
176 sprintf(spaces
, "%s", " ");
178 writes
+= pim_msdp_config_write(pim
, vty
, spaces
);
180 if (!pim
->send_v6_secondary
) {
181 vty_out(vty
, "%sno ip pim send-v6-secondary\n", spaces
);
185 writes
+= pim_rp_config_write(pim
, vty
, spaces
);
187 if (router
->register_suppress_time
188 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT
) {
189 vty_out(vty
, "%sip pim register-suppress-time %d\n", spaces
,
190 router
->register_suppress_time
);
193 if (router
->t_periodic
!= PIM_DEFAULT_T_PERIODIC
) {
194 vty_out(vty
, "%sip pim join-prune-interval %d\n", spaces
,
198 if (pim
->keep_alive_time
!= PIM_KEEPALIVE_PERIOD
) {
199 vty_out(vty
, "%sip pim keep-alive-timer %d\n", spaces
,
200 pim
->keep_alive_time
);
203 if (pim
->rp_keep_alive_time
!= (unsigned int)PIM_RP_KEEPALIVE_PERIOD
) {
204 vty_out(vty
, "%sip pim rp keep-alive-timer %d\n", spaces
,
205 pim
->rp_keep_alive_time
);
208 if (router
->packet_process
!= PIM_DEFAULT_PACKET_PROCESS
) {
209 vty_out(vty
, "%sip pim packets %d\n", spaces
,
210 router
->packet_process
);
213 if (ssm
->plist_name
) {
214 vty_out(vty
, "%sip pim ssm prefix-list %s\n", spaces
,
218 if (pim
->spt
.switchover
== PIM_SPT_INFINITY
) {
221 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
222 spaces
, pim
->spt
.plist
);
225 "%sip pim spt-switchover infinity-and-beyond\n",
229 if (pim
->ecmp_rebalance_enable
) {
230 vty_out(vty
, "%sip pim ecmp rebalance\n", spaces
);
232 } else if (pim
->ecmp_enable
) {
233 vty_out(vty
, "%sip pim ecmp\n", spaces
);
236 if (pim
->ssmpingd_list
) {
237 struct listnode
*node
;
238 struct ssmpingd_sock
*ss
;
240 for (ALL_LIST_ELEMENTS_RO(pim
->ssmpingd_list
, node
, ss
)) {
241 char source_str
[INET_ADDRSTRLEN
];
242 pim_inet4_dump("<src?>", ss
->source_addr
, source_str
,
244 vty_out(vty
, "%sip ssmpingd %s\n", spaces
, source_str
);
249 pim_vxlan_config_write(vty
, spaces
, &writes
);
254 int pim_interface_config_write(struct vty
*vty
)
256 struct pim_instance
*pim
;
257 struct interface
*ifp
;
261 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
266 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
268 if (vrf
->vrf_id
== VRF_DEFAULT
)
269 vty_frame(vty
, "interface %s\n", ifp
->name
);
271 vty_frame(vty
, "interface %s vrf %s\n",
272 ifp
->name
, vrf
->name
);
276 vty_out(vty
, " description %s\n", ifp
->desc
);
281 struct pim_interface
*pim_ifp
= ifp
->info
;
283 if (PIM_IF_TEST_PIM(pim_ifp
->options
)) {
284 vty_out(vty
, " ip pim\n");
288 /* IF ip pim drpriority */
289 if (pim_ifp
->pim_dr_priority
290 != PIM_DEFAULT_DR_PRIORITY
) {
291 vty_out(vty
, " ip pim drpriority %u\n",
292 pim_ifp
->pim_dr_priority
);
296 /* IF ip pim hello */
297 if (pim_ifp
->pim_hello_period
298 != PIM_DEFAULT_HELLO_PERIOD
) {
299 vty_out(vty
, " ip pim hello %d",
300 pim_ifp
->pim_hello_period
);
301 if (pim_ifp
->pim_default_holdtime
!= -1)
303 pim_ifp
->pim_default_holdtime
);
309 if (PIM_INADDR_ISNOT_ANY(
310 pim_ifp
->update_source
)) {
311 char src_str
[INET_ADDRSTRLEN
];
312 pim_inet4_dump("<src?>",
313 pim_ifp
->update_source
,
316 vty_out(vty
, " ip pim use-source %s\n",
322 if (PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
323 vty_out(vty
, " ip igmp\n");
327 /* ip igmp version */
328 if (pim_ifp
->igmp_version
329 != IGMP_DEFAULT_VERSION
) {
330 vty_out(vty
, " ip igmp version %d\n",
331 pim_ifp
->igmp_version
);
335 /* IF ip igmp query-max-response-time */
336 if (pim_ifp
->igmp_query_max_response_time_dsec
337 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC
) {
339 " ip igmp query-max-response-time %d\n",
340 pim_ifp
->igmp_query_max_response_time_dsec
);
344 /* IF ip igmp query-interval */
345 if (pim_ifp
->igmp_default_query_interval
346 != IGMP_GENERAL_QUERY_INTERVAL
) {
348 " ip igmp query-interval %d\n",
349 pim_ifp
->igmp_default_query_interval
);
353 /* IF ip igmp join */
354 if (pim_ifp
->igmp_join_list
) {
355 struct listnode
*node
;
356 struct igmp_join
*ij
;
357 for (ALL_LIST_ELEMENTS_RO(
358 pim_ifp
->igmp_join_list
,
360 char group_str
[INET_ADDRSTRLEN
];
373 " ip igmp join %s %s\n",
374 group_str
, source_str
);
379 if (pim_ifp
->activeactive
)
380 vty_out(vty
, " ip pim active-active\n");
383 if (pim_ifp
->boundary_oil_plist
) {
385 " ip multicast boundary oil %s\n",
386 pim_ifp
->boundary_oil_plist
);
391 pim_static_write_mroute(pim
, vty
, ifp
);
392 pim_bsm_write_config(vty
, ifp
);
394 pim_bfd_write_config(vty
, ifp
);
397 vty_endframe(vty
, "!\n");