blob: c89f2b5a31843b4dea2880312c502941f91a0410 [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
Everton Marques777fe1f2014-02-14 14:16:07 -0200566 vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri%s", VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -0300567
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
Everton Marques777fe1f2014-02-14 14:16:07 -0200590 vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d%s",
Everton Marques871dbcf2009-08-11 15:43:05 -0300591 ifp->name,
592 inet_ntoa(ifaddr),
593 dr_str,
594 dr_uptime,
595 pim_ifp->pim_dr_election_count,
Everton Marques777fe1f2014-02-14 14:16:07 -0200596 pim_ifp->pim_dr_election_changes,
Everton Marques871dbcf2009-08-11 15:43:05 -0300597 pim_ifp->pim_dr_num_nondrpri_neighbors,
598 VTY_NEWLINE);
599 }
600}
601
602static void pim_show_hello(struct vty *vty)
603{
604 struct listnode *node;
605 struct interface *ifp;
606 time_t now;
607
608 now = pim_time_monotonic_sec();
609
610 vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
611
612 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
613 struct pim_interface *pim_ifp;
614 struct in_addr ifaddr;
615 char hello_period[10];
616 char hello_timer[10];
617 char stat_uptime[10];
618
619 pim_ifp = ifp->info;
620
621 if (!pim_ifp)
622 continue;
623
624 if (pim_ifp->pim_sock_fd < 0)
625 continue;
626
627 ifaddr = pim_ifp->primary_address;
628
629 pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
630 pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
631 pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
632
633 vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
634 ifp->name,
635 inet_ntoa(ifaddr),
636 hello_period,
637 hello_timer,
638 stat_uptime,
639 pim_ifp->pim_ifstat_hello_recv,
640 pim_ifp->pim_ifstat_hello_recvfail,
641 pim_ifp->pim_ifstat_hello_sent,
642 pim_ifp->pim_ifstat_hello_sendfail,
643 VTY_NEWLINE);
644 }
645}
646
647static void pim_show_interfaces(struct vty *vty)
648{
649 struct listnode *node;
650 struct interface *ifp;
651 time_t now;
652
653 now = pim_time_monotonic_sec();
654
655 vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
656
657 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
658 struct pim_interface *pim_ifp;
659 struct in_addr ifaddr;
660 char uptime[10];
661 int mloop;
662
663 pim_ifp = ifp->info;
664
665 if (!pim_ifp)
666 continue;
667
668 if (pim_ifp->pim_sock_fd < 0)
669 continue;
670
671 ifaddr = pim_ifp->primary_address;
672
673 pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
674
675 mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
676
677 vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
678 ifp->name,
679 inet_ntoa(ifaddr),
680 ifp->ifindex,
681 pim_ifp->pim_sock_fd,
682 uptime,
683 if_is_multicast(ifp) ? "yes" : "no",
684 if_is_broadcast(ifp) ? "yes" : "no",
685 (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
686 (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
687 (ifp->flags & IFF_PROMISC) ? "yes" : "no",
688 PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
689 VTY_NEWLINE);
690 }
691}
692
693static void pim_show_join(struct vty *vty)
694{
695 struct listnode *ifnode;
696 struct interface *ifp;
697 time_t now;
698
699 now = pim_time_monotonic_sec();
700
701 vty_out(vty,
702 "Interface Address Source Group State Uptime Expire Prune%s",
703 VTY_NEWLINE);
704
705 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
706 struct pim_interface *pim_ifp;
707 struct in_addr ifaddr;
708 struct listnode *ch_node;
709 struct pim_ifchannel *ch;
710
711 pim_ifp = ifp->info;
712
713 if (!pim_ifp)
714 continue;
715
716 ifaddr = pim_ifp->primary_address;
717
718 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
719 char ch_src_str[100];
720 char ch_grp_str[100];
721 char uptime[10];
722 char expire[10];
723 char prune[10];
724
725 pim_inet4_dump("<ch_src?>", ch->source_addr,
726 ch_src_str, sizeof(ch_src_str));
727 pim_inet4_dump("<ch_grp?>", ch->group_addr,
728 ch_grp_str, sizeof(ch_grp_str));
729
730 pim_time_uptime(uptime, sizeof(uptime), now - ch->ifjoin_creation);
731 pim_time_timer_to_mmss(expire, sizeof(expire),
732 ch->t_ifjoin_expiry_timer);
733 pim_time_timer_to_mmss(prune, sizeof(prune),
734 ch->t_ifjoin_prune_pending_timer);
735
736 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
737 ifp->name,
738 inet_ntoa(ifaddr),
739 ch_src_str,
740 ch_grp_str,
741 pim_ifchannel_ifjoin_name(ch->ifjoin_state),
742 uptime,
743 expire,
744 prune,
745 VTY_NEWLINE);
746 } /* scan interface channels */
747 } /* scan interfaces */
748
749}
750
751static void pim_show_neighbors(struct vty *vty)
752{
753 struct listnode *node;
754 struct interface *ifp;
755 time_t now;
756
757 now = pim_time_monotonic_sec();
758
759 vty_out(vty,
760 "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
761 " T=can_disable_join_suppression%s%s",
762 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
763
764 vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
765
766 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
767 struct pim_interface *pim_ifp;
768 struct in_addr ifaddr;
769 struct listnode *neighnode;
770 struct pim_neighbor *neigh;
771
772 pim_ifp = ifp->info;
773
774 if (!pim_ifp)
775 continue;
776
777 if (pim_ifp->pim_sock_fd < 0)
778 continue;
779
780 ifaddr = pim_ifp->primary_address;
781
782 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
783 char uptime[10];
784 char holdtime[10];
785 char expire[10];
786 char neigh_src_str[100];
787 char recv[7];
788
789 pim_inet4_dump("<src?>", neigh->source_addr,
790 neigh_src_str, sizeof(neigh_src_str));
791 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
792 pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
793 pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
794
795 recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
796 recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
797 recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
798 recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
799 recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
800 recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
801 recv[6] = '\0';
802
803 vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
804 ifp->name,
805 inet_ntoa(ifaddr),
806 neigh_src_str,
807 uptime,
808 expire,
809 holdtime,
810 neigh->dr_priority,
811 neigh->generation_id,
812 recv,
813 VTY_NEWLINE);
814 }
815
816
817 }
818}
819
820static void pim_show_lan_prune_delay(struct vty *vty)
821{
822 struct listnode *node;
823 struct interface *ifp;
824
825 vty_out(vty,
826 "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
827 "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
828 "NoDly=number_of_non_lan_delay_neighbors%s"
829 "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
830 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
831
832 vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE);
833
834 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
835 struct pim_interface *pim_ifp;
836 struct in_addr ifaddr;
837 struct listnode *neighnode;
838 struct pim_neighbor *neigh;
839
840 pim_ifp = ifp->info;
841
842 if (!pim_ifp)
843 continue;
844
845 if (pim_ifp->pim_sock_fd < 0)
846 continue;
847
848 ifaddr = pim_ifp->primary_address;
849
850 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
851 char neigh_src_str[100];
852
853 pim_inet4_dump("<src?>", neigh->source_addr,
854 neigh_src_str, sizeof(neigh_src_str));
855
Everton Marques5f35a522009-08-20 11:57:41 -0300856 vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u %-15s %-3s %5u %5u %1u%s",
Everton Marques871dbcf2009-08-11 15:43:05 -0300857 ifp->name,
858 inet_ntoa(ifaddr),
859 pim_ifp->pim_propagation_delay_msec,
860 pim_ifp->pim_override_interval_msec,
861 pim_ifp->pim_number_of_nonlandelay_neighbors,
862 pim_ifp->pim_neighbors_highest_propagation_delay_msec,
863 pim_ifp->pim_neighbors_highest_override_interval_msec,
864 PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
865 neigh_src_str,
866 PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
867 neigh->propagation_delay_msec,
868 neigh->override_interval_msec,
869 PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
870 PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
871 VTY_NEWLINE);
872 }
873
874 }
875}
876
877static void pim_show_jp_override_interval(struct vty *vty)
878{
879 struct listnode *node;
880 struct interface *ifp;
881
882 vty_out(vty,
883 "EffPDelay=effective_propagation_delay (msec)%s"
884 "EffOvrInt=override_interval (msec)%s"
885 "JPOvrInt=jp_override_interval (msec)%s%s",
886 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
887
888 vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
889
890 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
891 struct pim_interface *pim_ifp;
892 struct in_addr ifaddr;
893
894 pim_ifp = ifp->info;
895
896 if (!pim_ifp)
897 continue;
898
899 if (pim_ifp->pim_sock_fd < 0)
900 continue;
901
902 ifaddr = pim_ifp->primary_address;
903
904 vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
905 ifp->name,
906 inet_ntoa(ifaddr),
907 pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
908 pim_if_effective_propagation_delay_msec(ifp),
909 pim_if_effective_override_interval_msec(ifp),
910 pim_if_jp_override_interval_msec(ifp),
911 VTY_NEWLINE);
912 }
913}
914
915static void pim_show_neighbors_secondary(struct vty *vty)
916{
917 struct listnode *node;
918 struct interface *ifp;
919
920 vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
921
922 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
923 struct pim_interface *pim_ifp;
924 struct in_addr ifaddr;
925 struct listnode *neighnode;
926 struct pim_neighbor *neigh;
927
928 pim_ifp = ifp->info;
929
930 if (!pim_ifp)
931 continue;
932
933 if (pim_ifp->pim_sock_fd < 0)
934 continue;
935
936 ifaddr = pim_ifp->primary_address;
937
938 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
939 char neigh_src_str[100];
940 struct listnode *prefix_node;
941 struct prefix *p;
942
943 if (!neigh->prefix_list)
944 continue;
945
946 pim_inet4_dump("<src?>", neigh->source_addr,
947 neigh_src_str, sizeof(neigh_src_str));
948
949 for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
950 char neigh_sec_str[100];
951
952 if (p->family != AF_INET)
953 continue;
954
955 pim_inet4_dump("<src?>", p->u.prefix4,
956 neigh_sec_str, sizeof(neigh_sec_str));
957
958 vty_out(vty, "%-9s %-15s %-15s %-15s%s",
959 ifp->name,
960 inet_ntoa(ifaddr),
961 neigh_src_str,
962 neigh_sec_str,
963 VTY_NEWLINE);
964 }
965 }
966 }
967}
968
969static void pim_show_upstream(struct vty *vty)
970{
971 struct listnode *upnode;
972 struct pim_upstream *up;
973 time_t now;
974
975 now = pim_time_monotonic_sec();
976
977 vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
978
979 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
980 char src_str[100];
981 char grp_str[100];
982 char uptime[10];
983 char join_timer[10];
984
985 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
986 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
987 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
988 pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
989
990 vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
991 src_str,
992 grp_str,
993 up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
994 uptime,
995 join_timer,
996 up->ref_count,
997 VTY_NEWLINE);
998 }
999}
1000
1001static void pim_show_join_desired(struct vty *vty)
1002{
1003 struct listnode *ifnode;
1004 struct listnode *chnode;
1005 struct interface *ifp;
1006 struct pim_interface *pim_ifp;
1007 struct pim_ifchannel *ch;
1008 struct in_addr me_ifaddr;
1009 char src_str[100];
1010 char grp_str[100];
1011
1012 vty_out(vty,
1013 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
1014 VTY_NEWLINE);
1015
1016 /* scan all interfaces */
1017 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1018 pim_ifp = ifp->info;
1019 if (!pim_ifp)
1020 continue;
1021
1022 me_ifaddr = pim_ifp->primary_address;
1023
1024 /* scan per-interface (S,G) state */
1025 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
1026 struct pim_upstream *up = ch->upstream;
1027
1028 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1029 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1030
1031 vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
1032 ifp->name,
1033 src_str,
1034 grp_str,
1035 pim_macro_ch_lost_assert(ch) ? "yes" : "no",
1036 pim_macro_chisin_joins(ch) ? "yes" : "no",
1037 pim_macro_chisin_pim_include(ch) ? "yes" : "no",
1038 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
1039 pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
1040 VTY_NEWLINE);
1041 }
1042 }
1043}
1044
1045static void pim_show_upstream_rpf(struct vty *vty)
1046{
1047 struct listnode *upnode;
1048 struct pim_upstream *up;
1049
1050 vty_out(vty,
1051 "Source Group RpfIface RibNextHop RpfAddress %s",
1052 VTY_NEWLINE);
1053
1054 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
1055 char src_str[100];
1056 char grp_str[100];
1057 char rpf_nexthop_str[100];
1058 char rpf_addr_str[100];
1059 struct pim_rpf *rpf;
1060 const char *rpf_ifname;
1061
1062 rpf = &up->rpf;
1063
1064 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1065 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1066 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
1067 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1068
1069 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1070
1071 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
1072 src_str,
1073 grp_str,
1074 rpf_ifname,
1075 rpf_nexthop_str,
1076 rpf_addr_str,
1077 VTY_NEWLINE);
1078 }
1079}
1080
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001081static void show_rpf_refresh_stats(struct vty *vty, time_t now)
Everton Marques613938d2009-08-13 15:39:31 -03001082{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001083 char refresh_uptime[10];
1084
Everton Marquesff752d42010-03-17 10:34:24 -03001085 pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001086
Everton Marques613938d2009-08-13 15:39:31 -03001087 vty_out(vty,
1088 "RPF Cache Refresh Delay: %ld msecs%s"
1089 "RPF Cache Refresh Timer: %ld msecs%s"
1090 "RPF Cache Refresh Requests: %lld%s"
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001091 "RPF Cache Refresh Events: %lld%s"
1092 "RPF Cache Refresh Last: %s%s",
Everton Marques613938d2009-08-13 15:39:31 -03001093 qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
1094 pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
David Lamparter5c697982012-02-16 04:47:56 +01001095 (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
1096 (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001097 refresh_uptime, VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03001098}
1099
Everton Marques871dbcf2009-08-11 15:43:05 -03001100static void pim_show_rpf(struct vty *vty)
1101{
1102 struct listnode *up_node;
1103 struct pim_upstream *up;
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001104 time_t now = pim_time_monotonic_sec();
Everton Marques871dbcf2009-08-11 15:43:05 -03001105
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001106 show_rpf_refresh_stats(vty, now);
Everton Marques613938d2009-08-13 15:39:31 -03001107
1108 vty_out(vty, "%s", VTY_NEWLINE);
1109
Everton Marques871dbcf2009-08-11 15:43:05 -03001110 vty_out(vty,
1111 "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
1112 VTY_NEWLINE);
1113
Everton Marques871dbcf2009-08-11 15:43:05 -03001114 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
1115 char src_str[100];
1116 char grp_str[100];
1117 char rpf_addr_str[100];
1118 char rib_nexthop_str[100];
1119 const char *rpf_ifname;
1120 struct pim_rpf *rpf = &up->rpf;
1121
1122 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1123 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1124 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1125 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
1126
1127 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1128
1129 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
1130 src_str,
1131 grp_str,
1132 rpf_ifname,
1133 rpf_addr_str,
1134 rib_nexthop_str,
1135 rpf->source_nexthop.mrib_route_metric,
1136 rpf->source_nexthop.mrib_metric_preference,
1137 VTY_NEWLINE);
1138 }
1139}
1140
1141static void igmp_show_querier(struct vty *vty)
1142{
1143 struct listnode *node;
1144 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001145
1146 vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
1147
1148 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
1149 struct pim_interface *pim_ifp = ifp->info;
1150 struct listnode *sock_node;
1151 struct igmp_sock *igmp;
1152
1153 if (!pim_ifp)
1154 continue;
1155
1156 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1157 char query_hhmmss[10];
1158 char other_hhmmss[10];
1159
1160 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
1161 pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
1162
Everton Marquese96f0af2009-08-11 15:48:02 -03001163 vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03001164 ifp->name,
1165 inet_ntoa(igmp->ifaddr),
1166 igmp->t_igmp_query_timer ? "THIS" : "OTHER",
1167 igmp->startup_query_count,
1168 query_hhmmss,
1169 other_hhmmss,
1170 VTY_NEWLINE);
1171 }
1172 }
1173}
1174
1175static void igmp_show_groups(struct vty *vty)
1176{
1177 struct listnode *ifnode;
1178 struct interface *ifp;
1179 time_t now;
1180
1181 now = pim_time_monotonic_sec();
1182
1183 vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
1184
1185 /* scan interfaces */
1186 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1187 struct pim_interface *pim_ifp = ifp->info;
1188 struct listnode *sock_node;
1189 struct igmp_sock *igmp;
1190
1191 if (!pim_ifp)
1192 continue;
1193
1194 /* scan igmp sockets */
1195 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1196 char ifaddr_str[100];
1197 struct listnode *grpnode;
1198 struct igmp_group *grp;
1199
1200 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1201
1202 /* scan igmp groups */
1203 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1204 char group_str[100];
1205 char hhmmss[10];
1206 char uptime[10];
1207
1208 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1209 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
1210 pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
1211
1212 vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
1213 ifp->name,
1214 ifaddr_str,
1215 group_str,
1216 grp->group_filtermode_isexcl ? "EXCL" : "INCL",
1217 hhmmss,
1218 grp->group_source_list ? listcount(grp->group_source_list) : 0,
1219 igmp_group_compat_mode(igmp, grp),
1220 uptime,
1221 VTY_NEWLINE);
1222
1223 } /* scan igmp groups */
1224 } /* scan igmp sockets */
1225 } /* scan interfaces */
1226}
1227
1228static void igmp_show_group_retransmission(struct vty *vty)
1229{
1230 struct listnode *ifnode;
1231 struct interface *ifp;
1232 time_t now;
1233
1234 now = pim_time_monotonic_sec();
1235
1236 vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
1237
1238 /* scan interfaces */
1239 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1240 struct pim_interface *pim_ifp = ifp->info;
1241 struct listnode *sock_node;
1242 struct igmp_sock *igmp;
1243
1244 if (!pim_ifp)
1245 continue;
1246
1247 /* scan igmp sockets */
1248 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1249 char ifaddr_str[100];
1250 struct listnode *grpnode;
1251 struct igmp_group *grp;
1252
1253 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1254
1255 /* scan igmp groups */
1256 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1257 char group_str[100];
1258 char grp_retr_mmss[10];
1259 struct listnode *src_node;
1260 struct igmp_source *src;
1261 int grp_retr_sources = 0;
1262
1263 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1264 pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
1265
1266
1267 /* count group sources with retransmission state */
1268 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
1269 if (src->source_query_retransmit_count > 0) {
1270 ++grp_retr_sources;
1271 }
1272 }
1273
1274 vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
1275 ifp->name,
1276 ifaddr_str,
1277 group_str,
1278 grp_retr_mmss,
1279 grp->group_specific_query_retransmit_count,
1280 grp_retr_sources,
1281 VTY_NEWLINE);
1282
1283 } /* scan igmp groups */
1284 } /* scan igmp sockets */
1285 } /* scan interfaces */
1286}
1287
1288static void igmp_show_parameters(struct vty *vty)
1289{
1290 struct listnode *ifnode;
1291 struct interface *ifp;
1292
1293 vty_out(vty,
1294 "QRV: Robustness Variable SQI: Startup Query Interval%s"
1295 "QQI: Query Interval OQPI: Other Querier Present Interval%s"
1296 "QRI: Query Response Interval LMQT: Last Member Query Time%s"
1297 "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
1298 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1299
1300 vty_out(vty,
1301 "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
1302 VTY_NEWLINE);
1303
1304 /* scan interfaces */
1305 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1306 struct pim_interface *pim_ifp = ifp->info;
1307 struct listnode *sock_node;
1308 struct igmp_sock *igmp;
1309
1310 if (!pim_ifp)
1311 continue;
1312
1313 /* scan igmp sockets */
1314 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1315 char ifaddr_str[100];
1316 long gmi_dsec; /* Group Membership Interval */
1317 long oqpi_dsec; /* Other Querier Present Interval */
1318 int sqi;
1319 long lmqt_dsec;
1320 long ohpi_dsec;
1321 long qri_dsec;
1322
1323 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1324
1325 gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
1326 igmp->querier_query_interval,
1327 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1328
1329 sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
1330
1331 oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
1332 igmp->querier_query_interval,
1333 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1334
1335 lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
1336 igmp->querier_robustness_variable) / 100;
1337
1338 ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
1339 igmp->querier_query_interval,
1340 pim_ifp->igmp_query_max_response_time_dsec);
1341
1342 qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
1343
1344 vty_out(vty,
1345 "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
1346 ifp->name,
1347 ifaddr_str,
1348 igmp->querier_robustness_variable,
1349 igmp->querier_query_interval,
1350 qri_dsec / 10, qri_dsec % 10,
1351 gmi_dsec / 10, gmi_dsec % 10,
1352 sqi,
1353 oqpi_dsec / 10, oqpi_dsec % 10,
1354 lmqt_dsec / 10, lmqt_dsec % 10,
1355 ohpi_dsec / 10, ohpi_dsec % 10,
1356 VTY_NEWLINE);
1357
1358 } /* scan igmp sockets */
1359 } /* scan interfaces */
1360}
1361
1362static void igmp_show_sources(struct vty *vty)
1363{
1364 struct listnode *ifnode;
1365 struct interface *ifp;
1366 time_t now;
1367
1368 now = pim_time_monotonic_sec();
1369
1370 vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
1371
1372 /* scan interfaces */
1373 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1374 struct pim_interface *pim_ifp = ifp->info;
1375 struct listnode *sock_node;
1376 struct igmp_sock *igmp;
1377
1378 if (!pim_ifp)
1379 continue;
1380
1381 /* scan igmp sockets */
1382 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1383 char ifaddr_str[100];
1384 struct listnode *grpnode;
1385 struct igmp_group *grp;
1386
1387 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1388
1389 /* scan igmp groups */
1390 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1391 char group_str[100];
1392 struct listnode *srcnode;
1393 struct igmp_source *src;
1394
1395 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1396
1397 /* scan group sources */
1398 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1399 char source_str[100];
1400 char mmss[10];
1401 char uptime[10];
1402
1403 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1404
1405 pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
1406
1407 pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
1408
1409 vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
1410 ifp->name,
1411 ifaddr_str,
1412 group_str,
1413 source_str,
1414 mmss,
1415 IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
1416 uptime,
1417 VTY_NEWLINE);
1418
1419 } /* scan group sources */
1420 } /* scan igmp groups */
1421 } /* scan igmp sockets */
1422 } /* scan interfaces */
1423}
1424
1425static void igmp_show_source_retransmission(struct vty *vty)
1426{
1427 struct listnode *ifnode;
1428 struct interface *ifp;
1429 time_t now;
1430
1431 now = pim_time_monotonic_sec();
1432
1433 vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
1434
1435 /* scan interfaces */
1436 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1437 struct pim_interface *pim_ifp = ifp->info;
1438 struct listnode *sock_node;
1439 struct igmp_sock *igmp;
1440
1441 if (!pim_ifp)
1442 continue;
1443
1444 /* scan igmp sockets */
1445 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1446 char ifaddr_str[100];
1447 struct listnode *grpnode;
1448 struct igmp_group *grp;
1449
1450 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1451
1452 /* scan igmp groups */
1453 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1454 char group_str[100];
1455 struct listnode *srcnode;
1456 struct igmp_source *src;
1457
1458 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1459
1460 /* scan group sources */
1461 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1462 char source_str[100];
1463
1464 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1465
1466 vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
1467 ifp->name,
1468 ifaddr_str,
1469 group_str,
1470 source_str,
1471 src->source_query_retransmit_count,
1472 VTY_NEWLINE);
1473
1474 } /* scan group sources */
1475 } /* scan igmp groups */
1476 } /* scan igmp sockets */
1477 } /* scan interfaces */
1478}
1479
1480static void clear_igmp_interfaces()
1481{
1482 struct listnode *ifnode;
1483 struct listnode *ifnextnode;
1484 struct interface *ifp;
1485
1486 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1487 pim_if_addr_del_all_igmp(ifp);
1488 }
1489
1490 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1491 pim_if_addr_add_all(ifp);
1492 }
1493}
1494
1495static void clear_pim_interfaces()
1496{
1497 struct listnode *ifnode;
1498 struct listnode *ifnextnode;
1499 struct interface *ifp;
1500
1501 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1502 if (ifp->info) {
1503 pim_neighbor_delete_all(ifp, "interface cleared");
1504 }
1505 }
1506}
1507
1508static void clear_interfaces()
1509{
1510 clear_igmp_interfaces();
1511 clear_pim_interfaces();
1512}
1513
1514DEFUN (pim_interface,
1515 pim_interface_cmd,
1516 "interface IFNAME",
1517 "Select an interface to configure\n"
1518 "Interface's name\n")
1519{
1520 struct interface *ifp;
1521 const char *ifname = argv[0];
1522 size_t sl;
1523
1524 sl = strlen(ifname);
1525 if (sl > INTERFACE_NAMSIZ) {
1526 vty_out(vty, "%% Interface name %s is invalid: length exceeds "
1527 "%d characters%s",
1528 ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
1529 return CMD_WARNING;
1530 }
1531
1532 ifp = if_lookup_by_name_len(ifname, sl);
1533 if (!ifp) {
1534 vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
1535
1536 /* Returning here would prevent pimd from booting when there are
1537 interface commands in pimd.conf, since all interfaces are
1538 unknown at pimd boot time (the zebra daemon has not been
1539 contacted for interface discovery). */
1540
1541 ifp = if_get_by_name_len(ifname, sl);
1542 if (!ifp) {
1543 vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546 }
1547
1548 vty->index = ifp;
1549 vty->node = INTERFACE_NODE;
1550
1551 return CMD_SUCCESS;
1552}
1553
1554DEFUN (clear_ip_interfaces,
1555 clear_ip_interfaces_cmd,
1556 "clear ip interfaces",
1557 CLEAR_STR
1558 IP_STR
1559 "Reset interfaces\n")
1560{
1561 clear_interfaces();
1562
1563 return CMD_SUCCESS;
1564}
1565
1566DEFUN (clear_ip_igmp_interfaces,
1567 clear_ip_igmp_interfaces_cmd,
1568 "clear ip igmp interfaces",
1569 CLEAR_STR
1570 IP_STR
1571 CLEAR_IP_IGMP_STR
1572 "Reset IGMP interfaces\n")
1573{
1574 clear_igmp_interfaces();
1575
1576 return CMD_SUCCESS;
1577}
1578
1579DEFUN (clear_ip_pim_interfaces,
1580 clear_ip_pim_interfaces_cmd,
1581 "clear ip pim interfaces",
1582 CLEAR_STR
1583 IP_STR
1584 CLEAR_IP_PIM_STR
1585 "Reset PIM interfaces\n")
1586{
1587 clear_pim_interfaces();
1588
1589 return CMD_SUCCESS;
1590}
1591
1592DEFUN (show_ip_igmp_interface,
1593 show_ip_igmp_interface_cmd,
1594 "show ip igmp interface",
1595 SHOW_STR
1596 IP_STR
1597 IGMP_STR
1598 "IGMP interface information\n")
1599{
1600 igmp_show_interfaces(vty);
1601
1602 return CMD_SUCCESS;
1603}
1604
Everton Marques567f9272010-02-19 19:07:00 -02001605DEFUN (show_ip_igmp_join,
1606 show_ip_igmp_join_cmd,
1607 "show ip igmp join",
1608 SHOW_STR
1609 IP_STR
1610 IGMP_STR
1611 "IGMP static join information\n")
1612{
1613 igmp_show_interface_join(vty);
1614
1615 return CMD_SUCCESS;
1616}
1617
Everton Marques871dbcf2009-08-11 15:43:05 -03001618DEFUN (show_ip_igmp_groups,
1619 show_ip_igmp_groups_cmd,
1620 "show ip igmp groups",
1621 SHOW_STR
1622 IP_STR
1623 IGMP_STR
1624 IGMP_GROUP_STR)
1625{
1626 igmp_show_groups(vty);
1627
1628 return CMD_SUCCESS;
1629}
1630
1631DEFUN (show_ip_igmp_groups_retransmissions,
1632 show_ip_igmp_groups_retransmissions_cmd,
1633 "show ip igmp groups retransmissions",
1634 SHOW_STR
1635 IP_STR
1636 IGMP_STR
1637 IGMP_GROUP_STR
1638 "IGMP group retransmissions\n")
1639{
1640 igmp_show_group_retransmission(vty);
1641
1642 return CMD_SUCCESS;
1643}
1644
1645DEFUN (show_ip_igmp_parameters,
1646 show_ip_igmp_parameters_cmd,
1647 "show ip igmp parameters",
1648 SHOW_STR
1649 IP_STR
1650 IGMP_STR
1651 "IGMP parameters information\n")
1652{
1653 igmp_show_parameters(vty);
1654
1655 return CMD_SUCCESS;
1656}
1657
1658DEFUN (show_ip_igmp_sources,
1659 show_ip_igmp_sources_cmd,
1660 "show ip igmp sources",
1661 SHOW_STR
1662 IP_STR
1663 IGMP_STR
1664 IGMP_SOURCE_STR)
1665{
1666 igmp_show_sources(vty);
1667
1668 return CMD_SUCCESS;
1669}
1670
1671DEFUN (show_ip_igmp_sources_retransmissions,
1672 show_ip_igmp_sources_retransmissions_cmd,
1673 "show ip igmp sources retransmissions",
1674 SHOW_STR
1675 IP_STR
1676 IGMP_STR
1677 IGMP_SOURCE_STR
1678 "IGMP source retransmissions\n")
1679{
1680 igmp_show_source_retransmission(vty);
1681
1682 return CMD_SUCCESS;
1683}
1684
1685DEFUN (show_ip_igmp_querier,
1686 show_ip_igmp_querier_cmd,
1687 "show ip igmp querier",
1688 SHOW_STR
1689 IP_STR
1690 IGMP_STR
1691 "IGMP querier information\n")
1692{
1693 igmp_show_querier(vty);
1694
1695 return CMD_SUCCESS;
1696}
1697
1698DEFUN (show_ip_pim_address,
1699 show_ip_pim_address_cmd,
1700 "show ip pim address",
1701 SHOW_STR
1702 IP_STR
1703 PIM_STR
1704 "PIM interface address\n")
1705{
1706 show_interface_address(vty);
1707
1708 return CMD_SUCCESS;
1709}
1710
1711DEFUN (show_ip_pim_assert,
1712 show_ip_pim_assert_cmd,
1713 "show ip pim assert",
1714 SHOW_STR
1715 IP_STR
1716 PIM_STR
1717 "PIM interface assert\n")
1718{
1719 pim_show_assert(vty);
1720
1721 return CMD_SUCCESS;
1722}
1723
1724DEFUN (show_ip_pim_assert_internal,
1725 show_ip_pim_assert_internal_cmd,
1726 "show ip pim assert-internal",
1727 SHOW_STR
1728 IP_STR
1729 PIM_STR
1730 "PIM interface internal assert state\n")
1731{
1732 pim_show_assert_internal(vty);
1733
1734 return CMD_SUCCESS;
1735}
1736
1737DEFUN (show_ip_pim_assert_metric,
1738 show_ip_pim_assert_metric_cmd,
1739 "show ip pim assert-metric",
1740 SHOW_STR
1741 IP_STR
1742 PIM_STR
1743 "PIM interface assert metric\n")
1744{
1745 pim_show_assert_metric(vty);
1746
1747 return CMD_SUCCESS;
1748}
1749
1750DEFUN (show_ip_pim_assert_winner_metric,
1751 show_ip_pim_assert_winner_metric_cmd,
1752 "show ip pim assert-winner-metric",
1753 SHOW_STR
1754 IP_STR
1755 PIM_STR
1756 "PIM interface assert winner metric\n")
1757{
1758 pim_show_assert_winner_metric(vty);
1759
1760 return CMD_SUCCESS;
1761}
1762
1763DEFUN (show_ip_pim_dr,
1764 show_ip_pim_dr_cmd,
1765 "show ip pim designated-router",
1766 SHOW_STR
1767 IP_STR
1768 PIM_STR
1769 "PIM interface designated router\n")
1770{
1771 pim_show_dr(vty);
1772
1773 return CMD_SUCCESS;
1774}
1775
1776DEFUN (show_ip_pim_hello,
1777 show_ip_pim_hello_cmd,
1778 "show ip pim hello",
1779 SHOW_STR
1780 IP_STR
1781 PIM_STR
1782 "PIM interface hello information\n")
1783{
1784 pim_show_hello(vty);
1785
1786 return CMD_SUCCESS;
1787}
1788
1789DEFUN (show_ip_pim_interface,
1790 show_ip_pim_interface_cmd,
1791 "show ip pim interface",
1792 SHOW_STR
1793 IP_STR
1794 PIM_STR
1795 "PIM interface information\n")
1796{
1797 pim_show_interfaces(vty);
1798
1799 return CMD_SUCCESS;
1800}
1801
1802DEFUN (show_ip_pim_join,
1803 show_ip_pim_join_cmd,
1804 "show ip pim join",
1805 SHOW_STR
1806 IP_STR
1807 PIM_STR
1808 "PIM interface join information\n")
1809{
1810 pim_show_join(vty);
1811
1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN (show_ip_pim_lan_prune_delay,
1816 show_ip_pim_lan_prune_delay_cmd,
1817 "show ip pim lan-prune-delay",
1818 SHOW_STR
1819 IP_STR
1820 PIM_STR
1821 "PIM neighbors LAN prune delay parameters\n")
1822{
1823 pim_show_lan_prune_delay(vty);
1824
1825 return CMD_SUCCESS;
1826}
1827
1828DEFUN (show_ip_pim_local_membership,
1829 show_ip_pim_local_membership_cmd,
1830 "show ip pim local-membership",
1831 SHOW_STR
1832 IP_STR
1833 PIM_STR
1834 "PIM interface local-membership\n")
1835{
1836 pim_show_membership(vty);
1837
1838 return CMD_SUCCESS;
1839}
1840
1841DEFUN (show_ip_pim_jp_override_interval,
1842 show_ip_pim_jp_override_interval_cmd,
1843 "show ip pim jp-override-interval",
1844 SHOW_STR
1845 IP_STR
1846 PIM_STR
1847 "PIM interface J/P override interval\n")
1848{
1849 pim_show_jp_override_interval(vty);
1850
1851 return CMD_SUCCESS;
1852}
1853
1854DEFUN (show_ip_pim_neighbor,
1855 show_ip_pim_neighbor_cmd,
1856 "show ip pim neighbor",
1857 SHOW_STR
1858 IP_STR
1859 PIM_STR
1860 "PIM neighbor information\n")
1861{
1862 pim_show_neighbors(vty);
1863
1864 return CMD_SUCCESS;
1865}
1866
1867DEFUN (show_ip_pim_secondary,
1868 show_ip_pim_secondary_cmd,
1869 "show ip pim secondary",
1870 SHOW_STR
1871 IP_STR
1872 PIM_STR
1873 "PIM neighbor addresses\n")
1874{
1875 pim_show_neighbors_secondary(vty);
1876
1877 return CMD_SUCCESS;
1878}
1879
1880DEFUN (show_ip_pim_upstream,
1881 show_ip_pim_upstream_cmd,
1882 "show ip pim upstream",
1883 SHOW_STR
1884 IP_STR
1885 PIM_STR
1886 "PIM upstream information\n")
1887{
1888 pim_show_upstream(vty);
1889
1890 return CMD_SUCCESS;
1891}
1892
1893DEFUN (show_ip_pim_upstream_join_desired,
1894 show_ip_pim_upstream_join_desired_cmd,
1895 "show ip pim upstream-join-desired",
1896 SHOW_STR
1897 IP_STR
1898 PIM_STR
1899 "PIM upstream join-desired\n")
1900{
1901 pim_show_join_desired(vty);
1902
1903 return CMD_SUCCESS;
1904}
1905
1906DEFUN (show_ip_pim_upstream_rpf,
1907 show_ip_pim_upstream_rpf_cmd,
1908 "show ip pim upstream-rpf",
1909 SHOW_STR
1910 IP_STR
1911 PIM_STR
1912 "PIM upstream source rpf\n")
1913{
1914 pim_show_upstream_rpf(vty);
1915
1916 return CMD_SUCCESS;
1917}
1918
1919DEFUN (show_ip_pim_rpf,
1920 show_ip_pim_rpf_cmd,
1921 "show ip pim rpf",
1922 SHOW_STR
1923 IP_STR
1924 PIM_STR
1925 "PIM cached source rpf information\n")
1926{
1927 pim_show_rpf(vty);
1928
1929 return CMD_SUCCESS;
1930}
1931
1932static void show_multicast_interfaces(struct vty *vty)
1933{
1934 struct listnode *node;
1935 struct interface *ifp;
1936
1937 vty_out(vty, "%s", VTY_NEWLINE);
1938
Everton Marques613938d2009-08-13 15:39:31 -03001939 vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03001940 VTY_NEWLINE);
1941
1942 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
1943 struct pim_interface *pim_ifp;
1944 struct in_addr ifaddr;
1945 struct sioc_vif_req vreq;
1946
1947 pim_ifp = ifp->info;
1948
1949 if (!pim_ifp)
1950 continue;
1951
1952 memset(&vreq, 0, sizeof(vreq));
1953 vreq.vifi = pim_ifp->mroute_vif_index;
1954
1955 if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
1956 int e = errno;
1957 vty_out(vty,
1958 "ioctl(SIOCGETVIFCNT=%d) failure for interface %s vif_index=%d: errno=%d: %s%s",
1959 SIOCGETVIFCNT,
1960 ifp->name,
1961 pim_ifp->mroute_vif_index,
1962 e,
Everton Marquese96f0af2009-08-11 15:48:02 -03001963 safe_strerror(e),
Everton Marques871dbcf2009-08-11 15:43:05 -03001964 VTY_NEWLINE);
1965 continue;
1966 }
1967
1968 ifaddr = pim_ifp->primary_address;
1969
Everton Marques613938d2009-08-13 15:39:31 -03001970 vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03001971 ifp->name,
1972 inet_ntoa(ifaddr),
1973 ifp->ifindex,
1974 pim_ifp->mroute_vif_index,
1975 vreq.icount,
1976 vreq.ocount,
1977 vreq.ibytes,
1978 vreq.obytes,
1979 VTY_NEWLINE);
1980 }
1981}
1982
1983DEFUN (show_ip_multicast,
1984 show_ip_multicast_cmd,
1985 "show ip multicast",
1986 SHOW_STR
1987 IP_STR
1988 "Multicast global information\n")
1989{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001990 time_t now = pim_time_monotonic_sec();
1991
Everton Marques871dbcf2009-08-11 15:43:05 -03001992 if (PIM_MROUTE_IS_ENABLED) {
Everton Marques871dbcf2009-08-11 15:43:05 -03001993 char uptime[10];
1994
1995 vty_out(vty, "Mroute socket descriptor: %d%s",
1996 qpim_mroute_socket_fd,
1997 VTY_NEWLINE);
1998
Everton Marques871dbcf2009-08-11 15:43:05 -03001999 pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
2000 vty_out(vty, "Mroute socket uptime: %s%s",
2001 uptime,
2002 VTY_NEWLINE);
2003 }
2004 else {
2005 vty_out(vty, "Multicast disabled%s",
2006 VTY_NEWLINE);
2007 }
2008
2009 vty_out(vty, "%s", VTY_NEWLINE);
2010 vty_out(vty, "Current highest VifIndex: %d%s",
2011 qpim_mroute_oif_highest_vif_index,
2012 VTY_NEWLINE);
2013 vty_out(vty, "Maximum highest VifIndex: %d%s",
2014 MAXVIFS - 1,
2015 VTY_NEWLINE);
2016
2017 vty_out(vty, "%s", VTY_NEWLINE);
2018 vty_out(vty, "Upstream Join Timer: %d secs%s",
2019 qpim_t_periodic,
2020 VTY_NEWLINE);
2021 vty_out(vty, "Join/Prune Holdtime: %d secs%s",
2022 PIM_JP_HOLDTIME,
2023 VTY_NEWLINE);
2024
2025 vty_out(vty, "%s", VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03002026
Everton Marquesbcc4abe2009-08-17 18:18:59 -03002027 show_rpf_refresh_stats(vty, now);
Everton Marques871dbcf2009-08-11 15:43:05 -03002028
2029 show_multicast_interfaces(vty);
2030
2031 return CMD_SUCCESS;
2032}
2033
2034static void show_mroute(struct vty *vty)
2035{
2036 struct listnode *node;
2037 struct channel_oil *c_oil;
2038 time_t now;
2039
2040 vty_out(vty, "Proto: I=IGMP P=PIM%s%s", VTY_NEWLINE, VTY_NEWLINE);
2041
2042 vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
2043 VTY_NEWLINE);
2044
2045 now = pim_time_monotonic_sec();
2046
2047 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2048 char group_str[100];
2049 char source_str[100];
2050 int oif_vif_index;
2051
2052 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2053 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2054
2055 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2056 struct interface *ifp_in;
2057 struct interface *ifp_out;
2058 char oif_uptime[10];
2059 int ttl;
2060 char proto[5];
2061
2062 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
2063 if (ttl < 1)
2064 continue;
2065
2066 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
2067 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2068
2069 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
2070
2071 proto[0] = '\0';
2072 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
2073 strcat(proto, "P");
2074 }
2075 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
2076 strcat(proto, "I");
2077 }
2078
2079 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2080 source_str,
2081 group_str,
2082 proto,
2083 ifp_in ? ifp_in->name : "<iif?>",
2084 c_oil->oil.mfcc_parent,
2085 ifp_out ? ifp_out->name : "<oif?>",
2086 oif_vif_index,
2087 ttl,
2088 oif_uptime,
2089 VTY_NEWLINE);
2090 }
2091 }
2092}
2093
2094DEFUN (show_ip_mroute,
2095 show_ip_mroute_cmd,
2096 "show ip mroute",
2097 SHOW_STR
2098 IP_STR
2099 MROUTE_STR)
2100{
2101 show_mroute(vty);
2102 return CMD_SUCCESS;
2103}
2104
2105static void show_mroute_count(struct vty *vty)
2106{
2107 struct listnode *node;
2108 struct channel_oil *c_oil;
2109
2110 vty_out(vty, "%s", VTY_NEWLINE);
2111
2112 vty_out(vty, "Source Group Packets Bytes WrongIf %s",
2113 VTY_NEWLINE);
2114
2115 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2116 char group_str[100];
2117 char source_str[100];
2118 struct sioc_sg_req sgreq;
2119
2120 memset(&sgreq, 0, sizeof(sgreq));
2121 sgreq.src = c_oil->oil.mfcc_origin;
2122 sgreq.grp = c_oil->oil.mfcc_mcastgrp;
2123
2124 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2125 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2126
2127 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2128 int e = errno;
2129 vty_out(vty,
2130 "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2131 SIOCGETSGCNT,
2132 source_str,
2133 group_str,
2134 e,
Everton Marquese96f0af2009-08-11 15:48:02 -03002135 safe_strerror(e),
Everton Marques871dbcf2009-08-11 15:43:05 -03002136 VTY_NEWLINE);
2137 continue;
2138 }
2139
2140 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2141 source_str,
2142 group_str,
2143 sgreq.pktcnt,
2144 sgreq.bytecnt,
2145 sgreq.wrong_if,
2146 VTY_NEWLINE);
2147
2148 }
2149}
2150
2151DEFUN (show_ip_mroute_count,
2152 show_ip_mroute_count_cmd,
2153 "show ip mroute count",
2154 SHOW_STR
2155 IP_STR
2156 MROUTE_STR
2157 "Route and packet count data\n")
2158{
2159 show_mroute_count(vty);
2160 return CMD_SUCCESS;
2161}
2162
Everton Marques05e573d2010-04-20 12:20:46 -03002163DEFUN (show_ip_rib,
2164 show_ip_rib_cmd,
2165 "show ip rib A.B.C.D",
Everton Marques871dbcf2009-08-11 15:43:05 -03002166 SHOW_STR
2167 IP_STR
Everton Marques05e573d2010-04-20 12:20:46 -03002168 RIB_STR
Everton Marques871dbcf2009-08-11 15:43:05 -03002169 "Unicast address\n")
2170{
2171 struct in_addr addr;
2172 const char *addr_str;
2173 struct pim_nexthop nexthop;
2174 char nexthop_addr_str[100];
2175 int result;
2176
2177 addr_str = argv[0];
2178 result = inet_pton(AF_INET, addr_str, &addr);
2179 if (result <= 0) {
2180 vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002181 addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002182 return CMD_WARNING;
2183 }
2184
2185 if (pim_nexthop_lookup(&nexthop, addr)) {
2186 vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
2187 addr_str, VTY_NEWLINE);
2188 return CMD_WARNING;
2189 }
2190
2191 vty_out(vty, "Address NextHop Interface Metric Preference%s",
2192 VTY_NEWLINE);
2193
2194 pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
2195 nexthop_addr_str, sizeof(nexthop_addr_str));
2196
2197 vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
2198 addr_str,
2199 nexthop_addr_str,
2200 nexthop.interface ? nexthop.interface->name : "<ifname?>",
2201 nexthop.mrib_route_metric,
2202 nexthop.mrib_metric_preference,
2203 VTY_NEWLINE);
2204
2205 return CMD_SUCCESS;
2206}
2207
Everton Marques824adbe2009-10-08 09:16:27 -03002208static void show_ssmpingd(struct vty *vty)
2209{
2210 struct listnode *node;
2211 struct ssmpingd_sock *ss;
2212 time_t now;
2213
Everton Marquese8c11bb2009-10-08 15:06:32 -03002214 vty_out(vty, "Source Socket Address Port Uptime Requests%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002215 VTY_NEWLINE);
2216
2217 if (!qpim_ssmpingd_list)
2218 return;
2219
2220 now = pim_time_monotonic_sec();
2221
2222 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
2223 char source_str[100];
2224 char ss_uptime[10];
Everton Marquese8c11bb2009-10-08 15:06:32 -03002225 struct sockaddr_in bind_addr;
David Lampartere269b962012-02-16 04:32:08 +00002226 socklen_t len = sizeof(bind_addr);
Everton Marquese8c11bb2009-10-08 15:06:32 -03002227 char bind_addr_str[100];
Everton Marques824adbe2009-10-08 09:16:27 -03002228
2229 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
Everton Marquese8c11bb2009-10-08 15:06:32 -03002230
2231 if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
2232 vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
2233 source_str, ss->sock_fd, VTY_NEWLINE);
2234 }
2235
2236 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
Everton Marques824adbe2009-10-08 09:16:27 -03002237 pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
2238
Everton Marquese8c11bb2009-10-08 15:06:32 -03002239 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002240 source_str,
2241 ss->sock_fd,
Everton Marquese8c11bb2009-10-08 15:06:32 -03002242 bind_addr_str,
2243 ntohs(bind_addr.sin_port),
Everton Marques824adbe2009-10-08 09:16:27 -03002244 ss_uptime,
David Lamparter5c697982012-02-16 04:47:56 +01002245 (long long)ss->requests,
Everton Marques824adbe2009-10-08 09:16:27 -03002246 VTY_NEWLINE);
2247 }
2248}
2249
2250DEFUN (show_ip_ssmpingd,
2251 show_ip_ssmpingd_cmd,
2252 "show ip ssmpingd",
2253 SHOW_STR
2254 IP_STR
2255 SHOW_SSMPINGD_STR)
2256{
2257 show_ssmpingd(vty);
2258 return CMD_SUCCESS;
2259}
2260
Everton Marques871dbcf2009-08-11 15:43:05 -03002261static void mroute_add_all()
2262{
2263 struct listnode *node;
2264 struct channel_oil *c_oil;
2265
2266 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2267 if (pim_mroute_add(&c_oil->oil)) {
2268 /* just log warning */
2269 char source_str[100];
2270 char group_str[100];
2271 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2272 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2273 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
2274 __FILE__, __PRETTY_FUNCTION__,
2275 source_str, group_str);
2276 }
2277 }
2278}
2279
2280static void mroute_del_all()
2281{
2282 struct listnode *node;
2283 struct channel_oil *c_oil;
2284
2285 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2286 if (pim_mroute_del(&c_oil->oil)) {
2287 /* just log warning */
2288 char source_str[100];
2289 char group_str[100];
2290 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2291 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2292 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
2293 __FILE__, __PRETTY_FUNCTION__,
2294 source_str, group_str);
2295 }
2296 }
2297}
2298
2299DEFUN (ip_multicast_routing,
2300 ip_multicast_routing_cmd,
2301 PIM_CMD_IP_MULTICAST_ROUTING,
2302 IP_STR
2303 "Enable IP multicast forwarding\n")
2304{
2305 pim_mroute_socket_enable();
2306 pim_if_add_vif_all();
2307 mroute_add_all();
2308 return CMD_SUCCESS;
2309}
2310
2311DEFUN (no_ip_multicast_routing,
2312 no_ip_multicast_routing_cmd,
2313 PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
2314 NO_STR
2315 IP_STR
2316 "Global IP configuration subcommands\n"
2317 "Enable IP multicast forwarding\n")
2318{
2319 mroute_del_all();
2320 pim_if_del_vif_all();
2321 pim_mroute_socket_disable();
2322 return CMD_SUCCESS;
2323}
2324
Everton Marques96f91ae2009-10-07 18:41:45 -03002325DEFUN (ip_ssmpingd,
2326 ip_ssmpingd_cmd,
2327 "ip ssmpingd [A.B.C.D]",
2328 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002329 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002330 "Source address\n")
2331{
2332 int result;
2333 struct in_addr source_addr;
2334 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2335
2336 result = inet_pton(AF_INET, source_str, &source_addr);
2337 if (result <= 0) {
2338 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2339 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2340 return CMD_WARNING;
2341 }
2342
2343 result = pim_ssmpingd_start(source_addr);
2344 if (result) {
2345 vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
2346 source_str, result, VTY_NEWLINE);
2347 return CMD_WARNING;
2348 }
2349
2350 return CMD_SUCCESS;
2351}
2352
2353DEFUN (no_ip_ssmpingd,
2354 no_ip_ssmpingd_cmd,
2355 "no ip ssmpingd [A.B.C.D]",
2356 NO_STR
2357 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002358 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002359 "Source address\n")
2360{
2361 int result;
2362 struct in_addr source_addr;
2363 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2364
2365 result = inet_pton(AF_INET, source_str, &source_addr);
2366 if (result <= 0) {
2367 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2368 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2369 return CMD_WARNING;
2370 }
2371
2372 result = pim_ssmpingd_stop(source_addr);
2373 if (result) {
2374 vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
2375 source_str, result, VTY_NEWLINE);
2376 return CMD_WARNING;
2377 }
2378
2379 return CMD_SUCCESS;
2380}
2381
Everton Marques871dbcf2009-08-11 15:43:05 -03002382DEFUN (interface_ip_igmp,
2383 interface_ip_igmp_cmd,
2384 "ip igmp",
2385 IP_STR
2386 IFACE_IGMP_STR)
2387{
2388 struct interface *ifp;
2389 struct pim_interface *pim_ifp;
2390
2391 ifp = vty->index;
2392 pim_ifp = ifp->info;
2393
2394 if (!pim_ifp) {
2395 pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
2396 if (!pim_ifp) {
2397 vty_out(vty, "Could not enable IGMP on interface %s%s",
2398 ifp->name, VTY_NEWLINE);
2399 return CMD_WARNING;
2400 }
2401 }
2402 else {
2403 PIM_IF_DO_IGMP(pim_ifp->options);
2404 }
2405
2406 pim_if_addr_add_all(ifp);
2407 pim_if_membership_refresh(ifp);
2408
2409 return CMD_SUCCESS;
2410}
2411
2412DEFUN (interface_no_ip_igmp,
2413 interface_no_ip_igmp_cmd,
2414 "no ip igmp",
2415 NO_STR
2416 IP_STR
2417 IFACE_IGMP_STR)
2418{
2419 struct interface *ifp;
2420 struct pim_interface *pim_ifp;
2421
2422 ifp = vty->index;
2423 pim_ifp = ifp->info;
2424 if (!pim_ifp)
2425 return CMD_SUCCESS;
2426
2427 PIM_IF_DONT_IGMP(pim_ifp->options);
2428
2429 pim_if_membership_clear(ifp);
2430
2431 pim_if_addr_del_all(ifp);
2432
2433 if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
2434 pim_if_delete(ifp);
2435 }
2436
2437 return CMD_SUCCESS;
2438}
2439
2440DEFUN (interface_ip_igmp_join,
2441 interface_ip_igmp_join_cmd,
2442 "ip igmp join A.B.C.D A.B.C.D",
2443 IP_STR
2444 IFACE_IGMP_STR
2445 "IGMP join multicast group\n"
2446 "Multicast group address\n"
2447 "Source address\n")
2448{
2449 struct interface *ifp;
2450 const char *group_str;
2451 const char *source_str;
2452 struct in_addr group_addr;
2453 struct in_addr source_addr;
2454 int result;
2455
2456 ifp = vty->index;
2457
2458 /* Group address */
2459 group_str = argv[0];
2460 result = inet_pton(AF_INET, group_str, &group_addr);
2461 if (result <= 0) {
2462 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002463 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002464 return CMD_WARNING;
2465 }
2466
2467 /* Source address */
2468 source_str = argv[1];
2469 result = inet_pton(AF_INET, source_str, &source_addr);
2470 if (result <= 0) {
2471 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002472 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002473 return CMD_WARNING;
2474 }
2475
2476 result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
2477 if (result) {
2478 vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
2479 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2480 return CMD_WARNING;
2481 }
2482
2483 return CMD_SUCCESS;
2484}
2485
2486DEFUN (interface_no_ip_igmp_join,
2487 interface_no_ip_igmp_join_cmd,
2488 "no ip igmp join A.B.C.D A.B.C.D",
2489 NO_STR
2490 IP_STR
2491 IFACE_IGMP_STR
2492 "IGMP join multicast group\n"
2493 "Multicast group address\n"
2494 "Source address\n")
2495{
2496 struct interface *ifp;
2497 const char *group_str;
2498 const char *source_str;
2499 struct in_addr group_addr;
2500 struct in_addr source_addr;
2501 int result;
2502
2503 ifp = vty->index;
2504
2505 /* Group address */
2506 group_str = argv[0];
2507 result = inet_pton(AF_INET, group_str, &group_addr);
2508 if (result <= 0) {
2509 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002510 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002511 return CMD_WARNING;
2512 }
2513
2514 /* Source address */
2515 source_str = argv[1];
2516 result = inet_pton(AF_INET, source_str, &source_addr);
2517 if (result <= 0) {
2518 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002519 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002520 return CMD_WARNING;
2521 }
2522
2523 result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
2524 if (result) {
2525 vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
2526 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2527 return CMD_WARNING;
2528 }
2529
2530 return CMD_SUCCESS;
2531}
2532
2533/*
2534 CLI reconfiguration affects the interface level (struct pim_interface).
2535 This function propagates the reconfiguration to every active socket
2536 for that interface.
2537 */
2538static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
2539{
2540 struct interface *ifp;
2541 struct pim_interface *pim_ifp;
2542
2543 zassert(igmp);
2544
2545 /* other querier present? */
2546
2547 if (igmp->t_other_querier_timer)
2548 return;
2549
2550 /* this is the querier */
2551
2552 zassert(igmp->interface);
2553 zassert(igmp->interface->info);
2554
2555 ifp = igmp->interface;
2556 pim_ifp = ifp->info;
2557
2558 if (PIM_DEBUG_IGMP_TRACE) {
2559 char ifaddr_str[100];
2560 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2561 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
2562 __PRETTY_FUNCTION__,
2563 ifaddr_str,
2564 ifp->name,
2565 pim_ifp->igmp_default_query_interval);
2566 }
2567
2568 /*
2569 igmp_startup_mode_on() will reset QQI:
2570
2571 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
2572 */
2573 igmp_startup_mode_on(igmp);
2574}
2575
2576static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
2577{
2578 if (igmp->t_igmp_query_timer) {
2579 /* other querier present */
2580 zassert(igmp->t_igmp_query_timer);
2581 zassert(!igmp->t_other_querier_timer);
2582
2583 pim_igmp_general_query_off(igmp);
2584 pim_igmp_general_query_on(igmp);
2585
2586 zassert(igmp->t_igmp_query_timer);
2587 zassert(!igmp->t_other_querier_timer);
2588 }
2589 else {
2590 /* this is the querier */
2591
2592 zassert(!igmp->t_igmp_query_timer);
2593 zassert(igmp->t_other_querier_timer);
2594
2595 pim_igmp_other_querier_timer_off(igmp);
2596 pim_igmp_other_querier_timer_on(igmp);
2597
2598 zassert(!igmp->t_igmp_query_timer);
2599 zassert(igmp->t_other_querier_timer);
2600 }
2601}
2602
2603static void change_query_interval(struct pim_interface *pim_ifp,
2604 int query_interval)
2605{
2606 struct listnode *sock_node;
2607 struct igmp_sock *igmp;
2608
2609 pim_ifp->igmp_default_query_interval = query_interval;
2610
2611 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2612 igmp_sock_query_interval_reconfig(igmp);
2613 igmp_sock_query_reschedule(igmp);
2614 }
2615}
2616
2617static void change_query_max_response_time(struct pim_interface *pim_ifp,
2618 int query_max_response_time_dsec)
2619{
2620 struct listnode *sock_node;
2621 struct igmp_sock *igmp;
2622
2623 pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
2624
2625 /*
2626 Below we modify socket/group/source timers in order to quickly
2627 reflect the change. Otherwise, those timers would eventually catch
2628 up.
2629 */
2630
2631 /* scan all sockets */
2632 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2633 struct listnode *grp_node;
2634 struct igmp_group *grp;
2635
2636 /* reschedule socket general query */
2637 igmp_sock_query_reschedule(igmp);
2638
2639 /* scan socket groups */
2640 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
2641 struct listnode *src_node;
2642 struct igmp_source *src;
2643
2644 /* reset group timers for groups in EXCLUDE mode */
2645 if (grp->group_filtermode_isexcl) {
2646 igmp_group_reset_gmi(grp);
2647 }
2648
2649 /* scan group sources */
2650 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
2651
2652 /* reset source timers for sources with running timers */
2653 if (src->t_source_timer) {
2654 igmp_source_reset_gmi(igmp, grp, src);
2655 }
2656 }
2657 }
2658 }
2659}
2660
2661#define IGMP_QUERY_INTERVAL_MIN (1)
2662#define IGMP_QUERY_INTERVAL_MAX (1800)
2663
2664DEFUN (interface_ip_igmp_query_interval,
2665 interface_ip_igmp_query_interval_cmd,
2666 PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
2667 IP_STR
2668 IFACE_IGMP_STR
2669 IFACE_IGMP_QUERY_INTERVAL_STR
2670 "Query interval in seconds\n")
2671{
2672 struct interface *ifp;
2673 struct pim_interface *pim_ifp;
2674 int query_interval;
2675 int query_interval_dsec;
2676
2677 ifp = vty->index;
2678 pim_ifp = ifp->info;
2679
2680 if (!pim_ifp) {
2681 vty_out(vty,
2682 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2683 ifp->name,
2684 VTY_NEWLINE);
2685 return CMD_WARNING;
2686 }
2687
2688 query_interval = atoi(argv[0]);
2689 query_interval_dsec = 10 * query_interval;
2690
2691 /*
2692 It seems we don't need to check bounds since command.c does it
2693 already, but we verify them anyway for extra safety.
2694 */
2695 if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
2696 vty_out(vty, "General query interval %d lower than minimum %d%s",
2697 query_interval,
2698 IGMP_QUERY_INTERVAL_MIN,
2699 VTY_NEWLINE);
2700 return CMD_WARNING;
2701 }
2702 if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
2703 vty_out(vty, "General query interval %d higher than maximum %d%s",
2704 query_interval,
2705 IGMP_QUERY_INTERVAL_MAX,
2706 VTY_NEWLINE);
2707 return CMD_WARNING;
2708 }
2709
2710 if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2711 vty_out(vty,
2712 "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
2713 query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2714 VTY_NEWLINE);
2715 return CMD_WARNING;
2716 }
2717
2718 change_query_interval(pim_ifp, query_interval);
2719
2720 return CMD_SUCCESS;
2721}
2722
2723DEFUN (interface_no_ip_igmp_query_interval,
2724 interface_no_ip_igmp_query_interval_cmd,
2725 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
2726 NO_STR
2727 IP_STR
2728 IFACE_IGMP_STR
2729 IFACE_IGMP_QUERY_INTERVAL_STR)
2730{
2731 struct interface *ifp;
2732 struct pim_interface *pim_ifp;
2733 int default_query_interval_dsec;
2734
2735 ifp = vty->index;
2736 pim_ifp = ifp->info;
2737
2738 if (!pim_ifp)
2739 return CMD_SUCCESS;
2740
2741 default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
2742
2743 if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2744 vty_out(vty,
2745 "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
2746 default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2747 VTY_NEWLINE);
2748 return CMD_WARNING;
2749 }
2750
2751 change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
2752
2753 return CMD_SUCCESS;
2754}
2755
2756#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
2757#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
2758
2759DEFUN (interface_ip_igmp_query_max_response_time,
2760 interface_ip_igmp_query_max_response_time_cmd,
2761 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
2762 IP_STR
2763 IFACE_IGMP_STR
2764 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
2765 "Query response value in seconds\n")
2766{
2767 struct interface *ifp;
2768 struct pim_interface *pim_ifp;
2769 int query_max_response_time;
2770
2771 ifp = vty->index;
2772 pim_ifp = ifp->info;
2773
2774 if (!pim_ifp) {
2775 vty_out(vty,
2776 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2777 ifp->name,
2778 VTY_NEWLINE);
2779 return CMD_WARNING;
2780 }
2781
2782 query_max_response_time = atoi(argv[0]);
2783
2784 /*
2785 It seems we don't need to check bounds since command.c does it
2786 already, but we verify them anyway for extra safety.
2787 */
2788 if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
2789 vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
2790 query_max_response_time,
2791 IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
2792 VTY_NEWLINE);
2793 return CMD_WARNING;
2794 }
2795 if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
2796 vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
2797 query_max_response_time,
2798 IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
2799 VTY_NEWLINE);
2800 return CMD_WARNING;
2801 }
2802
2803 if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
2804 vty_out(vty,
2805 "Can't set query max response time %d sec >= general query interval %d sec%s",
2806 query_max_response_time, pim_ifp->igmp_default_query_interval,
2807 VTY_NEWLINE);
2808 return CMD_WARNING;
2809 }
2810
2811 change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
2812
2813 return CMD_SUCCESS;
2814}
2815
2816DEFUN (interface_no_ip_igmp_query_max_response_time,
2817 interface_no_ip_igmp_query_max_response_time_cmd,
2818 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
2819 NO_STR
2820 IP_STR
2821 IFACE_IGMP_STR
2822 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
2823{
2824 struct interface *ifp;
2825 struct pim_interface *pim_ifp;
2826 int default_query_interval_dsec;
2827
2828 ifp = vty->index;
2829 pim_ifp = ifp->info;
2830
2831 if (!pim_ifp)
2832 return CMD_SUCCESS;
2833
2834 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2835
2836 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
2837 vty_out(vty,
2838 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
2839 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
2840 VTY_NEWLINE);
2841 return CMD_WARNING;
2842 }
2843
2844 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
2845
2846 return CMD_SUCCESS;
2847}
2848
2849#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
2850#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
2851
2852DEFUN (interface_ip_igmp_query_max_response_time_dsec,
2853 interface_ip_igmp_query_max_response_time_dsec_cmd,
2854 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
2855 IP_STR
2856 IFACE_IGMP_STR
2857 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
2858 "Query response value in deciseconds\n")
2859{
2860 struct interface *ifp;
2861 struct pim_interface *pim_ifp;
2862 int query_max_response_time_dsec;
2863 int default_query_interval_dsec;
2864
2865 ifp = vty->index;
2866 pim_ifp = ifp->info;
2867
2868 if (!pim_ifp) {
2869 vty_out(vty,
2870 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2871 ifp->name,
2872 VTY_NEWLINE);
2873 return CMD_WARNING;
2874 }
2875
2876 query_max_response_time_dsec = atoi(argv[0]);
2877
2878 /*
2879 It seems we don't need to check bounds since command.c does it
2880 already, but we verify them anyway for extra safety.
2881 */
2882 if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
2883 vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
2884 query_max_response_time_dsec,
2885 IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
2886 VTY_NEWLINE);
2887 return CMD_WARNING;
2888 }
2889 if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
2890 vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
2891 query_max_response_time_dsec,
2892 IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
2893 VTY_NEWLINE);
2894 return CMD_WARNING;
2895 }
2896
2897 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2898
2899 if (query_max_response_time_dsec >= default_query_interval_dsec) {
2900 vty_out(vty,
2901 "Can't set query max response time %d dsec >= general query interval %d dsec%s",
2902 query_max_response_time_dsec, default_query_interval_dsec,
2903 VTY_NEWLINE);
2904 return CMD_WARNING;
2905 }
2906
2907 change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
2908
2909 return CMD_SUCCESS;
2910}
2911
2912DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
2913 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
2914 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
2915 NO_STR
2916 IP_STR
2917 IFACE_IGMP_STR
2918 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
2919{
2920 struct interface *ifp;
2921 struct pim_interface *pim_ifp;
2922 int default_query_interval_dsec;
2923
2924 ifp = vty->index;
2925 pim_ifp = ifp->info;
2926
2927 if (!pim_ifp)
2928 return CMD_SUCCESS;
2929
2930 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2931
2932 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
2933 vty_out(vty,
2934 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
2935 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
2936 VTY_NEWLINE);
2937 return CMD_WARNING;
2938 }
2939
2940 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
2941
2942 return CMD_SUCCESS;
2943}
2944
2945DEFUN (interface_ip_pim_ssm,
2946 interface_ip_pim_ssm_cmd,
2947 "ip pim ssm",
2948 IP_STR
2949 PIM_STR
2950 IFACE_PIM_STR)
2951{
2952 struct interface *ifp;
2953 struct pim_interface *pim_ifp;
2954
2955 ifp = vty->index;
2956 pim_ifp = ifp->info;
2957
2958 if (!pim_ifp) {
2959 pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
2960 if (!pim_ifp) {
2961 vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
2962 return CMD_WARNING;
2963 }
2964 }
2965 else {
2966 PIM_IF_DO_PIM(pim_ifp->options);
2967 }
2968
2969 pim_if_addr_add_all(ifp);
2970 pim_if_membership_refresh(ifp);
2971
2972 return CMD_SUCCESS;
2973}
2974
2975DEFUN (interface_no_ip_pim_ssm,
2976 interface_no_ip_pim_ssm_cmd,
2977 "no ip pim ssm",
2978 NO_STR
2979 IP_STR
2980 PIM_STR
2981 IFACE_PIM_STR)
2982{
2983 struct interface *ifp;
2984 struct pim_interface *pim_ifp;
2985
2986 ifp = vty->index;
2987 pim_ifp = ifp->info;
2988 if (!pim_ifp)
2989 return CMD_SUCCESS;
2990
2991 PIM_IF_DONT_PIM(pim_ifp->options);
2992
2993 pim_if_membership_clear(ifp);
2994
2995 /*
2996 pim_if_addr_del_all() removes all sockets from
2997 pim_ifp->igmp_socket_list.
2998 */
2999 pim_if_addr_del_all(ifp);
3000
3001 /*
3002 pim_sock_delete() removes all neighbors from
3003 pim_ifp->pim_neighbor_list.
3004 */
3005 pim_sock_delete(ifp, "pim unconfigured on interface");
3006
3007 if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
3008 pim_if_delete(ifp);
3009 }
3010
3011 return CMD_SUCCESS;
3012}
3013
3014DEFUN (debug_igmp,
3015 debug_igmp_cmd,
3016 "debug igmp",
3017 DEBUG_STR
3018 DEBUG_IGMP_STR)
3019{
3020 PIM_DO_DEBUG_IGMP_EVENTS;
3021 PIM_DO_DEBUG_IGMP_PACKETS;
3022 PIM_DO_DEBUG_IGMP_TRACE;
3023 return CMD_SUCCESS;
3024}
3025
3026DEFUN (no_debug_igmp,
3027 no_debug_igmp_cmd,
3028 "no debug igmp",
3029 NO_STR
3030 DEBUG_STR
3031 DEBUG_IGMP_STR)
3032{
3033 PIM_DONT_DEBUG_IGMP_EVENTS;
3034 PIM_DONT_DEBUG_IGMP_PACKETS;
3035 PIM_DONT_DEBUG_IGMP_TRACE;
3036 return CMD_SUCCESS;
3037}
3038
3039ALIAS (no_debug_igmp,
3040 undebug_igmp_cmd,
3041 "undebug igmp",
3042 UNDEBUG_STR
3043 DEBUG_IGMP_STR)
3044
3045DEFUN (debug_igmp_events,
3046 debug_igmp_events_cmd,
3047 "debug igmp events",
3048 DEBUG_STR
3049 DEBUG_IGMP_STR
3050 DEBUG_IGMP_EVENTS_STR)
3051{
3052 PIM_DO_DEBUG_IGMP_EVENTS;
3053 return CMD_SUCCESS;
3054}
3055
3056DEFUN (no_debug_igmp_events,
3057 no_debug_igmp_events_cmd,
3058 "no debug igmp events",
3059 NO_STR
3060 DEBUG_STR
3061 DEBUG_IGMP_STR
3062 DEBUG_IGMP_EVENTS_STR)
3063{
3064 PIM_DONT_DEBUG_IGMP_EVENTS;
3065 return CMD_SUCCESS;
3066}
3067
3068ALIAS (no_debug_igmp_events,
3069 undebug_igmp_events_cmd,
3070 "undebug igmp events",
3071 UNDEBUG_STR
3072 DEBUG_IGMP_STR
3073 DEBUG_IGMP_EVENTS_STR)
3074
3075DEFUN (debug_igmp_packets,
3076 debug_igmp_packets_cmd,
3077 "debug igmp packets",
3078 DEBUG_STR
3079 DEBUG_IGMP_STR
3080 DEBUG_IGMP_PACKETS_STR)
3081{
3082 PIM_DO_DEBUG_IGMP_PACKETS;
3083 return CMD_SUCCESS;
3084}
3085
3086DEFUN (no_debug_igmp_packets,
3087 no_debug_igmp_packets_cmd,
3088 "no debug igmp packets",
3089 NO_STR
3090 DEBUG_STR
3091 DEBUG_IGMP_STR
3092 DEBUG_IGMP_PACKETS_STR)
3093{
3094 PIM_DONT_DEBUG_IGMP_PACKETS;
3095 return CMD_SUCCESS;
3096}
3097
3098ALIAS (no_debug_igmp_packets,
3099 undebug_igmp_packets_cmd,
3100 "undebug igmp packets",
3101 UNDEBUG_STR
3102 DEBUG_IGMP_STR
3103 DEBUG_IGMP_PACKETS_STR)
3104
3105DEFUN (debug_igmp_trace,
3106 debug_igmp_trace_cmd,
3107 "debug igmp trace",
3108 DEBUG_STR
3109 DEBUG_IGMP_STR
3110 DEBUG_IGMP_TRACE_STR)
3111{
3112 PIM_DO_DEBUG_IGMP_TRACE;
3113 return CMD_SUCCESS;
3114}
3115
3116DEFUN (no_debug_igmp_trace,
3117 no_debug_igmp_trace_cmd,
3118 "no debug igmp trace",
3119 NO_STR
3120 DEBUG_STR
3121 DEBUG_IGMP_STR
3122 DEBUG_IGMP_TRACE_STR)
3123{
3124 PIM_DONT_DEBUG_IGMP_TRACE;
3125 return CMD_SUCCESS;
3126}
3127
3128ALIAS (no_debug_igmp_trace,
3129 undebug_igmp_trace_cmd,
3130 "undebug igmp trace",
3131 UNDEBUG_STR
3132 DEBUG_IGMP_STR
3133 DEBUG_IGMP_TRACE_STR)
3134
Everton Marques67faabc2010-02-23 12:11:11 -03003135DEFUN (debug_mroute,
3136 debug_mroute_cmd,
3137 "debug mroute",
3138 DEBUG_STR
3139 DEBUG_MROUTE_STR)
3140{
3141 PIM_DO_DEBUG_MROUTE;
3142 return CMD_SUCCESS;
3143}
3144
3145DEFUN (no_debug_mroute,
3146 no_debug_mroute_cmd,
3147 "no debug mroute",
3148 NO_STR
3149 DEBUG_STR
3150 DEBUG_MROUTE_STR)
3151{
3152 PIM_DONT_DEBUG_MROUTE;
3153 return CMD_SUCCESS;
3154}
3155
3156ALIAS (no_debug_mroute,
3157 undebug_mroute_cmd,
3158 "undebug mroute",
3159 UNDEBUG_STR
3160 DEBUG_MROUTE_STR)
3161
Everton Marques871dbcf2009-08-11 15:43:05 -03003162DEFUN (debug_pim,
3163 debug_pim_cmd,
3164 "debug pim",
3165 DEBUG_STR
3166 DEBUG_PIM_STR)
3167{
3168 PIM_DO_DEBUG_PIM_EVENTS;
3169 PIM_DO_DEBUG_PIM_PACKETS;
3170 PIM_DO_DEBUG_PIM_TRACE;
3171 return CMD_SUCCESS;
3172}
3173
3174DEFUN (no_debug_pim,
3175 no_debug_pim_cmd,
3176 "no debug pim",
3177 NO_STR
3178 DEBUG_STR
3179 DEBUG_PIM_STR)
3180{
3181 PIM_DONT_DEBUG_PIM_EVENTS;
3182 PIM_DONT_DEBUG_PIM_PACKETS;
3183 PIM_DONT_DEBUG_PIM_TRACE;
Everton Marques62738042009-11-18 10:44:13 -02003184
3185 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3186 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3187
Everton Marques871dbcf2009-08-11 15:43:05 -03003188 return CMD_SUCCESS;
3189}
3190
3191ALIAS (no_debug_pim,
3192 undebug_pim_cmd,
3193 "undebug pim",
3194 UNDEBUG_STR
3195 DEBUG_PIM_STR)
3196
3197DEFUN (debug_pim_events,
3198 debug_pim_events_cmd,
3199 "debug pim events",
3200 DEBUG_STR
3201 DEBUG_PIM_STR
3202 DEBUG_PIM_EVENTS_STR)
3203{
3204 PIM_DO_DEBUG_PIM_EVENTS;
3205 return CMD_SUCCESS;
3206}
3207
3208DEFUN (no_debug_pim_events,
3209 no_debug_pim_events_cmd,
3210 "no debug pim events",
3211 NO_STR
3212 DEBUG_STR
3213 DEBUG_PIM_STR
3214 DEBUG_PIM_EVENTS_STR)
3215{
3216 PIM_DONT_DEBUG_PIM_EVENTS;
3217 return CMD_SUCCESS;
3218}
3219
3220ALIAS (no_debug_pim_events,
3221 undebug_pim_events_cmd,
3222 "undebug pim events",
3223 UNDEBUG_STR
3224 DEBUG_PIM_STR
3225 DEBUG_PIM_EVENTS_STR)
3226
3227DEFUN (debug_pim_packets,
3228 debug_pim_packets_cmd,
3229 "debug pim packets",
3230 DEBUG_STR
3231 DEBUG_PIM_STR
3232 DEBUG_PIM_PACKETS_STR)
3233{
3234 PIM_DO_DEBUG_PIM_PACKETS;
3235 return CMD_SUCCESS;
3236}
3237
3238DEFUN (no_debug_pim_packets,
3239 no_debug_pim_packets_cmd,
3240 "no debug pim packets",
3241 NO_STR
3242 DEBUG_STR
3243 DEBUG_PIM_STR
3244 DEBUG_PIM_PACKETS_STR)
3245{
3246 PIM_DONT_DEBUG_PIM_PACKETS;
3247 return CMD_SUCCESS;
3248}
3249
3250ALIAS (no_debug_pim_packets,
3251 undebug_pim_packets_cmd,
3252 "undebug pim packets",
3253 UNDEBUG_STR
3254 DEBUG_PIM_STR
3255 DEBUG_PIM_PACKETS_STR)
3256
Everton Marques62738042009-11-18 10:44:13 -02003257DEFUN (debug_pim_packetdump_send,
3258 debug_pim_packetdump_send_cmd,
3259 "debug pim packet-dump send",
3260 DEBUG_STR
3261 DEBUG_PIM_STR
3262 DEBUG_PIM_PACKETDUMP_STR
3263 DEBUG_PIM_PACKETDUMP_SEND_STR)
3264{
3265 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
3266 return CMD_SUCCESS;
3267}
3268
3269DEFUN (no_debug_pim_packetdump_send,
3270 no_debug_pim_packetdump_send_cmd,
3271 "no debug pim packet-dump send",
3272 NO_STR
3273 DEBUG_STR
3274 DEBUG_PIM_STR
3275 DEBUG_PIM_PACKETDUMP_STR
3276 DEBUG_PIM_PACKETDUMP_SEND_STR)
3277{
3278 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3279 return CMD_SUCCESS;
3280}
3281
3282ALIAS (no_debug_pim_packetdump_send,
3283 undebug_pim_packetdump_send_cmd,
3284 "undebug pim packet-dump send",
3285 UNDEBUG_STR
3286 DEBUG_PIM_STR
3287 DEBUG_PIM_PACKETDUMP_STR
3288 DEBUG_PIM_PACKETDUMP_SEND_STR)
3289
3290DEFUN (debug_pim_packetdump_recv,
3291 debug_pim_packetdump_recv_cmd,
3292 "debug pim packet-dump receive",
3293 DEBUG_STR
3294 DEBUG_PIM_STR
3295 DEBUG_PIM_PACKETDUMP_STR
3296 DEBUG_PIM_PACKETDUMP_RECV_STR)
3297{
3298 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
3299 return CMD_SUCCESS;
3300}
3301
3302DEFUN (no_debug_pim_packetdump_recv,
3303 no_debug_pim_packetdump_recv_cmd,
3304 "no debug pim packet-dump receive",
3305 NO_STR
3306 DEBUG_STR
3307 DEBUG_PIM_STR
3308 DEBUG_PIM_PACKETDUMP_STR
3309 DEBUG_PIM_PACKETDUMP_RECV_STR)
3310{
3311 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3312 return CMD_SUCCESS;
3313}
3314
3315ALIAS (no_debug_pim_packetdump_recv,
3316 undebug_pim_packetdump_recv_cmd,
3317 "undebug pim packet-dump receive",
3318 UNDEBUG_STR
3319 DEBUG_PIM_STR
3320 DEBUG_PIM_PACKETDUMP_STR
3321 DEBUG_PIM_PACKETDUMP_RECV_STR)
3322
Everton Marques871dbcf2009-08-11 15:43:05 -03003323DEFUN (debug_pim_trace,
3324 debug_pim_trace_cmd,
3325 "debug pim trace",
3326 DEBUG_STR
3327 DEBUG_PIM_STR
3328 DEBUG_PIM_TRACE_STR)
3329{
3330 PIM_DO_DEBUG_PIM_TRACE;
3331 return CMD_SUCCESS;
3332}
3333
3334DEFUN (no_debug_pim_trace,
3335 no_debug_pim_trace_cmd,
3336 "no debug pim trace",
3337 NO_STR
3338 DEBUG_STR
3339 DEBUG_PIM_STR
3340 DEBUG_PIM_TRACE_STR)
3341{
3342 PIM_DONT_DEBUG_PIM_TRACE;
3343 return CMD_SUCCESS;
3344}
3345
3346ALIAS (no_debug_pim_trace,
3347 undebug_pim_trace_cmd,
3348 "undebug pim trace",
3349 UNDEBUG_STR
3350 DEBUG_PIM_STR
3351 DEBUG_PIM_TRACE_STR)
3352
Everton Marques824adbe2009-10-08 09:16:27 -03003353DEFUN (debug_ssmpingd,
3354 debug_ssmpingd_cmd,
3355 "debug ssmpingd",
3356 DEBUG_STR
3357 DEBUG_PIM_STR
3358 DEBUG_SSMPINGD_STR)
3359{
3360 PIM_DO_DEBUG_SSMPINGD;
3361 return CMD_SUCCESS;
3362}
3363
3364DEFUN (no_debug_ssmpingd,
3365 no_debug_ssmpingd_cmd,
3366 "no debug ssmpingd",
3367 NO_STR
3368 DEBUG_STR
3369 DEBUG_PIM_STR
3370 DEBUG_SSMPINGD_STR)
3371{
3372 PIM_DONT_DEBUG_SSMPINGD;
3373 return CMD_SUCCESS;
3374}
3375
3376ALIAS (no_debug_ssmpingd,
3377 undebug_ssmpingd_cmd,
3378 "undebug ssmpingd",
3379 UNDEBUG_STR
3380 DEBUG_PIM_STR
3381 DEBUG_SSMPINGD_STR)
3382
Everton Marques871dbcf2009-08-11 15:43:05 -03003383DEFUN (debug_pim_zebra,
3384 debug_pim_zebra_cmd,
3385 "debug pim zebra",
3386 DEBUG_STR
3387 DEBUG_PIM_STR
3388 DEBUG_PIM_ZEBRA_STR)
3389{
3390 PIM_DO_DEBUG_ZEBRA;
3391 return CMD_SUCCESS;
3392}
3393
3394DEFUN (no_debug_pim_zebra,
3395 no_debug_pim_zebra_cmd,
3396 "no debug pim zebra",
3397 NO_STR
3398 DEBUG_STR
3399 DEBUG_PIM_STR
3400 DEBUG_PIM_ZEBRA_STR)
3401{
3402 PIM_DONT_DEBUG_ZEBRA;
3403 return CMD_SUCCESS;
3404}
3405
3406ALIAS (no_debug_pim_zebra,
3407 undebug_pim_zebra_cmd,
3408 "undebug pim zebra",
3409 UNDEBUG_STR
3410 DEBUG_PIM_STR
3411 DEBUG_PIM_ZEBRA_STR)
3412
3413DEFUN (show_debugging,
3414 show_debugging_cmd,
3415 "show debugging",
3416 SHOW_STR
3417 "State of each debugging option\n")
3418{
3419 pim_debug_config_write(vty);
3420 return CMD_SUCCESS;
3421}
3422
3423static struct igmp_sock *find_igmp_sock_by_fd(int fd)
3424{
3425 struct listnode *ifnode;
3426 struct interface *ifp;
3427
3428 /* scan all interfaces */
3429 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
3430 struct pim_interface *pim_ifp;
3431 struct igmp_sock *igmp;
3432
3433 if (!ifp->info)
3434 continue;
3435
3436 pim_ifp = ifp->info;
3437
3438 /* lookup igmp socket under current interface */
3439 igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
3440 if (igmp)
3441 return igmp;
3442 }
3443
3444 return 0;
3445}
3446
3447DEFUN (test_igmp_receive_report,
3448 test_igmp_receive_report_cmd,
3449 "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
3450 "Test\n"
3451 "Test IGMP protocol\n"
3452 "Test IGMP message\n"
3453 "Test IGMP report\n"
3454 "Socket\n"
3455 "IGMP group address\n"
3456 "Record type\n"
3457 "Sources\n")
3458{
3459 char buf[1000];
3460 char *igmp_msg;
3461 struct ip *ip_hdr;
3462 size_t ip_hlen; /* ip header length in bytes */
3463 int ip_msg_len;
3464 int igmp_msg_len;
3465 const char *socket;
3466 int socket_fd;
3467 const char *grp_str;
3468 struct in_addr grp_addr;
3469 const char *record_type_str;
3470 int record_type;
3471 const char *src_str;
3472 int result;
3473 struct igmp_sock *igmp;
3474 char *group_record;
3475 int num_sources;
3476 struct in_addr *sources;
3477 struct in_addr *src_addr;
3478 int argi;
3479
3480 socket = argv[0];
3481 socket_fd = atoi(socket);
3482 igmp = find_igmp_sock_by_fd(socket_fd);
3483 if (!igmp) {
3484 vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
3485 socket, socket_fd, VTY_NEWLINE);
3486 return CMD_WARNING;
3487 }
3488
3489 grp_str = argv[1];
3490 result = inet_pton(AF_INET, grp_str, &grp_addr);
3491 if (result <= 0) {
3492 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003493 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003494 return CMD_WARNING;
3495 }
3496
3497 record_type_str = argv[2];
3498 record_type = atoi(record_type_str);
3499
3500 /*
3501 Tweak IP header
3502 */
3503 ip_hdr = (struct ip *) buf;
3504 ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
3505 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3506 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3507 ip_hdr->ip_src = igmp->ifaddr;
3508 ip_hdr->ip_dst = igmp->ifaddr;
3509
3510 /*
3511 Build IGMP v3 report message
3512 */
3513 igmp_msg = buf + ip_hlen;
3514 group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
3515 *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
3516 *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
3517 *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
3518 *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
Klemen Sladic3defeb32014-02-07 16:23:44 +13003519 memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr));
Everton Marques871dbcf2009-08-11 15:43:05 -03003520
3521 /* Scan LINE sources */
3522 sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
3523 src_addr = sources;
3524 for (argi = 3; argi < argc; ++argi,++src_addr) {
3525 src_str = argv[argi];
3526 result = inet_pton(AF_INET, src_str, src_addr);
3527 if (result <= 0) {
3528 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003529 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003530 return CMD_WARNING;
3531 }
3532 }
3533 num_sources = src_addr - sources;
3534
3535 *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
3536
3537 igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
3538
3539 /* compute checksum */
3540 *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = pim_inet_checksum(igmp_msg, igmp_msg_len);
3541
3542 /* "receive" message */
3543
3544 ip_msg_len = ip_hlen + igmp_msg_len;
3545 result = pim_igmp_packet(igmp, buf, ip_msg_len);
3546 if (result) {
3547 vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
3548 ip_msg_len, result, VTY_NEWLINE);
3549 return CMD_WARNING;
3550 }
3551
3552 return CMD_SUCCESS;
3553}
3554
Everton Marquesdba77582009-11-19 10:32:19 -02003555static int hexval(uint8_t ch)
3556{
3557 return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a');
3558}
3559
Everton Marques3e92c452009-11-18 16:26:38 -02003560DEFUN (test_pim_receive_dump,
3561 test_pim_receive_dump_cmd,
3562 "test pim receive dump INTERFACE A.B.C.D .LINE",
3563 "Test\n"
3564 "Test PIM protocol\n"
3565 "Test PIM message reception\n"
3566 "Test PIM packet dump reception from neighbor\n"
3567 "Interface\n"
3568 "Neighbor address\n"
3569 "Packet dump\n")
3570{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003571 uint8_t buf[1000];
3572 uint8_t *pim_msg;
Everton Marques3e92c452009-11-18 16:26:38 -02003573 struct ip *ip_hdr;
3574 size_t ip_hlen; /* ip header length in bytes */
3575 int ip_msg_len;
3576 int pim_msg_size;
3577 const char *neigh_str;
3578 struct in_addr neigh_addr;
3579 const char *ifname;
3580 struct interface *ifp;
3581 int argi;
3582 int result;
3583
3584 /* Find interface */
3585 ifname = argv[0];
3586 ifp = if_lookup_by_name(ifname);
3587 if (!ifp) {
3588 vty_out(vty, "No such interface name %s%s",
3589 ifname, VTY_NEWLINE);
3590 return CMD_WARNING;
3591 }
3592
3593 /* Neighbor address */
3594 neigh_str = argv[1];
3595 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3596 if (result <= 0) {
3597 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
3598 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
3599 return CMD_WARNING;
3600 }
3601
3602 /*
3603 Tweak IP header
3604 */
3605 ip_hdr = (struct ip *) buf;
3606 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3607 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3608 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3609 ip_hdr->ip_src = neigh_addr;
3610 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3611
3612 /*
3613 Build PIM hello message
3614 */
3615 pim_msg = buf + ip_hlen;
3616 pim_msg_size = 0;
3617
3618 /* Scan LINE dump into buffer */
Everton Marquesdba77582009-11-19 10:32:19 -02003619 for (argi = 2; argi < argc; ++argi) {
3620 const char *str = argv[argi];
3621 int str_len = strlen(str);
3622 int str_last = str_len - 1;
3623 int i;
Everton Marques3e92c452009-11-18 16:26:38 -02003624
Everton Marquesdba77582009-11-19 10:32:19 -02003625 if (str_len % 2) {
3626 vty_out(vty, "%% Uneven hex array arg %d=%s%s",
3627 argi, str, VTY_NEWLINE);
Everton Marques3e92c452009-11-18 16:26:38 -02003628 return CMD_WARNING;
3629 }
3630
Everton Marquesdba77582009-11-19 10:32:19 -02003631 for (i = 0; i < str_last; i += 2) {
3632 uint8_t octet;
3633 int left;
3634 uint8_t h1 = str[i];
3635 uint8_t h2 = str[i + 1];
3636
3637 if (!isxdigit(h1) || !isxdigit(h2)) {
3638 vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s",
3639 h1, h2, argi, str, VTY_NEWLINE);
3640 return CMD_WARNING;
3641 }
3642 octet = (hexval(h1) << 4) + hexval(h2);
3643
3644 left = sizeof(buf) - ip_hlen - pim_msg_size;
3645 if (left < 1) {
David Lamparter5c697982012-02-16 04:47:56 +01003646 vty_out(vty, "%% Overflow buf_size=%zu buf_left=%d at hex array arg %d=%s octet %02x%s",
Everton Marquesdba77582009-11-19 10:32:19 -02003647 sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
3648 return CMD_WARNING;
3649 }
3650
3651 pim_msg[pim_msg_size++] = octet;
3652 }
Everton Marques3e92c452009-11-18 16:26:38 -02003653 }
3654
3655 ip_msg_len = ip_hlen + pim_msg_size;
3656
David Lamparter5c697982012-02-16 04:47:56 +01003657 vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
Everton Marques3e92c452009-11-18 16:26:38 -02003658 sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
3659
3660 /* "receive" message */
3661
3662 result = pim_pim_packet(ifp, buf, ip_msg_len);
3663 if (result) {
3664 vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s",
3665 ip_msg_len, result, VTY_NEWLINE);
3666 return CMD_WARNING;
3667 }
3668
3669 return CMD_SUCCESS;
3670}
3671
Everton Marques871dbcf2009-08-11 15:43:05 -03003672DEFUN (test_pim_receive_hello,
3673 test_pim_receive_hello_cmd,
3674 "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
3675 "Test\n"
3676 "Test PIM protocol\n"
3677 "Test PIM message reception\n"
3678 "Test PIM hello reception from neighbor\n"
3679 "Interface\n"
3680 "Neighbor address\n"
3681 "Neighbor holdtime\n"
3682 "Neighbor DR priority\n"
3683 "Neighbor generation ID\n"
3684 "Neighbor propagation delay (msec)\n"
3685 "Neighbor override interval (msec)\n"
3686 "Neighbor LAN prune delay T-bit\n"
3687 "Neighbor secondary addresses\n")
3688{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003689 uint8_t buf[1000];
3690 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03003691 struct ip *ip_hdr;
3692 size_t ip_hlen; /* ip header length in bytes */
3693 int ip_msg_len;
3694 int pim_tlv_size;
3695 int pim_msg_size;
3696 const char *neigh_str;
3697 struct in_addr neigh_addr;
3698 const char *ifname;
3699 struct interface *ifp;
3700 uint16_t neigh_holdtime;
3701 uint16_t neigh_propagation_delay;
3702 uint16_t neigh_override_interval;
3703 int neigh_can_disable_join_suppression;
3704 uint32_t neigh_dr_priority;
3705 uint32_t neigh_generation_id;
3706 int argi;
3707 int result;
3708
3709 /* Find interface */
3710 ifname = argv[0];
3711 ifp = if_lookup_by_name(ifname);
3712 if (!ifp) {
3713 vty_out(vty, "No such interface name %s%s",
3714 ifname, VTY_NEWLINE);
3715 return CMD_WARNING;
3716 }
3717
3718 /* Neighbor address */
3719 neigh_str = argv[1];
3720 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3721 if (result <= 0) {
3722 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003723 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003724 return CMD_WARNING;
3725 }
3726
3727 neigh_holdtime = atoi(argv[2]);
3728 neigh_dr_priority = atoi(argv[3]);
3729 neigh_generation_id = atoi(argv[4]);
3730 neigh_propagation_delay = atoi(argv[5]);
3731 neigh_override_interval = atoi(argv[6]);
3732 neigh_can_disable_join_suppression = atoi(argv[7]);
3733
3734 /*
3735 Tweak IP header
3736 */
3737 ip_hdr = (struct ip *) buf;
3738 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3739 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3740 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3741 ip_hdr->ip_src = neigh_addr;
3742 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3743
3744 /*
3745 Build PIM hello message
3746 */
3747 pim_msg = buf + ip_hlen;
3748
3749 /* Scan LINE addresses */
3750 for (argi = 8; argi < argc; ++argi) {
3751 const char *sec_str = argv[argi];
3752 struct in_addr sec_addr;
3753 result = inet_pton(AF_INET, sec_str, &sec_addr);
3754 if (result <= 0) {
3755 vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003756 sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003757 return CMD_WARNING;
3758 }
3759
3760 vty_out(vty,
3761 "FIXME WRITEME consider neighbor secondary address %s%s",
3762 sec_str, VTY_NEWLINE);
3763 }
3764
3765 pim_tlv_size = pim_hello_build_tlv(ifp->name,
3766 pim_msg + PIM_PIM_MIN_LEN,
3767 sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
3768 neigh_holdtime,
3769 neigh_dr_priority,
3770 neigh_generation_id,
3771 neigh_propagation_delay,
3772 neigh_override_interval,
3773 neigh_can_disable_join_suppression,
3774 0 /* FIXME secondary address list */);
3775 if (pim_tlv_size < 0) {
3776 vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
3777 pim_tlv_size, VTY_NEWLINE);
3778 return CMD_WARNING;
3779 }
3780
3781 pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
3782
3783 pim_msg_build_header(pim_msg, pim_msg_size,
3784 PIM_MSG_TYPE_HELLO);
3785
3786 /* "receive" message */
3787
3788 ip_msg_len = ip_hlen + pim_msg_size;
3789 result = pim_pim_packet(ifp, buf, ip_msg_len);
3790 if (result) {
3791 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
3792 ip_msg_len, result, VTY_NEWLINE);
3793 return CMD_WARNING;
3794 }
3795
3796 return CMD_SUCCESS;
3797}
3798
3799DEFUN (test_pim_receive_assert,
3800 test_pim_receive_assert_cmd,
3801 "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
3802 "Test\n"
3803 "Test PIM protocol\n"
3804 "Test PIM message reception\n"
3805 "Test reception of PIM assert\n"
3806 "Interface\n"
3807 "Neighbor address\n"
3808 "Assert multicast group address\n"
3809 "Assert unicast source address\n"
3810 "Assert metric preference\n"
3811 "Assert route metric\n"
3812 "Assert RPT bit flag\n")
3813{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003814 uint8_t buf[1000];
3815 uint8_t *buf_pastend = buf + sizeof(buf);
3816 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03003817 struct ip *ip_hdr;
3818 size_t ip_hlen; /* ip header length in bytes */
3819 int ip_msg_len;
3820 int pim_msg_size;
3821 const char *neigh_str;
3822 struct in_addr neigh_addr;
3823 const char *group_str;
3824 struct in_addr group_addr;
3825 const char *source_str;
3826 struct in_addr source_addr;
3827 const char *ifname;
3828 struct interface *ifp;
3829 uint32_t assert_metric_preference;
3830 uint32_t assert_route_metric;
3831 uint32_t assert_rpt_bit_flag;
3832 int remain;
3833 int result;
3834
3835 /* Find interface */
3836 ifname = argv[0];
3837 ifp = if_lookup_by_name(ifname);
3838 if (!ifp) {
3839 vty_out(vty, "No such interface name %s%s",
3840 ifname, VTY_NEWLINE);
3841 return CMD_WARNING;
3842 }
3843
3844 /* Neighbor address */
3845 neigh_str = argv[1];
3846 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3847 if (result <= 0) {
3848 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003849 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003850 return CMD_WARNING;
3851 }
3852
3853 /* Group address */
3854 group_str = argv[2];
3855 result = inet_pton(AF_INET, group_str, &group_addr);
3856 if (result <= 0) {
3857 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003858 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003859 return CMD_WARNING;
3860 }
3861
3862 /* Source address */
3863 source_str = argv[3];
3864 result = inet_pton(AF_INET, source_str, &source_addr);
3865 if (result <= 0) {
3866 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003867 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003868 return CMD_WARNING;
3869 }
3870
3871 assert_metric_preference = atoi(argv[4]);
3872 assert_route_metric = atoi(argv[5]);
3873 assert_rpt_bit_flag = atoi(argv[6]);
3874
3875 remain = buf_pastend - buf;
3876 if (remain < (int) sizeof(struct ip)) {
David Lamparter5c697982012-02-16 04:47:56 +01003877 vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03003878 remain, sizeof(struct ip), VTY_NEWLINE);
3879 return CMD_WARNING;
3880 }
3881
3882 /*
3883 Tweak IP header
3884 */
3885 ip_hdr = (struct ip *) buf;
3886 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3887 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3888 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3889 ip_hdr->ip_src = neigh_addr;
3890 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3891
3892 /*
3893 Build PIM assert message
3894 */
3895 pim_msg = buf + ip_hlen; /* skip ip header */
3896
3897 pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
3898 group_addr, source_addr,
3899 assert_metric_preference,
3900 assert_route_metric,
3901 assert_rpt_bit_flag);
3902 if (pim_msg_size < 0) {
3903 vty_out(vty, "Failure building PIM assert message: size=%d%s",
3904 pim_msg_size, VTY_NEWLINE);
3905 return CMD_WARNING;
3906 }
3907
3908 /* "receive" message */
3909
3910 ip_msg_len = ip_hlen + pim_msg_size;
3911 result = pim_pim_packet(ifp, buf, ip_msg_len);
3912 if (result) {
3913 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
3914 ip_msg_len, result, VTY_NEWLINE);
3915 return CMD_WARNING;
3916 }
3917
3918 return CMD_SUCCESS;
3919}
3920
3921static int recv_joinprune(struct vty *vty,
3922 const char *argv[],
3923 int src_is_join)
3924{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003925 uint8_t buf[1000];
3926 const uint8_t *buf_pastend = buf + sizeof(buf);
3927 uint8_t *pim_msg;
3928 uint8_t *pim_msg_curr;
Everton Marques871dbcf2009-08-11 15:43:05 -03003929 int pim_msg_size;
3930 struct ip *ip_hdr;
3931 size_t ip_hlen; /* ip header length in bytes */
3932 int ip_msg_len;
3933 uint16_t neigh_holdtime;
3934 const char *neigh_dst_str;
3935 struct in_addr neigh_dst_addr;
3936 const char *neigh_src_str;
3937 struct in_addr neigh_src_addr;
3938 const char *group_str;
3939 struct in_addr group_addr;
3940 const char *source_str;
3941 struct in_addr source_addr;
3942 const char *ifname;
3943 struct interface *ifp;
3944 int result;
3945 int remain;
3946 uint16_t num_joined;
3947 uint16_t num_pruned;
3948
3949 /* Find interface */
3950 ifname = argv[0];
3951 ifp = if_lookup_by_name(ifname);
3952 if (!ifp) {
3953 vty_out(vty, "No such interface name %s%s",
3954 ifname, VTY_NEWLINE);
3955 return CMD_WARNING;
3956 }
3957
3958 neigh_holdtime = atoi(argv[1]);
3959
3960 /* Neighbor destination address */
3961 neigh_dst_str = argv[2];
3962 result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
3963 if (result <= 0) {
3964 vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003965 neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003966 return CMD_WARNING;
3967 }
3968
3969 /* Neighbor source address */
3970 neigh_src_str = argv[3];
3971 result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
3972 if (result <= 0) {
3973 vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003974 neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003975 return CMD_WARNING;
3976 }
3977
3978 /* Multicast group address */
3979 group_str = argv[4];
3980 result = inet_pton(AF_INET, group_str, &group_addr);
3981 if (result <= 0) {
3982 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003983 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003984 return CMD_WARNING;
3985 }
3986
3987 /* Multicast source address */
3988 source_str = argv[5];
3989 result = inet_pton(AF_INET, source_str, &source_addr);
3990 if (result <= 0) {
3991 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003992 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003993 return CMD_WARNING;
3994 }
3995
3996 /*
3997 Tweak IP header
3998 */
3999 ip_hdr = (struct ip *) buf;
4000 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4001 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4002 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4003 ip_hdr->ip_src = neigh_src_addr;
4004 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4005
4006 /*
4007 Build PIM message
4008 */
4009 pim_msg = buf + ip_hlen;
4010
4011 /* skip room for pim header */
4012 pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
4013
4014 remain = buf_pastend - pim_msg_curr;
4015 pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
4016 remain,
4017 neigh_dst_addr);
4018 if (!pim_msg_curr) {
4019 vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
4020 neigh_dst_str, remain, VTY_NEWLINE);
4021 return CMD_WARNING;
4022 }
4023
4024 remain = buf_pastend - pim_msg_curr;
4025 if (remain < 4) {
4026 vty_out(vty, "Group will not fit: space left=%d%s",
4027 remain, VTY_NEWLINE);
4028 return CMD_WARNING;
4029 }
4030
4031 *pim_msg_curr = 0; /* reserved */
4032 ++pim_msg_curr;
4033 *pim_msg_curr = 1; /* number of groups */
4034 ++pim_msg_curr;
4035 *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
4036 ++pim_msg_curr;
4037 ++pim_msg_curr;
4038
4039 remain = buf_pastend - pim_msg_curr;
4040 pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
4041 remain,
4042 group_addr);
4043 if (!pim_msg_curr) {
4044 vty_out(vty, "Failure encoding group address %s: space left=%d%s",
4045 group_str, remain, VTY_NEWLINE);
4046 return CMD_WARNING;
4047 }
4048
4049 remain = buf_pastend - pim_msg_curr;
4050 if (remain < 4) {
4051 vty_out(vty, "Sources will not fit: space left=%d%s",
4052 remain, VTY_NEWLINE);
4053 return CMD_WARNING;
4054 }
4055
4056 if (src_is_join) {
4057 num_joined = 1;
4058 num_pruned = 0;
4059 }
4060 else {
4061 num_joined = 0;
4062 num_pruned = 1;
4063 }
4064
4065 /* number of joined sources */
4066 *((uint16_t *) pim_msg_curr) = htons(num_joined);
4067 ++pim_msg_curr;
4068 ++pim_msg_curr;
4069
4070 /* number of pruned sources */
4071 *((uint16_t *) pim_msg_curr) = htons(num_pruned);
4072 ++pim_msg_curr;
4073 ++pim_msg_curr;
4074
4075 remain = buf_pastend - pim_msg_curr;
4076 pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
4077 remain,
4078 source_addr);
4079 if (!pim_msg_curr) {
4080 vty_out(vty, "Failure encoding source address %s: space left=%d%s",
4081 source_str, remain, VTY_NEWLINE);
4082 return CMD_WARNING;
4083 }
4084
4085 /* Add PIM header */
4086
4087 pim_msg_size = pim_msg_curr - pim_msg;
4088
4089 pim_msg_build_header(pim_msg, pim_msg_size,
4090 PIM_MSG_TYPE_JOIN_PRUNE);
4091
4092 /*
4093 "Receive" message
4094 */
4095
4096 ip_msg_len = ip_hlen + pim_msg_size;
4097 result = pim_pim_packet(ifp, buf, ip_msg_len);
4098 if (result) {
4099 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4100 ip_msg_len, result, VTY_NEWLINE);
4101 return CMD_WARNING;
4102 }
4103
4104 return CMD_SUCCESS;
4105}
4106
4107DEFUN (test_pim_receive_join,
4108 test_pim_receive_join_cmd,
4109 "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4110 "Test\n"
4111 "Test PIM protocol\n"
4112 "Test PIM message reception\n"
4113 "Test PIM join reception from neighbor\n"
4114 "Interface\n"
4115 "Neighbor holdtime\n"
4116 "Upstream neighbor unicast destination address\n"
4117 "Downstream neighbor unicast source address\n"
4118 "Multicast group address\n"
4119 "Unicast source address\n")
4120{
4121 return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
4122}
4123
4124DEFUN (test_pim_receive_prune,
4125 test_pim_receive_prune_cmd,
4126 "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4127 "Test\n"
4128 "Test PIM protocol\n"
4129 "Test PIM message reception\n"
4130 "Test PIM prune reception from neighbor\n"
4131 "Interface\n"
4132 "Neighbor holdtime\n"
4133 "Upstream neighbor unicast destination address\n"
4134 "Downstream neighbor unicast source address\n"
4135 "Multicast group address\n"
4136 "Unicast source address\n")
4137{
4138 return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
4139}
4140
4141DEFUN (test_pim_receive_upcall,
4142 test_pim_receive_upcall_cmd,
4143 "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
4144 "Test\n"
4145 "Test PIM protocol\n"
4146 "Test PIM message reception\n"
4147 "Test reception of kernel upcall\n"
4148 "NOCACHE kernel upcall\n"
4149 "WRONGVIF kernel upcall\n"
4150 "WHOLEPKT kernel upcall\n"
4151 "Input interface vif index\n"
4152 "Multicast group address\n"
4153 "Multicast source address\n")
4154{
4155 struct igmpmsg msg;
4156 const char *upcall_type;
4157 const char *group_str;
4158 const char *source_str;
4159 int result;
4160
4161 upcall_type = argv[0];
4162
4163 if (upcall_type[0] == 'n')
4164 msg.im_msgtype = IGMPMSG_NOCACHE;
4165 else if (upcall_type[1] == 'r')
4166 msg.im_msgtype = IGMPMSG_WRONGVIF;
4167 else if (upcall_type[1] == 'h')
4168 msg.im_msgtype = IGMPMSG_WHOLEPKT;
4169 else {
4170 vty_out(vty, "Unknown kernel upcall type: %s%s",
4171 upcall_type, VTY_NEWLINE);
4172 return CMD_WARNING;
4173 }
4174
4175 msg.im_vif = atoi(argv[1]);
4176
4177 /* Group address */
4178 group_str = argv[2];
4179 result = inet_pton(AF_INET, group_str, &msg.im_dst);
4180 if (result <= 0) {
4181 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004182 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004183 return CMD_WARNING;
4184 }
4185
4186 /* Source address */
4187 source_str = argv[3];
4188 result = inet_pton(AF_INET, source_str, &msg.im_src);
4189 if (result <= 0) {
4190 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004191 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004192 return CMD_WARNING;
4193 }
4194
4195 msg.im_mbz = 0; /* Must be zero */
4196
4197 result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
4198 if (result) {
David Lamparter5c697982012-02-16 04:47:56 +01004199 vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03004200 sizeof(msg), result, VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203
4204 return CMD_SUCCESS;
4205}
4206
4207void pim_cmd_init()
4208{
Leonard Herve596470f2009-08-11 15:45:26 -03004209 install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
4210 install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
Everton Marques871dbcf2009-08-11 15:43:05 -03004211
Leonard Herve596470f2009-08-11 15:45:26 -03004212 install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
4213 install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
Everton Marques96f91ae2009-10-07 18:41:45 -03004214 install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
4215 install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004216#if 0
Leonard Herve596470f2009-08-11 15:45:26 -03004217 install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004218#else
Leonard Herve596470f2009-08-11 15:45:26 -03004219 install_element (CONFIG_NODE, &pim_interface_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004220#endif
Leonard Herve596470f2009-08-11 15:45:26 -03004221 install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004222
Leonard Herve596470f2009-08-11 15:45:26 -03004223 install_default (INTERFACE_NODE);
4224 install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
4225 install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
4226 install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
4227 install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
4228 install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
4229 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
4230 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
4231 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
4232 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
4233 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
4234 install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
4235 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004236
Leonard Herve596470f2009-08-11 15:45:26 -03004237 install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004238 install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004239 install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
4240 install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
4241 install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4242 install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
4243 install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4244 install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
4245 install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
4246 install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
4247 install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
4248 install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
4249 install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
4250 install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
4251 install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
4252 install_element (VIEW_NODE, &show_ip_pim_join_cmd);
4253 install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
4254 install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
4255 install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
4256 install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
4257 install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
4258 install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
4259 install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
4260 install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
4261 install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
4262 install_element (VIEW_NODE, &show_ip_multicast_cmd);
4263 install_element (VIEW_NODE, &show_ip_mroute_cmd);
4264 install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004265 install_element (VIEW_NODE, &show_ip_rib_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004266 install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004267 install_element (VIEW_NODE, &show_debugging_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004268
Leonard Herve596470f2009-08-11 15:45:26 -03004269 install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
4270 install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
4271 install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004272
Leonard Herve596470f2009-08-11 15:45:26 -03004273 install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004274 install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004275 install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
4276 install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
4277 install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4278 install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
4279 install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4280 install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
4281 install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
4282 install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
4283 install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
4284 install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
4285 install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
4286 install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
4287 install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
4288 install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
4289 install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
4290 install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
4291 install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
4292 install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
4293 install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
4294 install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
4295 install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
4296 install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
4297 install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
4298 install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
4299 install_element (ENABLE_NODE, &show_ip_multicast_cmd);
4300 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
4301 install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004302 install_element (ENABLE_NODE, &show_ip_rib_cmd);
Everton Marquese8c11bb2009-10-08 15:06:32 -03004303 install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004304 install_element (ENABLE_NODE, &show_debugging_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004305
Leonard Herve596470f2009-08-11 15:45:26 -03004306 install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
4307 install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
Everton Marques3e92c452009-11-18 16:26:38 -02004308 install_element (ENABLE_NODE, &test_pim_receive_dump_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004309 install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
4310 install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
4311 install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
4312 install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004313
Leonard Herve596470f2009-08-11 15:45:26 -03004314 install_element (ENABLE_NODE, &debug_igmp_cmd);
4315 install_element (ENABLE_NODE, &no_debug_igmp_cmd);
4316 install_element (ENABLE_NODE, &undebug_igmp_cmd);
4317 install_element (ENABLE_NODE, &debug_igmp_events_cmd);
4318 install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
4319 install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
4320 install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
4321 install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
4322 install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
4323 install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
4324 install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
4325 install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004326 install_element (ENABLE_NODE, &debug_mroute_cmd);
4327 install_element (ENABLE_NODE, &no_debug_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004328 install_element (ENABLE_NODE, &debug_pim_cmd);
4329 install_element (ENABLE_NODE, &no_debug_pim_cmd);
4330 install_element (ENABLE_NODE, &undebug_pim_cmd);
4331 install_element (ENABLE_NODE, &debug_pim_events_cmd);
4332 install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
4333 install_element (ENABLE_NODE, &undebug_pim_events_cmd);
4334 install_element (ENABLE_NODE, &debug_pim_packets_cmd);
4335 install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
4336 install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
Everton Marques62738042009-11-18 10:44:13 -02004337 install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
4338 install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
4339 install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd);
4340 install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
4341 install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
4342 install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004343 install_element (ENABLE_NODE, &debug_pim_trace_cmd);
4344 install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
4345 install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004346 install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
4347 install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
4348 install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004349 install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
4350 install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
4351 install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004352
Leonard Herve596470f2009-08-11 15:45:26 -03004353 install_element (CONFIG_NODE, &debug_igmp_cmd);
4354 install_element (CONFIG_NODE, &no_debug_igmp_cmd);
4355 install_element (CONFIG_NODE, &undebug_igmp_cmd);
4356 install_element (CONFIG_NODE, &debug_igmp_events_cmd);
4357 install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
4358 install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
4359 install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
4360 install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
4361 install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
4362 install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
4363 install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
4364 install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004365 install_element (CONFIG_NODE, &debug_mroute_cmd);
4366 install_element (CONFIG_NODE, &no_debug_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004367 install_element (CONFIG_NODE, &debug_pim_cmd);
4368 install_element (CONFIG_NODE, &no_debug_pim_cmd);
4369 install_element (CONFIG_NODE, &undebug_pim_cmd);
4370 install_element (CONFIG_NODE, &debug_pim_events_cmd);
4371 install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
4372 install_element (CONFIG_NODE, &undebug_pim_events_cmd);
4373 install_element (CONFIG_NODE, &debug_pim_packets_cmd);
4374 install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
4375 install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
4376 install_element (CONFIG_NODE, &debug_pim_trace_cmd);
4377 install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
4378 install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004379 install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
4380 install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
4381 install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004382 install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
4383 install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
4384 install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004385}