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