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