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"
42 #include "pim_vxlan.h"
44 int pim_debug_config_write(struct vty
*vty
)
48 if (PIM_DEBUG_MSDP_EVENTS
) {
49 vty_out(vty
, "debug msdp events\n");
52 if (PIM_DEBUG_MSDP_PACKETS
) {
53 vty_out(vty
, "debug msdp packets\n");
56 if (PIM_DEBUG_MSDP_INTERNAL
) {
57 vty_out(vty
, "debug msdp internal\n");
60 if (PIM_DEBUG_IGMP_EVENTS
) {
61 vty_out(vty
, "debug igmp events\n");
64 if (PIM_DEBUG_IGMP_PACKETS
) {
65 vty_out(vty
, "debug igmp packets\n");
68 if (PIM_DEBUG_IGMP_TRACE
) {
69 vty_out(vty
, "debug igmp trace\n");
72 if (PIM_DEBUG_IGMP_TRACE_DETAIL
) {
73 vty_out(vty
, "debug igmp trace detail\n");
77 if (PIM_DEBUG_MROUTE
) {
78 vty_out(vty
, "debug mroute\n");
82 if (PIM_DEBUG_MTRACE
) {
83 vty_out(vty
, "debug mtrace\n");
87 if (PIM_DEBUG_MROUTE_DETAIL
) {
88 vty_out(vty
, "debug mroute detail\n");
92 if (PIM_DEBUG_PIM_EVENTS
) {
93 vty_out(vty
, "debug pim events\n");
96 if (PIM_DEBUG_PIM_PACKETS
) {
97 vty_out(vty
, "debug pim packets\n");
100 if (PIM_DEBUG_PIM_PACKETDUMP_SEND
) {
101 vty_out(vty
, "debug pim packet-dump send\n");
104 if (PIM_DEBUG_PIM_PACKETDUMP_RECV
) {
105 vty_out(vty
, "debug pim packet-dump receive\n");
109 if (PIM_DEBUG_PIM_TRACE
) {
110 vty_out(vty
, "debug pim trace\n");
113 if (PIM_DEBUG_PIM_TRACE_DETAIL
) {
114 vty_out(vty
, "debug pim trace detail\n");
118 if (PIM_DEBUG_ZEBRA
) {
119 vty_out(vty
, "debug pim zebra\n");
123 if (PIM_DEBUG_VXLAN
) {
124 vty_out(vty
, "debug pim vxlan\n");
128 if (PIM_DEBUG_SSMPINGD
) {
129 vty_out(vty
, "debug ssmpingd\n");
133 if (PIM_DEBUG_PIM_HELLO
) {
134 vty_out(vty
, "debug pim packets hello\n");
138 if (PIM_DEBUG_PIM_J_P
) {
139 vty_out(vty
, "debug pim packets joins\n");
143 if (PIM_DEBUG_PIM_REG
) {
144 vty_out(vty
, "debug pim packets register\n");
148 if (PIM_DEBUG_STATIC
) {
149 vty_out(vty
, "debug pim static\n");
153 if (PIM_DEBUG_PIM_NHT
) {
154 vty_out(vty
, "debug pim nht\n");
161 int pim_global_config_write_worker(struct pim_instance
*pim
, struct vty
*vty
)
164 struct pim_ssm
*ssm
= pim
->ssm_info
;
167 if (pim
->vrf_id
== VRF_DEFAULT
)
168 sprintf(spaces
, "%s", "");
170 sprintf(spaces
, "%s", " ");
172 writes
+= pim_msdp_config_write(pim
, vty
, spaces
);
174 if (!pim
->send_v6_secondary
) {
175 vty_out(vty
, "%sno ip pim send-v6-secondary\n", spaces
);
179 writes
+= pim_rp_config_write(pim
, vty
, spaces
);
181 if (router
->register_suppress_time
182 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT
) {
183 vty_out(vty
, "%sip pim register-suppress-time %d\n", spaces
,
184 router
->register_suppress_time
);
187 if (router
->t_periodic
!= PIM_DEFAULT_T_PERIODIC
) {
188 vty_out(vty
, "%sip pim join-prune-interval %d\n", spaces
,
192 if (pim
->keep_alive_time
!= PIM_KEEPALIVE_PERIOD
) {
193 vty_out(vty
, "%sip pim keep-alive-timer %d\n", spaces
,
194 pim
->keep_alive_time
);
197 if (pim
->rp_keep_alive_time
!= (unsigned int)PIM_RP_KEEPALIVE_PERIOD
) {
198 vty_out(vty
, "%sip pim rp keep-alive-timer %d\n", spaces
,
199 pim
->rp_keep_alive_time
);
202 if (router
->packet_process
!= PIM_DEFAULT_PACKET_PROCESS
) {
203 vty_out(vty
, "%sip pim packets %d\n", spaces
,
204 router
->packet_process
);
207 if (ssm
->plist_name
) {
208 vty_out(vty
, "%sip pim ssm prefix-list %s\n", spaces
,
212 if (pim
->spt
.switchover
== PIM_SPT_INFINITY
) {
215 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
216 spaces
, pim
->spt
.plist
);
219 "%sip pim spt-switchover infinity-and-beyond\n",
223 if (pim
->ecmp_rebalance_enable
) {
224 vty_out(vty
, "%sip pim ecmp rebalance\n", spaces
);
226 } else if (pim
->ecmp_enable
) {
227 vty_out(vty
, "%sip pim ecmp\n", spaces
);
230 if (pim
->ssmpingd_list
) {
231 struct listnode
*node
;
232 struct ssmpingd_sock
*ss
;
234 for (ALL_LIST_ELEMENTS_RO(pim
->ssmpingd_list
, node
, ss
)) {
235 char source_str
[INET_ADDRSTRLEN
];
236 pim_inet4_dump("<src?>", ss
->source_addr
, source_str
,
238 vty_out(vty
, "%sip ssmpingd %s\n", spaces
, source_str
);
243 pim_vxlan_config_write(vty
, spaces
, &writes
);
248 int pim_interface_config_write(struct vty
*vty
)
250 struct pim_instance
*pim
;
251 struct interface
*ifp
;
255 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
260 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
262 if (vrf
->vrf_id
== VRF_DEFAULT
)
263 vty_frame(vty
, "interface %s\n", ifp
->name
);
265 vty_frame(vty
, "interface %s vrf %s\n",
266 ifp
->name
, vrf
->name
);
270 vty_out(vty
, " description %s\n", ifp
->desc
);
275 struct pim_interface
*pim_ifp
= ifp
->info
;
277 if (PIM_IF_TEST_PIM(pim_ifp
->options
)) {
278 vty_out(vty
, " ip pim\n");
282 /* IF ip pim drpriority */
283 if (pim_ifp
->pim_dr_priority
284 != PIM_DEFAULT_DR_PRIORITY
) {
285 vty_out(vty
, " ip pim drpriority %u\n",
286 pim_ifp
->pim_dr_priority
);
290 /* IF ip pim hello */
291 if (pim_ifp
->pim_hello_period
292 != PIM_DEFAULT_HELLO_PERIOD
) {
293 vty_out(vty
, " ip pim hello %d",
294 pim_ifp
->pim_hello_period
);
295 if (pim_ifp
->pim_default_holdtime
!= -1)
297 pim_ifp
->pim_default_holdtime
);
303 if (PIM_INADDR_ISNOT_ANY(
304 pim_ifp
->update_source
)) {
305 char src_str
[INET_ADDRSTRLEN
];
306 pim_inet4_dump("<src?>",
307 pim_ifp
->update_source
,
310 vty_out(vty
, " ip pim use-source %s\n",
316 if (PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
317 vty_out(vty
, " ip igmp\n");
321 /* ip igmp version */
322 if (pim_ifp
->igmp_version
323 != IGMP_DEFAULT_VERSION
) {
324 vty_out(vty
, " ip igmp version %d\n",
325 pim_ifp
->igmp_version
);
329 /* IF ip igmp query-max-response-time */
330 if (pim_ifp
->igmp_query_max_response_time_dsec
331 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC
) {
333 " ip igmp query-max-response-time %d\n",
334 pim_ifp
->igmp_query_max_response_time_dsec
);
338 /* IF ip igmp query-interval */
339 if (pim_ifp
->igmp_default_query_interval
340 != IGMP_GENERAL_QUERY_INTERVAL
) {
342 " ip igmp query-interval %d\n",
343 pim_ifp
->igmp_default_query_interval
);
347 /* IF ip igmp join */
348 if (pim_ifp
->igmp_join_list
) {
349 struct listnode
*node
;
350 struct igmp_join
*ij
;
351 for (ALL_LIST_ELEMENTS_RO(
352 pim_ifp
->igmp_join_list
,
354 char group_str
[INET_ADDRSTRLEN
];
367 " ip igmp join %s %s\n",
368 group_str
, source_str
);
373 if (pim_ifp
->activeactive
)
374 vty_out(vty
, " ip pim active-active\n");
377 if (pim_ifp
->boundary_oil_plist
) {
379 " ip multicast boundary oil %s\n",
380 pim_ifp
->boundary_oil_plist
);
385 pim_static_write_mroute(pim
, vty
, ifp
);
386 pim_bfd_write_config(vty
, ifp
);
388 vty_endframe(vty
, "!\n");