]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_cmd.c
pimd: Add New Source type for where a (S,G) mroute is learned
[mirror_frr.git] / pimd / pim_cmd.c
CommitLineData
12e41d03
DL
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
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19
20 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#include <sys/ioctl.h>
24
25#include <zebra.h>
26
27#include "command.h"
28#include "if.h"
29#include "prefix.h"
30#include "zclient.h"
31
32#include "pimd.h"
33#include "pim_cmd.h"
34#include "pim_iface.h"
35#include "pim_vty.h"
36#include "pim_mroute.h"
37#include "pim_str.h"
38#include "pim_igmp.h"
39#include "pim_igmpv3.h"
40#include "pim_sock.h"
41#include "pim_time.h"
42#include "pim_util.h"
43#include "pim_oil.h"
44#include "pim_neighbor.h"
45#include "pim_pim.h"
46#include "pim_ifchannel.h"
47#include "pim_hello.h"
48#include "pim_msg.h"
49#include "pim_upstream.h"
50#include "pim_rpf.h"
51#include "pim_macro.h"
52#include "pim_ssmpingd.h"
53#include "pim_zebra.h"
6250610a 54#include "pim_static.h"
12e41d03
DL
55
56static struct cmd_node pim_global_node = {
57 PIM_NODE,
58 "",
59 1 /* vtysh ? yes */
60};
61
62static struct cmd_node interface_node = {
63 INTERFACE_NODE,
64 "%s(config-if)# ",
65 1 /* vtysh ? yes */
66};
67
68static void pim_if_membership_clear(struct interface *ifp)
69{
70 struct pim_interface *pim_ifp;
71
72 pim_ifp = ifp->info;
73 zassert(pim_ifp);
74
75 if (PIM_IF_TEST_PIM(pim_ifp->options) &&
76 PIM_IF_TEST_IGMP(pim_ifp->options)) {
77 return;
78 }
79
80 pim_ifchannel_membership_clear(ifp);
81}
82
83/*
84 When PIM is disabled on interface, IGMPv3 local membership
85 information is not injected into PIM interface state.
86
87 The function pim_if_membership_refresh() fetches all IGMPv3 local
88 membership information into PIM. It is intented to be called
89 whenever PIM is enabled on the interface in order to collect missed
90 local membership information.
91 */
92static void pim_if_membership_refresh(struct interface *ifp)
93{
94 struct pim_interface *pim_ifp;
95 struct listnode *sock_node;
96 struct igmp_sock *igmp;
97
98 pim_ifp = ifp->info;
99 zassert(pim_ifp);
100
101 if (!PIM_IF_TEST_PIM(pim_ifp->options))
102 return;
103 if (!PIM_IF_TEST_IGMP(pim_ifp->options))
104 return;
105
106 /*
107 First clear off membership from all PIM (S,G) entries on the
108 interface
109 */
110
111 pim_ifchannel_membership_clear(ifp);
112
113 /*
114 Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
115 the interface
116 */
117
118 /* scan igmp sockets */
119 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
120 struct listnode *grpnode;
121 struct igmp_group *grp;
122
123 /* scan igmp groups */
124 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
125 struct listnode *srcnode;
126 struct igmp_source *src;
127
128 /* scan group sources */
129 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
130
131 if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) {
132 pim_ifchannel_local_membership_add(ifp,
133 src->source_addr,
134 grp->group_addr);
135 }
136
137 } /* scan group sources */
138 } /* scan igmp groups */
139 } /* scan igmp sockets */
140
141 /*
142 Finally delete every PIM (S,G) entry lacking all state info
143 */
144
145 pim_ifchannel_delete_on_noinfo(ifp);
146
147}
148
149static void pim_show_assert(struct vty *vty)
150{
151 struct listnode *ifnode;
152 struct interface *ifp;
153 time_t now;
154
155 now = pim_time_monotonic_sec();
156
157 vty_out(vty,
158 "Interface Address Source Group State Winner Uptime Timer%s",
159 VTY_NEWLINE);
160
469351b3 161 for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
162 struct pim_interface *pim_ifp;
163 struct in_addr ifaddr;
164 struct listnode *ch_node;
165 struct pim_ifchannel *ch;
166
167 pim_ifp = ifp->info;
168
169 if (!pim_ifp)
170 continue;
171
172 ifaddr = pim_ifp->primary_address;
173
174 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
175 char ch_src_str[100];
176 char ch_grp_str[100];
177 char winner_str[100];
178 char uptime[10];
179 char timer[10];
180
181 pim_inet4_dump("<ch_src?>", ch->source_addr,
182 ch_src_str, sizeof(ch_src_str));
183 pim_inet4_dump("<ch_grp?>", ch->group_addr,
184 ch_grp_str, sizeof(ch_grp_str));
185 pim_inet4_dump("<assrt_win?>", ch->ifassert_winner,
186 winner_str, sizeof(winner_str));
187
188 pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
189 pim_time_timer_to_mmss(timer, sizeof(timer),
190 ch->t_ifassert_timer);
191
192 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s",
193 ifp->name,
194 inet_ntoa(ifaddr),
195 ch_src_str,
196 ch_grp_str,
197 pim_ifchannel_ifassert_name(ch->ifassert_state),
198 winner_str,
199 uptime,
200 timer,
201 VTY_NEWLINE);
202 } /* scan interface channels */
203 } /* scan interfaces */
204}
205
206static void pim_show_assert_internal(struct vty *vty)
207{
208 struct listnode *ifnode;
209 struct interface *ifp;
210
211 vty_out(vty,
212 "CA: CouldAssert%s"
213 "ECA: Evaluate CouldAssert%s"
214 "ATD: AssertTrackingDesired%s"
215 "eATD: Evaluate AssertTrackingDesired%s%s",
216 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
217
218 vty_out(vty,
219 "Interface Address Source Group CA eCA ATD eATD%s",
220 VTY_NEWLINE);
221
469351b3 222 for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
223 struct pim_interface *pim_ifp;
224 struct in_addr ifaddr;
225 struct listnode *ch_node;
226 struct pim_ifchannel *ch;
227
228 pim_ifp = ifp->info;
229
230 if (!pim_ifp)
231 continue;
232
233 ifaddr = pim_ifp->primary_address;
234
235 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
236 char ch_src_str[100];
237 char ch_grp_str[100];
238
239 pim_inet4_dump("<ch_src?>", ch->source_addr,
240 ch_src_str, sizeof(ch_src_str));
241 pim_inet4_dump("<ch_grp?>", ch->group_addr,
242 ch_grp_str, sizeof(ch_grp_str));
243 vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s",
244 ifp->name,
245 inet_ntoa(ifaddr),
246 ch_src_str,
247 ch_grp_str,
248 PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
249 pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
250 PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no",
251 pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no",
252 VTY_NEWLINE);
253 } /* scan interface channels */
254 } /* scan interfaces */
255}
256
257static void pim_show_assert_metric(struct vty *vty)
258{
259 struct listnode *ifnode;
260 struct interface *ifp;
261
262 vty_out(vty,
263 "Interface Address Source Group RPT Pref Metric Address %s",
264 VTY_NEWLINE);
265
469351b3 266 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
267 struct pim_interface *pim_ifp;
268 struct in_addr ifaddr;
269 struct listnode *ch_node;
270 struct pim_ifchannel *ch;
271
272 pim_ifp = ifp->info;
273
274 if (!pim_ifp)
275 continue;
276
277 ifaddr = pim_ifp->primary_address;
278
279 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
280 char ch_src_str[100];
281 char ch_grp_str[100];
282 char addr_str[100];
283 struct pim_assert_metric am;
284
285 am = pim_macro_spt_assert_metric(&ch->upstream->rpf, pim_ifp->primary_address);
286
287 pim_inet4_dump("<ch_src?>", ch->source_addr,
288 ch_src_str, sizeof(ch_src_str));
289 pim_inet4_dump("<ch_grp?>", ch->group_addr,
290 ch_grp_str, sizeof(ch_grp_str));
291 pim_inet4_dump("<addr?>", am.ip_address,
292 addr_str, sizeof(addr_str));
293
294 vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s%s",
295 ifp->name,
296 inet_ntoa(ifaddr),
297 ch_src_str,
298 ch_grp_str,
299 am.rpt_bit_flag ? "yes" : "no",
300 am.metric_preference,
301 am.route_metric,
302 addr_str,
303 VTY_NEWLINE);
304 } /* scan interface channels */
305 } /* scan interfaces */
306}
307
308static void pim_show_assert_winner_metric(struct vty *vty)
309{
310 struct listnode *ifnode;
311 struct interface *ifp;
312
313 vty_out(vty,
314 "Interface Address Source Group RPT Pref Metric Address %s",
315 VTY_NEWLINE);
316
469351b3 317 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
318 struct pim_interface *pim_ifp;
319 struct in_addr ifaddr;
320 struct listnode *ch_node;
321 struct pim_ifchannel *ch;
322
323 pim_ifp = ifp->info;
324
325 if (!pim_ifp)
326 continue;
327
328 ifaddr = pim_ifp->primary_address;
329
330 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
331 char ch_src_str[100];
332 char ch_grp_str[100];
333 char addr_str[100];
334 struct pim_assert_metric *am;
335 char pref_str[5];
336 char metr_str[7];
337
338 am = &ch->ifassert_winner_metric;
339
340 pim_inet4_dump("<ch_src?>", ch->source_addr,
341 ch_src_str, sizeof(ch_src_str));
342 pim_inet4_dump("<ch_grp?>", ch->group_addr,
343 ch_grp_str, sizeof(ch_grp_str));
344 pim_inet4_dump("<addr?>", am->ip_address,
345 addr_str, sizeof(addr_str));
346
347 if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
348 snprintf(pref_str, sizeof(pref_str), "INFI");
349 else
350 snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference);
351
352 if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
353 snprintf(metr_str, sizeof(metr_str), "INFI");
354 else
355 snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
356
357 vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s",
358 ifp->name,
359 inet_ntoa(ifaddr),
360 ch_src_str,
361 ch_grp_str,
362 am->rpt_bit_flag ? "yes" : "no",
363 pref_str,
364 metr_str,
365 addr_str,
366 VTY_NEWLINE);
367 } /* scan interface channels */
368 } /* scan interfaces */
369}
370
371static void pim_show_membership(struct vty *vty)
372{
373 struct listnode *ifnode;
374 struct interface *ifp;
375
376 vty_out(vty,
377 "Interface Address Source Group Membership%s",
378 VTY_NEWLINE);
379
469351b3 380 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
381 struct pim_interface *pim_ifp;
382 struct in_addr ifaddr;
383 struct listnode *ch_node;
384 struct pim_ifchannel *ch;
385
386 pim_ifp = ifp->info;
387
388 if (!pim_ifp)
389 continue;
390
391 ifaddr = pim_ifp->primary_address;
392
393 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
394 char ch_src_str[100];
395 char ch_grp_str[100];
396
397 pim_inet4_dump("<ch_src?>", ch->source_addr,
398 ch_src_str, sizeof(ch_src_str));
399 pim_inet4_dump("<ch_grp?>", ch->group_addr,
400 ch_grp_str, sizeof(ch_grp_str));
401
402 vty_out(vty, "%-9s %-15s %-15s %-15s %-10s%s",
403 ifp->name,
404 inet_ntoa(ifaddr),
405 ch_src_str,
406 ch_grp_str,
407 ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ?
408 "NOINFO" : "INCLUDE",
409 VTY_NEWLINE);
410 } /* scan interface channels */
411 } /* scan interfaces */
412
413}
414
415static void igmp_show_interfaces(struct vty *vty)
416{
417 struct listnode *node;
418 struct interface *ifp;
419 time_t now;
420
421 now = pim_time_monotonic_sec();
422
423 vty_out(vty,
424 "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s",
425 VTY_NEWLINE);
426
469351b3 427 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
428 struct pim_interface *pim_ifp;
429 struct listnode *sock_node;
430 struct igmp_sock *igmp;
431
432 pim_ifp = ifp->info;
433
434 if (!pim_ifp)
435 continue;
436
437 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
438 char uptime[10];
439 int mloop;
440
441 pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
442
443 mloop = pim_socket_mcastloop_get(igmp->fd);
444
445 vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
446 ifp->name,
447 inet_ntoa(igmp->ifaddr),
448 ifp->ifindex,
449 igmp->fd,
450 uptime,
451 if_is_multicast(ifp) ? "yes" : "no",
452 if_is_broadcast(ifp) ? "yes" : "no",
453 (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
454 (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
455 (ifp->flags & IFF_PROMISC) ? "yes" : "no",
456 PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
457 VTY_NEWLINE);
458 }
459 }
460}
461
462static void igmp_show_interface_join(struct vty *vty)
463{
464 struct listnode *node;
465 struct interface *ifp;
466 time_t now;
467
468 now = pim_time_monotonic_sec();
469
470 vty_out(vty,
471 "Interface Address Source Group Socket Uptime %s",
472 VTY_NEWLINE);
473
469351b3 474 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
475 struct pim_interface *pim_ifp;
476 struct listnode *join_node;
477 struct igmp_join *ij;
478 struct in_addr pri_addr;
479 char pri_addr_str[100];
480
481 pim_ifp = ifp->info;
482
483 if (!pim_ifp)
484 continue;
485
486 if (!pim_ifp->igmp_join_list)
487 continue;
488
489 pri_addr = pim_find_primary_addr(ifp);
490 pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
491
492 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, join_node, ij)) {
493 char group_str[100];
494 char source_str[100];
495 char uptime[10];
496
497 pim_time_uptime(uptime, sizeof(uptime), now - ij->sock_creation);
498 pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
499 pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
500
501 vty_out(vty, "%-9s %-15s %-15s %-15s %6d %8s%s",
502 ifp->name,
503 pri_addr_str,
504 source_str,
505 group_str,
506 ij->sock_fd,
507 uptime,
508 VTY_NEWLINE);
509 } /* for (pim_ifp->igmp_join_list) */
510
511 } /* for (iflist) */
512
513}
514
515static void show_interface_address(struct vty *vty)
516{
517 struct listnode *ifpnode;
518 struct interface *ifp;
519
520 vty_out(vty,
521 "Interface Primary Secondary %s",
522 VTY_NEWLINE);
523
469351b3 524 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifpnode, ifp)) {
12e41d03
DL
525 struct listnode *ifcnode;
526 struct connected *ifc;
527 struct in_addr pri_addr;
528 char pri_addr_str[100];
529
530 pri_addr = pim_find_primary_addr(ifp);
531
532 pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
533
534 for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifcnode, ifc)) {
535 char sec_addr_str[100];
536 struct prefix *p = ifc->address;
537
538 if (p->family != AF_INET)
539 continue;
540
541 if (p->u.prefix4.s_addr == pri_addr.s_addr) {
542 sec_addr_str[0] = '\0';
543 }
544 else {
545 pim_inet4_dump("<sec?>", p->u.prefix4, sec_addr_str, sizeof(sec_addr_str));
546 }
547
548 vty_out(vty, "%-9s %-15s %-15s%s",
549 ifp->name,
550 pri_addr_str,
551 sec_addr_str,
552 VTY_NEWLINE);
553 }
554 }
555}
556
557static void pim_show_dr(struct vty *vty)
558{
559 struct listnode *node;
560 struct interface *ifp;
561 time_t now;
562
563 now = pim_time_monotonic_sec();
564
565 vty_out(vty,
dedccda6
DS
566 "NonPri: Number of neighbors missing DR Priority hello option%s"
567 "DrPri: Designated Router Priority sent%s%s",
568 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12e41d03 569
dedccda6 570 vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri DrPri%s", VTY_NEWLINE);
12e41d03 571
469351b3 572 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
573 struct pim_interface *pim_ifp;
574 struct in_addr ifaddr;
575 char dr_str[100];
576 char dr_uptime[10];
577
578 pim_ifp = ifp->info;
579
580 if (!pim_ifp)
581 continue;
582
583 if (pim_ifp->pim_sock_fd < 0)
584 continue;
585
586 ifaddr = pim_ifp->primary_address;
587
588 pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime),
589 now, pim_ifp->pim_dr_election_last);
590
591 pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
592 dr_str, sizeof(dr_str));
593
dedccda6 594 vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d %10d%s",
12e41d03
DL
595 ifp->name,
596 inet_ntoa(ifaddr),
597 dr_str,
598 dr_uptime,
599 pim_ifp->pim_dr_election_count,
600 pim_ifp->pim_dr_election_changes,
601 pim_ifp->pim_dr_num_nondrpri_neighbors,
dedccda6 602 pim_ifp->pim_dr_priority,
12e41d03
DL
603 VTY_NEWLINE);
604 }
605}
606
607static void pim_show_hello(struct vty *vty)
608{
609 struct listnode *node;
610 struct interface *ifp;
611 time_t now;
612
613 now = pim_time_monotonic_sec();
614
615 vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
616
469351b3 617 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
618 struct pim_interface *pim_ifp;
619 struct in_addr ifaddr;
620 char hello_period[10];
621 char hello_timer[10];
622 char stat_uptime[10];
623
624 pim_ifp = ifp->info;
625
626 if (!pim_ifp)
627 continue;
628
629 if (pim_ifp->pim_sock_fd < 0)
630 continue;
631
632 ifaddr = pim_ifp->primary_address;
633
634 pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
635 pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
636 pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
637
638 vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
639 ifp->name,
640 inet_ntoa(ifaddr),
641 hello_period,
642 hello_timer,
643 stat_uptime,
644 pim_ifp->pim_ifstat_hello_recv,
645 pim_ifp->pim_ifstat_hello_recvfail,
646 pim_ifp->pim_ifstat_hello_sent,
647 pim_ifp->pim_ifstat_hello_sendfail,
648 VTY_NEWLINE);
649 }
650}
651
652static void pim_show_interfaces(struct vty *vty)
653{
654 struct listnode *node;
655 struct interface *ifp;
656 time_t now;
657
658 now = pim_time_monotonic_sec();
659
660 vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
661
469351b3 662 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
663 struct pim_interface *pim_ifp;
664 struct in_addr ifaddr;
665 char uptime[10];
666 int mloop;
667
668 pim_ifp = ifp->info;
669
670 if (!pim_ifp)
671 continue;
672
673 if (pim_ifp->pim_sock_fd < 0)
674 continue;
675
676 ifaddr = pim_ifp->primary_address;
677
678 pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
679
680 mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
681
682 vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
683 ifp->name,
684 inet_ntoa(ifaddr),
685 ifp->ifindex,
686 pim_ifp->pim_sock_fd,
687 uptime,
688 if_is_multicast(ifp) ? "yes" : "no",
689 if_is_broadcast(ifp) ? "yes" : "no",
690 (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
691 (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
692 (ifp->flags & IFF_PROMISC) ? "yes" : "no",
693 PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
694 VTY_NEWLINE);
695 }
696}
697
698static void pim_show_join(struct vty *vty)
699{
700 struct listnode *ifnode;
701 struct interface *ifp;
702 time_t now;
703
704 now = pim_time_monotonic_sec();
705
706 vty_out(vty,
707 "Interface Address Source Group State Uptime Expire Prune%s",
708 VTY_NEWLINE);
709
469351b3 710 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
711 struct pim_interface *pim_ifp;
712 struct in_addr ifaddr;
713 struct listnode *ch_node;
714 struct pim_ifchannel *ch;
715
716 pim_ifp = ifp->info;
717
718 if (!pim_ifp)
719 continue;
720
721 ifaddr = pim_ifp->primary_address;
722
723 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
724 char ch_src_str[100];
725 char ch_grp_str[100];
726 char uptime[10];
727 char expire[10];
728 char prune[10];
729
730 pim_inet4_dump("<ch_src?>", ch->source_addr,
731 ch_src_str, sizeof(ch_src_str));
732 pim_inet4_dump("<ch_grp?>", ch->group_addr,
733 ch_grp_str, sizeof(ch_grp_str));
734
735 pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation);
736 pim_time_timer_to_mmss(expire, sizeof(expire),
737 ch->t_ifjoin_expiry_timer);
738 pim_time_timer_to_mmss(prune, sizeof(prune),
739 ch->t_ifjoin_prune_pending_timer);
740
741 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
742 ifp->name,
743 inet_ntoa(ifaddr),
744 ch_src_str,
745 ch_grp_str,
746 pim_ifchannel_ifjoin_name(ch->ifjoin_state),
747 uptime,
748 expire,
749 prune,
750 VTY_NEWLINE);
751 } /* scan interface channels */
752 } /* scan interfaces */
753
754}
755
756static void pim_show_neighbors(struct vty *vty)
757{
758 struct listnode *node;
759 struct interface *ifp;
760 time_t now;
761
762 now = pim_time_monotonic_sec();
763
764 vty_out(vty,
765 "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
766 " T=can_disable_join_suppression%s%s",
767 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
768
769 vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
770
469351b3 771 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
772 struct pim_interface *pim_ifp;
773 struct in_addr ifaddr;
774 struct listnode *neighnode;
775 struct pim_neighbor *neigh;
776
777 pim_ifp = ifp->info;
778
779 if (!pim_ifp)
780 continue;
781
782 if (pim_ifp->pim_sock_fd < 0)
783 continue;
784
785 ifaddr = pim_ifp->primary_address;
786
787 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
788 char uptime[10];
789 char holdtime[10];
790 char expire[10];
791 char neigh_src_str[100];
792 char recv[7];
793
794 pim_inet4_dump("<src?>", neigh->source_addr,
795 neigh_src_str, sizeof(neigh_src_str));
796 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
797 pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
798 pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
799
800 recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
801 recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
802 recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
803 recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
804 recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
805 recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
806 recv[6] = '\0';
807
808 vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
809 ifp->name,
810 inet_ntoa(ifaddr),
811 neigh_src_str,
812 uptime,
813 expire,
814 holdtime,
815 neigh->dr_priority,
816 neigh->generation_id,
817 recv,
818 VTY_NEWLINE);
819 }
820
821
822 }
823}
824
825static void pim_show_lan_prune_delay(struct vty *vty)
826{
827 struct listnode *node;
828 struct interface *ifp;
829
830 vty_out(vty,
831 "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
832 "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
833 "NoDly=number_of_non_lan_delay_neighbors%s"
834 "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
835 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
836
837 vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T | Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE);
838
469351b3 839 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
840 struct pim_interface *pim_ifp;
841 struct in_addr ifaddr;
842 struct listnode *neighnode;
843 struct pim_neighbor *neigh;
844
845 pim_ifp = ifp->info;
846
847 if (!pim_ifp)
848 continue;
849
850 if (pim_ifp->pim_sock_fd < 0)
851 continue;
852
853 ifaddr = pim_ifp->primary_address;
854
855 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
856 char neigh_src_str[100];
857
858 pim_inet4_dump("<src?>", neigh->source_addr,
859 neigh_src_str, sizeof(neigh_src_str));
860
861 vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u | %-15s %-3s %5u %5u %1u%s",
862 ifp->name,
863 inet_ntoa(ifaddr),
864 pim_ifp->pim_propagation_delay_msec,
865 pim_ifp->pim_override_interval_msec,
866 pim_ifp->pim_number_of_nonlandelay_neighbors,
867 pim_ifp->pim_neighbors_highest_propagation_delay_msec,
868 pim_ifp->pim_neighbors_highest_override_interval_msec,
869 PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
870 neigh_src_str,
871 PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
872 neigh->propagation_delay_msec,
873 neigh->override_interval_msec,
874 PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
875 PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
876 VTY_NEWLINE);
877 }
878
879 }
880}
881
882static void pim_show_jp_override_interval(struct vty *vty)
883{
884 struct listnode *node;
885 struct interface *ifp;
886
887 vty_out(vty,
888 "EffPDelay=effective_propagation_delay (msec)%s"
889 "EffOvrInt=override_interval (msec)%s"
890 "JPOvrInt=jp_override_interval (msec)%s%s",
891 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
892
893 vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
894
469351b3 895 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
896 struct pim_interface *pim_ifp;
897 struct in_addr ifaddr;
898
899 pim_ifp = ifp->info;
900
901 if (!pim_ifp)
902 continue;
903
904 if (pim_ifp->pim_sock_fd < 0)
905 continue;
906
907 ifaddr = pim_ifp->primary_address;
908
909 vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
910 ifp->name,
911 inet_ntoa(ifaddr),
912 pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
913 pim_if_effective_propagation_delay_msec(ifp),
914 pim_if_effective_override_interval_msec(ifp),
915 pim_if_jp_override_interval_msec(ifp),
916 VTY_NEWLINE);
917 }
918}
919
920static void pim_show_neighbors_secondary(struct vty *vty)
921{
922 struct listnode *node;
923 struct interface *ifp;
924
925 vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
926
469351b3 927 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
928 struct pim_interface *pim_ifp;
929 struct in_addr ifaddr;
930 struct listnode *neighnode;
931 struct pim_neighbor *neigh;
932
933 pim_ifp = ifp->info;
934
935 if (!pim_ifp)
936 continue;
937
938 if (pim_ifp->pim_sock_fd < 0)
939 continue;
940
941 ifaddr = pim_ifp->primary_address;
942
943 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
944 char neigh_src_str[100];
945 struct listnode *prefix_node;
946 struct prefix *p;
947
948 if (!neigh->prefix_list)
949 continue;
950
951 pim_inet4_dump("<src?>", neigh->source_addr,
952 neigh_src_str, sizeof(neigh_src_str));
953
954 for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
955 char neigh_sec_str[100];
956
957 if (p->family != AF_INET)
958 continue;
959
960 pim_inet4_dump("<src?>", p->u.prefix4,
961 neigh_sec_str, sizeof(neigh_sec_str));
962
963 vty_out(vty, "%-9s %-15s %-15s %-15s%s",
964 ifp->name,
965 inet_ntoa(ifaddr),
966 neigh_src_str,
967 neigh_sec_str,
968 VTY_NEWLINE);
969 }
970 }
971 }
972}
973
974static void pim_show_upstream(struct vty *vty)
975{
976 struct listnode *upnode;
977 struct pim_upstream *up;
978 time_t now;
979
980 now = pim_time_monotonic_sec();
981
982 vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
983
984 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
985 char src_str[100];
986 char grp_str[100];
987 char uptime[10];
988 char join_timer[10];
989
990 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
991 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
992 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
993 pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
994
995 vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
996 src_str,
997 grp_str,
998 up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
999 uptime,
1000 join_timer,
1001 up->ref_count,
1002 VTY_NEWLINE);
1003 }
1004}
1005
1006static void pim_show_join_desired(struct vty *vty)
1007{
1008 struct listnode *ifnode;
1009 struct listnode *chnode;
1010 struct interface *ifp;
1011 struct pim_interface *pim_ifp;
1012 struct pim_ifchannel *ch;
1013 char src_str[100];
1014 char grp_str[100];
1015
1016 vty_out(vty,
1017 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
1018 VTY_NEWLINE);
1019
1020 /* scan all interfaces */
469351b3 1021 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1022 pim_ifp = ifp->info;
1023 if (!pim_ifp)
1024 continue;
1025
1026 /* scan per-interface (S,G) state */
1027 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
1028 struct pim_upstream *up = ch->upstream;
1029
1030 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1031 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1032
1033 vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
1034 ifp->name,
1035 src_str,
1036 grp_str,
1037 pim_macro_ch_lost_assert(ch) ? "yes" : "no",
1038 pim_macro_chisin_joins(ch) ? "yes" : "no",
1039 pim_macro_chisin_pim_include(ch) ? "yes" : "no",
1040 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
1041 pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
1042 VTY_NEWLINE);
1043 }
1044 }
1045}
1046
1047static void pim_show_upstream_rpf(struct vty *vty)
1048{
1049 struct listnode *upnode;
1050 struct pim_upstream *up;
1051
1052 vty_out(vty,
1053 "Source Group RpfIface RibNextHop RpfAddress %s",
1054 VTY_NEWLINE);
1055
1056 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
1057 char src_str[100];
1058 char grp_str[100];
1059 char rpf_nexthop_str[100];
1060 char rpf_addr_str[100];
1061 struct pim_rpf *rpf;
1062 const char *rpf_ifname;
1063
1064 rpf = &up->rpf;
1065
1066 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1067 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1068 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
1069 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1070
1071 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1072
1073 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
1074 src_str,
1075 grp_str,
1076 rpf_ifname,
1077 rpf_nexthop_str,
1078 rpf_addr_str,
1079 VTY_NEWLINE);
1080 }
1081}
1082
1083static void show_rpf_refresh_stats(struct vty *vty, time_t now)
1084{
1085 char refresh_uptime[10];
1086
1087 pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
1088
1089 vty_out(vty,
1090 "RPF Cache Refresh Delay: %ld msecs%s"
1091 "RPF Cache Refresh Timer: %ld msecs%s"
1092 "RPF Cache Refresh Requests: %lld%s"
1093 "RPF Cache Refresh Events: %lld%s"
1094 "RPF Cache Refresh Last: %s%s",
1095 qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
1096 pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
1097 (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
1098 (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
1099 refresh_uptime, VTY_NEWLINE);
1100}
1101
1102static void show_scan_oil_stats(struct vty *vty, time_t now)
1103{
1104 char uptime_scan_oil[10];
1105 char uptime_mroute_add[10];
1106 char uptime_mroute_del[10];
1107
1108 pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last);
1109 pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last);
1110 pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last);
1111
1112 vty_out(vty,
1113 "Scan OIL - Last: %s Events: %lld%s"
1114 "MFC Add - Last: %s Events: %lld%s"
1115 "MFC Del - Last: %s Events: %lld%s",
1116 uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE,
1117 uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE,
1118 uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE);
1119}
1120
1121static void pim_show_rpf(struct vty *vty)
1122{
1123 struct listnode *up_node;
1124 struct pim_upstream *up;
1125 time_t now = pim_time_monotonic_sec();
1126
1127 show_rpf_refresh_stats(vty, now);
1128
1129 vty_out(vty, "%s", VTY_NEWLINE);
1130
1131 vty_out(vty,
1132 "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
1133 VTY_NEWLINE);
1134
1135 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
1136 char src_str[100];
1137 char grp_str[100];
1138 char rpf_addr_str[100];
1139 char rib_nexthop_str[100];
1140 const char *rpf_ifname;
1141 struct pim_rpf *rpf = &up->rpf;
1142
1143 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1144 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1145 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1146 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
1147
1148 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1149
1150 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
1151 src_str,
1152 grp_str,
1153 rpf_ifname,
1154 rpf_addr_str,
1155 rib_nexthop_str,
1156 rpf->source_nexthop.mrib_route_metric,
1157 rpf->source_nexthop.mrib_metric_preference,
1158 VTY_NEWLINE);
1159 }
1160}
1161
1162static void igmp_show_querier(struct vty *vty)
1163{
1164 struct listnode *node;
1165 struct interface *ifp;
1166
1167 vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
1168
469351b3 1169 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
1170 struct pim_interface *pim_ifp = ifp->info;
1171 struct listnode *sock_node;
1172 struct igmp_sock *igmp;
1173
1174 if (!pim_ifp)
1175 continue;
1176
1177 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1178 char query_hhmmss[10];
1179 char other_hhmmss[10];
1180
1181 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
1182 pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
1183
1184 vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
1185 ifp->name,
1186 inet_ntoa(igmp->ifaddr),
1187 igmp->t_igmp_query_timer ? "THIS" : "OTHER",
1188 igmp->startup_query_count,
1189 query_hhmmss,
1190 other_hhmmss,
1191 VTY_NEWLINE);
1192 }
1193 }
1194}
1195
1196static void igmp_show_groups(struct vty *vty)
1197{
1198 struct listnode *ifnode;
1199 struct interface *ifp;
1200 time_t now;
1201
1202 now = pim_time_monotonic_sec();
1203
1204 vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
1205
1206 /* scan interfaces */
469351b3 1207 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1208 struct pim_interface *pim_ifp = ifp->info;
1209 struct listnode *sock_node;
1210 struct igmp_sock *igmp;
1211
1212 if (!pim_ifp)
1213 continue;
1214
1215 /* scan igmp sockets */
1216 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1217 char ifaddr_str[100];
1218 struct listnode *grpnode;
1219 struct igmp_group *grp;
1220
1221 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1222
1223 /* scan igmp groups */
1224 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1225 char group_str[100];
1226 char hhmmss[10];
1227 char uptime[10];
1228
1229 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1230 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
1231 pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
1232
1233 vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
1234 ifp->name,
1235 ifaddr_str,
1236 group_str,
1237 grp->group_filtermode_isexcl ? "EXCL" : "INCL",
1238 hhmmss,
1239 grp->group_source_list ? listcount(grp->group_source_list) : 0,
1240 igmp_group_compat_mode(igmp, grp),
1241 uptime,
1242 VTY_NEWLINE);
1243
1244 } /* scan igmp groups */
1245 } /* scan igmp sockets */
1246 } /* scan interfaces */
1247}
1248
1249static void igmp_show_group_retransmission(struct vty *vty)
1250{
1251 struct listnode *ifnode;
1252 struct interface *ifp;
1253
1254 vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
1255
1256 /* scan interfaces */
469351b3 1257 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1258 struct pim_interface *pim_ifp = ifp->info;
1259 struct listnode *sock_node;
1260 struct igmp_sock *igmp;
1261
1262 if (!pim_ifp)
1263 continue;
1264
1265 /* scan igmp sockets */
1266 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1267 char ifaddr_str[100];
1268 struct listnode *grpnode;
1269 struct igmp_group *grp;
1270
1271 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1272
1273 /* scan igmp groups */
1274 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1275 char group_str[100];
1276 char grp_retr_mmss[10];
1277 struct listnode *src_node;
1278 struct igmp_source *src;
1279 int grp_retr_sources = 0;
1280
1281 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1282 pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
1283
1284
1285 /* count group sources with retransmission state */
1286 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
1287 if (src->source_query_retransmit_count > 0) {
1288 ++grp_retr_sources;
1289 }
1290 }
1291
1292 vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
1293 ifp->name,
1294 ifaddr_str,
1295 group_str,
1296 grp_retr_mmss,
1297 grp->group_specific_query_retransmit_count,
1298 grp_retr_sources,
1299 VTY_NEWLINE);
1300
1301 } /* scan igmp groups */
1302 } /* scan igmp sockets */
1303 } /* scan interfaces */
1304}
1305
1306static void igmp_show_parameters(struct vty *vty)
1307{
1308 struct listnode *ifnode;
1309 struct interface *ifp;
1310
1311 vty_out(vty,
1312 "QRV: Robustness Variable SQI: Startup Query Interval%s"
1313 "QQI: Query Interval OQPI: Other Querier Present Interval%s"
1314 "QRI: Query Response Interval LMQT: Last Member Query Time%s"
1315 "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
1316 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1317
1318 vty_out(vty,
1319 "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
1320 VTY_NEWLINE);
1321
1322 /* scan interfaces */
469351b3 1323 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1324 struct pim_interface *pim_ifp = ifp->info;
1325 struct listnode *sock_node;
1326 struct igmp_sock *igmp;
1327
1328 if (!pim_ifp)
1329 continue;
1330
1331 /* scan igmp sockets */
1332 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1333 char ifaddr_str[100];
1334 long gmi_dsec; /* Group Membership Interval */
1335 long oqpi_dsec; /* Other Querier Present Interval */
1336 int sqi;
1337 long lmqt_dsec;
1338 long ohpi_dsec;
1339 long qri_dsec;
1340
1341 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1342
1343 gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
1344 igmp->querier_query_interval,
1345 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1346
1347 sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
1348
1349 oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
1350 igmp->querier_query_interval,
1351 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1352
1353 lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
1354 igmp->querier_robustness_variable) / 100;
1355
1356 ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
1357 igmp->querier_query_interval,
1358 pim_ifp->igmp_query_max_response_time_dsec);
1359
1360 qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
1361
1362 vty_out(vty,
1363 "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
1364 ifp->name,
1365 ifaddr_str,
1366 igmp->querier_robustness_variable,
1367 igmp->querier_query_interval,
1368 qri_dsec / 10, qri_dsec % 10,
1369 gmi_dsec / 10, gmi_dsec % 10,
1370 sqi,
1371 oqpi_dsec / 10, oqpi_dsec % 10,
1372 lmqt_dsec / 10, lmqt_dsec % 10,
1373 ohpi_dsec / 10, ohpi_dsec % 10,
1374 VTY_NEWLINE);
1375
1376 } /* scan igmp sockets */
1377 } /* scan interfaces */
1378}
1379
1380static void igmp_show_sources(struct vty *vty)
1381{
1382 struct listnode *ifnode;
1383 struct interface *ifp;
1384 time_t now;
1385
1386 now = pim_time_monotonic_sec();
1387
1388 vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
1389
1390 /* scan interfaces */
469351b3 1391 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1392 struct pim_interface *pim_ifp = ifp->info;
1393 struct listnode *sock_node;
1394 struct igmp_sock *igmp;
1395
1396 if (!pim_ifp)
1397 continue;
1398
1399 /* scan igmp sockets */
1400 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1401 char ifaddr_str[100];
1402 struct listnode *grpnode;
1403 struct igmp_group *grp;
1404
1405 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1406
1407 /* scan igmp groups */
1408 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1409 char group_str[100];
1410 struct listnode *srcnode;
1411 struct igmp_source *src;
1412
1413 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1414
1415 /* scan group sources */
1416 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1417 char source_str[100];
1418 char mmss[10];
1419 char uptime[10];
1420
1421 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1422
1423 pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
1424
1425 pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
1426
1427 vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
1428 ifp->name,
1429 ifaddr_str,
1430 group_str,
1431 source_str,
1432 mmss,
1433 IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
1434 uptime,
1435 VTY_NEWLINE);
1436
1437 } /* scan group sources */
1438 } /* scan igmp groups */
1439 } /* scan igmp sockets */
1440 } /* scan interfaces */
1441}
1442
1443static void igmp_show_source_retransmission(struct vty *vty)
1444{
1445 struct listnode *ifnode;
1446 struct interface *ifp;
1447
1448 vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
1449
1450 /* scan interfaces */
469351b3 1451 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
1452 struct pim_interface *pim_ifp = ifp->info;
1453 struct listnode *sock_node;
1454 struct igmp_sock *igmp;
1455
1456 if (!pim_ifp)
1457 continue;
1458
1459 /* scan igmp sockets */
1460 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1461 char ifaddr_str[100];
1462 struct listnode *grpnode;
1463 struct igmp_group *grp;
1464
1465 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1466
1467 /* scan igmp groups */
1468 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1469 char group_str[100];
1470 struct listnode *srcnode;
1471 struct igmp_source *src;
1472
1473 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1474
1475 /* scan group sources */
1476 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1477 char source_str[100];
1478
1479 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1480
1481 vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
1482 ifp->name,
1483 ifaddr_str,
1484 group_str,
1485 source_str,
1486 src->source_query_retransmit_count,
1487 VTY_NEWLINE);
1488
1489 } /* scan group sources */
1490 } /* scan igmp groups */
1491 } /* scan igmp sockets */
1492 } /* scan interfaces */
1493}
1494
1495static void clear_igmp_interfaces()
1496{
1497 struct listnode *ifnode;
1498 struct listnode *ifnextnode;
1499 struct interface *ifp;
1500
469351b3 1501 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
1502 pim_if_addr_del_all_igmp(ifp);
1503 }
1504
469351b3 1505 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
1506 pim_if_addr_add_all(ifp);
1507 }
1508}
1509
1510static void clear_pim_interfaces()
1511{
1512 struct listnode *ifnode;
1513 struct listnode *ifnextnode;
1514 struct interface *ifp;
1515
469351b3 1516 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
1517 if (ifp->info) {
1518 pim_neighbor_delete_all(ifp, "interface cleared");
1519 }
1520 }
1521}
1522
1523static void clear_interfaces()
1524{
1525 clear_igmp_interfaces();
1526 clear_pim_interfaces();
1527}
1528
1529DEFUN (pim_interface,
1530 pim_interface_cmd,
1531 "interface IFNAME",
1532 "Select an interface to configure\n"
1533 "Interface's name\n")
1534{
1535 struct interface *ifp;
1536 const char *ifname = argv[0];
1537 size_t sl;
1538
1539 sl = strlen(ifname);
1540 if (sl > INTERFACE_NAMSIZ) {
1541 vty_out(vty, "%% Interface name %s is invalid: length exceeds "
1542 "%d characters%s",
1543 ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546
1547 ifp = if_lookup_by_name_len(ifname, sl);
1548 if (!ifp) {
1549 vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
1550
1551 /* Returning here would prevent pimd from booting when there are
1552 interface commands in pimd.conf, since all interfaces are
1553 unknown at pimd boot time (the zebra daemon has not been
1554 contacted for interface discovery). */
1555
1556 ifp = if_get_by_name_len(ifname, sl);
1557 if (!ifp) {
1558 vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
1559 return CMD_WARNING;
1560 }
1561 }
1562
1563 vty->index = ifp;
1564 vty->node = INTERFACE_NODE;
1565
1566 return CMD_SUCCESS;
1567}
1568
1569DEFUN (clear_ip_interfaces,
1570 clear_ip_interfaces_cmd,
1571 "clear ip interfaces",
1572 CLEAR_STR
1573 IP_STR
1574 "Reset interfaces\n")
1575{
1576 clear_interfaces();
1577
1578 return CMD_SUCCESS;
1579}
1580
1581DEFUN (clear_ip_igmp_interfaces,
1582 clear_ip_igmp_interfaces_cmd,
1583 "clear ip igmp interfaces",
1584 CLEAR_STR
1585 IP_STR
1586 CLEAR_IP_IGMP_STR
1587 "Reset IGMP interfaces\n")
1588{
1589 clear_igmp_interfaces();
1590
1591 return CMD_SUCCESS;
1592}
1593
1594static void mroute_add_all()
1595{
1596 struct listnode *node;
1597 struct channel_oil *c_oil;
1598
1599 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1600 if (pim_mroute_add(&c_oil->oil)) {
1601 /* just log warning */
1602 char source_str[100];
1603 char group_str[100];
1604 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1605 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1606 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
1607 __FILE__, __PRETTY_FUNCTION__,
1608 source_str, group_str);
1609 }
1610 }
1611}
1612
1613static void mroute_del_all()
1614{
1615 struct listnode *node;
1616 struct channel_oil *c_oil;
1617
1618 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1619 if (pim_mroute_del(&c_oil->oil)) {
1620 /* just log warning */
1621 char source_str[100];
1622 char group_str[100];
1623 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1624 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1625 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
1626 __FILE__, __PRETTY_FUNCTION__,
1627 source_str, group_str);
1628 }
1629 }
1630}
1631
6250610a
JAG
1632static void static_mroute_add_all()
1633{
1634 struct listnode *node;
1635 struct static_route *s_route;
1636
1637 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
1638 if (pim_mroute_add(&s_route->mc)) {
1639 /* just log warning */
1640 char source_str[100];
1641 char group_str[100];
1642 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
1643 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
1644 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
1645 __FILE__, __PRETTY_FUNCTION__,
1646 source_str, group_str);
1647 }
1648 }
1649}
1650
1651static void static_mroute_del_all()
1652{
1653 struct listnode *node;
1654 struct static_route *s_route;
1655
1656 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
1657 if (pim_mroute_del(&s_route->mc)) {
1658 /* just log warning */
1659 char source_str[100];
1660 char group_str[100];
1661 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
1662 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
1663 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
1664 __FILE__, __PRETTY_FUNCTION__,
1665 source_str, group_str);
1666 }
1667 }
1668}
1669
12e41d03
DL
1670DEFUN (clear_ip_mroute,
1671 clear_ip_mroute_cmd,
1672 "clear ip mroute",
1673 CLEAR_STR
1674 IP_STR
1675 "Reset multicast routes\n")
1676{
1677 mroute_del_all();
1678 mroute_add_all();
1679
1680 return CMD_SUCCESS;
1681}
1682
1683DEFUN (clear_ip_pim_interfaces,
1684 clear_ip_pim_interfaces_cmd,
1685 "clear ip pim interfaces",
1686 CLEAR_STR
1687 IP_STR
1688 CLEAR_IP_PIM_STR
1689 "Reset PIM interfaces\n")
1690{
1691 clear_pim_interfaces();
1692
1693 return CMD_SUCCESS;
1694}
1695
1696DEFUN (clear_ip_pim_oil,
1697 clear_ip_pim_oil_cmd,
1698 "clear ip pim oil",
1699 CLEAR_STR
1700 IP_STR
1701 CLEAR_IP_PIM_STR
1702 "Rescan PIM OIL (output interface list)\n")
1703{
1704 pim_scan_oil();
1705
1706 return CMD_SUCCESS;
1707}
1708
1709DEFUN (show_ip_igmp_interface,
1710 show_ip_igmp_interface_cmd,
1711 "show ip igmp interface",
1712 SHOW_STR
1713 IP_STR
1714 IGMP_STR
1715 "IGMP interface information\n")
1716{
1717 igmp_show_interfaces(vty);
1718
1719 return CMD_SUCCESS;
1720}
1721
1722DEFUN (show_ip_igmp_join,
1723 show_ip_igmp_join_cmd,
1724 "show ip igmp join",
1725 SHOW_STR
1726 IP_STR
1727 IGMP_STR
1728 "IGMP static join information\n")
1729{
1730 igmp_show_interface_join(vty);
1731
1732 return CMD_SUCCESS;
1733}
1734
1735DEFUN (show_ip_igmp_groups,
1736 show_ip_igmp_groups_cmd,
1737 "show ip igmp groups",
1738 SHOW_STR
1739 IP_STR
1740 IGMP_STR
1741 IGMP_GROUP_STR)
1742{
1743 igmp_show_groups(vty);
1744
1745 return CMD_SUCCESS;
1746}
1747
1748DEFUN (show_ip_igmp_groups_retransmissions,
1749 show_ip_igmp_groups_retransmissions_cmd,
1750 "show ip igmp groups retransmissions",
1751 SHOW_STR
1752 IP_STR
1753 IGMP_STR
1754 IGMP_GROUP_STR
1755 "IGMP group retransmissions\n")
1756{
1757 igmp_show_group_retransmission(vty);
1758
1759 return CMD_SUCCESS;
1760}
1761
1762DEFUN (show_ip_igmp_parameters,
1763 show_ip_igmp_parameters_cmd,
1764 "show ip igmp parameters",
1765 SHOW_STR
1766 IP_STR
1767 IGMP_STR
1768 "IGMP parameters information\n")
1769{
1770 igmp_show_parameters(vty);
1771
1772 return CMD_SUCCESS;
1773}
1774
1775DEFUN (show_ip_igmp_sources,
1776 show_ip_igmp_sources_cmd,
1777 "show ip igmp sources",
1778 SHOW_STR
1779 IP_STR
1780 IGMP_STR
1781 IGMP_SOURCE_STR)
1782{
1783 igmp_show_sources(vty);
1784
1785 return CMD_SUCCESS;
1786}
1787
1788DEFUN (show_ip_igmp_sources_retransmissions,
1789 show_ip_igmp_sources_retransmissions_cmd,
1790 "show ip igmp sources retransmissions",
1791 SHOW_STR
1792 IP_STR
1793 IGMP_STR
1794 IGMP_SOURCE_STR
1795 "IGMP source retransmissions\n")
1796{
1797 igmp_show_source_retransmission(vty);
1798
1799 return CMD_SUCCESS;
1800}
1801
1802DEFUN (show_ip_igmp_querier,
1803 show_ip_igmp_querier_cmd,
1804 "show ip igmp querier",
1805 SHOW_STR
1806 IP_STR
1807 IGMP_STR
1808 "IGMP querier information\n")
1809{
1810 igmp_show_querier(vty);
1811
1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN (show_ip_pim_address,
1816 show_ip_pim_address_cmd,
1817 "show ip pim address",
1818 SHOW_STR
1819 IP_STR
1820 PIM_STR
1821 "PIM interface address\n")
1822{
1823 show_interface_address(vty);
1824
1825 return CMD_SUCCESS;
1826}
1827
1828DEFUN (show_ip_pim_assert,
1829 show_ip_pim_assert_cmd,
1830 "show ip pim assert",
1831 SHOW_STR
1832 IP_STR
1833 PIM_STR
1834 "PIM interface assert\n")
1835{
1836 pim_show_assert(vty);
1837
1838 return CMD_SUCCESS;
1839}
1840
1841DEFUN (show_ip_pim_assert_internal,
1842 show_ip_pim_assert_internal_cmd,
1843 "show ip pim assert-internal",
1844 SHOW_STR
1845 IP_STR
1846 PIM_STR
1847 "PIM interface internal assert state\n")
1848{
1849 pim_show_assert_internal(vty);
1850
1851 return CMD_SUCCESS;
1852}
1853
1854DEFUN (show_ip_pim_assert_metric,
1855 show_ip_pim_assert_metric_cmd,
1856 "show ip pim assert-metric",
1857 SHOW_STR
1858 IP_STR
1859 PIM_STR
1860 "PIM interface assert metric\n")
1861{
1862 pim_show_assert_metric(vty);
1863
1864 return CMD_SUCCESS;
1865}
1866
1867DEFUN (show_ip_pim_assert_winner_metric,
1868 show_ip_pim_assert_winner_metric_cmd,
1869 "show ip pim assert-winner-metric",
1870 SHOW_STR
1871 IP_STR
1872 PIM_STR
1873 "PIM interface assert winner metric\n")
1874{
1875 pim_show_assert_winner_metric(vty);
1876
1877 return CMD_SUCCESS;
1878}
1879
1880DEFUN (show_ip_pim_dr,
1881 show_ip_pim_dr_cmd,
1882 "show ip pim designated-router",
1883 SHOW_STR
1884 IP_STR
1885 PIM_STR
1886 "PIM interface designated router\n")
1887{
1888 pim_show_dr(vty);
1889
1890 return CMD_SUCCESS;
1891}
1892
1893DEFUN (show_ip_pim_hello,
1894 show_ip_pim_hello_cmd,
1895 "show ip pim hello",
1896 SHOW_STR
1897 IP_STR
1898 PIM_STR
1899 "PIM interface hello information\n")
1900{
1901 pim_show_hello(vty);
1902
1903 return CMD_SUCCESS;
1904}
1905
1906DEFUN (show_ip_pim_interface,
1907 show_ip_pim_interface_cmd,
1908 "show ip pim interface",
1909 SHOW_STR
1910 IP_STR
1911 PIM_STR
1912 "PIM interface information\n")
1913{
1914 pim_show_interfaces(vty);
1915
1916 return CMD_SUCCESS;
1917}
1918
1919DEFUN (show_ip_pim_join,
1920 show_ip_pim_join_cmd,
1921 "show ip pim join",
1922 SHOW_STR
1923 IP_STR
1924 PIM_STR
1925 "PIM interface join information\n")
1926{
1927 pim_show_join(vty);
1928
1929 return CMD_SUCCESS;
1930}
1931
1932DEFUN (show_ip_pim_lan_prune_delay,
1933 show_ip_pim_lan_prune_delay_cmd,
1934 "show ip pim lan-prune-delay",
1935 SHOW_STR
1936 IP_STR
1937 PIM_STR
1938 "PIM neighbors LAN prune delay parameters\n")
1939{
1940 pim_show_lan_prune_delay(vty);
1941
1942 return CMD_SUCCESS;
1943}
1944
1945DEFUN (show_ip_pim_local_membership,
1946 show_ip_pim_local_membership_cmd,
1947 "show ip pim local-membership",
1948 SHOW_STR
1949 IP_STR
1950 PIM_STR
1951 "PIM interface local-membership\n")
1952{
1953 pim_show_membership(vty);
1954
1955 return CMD_SUCCESS;
1956}
1957
1958DEFUN (show_ip_pim_jp_override_interval,
1959 show_ip_pim_jp_override_interval_cmd,
1960 "show ip pim jp-override-interval",
1961 SHOW_STR
1962 IP_STR
1963 PIM_STR
1964 "PIM interface J/P override interval\n")
1965{
1966 pim_show_jp_override_interval(vty);
1967
1968 return CMD_SUCCESS;
1969}
1970
1971DEFUN (show_ip_pim_neighbor,
1972 show_ip_pim_neighbor_cmd,
1973 "show ip pim neighbor",
1974 SHOW_STR
1975 IP_STR
1976 PIM_STR
1977 "PIM neighbor information\n")
1978{
1979 pim_show_neighbors(vty);
1980
1981 return CMD_SUCCESS;
1982}
1983
1984DEFUN (show_ip_pim_secondary,
1985 show_ip_pim_secondary_cmd,
1986 "show ip pim secondary",
1987 SHOW_STR
1988 IP_STR
1989 PIM_STR
1990 "PIM neighbor addresses\n")
1991{
1992 pim_show_neighbors_secondary(vty);
1993
1994 return CMD_SUCCESS;
1995}
1996
1997DEFUN (show_ip_pim_upstream,
1998 show_ip_pim_upstream_cmd,
1999 "show ip pim upstream",
2000 SHOW_STR
2001 IP_STR
2002 PIM_STR
2003 "PIM upstream information\n")
2004{
2005 pim_show_upstream(vty);
2006
2007 return CMD_SUCCESS;
2008}
2009
2010DEFUN (show_ip_pim_upstream_join_desired,
2011 show_ip_pim_upstream_join_desired_cmd,
2012 "show ip pim upstream-join-desired",
2013 SHOW_STR
2014 IP_STR
2015 PIM_STR
2016 "PIM upstream join-desired\n")
2017{
2018 pim_show_join_desired(vty);
2019
2020 return CMD_SUCCESS;
2021}
2022
2023DEFUN (show_ip_pim_upstream_rpf,
2024 show_ip_pim_upstream_rpf_cmd,
2025 "show ip pim upstream-rpf",
2026 SHOW_STR
2027 IP_STR
2028 PIM_STR
2029 "PIM upstream source rpf\n")
2030{
2031 pim_show_upstream_rpf(vty);
2032
2033 return CMD_SUCCESS;
2034}
2035
2036DEFUN (show_ip_pim_rpf,
2037 show_ip_pim_rpf_cmd,
2038 "show ip pim rpf",
2039 SHOW_STR
2040 IP_STR
2041 PIM_STR
2042 "PIM cached source rpf information\n")
2043{
2044 pim_show_rpf(vty);
2045
2046 return CMD_SUCCESS;
2047}
2048
2049static void show_multicast_interfaces(struct vty *vty)
2050{
2051 struct listnode *node;
2052 struct interface *ifp;
2053
2054 vty_out(vty, "%s", VTY_NEWLINE);
2055
2056 vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
2057 VTY_NEWLINE);
2058
469351b3 2059 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
2060 struct pim_interface *pim_ifp;
2061 struct in_addr ifaddr;
2062 struct sioc_vif_req vreq;
2063
2064 pim_ifp = ifp->info;
2065
2066 if (!pim_ifp)
2067 continue;
2068
2069 memset(&vreq, 0, sizeof(vreq));
2070 vreq.vifi = pim_ifp->mroute_vif_index;
2071
2072 if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
6c44fe22
DS
2073 zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s",
2074 (unsigned long)SIOCGETVIFCNT,
2075 ifp->name,
2076 pim_ifp->mroute_vif_index,
2077 errno,
2078 safe_strerror(errno),
2079 VTY_NEWLINE);
12e41d03
DL
2080 }
2081
2082 ifaddr = pim_ifp->primary_address;
2083
2084 vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
2085 ifp->name,
2086 inet_ntoa(ifaddr),
2087 ifp->ifindex,
2088 pim_ifp->mroute_vif_index,
2089 vreq.icount,
2090 vreq.ocount,
2091 vreq.ibytes,
2092 vreq.obytes,
2093 VTY_NEWLINE);
2094 }
2095}
2096
2097DEFUN (show_ip_multicast,
2098 show_ip_multicast_cmd,
2099 "show ip multicast",
2100 SHOW_STR
2101 IP_STR
2102 "Multicast global information\n")
2103{
2104 time_t now = pim_time_monotonic_sec();
2105
2106 if (PIM_MROUTE_IS_ENABLED) {
2107 char uptime[10];
2108
2109 vty_out(vty, "Mroute socket descriptor: %d%s",
2110 qpim_mroute_socket_fd,
2111 VTY_NEWLINE);
2112
2113 pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
2114 vty_out(vty, "Mroute socket uptime: %s%s",
2115 uptime,
2116 VTY_NEWLINE);
2117 }
2118 else {
2119 vty_out(vty, "Multicast disabled%s",
2120 VTY_NEWLINE);
2121 }
2122
2123 vty_out(vty, "%s", VTY_NEWLINE);
2124 vty_out(vty, "Zclient update socket: ");
2125 if (qpim_zclient_update) {
2126 vty_out(vty, "%d failures=%d%s", qpim_zclient_update->sock,
2127 qpim_zclient_update->fail, VTY_NEWLINE);
2128 }
2129 else {
2130 vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
2131 }
2132 vty_out(vty, "Zclient lookup socket: ");
2133 if (qpim_zclient_lookup) {
2134 vty_out(vty, "%d failures=%d%s", qpim_zclient_lookup->sock,
2135 qpim_zclient_lookup->fail, VTY_NEWLINE);
2136 }
2137 else {
2138 vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
2139 }
2140
2141 vty_out(vty, "%s", VTY_NEWLINE);
2142 vty_out(vty, "Current highest VifIndex: %d%s",
2143 qpim_mroute_oif_highest_vif_index,
2144 VTY_NEWLINE);
2145 vty_out(vty, "Maximum highest VifIndex: %d%s",
b45cefcb 2146 MAXVIFS - 2,
12e41d03
DL
2147 VTY_NEWLINE);
2148
2149 vty_out(vty, "%s", VTY_NEWLINE);
2150 vty_out(vty, "Upstream Join Timer: %d secs%s",
2151 qpim_t_periodic,
2152 VTY_NEWLINE);
2153 vty_out(vty, "Join/Prune Holdtime: %d secs%s",
2154 PIM_JP_HOLDTIME,
2155 VTY_NEWLINE);
2156
2157 vty_out(vty, "%s", VTY_NEWLINE);
2158
2159 show_rpf_refresh_stats(vty, now);
2160
2161 vty_out(vty, "%s", VTY_NEWLINE);
2162
2163 show_scan_oil_stats(vty, now);
2164
2165 show_multicast_interfaces(vty);
2166
2167 return CMD_SUCCESS;
2168}
2169
2170static void show_mroute(struct vty *vty)
2171{
2172 struct listnode *node;
2173 struct channel_oil *c_oil;
6250610a 2174 struct static_route *s_route;
12e41d03
DL
2175 time_t now;
2176
0fba6e63 2177 vty_out(vty, "Proto: I=IGMP P=PIM S=STATIC O=SOURCE%s%s", VTY_NEWLINE, VTY_NEWLINE);
12e41d03
DL
2178
2179 vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
2180 VTY_NEWLINE);
2181
2182 now = pim_time_monotonic_sec();
2183
6250610a 2184 /* print list of PIM and IGMP routes */
12e41d03
DL
2185 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2186 char group_str[100];
2187 char source_str[100];
2188 int oif_vif_index;
2189
2190 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2191 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2192
2193 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2194 struct interface *ifp_in;
2195 struct interface *ifp_out;
2196 char oif_uptime[10];
2197 int ttl;
2198 char proto[5];
2199
2200 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
2201 if (ttl < 1)
2202 continue;
2203
2204 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
2205 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2206
2207 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
2208
2209 proto[0] = '\0';
2210 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
2211 strcat(proto, "P");
2212 }
2213 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
2214 strcat(proto, "I");
2215 }
0fba6e63
DS
2216 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_SOURCE) {
2217 strcat(proto, "O");
2218 }
12e41d03
DL
2219
2220 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2221 source_str,
2222 group_str,
2223 proto,
2224 ifp_in ? ifp_in->name : "<iif?>",
2225 c_oil->oil.mfcc_parent,
2226 ifp_out ? ifp_out->name : "<oif?>",
2227 oif_vif_index,
2228 ttl,
2229 oif_uptime,
2230 VTY_NEWLINE);
2231 }
2232 }
6250610a
JAG
2233
2234 /* Print list of static routes */
2235 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
2236 char group_str[100];
2237 char source_str[100];
2238 int oif_vif_index;
2239
2240 pim_inet4_dump("<group?>", s_route->group, group_str, sizeof(group_str));
2241 pim_inet4_dump("<source?>", s_route->source, source_str, sizeof(source_str));
2242
2243 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2244 struct interface *ifp_in;
2245 struct interface *ifp_out;
2246 char oif_uptime[10];
2247 int ttl;
2248 char proto[5];
2249
2250 ttl = s_route->oif_ttls[oif_vif_index];
2251 if (ttl < 1)
2252 continue;
2253
2254 ifp_in = pim_if_find_by_vif_index(s_route->iif);
2255 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2256
2257 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - s_route->creation[oif_vif_index]);
2258
2259 proto[0] = '\0';
2260 strcat(proto, "S");
2261
2262 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2263 source_str,
2264 group_str,
2265 proto,
2266 ifp_in ? ifp_in->name : "<iif?>",
2267 s_route->iif,
2268 ifp_out ? ifp_out->name : "<oif?>",
2269 oif_vif_index,
2270 ttl,
2271 oif_uptime,
2272 VTY_NEWLINE);
2273 }
2274 }
12e41d03
DL
2275}
2276
2277DEFUN (show_ip_mroute,
2278 show_ip_mroute_cmd,
2279 "show ip mroute",
2280 SHOW_STR
2281 IP_STR
2282 MROUTE_STR)
2283{
2284 show_mroute(vty);
2285 return CMD_SUCCESS;
2286}
2287
2288static void show_mroute_count(struct vty *vty)
2289{
2290 struct listnode *node;
2291 struct channel_oil *c_oil;
6250610a 2292 struct static_route *s_route;
12e41d03
DL
2293
2294 vty_out(vty, "%s", VTY_NEWLINE);
2295
2296 vty_out(vty, "Source Group Packets Bytes WrongIf %s",
2297 VTY_NEWLINE);
2298
6250610a 2299 /* Print PIM and IGMP route counts */
12e41d03
DL
2300 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2301 char group_str[100];
2302 char source_str[100];
2303 struct sioc_sg_req sgreq;
2304
2305 memset(&sgreq, 0, sizeof(sgreq));
2306 sgreq.src = c_oil->oil.mfcc_origin;
2307 sgreq.grp = c_oil->oil.mfcc_mcastgrp;
2308
2309 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2310 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2311
2312 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2313 int e = errno;
2314 vty_out(vty,
1cb17fc7
DL
2315 "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2316 (unsigned long)SIOCGETSGCNT,
12e41d03
DL
2317 source_str,
2318 group_str,
2319 e,
2320 safe_strerror(e),
2321 VTY_NEWLINE);
2322 continue;
2323 }
2324
2325 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2326 source_str,
2327 group_str,
2328 sgreq.pktcnt,
2329 sgreq.bytecnt,
2330 sgreq.wrong_if,
2331 VTY_NEWLINE);
6250610a
JAG
2332 }
2333
2334 /* Print static route counts */
2335 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
2336 char group_str[100];
2337 char source_str[100];
2338 struct sioc_sg_req sgreq;
2339
2340 memset(&sgreq, 0, sizeof(sgreq));
2341 sgreq.src = s_route->mc.mfcc_origin;
2342 sgreq.grp = s_route->mc.mfcc_mcastgrp;
2343
2344 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
2345 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
2346
2347 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2348 int e = errno;
2349 vty_out(vty,
02e51cad
PJ
2350 "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2351 /* note that typeof ioctl defs can vary across platforms, from
2352 * int, to unsigned int, to long unsigned int
2353 */
2354 (unsigned long)SIOCGETSGCNT,
6250610a
JAG
2355 source_str,
2356 group_str,
2357 e,
2358 safe_strerror(e),
2359 VTY_NEWLINE);
2360 continue;
2361 }
12e41d03 2362
6250610a
JAG
2363 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2364 source_str,
2365 group_str,
2366 sgreq.pktcnt,
2367 sgreq.bytecnt,
2368 sgreq.wrong_if,
2369 VTY_NEWLINE);
12e41d03
DL
2370 }
2371}
2372
2373DEFUN (show_ip_mroute_count,
2374 show_ip_mroute_count_cmd,
2375 "show ip mroute count",
2376 SHOW_STR
2377 IP_STR
2378 MROUTE_STR
2379 "Route and packet count data\n")
2380{
2381 show_mroute_count(vty);
2382 return CMD_SUCCESS;
2383}
2384
2385DEFUN (show_ip_rib,
2386 show_ip_rib_cmd,
2387 "show ip rib A.B.C.D",
2388 SHOW_STR
2389 IP_STR
2390 RIB_STR
2391 "Unicast address\n")
2392{
2393 struct in_addr addr;
2394 const char *addr_str;
2395 struct pim_nexthop nexthop;
2396 char nexthop_addr_str[100];
2397 int result;
2398
2399 addr_str = argv[0];
2400 result = inet_pton(AF_INET, addr_str, &addr);
2401 if (result <= 0) {
2402 vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
2403 addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 if (pim_nexthop_lookup(&nexthop, addr)) {
2408 vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
2409 addr_str, VTY_NEWLINE);
2410 return CMD_WARNING;
2411 }
2412
2413 vty_out(vty, "Address NextHop Interface Metric Preference%s",
2414 VTY_NEWLINE);
2415
2416 pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
2417 nexthop_addr_str, sizeof(nexthop_addr_str));
2418
2419 vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
2420 addr_str,
2421 nexthop_addr_str,
2422 nexthop.interface ? nexthop.interface->name : "<ifname?>",
2423 nexthop.mrib_route_metric,
2424 nexthop.mrib_metric_preference,
2425 VTY_NEWLINE);
2426
2427 return CMD_SUCCESS;
2428}
2429
2430static void show_ssmpingd(struct vty *vty)
2431{
2432 struct listnode *node;
2433 struct ssmpingd_sock *ss;
2434 time_t now;
2435
2436 vty_out(vty, "Source Socket Address Port Uptime Requests%s",
2437 VTY_NEWLINE);
2438
2439 if (!qpim_ssmpingd_list)
2440 return;
2441
2442 now = pim_time_monotonic_sec();
2443
2444 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
2445 char source_str[100];
2446 char ss_uptime[10];
2447 struct sockaddr_in bind_addr;
2448 socklen_t len = sizeof(bind_addr);
2449 char bind_addr_str[100];
2450
2451 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
2452
2453 if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
2454 vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
2455 source_str, ss->sock_fd, VTY_NEWLINE);
2456 }
2457
2458 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
2459 pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
2460
2461 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
2462 source_str,
2463 ss->sock_fd,
2464 bind_addr_str,
2465 ntohs(bind_addr.sin_port),
2466 ss_uptime,
2467 (long long)ss->requests,
2468 VTY_NEWLINE);
2469 }
2470}
2471
2472DEFUN (show_ip_ssmpingd,
2473 show_ip_ssmpingd_cmd,
2474 "show ip ssmpingd",
2475 SHOW_STR
2476 IP_STR
2477 SHOW_SSMPINGD_STR)
2478{
2479 show_ssmpingd(vty);
2480 return CMD_SUCCESS;
2481}
2482
981d6c7a
DS
2483DEFUN (ip_pim_rp,
2484 ip_pim_rp_cmd,
2485 "ip pim rp A.B.C.D",
2486 IP_STR
2487 "pim multicast routing"
2488 "Rendevous Point"
2489 "ip address of RP")
2490{
2491 int result;
2492
c8ae3ce8 2493 result = inet_pton(AF_INET, argv[0], &qpim_rp.rpf_addr.s_addr);
981d6c7a
DS
2494 if (result <= 0) {
2495 vty_out(vty, "%% Bad RP address specified: %s", argv[0]);
2496 return CMD_WARNING;
2497 }
2498
c8ae3ce8
DS
2499 if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr) != 0) {
2500 vty_out(vty, "%% No Path to RP address specified: %s", argv[0]);
2501 return CMD_WARNING;
2502 }
2503
981d6c7a
DS
2504 return CMD_SUCCESS;
2505}
2506
2507DEFUN (no_ip_pim_rp,
2508 no_ip_pim_rp_cmd,
2509 "no ip pim rp {A.B.C.D}",
2510 NO_STR
2511 IP_STR
2512 "pim multicast routing"
2513 "Rendevous Point"
2514 "ip address of RP")
2515{
c8ae3ce8 2516 qpim_rp.rpf_addr.s_addr = INADDR_NONE;
981d6c7a
DS
2517
2518 return CMD_SUCCESS;
2519}
2520
12e41d03
DL
2521DEFUN (ip_multicast_routing,
2522 ip_multicast_routing_cmd,
2523 PIM_CMD_IP_MULTICAST_ROUTING,
2524 IP_STR
2525 "Enable IP multicast forwarding\n")
2526{
2527 pim_mroute_socket_enable();
2528 pim_if_add_vif_all();
2529 mroute_add_all();
6250610a 2530 static_mroute_add_all();
12e41d03
DL
2531 return CMD_SUCCESS;
2532}
2533
2534DEFUN (no_ip_multicast_routing,
2535 no_ip_multicast_routing_cmd,
2536 PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
2537 NO_STR
2538 IP_STR
2539 "Global IP configuration subcommands\n"
2540 "Enable IP multicast forwarding\n")
2541{
2542 mroute_del_all();
6250610a 2543 static_mroute_del_all();
12e41d03
DL
2544 pim_if_del_vif_all();
2545 pim_mroute_socket_disable();
2546 return CMD_SUCCESS;
2547}
2548
2549DEFUN (ip_ssmpingd,
2550 ip_ssmpingd_cmd,
2551 "ip ssmpingd [A.B.C.D]",
2552 IP_STR
2553 CONF_SSMPINGD_STR
2554 "Source address\n")
2555{
2556 int result;
2557 struct in_addr source_addr;
2558 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2559
2560 result = inet_pton(AF_INET, source_str, &source_addr);
2561 if (result <= 0) {
2562 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2563 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2564 return CMD_WARNING;
2565 }
2566
2567 result = pim_ssmpingd_start(source_addr);
2568 if (result) {
2569 vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
2570 source_str, result, VTY_NEWLINE);
2571 return CMD_WARNING;
2572 }
2573
2574 return CMD_SUCCESS;
2575}
2576
2577DEFUN (no_ip_ssmpingd,
2578 no_ip_ssmpingd_cmd,
2579 "no ip ssmpingd [A.B.C.D]",
2580 NO_STR
2581 IP_STR
2582 CONF_SSMPINGD_STR
2583 "Source address\n")
2584{
2585 int result;
2586 struct in_addr source_addr;
2587 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2588
2589 result = inet_pton(AF_INET, source_str, &source_addr);
2590 if (result <= 0) {
2591 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2592 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2593 return CMD_WARNING;
2594 }
2595
2596 result = pim_ssmpingd_stop(source_addr);
2597 if (result) {
2598 vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
2599 source_str, result, VTY_NEWLINE);
2600 return CMD_WARNING;
2601 }
2602
2603 return CMD_SUCCESS;
2604}
2605
2606DEFUN (interface_ip_igmp,
2607 interface_ip_igmp_cmd,
2608 "ip igmp",
2609 IP_STR
2610 IFACE_IGMP_STR)
2611{
2612 struct interface *ifp;
2613 struct pim_interface *pim_ifp;
2614
2615 ifp = vty->index;
2616 pim_ifp = ifp->info;
2617
2618 if (!pim_ifp) {
2619 pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
2620 if (!pim_ifp) {
2621 vty_out(vty, "Could not enable IGMP on interface %s%s",
2622 ifp->name, VTY_NEWLINE);
2623 return CMD_WARNING;
2624 }
2625 }
2626 else {
2627 PIM_IF_DO_IGMP(pim_ifp->options);
2628 }
2629
2630 pim_if_addr_add_all(ifp);
2631 pim_if_membership_refresh(ifp);
2632
2633 return CMD_SUCCESS;
2634}
2635
2636DEFUN (interface_no_ip_igmp,
2637 interface_no_ip_igmp_cmd,
2638 "no ip igmp",
2639 NO_STR
2640 IP_STR
2641 IFACE_IGMP_STR)
2642{
2643 struct interface *ifp;
2644 struct pim_interface *pim_ifp;
2645
2646 ifp = vty->index;
2647 pim_ifp = ifp->info;
2648 if (!pim_ifp)
2649 return CMD_SUCCESS;
2650
2651 PIM_IF_DONT_IGMP(pim_ifp->options);
2652
2653 pim_if_membership_clear(ifp);
2654
2655 pim_if_addr_del_all_igmp(ifp);
2656
2657 if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
2658 pim_if_delete(ifp);
2659 }
2660
2661 return CMD_SUCCESS;
2662}
2663
2664DEFUN (interface_ip_igmp_join,
2665 interface_ip_igmp_join_cmd,
2666 "ip igmp join A.B.C.D A.B.C.D",
2667 IP_STR
2668 IFACE_IGMP_STR
2669 "IGMP join multicast group\n"
2670 "Multicast group address\n"
2671 "Source address\n")
2672{
2673 struct interface *ifp;
2674 const char *group_str;
2675 const char *source_str;
2676 struct in_addr group_addr;
2677 struct in_addr source_addr;
2678 int result;
2679
2680 ifp = vty->index;
2681
2682 /* Group address */
2683 group_str = argv[0];
2684 result = inet_pton(AF_INET, group_str, &group_addr);
2685 if (result <= 0) {
2686 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
2687 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
2688 return CMD_WARNING;
2689 }
2690
2691 /* Source address */
2692 source_str = argv[1];
2693 result = inet_pton(AF_INET, source_str, &source_addr);
2694 if (result <= 0) {
2695 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
2696 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2697 return CMD_WARNING;
2698 }
2699
2700 result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
2701 if (result) {
2702 vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
2703 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2704 return CMD_WARNING;
2705 }
2706
2707 return CMD_SUCCESS;
2708}
2709
2710DEFUN (interface_no_ip_igmp_join,
2711 interface_no_ip_igmp_join_cmd,
2712 "no ip igmp join A.B.C.D A.B.C.D",
2713 NO_STR
2714 IP_STR
2715 IFACE_IGMP_STR
2716 "IGMP join multicast group\n"
2717 "Multicast group address\n"
2718 "Source address\n")
2719{
2720 struct interface *ifp;
2721 const char *group_str;
2722 const char *source_str;
2723 struct in_addr group_addr;
2724 struct in_addr source_addr;
2725 int result;
2726
2727 ifp = vty->index;
2728
2729 /* Group address */
2730 group_str = argv[0];
2731 result = inet_pton(AF_INET, group_str, &group_addr);
2732 if (result <= 0) {
2733 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
2734 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
2735 return CMD_WARNING;
2736 }
2737
2738 /* Source address */
2739 source_str = argv[1];
2740 result = inet_pton(AF_INET, source_str, &source_addr);
2741 if (result <= 0) {
2742 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
2743 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2744 return CMD_WARNING;
2745 }
2746
2747 result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
2748 if (result) {
2749 vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
2750 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2751 return CMD_WARNING;
2752 }
2753
2754 return CMD_SUCCESS;
2755}
2756
2757/*
2758 CLI reconfiguration affects the interface level (struct pim_interface).
2759 This function propagates the reconfiguration to every active socket
2760 for that interface.
2761 */
2762static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
2763{
2764 struct interface *ifp;
2765 struct pim_interface *pim_ifp;
2766
2767 zassert(igmp);
2768
2769 /* other querier present? */
2770
2771 if (igmp->t_other_querier_timer)
2772 return;
2773
2774 /* this is the querier */
2775
2776 zassert(igmp->interface);
2777 zassert(igmp->interface->info);
2778
2779 ifp = igmp->interface;
2780 pim_ifp = ifp->info;
2781
2782 if (PIM_DEBUG_IGMP_TRACE) {
2783 char ifaddr_str[100];
2784 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2785 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
2786 __PRETTY_FUNCTION__,
2787 ifaddr_str,
2788 ifp->name,
2789 pim_ifp->igmp_default_query_interval);
2790 }
2791
2792 /*
2793 igmp_startup_mode_on() will reset QQI:
2794
2795 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
2796 */
2797 igmp_startup_mode_on(igmp);
2798}
2799
2800static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
2801{
2802 if (igmp->t_igmp_query_timer) {
2803 /* other querier present */
2804 zassert(igmp->t_igmp_query_timer);
2805 zassert(!igmp->t_other_querier_timer);
2806
2807 pim_igmp_general_query_off(igmp);
2808 pim_igmp_general_query_on(igmp);
2809
2810 zassert(igmp->t_igmp_query_timer);
2811 zassert(!igmp->t_other_querier_timer);
2812 }
2813 else {
2814 /* this is the querier */
2815
2816 zassert(!igmp->t_igmp_query_timer);
2817 zassert(igmp->t_other_querier_timer);
2818
2819 pim_igmp_other_querier_timer_off(igmp);
2820 pim_igmp_other_querier_timer_on(igmp);
2821
2822 zassert(!igmp->t_igmp_query_timer);
2823 zassert(igmp->t_other_querier_timer);
2824 }
2825}
2826
2827static void change_query_interval(struct pim_interface *pim_ifp,
2828 int query_interval)
2829{
2830 struct listnode *sock_node;
2831 struct igmp_sock *igmp;
2832
2833 pim_ifp->igmp_default_query_interval = query_interval;
2834
2835 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2836 igmp_sock_query_interval_reconfig(igmp);
2837 igmp_sock_query_reschedule(igmp);
2838 }
2839}
2840
2841static void change_query_max_response_time(struct pim_interface *pim_ifp,
2842 int query_max_response_time_dsec)
2843{
2844 struct listnode *sock_node;
2845 struct igmp_sock *igmp;
2846
2847 pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
2848
2849 /*
2850 Below we modify socket/group/source timers in order to quickly
2851 reflect the change. Otherwise, those timers would eventually catch
2852 up.
2853 */
2854
2855 /* scan all sockets */
2856 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2857 struct listnode *grp_node;
2858 struct igmp_group *grp;
2859
2860 /* reschedule socket general query */
2861 igmp_sock_query_reschedule(igmp);
2862
2863 /* scan socket groups */
2864 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
2865 struct listnode *src_node;
2866 struct igmp_source *src;
2867
2868 /* reset group timers for groups in EXCLUDE mode */
2869 if (grp->group_filtermode_isexcl) {
2870 igmp_group_reset_gmi(grp);
2871 }
2872
2873 /* scan group sources */
2874 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
2875
2876 /* reset source timers for sources with running timers */
2877 if (src->t_source_timer) {
2878 igmp_source_reset_gmi(igmp, grp, src);
2879 }
2880 }
2881 }
2882 }
2883}
2884
2885#define IGMP_QUERY_INTERVAL_MIN (1)
2886#define IGMP_QUERY_INTERVAL_MAX (1800)
2887
2888DEFUN (interface_ip_igmp_query_interval,
2889 interface_ip_igmp_query_interval_cmd,
2890 PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
2891 IP_STR
2892 IFACE_IGMP_STR
2893 IFACE_IGMP_QUERY_INTERVAL_STR
2894 "Query interval in seconds\n")
2895{
2896 struct interface *ifp;
2897 struct pim_interface *pim_ifp;
2898 int query_interval;
2899 int query_interval_dsec;
2900
2901 ifp = vty->index;
2902 pim_ifp = ifp->info;
2903
2904 if (!pim_ifp) {
2905 vty_out(vty,
2906 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2907 ifp->name,
2908 VTY_NEWLINE);
2909 return CMD_WARNING;
2910 }
2911
2912 query_interval = atoi(argv[0]);
2913 query_interval_dsec = 10 * query_interval;
2914
2915 /*
2916 It seems we don't need to check bounds since command.c does it
2917 already, but we verify them anyway for extra safety.
2918 */
2919 if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
2920 vty_out(vty, "General query interval %d lower than minimum %d%s",
2921 query_interval,
2922 IGMP_QUERY_INTERVAL_MIN,
2923 VTY_NEWLINE);
2924 return CMD_WARNING;
2925 }
2926 if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
2927 vty_out(vty, "General query interval %d higher than maximum %d%s",
2928 query_interval,
2929 IGMP_QUERY_INTERVAL_MAX,
2930 VTY_NEWLINE);
2931 return CMD_WARNING;
2932 }
2933
2934 if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2935 vty_out(vty,
2936 "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
2937 query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2938 VTY_NEWLINE);
2939 return CMD_WARNING;
2940 }
2941
2942 change_query_interval(pim_ifp, query_interval);
2943
2944 return CMD_SUCCESS;
2945}
2946
2947DEFUN (interface_no_ip_igmp_query_interval,
2948 interface_no_ip_igmp_query_interval_cmd,
2949 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
2950 NO_STR
2951 IP_STR
2952 IFACE_IGMP_STR
2953 IFACE_IGMP_QUERY_INTERVAL_STR)
2954{
2955 struct interface *ifp;
2956 struct pim_interface *pim_ifp;
2957 int default_query_interval_dsec;
2958
2959 ifp = vty->index;
2960 pim_ifp = ifp->info;
2961
2962 if (!pim_ifp)
2963 return CMD_SUCCESS;
2964
2965 default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
2966
2967 if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2968 vty_out(vty,
2969 "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
2970 default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2971 VTY_NEWLINE);
2972 return CMD_WARNING;
2973 }
2974
2975 change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
2976
2977 return CMD_SUCCESS;
2978}
2979
2980#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
2981#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
2982
2983DEFUN (interface_ip_igmp_query_max_response_time,
2984 interface_ip_igmp_query_max_response_time_cmd,
2985 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
2986 IP_STR
2987 IFACE_IGMP_STR
2988 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
2989 "Query response value in seconds\n")
2990{
2991 struct interface *ifp;
2992 struct pim_interface *pim_ifp;
2993 int query_max_response_time;
2994
2995 ifp = vty->index;
2996 pim_ifp = ifp->info;
2997
2998 if (!pim_ifp) {
2999 vty_out(vty,
3000 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
3001 ifp->name,
3002 VTY_NEWLINE);
3003 return CMD_WARNING;
3004 }
3005
3006 query_max_response_time = atoi(argv[0]);
3007
3008 /*
3009 It seems we don't need to check bounds since command.c does it
3010 already, but we verify them anyway for extra safety.
3011 */
3012 if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
3013 vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
3014 query_max_response_time,
3015 IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
3016 VTY_NEWLINE);
3017 return CMD_WARNING;
3018 }
3019 if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
3020 vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
3021 query_max_response_time,
3022 IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
3023 VTY_NEWLINE);
3024 return CMD_WARNING;
3025 }
3026
3027 if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
3028 vty_out(vty,
3029 "Can't set query max response time %d sec >= general query interval %d sec%s",
3030 query_max_response_time, pim_ifp->igmp_default_query_interval,
3031 VTY_NEWLINE);
3032 return CMD_WARNING;
3033 }
3034
3035 change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
3036
3037 return CMD_SUCCESS;
3038}
3039
3040DEFUN (interface_no_ip_igmp_query_max_response_time,
3041 interface_no_ip_igmp_query_max_response_time_cmd,
3042 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
3043 NO_STR
3044 IP_STR
3045 IFACE_IGMP_STR
3046 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
3047{
3048 struct interface *ifp;
3049 struct pim_interface *pim_ifp;
3050 int default_query_interval_dsec;
3051
3052 ifp = vty->index;
3053 pim_ifp = ifp->info;
3054
3055 if (!pim_ifp)
3056 return CMD_SUCCESS;
3057
3058 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3059
3060 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
3061 vty_out(vty,
3062 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
3063 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
3064 VTY_NEWLINE);
3065 return CMD_WARNING;
3066 }
3067
3068 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
3069
3070 return CMD_SUCCESS;
3071}
3072
3073#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
3074#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
3075
3076DEFUN (interface_ip_igmp_query_max_response_time_dsec,
3077 interface_ip_igmp_query_max_response_time_dsec_cmd,
3078 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
3079 IP_STR
3080 IFACE_IGMP_STR
3081 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
3082 "Query response value in deciseconds\n")
3083{
3084 struct interface *ifp;
3085 struct pim_interface *pim_ifp;
3086 int query_max_response_time_dsec;
3087 int default_query_interval_dsec;
3088
3089 ifp = vty->index;
3090 pim_ifp = ifp->info;
3091
3092 if (!pim_ifp) {
3093 vty_out(vty,
3094 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
3095 ifp->name,
3096 VTY_NEWLINE);
3097 return CMD_WARNING;
3098 }
3099
3100 query_max_response_time_dsec = atoi(argv[0]);
3101
3102 /*
3103 It seems we don't need to check bounds since command.c does it
3104 already, but we verify them anyway for extra safety.
3105 */
3106 if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
3107 vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
3108 query_max_response_time_dsec,
3109 IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
3110 VTY_NEWLINE);
3111 return CMD_WARNING;
3112 }
3113 if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
3114 vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
3115 query_max_response_time_dsec,
3116 IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
3117 VTY_NEWLINE);
3118 return CMD_WARNING;
3119 }
3120
3121 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3122
3123 if (query_max_response_time_dsec >= default_query_interval_dsec) {
3124 vty_out(vty,
3125 "Can't set query max response time %d dsec >= general query interval %d dsec%s",
3126 query_max_response_time_dsec, default_query_interval_dsec,
3127 VTY_NEWLINE);
3128 return CMD_WARNING;
3129 }
3130
3131 change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
3132
3133 return CMD_SUCCESS;
3134}
3135
3136DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
3137 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
3138 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
3139 NO_STR
3140 IP_STR
3141 IFACE_IGMP_STR
3142 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
3143{
3144 struct interface *ifp;
3145 struct pim_interface *pim_ifp;
3146 int default_query_interval_dsec;
3147
3148 ifp = vty->index;
3149 pim_ifp = ifp->info;
3150
3151 if (!pim_ifp)
3152 return CMD_SUCCESS;
3153
3154 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3155
3156 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
3157 vty_out(vty,
3158 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
3159 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
3160 VTY_NEWLINE);
3161 return CMD_WARNING;
3162 }
3163
3164 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
3165
3166 return CMD_SUCCESS;
3167}
3168
dedccda6
DS
3169DEFUN (interface_ip_pim_drprio,
3170 interface_ip_pim_drprio_cmd,
3171 "ip pim drpriority <1-4294967295>",
3172 IP_STR
3173 PIM_STR
3174 "Set the Designated Router Election Priority\n"
3175 "Value of the new DR Priority\n")
3176{
3177 struct interface *ifp;
3178 struct pim_interface *pim_ifp;
3179 uint32_t old_dr_prio;
3180
3181 ifp = vty->index;
3182 pim_ifp = ifp->info;
3183
3184 if (!pim_ifp) {
3185 vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE);
3186 return CMD_WARNING;
3187 }
3188
3189 old_dr_prio = pim_ifp->pim_dr_priority;
3190
3191 pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10);
3192
3193 if (old_dr_prio != pim_ifp->pim_dr_priority) {
3194 if (pim_if_dr_election(ifp))
3195 pim_hello_restart_now(ifp);
3196 }
3197
3198 return CMD_SUCCESS;
3199}
3200
3201DEFUN (interface_no_ip_pim_drprio,
3202 interface_no_ip_pim_drprio_cmd,
3203 "no ip pim drpriority {<1-4294967295>}",
3204 IP_STR
3205 PIM_STR
3206 "Revert the Designated Router Priority to default\n"
3207 "Old Value of the Priority\n")
3208{
3209 struct interface *ifp;
3210 struct pim_interface *pim_ifp;
3211
3212 ifp = vty->index;
3213 pim_ifp = ifp->info;
3214
3215 if (!pim_ifp) {
7960fa8f 3216 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
dedccda6
DS
3217 return CMD_WARNING;
3218 }
3219
3220 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
3221 pim_ifp->pim_dr_priority = PIM_DEFAULT_DR_PRIORITY;
3222 if (pim_if_dr_election(ifp))
3223 pim_hello_restart_now(ifp);
3224 }
3225
3226 return CMD_SUCCESS;
3227}
3228
981d6c7a
DS
3229static int
3230pim_cmd_interface_add (struct interface *ifp, enum pim_interface_type itype)
12e41d03 3231{
981d6c7a 3232 struct pim_interface *pim_ifp = ifp->info;
12e41d03
DL
3233
3234 if (!pim_ifp) {
3235 pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
3236 if (!pim_ifp) {
981d6c7a 3237 return 0;
12e41d03
DL
3238 }
3239 }
3240 else {
3241 PIM_IF_DO_PIM(pim_ifp->options);
3242 }
3243
981d6c7a 3244 pim_ifp->itype = itype;
12e41d03
DL
3245 pim_if_addr_add_all(ifp);
3246 pim_if_membership_refresh(ifp);
3247
981d6c7a
DS
3248 return 1;
3249}
3250
3251
3252DEFUN (interface_ip_pim_ssm,
3253 interface_ip_pim_ssm_cmd,
3254 "ip pim ssm",
3255 IP_STR
3256 PIM_STR
3257 IFACE_PIM_STR)
3258{
3259 struct interface *ifp;
3260
3261 ifp = vty->index;
3262
3263 if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SSM)) {
3264 vty_out(vty, "Could not enable PIM SSM on interface%s", VTY_NEWLINE);
3265 return CMD_WARNING;
3266 }
3267
12e41d03
DL
3268 return CMD_SUCCESS;
3269}
3270
981d6c7a
DS
3271DEFUN (interface_ip_pim_sm,
3272 interface_ip_pim_sm_cmd,
3273 "ip pim sm",
12e41d03
DL
3274 IP_STR
3275 PIM_STR
3276 IFACE_PIM_STR)
3277{
3278 struct interface *ifp;
12e41d03
DL
3279
3280 ifp = vty->index;
981d6c7a
DS
3281 if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SM)) {
3282 vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE);
3283 return CMD_WARNING;
3284 }
3285
3286 return CMD_SUCCESS;
3287}
3288
3289static int
3290pim_cmd_interface_delete (struct interface *ifp)
3291{
3292 struct pim_interface *pim_ifp = ifp->info;
3293
12e41d03 3294 if (!pim_ifp)
981d6c7a 3295 return 1;
12e41d03
DL
3296
3297 PIM_IF_DONT_PIM(pim_ifp->options);
3298
3299 pim_if_membership_clear(ifp);
3300
3301 /*
3302 pim_if_addr_del_all() removes all sockets from
3303 pim_ifp->igmp_socket_list.
3304 */
3305 pim_if_addr_del_all(ifp);
3306
3307 /*
3308 pim_sock_delete() removes all neighbors from
3309 pim_ifp->pim_neighbor_list.
3310 */
3311 pim_sock_delete(ifp, "pim unconfigured on interface");
3312
3313 if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
3314 pim_if_delete(ifp);
3315 }
3316
981d6c7a
DS
3317 return 1;
3318}
3319
3320DEFUN (interface_no_ip_pim_ssm,
3321 interface_no_ip_pim_ssm_cmd,
3322 "no ip pim ssm",
3323 NO_STR
3324 IP_STR
3325 PIM_STR
3326 IFACE_PIM_STR)
3327{
3328 struct interface *ifp;
3329
3330 ifp = vty->index;
3331 if (!pim_cmd_interface_delete(ifp)) {
3332 vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
3333 return CMD_WARNING;
3334 }
3335
3336 return CMD_SUCCESS;
3337}
3338
3339DEFUN (interface_no_ip_pim_sm,
3340 interface_no_ip_pim_sm_cmd,
3341 "no ip pim sm",
3342 NO_STR
3343 IP_STR
3344 PIM_STR
3345 IFACE_PIM_STR)
3346{
3347 struct interface *ifp;
3348
3349 ifp = vty->index;
3350 if (!pim_cmd_interface_delete(ifp)) {
3351 vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
3352 return CMD_WARNING;
3353 }
3354
12e41d03
DL
3355 return CMD_SUCCESS;
3356}
3357
6250610a
JAG
3358DEFUN (interface_ip_mroute,
3359 interface_ip_mroute_cmd,
3360 "ip mroute INTERFACE A.B.C.D",
3361 IP_STR
3362 "Add multicast route\n"
3363 "Outgoing interface name\n"
3364 "Group address\n")
3365{
3366 struct interface *iif;
3367 struct interface *oif;
3368 const char *oifname;
3369 const char *grp_str;
3370 struct in_addr grp_addr;
3371 struct in_addr src_addr;
3372 int result;
3373
3374 iif = vty->index;
3375
3376 oifname = argv[0];
3377 oif = if_lookup_by_name(oifname);
3378 if (!oif) {
3379 vty_out(vty, "No such interface name %s%s",
3380 oifname, VTY_NEWLINE);
3381 return CMD_WARNING;
3382 }
3383
3384 grp_str = argv[1];
3385 result = inet_pton(AF_INET, grp_str, &grp_addr);
3386 if (result <= 0) {
3387 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3388 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3389 return CMD_WARNING;
3390 }
3391
3392 src_addr.s_addr = INADDR_ANY;
3393
3394 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
3395 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
3396 return CMD_WARNING;
3397 }
3398
3399 return CMD_SUCCESS;
3400}
3401
3402DEFUN (interface_ip_mroute_source,
3403 interface_ip_mroute_source_cmd,
3404 "ip mroute INTERFACE A.B.C.D A.B.C.D",
3405 IP_STR
3406 "Add multicast route\n"
3407 "Outgoing interface name\n"
3408 "Group address\n"
3409 "Source address\n")
3410{
3411 struct interface *iif;
3412 struct interface *oif;
3413 const char *oifname;
3414 const char *grp_str;
3415 struct in_addr grp_addr;
3416 const char *src_str;
3417 struct in_addr src_addr;
3418 int result;
3419
3420 iif = vty->index;
3421
3422 oifname = argv[0];
3423 oif = if_lookup_by_name(oifname);
3424 if (!oif) {
3425 vty_out(vty, "No such interface name %s%s",
3426 oifname, VTY_NEWLINE);
3427 return CMD_WARNING;
3428 }
3429
3430 grp_str = argv[1];
3431 result = inet_pton(AF_INET, grp_str, &grp_addr);
3432 if (result <= 0) {
3433 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3434 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3435 return CMD_WARNING;
3436 }
3437
3438 src_str = argv[2];
3439 result = inet_pton(AF_INET, src_str, &src_addr);
3440 if (result <= 0) {
3441 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3442 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
3443 return CMD_WARNING;
3444 }
3445
3446 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
3447 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
3448 return CMD_WARNING;
3449 }
3450
3451 return CMD_SUCCESS;
3452}
3453
3454DEFUN (interface_no_ip_mroute,
3455 interface_no_ip_mroute_cmd,
3456 "no ip mroute INTERFACE A.B.C.D",
3457 NO_STR
3458 IP_STR
3459 "Add multicast route\n"
3460 "Outgoing interface name\n"
3461 "Group Address\n")
3462{
3463 struct interface *iif;
3464 struct interface *oif;
3465 const char *oifname;
3466 const char *grp_str;
3467 struct in_addr grp_addr;
3468 struct in_addr src_addr;
3469 int result;
3470
3471 iif = vty->index;
3472
3473 oifname = argv[0];
3474 oif = if_lookup_by_name(oifname);
3475 if (!oif) {
3476 vty_out(vty, "No such interface name %s%s",
3477 oifname, VTY_NEWLINE);
3478 return CMD_WARNING;
3479 }
3480
3481 grp_str = argv[1];
3482 result = inet_pton(AF_INET, grp_str, &grp_addr);
3483 if (result <= 0) {
3484 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3485 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3486 return CMD_WARNING;
3487 }
3488
3489 src_addr.s_addr = INADDR_ANY;
3490
3491 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
3492 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
3493 return CMD_WARNING;
3494 }
3495
3496 return CMD_SUCCESS;
3497}
3498
3499DEFUN (interface_no_ip_mroute_source,
3500 interface_no_ip_mroute_source_cmd,
3501 "no ip mroute INTERFACE A.B.C.D A.B.C.D",
3502 NO_STR
3503 IP_STR
3504 "Add multicast route\n"
3505 "Outgoing interface name\n"
3506 "Group Address\n"
3507 "Source Address\n")
3508{
3509 struct interface *iif;
3510 struct interface *oif;
3511 const char *oifname;
3512 const char *grp_str;
3513 struct in_addr grp_addr;
3514 const char *src_str;
3515 struct in_addr src_addr;
3516 int result;
3517
3518 iif = vty->index;
3519
3520 oifname = argv[0];
3521 oif = if_lookup_by_name(oifname);
3522 if (!oif) {
3523 vty_out(vty, "No such interface name %s%s",
3524 oifname, VTY_NEWLINE);
3525 return CMD_WARNING;
3526 }
3527
3528 grp_str = argv[1];
3529 result = inet_pton(AF_INET, grp_str, &grp_addr);
3530 if (result <= 0) {
3531 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3532 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3533 return CMD_WARNING;
3534 }
3535
3536 src_str = argv[2];
3537 result = inet_pton(AF_INET, src_str, &src_addr);
3538 if (result <= 0) {
3539 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3540 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
3541 return CMD_WARNING;
3542 }
3543
3544 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
3545 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
3546 return CMD_WARNING;
3547 }
3548
3549 return CMD_SUCCESS;
3550}
3551
7960fa8f
DS
3552DEFUN (interface_ip_pim_hello,
3553 interface_ip_pim_hello_cmd,
3554 "ip pim hello <1-180>",
3555 IP_STR
3556 PIM_STR
3557 IFACE_PIM_HELLO_STR
3558 IFACE_PIM_HELLO_TIME_STR)
3559{
3560 struct interface *ifp;
3561 struct pim_interface *pim_ifp;
3562
3563 ifp = vty->index;
3564 pim_ifp = ifp->info;
3565
3566 if (!pim_ifp) {
3567 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
3568 return CMD_WARNING;
3569 }
3570
3571 pim_ifp->pim_hello_period = strtol(argv[0], NULL, 10);
3572
3573 if (argc == 2)
3574 pim_ifp->pim_default_holdtime = strtol(argv[1], NULL, 10);
3575
3576 return CMD_SUCCESS;
3577}
3578
3579ALIAS (interface_ip_pim_hello,
3580 interface_ip_pim_hello_hold_cmd,
3581 "ip pim hello <1-180> <1-180>",
3582 IP_STR
3583 PIM_STR
3584 IFACE_PIM_HELLO_STR
3585 IFACE_PIM_HELLO_TIME_STR
3586 IFACE_PIM_HELLO_HOLD_STR)
3587
3588
3589DEFUN (interface_no_ip_pim_hello,
3590 interface_no_ip_pim_hello_cmd,
3591 "no ip pim hello {<1-180> <1-180>}",
3592 NO_STR
3593 IP_STR
3594 PIM_STR
3595 IFACE_PIM_HELLO_STR
3596 IFACE_PIM_HELLO_TIME_STR
3597 IFACE_PIM_HELLO_HOLD_STR)
3598{
3599 struct interface *ifp;
3600 struct pim_interface *pim_ifp;
3601
3602 ifp = vty->index;
3603 pim_ifp = ifp->info;
3604
3605 if (!pim_ifp) {
3606 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
3607 return CMD_WARNING;
3608 }
3609
3610 pim_ifp->pim_hello_period = PIM_DEFAULT_HELLO_PERIOD;
3611 pim_ifp->pim_default_holdtime = -1;
3612
3613 return CMD_SUCCESS;
3614}
3615
12e41d03
DL
3616DEFUN (debug_igmp,
3617 debug_igmp_cmd,
3618 "debug igmp",
3619 DEBUG_STR
3620 DEBUG_IGMP_STR)
3621{
3622 PIM_DO_DEBUG_IGMP_EVENTS;
3623 PIM_DO_DEBUG_IGMP_PACKETS;
3624 PIM_DO_DEBUG_IGMP_TRACE;
3625 return CMD_SUCCESS;
3626}
3627
3628DEFUN (no_debug_igmp,
3629 no_debug_igmp_cmd,
3630 "no debug igmp",
3631 NO_STR
3632 DEBUG_STR
3633 DEBUG_IGMP_STR)
3634{
3635 PIM_DONT_DEBUG_IGMP_EVENTS;
3636 PIM_DONT_DEBUG_IGMP_PACKETS;
3637 PIM_DONT_DEBUG_IGMP_TRACE;
3638 return CMD_SUCCESS;
3639}
3640
3641ALIAS (no_debug_igmp,
3642 undebug_igmp_cmd,
3643 "undebug igmp",
3644 UNDEBUG_STR
3645 DEBUG_IGMP_STR)
3646
3647DEFUN (debug_igmp_events,
3648 debug_igmp_events_cmd,
3649 "debug igmp events",
3650 DEBUG_STR
3651 DEBUG_IGMP_STR
3652 DEBUG_IGMP_EVENTS_STR)
3653{
3654 PIM_DO_DEBUG_IGMP_EVENTS;
3655 return CMD_SUCCESS;
3656}
3657
3658DEFUN (no_debug_igmp_events,
3659 no_debug_igmp_events_cmd,
3660 "no debug igmp events",
3661 NO_STR
3662 DEBUG_STR
3663 DEBUG_IGMP_STR
3664 DEBUG_IGMP_EVENTS_STR)
3665{
3666 PIM_DONT_DEBUG_IGMP_EVENTS;
3667 return CMD_SUCCESS;
3668}
3669
3670ALIAS (no_debug_igmp_events,
3671 undebug_igmp_events_cmd,
3672 "undebug igmp events",
3673 UNDEBUG_STR
3674 DEBUG_IGMP_STR
3675 DEBUG_IGMP_EVENTS_STR)
3676
3677DEFUN (debug_igmp_packets,
3678 debug_igmp_packets_cmd,
3679 "debug igmp packets",
3680 DEBUG_STR
3681 DEBUG_IGMP_STR
3682 DEBUG_IGMP_PACKETS_STR)
3683{
3684 PIM_DO_DEBUG_IGMP_PACKETS;
3685 return CMD_SUCCESS;
3686}
3687
3688DEFUN (no_debug_igmp_packets,
3689 no_debug_igmp_packets_cmd,
3690 "no debug igmp packets",
3691 NO_STR
3692 DEBUG_STR
3693 DEBUG_IGMP_STR
3694 DEBUG_IGMP_PACKETS_STR)
3695{
3696 PIM_DONT_DEBUG_IGMP_PACKETS;
3697 return CMD_SUCCESS;
3698}
3699
3700ALIAS (no_debug_igmp_packets,
3701 undebug_igmp_packets_cmd,
3702 "undebug igmp packets",
3703 UNDEBUG_STR
3704 DEBUG_IGMP_STR
3705 DEBUG_IGMP_PACKETS_STR)
3706
3707DEFUN (debug_igmp_trace,
3708 debug_igmp_trace_cmd,
3709 "debug igmp trace",
3710 DEBUG_STR
3711 DEBUG_IGMP_STR
3712 DEBUG_IGMP_TRACE_STR)
3713{
3714 PIM_DO_DEBUG_IGMP_TRACE;
3715 return CMD_SUCCESS;
3716}
3717
3718DEFUN (no_debug_igmp_trace,
3719 no_debug_igmp_trace_cmd,
3720 "no debug igmp trace",
3721 NO_STR
3722 DEBUG_STR
3723 DEBUG_IGMP_STR
3724 DEBUG_IGMP_TRACE_STR)
3725{
3726 PIM_DONT_DEBUG_IGMP_TRACE;
3727 return CMD_SUCCESS;
3728}
3729
3730ALIAS (no_debug_igmp_trace,
3731 undebug_igmp_trace_cmd,
3732 "undebug igmp trace",
3733 UNDEBUG_STR
3734 DEBUG_IGMP_STR
3735 DEBUG_IGMP_TRACE_STR)
3736
3737DEFUN (debug_mroute,
3738 debug_mroute_cmd,
3739 "debug mroute",
3740 DEBUG_STR
3741 DEBUG_MROUTE_STR)
3742{
3743 PIM_DO_DEBUG_MROUTE;
3744 return CMD_SUCCESS;
3745}
3746
3747DEFUN (no_debug_mroute,
3748 no_debug_mroute_cmd,
3749 "no debug mroute",
3750 NO_STR
3751 DEBUG_STR
3752 DEBUG_MROUTE_STR)
3753{
3754 PIM_DONT_DEBUG_MROUTE;
3755 return CMD_SUCCESS;
3756}
3757
3758ALIAS (no_debug_mroute,
3759 undebug_mroute_cmd,
3760 "undebug mroute",
3761 UNDEBUG_STR
3762 DEBUG_MROUTE_STR)
3763
6250610a
JAG
3764DEFUN (debug_static,
3765 debug_static_cmd,
3766 "debug static",
3767 DEBUG_STR
3768 DEBUG_STATIC_STR)
3769{
3770 PIM_DO_DEBUG_STATIC;
3771 return CMD_SUCCESS;
3772}
3773
3774DEFUN (no_debug_static,
3775 no_debug_static_cmd,
3776 "no debug static",
3777 NO_STR
3778 DEBUG_STR
3779 DEBUG_STATIC_STR)
3780{
3781 PIM_DONT_DEBUG_STATIC;
3782 return CMD_SUCCESS;
3783}
3784
3785ALIAS (no_debug_static,
3786 undebug_static_cmd,
3787 "undebug static",
3788 UNDEBUG_STR
3789 DEBUG_STATIC_STR)
3790
12e41d03
DL
3791DEFUN (debug_pim,
3792 debug_pim_cmd,
3793 "debug pim",
3794 DEBUG_STR
3795 DEBUG_PIM_STR)
3796{
3797 PIM_DO_DEBUG_PIM_EVENTS;
3798 PIM_DO_DEBUG_PIM_PACKETS;
3799 PIM_DO_DEBUG_PIM_TRACE;
3800 return CMD_SUCCESS;
3801}
3802
3803DEFUN (no_debug_pim,
3804 no_debug_pim_cmd,
3805 "no debug pim",
3806 NO_STR
3807 DEBUG_STR
3808 DEBUG_PIM_STR)
3809{
3810 PIM_DONT_DEBUG_PIM_EVENTS;
3811 PIM_DONT_DEBUG_PIM_PACKETS;
3812 PIM_DONT_DEBUG_PIM_TRACE;
3813
3814 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3815 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3816
3817 return CMD_SUCCESS;
3818}
3819
3820ALIAS (no_debug_pim,
3821 undebug_pim_cmd,
3822 "undebug pim",
3823 UNDEBUG_STR
3824 DEBUG_PIM_STR)
3825
3826DEFUN (debug_pim_events,
3827 debug_pim_events_cmd,
3828 "debug pim events",
3829 DEBUG_STR
3830 DEBUG_PIM_STR
3831 DEBUG_PIM_EVENTS_STR)
3832{
3833 PIM_DO_DEBUG_PIM_EVENTS;
3834 return CMD_SUCCESS;
3835}
3836
3837DEFUN (no_debug_pim_events,
3838 no_debug_pim_events_cmd,
3839 "no debug pim events",
3840 NO_STR
3841 DEBUG_STR
3842 DEBUG_PIM_STR
3843 DEBUG_PIM_EVENTS_STR)
3844{
3845 PIM_DONT_DEBUG_PIM_EVENTS;
3846 return CMD_SUCCESS;
3847}
3848
3849ALIAS (no_debug_pim_events,
3850 undebug_pim_events_cmd,
3851 "undebug pim events",
3852 UNDEBUG_STR
3853 DEBUG_PIM_STR
3854 DEBUG_PIM_EVENTS_STR)
3855
3856DEFUN (debug_pim_packets,
3857 debug_pim_packets_cmd,
3858 "debug pim packets",
3859 DEBUG_STR
3860 DEBUG_PIM_STR
3861 DEBUG_PIM_PACKETS_STR)
3862{
3863 PIM_DO_DEBUG_PIM_PACKETS;
3864 vty_out (vty, "PIM Packet debugging is on %s", VTY_NEWLINE);
3865 return CMD_SUCCESS;
3866}
3867
3868DEFUN (debug_pim_packets_filter,
3869 debug_pim_packets_filter_cmd,
3870 "debug pim packets (hello|joins)",
3871 DEBUG_STR
3872 DEBUG_PIM_STR
3873 DEBUG_PIM_PACKETS_STR
3874 DEBUG_PIM_HELLO_PACKETS_STR
3875 DEBUG_PIM_J_P_PACKETS_STR)
3876{
3877 if (strncmp(argv[0],"h",1) == 0)
3878 {
3879 PIM_DO_DEBUG_PIM_HELLO;
3880 vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE);
3881 }
3882 else if (strncmp(argv[0],"j",1) == 0)
3883 {
3884 PIM_DO_DEBUG_PIM_J_P;
3885 vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE);
3886 }
3887 return CMD_SUCCESS;
3888}
3889
3890DEFUN (no_debug_pim_packets,
3891 no_debug_pim_packets_cmd,
3892 "no debug pim packets",
3893 NO_STR
3894 DEBUG_STR
3895 DEBUG_PIM_STR
3896 DEBUG_PIM_PACKETS_STR
3897 DEBUG_PIM_HELLO_PACKETS_STR
3898 DEBUG_PIM_J_P_PACKETS_STR)
3899{
3900 PIM_DONT_DEBUG_PIM_PACKETS;
3901 vty_out (vty, "PIM Packet debugging is off %s", VTY_NEWLINE);
3902 return CMD_SUCCESS;
3903}
3904
3905DEFUN (no_debug_pim_packets_filter,
3906 no_debug_pim_packets_filter_cmd,
3907 "no debug pim packets (hello|joins)",
3908 NO_STR
3909 DEBUG_STR
3910 DEBUG_PIM_STR
3911 DEBUG_PIM_PACKETS_STR
3912 DEBUG_PIM_HELLO_PACKETS_STR
3913 DEBUG_PIM_J_P_PACKETS_STR)
3914{
3915 if (strncmp(argv[0],"h",1) == 0)
3916 {
3917 PIM_DONT_DEBUG_PIM_HELLO;
3918 vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
3919 }
3920 else if (strncmp(argv[0],"j",1) == 0)
3921 {
3922 PIM_DONT_DEBUG_PIM_J_P;
3923 vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
3924 }
3925 return CMD_SUCCESS;
3926}
3927
3928ALIAS (no_debug_pim_packets,
3929 undebug_pim_packets_cmd,
3930 "undebug pim packets",
3931 UNDEBUG_STR
3932 DEBUG_PIM_STR
3933 DEBUG_PIM_PACKETS_STR)
3934
3935DEFUN (debug_pim_packetdump_send,
3936 debug_pim_packetdump_send_cmd,
3937 "debug pim packet-dump send",
3938 DEBUG_STR
3939 DEBUG_PIM_STR
3940 DEBUG_PIM_PACKETDUMP_STR
3941 DEBUG_PIM_PACKETDUMP_SEND_STR)
3942{
3943 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
3944 return CMD_SUCCESS;
3945}
3946
3947DEFUN (no_debug_pim_packetdump_send,
3948 no_debug_pim_packetdump_send_cmd,
3949 "no debug pim packet-dump send",
3950 NO_STR
3951 DEBUG_STR
3952 DEBUG_PIM_STR
3953 DEBUG_PIM_PACKETDUMP_STR
3954 DEBUG_PIM_PACKETDUMP_SEND_STR)
3955{
3956 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3957 return CMD_SUCCESS;
3958}
3959
3960ALIAS (no_debug_pim_packetdump_send,
3961 undebug_pim_packetdump_send_cmd,
3962 "undebug pim packet-dump send",
3963 UNDEBUG_STR
3964 DEBUG_PIM_STR
3965 DEBUG_PIM_PACKETDUMP_STR
3966 DEBUG_PIM_PACKETDUMP_SEND_STR)
3967
3968DEFUN (debug_pim_packetdump_recv,
3969 debug_pim_packetdump_recv_cmd,
3970 "debug pim packet-dump receive",
3971 DEBUG_STR
3972 DEBUG_PIM_STR
3973 DEBUG_PIM_PACKETDUMP_STR
3974 DEBUG_PIM_PACKETDUMP_RECV_STR)
3975{
3976 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
3977 return CMD_SUCCESS;
3978}
3979
3980DEFUN (no_debug_pim_packetdump_recv,
3981 no_debug_pim_packetdump_recv_cmd,
3982 "no debug pim packet-dump receive",
3983 NO_STR
3984 DEBUG_STR
3985 DEBUG_PIM_STR
3986 DEBUG_PIM_PACKETDUMP_STR
3987 DEBUG_PIM_PACKETDUMP_RECV_STR)
3988{
3989 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3990 return CMD_SUCCESS;
3991}
3992
3993ALIAS (no_debug_pim_packetdump_recv,
3994 undebug_pim_packetdump_recv_cmd,
3995 "undebug pim packet-dump receive",
3996 UNDEBUG_STR
3997 DEBUG_PIM_STR
3998 DEBUG_PIM_PACKETDUMP_STR
3999 DEBUG_PIM_PACKETDUMP_RECV_STR)
4000
4001DEFUN (debug_pim_trace,
4002 debug_pim_trace_cmd,
4003 "debug pim trace",
4004 DEBUG_STR
4005 DEBUG_PIM_STR
4006 DEBUG_PIM_TRACE_STR)
4007{
4008 PIM_DO_DEBUG_PIM_TRACE;
4009 return CMD_SUCCESS;
4010}
4011
4012DEFUN (no_debug_pim_trace,
4013 no_debug_pim_trace_cmd,
4014 "no debug pim trace",
4015 NO_STR
4016 DEBUG_STR
4017 DEBUG_PIM_STR
4018 DEBUG_PIM_TRACE_STR)
4019{
4020 PIM_DONT_DEBUG_PIM_TRACE;
4021 return CMD_SUCCESS;
4022}
4023
4024ALIAS (no_debug_pim_trace,
4025 undebug_pim_trace_cmd,
4026 "undebug pim trace",
4027 UNDEBUG_STR
4028 DEBUG_PIM_STR
4029 DEBUG_PIM_TRACE_STR)
4030
4031DEFUN (debug_ssmpingd,
4032 debug_ssmpingd_cmd,
4033 "debug ssmpingd",
4034 DEBUG_STR
4035 DEBUG_PIM_STR
4036 DEBUG_SSMPINGD_STR)
4037{
4038 PIM_DO_DEBUG_SSMPINGD;
4039 return CMD_SUCCESS;
4040}
4041
4042DEFUN (no_debug_ssmpingd,
4043 no_debug_ssmpingd_cmd,
4044 "no debug ssmpingd",
4045 NO_STR
4046 DEBUG_STR
4047 DEBUG_PIM_STR
4048 DEBUG_SSMPINGD_STR)
4049{
4050 PIM_DONT_DEBUG_SSMPINGD;
4051 return CMD_SUCCESS;
4052}
4053
4054ALIAS (no_debug_ssmpingd,
4055 undebug_ssmpingd_cmd,
4056 "undebug ssmpingd",
4057 UNDEBUG_STR
4058 DEBUG_PIM_STR
4059 DEBUG_SSMPINGD_STR)
4060
4061DEFUN (debug_pim_zebra,
4062 debug_pim_zebra_cmd,
4063 "debug pim zebra",
4064 DEBUG_STR
4065 DEBUG_PIM_STR
4066 DEBUG_PIM_ZEBRA_STR)
4067{
4068 PIM_DO_DEBUG_ZEBRA;
4069 return CMD_SUCCESS;
4070}
4071
4072DEFUN (no_debug_pim_zebra,
4073 no_debug_pim_zebra_cmd,
4074 "no debug pim zebra",
4075 NO_STR
4076 DEBUG_STR
4077 DEBUG_PIM_STR
4078 DEBUG_PIM_ZEBRA_STR)
4079{
4080 PIM_DONT_DEBUG_ZEBRA;
4081 return CMD_SUCCESS;
4082}
4083
4084ALIAS (no_debug_pim_zebra,
4085 undebug_pim_zebra_cmd,
4086 "undebug pim zebra",
4087 UNDEBUG_STR
4088 DEBUG_PIM_STR
4089 DEBUG_PIM_ZEBRA_STR)
4090
7a1d58ce
DS
4091DEFUN (show_debugging_pim,
4092 show_debugging_pim_cmd,
4093 "show debugging pim",
12e41d03 4094 SHOW_STR
7a1d58ce
DS
4095 DEBUG_STR
4096 PIM_STR)
12e41d03
DL
4097{
4098 pim_debug_config_write(vty);
4099 return CMD_SUCCESS;
4100}
4101
4102static struct igmp_sock *find_igmp_sock_by_fd(int fd)
4103{
4104 struct listnode *ifnode;
4105 struct interface *ifp;
4106
4107 /* scan all interfaces */
469351b3 4108 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
4109 struct pim_interface *pim_ifp;
4110 struct igmp_sock *igmp;
4111
4112 if (!ifp->info)
4113 continue;
4114
4115 pim_ifp = ifp->info;
4116
4117 /* lookup igmp socket under current interface */
4118 igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
4119 if (igmp)
4120 return igmp;
4121 }
4122
4123 return 0;
4124}
4125
4126DEFUN (test_igmp_receive_report,
4127 test_igmp_receive_report_cmd,
4128 "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
4129 "Test\n"
4130 "Test IGMP protocol\n"
4131 "Test IGMP message\n"
4132 "Test IGMP report\n"
4133 "Socket\n"
4134 "IGMP group address\n"
4135 "Record type\n"
4136 "Sources\n")
4137{
4138 char buf[1000];
4139 char *igmp_msg;
4140 struct ip *ip_hdr;
4141 size_t ip_hlen; /* ip header length in bytes */
4142 int ip_msg_len;
4143 int igmp_msg_len;
4144 const char *socket;
4145 int socket_fd;
4146 const char *grp_str;
4147 struct in_addr grp_addr;
4148 const char *record_type_str;
4149 int record_type;
4150 const char *src_str;
4151 int result;
4152 struct igmp_sock *igmp;
4153 char *group_record;
4154 int num_sources;
4155 struct in_addr *sources;
4156 struct in_addr *src_addr;
4157 int argi;
4158
4159 socket = argv[0];
4160 socket_fd = atoi(socket);
4161 igmp = find_igmp_sock_by_fd(socket_fd);
4162 if (!igmp) {
4163 vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
4164 socket, socket_fd, VTY_NEWLINE);
4165 return CMD_WARNING;
4166 }
4167
4168 grp_str = argv[1];
4169 result = inet_pton(AF_INET, grp_str, &grp_addr);
4170 if (result <= 0) {
4171 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4172 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
4173 return CMD_WARNING;
4174 }
4175
4176 record_type_str = argv[2];
4177 record_type = atoi(record_type_str);
4178
4179 /*
4180 Tweak IP header
4181 */
4182 ip_hdr = (struct ip *) buf;
4183 ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
4184 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4185 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4186 ip_hdr->ip_src = igmp->ifaddr;
4187 ip_hdr->ip_dst = igmp->ifaddr;
4188
4189 /*
4190 Build IGMP v3 report message
4191 */
4192 igmp_msg = buf + ip_hlen;
4193 group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
4194 *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
4195 *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
4196 *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
4197 *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
4198 memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr));
4199
4200 /* Scan LINE sources */
4201 sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
4202 src_addr = sources;
4203 for (argi = 3; argi < argc; ++argi,++src_addr) {
4204 src_str = argv[argi];
4205 result = inet_pton(AF_INET, src_str, src_addr);
4206 if (result <= 0) {
4207 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4208 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
4209 return CMD_WARNING;
4210 }
4211 }
4212 num_sources = src_addr - sources;
4213
4214 *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
4215
4216 igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
4217
4218 /* compute checksum */
4219 *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = in_cksum(igmp_msg, igmp_msg_len);
4220
4221 /* "receive" message */
4222
4223 ip_msg_len = ip_hlen + igmp_msg_len;
4224 result = pim_igmp_packet(igmp, buf, ip_msg_len);
4225 if (result) {
4226 vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
4227 ip_msg_len, result, VTY_NEWLINE);
4228 return CMD_WARNING;
4229 }
4230
4231 return CMD_SUCCESS;
4232}
4233
4234static int hexval(uint8_t ch)
4235{
4236 return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a');
4237}
4238
4239DEFUN (test_pim_receive_dump,
4240 test_pim_receive_dump_cmd,
4241 "test pim receive dump INTERFACE A.B.C.D .LINE",
4242 "Test\n"
4243 "Test PIM protocol\n"
4244 "Test PIM message reception\n"
4245 "Test PIM packet dump reception from neighbor\n"
4246 "Interface\n"
4247 "Neighbor address\n"
4248 "Packet dump\n")
4249{
4250 uint8_t buf[1000];
4251 uint8_t *pim_msg;
4252 struct ip *ip_hdr;
4253 size_t ip_hlen; /* ip header length in bytes */
4254 int ip_msg_len;
4255 int pim_msg_size;
4256 const char *neigh_str;
4257 struct in_addr neigh_addr;
4258 const char *ifname;
4259 struct interface *ifp;
4260 int argi;
4261 int result;
4262
4263 /* Find interface */
4264 ifname = argv[0];
4265 ifp = if_lookup_by_name(ifname);
4266 if (!ifp) {
4267 vty_out(vty, "No such interface name %s%s",
4268 ifname, VTY_NEWLINE);
4269 return CMD_WARNING;
4270 }
4271
4272 /* Neighbor address */
4273 neigh_str = argv[1];
4274 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4275 if (result <= 0) {
4276 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
4277 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
4278 return CMD_WARNING;
4279 }
4280
4281 /*
4282 Tweak IP header
4283 */
4284 ip_hdr = (struct ip *) buf;
4285 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4286 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4287 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4288 ip_hdr->ip_src = neigh_addr;
4289 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4290
4291 /*
4292 Build PIM hello message
4293 */
4294 pim_msg = buf + ip_hlen;
4295 pim_msg_size = 0;
4296
4297 /* Scan LINE dump into buffer */
4298 for (argi = 2; argi < argc; ++argi) {
4299 const char *str = argv[argi];
4300 int str_len = strlen(str);
4301 int str_last = str_len - 1;
4302 int i;
4303
4304 if (str_len % 2) {
4305 vty_out(vty, "%% Uneven hex array arg %d=%s%s",
4306 argi, str, VTY_NEWLINE);
4307 return CMD_WARNING;
4308 }
4309
4310 for (i = 0; i < str_last; i += 2) {
4311 uint8_t octet;
4312 int left;
4313 uint8_t h1 = str[i];
4314 uint8_t h2 = str[i + 1];
4315
4316 if (!isxdigit(h1) || !isxdigit(h2)) {
4317 vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s",
4318 h1, h2, argi, str, VTY_NEWLINE);
4319 return CMD_WARNING;
4320 }
4321 octet = (hexval(h1) << 4) + hexval(h2);
4322
4323 left = sizeof(buf) - ip_hlen - pim_msg_size;
4324 if (left < 1) {
4325 vty_out(vty, "%% Overflow buf_size=%zu buf_left=%d at hex array arg %d=%s octet %02x%s",
4326 sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
4327 return CMD_WARNING;
4328 }
4329
4330 pim_msg[pim_msg_size++] = octet;
4331 }
4332 }
4333
4334 ip_msg_len = ip_hlen + pim_msg_size;
4335
4336 vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
4337 sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
4338
4339 /* "receive" message */
4340
4341 result = pim_pim_packet(ifp, buf, ip_msg_len);
4342 if (result) {
4343 vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s",
4344 ip_msg_len, result, VTY_NEWLINE);
4345 return CMD_WARNING;
4346 }
4347
4348 return CMD_SUCCESS;
4349}
4350
4351DEFUN (test_pim_receive_hello,
4352 test_pim_receive_hello_cmd,
4353 "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
4354 "Test\n"
4355 "Test PIM protocol\n"
4356 "Test PIM message reception\n"
4357 "Test PIM hello reception from neighbor\n"
4358 "Interface\n"
4359 "Neighbor address\n"
4360 "Neighbor holdtime\n"
4361 "Neighbor DR priority\n"
4362 "Neighbor generation ID\n"
4363 "Neighbor propagation delay (msec)\n"
4364 "Neighbor override interval (msec)\n"
4365 "Neighbor LAN prune delay T-bit\n"
4366 "Neighbor secondary addresses\n")
4367{
4368 uint8_t buf[1000];
4369 uint8_t *pim_msg;
4370 struct ip *ip_hdr;
4371 size_t ip_hlen; /* ip header length in bytes */
4372 int ip_msg_len;
4373 int pim_tlv_size;
4374 int pim_msg_size;
4375 const char *neigh_str;
4376 struct in_addr neigh_addr;
4377 const char *ifname;
4378 struct interface *ifp;
4379 uint16_t neigh_holdtime;
4380 uint16_t neigh_propagation_delay;
4381 uint16_t neigh_override_interval;
4382 int neigh_can_disable_join_suppression;
4383 uint32_t neigh_dr_priority;
4384 uint32_t neigh_generation_id;
4385 int argi;
4386 int result;
4387
4388 /* Find interface */
4389 ifname = argv[0];
4390 ifp = if_lookup_by_name(ifname);
4391 if (!ifp) {
4392 vty_out(vty, "No such interface name %s%s",
4393 ifname, VTY_NEWLINE);
4394 return CMD_WARNING;
4395 }
4396
4397 /* Neighbor address */
4398 neigh_str = argv[1];
4399 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4400 if (result <= 0) {
4401 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
4402 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
4403 return CMD_WARNING;
4404 }
4405
4406 neigh_holdtime = atoi(argv[2]);
4407 neigh_dr_priority = atoi(argv[3]);
4408 neigh_generation_id = atoi(argv[4]);
4409 neigh_propagation_delay = atoi(argv[5]);
4410 neigh_override_interval = atoi(argv[6]);
4411 neigh_can_disable_join_suppression = atoi(argv[7]);
4412
4413 /*
4414 Tweak IP header
4415 */
4416 ip_hdr = (struct ip *) buf;
4417 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4418 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4419 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4420 ip_hdr->ip_src = neigh_addr;
4421 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4422
4423 /*
4424 Build PIM hello message
4425 */
4426 pim_msg = buf + ip_hlen;
4427
4428 /* Scan LINE addresses */
4429 for (argi = 8; argi < argc; ++argi) {
4430 const char *sec_str = argv[argi];
4431 struct in_addr sec_addr;
4432 result = inet_pton(AF_INET, sec_str, &sec_addr);
4433 if (result <= 0) {
4434 vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
4435 sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
4436 return CMD_WARNING;
4437 }
4438
4439 vty_out(vty,
4440 "FIXME WRITEME consider neighbor secondary address %s%s",
4441 sec_str, VTY_NEWLINE);
4442 }
4443
4444 pim_tlv_size = pim_hello_build_tlv(ifp->name,
4445 pim_msg + PIM_PIM_MIN_LEN,
4446 sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
4447 neigh_holdtime,
4448 neigh_dr_priority,
4449 neigh_generation_id,
4450 neigh_propagation_delay,
4451 neigh_override_interval,
4452 neigh_can_disable_join_suppression,
4453 0 /* FIXME secondary address list */);
4454 if (pim_tlv_size < 0) {
4455 vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
4456 pim_tlv_size, VTY_NEWLINE);
4457 return CMD_WARNING;
4458 }
4459
4460 pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
4461
4462 pim_msg_build_header(pim_msg, pim_msg_size,
4463 PIM_MSG_TYPE_HELLO);
4464
4465 /* "receive" message */
4466
4467 ip_msg_len = ip_hlen + pim_msg_size;
4468 result = pim_pim_packet(ifp, buf, ip_msg_len);
4469 if (result) {
4470 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4471 ip_msg_len, result, VTY_NEWLINE);
4472 return CMD_WARNING;
4473 }
4474
4475 return CMD_SUCCESS;
4476}
4477
4478DEFUN (test_pim_receive_assert,
4479 test_pim_receive_assert_cmd,
4480 "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
4481 "Test\n"
4482 "Test PIM protocol\n"
4483 "Test PIM message reception\n"
4484 "Test reception of PIM assert\n"
4485 "Interface\n"
4486 "Neighbor address\n"
4487 "Assert multicast group address\n"
4488 "Assert unicast source address\n"
4489 "Assert metric preference\n"
4490 "Assert route metric\n"
4491 "Assert RPT bit flag\n")
4492{
4493 uint8_t buf[1000];
4494 uint8_t *buf_pastend = buf + sizeof(buf);
4495 uint8_t *pim_msg;
4496 struct ip *ip_hdr;
4497 size_t ip_hlen; /* ip header length in bytes */
4498 int ip_msg_len;
4499 int pim_msg_size;
4500 const char *neigh_str;
4501 struct in_addr neigh_addr;
4502 const char *group_str;
4503 struct in_addr group_addr;
4504 const char *source_str;
4505 struct in_addr source_addr;
4506 const char *ifname;
4507 struct interface *ifp;
4508 uint32_t assert_metric_preference;
4509 uint32_t assert_route_metric;
4510 uint32_t assert_rpt_bit_flag;
4511 int remain;
4512 int result;
4513
4514 /* Find interface */
4515 ifname = argv[0];
4516 ifp = if_lookup_by_name(ifname);
4517 if (!ifp) {
4518 vty_out(vty, "No such interface name %s%s",
4519 ifname, VTY_NEWLINE);
4520 return CMD_WARNING;
4521 }
4522
4523 /* Neighbor address */
4524 neigh_str = argv[1];
4525 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4526 if (result <= 0) {
4527 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
4528 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
4529 return CMD_WARNING;
4530 }
4531
4532 /* Group address */
4533 group_str = argv[2];
4534 result = inet_pton(AF_INET, group_str, &group_addr);
4535 if (result <= 0) {
4536 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4537 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
4538 return CMD_WARNING;
4539 }
4540
4541 /* Source address */
4542 source_str = argv[3];
4543 result = inet_pton(AF_INET, source_str, &source_addr);
4544 if (result <= 0) {
4545 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4546 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
4547 return CMD_WARNING;
4548 }
4549
4550 assert_metric_preference = atoi(argv[4]);
4551 assert_route_metric = atoi(argv[5]);
4552 assert_rpt_bit_flag = atoi(argv[6]);
4553
4554 remain = buf_pastend - buf;
4555 if (remain < (int) sizeof(struct ip)) {
4556 vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
4557 remain, sizeof(struct ip), VTY_NEWLINE);
4558 return CMD_WARNING;
4559 }
4560
4561 /*
4562 Tweak IP header
4563 */
4564 ip_hdr = (struct ip *) buf;
4565 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4566 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4567 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4568 ip_hdr->ip_src = neigh_addr;
4569 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4570
4571 /*
4572 Build PIM assert message
4573 */
4574 pim_msg = buf + ip_hlen; /* skip ip header */
4575
4576 pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
4577 group_addr, source_addr,
4578 assert_metric_preference,
4579 assert_route_metric,
4580 assert_rpt_bit_flag);
4581 if (pim_msg_size < 0) {
4582 vty_out(vty, "Failure building PIM assert message: size=%d%s",
4583 pim_msg_size, VTY_NEWLINE);
4584 return CMD_WARNING;
4585 }
4586
4587 /* "receive" message */
4588
4589 ip_msg_len = ip_hlen + pim_msg_size;
4590 result = pim_pim_packet(ifp, buf, ip_msg_len);
4591 if (result) {
4592 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4593 ip_msg_len, result, VTY_NEWLINE);
4594 return CMD_WARNING;
4595 }
4596
4597 return CMD_SUCCESS;
4598}
4599
4600static int recv_joinprune(struct vty *vty,
4601 const char *argv[],
4602 int src_is_join)
4603{
4604 uint8_t buf[1000];
4605 const uint8_t *buf_pastend = buf + sizeof(buf);
4606 uint8_t *pim_msg;
4607 uint8_t *pim_msg_curr;
4608 int pim_msg_size;
4609 struct ip *ip_hdr;
4610 size_t ip_hlen; /* ip header length in bytes */
4611 int ip_msg_len;
4612 uint16_t neigh_holdtime;
4613 const char *neigh_dst_str;
4614 struct in_addr neigh_dst_addr;
4615 const char *neigh_src_str;
4616 struct in_addr neigh_src_addr;
4617 const char *group_str;
4618 struct in_addr group_addr;
4619 const char *source_str;
4620 struct in_addr source_addr;
4621 const char *ifname;
4622 struct interface *ifp;
4623 int result;
4624 int remain;
4625 uint16_t num_joined;
4626 uint16_t num_pruned;
4627
4628 /* Find interface */
4629 ifname = argv[0];
4630 ifp = if_lookup_by_name(ifname);
4631 if (!ifp) {
4632 vty_out(vty, "No such interface name %s%s",
4633 ifname, VTY_NEWLINE);
4634 return CMD_WARNING;
4635 }
4636
4637 neigh_holdtime = atoi(argv[1]);
4638
4639 /* Neighbor destination address */
4640 neigh_dst_str = argv[2];
4641 result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
4642 if (result <= 0) {
4643 vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
4644 neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
4645 return CMD_WARNING;
4646 }
4647
4648 /* Neighbor source address */
4649 neigh_src_str = argv[3];
4650 result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
4651 if (result <= 0) {
4652 vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
4653 neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
4654 return CMD_WARNING;
4655 }
4656
4657 /* Multicast group address */
4658 group_str = argv[4];
4659 result = inet_pton(AF_INET, group_str, &group_addr);
4660 if (result <= 0) {
4661 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4662 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
4663 return CMD_WARNING;
4664 }
4665
4666 /* Multicast source address */
4667 source_str = argv[5];
4668 result = inet_pton(AF_INET, source_str, &source_addr);
4669 if (result <= 0) {
4670 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4671 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
4672 return CMD_WARNING;
4673 }
4674
4675 /*
4676 Tweak IP header
4677 */
4678 ip_hdr = (struct ip *) buf;
4679 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4680 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4681 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4682 ip_hdr->ip_src = neigh_src_addr;
4683 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4684
4685 /*
4686 Build PIM message
4687 */
4688 pim_msg = buf + ip_hlen;
4689
4690 /* skip room for pim header */
4691 pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
4692
4693 remain = buf_pastend - pim_msg_curr;
4694 pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
4695 remain,
4696 neigh_dst_addr);
4697 if (!pim_msg_curr) {
4698 vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
4699 neigh_dst_str, remain, VTY_NEWLINE);
4700 return CMD_WARNING;
4701 }
4702
4703 remain = buf_pastend - pim_msg_curr;
4704 if (remain < 4) {
4705 vty_out(vty, "Group will not fit: space left=%d%s",
4706 remain, VTY_NEWLINE);
4707 return CMD_WARNING;
4708 }
4709
4710 *pim_msg_curr = 0; /* reserved */
4711 ++pim_msg_curr;
4712 *pim_msg_curr = 1; /* number of groups */
4713 ++pim_msg_curr;
4714 *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
4715 ++pim_msg_curr;
4716 ++pim_msg_curr;
4717
4718 remain = buf_pastend - pim_msg_curr;
4719 pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
4720 remain,
4721 group_addr);
4722 if (!pim_msg_curr) {
4723 vty_out(vty, "Failure encoding group address %s: space left=%d%s",
4724 group_str, remain, VTY_NEWLINE);
4725 return CMD_WARNING;
4726 }
4727
4728 remain = buf_pastend - pim_msg_curr;
4729 if (remain < 4) {
4730 vty_out(vty, "Sources will not fit: space left=%d%s",
4731 remain, VTY_NEWLINE);
4732 return CMD_WARNING;
4733 }
4734
4735 if (src_is_join) {
4736 num_joined = 1;
4737 num_pruned = 0;
4738 }
4739 else {
4740 num_joined = 0;
4741 num_pruned = 1;
4742 }
4743
4744 /* number of joined sources */
4745 *((uint16_t *) pim_msg_curr) = htons(num_joined);
4746 ++pim_msg_curr;
4747 ++pim_msg_curr;
4748
4749 /* number of pruned sources */
4750 *((uint16_t *) pim_msg_curr) = htons(num_pruned);
4751 ++pim_msg_curr;
4752 ++pim_msg_curr;
4753
4754 remain = buf_pastend - pim_msg_curr;
4755 pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
4756 remain,
4757 source_addr);
4758 if (!pim_msg_curr) {
4759 vty_out(vty, "Failure encoding source address %s: space left=%d%s",
4760 source_str, remain, VTY_NEWLINE);
4761 return CMD_WARNING;
4762 }
4763
4764 /* Add PIM header */
4765
4766 pim_msg_size = pim_msg_curr - pim_msg;
4767
4768 pim_msg_build_header(pim_msg, pim_msg_size,
4769 PIM_MSG_TYPE_JOIN_PRUNE);
4770
4771 /*
4772 "Receive" message
4773 */
4774
4775 ip_msg_len = ip_hlen + pim_msg_size;
4776 result = pim_pim_packet(ifp, buf, ip_msg_len);
4777 if (result) {
4778 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4779 ip_msg_len, result, VTY_NEWLINE);
4780 return CMD_WARNING;
4781 }
4782
4783 return CMD_SUCCESS;
4784}
4785
4786DEFUN (test_pim_receive_join,
4787 test_pim_receive_join_cmd,
4788 "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4789 "Test\n"
4790 "Test PIM protocol\n"
4791 "Test PIM message reception\n"
4792 "Test PIM join reception from neighbor\n"
4793 "Interface\n"
4794 "Neighbor holdtime\n"
4795 "Upstream neighbor unicast destination address\n"
4796 "Downstream neighbor unicast source address\n"
4797 "Multicast group address\n"
4798 "Unicast source address\n")
4799{
4800 return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
4801}
4802
4803DEFUN (test_pim_receive_prune,
4804 test_pim_receive_prune_cmd,
4805 "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4806 "Test\n"
4807 "Test PIM protocol\n"
4808 "Test PIM message reception\n"
4809 "Test PIM prune reception from neighbor\n"
4810 "Interface\n"
4811 "Neighbor holdtime\n"
4812 "Upstream neighbor unicast destination address\n"
4813 "Downstream neighbor unicast source address\n"
4814 "Multicast group address\n"
4815 "Unicast source address\n")
4816{
4817 return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
4818}
4819
4820DEFUN (test_pim_receive_upcall,
4821 test_pim_receive_upcall_cmd,
4822 "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
4823 "Test\n"
4824 "Test PIM protocol\n"
4825 "Test PIM message reception\n"
4826 "Test reception of kernel upcall\n"
4827 "NOCACHE kernel upcall\n"
4828 "WRONGVIF kernel upcall\n"
4829 "WHOLEPKT kernel upcall\n"
4830 "Input interface vif index\n"
4831 "Multicast group address\n"
4832 "Multicast source address\n")
4833{
4834 struct igmpmsg msg;
4835 const char *upcall_type;
4836 const char *group_str;
4837 const char *source_str;
4838 int result;
4839
4840 upcall_type = argv[0];
4841
4842 if (upcall_type[0] == 'n')
4843 msg.im_msgtype = IGMPMSG_NOCACHE;
4844 else if (upcall_type[1] == 'r')
4845 msg.im_msgtype = IGMPMSG_WRONGVIF;
4846 else if (upcall_type[1] == 'h')
4847 msg.im_msgtype = IGMPMSG_WHOLEPKT;
4848 else {
4849 vty_out(vty, "Unknown kernel upcall type: %s%s",
4850 upcall_type, VTY_NEWLINE);
4851 return CMD_WARNING;
4852 }
4853
4854 msg.im_vif = atoi(argv[1]);
4855
4856 /* Group address */
4857 group_str = argv[2];
4858 result = inet_pton(AF_INET, group_str, &msg.im_dst);
4859 if (result <= 0) {
4860 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4861 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
4862 return CMD_WARNING;
4863 }
4864
4865 /* Source address */
4866 source_str = argv[3];
4867 result = inet_pton(AF_INET, source_str, &msg.im_src);
4868 if (result <= 0) {
4869 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4870 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
4871 return CMD_WARNING;
4872 }
4873
4874 msg.im_mbz = 0; /* Must be zero */
4875
4876 result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
4877 if (result) {
4878 vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
4879 sizeof(msg), result, VTY_NEWLINE);
4880 return CMD_WARNING;
4881 }
4882
4883 return CMD_SUCCESS;
4884}
4885
4886void pim_cmd_init()
4887{
4888 install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
4889 install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
4890
4891 install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
4892 install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
981d6c7a
DS
4893 install_element (CONFIG_NODE, &ip_pim_rp_cmd);
4894 install_element (CONFIG_NODE, &no_ip_pim_rp_cmd);
12e41d03
DL
4895 install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
4896 install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
4897#if 0
4898 install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
4899#else
4900 install_element (CONFIG_NODE, &pim_interface_cmd);
4901#endif
4902 install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
4903
4904 install_default (INTERFACE_NODE);
4905 install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
4906 install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
4907 install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
4908 install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
4909 install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
4910 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
4911 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
4912 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
4913 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
4914 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
4915 install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
dedccda6 4916 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
981d6c7a
DS
4917 install_element (INTERFACE_NODE, &interface_ip_pim_sm_cmd);
4918 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
dedccda6
DS
4919 install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd);
4920 install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd);
7960fa8f
DS
4921 install_element (INTERFACE_NODE, &interface_ip_pim_hello_cmd);
4922 install_element (INTERFACE_NODE, &interface_ip_pim_hello_hold_cmd);
4923 install_element (INTERFACE_NODE, &interface_no_ip_pim_hello_cmd);
12e41d03 4924
6250610a
JAG
4925 // Static mroutes NEB
4926 install_element (INTERFACE_NODE, &interface_ip_mroute_cmd);
4927 install_element (INTERFACE_NODE, &interface_ip_mroute_source_cmd);
4928 install_element (INTERFACE_NODE, &interface_no_ip_mroute_cmd);
4929 install_element (INTERFACE_NODE, &interface_no_ip_mroute_source_cmd);
4930
12e41d03
DL
4931 install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
4932 install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
4933 install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
4934 install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
4935 install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4936 install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
4937 install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4938 install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
4939 install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
4940 install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
4941 install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
4942 install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
4943 install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
4944 install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
4945 install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
4946 install_element (VIEW_NODE, &show_ip_pim_join_cmd);
4947 install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
4948 install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
4949 install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
4950 install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
4951 install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
4952 install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
4953 install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
4954 install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
4955 install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
4956 install_element (VIEW_NODE, &show_ip_multicast_cmd);
4957 install_element (VIEW_NODE, &show_ip_mroute_cmd);
4958 install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
4959 install_element (VIEW_NODE, &show_ip_rib_cmd);
4960 install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
7a1d58ce 4961 install_element (VIEW_NODE, &show_debugging_pim_cmd);
12e41d03
DL
4962
4963 install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
4964 install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
4965 install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
4966 install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
4967 install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
4968
4969 install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
4970 install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
4971 install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
4972 install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
4973 install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4974 install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
4975 install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4976 install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
4977 install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
4978 install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
4979 install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
4980 install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
4981 install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
4982 install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
4983 install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
4984 install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
4985 install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
4986 install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
4987 install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
4988 install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
4989 install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
4990 install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
4991 install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
4992 install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
4993 install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
4994 install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
4995 install_element (ENABLE_NODE, &show_ip_multicast_cmd);
4996 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
4997 install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
4998 install_element (ENABLE_NODE, &show_ip_rib_cmd);
4999 install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd);
7a1d58ce 5000 install_element (ENABLE_NODE, &show_debugging_pim_cmd);
12e41d03
DL
5001
5002 install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
5003 install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
5004 install_element (ENABLE_NODE, &test_pim_receive_dump_cmd);
5005 install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
5006 install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
5007 install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
5008 install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
5009
5010 install_element (ENABLE_NODE, &debug_igmp_cmd);
5011 install_element (ENABLE_NODE, &no_debug_igmp_cmd);
5012 install_element (ENABLE_NODE, &undebug_igmp_cmd);
5013 install_element (ENABLE_NODE, &debug_igmp_events_cmd);
5014 install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
5015 install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
5016 install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
5017 install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
5018 install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
5019 install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
5020 install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
5021 install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
5022 install_element (ENABLE_NODE, &debug_mroute_cmd);
5023 install_element (ENABLE_NODE, &no_debug_mroute_cmd);
6250610a
JAG
5024 install_element (ENABLE_NODE, &debug_static_cmd);
5025 install_element (ENABLE_NODE, &no_debug_static_cmd);
12e41d03
DL
5026 install_element (ENABLE_NODE, &debug_pim_cmd);
5027 install_element (ENABLE_NODE, &no_debug_pim_cmd);
5028 install_element (ENABLE_NODE, &undebug_pim_cmd);
5029 install_element (ENABLE_NODE, &debug_pim_events_cmd);
5030 install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
5031 install_element (ENABLE_NODE, &undebug_pim_events_cmd);
5032 install_element (ENABLE_NODE, &debug_pim_packets_cmd);
5033 install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd);
5034 install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
5035 install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd);
5036 install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
5037 install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
5038 install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
5039 install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd);
5040 install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
5041 install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
5042 install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd);
5043 install_element (ENABLE_NODE, &debug_pim_trace_cmd);
5044 install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
5045 install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
5046 install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
5047 install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
5048 install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
5049 install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
5050 install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
5051 install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
5052
5053 install_element (CONFIG_NODE, &debug_igmp_cmd);
5054 install_element (CONFIG_NODE, &no_debug_igmp_cmd);
5055 install_element (CONFIG_NODE, &undebug_igmp_cmd);
5056 install_element (CONFIG_NODE, &debug_igmp_events_cmd);
5057 install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
5058 install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
5059 install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
5060 install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
5061 install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
5062 install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
5063 install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
5064 install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
5065 install_element (CONFIG_NODE, &debug_mroute_cmd);
5066 install_element (CONFIG_NODE, &no_debug_mroute_cmd);
6250610a
JAG
5067 install_element (CONFIG_NODE, &debug_static_cmd);
5068 install_element (CONFIG_NODE, &no_debug_static_cmd);
12e41d03
DL
5069 install_element (CONFIG_NODE, &debug_pim_cmd);
5070 install_element (CONFIG_NODE, &no_debug_pim_cmd);
5071 install_element (CONFIG_NODE, &undebug_pim_cmd);
5072 install_element (CONFIG_NODE, &debug_pim_events_cmd);
5073 install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
5074 install_element (CONFIG_NODE, &undebug_pim_events_cmd);
5075 install_element (CONFIG_NODE, &debug_pim_packets_cmd);
5076 install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd);
5077 install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
5078 install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd);
5079 install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
5080 install_element (CONFIG_NODE, &debug_pim_trace_cmd);
5081 install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
5082 install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
5083 install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
5084 install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
5085 install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
5086 install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
5087 install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
5088 install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
5089}