blob: 9363e3c980f0b6c4ba1229355a9f58a21851e48f [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
Everton Marques5c55a492014-07-02 12:12:16 -0300585 pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime),
586 now, pim_ifp->pim_dr_election_last);
Everton Marques871dbcf2009-08-11 15:43:05 -0300587
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;
Everton Marques871dbcf2009-08-11 15:43:05 -03001009 char src_str[100];
1010 char grp_str[100];
1011
1012 vty_out(vty,
1013 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
1014 VTY_NEWLINE);
1015
1016 /* scan all interfaces */
1017 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1018 pim_ifp = ifp->info;
1019 if (!pim_ifp)
1020 continue;
1021
Everton Marques871dbcf2009-08-11 15:43:05 -03001022 /* scan per-interface (S,G) state */
1023 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
1024 struct pim_upstream *up = ch->upstream;
1025
1026 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1027 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1028
1029 vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
1030 ifp->name,
1031 src_str,
1032 grp_str,
1033 pim_macro_ch_lost_assert(ch) ? "yes" : "no",
1034 pim_macro_chisin_joins(ch) ? "yes" : "no",
1035 pim_macro_chisin_pim_include(ch) ? "yes" : "no",
1036 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
1037 pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
1038 VTY_NEWLINE);
1039 }
1040 }
1041}
1042
1043static void pim_show_upstream_rpf(struct vty *vty)
1044{
1045 struct listnode *upnode;
1046 struct pim_upstream *up;
1047
1048 vty_out(vty,
1049 "Source Group RpfIface RibNextHop RpfAddress %s",
1050 VTY_NEWLINE);
1051
1052 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
1053 char src_str[100];
1054 char grp_str[100];
1055 char rpf_nexthop_str[100];
1056 char rpf_addr_str[100];
1057 struct pim_rpf *rpf;
1058 const char *rpf_ifname;
1059
1060 rpf = &up->rpf;
1061
1062 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1063 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1064 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
1065 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1066
1067 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1068
1069 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
1070 src_str,
1071 grp_str,
1072 rpf_ifname,
1073 rpf_nexthop_str,
1074 rpf_addr_str,
1075 VTY_NEWLINE);
1076 }
1077}
1078
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001079static void show_rpf_refresh_stats(struct vty *vty, time_t now)
Everton Marques613938d2009-08-13 15:39:31 -03001080{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001081 char refresh_uptime[10];
1082
Everton Marquesff752d42010-03-17 10:34:24 -03001083 pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001084
Everton Marques613938d2009-08-13 15:39:31 -03001085 vty_out(vty,
1086 "RPF Cache Refresh Delay: %ld msecs%s"
1087 "RPF Cache Refresh Timer: %ld msecs%s"
1088 "RPF Cache Refresh Requests: %lld%s"
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001089 "RPF Cache Refresh Events: %lld%s"
1090 "RPF Cache Refresh Last: %s%s",
Everton Marques613938d2009-08-13 15:39:31 -03001091 qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
1092 pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
David Lamparter5c697982012-02-16 04:47:56 +01001093 (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
1094 (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001095 refresh_uptime, VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03001096}
1097
Everton Marquesf24200d2014-02-14 16:40:34 -02001098static void show_scan_oil_stats(struct vty *vty, time_t now)
1099{
1100 char uptime_scan_oil[10];
1101 char uptime_mroute_add[10];
1102 char uptime_mroute_del[10];
1103
1104 pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last);
1105 pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last);
1106 pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last);
1107
1108 vty_out(vty,
1109 "Scan OIL - Last: %s Events: %lld%s"
1110 "MFC Add - Last: %s Events: %lld%s"
1111 "MFC Del - Last: %s Events: %lld%s",
1112 uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE,
1113 uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE,
1114 uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE);
1115}
1116
Everton Marques871dbcf2009-08-11 15:43:05 -03001117static void pim_show_rpf(struct vty *vty)
1118{
1119 struct listnode *up_node;
1120 struct pim_upstream *up;
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001121 time_t now = pim_time_monotonic_sec();
Everton Marques871dbcf2009-08-11 15:43:05 -03001122
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001123 show_rpf_refresh_stats(vty, now);
Everton Marques613938d2009-08-13 15:39:31 -03001124
1125 vty_out(vty, "%s", VTY_NEWLINE);
1126
Everton Marques871dbcf2009-08-11 15:43:05 -03001127 vty_out(vty,
1128 "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
1129 VTY_NEWLINE);
1130
Everton Marques871dbcf2009-08-11 15:43:05 -03001131 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
1132 char src_str[100];
1133 char grp_str[100];
1134 char rpf_addr_str[100];
1135 char rib_nexthop_str[100];
1136 const char *rpf_ifname;
1137 struct pim_rpf *rpf = &up->rpf;
1138
1139 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1140 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1141 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1142 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
1143
1144 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1145
1146 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
1147 src_str,
1148 grp_str,
1149 rpf_ifname,
1150 rpf_addr_str,
1151 rib_nexthop_str,
1152 rpf->source_nexthop.mrib_route_metric,
1153 rpf->source_nexthop.mrib_metric_preference,
1154 VTY_NEWLINE);
1155 }
1156}
1157
1158static void igmp_show_querier(struct vty *vty)
1159{
1160 struct listnode *node;
1161 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001162
1163 vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
1164
1165 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
1166 struct pim_interface *pim_ifp = ifp->info;
1167 struct listnode *sock_node;
1168 struct igmp_sock *igmp;
1169
1170 if (!pim_ifp)
1171 continue;
1172
1173 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1174 char query_hhmmss[10];
1175 char other_hhmmss[10];
1176
1177 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
1178 pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
1179
Everton Marquese96f0af2009-08-11 15:48:02 -03001180 vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03001181 ifp->name,
1182 inet_ntoa(igmp->ifaddr),
1183 igmp->t_igmp_query_timer ? "THIS" : "OTHER",
1184 igmp->startup_query_count,
1185 query_hhmmss,
1186 other_hhmmss,
1187 VTY_NEWLINE);
1188 }
1189 }
1190}
1191
1192static void igmp_show_groups(struct vty *vty)
1193{
1194 struct listnode *ifnode;
1195 struct interface *ifp;
1196 time_t now;
1197
1198 now = pim_time_monotonic_sec();
1199
1200 vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
1201
1202 /* scan interfaces */
1203 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1204 struct pim_interface *pim_ifp = ifp->info;
1205 struct listnode *sock_node;
1206 struct igmp_sock *igmp;
1207
1208 if (!pim_ifp)
1209 continue;
1210
1211 /* scan igmp sockets */
1212 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1213 char ifaddr_str[100];
1214 struct listnode *grpnode;
1215 struct igmp_group *grp;
1216
1217 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1218
1219 /* scan igmp groups */
1220 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1221 char group_str[100];
1222 char hhmmss[10];
1223 char uptime[10];
1224
1225 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1226 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
1227 pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
1228
1229 vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
1230 ifp->name,
1231 ifaddr_str,
1232 group_str,
1233 grp->group_filtermode_isexcl ? "EXCL" : "INCL",
1234 hhmmss,
1235 grp->group_source_list ? listcount(grp->group_source_list) : 0,
1236 igmp_group_compat_mode(igmp, grp),
1237 uptime,
1238 VTY_NEWLINE);
1239
1240 } /* scan igmp groups */
1241 } /* scan igmp sockets */
1242 } /* scan interfaces */
1243}
1244
1245static void igmp_show_group_retransmission(struct vty *vty)
1246{
1247 struct listnode *ifnode;
1248 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001249
1250 vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
1251
1252 /* scan interfaces */
1253 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1254 struct pim_interface *pim_ifp = ifp->info;
1255 struct listnode *sock_node;
1256 struct igmp_sock *igmp;
1257
1258 if (!pim_ifp)
1259 continue;
1260
1261 /* scan igmp sockets */
1262 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1263 char ifaddr_str[100];
1264 struct listnode *grpnode;
1265 struct igmp_group *grp;
1266
1267 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1268
1269 /* scan igmp groups */
1270 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1271 char group_str[100];
1272 char grp_retr_mmss[10];
1273 struct listnode *src_node;
1274 struct igmp_source *src;
1275 int grp_retr_sources = 0;
1276
1277 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1278 pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
1279
1280
1281 /* count group sources with retransmission state */
1282 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
1283 if (src->source_query_retransmit_count > 0) {
1284 ++grp_retr_sources;
1285 }
1286 }
1287
1288 vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
1289 ifp->name,
1290 ifaddr_str,
1291 group_str,
1292 grp_retr_mmss,
1293 grp->group_specific_query_retransmit_count,
1294 grp_retr_sources,
1295 VTY_NEWLINE);
1296
1297 } /* scan igmp groups */
1298 } /* scan igmp sockets */
1299 } /* scan interfaces */
1300}
1301
1302static void igmp_show_parameters(struct vty *vty)
1303{
1304 struct listnode *ifnode;
1305 struct interface *ifp;
1306
1307 vty_out(vty,
1308 "QRV: Robustness Variable SQI: Startup Query Interval%s"
1309 "QQI: Query Interval OQPI: Other Querier Present Interval%s"
1310 "QRI: Query Response Interval LMQT: Last Member Query Time%s"
1311 "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
1312 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1313
1314 vty_out(vty,
1315 "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
1316 VTY_NEWLINE);
1317
1318 /* scan interfaces */
1319 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1320 struct pim_interface *pim_ifp = ifp->info;
1321 struct listnode *sock_node;
1322 struct igmp_sock *igmp;
1323
1324 if (!pim_ifp)
1325 continue;
1326
1327 /* scan igmp sockets */
1328 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1329 char ifaddr_str[100];
1330 long gmi_dsec; /* Group Membership Interval */
1331 long oqpi_dsec; /* Other Querier Present Interval */
1332 int sqi;
1333 long lmqt_dsec;
1334 long ohpi_dsec;
1335 long qri_dsec;
1336
1337 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1338
1339 gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
1340 igmp->querier_query_interval,
1341 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1342
1343 sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
1344
1345 oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
1346 igmp->querier_query_interval,
1347 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1348
1349 lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
1350 igmp->querier_robustness_variable) / 100;
1351
1352 ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
1353 igmp->querier_query_interval,
1354 pim_ifp->igmp_query_max_response_time_dsec);
1355
1356 qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
1357
1358 vty_out(vty,
1359 "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
1360 ifp->name,
1361 ifaddr_str,
1362 igmp->querier_robustness_variable,
1363 igmp->querier_query_interval,
1364 qri_dsec / 10, qri_dsec % 10,
1365 gmi_dsec / 10, gmi_dsec % 10,
1366 sqi,
1367 oqpi_dsec / 10, oqpi_dsec % 10,
1368 lmqt_dsec / 10, lmqt_dsec % 10,
1369 ohpi_dsec / 10, ohpi_dsec % 10,
1370 VTY_NEWLINE);
1371
1372 } /* scan igmp sockets */
1373 } /* scan interfaces */
1374}
1375
1376static void igmp_show_sources(struct vty *vty)
1377{
1378 struct listnode *ifnode;
1379 struct interface *ifp;
1380 time_t now;
1381
1382 now = pim_time_monotonic_sec();
1383
1384 vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
1385
1386 /* scan interfaces */
1387 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1388 struct pim_interface *pim_ifp = ifp->info;
1389 struct listnode *sock_node;
1390 struct igmp_sock *igmp;
1391
1392 if (!pim_ifp)
1393 continue;
1394
1395 /* scan igmp sockets */
1396 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1397 char ifaddr_str[100];
1398 struct listnode *grpnode;
1399 struct igmp_group *grp;
1400
1401 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1402
1403 /* scan igmp groups */
1404 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1405 char group_str[100];
1406 struct listnode *srcnode;
1407 struct igmp_source *src;
1408
1409 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1410
1411 /* scan group sources */
1412 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1413 char source_str[100];
1414 char mmss[10];
1415 char uptime[10];
1416
1417 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1418
1419 pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
1420
1421 pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
1422
1423 vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
1424 ifp->name,
1425 ifaddr_str,
1426 group_str,
1427 source_str,
1428 mmss,
1429 IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
1430 uptime,
1431 VTY_NEWLINE);
1432
1433 } /* scan group sources */
1434 } /* scan igmp groups */
1435 } /* scan igmp sockets */
1436 } /* scan interfaces */
1437}
1438
1439static void igmp_show_source_retransmission(struct vty *vty)
1440{
1441 struct listnode *ifnode;
1442 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001443
1444 vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
1445
1446 /* scan interfaces */
1447 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1448 struct pim_interface *pim_ifp = ifp->info;
1449 struct listnode *sock_node;
1450 struct igmp_sock *igmp;
1451
1452 if (!pim_ifp)
1453 continue;
1454
1455 /* scan igmp sockets */
1456 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1457 char ifaddr_str[100];
1458 struct listnode *grpnode;
1459 struct igmp_group *grp;
1460
1461 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1462
1463 /* scan igmp groups */
1464 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1465 char group_str[100];
1466 struct listnode *srcnode;
1467 struct igmp_source *src;
1468
1469 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1470
1471 /* scan group sources */
1472 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1473 char source_str[100];
1474
1475 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1476
1477 vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
1478 ifp->name,
1479 ifaddr_str,
1480 group_str,
1481 source_str,
1482 src->source_query_retransmit_count,
1483 VTY_NEWLINE);
1484
1485 } /* scan group sources */
1486 } /* scan igmp groups */
1487 } /* scan igmp sockets */
1488 } /* scan interfaces */
1489}
1490
1491static void clear_igmp_interfaces()
1492{
1493 struct listnode *ifnode;
1494 struct listnode *ifnextnode;
1495 struct interface *ifp;
1496
1497 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1498 pim_if_addr_del_all_igmp(ifp);
1499 }
1500
1501 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1502 pim_if_addr_add_all(ifp);
1503 }
1504}
1505
1506static void clear_pim_interfaces()
1507{
1508 struct listnode *ifnode;
1509 struct listnode *ifnextnode;
1510 struct interface *ifp;
1511
1512 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1513 if (ifp->info) {
1514 pim_neighbor_delete_all(ifp, "interface cleared");
1515 }
1516 }
1517}
1518
1519static void clear_interfaces()
1520{
1521 clear_igmp_interfaces();
1522 clear_pim_interfaces();
1523}
1524
1525DEFUN (pim_interface,
1526 pim_interface_cmd,
1527 "interface IFNAME",
1528 "Select an interface to configure\n"
1529 "Interface's name\n")
1530{
1531 struct interface *ifp;
1532 const char *ifname = argv[0];
1533 size_t sl;
1534
1535 sl = strlen(ifname);
1536 if (sl > INTERFACE_NAMSIZ) {
1537 vty_out(vty, "%% Interface name %s is invalid: length exceeds "
1538 "%d characters%s",
1539 ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
1540 return CMD_WARNING;
1541 }
1542
1543 ifp = if_lookup_by_name_len(ifname, sl);
1544 if (!ifp) {
1545 vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
1546
1547 /* Returning here would prevent pimd from booting when there are
1548 interface commands in pimd.conf, since all interfaces are
1549 unknown at pimd boot time (the zebra daemon has not been
1550 contacted for interface discovery). */
1551
1552 ifp = if_get_by_name_len(ifname, sl);
1553 if (!ifp) {
1554 vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
1555 return CMD_WARNING;
1556 }
1557 }
1558
1559 vty->index = ifp;
1560 vty->node = INTERFACE_NODE;
1561
1562 return CMD_SUCCESS;
1563}
1564
1565DEFUN (clear_ip_interfaces,
1566 clear_ip_interfaces_cmd,
1567 "clear ip interfaces",
1568 CLEAR_STR
1569 IP_STR
1570 "Reset interfaces\n")
1571{
1572 clear_interfaces();
1573
1574 return CMD_SUCCESS;
1575}
1576
1577DEFUN (clear_ip_igmp_interfaces,
1578 clear_ip_igmp_interfaces_cmd,
1579 "clear ip igmp interfaces",
1580 CLEAR_STR
1581 IP_STR
1582 CLEAR_IP_IGMP_STR
1583 "Reset IGMP interfaces\n")
1584{
1585 clear_igmp_interfaces();
1586
1587 return CMD_SUCCESS;
1588}
1589
Everton Marquesf24200d2014-02-14 16:40:34 -02001590static void mroute_add_all()
1591{
1592 struct listnode *node;
1593 struct channel_oil *c_oil;
1594
1595 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1596 if (pim_mroute_add(&c_oil->oil)) {
1597 /* just log warning */
1598 char source_str[100];
1599 char group_str[100];
1600 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1601 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1602 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
1603 __FILE__, __PRETTY_FUNCTION__,
1604 source_str, group_str);
1605 }
1606 }
1607}
1608
1609static void mroute_del_all()
1610{
1611 struct listnode *node;
1612 struct channel_oil *c_oil;
1613
1614 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1615 if (pim_mroute_del(&c_oil->oil)) {
1616 /* just log warning */
1617 char source_str[100];
1618 char group_str[100];
1619 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1620 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1621 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
1622 __FILE__, __PRETTY_FUNCTION__,
1623 source_str, group_str);
1624 }
1625 }
1626}
1627
1628DEFUN (clear_ip_mroute,
1629 clear_ip_mroute_cmd,
1630 "clear ip mroute",
1631 CLEAR_STR
1632 IP_STR
1633 "Reset multicast routes\n")
1634{
1635 mroute_del_all();
1636 mroute_add_all();
1637
1638 return CMD_SUCCESS;
1639}
1640
Everton Marques871dbcf2009-08-11 15:43:05 -03001641DEFUN (clear_ip_pim_interfaces,
1642 clear_ip_pim_interfaces_cmd,
1643 "clear ip pim interfaces",
1644 CLEAR_STR
1645 IP_STR
1646 CLEAR_IP_PIM_STR
1647 "Reset PIM interfaces\n")
1648{
1649 clear_pim_interfaces();
1650
1651 return CMD_SUCCESS;
1652}
1653
Everton Marquesf24200d2014-02-14 16:40:34 -02001654DEFUN (clear_ip_pim_oil,
1655 clear_ip_pim_oil_cmd,
1656 "clear ip pim oil",
1657 CLEAR_STR
1658 IP_STR
1659 CLEAR_IP_PIM_STR
1660 "Rescan PIM OIL (output interface list)\n")
1661{
1662 pim_scan_oil();
1663
1664 return CMD_SUCCESS;
1665}
1666
Everton Marques871dbcf2009-08-11 15:43:05 -03001667DEFUN (show_ip_igmp_interface,
1668 show_ip_igmp_interface_cmd,
1669 "show ip igmp interface",
1670 SHOW_STR
1671 IP_STR
1672 IGMP_STR
1673 "IGMP interface information\n")
1674{
1675 igmp_show_interfaces(vty);
1676
1677 return CMD_SUCCESS;
1678}
1679
Everton Marques567f9272010-02-19 19:07:00 -02001680DEFUN (show_ip_igmp_join,
1681 show_ip_igmp_join_cmd,
1682 "show ip igmp join",
1683 SHOW_STR
1684 IP_STR
1685 IGMP_STR
1686 "IGMP static join information\n")
1687{
1688 igmp_show_interface_join(vty);
1689
1690 return CMD_SUCCESS;
1691}
1692
Everton Marques871dbcf2009-08-11 15:43:05 -03001693DEFUN (show_ip_igmp_groups,
1694 show_ip_igmp_groups_cmd,
1695 "show ip igmp groups",
1696 SHOW_STR
1697 IP_STR
1698 IGMP_STR
1699 IGMP_GROUP_STR)
1700{
1701 igmp_show_groups(vty);
1702
1703 return CMD_SUCCESS;
1704}
1705
1706DEFUN (show_ip_igmp_groups_retransmissions,
1707 show_ip_igmp_groups_retransmissions_cmd,
1708 "show ip igmp groups retransmissions",
1709 SHOW_STR
1710 IP_STR
1711 IGMP_STR
1712 IGMP_GROUP_STR
1713 "IGMP group retransmissions\n")
1714{
1715 igmp_show_group_retransmission(vty);
1716
1717 return CMD_SUCCESS;
1718}
1719
1720DEFUN (show_ip_igmp_parameters,
1721 show_ip_igmp_parameters_cmd,
1722 "show ip igmp parameters",
1723 SHOW_STR
1724 IP_STR
1725 IGMP_STR
1726 "IGMP parameters information\n")
1727{
1728 igmp_show_parameters(vty);
1729
1730 return CMD_SUCCESS;
1731}
1732
1733DEFUN (show_ip_igmp_sources,
1734 show_ip_igmp_sources_cmd,
1735 "show ip igmp sources",
1736 SHOW_STR
1737 IP_STR
1738 IGMP_STR
1739 IGMP_SOURCE_STR)
1740{
1741 igmp_show_sources(vty);
1742
1743 return CMD_SUCCESS;
1744}
1745
1746DEFUN (show_ip_igmp_sources_retransmissions,
1747 show_ip_igmp_sources_retransmissions_cmd,
1748 "show ip igmp sources retransmissions",
1749 SHOW_STR
1750 IP_STR
1751 IGMP_STR
1752 IGMP_SOURCE_STR
1753 "IGMP source retransmissions\n")
1754{
1755 igmp_show_source_retransmission(vty);
1756
1757 return CMD_SUCCESS;
1758}
1759
1760DEFUN (show_ip_igmp_querier,
1761 show_ip_igmp_querier_cmd,
1762 "show ip igmp querier",
1763 SHOW_STR
1764 IP_STR
1765 IGMP_STR
1766 "IGMP querier information\n")
1767{
1768 igmp_show_querier(vty);
1769
1770 return CMD_SUCCESS;
1771}
1772
1773DEFUN (show_ip_pim_address,
1774 show_ip_pim_address_cmd,
1775 "show ip pim address",
1776 SHOW_STR
1777 IP_STR
1778 PIM_STR
1779 "PIM interface address\n")
1780{
1781 show_interface_address(vty);
1782
1783 return CMD_SUCCESS;
1784}
1785
1786DEFUN (show_ip_pim_assert,
1787 show_ip_pim_assert_cmd,
1788 "show ip pim assert",
1789 SHOW_STR
1790 IP_STR
1791 PIM_STR
1792 "PIM interface assert\n")
1793{
1794 pim_show_assert(vty);
1795
1796 return CMD_SUCCESS;
1797}
1798
1799DEFUN (show_ip_pim_assert_internal,
1800 show_ip_pim_assert_internal_cmd,
1801 "show ip pim assert-internal",
1802 SHOW_STR
1803 IP_STR
1804 PIM_STR
1805 "PIM interface internal assert state\n")
1806{
1807 pim_show_assert_internal(vty);
1808
1809 return CMD_SUCCESS;
1810}
1811
1812DEFUN (show_ip_pim_assert_metric,
1813 show_ip_pim_assert_metric_cmd,
1814 "show ip pim assert-metric",
1815 SHOW_STR
1816 IP_STR
1817 PIM_STR
1818 "PIM interface assert metric\n")
1819{
1820 pim_show_assert_metric(vty);
1821
1822 return CMD_SUCCESS;
1823}
1824
1825DEFUN (show_ip_pim_assert_winner_metric,
1826 show_ip_pim_assert_winner_metric_cmd,
1827 "show ip pim assert-winner-metric",
1828 SHOW_STR
1829 IP_STR
1830 PIM_STR
1831 "PIM interface assert winner metric\n")
1832{
1833 pim_show_assert_winner_metric(vty);
1834
1835 return CMD_SUCCESS;
1836}
1837
1838DEFUN (show_ip_pim_dr,
1839 show_ip_pim_dr_cmd,
1840 "show ip pim designated-router",
1841 SHOW_STR
1842 IP_STR
1843 PIM_STR
1844 "PIM interface designated router\n")
1845{
1846 pim_show_dr(vty);
1847
1848 return CMD_SUCCESS;
1849}
1850
1851DEFUN (show_ip_pim_hello,
1852 show_ip_pim_hello_cmd,
1853 "show ip pim hello",
1854 SHOW_STR
1855 IP_STR
1856 PIM_STR
1857 "PIM interface hello information\n")
1858{
1859 pim_show_hello(vty);
1860
1861 return CMD_SUCCESS;
1862}
1863
1864DEFUN (show_ip_pim_interface,
1865 show_ip_pim_interface_cmd,
1866 "show ip pim interface",
1867 SHOW_STR
1868 IP_STR
1869 PIM_STR
1870 "PIM interface information\n")
1871{
1872 pim_show_interfaces(vty);
1873
1874 return CMD_SUCCESS;
1875}
1876
1877DEFUN (show_ip_pim_join,
1878 show_ip_pim_join_cmd,
1879 "show ip pim join",
1880 SHOW_STR
1881 IP_STR
1882 PIM_STR
1883 "PIM interface join information\n")
1884{
1885 pim_show_join(vty);
1886
1887 return CMD_SUCCESS;
1888}
1889
1890DEFUN (show_ip_pim_lan_prune_delay,
1891 show_ip_pim_lan_prune_delay_cmd,
1892 "show ip pim lan-prune-delay",
1893 SHOW_STR
1894 IP_STR
1895 PIM_STR
1896 "PIM neighbors LAN prune delay parameters\n")
1897{
1898 pim_show_lan_prune_delay(vty);
1899
1900 return CMD_SUCCESS;
1901}
1902
1903DEFUN (show_ip_pim_local_membership,
1904 show_ip_pim_local_membership_cmd,
1905 "show ip pim local-membership",
1906 SHOW_STR
1907 IP_STR
1908 PIM_STR
1909 "PIM interface local-membership\n")
1910{
1911 pim_show_membership(vty);
1912
1913 return CMD_SUCCESS;
1914}
1915
1916DEFUN (show_ip_pim_jp_override_interval,
1917 show_ip_pim_jp_override_interval_cmd,
1918 "show ip pim jp-override-interval",
1919 SHOW_STR
1920 IP_STR
1921 PIM_STR
1922 "PIM interface J/P override interval\n")
1923{
1924 pim_show_jp_override_interval(vty);
1925
1926 return CMD_SUCCESS;
1927}
1928
1929DEFUN (show_ip_pim_neighbor,
1930 show_ip_pim_neighbor_cmd,
1931 "show ip pim neighbor",
1932 SHOW_STR
1933 IP_STR
1934 PIM_STR
1935 "PIM neighbor information\n")
1936{
1937 pim_show_neighbors(vty);
1938
1939 return CMD_SUCCESS;
1940}
1941
1942DEFUN (show_ip_pim_secondary,
1943 show_ip_pim_secondary_cmd,
1944 "show ip pim secondary",
1945 SHOW_STR
1946 IP_STR
1947 PIM_STR
1948 "PIM neighbor addresses\n")
1949{
1950 pim_show_neighbors_secondary(vty);
1951
1952 return CMD_SUCCESS;
1953}
1954
1955DEFUN (show_ip_pim_upstream,
1956 show_ip_pim_upstream_cmd,
1957 "show ip pim upstream",
1958 SHOW_STR
1959 IP_STR
1960 PIM_STR
1961 "PIM upstream information\n")
1962{
1963 pim_show_upstream(vty);
1964
1965 return CMD_SUCCESS;
1966}
1967
1968DEFUN (show_ip_pim_upstream_join_desired,
1969 show_ip_pim_upstream_join_desired_cmd,
1970 "show ip pim upstream-join-desired",
1971 SHOW_STR
1972 IP_STR
1973 PIM_STR
1974 "PIM upstream join-desired\n")
1975{
1976 pim_show_join_desired(vty);
1977
1978 return CMD_SUCCESS;
1979}
1980
1981DEFUN (show_ip_pim_upstream_rpf,
1982 show_ip_pim_upstream_rpf_cmd,
1983 "show ip pim upstream-rpf",
1984 SHOW_STR
1985 IP_STR
1986 PIM_STR
1987 "PIM upstream source rpf\n")
1988{
1989 pim_show_upstream_rpf(vty);
1990
1991 return CMD_SUCCESS;
1992}
1993
1994DEFUN (show_ip_pim_rpf,
1995 show_ip_pim_rpf_cmd,
1996 "show ip pim rpf",
1997 SHOW_STR
1998 IP_STR
1999 PIM_STR
2000 "PIM cached source rpf information\n")
2001{
2002 pim_show_rpf(vty);
2003
2004 return CMD_SUCCESS;
2005}
2006
2007static void show_multicast_interfaces(struct vty *vty)
2008{
2009 struct listnode *node;
2010 struct interface *ifp;
2011
2012 vty_out(vty, "%s", VTY_NEWLINE);
2013
Everton Marques613938d2009-08-13 15:39:31 -03002014 vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03002015 VTY_NEWLINE);
2016
2017 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
2018 struct pim_interface *pim_ifp;
2019 struct in_addr ifaddr;
2020 struct sioc_vif_req vreq;
2021
2022 pim_ifp = ifp->info;
2023
2024 if (!pim_ifp)
2025 continue;
2026
2027 memset(&vreq, 0, sizeof(vreq));
2028 vreq.vifi = pim_ifp->mroute_vif_index;
2029
2030 if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
2031 int e = errno;
2032 vty_out(vty,
2033 "ioctl(SIOCGETVIFCNT=%d) failure for interface %s vif_index=%d: errno=%d: %s%s",
2034 SIOCGETVIFCNT,
2035 ifp->name,
2036 pim_ifp->mroute_vif_index,
2037 e,
Everton Marquese96f0af2009-08-11 15:48:02 -03002038 safe_strerror(e),
Everton Marques871dbcf2009-08-11 15:43:05 -03002039 VTY_NEWLINE);
2040 continue;
2041 }
2042
2043 ifaddr = pim_ifp->primary_address;
2044
Everton Marques613938d2009-08-13 15:39:31 -03002045 vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03002046 ifp->name,
2047 inet_ntoa(ifaddr),
2048 ifp->ifindex,
2049 pim_ifp->mroute_vif_index,
2050 vreq.icount,
2051 vreq.ocount,
2052 vreq.ibytes,
2053 vreq.obytes,
2054 VTY_NEWLINE);
2055 }
2056}
2057
2058DEFUN (show_ip_multicast,
2059 show_ip_multicast_cmd,
2060 "show ip multicast",
2061 SHOW_STR
2062 IP_STR
2063 "Multicast global information\n")
2064{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03002065 time_t now = pim_time_monotonic_sec();
2066
Everton Marques871dbcf2009-08-11 15:43:05 -03002067 if (PIM_MROUTE_IS_ENABLED) {
Everton Marques871dbcf2009-08-11 15:43:05 -03002068 char uptime[10];
2069
2070 vty_out(vty, "Mroute socket descriptor: %d%s",
2071 qpim_mroute_socket_fd,
2072 VTY_NEWLINE);
2073
Everton Marques871dbcf2009-08-11 15:43:05 -03002074 pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
2075 vty_out(vty, "Mroute socket uptime: %s%s",
2076 uptime,
2077 VTY_NEWLINE);
2078 }
2079 else {
2080 vty_out(vty, "Multicast disabled%s",
2081 VTY_NEWLINE);
2082 }
2083
2084 vty_out(vty, "%s", VTY_NEWLINE);
2085 vty_out(vty, "Current highest VifIndex: %d%s",
2086 qpim_mroute_oif_highest_vif_index,
2087 VTY_NEWLINE);
2088 vty_out(vty, "Maximum highest VifIndex: %d%s",
2089 MAXVIFS - 1,
2090 VTY_NEWLINE);
2091
2092 vty_out(vty, "%s", VTY_NEWLINE);
2093 vty_out(vty, "Upstream Join Timer: %d secs%s",
2094 qpim_t_periodic,
2095 VTY_NEWLINE);
2096 vty_out(vty, "Join/Prune Holdtime: %d secs%s",
2097 PIM_JP_HOLDTIME,
2098 VTY_NEWLINE);
2099
2100 vty_out(vty, "%s", VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03002101
Everton Marquesbcc4abe2009-08-17 18:18:59 -03002102 show_rpf_refresh_stats(vty, now);
Everton Marques871dbcf2009-08-11 15:43:05 -03002103
Everton Marquesf24200d2014-02-14 16:40:34 -02002104 vty_out(vty, "%s", VTY_NEWLINE);
2105
2106 show_scan_oil_stats(vty, now);
2107
Everton Marques871dbcf2009-08-11 15:43:05 -03002108 show_multicast_interfaces(vty);
2109
2110 return CMD_SUCCESS;
2111}
2112
2113static void show_mroute(struct vty *vty)
2114{
2115 struct listnode *node;
2116 struct channel_oil *c_oil;
2117 time_t now;
2118
2119 vty_out(vty, "Proto: I=IGMP P=PIM%s%s", VTY_NEWLINE, VTY_NEWLINE);
2120
2121 vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
2122 VTY_NEWLINE);
2123
2124 now = pim_time_monotonic_sec();
2125
2126 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2127 char group_str[100];
2128 char source_str[100];
2129 int oif_vif_index;
2130
2131 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2132 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2133
2134 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2135 struct interface *ifp_in;
2136 struct interface *ifp_out;
2137 char oif_uptime[10];
2138 int ttl;
2139 char proto[5];
2140
2141 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
2142 if (ttl < 1)
2143 continue;
2144
2145 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
2146 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2147
2148 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
2149
2150 proto[0] = '\0';
2151 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
2152 strcat(proto, "P");
2153 }
2154 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
2155 strcat(proto, "I");
2156 }
2157
2158 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2159 source_str,
2160 group_str,
2161 proto,
2162 ifp_in ? ifp_in->name : "<iif?>",
2163 c_oil->oil.mfcc_parent,
2164 ifp_out ? ifp_out->name : "<oif?>",
2165 oif_vif_index,
2166 ttl,
2167 oif_uptime,
2168 VTY_NEWLINE);
2169 }
2170 }
2171}
2172
2173DEFUN (show_ip_mroute,
2174 show_ip_mroute_cmd,
2175 "show ip mroute",
2176 SHOW_STR
2177 IP_STR
2178 MROUTE_STR)
2179{
2180 show_mroute(vty);
2181 return CMD_SUCCESS;
2182}
2183
2184static void show_mroute_count(struct vty *vty)
2185{
2186 struct listnode *node;
2187 struct channel_oil *c_oil;
2188
2189 vty_out(vty, "%s", VTY_NEWLINE);
2190
2191 vty_out(vty, "Source Group Packets Bytes WrongIf %s",
2192 VTY_NEWLINE);
2193
2194 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2195 char group_str[100];
2196 char source_str[100];
2197 struct sioc_sg_req sgreq;
2198
2199 memset(&sgreq, 0, sizeof(sgreq));
2200 sgreq.src = c_oil->oil.mfcc_origin;
2201 sgreq.grp = c_oil->oil.mfcc_mcastgrp;
2202
2203 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2204 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2205
2206 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2207 int e = errno;
2208 vty_out(vty,
2209 "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2210 SIOCGETSGCNT,
2211 source_str,
2212 group_str,
2213 e,
Everton Marquese96f0af2009-08-11 15:48:02 -03002214 safe_strerror(e),
Everton Marques871dbcf2009-08-11 15:43:05 -03002215 VTY_NEWLINE);
2216 continue;
2217 }
2218
2219 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2220 source_str,
2221 group_str,
2222 sgreq.pktcnt,
2223 sgreq.bytecnt,
2224 sgreq.wrong_if,
2225 VTY_NEWLINE);
2226
2227 }
2228}
2229
2230DEFUN (show_ip_mroute_count,
2231 show_ip_mroute_count_cmd,
2232 "show ip mroute count",
2233 SHOW_STR
2234 IP_STR
2235 MROUTE_STR
2236 "Route and packet count data\n")
2237{
2238 show_mroute_count(vty);
2239 return CMD_SUCCESS;
2240}
2241
Everton Marques05e573d2010-04-20 12:20:46 -03002242DEFUN (show_ip_rib,
2243 show_ip_rib_cmd,
2244 "show ip rib A.B.C.D",
Everton Marques871dbcf2009-08-11 15:43:05 -03002245 SHOW_STR
2246 IP_STR
Everton Marques05e573d2010-04-20 12:20:46 -03002247 RIB_STR
Everton Marques871dbcf2009-08-11 15:43:05 -03002248 "Unicast address\n")
2249{
2250 struct in_addr addr;
2251 const char *addr_str;
2252 struct pim_nexthop nexthop;
2253 char nexthop_addr_str[100];
2254 int result;
2255
2256 addr_str = argv[0];
2257 result = inet_pton(AF_INET, addr_str, &addr);
2258 if (result <= 0) {
2259 vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002260 addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002261 return CMD_WARNING;
2262 }
2263
2264 if (pim_nexthop_lookup(&nexthop, addr)) {
2265 vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
2266 addr_str, VTY_NEWLINE);
2267 return CMD_WARNING;
2268 }
2269
2270 vty_out(vty, "Address NextHop Interface Metric Preference%s",
2271 VTY_NEWLINE);
2272
2273 pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
2274 nexthop_addr_str, sizeof(nexthop_addr_str));
2275
2276 vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
2277 addr_str,
2278 nexthop_addr_str,
2279 nexthop.interface ? nexthop.interface->name : "<ifname?>",
2280 nexthop.mrib_route_metric,
2281 nexthop.mrib_metric_preference,
2282 VTY_NEWLINE);
2283
2284 return CMD_SUCCESS;
2285}
2286
Everton Marques824adbe2009-10-08 09:16:27 -03002287static void show_ssmpingd(struct vty *vty)
2288{
2289 struct listnode *node;
2290 struct ssmpingd_sock *ss;
2291 time_t now;
2292
Everton Marquese8c11bb2009-10-08 15:06:32 -03002293 vty_out(vty, "Source Socket Address Port Uptime Requests%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002294 VTY_NEWLINE);
2295
2296 if (!qpim_ssmpingd_list)
2297 return;
2298
2299 now = pim_time_monotonic_sec();
2300
2301 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
2302 char source_str[100];
2303 char ss_uptime[10];
Everton Marquese8c11bb2009-10-08 15:06:32 -03002304 struct sockaddr_in bind_addr;
David Lampartere269b962012-02-16 04:32:08 +00002305 socklen_t len = sizeof(bind_addr);
Everton Marquese8c11bb2009-10-08 15:06:32 -03002306 char bind_addr_str[100];
Everton Marques824adbe2009-10-08 09:16:27 -03002307
2308 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
Everton Marquese8c11bb2009-10-08 15:06:32 -03002309
2310 if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
2311 vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
2312 source_str, ss->sock_fd, VTY_NEWLINE);
2313 }
2314
2315 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
Everton Marques824adbe2009-10-08 09:16:27 -03002316 pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
2317
Everton Marquese8c11bb2009-10-08 15:06:32 -03002318 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002319 source_str,
2320 ss->sock_fd,
Everton Marquese8c11bb2009-10-08 15:06:32 -03002321 bind_addr_str,
2322 ntohs(bind_addr.sin_port),
Everton Marques824adbe2009-10-08 09:16:27 -03002323 ss_uptime,
David Lamparter5c697982012-02-16 04:47:56 +01002324 (long long)ss->requests,
Everton Marques824adbe2009-10-08 09:16:27 -03002325 VTY_NEWLINE);
2326 }
2327}
2328
2329DEFUN (show_ip_ssmpingd,
2330 show_ip_ssmpingd_cmd,
2331 "show ip ssmpingd",
2332 SHOW_STR
2333 IP_STR
2334 SHOW_SSMPINGD_STR)
2335{
2336 show_ssmpingd(vty);
2337 return CMD_SUCCESS;
2338}
2339
Everton Marques871dbcf2009-08-11 15:43:05 -03002340DEFUN (ip_multicast_routing,
2341 ip_multicast_routing_cmd,
2342 PIM_CMD_IP_MULTICAST_ROUTING,
2343 IP_STR
2344 "Enable IP multicast forwarding\n")
2345{
2346 pim_mroute_socket_enable();
2347 pim_if_add_vif_all();
2348 mroute_add_all();
2349 return CMD_SUCCESS;
2350}
2351
2352DEFUN (no_ip_multicast_routing,
2353 no_ip_multicast_routing_cmd,
2354 PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
2355 NO_STR
2356 IP_STR
2357 "Global IP configuration subcommands\n"
2358 "Enable IP multicast forwarding\n")
2359{
2360 mroute_del_all();
2361 pim_if_del_vif_all();
2362 pim_mroute_socket_disable();
2363 return CMD_SUCCESS;
2364}
2365
Everton Marques96f91ae2009-10-07 18:41:45 -03002366DEFUN (ip_ssmpingd,
2367 ip_ssmpingd_cmd,
2368 "ip ssmpingd [A.B.C.D]",
2369 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002370 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002371 "Source address\n")
2372{
2373 int result;
2374 struct in_addr source_addr;
2375 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2376
2377 result = inet_pton(AF_INET, source_str, &source_addr);
2378 if (result <= 0) {
2379 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2380 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2381 return CMD_WARNING;
2382 }
2383
2384 result = pim_ssmpingd_start(source_addr);
2385 if (result) {
2386 vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
2387 source_str, result, VTY_NEWLINE);
2388 return CMD_WARNING;
2389 }
2390
2391 return CMD_SUCCESS;
2392}
2393
2394DEFUN (no_ip_ssmpingd,
2395 no_ip_ssmpingd_cmd,
2396 "no ip ssmpingd [A.B.C.D]",
2397 NO_STR
2398 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002399 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002400 "Source address\n")
2401{
2402 int result;
2403 struct in_addr source_addr;
2404 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2405
2406 result = inet_pton(AF_INET, source_str, &source_addr);
2407 if (result <= 0) {
2408 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2409 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2410 return CMD_WARNING;
2411 }
2412
2413 result = pim_ssmpingd_stop(source_addr);
2414 if (result) {
2415 vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
2416 source_str, result, VTY_NEWLINE);
2417 return CMD_WARNING;
2418 }
2419
2420 return CMD_SUCCESS;
2421}
2422
Everton Marques871dbcf2009-08-11 15:43:05 -03002423DEFUN (interface_ip_igmp,
2424 interface_ip_igmp_cmd,
2425 "ip igmp",
2426 IP_STR
2427 IFACE_IGMP_STR)
2428{
2429 struct interface *ifp;
2430 struct pim_interface *pim_ifp;
2431
2432 ifp = vty->index;
2433 pim_ifp = ifp->info;
2434
2435 if (!pim_ifp) {
2436 pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
2437 if (!pim_ifp) {
2438 vty_out(vty, "Could not enable IGMP on interface %s%s",
2439 ifp->name, VTY_NEWLINE);
2440 return CMD_WARNING;
2441 }
2442 }
2443 else {
2444 PIM_IF_DO_IGMP(pim_ifp->options);
2445 }
2446
2447 pim_if_addr_add_all(ifp);
2448 pim_if_membership_refresh(ifp);
2449
2450 return CMD_SUCCESS;
2451}
2452
2453DEFUN (interface_no_ip_igmp,
2454 interface_no_ip_igmp_cmd,
2455 "no ip igmp",
2456 NO_STR
2457 IP_STR
2458 IFACE_IGMP_STR)
2459{
2460 struct interface *ifp;
2461 struct pim_interface *pim_ifp;
2462
2463 ifp = vty->index;
2464 pim_ifp = ifp->info;
2465 if (!pim_ifp)
2466 return CMD_SUCCESS;
2467
2468 PIM_IF_DONT_IGMP(pim_ifp->options);
2469
2470 pim_if_membership_clear(ifp);
2471
2472 pim_if_addr_del_all(ifp);
2473
2474 if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
2475 pim_if_delete(ifp);
2476 }
2477
2478 return CMD_SUCCESS;
2479}
2480
2481DEFUN (interface_ip_igmp_join,
2482 interface_ip_igmp_join_cmd,
2483 "ip igmp join A.B.C.D A.B.C.D",
2484 IP_STR
2485 IFACE_IGMP_STR
2486 "IGMP join multicast group\n"
2487 "Multicast group address\n"
2488 "Source address\n")
2489{
2490 struct interface *ifp;
2491 const char *group_str;
2492 const char *source_str;
2493 struct in_addr group_addr;
2494 struct in_addr source_addr;
2495 int result;
2496
2497 ifp = vty->index;
2498
2499 /* Group address */
2500 group_str = argv[0];
2501 result = inet_pton(AF_INET, group_str, &group_addr);
2502 if (result <= 0) {
2503 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002504 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002505 return CMD_WARNING;
2506 }
2507
2508 /* Source address */
2509 source_str = argv[1];
2510 result = inet_pton(AF_INET, source_str, &source_addr);
2511 if (result <= 0) {
2512 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002513 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002514 return CMD_WARNING;
2515 }
2516
2517 result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
2518 if (result) {
2519 vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
2520 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2521 return CMD_WARNING;
2522 }
2523
2524 return CMD_SUCCESS;
2525}
2526
2527DEFUN (interface_no_ip_igmp_join,
2528 interface_no_ip_igmp_join_cmd,
2529 "no ip igmp join A.B.C.D A.B.C.D",
2530 NO_STR
2531 IP_STR
2532 IFACE_IGMP_STR
2533 "IGMP join multicast group\n"
2534 "Multicast group address\n"
2535 "Source address\n")
2536{
2537 struct interface *ifp;
2538 const char *group_str;
2539 const char *source_str;
2540 struct in_addr group_addr;
2541 struct in_addr source_addr;
2542 int result;
2543
2544 ifp = vty->index;
2545
2546 /* Group address */
2547 group_str = argv[0];
2548 result = inet_pton(AF_INET, group_str, &group_addr);
2549 if (result <= 0) {
2550 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002551 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002552 return CMD_WARNING;
2553 }
2554
2555 /* Source address */
2556 source_str = argv[1];
2557 result = inet_pton(AF_INET, source_str, &source_addr);
2558 if (result <= 0) {
2559 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002560 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002561 return CMD_WARNING;
2562 }
2563
2564 result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
2565 if (result) {
2566 vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
2567 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2568 return CMD_WARNING;
2569 }
2570
2571 return CMD_SUCCESS;
2572}
2573
2574/*
2575 CLI reconfiguration affects the interface level (struct pim_interface).
2576 This function propagates the reconfiguration to every active socket
2577 for that interface.
2578 */
2579static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
2580{
2581 struct interface *ifp;
2582 struct pim_interface *pim_ifp;
2583
2584 zassert(igmp);
2585
2586 /* other querier present? */
2587
2588 if (igmp->t_other_querier_timer)
2589 return;
2590
2591 /* this is the querier */
2592
2593 zassert(igmp->interface);
2594 zassert(igmp->interface->info);
2595
2596 ifp = igmp->interface;
2597 pim_ifp = ifp->info;
2598
2599 if (PIM_DEBUG_IGMP_TRACE) {
2600 char ifaddr_str[100];
2601 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2602 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
2603 __PRETTY_FUNCTION__,
2604 ifaddr_str,
2605 ifp->name,
2606 pim_ifp->igmp_default_query_interval);
2607 }
2608
2609 /*
2610 igmp_startup_mode_on() will reset QQI:
2611
2612 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
2613 */
2614 igmp_startup_mode_on(igmp);
2615}
2616
2617static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
2618{
2619 if (igmp->t_igmp_query_timer) {
2620 /* other querier present */
2621 zassert(igmp->t_igmp_query_timer);
2622 zassert(!igmp->t_other_querier_timer);
2623
2624 pim_igmp_general_query_off(igmp);
2625 pim_igmp_general_query_on(igmp);
2626
2627 zassert(igmp->t_igmp_query_timer);
2628 zassert(!igmp->t_other_querier_timer);
2629 }
2630 else {
2631 /* this is the querier */
2632
2633 zassert(!igmp->t_igmp_query_timer);
2634 zassert(igmp->t_other_querier_timer);
2635
2636 pim_igmp_other_querier_timer_off(igmp);
2637 pim_igmp_other_querier_timer_on(igmp);
2638
2639 zassert(!igmp->t_igmp_query_timer);
2640 zassert(igmp->t_other_querier_timer);
2641 }
2642}
2643
2644static void change_query_interval(struct pim_interface *pim_ifp,
2645 int query_interval)
2646{
2647 struct listnode *sock_node;
2648 struct igmp_sock *igmp;
2649
2650 pim_ifp->igmp_default_query_interval = query_interval;
2651
2652 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2653 igmp_sock_query_interval_reconfig(igmp);
2654 igmp_sock_query_reschedule(igmp);
2655 }
2656}
2657
2658static void change_query_max_response_time(struct pim_interface *pim_ifp,
2659 int query_max_response_time_dsec)
2660{
2661 struct listnode *sock_node;
2662 struct igmp_sock *igmp;
2663
2664 pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
2665
2666 /*
2667 Below we modify socket/group/source timers in order to quickly
2668 reflect the change. Otherwise, those timers would eventually catch
2669 up.
2670 */
2671
2672 /* scan all sockets */
2673 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2674 struct listnode *grp_node;
2675 struct igmp_group *grp;
2676
2677 /* reschedule socket general query */
2678 igmp_sock_query_reschedule(igmp);
2679
2680 /* scan socket groups */
2681 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
2682 struct listnode *src_node;
2683 struct igmp_source *src;
2684
2685 /* reset group timers for groups in EXCLUDE mode */
2686 if (grp->group_filtermode_isexcl) {
2687 igmp_group_reset_gmi(grp);
2688 }
2689
2690 /* scan group sources */
2691 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
2692
2693 /* reset source timers for sources with running timers */
2694 if (src->t_source_timer) {
2695 igmp_source_reset_gmi(igmp, grp, src);
2696 }
2697 }
2698 }
2699 }
2700}
2701
2702#define IGMP_QUERY_INTERVAL_MIN (1)
2703#define IGMP_QUERY_INTERVAL_MAX (1800)
2704
2705DEFUN (interface_ip_igmp_query_interval,
2706 interface_ip_igmp_query_interval_cmd,
2707 PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
2708 IP_STR
2709 IFACE_IGMP_STR
2710 IFACE_IGMP_QUERY_INTERVAL_STR
2711 "Query interval in seconds\n")
2712{
2713 struct interface *ifp;
2714 struct pim_interface *pim_ifp;
2715 int query_interval;
2716 int query_interval_dsec;
2717
2718 ifp = vty->index;
2719 pim_ifp = ifp->info;
2720
2721 if (!pim_ifp) {
2722 vty_out(vty,
2723 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2724 ifp->name,
2725 VTY_NEWLINE);
2726 return CMD_WARNING;
2727 }
2728
2729 query_interval = atoi(argv[0]);
2730 query_interval_dsec = 10 * query_interval;
2731
2732 /*
2733 It seems we don't need to check bounds since command.c does it
2734 already, but we verify them anyway for extra safety.
2735 */
2736 if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
2737 vty_out(vty, "General query interval %d lower than minimum %d%s",
2738 query_interval,
2739 IGMP_QUERY_INTERVAL_MIN,
2740 VTY_NEWLINE);
2741 return CMD_WARNING;
2742 }
2743 if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
2744 vty_out(vty, "General query interval %d higher than maximum %d%s",
2745 query_interval,
2746 IGMP_QUERY_INTERVAL_MAX,
2747 VTY_NEWLINE);
2748 return CMD_WARNING;
2749 }
2750
2751 if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2752 vty_out(vty,
2753 "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
2754 query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2755 VTY_NEWLINE);
2756 return CMD_WARNING;
2757 }
2758
2759 change_query_interval(pim_ifp, query_interval);
2760
2761 return CMD_SUCCESS;
2762}
2763
2764DEFUN (interface_no_ip_igmp_query_interval,
2765 interface_no_ip_igmp_query_interval_cmd,
2766 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
2767 NO_STR
2768 IP_STR
2769 IFACE_IGMP_STR
2770 IFACE_IGMP_QUERY_INTERVAL_STR)
2771{
2772 struct interface *ifp;
2773 struct pim_interface *pim_ifp;
2774 int default_query_interval_dsec;
2775
2776 ifp = vty->index;
2777 pim_ifp = ifp->info;
2778
2779 if (!pim_ifp)
2780 return CMD_SUCCESS;
2781
2782 default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
2783
2784 if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2785 vty_out(vty,
2786 "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
2787 default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2788 VTY_NEWLINE);
2789 return CMD_WARNING;
2790 }
2791
2792 change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
2793
2794 return CMD_SUCCESS;
2795}
2796
2797#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
2798#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
2799
2800DEFUN (interface_ip_igmp_query_max_response_time,
2801 interface_ip_igmp_query_max_response_time_cmd,
2802 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
2803 IP_STR
2804 IFACE_IGMP_STR
2805 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
2806 "Query response value in seconds\n")
2807{
2808 struct interface *ifp;
2809 struct pim_interface *pim_ifp;
2810 int query_max_response_time;
2811
2812 ifp = vty->index;
2813 pim_ifp = ifp->info;
2814
2815 if (!pim_ifp) {
2816 vty_out(vty,
2817 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2818 ifp->name,
2819 VTY_NEWLINE);
2820 return CMD_WARNING;
2821 }
2822
2823 query_max_response_time = atoi(argv[0]);
2824
2825 /*
2826 It seems we don't need to check bounds since command.c does it
2827 already, but we verify them anyway for extra safety.
2828 */
2829 if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
2830 vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
2831 query_max_response_time,
2832 IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
2833 VTY_NEWLINE);
2834 return CMD_WARNING;
2835 }
2836 if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
2837 vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
2838 query_max_response_time,
2839 IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
2840 VTY_NEWLINE);
2841 return CMD_WARNING;
2842 }
2843
2844 if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
2845 vty_out(vty,
2846 "Can't set query max response time %d sec >= general query interval %d sec%s",
2847 query_max_response_time, pim_ifp->igmp_default_query_interval,
2848 VTY_NEWLINE);
2849 return CMD_WARNING;
2850 }
2851
2852 change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
2853
2854 return CMD_SUCCESS;
2855}
2856
2857DEFUN (interface_no_ip_igmp_query_max_response_time,
2858 interface_no_ip_igmp_query_max_response_time_cmd,
2859 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
2860 NO_STR
2861 IP_STR
2862 IFACE_IGMP_STR
2863 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
2864{
2865 struct interface *ifp;
2866 struct pim_interface *pim_ifp;
2867 int default_query_interval_dsec;
2868
2869 ifp = vty->index;
2870 pim_ifp = ifp->info;
2871
2872 if (!pim_ifp)
2873 return CMD_SUCCESS;
2874
2875 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2876
2877 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
2878 vty_out(vty,
2879 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
2880 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
2881 VTY_NEWLINE);
2882 return CMD_WARNING;
2883 }
2884
2885 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
2886
2887 return CMD_SUCCESS;
2888}
2889
2890#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
2891#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
2892
2893DEFUN (interface_ip_igmp_query_max_response_time_dsec,
2894 interface_ip_igmp_query_max_response_time_dsec_cmd,
2895 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
2896 IP_STR
2897 IFACE_IGMP_STR
2898 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
2899 "Query response value in deciseconds\n")
2900{
2901 struct interface *ifp;
2902 struct pim_interface *pim_ifp;
2903 int query_max_response_time_dsec;
2904 int default_query_interval_dsec;
2905
2906 ifp = vty->index;
2907 pim_ifp = ifp->info;
2908
2909 if (!pim_ifp) {
2910 vty_out(vty,
2911 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2912 ifp->name,
2913 VTY_NEWLINE);
2914 return CMD_WARNING;
2915 }
2916
2917 query_max_response_time_dsec = atoi(argv[0]);
2918
2919 /*
2920 It seems we don't need to check bounds since command.c does it
2921 already, but we verify them anyway for extra safety.
2922 */
2923 if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
2924 vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
2925 query_max_response_time_dsec,
2926 IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
2927 VTY_NEWLINE);
2928 return CMD_WARNING;
2929 }
2930 if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
2931 vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
2932 query_max_response_time_dsec,
2933 IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
2934 VTY_NEWLINE);
2935 return CMD_WARNING;
2936 }
2937
2938 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2939
2940 if (query_max_response_time_dsec >= default_query_interval_dsec) {
2941 vty_out(vty,
2942 "Can't set query max response time %d dsec >= general query interval %d dsec%s",
2943 query_max_response_time_dsec, default_query_interval_dsec,
2944 VTY_NEWLINE);
2945 return CMD_WARNING;
2946 }
2947
2948 change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
2949
2950 return CMD_SUCCESS;
2951}
2952
2953DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
2954 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
2955 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
2956 NO_STR
2957 IP_STR
2958 IFACE_IGMP_STR
2959 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
2960{
2961 struct interface *ifp;
2962 struct pim_interface *pim_ifp;
2963 int default_query_interval_dsec;
2964
2965 ifp = vty->index;
2966 pim_ifp = ifp->info;
2967
2968 if (!pim_ifp)
2969 return CMD_SUCCESS;
2970
2971 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
2972
2973 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
2974 vty_out(vty,
2975 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
2976 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
2977 VTY_NEWLINE);
2978 return CMD_WARNING;
2979 }
2980
2981 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
2982
2983 return CMD_SUCCESS;
2984}
2985
2986DEFUN (interface_ip_pim_ssm,
2987 interface_ip_pim_ssm_cmd,
2988 "ip pim ssm",
2989 IP_STR
2990 PIM_STR
2991 IFACE_PIM_STR)
2992{
2993 struct interface *ifp;
2994 struct pim_interface *pim_ifp;
2995
2996 ifp = vty->index;
2997 pim_ifp = ifp->info;
2998
2999 if (!pim_ifp) {
3000 pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
3001 if (!pim_ifp) {
3002 vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
3003 return CMD_WARNING;
3004 }
3005 }
3006 else {
3007 PIM_IF_DO_PIM(pim_ifp->options);
3008 }
3009
3010 pim_if_addr_add_all(ifp);
3011 pim_if_membership_refresh(ifp);
3012
3013 return CMD_SUCCESS;
3014}
3015
3016DEFUN (interface_no_ip_pim_ssm,
3017 interface_no_ip_pim_ssm_cmd,
3018 "no ip pim ssm",
3019 NO_STR
3020 IP_STR
3021 PIM_STR
3022 IFACE_PIM_STR)
3023{
3024 struct interface *ifp;
3025 struct pim_interface *pim_ifp;
3026
3027 ifp = vty->index;
3028 pim_ifp = ifp->info;
3029 if (!pim_ifp)
3030 return CMD_SUCCESS;
3031
3032 PIM_IF_DONT_PIM(pim_ifp->options);
3033
3034 pim_if_membership_clear(ifp);
3035
3036 /*
3037 pim_if_addr_del_all() removes all sockets from
3038 pim_ifp->igmp_socket_list.
3039 */
3040 pim_if_addr_del_all(ifp);
3041
3042 /*
3043 pim_sock_delete() removes all neighbors from
3044 pim_ifp->pim_neighbor_list.
3045 */
3046 pim_sock_delete(ifp, "pim unconfigured on interface");
3047
3048 if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
3049 pim_if_delete(ifp);
3050 }
3051
3052 return CMD_SUCCESS;
3053}
3054
3055DEFUN (debug_igmp,
3056 debug_igmp_cmd,
3057 "debug igmp",
3058 DEBUG_STR
3059 DEBUG_IGMP_STR)
3060{
3061 PIM_DO_DEBUG_IGMP_EVENTS;
3062 PIM_DO_DEBUG_IGMP_PACKETS;
3063 PIM_DO_DEBUG_IGMP_TRACE;
3064 return CMD_SUCCESS;
3065}
3066
3067DEFUN (no_debug_igmp,
3068 no_debug_igmp_cmd,
3069 "no debug igmp",
3070 NO_STR
3071 DEBUG_STR
3072 DEBUG_IGMP_STR)
3073{
3074 PIM_DONT_DEBUG_IGMP_EVENTS;
3075 PIM_DONT_DEBUG_IGMP_PACKETS;
3076 PIM_DONT_DEBUG_IGMP_TRACE;
3077 return CMD_SUCCESS;
3078}
3079
3080ALIAS (no_debug_igmp,
3081 undebug_igmp_cmd,
3082 "undebug igmp",
3083 UNDEBUG_STR
3084 DEBUG_IGMP_STR)
3085
3086DEFUN (debug_igmp_events,
3087 debug_igmp_events_cmd,
3088 "debug igmp events",
3089 DEBUG_STR
3090 DEBUG_IGMP_STR
3091 DEBUG_IGMP_EVENTS_STR)
3092{
3093 PIM_DO_DEBUG_IGMP_EVENTS;
3094 return CMD_SUCCESS;
3095}
3096
3097DEFUN (no_debug_igmp_events,
3098 no_debug_igmp_events_cmd,
3099 "no debug igmp events",
3100 NO_STR
3101 DEBUG_STR
3102 DEBUG_IGMP_STR
3103 DEBUG_IGMP_EVENTS_STR)
3104{
3105 PIM_DONT_DEBUG_IGMP_EVENTS;
3106 return CMD_SUCCESS;
3107}
3108
3109ALIAS (no_debug_igmp_events,
3110 undebug_igmp_events_cmd,
3111 "undebug igmp events",
3112 UNDEBUG_STR
3113 DEBUG_IGMP_STR
3114 DEBUG_IGMP_EVENTS_STR)
3115
3116DEFUN (debug_igmp_packets,
3117 debug_igmp_packets_cmd,
3118 "debug igmp packets",
3119 DEBUG_STR
3120 DEBUG_IGMP_STR
3121 DEBUG_IGMP_PACKETS_STR)
3122{
3123 PIM_DO_DEBUG_IGMP_PACKETS;
3124 return CMD_SUCCESS;
3125}
3126
3127DEFUN (no_debug_igmp_packets,
3128 no_debug_igmp_packets_cmd,
3129 "no debug igmp packets",
3130 NO_STR
3131 DEBUG_STR
3132 DEBUG_IGMP_STR
3133 DEBUG_IGMP_PACKETS_STR)
3134{
3135 PIM_DONT_DEBUG_IGMP_PACKETS;
3136 return CMD_SUCCESS;
3137}
3138
3139ALIAS (no_debug_igmp_packets,
3140 undebug_igmp_packets_cmd,
3141 "undebug igmp packets",
3142 UNDEBUG_STR
3143 DEBUG_IGMP_STR
3144 DEBUG_IGMP_PACKETS_STR)
3145
3146DEFUN (debug_igmp_trace,
3147 debug_igmp_trace_cmd,
3148 "debug igmp trace",
3149 DEBUG_STR
3150 DEBUG_IGMP_STR
3151 DEBUG_IGMP_TRACE_STR)
3152{
3153 PIM_DO_DEBUG_IGMP_TRACE;
3154 return CMD_SUCCESS;
3155}
3156
3157DEFUN (no_debug_igmp_trace,
3158 no_debug_igmp_trace_cmd,
3159 "no debug igmp trace",
3160 NO_STR
3161 DEBUG_STR
3162 DEBUG_IGMP_STR
3163 DEBUG_IGMP_TRACE_STR)
3164{
3165 PIM_DONT_DEBUG_IGMP_TRACE;
3166 return CMD_SUCCESS;
3167}
3168
3169ALIAS (no_debug_igmp_trace,
3170 undebug_igmp_trace_cmd,
3171 "undebug igmp trace",
3172 UNDEBUG_STR
3173 DEBUG_IGMP_STR
3174 DEBUG_IGMP_TRACE_STR)
3175
Everton Marques67faabc2010-02-23 12:11:11 -03003176DEFUN (debug_mroute,
3177 debug_mroute_cmd,
3178 "debug mroute",
3179 DEBUG_STR
3180 DEBUG_MROUTE_STR)
3181{
3182 PIM_DO_DEBUG_MROUTE;
3183 return CMD_SUCCESS;
3184}
3185
3186DEFUN (no_debug_mroute,
3187 no_debug_mroute_cmd,
3188 "no debug mroute",
3189 NO_STR
3190 DEBUG_STR
3191 DEBUG_MROUTE_STR)
3192{
3193 PIM_DONT_DEBUG_MROUTE;
3194 return CMD_SUCCESS;
3195}
3196
3197ALIAS (no_debug_mroute,
3198 undebug_mroute_cmd,
3199 "undebug mroute",
3200 UNDEBUG_STR
3201 DEBUG_MROUTE_STR)
3202
Everton Marques871dbcf2009-08-11 15:43:05 -03003203DEFUN (debug_pim,
3204 debug_pim_cmd,
3205 "debug pim",
3206 DEBUG_STR
3207 DEBUG_PIM_STR)
3208{
3209 PIM_DO_DEBUG_PIM_EVENTS;
3210 PIM_DO_DEBUG_PIM_PACKETS;
3211 PIM_DO_DEBUG_PIM_TRACE;
3212 return CMD_SUCCESS;
3213}
3214
3215DEFUN (no_debug_pim,
3216 no_debug_pim_cmd,
3217 "no debug pim",
3218 NO_STR
3219 DEBUG_STR
3220 DEBUG_PIM_STR)
3221{
3222 PIM_DONT_DEBUG_PIM_EVENTS;
3223 PIM_DONT_DEBUG_PIM_PACKETS;
3224 PIM_DONT_DEBUG_PIM_TRACE;
Everton Marques62738042009-11-18 10:44:13 -02003225
3226 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3227 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3228
Everton Marques871dbcf2009-08-11 15:43:05 -03003229 return CMD_SUCCESS;
3230}
3231
3232ALIAS (no_debug_pim,
3233 undebug_pim_cmd,
3234 "undebug pim",
3235 UNDEBUG_STR
3236 DEBUG_PIM_STR)
3237
3238DEFUN (debug_pim_events,
3239 debug_pim_events_cmd,
3240 "debug pim events",
3241 DEBUG_STR
3242 DEBUG_PIM_STR
3243 DEBUG_PIM_EVENTS_STR)
3244{
3245 PIM_DO_DEBUG_PIM_EVENTS;
3246 return CMD_SUCCESS;
3247}
3248
3249DEFUN (no_debug_pim_events,
3250 no_debug_pim_events_cmd,
3251 "no debug pim events",
3252 NO_STR
3253 DEBUG_STR
3254 DEBUG_PIM_STR
3255 DEBUG_PIM_EVENTS_STR)
3256{
3257 PIM_DONT_DEBUG_PIM_EVENTS;
3258 return CMD_SUCCESS;
3259}
3260
3261ALIAS (no_debug_pim_events,
3262 undebug_pim_events_cmd,
3263 "undebug pim events",
3264 UNDEBUG_STR
3265 DEBUG_PIM_STR
3266 DEBUG_PIM_EVENTS_STR)
3267
3268DEFUN (debug_pim_packets,
3269 debug_pim_packets_cmd,
3270 "debug pim packets",
3271 DEBUG_STR
3272 DEBUG_PIM_STR
3273 DEBUG_PIM_PACKETS_STR)
3274{
3275 PIM_DO_DEBUG_PIM_PACKETS;
3276 return CMD_SUCCESS;
3277}
3278
3279DEFUN (no_debug_pim_packets,
3280 no_debug_pim_packets_cmd,
3281 "no debug pim packets",
3282 NO_STR
3283 DEBUG_STR
3284 DEBUG_PIM_STR
3285 DEBUG_PIM_PACKETS_STR)
3286{
3287 PIM_DONT_DEBUG_PIM_PACKETS;
3288 return CMD_SUCCESS;
3289}
3290
3291ALIAS (no_debug_pim_packets,
3292 undebug_pim_packets_cmd,
3293 "undebug pim packets",
3294 UNDEBUG_STR
3295 DEBUG_PIM_STR
3296 DEBUG_PIM_PACKETS_STR)
3297
Everton Marques62738042009-11-18 10:44:13 -02003298DEFUN (debug_pim_packetdump_send,
3299 debug_pim_packetdump_send_cmd,
3300 "debug pim packet-dump send",
3301 DEBUG_STR
3302 DEBUG_PIM_STR
3303 DEBUG_PIM_PACKETDUMP_STR
3304 DEBUG_PIM_PACKETDUMP_SEND_STR)
3305{
3306 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
3307 return CMD_SUCCESS;
3308}
3309
3310DEFUN (no_debug_pim_packetdump_send,
3311 no_debug_pim_packetdump_send_cmd,
3312 "no debug pim packet-dump send",
3313 NO_STR
3314 DEBUG_STR
3315 DEBUG_PIM_STR
3316 DEBUG_PIM_PACKETDUMP_STR
3317 DEBUG_PIM_PACKETDUMP_SEND_STR)
3318{
3319 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3320 return CMD_SUCCESS;
3321}
3322
3323ALIAS (no_debug_pim_packetdump_send,
3324 undebug_pim_packetdump_send_cmd,
3325 "undebug pim packet-dump send",
3326 UNDEBUG_STR
3327 DEBUG_PIM_STR
3328 DEBUG_PIM_PACKETDUMP_STR
3329 DEBUG_PIM_PACKETDUMP_SEND_STR)
3330
3331DEFUN (debug_pim_packetdump_recv,
3332 debug_pim_packetdump_recv_cmd,
3333 "debug pim packet-dump receive",
3334 DEBUG_STR
3335 DEBUG_PIM_STR
3336 DEBUG_PIM_PACKETDUMP_STR
3337 DEBUG_PIM_PACKETDUMP_RECV_STR)
3338{
3339 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
3340 return CMD_SUCCESS;
3341}
3342
3343DEFUN (no_debug_pim_packetdump_recv,
3344 no_debug_pim_packetdump_recv_cmd,
3345 "no debug pim packet-dump receive",
3346 NO_STR
3347 DEBUG_STR
3348 DEBUG_PIM_STR
3349 DEBUG_PIM_PACKETDUMP_STR
3350 DEBUG_PIM_PACKETDUMP_RECV_STR)
3351{
3352 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3353 return CMD_SUCCESS;
3354}
3355
3356ALIAS (no_debug_pim_packetdump_recv,
3357 undebug_pim_packetdump_recv_cmd,
3358 "undebug pim packet-dump receive",
3359 UNDEBUG_STR
3360 DEBUG_PIM_STR
3361 DEBUG_PIM_PACKETDUMP_STR
3362 DEBUG_PIM_PACKETDUMP_RECV_STR)
3363
Everton Marques871dbcf2009-08-11 15:43:05 -03003364DEFUN (debug_pim_trace,
3365 debug_pim_trace_cmd,
3366 "debug pim trace",
3367 DEBUG_STR
3368 DEBUG_PIM_STR
3369 DEBUG_PIM_TRACE_STR)
3370{
3371 PIM_DO_DEBUG_PIM_TRACE;
3372 return CMD_SUCCESS;
3373}
3374
3375DEFUN (no_debug_pim_trace,
3376 no_debug_pim_trace_cmd,
3377 "no debug pim trace",
3378 NO_STR
3379 DEBUG_STR
3380 DEBUG_PIM_STR
3381 DEBUG_PIM_TRACE_STR)
3382{
3383 PIM_DONT_DEBUG_PIM_TRACE;
3384 return CMD_SUCCESS;
3385}
3386
3387ALIAS (no_debug_pim_trace,
3388 undebug_pim_trace_cmd,
3389 "undebug pim trace",
3390 UNDEBUG_STR
3391 DEBUG_PIM_STR
3392 DEBUG_PIM_TRACE_STR)
3393
Everton Marques824adbe2009-10-08 09:16:27 -03003394DEFUN (debug_ssmpingd,
3395 debug_ssmpingd_cmd,
3396 "debug ssmpingd",
3397 DEBUG_STR
3398 DEBUG_PIM_STR
3399 DEBUG_SSMPINGD_STR)
3400{
3401 PIM_DO_DEBUG_SSMPINGD;
3402 return CMD_SUCCESS;
3403}
3404
3405DEFUN (no_debug_ssmpingd,
3406 no_debug_ssmpingd_cmd,
3407 "no debug ssmpingd",
3408 NO_STR
3409 DEBUG_STR
3410 DEBUG_PIM_STR
3411 DEBUG_SSMPINGD_STR)
3412{
3413 PIM_DONT_DEBUG_SSMPINGD;
3414 return CMD_SUCCESS;
3415}
3416
3417ALIAS (no_debug_ssmpingd,
3418 undebug_ssmpingd_cmd,
3419 "undebug ssmpingd",
3420 UNDEBUG_STR
3421 DEBUG_PIM_STR
3422 DEBUG_SSMPINGD_STR)
3423
Everton Marques871dbcf2009-08-11 15:43:05 -03003424DEFUN (debug_pim_zebra,
3425 debug_pim_zebra_cmd,
3426 "debug pim zebra",
3427 DEBUG_STR
3428 DEBUG_PIM_STR
3429 DEBUG_PIM_ZEBRA_STR)
3430{
3431 PIM_DO_DEBUG_ZEBRA;
3432 return CMD_SUCCESS;
3433}
3434
3435DEFUN (no_debug_pim_zebra,
3436 no_debug_pim_zebra_cmd,
3437 "no debug pim zebra",
3438 NO_STR
3439 DEBUG_STR
3440 DEBUG_PIM_STR
3441 DEBUG_PIM_ZEBRA_STR)
3442{
3443 PIM_DONT_DEBUG_ZEBRA;
3444 return CMD_SUCCESS;
3445}
3446
3447ALIAS (no_debug_pim_zebra,
3448 undebug_pim_zebra_cmd,
3449 "undebug pim zebra",
3450 UNDEBUG_STR
3451 DEBUG_PIM_STR
3452 DEBUG_PIM_ZEBRA_STR)
3453
3454DEFUN (show_debugging,
3455 show_debugging_cmd,
3456 "show debugging",
3457 SHOW_STR
3458 "State of each debugging option\n")
3459{
3460 pim_debug_config_write(vty);
3461 return CMD_SUCCESS;
3462}
3463
3464static struct igmp_sock *find_igmp_sock_by_fd(int fd)
3465{
3466 struct listnode *ifnode;
3467 struct interface *ifp;
3468
3469 /* scan all interfaces */
3470 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
3471 struct pim_interface *pim_ifp;
3472 struct igmp_sock *igmp;
3473
3474 if (!ifp->info)
3475 continue;
3476
3477 pim_ifp = ifp->info;
3478
3479 /* lookup igmp socket under current interface */
3480 igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
3481 if (igmp)
3482 return igmp;
3483 }
3484
3485 return 0;
3486}
3487
3488DEFUN (test_igmp_receive_report,
3489 test_igmp_receive_report_cmd,
3490 "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
3491 "Test\n"
3492 "Test IGMP protocol\n"
3493 "Test IGMP message\n"
3494 "Test IGMP report\n"
3495 "Socket\n"
3496 "IGMP group address\n"
3497 "Record type\n"
3498 "Sources\n")
3499{
3500 char buf[1000];
3501 char *igmp_msg;
3502 struct ip *ip_hdr;
3503 size_t ip_hlen; /* ip header length in bytes */
3504 int ip_msg_len;
3505 int igmp_msg_len;
3506 const char *socket;
3507 int socket_fd;
3508 const char *grp_str;
3509 struct in_addr grp_addr;
3510 const char *record_type_str;
3511 int record_type;
3512 const char *src_str;
3513 int result;
3514 struct igmp_sock *igmp;
3515 char *group_record;
3516 int num_sources;
3517 struct in_addr *sources;
3518 struct in_addr *src_addr;
3519 int argi;
3520
3521 socket = argv[0];
3522 socket_fd = atoi(socket);
3523 igmp = find_igmp_sock_by_fd(socket_fd);
3524 if (!igmp) {
3525 vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
3526 socket, socket_fd, VTY_NEWLINE);
3527 return CMD_WARNING;
3528 }
3529
3530 grp_str = argv[1];
3531 result = inet_pton(AF_INET, grp_str, &grp_addr);
3532 if (result <= 0) {
3533 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003534 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003535 return CMD_WARNING;
3536 }
3537
3538 record_type_str = argv[2];
3539 record_type = atoi(record_type_str);
3540
3541 /*
3542 Tweak IP header
3543 */
3544 ip_hdr = (struct ip *) buf;
3545 ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
3546 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3547 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3548 ip_hdr->ip_src = igmp->ifaddr;
3549 ip_hdr->ip_dst = igmp->ifaddr;
3550
3551 /*
3552 Build IGMP v3 report message
3553 */
3554 igmp_msg = buf + ip_hlen;
3555 group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
3556 *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
3557 *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
3558 *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
3559 *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
Klemen Sladic3defeb32014-02-07 16:23:44 +13003560 memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr));
Everton Marques871dbcf2009-08-11 15:43:05 -03003561
3562 /* Scan LINE sources */
3563 sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
3564 src_addr = sources;
3565 for (argi = 3; argi < argc; ++argi,++src_addr) {
3566 src_str = argv[argi];
3567 result = inet_pton(AF_INET, src_str, src_addr);
3568 if (result <= 0) {
3569 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003570 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003571 return CMD_WARNING;
3572 }
3573 }
3574 num_sources = src_addr - sources;
3575
3576 *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
3577
3578 igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
3579
3580 /* compute checksum */
3581 *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = pim_inet_checksum(igmp_msg, igmp_msg_len);
3582
3583 /* "receive" message */
3584
3585 ip_msg_len = ip_hlen + igmp_msg_len;
3586 result = pim_igmp_packet(igmp, buf, ip_msg_len);
3587 if (result) {
3588 vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
3589 ip_msg_len, result, VTY_NEWLINE);
3590 return CMD_WARNING;
3591 }
3592
3593 return CMD_SUCCESS;
3594}
3595
Everton Marquesdba77582009-11-19 10:32:19 -02003596static int hexval(uint8_t ch)
3597{
3598 return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a');
3599}
3600
Everton Marques3e92c452009-11-18 16:26:38 -02003601DEFUN (test_pim_receive_dump,
3602 test_pim_receive_dump_cmd,
3603 "test pim receive dump INTERFACE A.B.C.D .LINE",
3604 "Test\n"
3605 "Test PIM protocol\n"
3606 "Test PIM message reception\n"
3607 "Test PIM packet dump reception from neighbor\n"
3608 "Interface\n"
3609 "Neighbor address\n"
3610 "Packet dump\n")
3611{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003612 uint8_t buf[1000];
3613 uint8_t *pim_msg;
Everton Marques3e92c452009-11-18 16:26:38 -02003614 struct ip *ip_hdr;
3615 size_t ip_hlen; /* ip header length in bytes */
3616 int ip_msg_len;
3617 int pim_msg_size;
3618 const char *neigh_str;
3619 struct in_addr neigh_addr;
3620 const char *ifname;
3621 struct interface *ifp;
3622 int argi;
3623 int result;
3624
3625 /* Find interface */
3626 ifname = argv[0];
3627 ifp = if_lookup_by_name(ifname);
3628 if (!ifp) {
3629 vty_out(vty, "No such interface name %s%s",
3630 ifname, VTY_NEWLINE);
3631 return CMD_WARNING;
3632 }
3633
3634 /* Neighbor address */
3635 neigh_str = argv[1];
3636 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3637 if (result <= 0) {
3638 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
3639 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
3640 return CMD_WARNING;
3641 }
3642
3643 /*
3644 Tweak IP header
3645 */
3646 ip_hdr = (struct ip *) buf;
3647 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3648 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3649 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3650 ip_hdr->ip_src = neigh_addr;
3651 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3652
3653 /*
3654 Build PIM hello message
3655 */
3656 pim_msg = buf + ip_hlen;
3657 pim_msg_size = 0;
3658
3659 /* Scan LINE dump into buffer */
Everton Marquesdba77582009-11-19 10:32:19 -02003660 for (argi = 2; argi < argc; ++argi) {
3661 const char *str = argv[argi];
3662 int str_len = strlen(str);
3663 int str_last = str_len - 1;
3664 int i;
Everton Marques3e92c452009-11-18 16:26:38 -02003665
Everton Marquesdba77582009-11-19 10:32:19 -02003666 if (str_len % 2) {
3667 vty_out(vty, "%% Uneven hex array arg %d=%s%s",
3668 argi, str, VTY_NEWLINE);
Everton Marques3e92c452009-11-18 16:26:38 -02003669 return CMD_WARNING;
3670 }
3671
Everton Marquesdba77582009-11-19 10:32:19 -02003672 for (i = 0; i < str_last; i += 2) {
3673 uint8_t octet;
3674 int left;
3675 uint8_t h1 = str[i];
3676 uint8_t h2 = str[i + 1];
3677
3678 if (!isxdigit(h1) || !isxdigit(h2)) {
3679 vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s",
3680 h1, h2, argi, str, VTY_NEWLINE);
3681 return CMD_WARNING;
3682 }
3683 octet = (hexval(h1) << 4) + hexval(h2);
3684
3685 left = sizeof(buf) - ip_hlen - pim_msg_size;
3686 if (left < 1) {
David Lamparter5c697982012-02-16 04:47:56 +01003687 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 -02003688 sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
3689 return CMD_WARNING;
3690 }
3691
3692 pim_msg[pim_msg_size++] = octet;
3693 }
Everton Marques3e92c452009-11-18 16:26:38 -02003694 }
3695
3696 ip_msg_len = ip_hlen + pim_msg_size;
3697
David Lamparter5c697982012-02-16 04:47:56 +01003698 vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
Everton Marques3e92c452009-11-18 16:26:38 -02003699 sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
3700
3701 /* "receive" message */
3702
3703 result = pim_pim_packet(ifp, buf, ip_msg_len);
3704 if (result) {
3705 vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s",
3706 ip_msg_len, result, VTY_NEWLINE);
3707 return CMD_WARNING;
3708 }
3709
3710 return CMD_SUCCESS;
3711}
3712
Everton Marques871dbcf2009-08-11 15:43:05 -03003713DEFUN (test_pim_receive_hello,
3714 test_pim_receive_hello_cmd,
3715 "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
3716 "Test\n"
3717 "Test PIM protocol\n"
3718 "Test PIM message reception\n"
3719 "Test PIM hello reception from neighbor\n"
3720 "Interface\n"
3721 "Neighbor address\n"
3722 "Neighbor holdtime\n"
3723 "Neighbor DR priority\n"
3724 "Neighbor generation ID\n"
3725 "Neighbor propagation delay (msec)\n"
3726 "Neighbor override interval (msec)\n"
3727 "Neighbor LAN prune delay T-bit\n"
3728 "Neighbor secondary addresses\n")
3729{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003730 uint8_t buf[1000];
3731 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03003732 struct ip *ip_hdr;
3733 size_t ip_hlen; /* ip header length in bytes */
3734 int ip_msg_len;
3735 int pim_tlv_size;
3736 int pim_msg_size;
3737 const char *neigh_str;
3738 struct in_addr neigh_addr;
3739 const char *ifname;
3740 struct interface *ifp;
3741 uint16_t neigh_holdtime;
3742 uint16_t neigh_propagation_delay;
3743 uint16_t neigh_override_interval;
3744 int neigh_can_disable_join_suppression;
3745 uint32_t neigh_dr_priority;
3746 uint32_t neigh_generation_id;
3747 int argi;
3748 int result;
3749
3750 /* Find interface */
3751 ifname = argv[0];
3752 ifp = if_lookup_by_name(ifname);
3753 if (!ifp) {
3754 vty_out(vty, "No such interface name %s%s",
3755 ifname, VTY_NEWLINE);
3756 return CMD_WARNING;
3757 }
3758
3759 /* Neighbor address */
3760 neigh_str = argv[1];
3761 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3762 if (result <= 0) {
3763 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003764 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003765 return CMD_WARNING;
3766 }
3767
3768 neigh_holdtime = atoi(argv[2]);
3769 neigh_dr_priority = atoi(argv[3]);
3770 neigh_generation_id = atoi(argv[4]);
3771 neigh_propagation_delay = atoi(argv[5]);
3772 neigh_override_interval = atoi(argv[6]);
3773 neigh_can_disable_join_suppression = atoi(argv[7]);
3774
3775 /*
3776 Tweak IP header
3777 */
3778 ip_hdr = (struct ip *) buf;
3779 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3780 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3781 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3782 ip_hdr->ip_src = neigh_addr;
3783 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3784
3785 /*
3786 Build PIM hello message
3787 */
3788 pim_msg = buf + ip_hlen;
3789
3790 /* Scan LINE addresses */
3791 for (argi = 8; argi < argc; ++argi) {
3792 const char *sec_str = argv[argi];
3793 struct in_addr sec_addr;
3794 result = inet_pton(AF_INET, sec_str, &sec_addr);
3795 if (result <= 0) {
3796 vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003797 sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003798 return CMD_WARNING;
3799 }
3800
3801 vty_out(vty,
3802 "FIXME WRITEME consider neighbor secondary address %s%s",
3803 sec_str, VTY_NEWLINE);
3804 }
3805
3806 pim_tlv_size = pim_hello_build_tlv(ifp->name,
3807 pim_msg + PIM_PIM_MIN_LEN,
3808 sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
3809 neigh_holdtime,
3810 neigh_dr_priority,
3811 neigh_generation_id,
3812 neigh_propagation_delay,
3813 neigh_override_interval,
3814 neigh_can_disable_join_suppression,
3815 0 /* FIXME secondary address list */);
3816 if (pim_tlv_size < 0) {
3817 vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
3818 pim_tlv_size, VTY_NEWLINE);
3819 return CMD_WARNING;
3820 }
3821
3822 pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
3823
3824 pim_msg_build_header(pim_msg, pim_msg_size,
3825 PIM_MSG_TYPE_HELLO);
3826
3827 /* "receive" message */
3828
3829 ip_msg_len = ip_hlen + pim_msg_size;
3830 result = pim_pim_packet(ifp, buf, ip_msg_len);
3831 if (result) {
3832 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
3833 ip_msg_len, result, VTY_NEWLINE);
3834 return CMD_WARNING;
3835 }
3836
3837 return CMD_SUCCESS;
3838}
3839
3840DEFUN (test_pim_receive_assert,
3841 test_pim_receive_assert_cmd,
3842 "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
3843 "Test\n"
3844 "Test PIM protocol\n"
3845 "Test PIM message reception\n"
3846 "Test reception of PIM assert\n"
3847 "Interface\n"
3848 "Neighbor address\n"
3849 "Assert multicast group address\n"
3850 "Assert unicast source address\n"
3851 "Assert metric preference\n"
3852 "Assert route metric\n"
3853 "Assert RPT bit flag\n")
3854{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003855 uint8_t buf[1000];
3856 uint8_t *buf_pastend = buf + sizeof(buf);
3857 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03003858 struct ip *ip_hdr;
3859 size_t ip_hlen; /* ip header length in bytes */
3860 int ip_msg_len;
3861 int pim_msg_size;
3862 const char *neigh_str;
3863 struct in_addr neigh_addr;
3864 const char *group_str;
3865 struct in_addr group_addr;
3866 const char *source_str;
3867 struct in_addr source_addr;
3868 const char *ifname;
3869 struct interface *ifp;
3870 uint32_t assert_metric_preference;
3871 uint32_t assert_route_metric;
3872 uint32_t assert_rpt_bit_flag;
3873 int remain;
3874 int result;
3875
3876 /* Find interface */
3877 ifname = argv[0];
3878 ifp = if_lookup_by_name(ifname);
3879 if (!ifp) {
3880 vty_out(vty, "No such interface name %s%s",
3881 ifname, VTY_NEWLINE);
3882 return CMD_WARNING;
3883 }
3884
3885 /* Neighbor address */
3886 neigh_str = argv[1];
3887 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
3888 if (result <= 0) {
3889 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003890 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003891 return CMD_WARNING;
3892 }
3893
3894 /* Group address */
3895 group_str = argv[2];
3896 result = inet_pton(AF_INET, group_str, &group_addr);
3897 if (result <= 0) {
3898 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003899 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003900 return CMD_WARNING;
3901 }
3902
3903 /* Source address */
3904 source_str = argv[3];
3905 result = inet_pton(AF_INET, source_str, &source_addr);
3906 if (result <= 0) {
3907 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03003908 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003909 return CMD_WARNING;
3910 }
3911
3912 assert_metric_preference = atoi(argv[4]);
3913 assert_route_metric = atoi(argv[5]);
3914 assert_rpt_bit_flag = atoi(argv[6]);
3915
3916 remain = buf_pastend - buf;
3917 if (remain < (int) sizeof(struct ip)) {
David Lamparter5c697982012-02-16 04:47:56 +01003918 vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03003919 remain, sizeof(struct ip), VTY_NEWLINE);
3920 return CMD_WARNING;
3921 }
3922
3923 /*
3924 Tweak IP header
3925 */
3926 ip_hdr = (struct ip *) buf;
3927 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
3928 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
3929 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
3930 ip_hdr->ip_src = neigh_addr;
3931 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
3932
3933 /*
3934 Build PIM assert message
3935 */
3936 pim_msg = buf + ip_hlen; /* skip ip header */
3937
3938 pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
3939 group_addr, source_addr,
3940 assert_metric_preference,
3941 assert_route_metric,
3942 assert_rpt_bit_flag);
3943 if (pim_msg_size < 0) {
3944 vty_out(vty, "Failure building PIM assert message: size=%d%s",
3945 pim_msg_size, VTY_NEWLINE);
3946 return CMD_WARNING;
3947 }
3948
3949 /* "receive" message */
3950
3951 ip_msg_len = ip_hlen + pim_msg_size;
3952 result = pim_pim_packet(ifp, buf, ip_msg_len);
3953 if (result) {
3954 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
3955 ip_msg_len, result, VTY_NEWLINE);
3956 return CMD_WARNING;
3957 }
3958
3959 return CMD_SUCCESS;
3960}
3961
3962static int recv_joinprune(struct vty *vty,
3963 const char *argv[],
3964 int src_is_join)
3965{
David Lamparterf8cfeb22012-02-16 04:31:08 +00003966 uint8_t buf[1000];
3967 const uint8_t *buf_pastend = buf + sizeof(buf);
3968 uint8_t *pim_msg;
3969 uint8_t *pim_msg_curr;
Everton Marques871dbcf2009-08-11 15:43:05 -03003970 int pim_msg_size;
3971 struct ip *ip_hdr;
3972 size_t ip_hlen; /* ip header length in bytes */
3973 int ip_msg_len;
3974 uint16_t neigh_holdtime;
3975 const char *neigh_dst_str;
3976 struct in_addr neigh_dst_addr;
3977 const char *neigh_src_str;
3978 struct in_addr neigh_src_addr;
3979 const char *group_str;
3980 struct in_addr group_addr;
3981 const char *source_str;
3982 struct in_addr source_addr;
3983 const char *ifname;
3984 struct interface *ifp;
3985 int result;
3986 int remain;
3987 uint16_t num_joined;
3988 uint16_t num_pruned;
3989
3990 /* Find interface */
3991 ifname = argv[0];
3992 ifp = if_lookup_by_name(ifname);
3993 if (!ifp) {
3994 vty_out(vty, "No such interface name %s%s",
3995 ifname, VTY_NEWLINE);
3996 return CMD_WARNING;
3997 }
3998
3999 neigh_holdtime = atoi(argv[1]);
4000
4001 /* Neighbor destination address */
4002 neigh_dst_str = argv[2];
4003 result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
4004 if (result <= 0) {
4005 vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004006 neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004007 return CMD_WARNING;
4008 }
4009
4010 /* Neighbor source address */
4011 neigh_src_str = argv[3];
4012 result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
4013 if (result <= 0) {
4014 vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004015 neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004016 return CMD_WARNING;
4017 }
4018
4019 /* Multicast group address */
4020 group_str = argv[4];
4021 result = inet_pton(AF_INET, group_str, &group_addr);
4022 if (result <= 0) {
4023 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004024 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004025 return CMD_WARNING;
4026 }
4027
4028 /* Multicast source address */
4029 source_str = argv[5];
4030 result = inet_pton(AF_INET, source_str, &source_addr);
4031 if (result <= 0) {
4032 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004033 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004034 return CMD_WARNING;
4035 }
4036
4037 /*
4038 Tweak IP header
4039 */
4040 ip_hdr = (struct ip *) buf;
4041 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4042 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4043 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4044 ip_hdr->ip_src = neigh_src_addr;
4045 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4046
4047 /*
4048 Build PIM message
4049 */
4050 pim_msg = buf + ip_hlen;
4051
4052 /* skip room for pim header */
4053 pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
4054
4055 remain = buf_pastend - pim_msg_curr;
4056 pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
4057 remain,
4058 neigh_dst_addr);
4059 if (!pim_msg_curr) {
4060 vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
4061 neigh_dst_str, remain, VTY_NEWLINE);
4062 return CMD_WARNING;
4063 }
4064
4065 remain = buf_pastend - pim_msg_curr;
4066 if (remain < 4) {
4067 vty_out(vty, "Group will not fit: space left=%d%s",
4068 remain, VTY_NEWLINE);
4069 return CMD_WARNING;
4070 }
4071
4072 *pim_msg_curr = 0; /* reserved */
4073 ++pim_msg_curr;
4074 *pim_msg_curr = 1; /* number of groups */
4075 ++pim_msg_curr;
4076 *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
4077 ++pim_msg_curr;
4078 ++pim_msg_curr;
4079
4080 remain = buf_pastend - pim_msg_curr;
4081 pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
4082 remain,
4083 group_addr);
4084 if (!pim_msg_curr) {
4085 vty_out(vty, "Failure encoding group address %s: space left=%d%s",
4086 group_str, remain, VTY_NEWLINE);
4087 return CMD_WARNING;
4088 }
4089
4090 remain = buf_pastend - pim_msg_curr;
4091 if (remain < 4) {
4092 vty_out(vty, "Sources will not fit: space left=%d%s",
4093 remain, VTY_NEWLINE);
4094 return CMD_WARNING;
4095 }
4096
4097 if (src_is_join) {
4098 num_joined = 1;
4099 num_pruned = 0;
4100 }
4101 else {
4102 num_joined = 0;
4103 num_pruned = 1;
4104 }
4105
4106 /* number of joined sources */
4107 *((uint16_t *) pim_msg_curr) = htons(num_joined);
4108 ++pim_msg_curr;
4109 ++pim_msg_curr;
4110
4111 /* number of pruned sources */
4112 *((uint16_t *) pim_msg_curr) = htons(num_pruned);
4113 ++pim_msg_curr;
4114 ++pim_msg_curr;
4115
4116 remain = buf_pastend - pim_msg_curr;
4117 pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
4118 remain,
4119 source_addr);
4120 if (!pim_msg_curr) {
4121 vty_out(vty, "Failure encoding source address %s: space left=%d%s",
4122 source_str, remain, VTY_NEWLINE);
4123 return CMD_WARNING;
4124 }
4125
4126 /* Add PIM header */
4127
4128 pim_msg_size = pim_msg_curr - pim_msg;
4129
4130 pim_msg_build_header(pim_msg, pim_msg_size,
4131 PIM_MSG_TYPE_JOIN_PRUNE);
4132
4133 /*
4134 "Receive" message
4135 */
4136
4137 ip_msg_len = ip_hlen + pim_msg_size;
4138 result = pim_pim_packet(ifp, buf, ip_msg_len);
4139 if (result) {
4140 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4141 ip_msg_len, result, VTY_NEWLINE);
4142 return CMD_WARNING;
4143 }
4144
4145 return CMD_SUCCESS;
4146}
4147
4148DEFUN (test_pim_receive_join,
4149 test_pim_receive_join_cmd,
4150 "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4151 "Test\n"
4152 "Test PIM protocol\n"
4153 "Test PIM message reception\n"
4154 "Test PIM join reception from neighbor\n"
4155 "Interface\n"
4156 "Neighbor holdtime\n"
4157 "Upstream neighbor unicast destination address\n"
4158 "Downstream neighbor unicast source address\n"
4159 "Multicast group address\n"
4160 "Unicast source address\n")
4161{
4162 return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
4163}
4164
4165DEFUN (test_pim_receive_prune,
4166 test_pim_receive_prune_cmd,
4167 "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4168 "Test\n"
4169 "Test PIM protocol\n"
4170 "Test PIM message reception\n"
4171 "Test PIM prune reception from neighbor\n"
4172 "Interface\n"
4173 "Neighbor holdtime\n"
4174 "Upstream neighbor unicast destination address\n"
4175 "Downstream neighbor unicast source address\n"
4176 "Multicast group address\n"
4177 "Unicast source address\n")
4178{
4179 return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
4180}
4181
4182DEFUN (test_pim_receive_upcall,
4183 test_pim_receive_upcall_cmd,
4184 "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
4185 "Test\n"
4186 "Test PIM protocol\n"
4187 "Test PIM message reception\n"
4188 "Test reception of kernel upcall\n"
4189 "NOCACHE kernel upcall\n"
4190 "WRONGVIF kernel upcall\n"
4191 "WHOLEPKT kernel upcall\n"
4192 "Input interface vif index\n"
4193 "Multicast group address\n"
4194 "Multicast source address\n")
4195{
4196 struct igmpmsg msg;
4197 const char *upcall_type;
4198 const char *group_str;
4199 const char *source_str;
4200 int result;
4201
4202 upcall_type = argv[0];
4203
4204 if (upcall_type[0] == 'n')
4205 msg.im_msgtype = IGMPMSG_NOCACHE;
4206 else if (upcall_type[1] == 'r')
4207 msg.im_msgtype = IGMPMSG_WRONGVIF;
4208 else if (upcall_type[1] == 'h')
4209 msg.im_msgtype = IGMPMSG_WHOLEPKT;
4210 else {
4211 vty_out(vty, "Unknown kernel upcall type: %s%s",
4212 upcall_type, VTY_NEWLINE);
4213 return CMD_WARNING;
4214 }
4215
4216 msg.im_vif = atoi(argv[1]);
4217
4218 /* Group address */
4219 group_str = argv[2];
4220 result = inet_pton(AF_INET, group_str, &msg.im_dst);
4221 if (result <= 0) {
4222 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004223 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004224 return CMD_WARNING;
4225 }
4226
4227 /* Source address */
4228 source_str = argv[3];
4229 result = inet_pton(AF_INET, source_str, &msg.im_src);
4230 if (result <= 0) {
4231 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004232 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004233 return CMD_WARNING;
4234 }
4235
4236 msg.im_mbz = 0; /* Must be zero */
4237
4238 result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
4239 if (result) {
David Lamparter5c697982012-02-16 04:47:56 +01004240 vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03004241 sizeof(msg), result, VTY_NEWLINE);
4242 return CMD_WARNING;
4243 }
4244
4245 return CMD_SUCCESS;
4246}
4247
4248void pim_cmd_init()
4249{
Leonard Herve596470f2009-08-11 15:45:26 -03004250 install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
4251 install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
Everton Marques871dbcf2009-08-11 15:43:05 -03004252
Leonard Herve596470f2009-08-11 15:45:26 -03004253 install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
4254 install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
Everton Marques96f91ae2009-10-07 18:41:45 -03004255 install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
4256 install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004257#if 0
Leonard Herve596470f2009-08-11 15:45:26 -03004258 install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004259#else
Leonard Herve596470f2009-08-11 15:45:26 -03004260 install_element (CONFIG_NODE, &pim_interface_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004261#endif
Leonard Herve596470f2009-08-11 15:45:26 -03004262 install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004263
Leonard Herve596470f2009-08-11 15:45:26 -03004264 install_default (INTERFACE_NODE);
4265 install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
4266 install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
4267 install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
4268 install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
4269 install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
4270 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
4271 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
4272 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
4273 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
4274 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
4275 install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
4276 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004277
Leonard Herve596470f2009-08-11 15:45:26 -03004278 install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004279 install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004280 install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
4281 install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
4282 install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4283 install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
4284 install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4285 install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
4286 install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
4287 install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
4288 install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
4289 install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
4290 install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
4291 install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
4292 install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
4293 install_element (VIEW_NODE, &show_ip_pim_join_cmd);
4294 install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
4295 install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
4296 install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
4297 install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
4298 install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
4299 install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
4300 install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
4301 install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
4302 install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
4303 install_element (VIEW_NODE, &show_ip_multicast_cmd);
4304 install_element (VIEW_NODE, &show_ip_mroute_cmd);
4305 install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004306 install_element (VIEW_NODE, &show_ip_rib_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004307 install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004308 install_element (VIEW_NODE, &show_debugging_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004309
Leonard Herve596470f2009-08-11 15:45:26 -03004310 install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
4311 install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
Everton Marquesf24200d2014-02-14 16:40:34 -02004312 install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004313 install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
Everton Marquesf24200d2014-02-14 16:40:34 -02004314 install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004315
Leonard Herve596470f2009-08-11 15:45:26 -03004316 install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004317 install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004318 install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
4319 install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
4320 install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4321 install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
4322 install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4323 install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
4324 install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
4325 install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
4326 install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
4327 install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
4328 install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
4329 install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
4330 install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
4331 install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
4332 install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
4333 install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
4334 install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
4335 install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
4336 install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
4337 install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
4338 install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
4339 install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
4340 install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
4341 install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
4342 install_element (ENABLE_NODE, &show_ip_multicast_cmd);
4343 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
4344 install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004345 install_element (ENABLE_NODE, &show_ip_rib_cmd);
Everton Marquese8c11bb2009-10-08 15:06:32 -03004346 install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004347 install_element (ENABLE_NODE, &show_debugging_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004348
Leonard Herve596470f2009-08-11 15:45:26 -03004349 install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
4350 install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
Everton Marques3e92c452009-11-18 16:26:38 -02004351 install_element (ENABLE_NODE, &test_pim_receive_dump_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004352 install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
4353 install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
4354 install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
4355 install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004356
Leonard Herve596470f2009-08-11 15:45:26 -03004357 install_element (ENABLE_NODE, &debug_igmp_cmd);
4358 install_element (ENABLE_NODE, &no_debug_igmp_cmd);
4359 install_element (ENABLE_NODE, &undebug_igmp_cmd);
4360 install_element (ENABLE_NODE, &debug_igmp_events_cmd);
4361 install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
4362 install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
4363 install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
4364 install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
4365 install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
4366 install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
4367 install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
4368 install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004369 install_element (ENABLE_NODE, &debug_mroute_cmd);
4370 install_element (ENABLE_NODE, &no_debug_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004371 install_element (ENABLE_NODE, &debug_pim_cmd);
4372 install_element (ENABLE_NODE, &no_debug_pim_cmd);
4373 install_element (ENABLE_NODE, &undebug_pim_cmd);
4374 install_element (ENABLE_NODE, &debug_pim_events_cmd);
4375 install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
4376 install_element (ENABLE_NODE, &undebug_pim_events_cmd);
4377 install_element (ENABLE_NODE, &debug_pim_packets_cmd);
4378 install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
4379 install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
Everton Marques62738042009-11-18 10:44:13 -02004380 install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
4381 install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
4382 install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd);
4383 install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
4384 install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
4385 install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004386 install_element (ENABLE_NODE, &debug_pim_trace_cmd);
4387 install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
4388 install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004389 install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
4390 install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
4391 install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004392 install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
4393 install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
4394 install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004395
Leonard Herve596470f2009-08-11 15:45:26 -03004396 install_element (CONFIG_NODE, &debug_igmp_cmd);
4397 install_element (CONFIG_NODE, &no_debug_igmp_cmd);
4398 install_element (CONFIG_NODE, &undebug_igmp_cmd);
4399 install_element (CONFIG_NODE, &debug_igmp_events_cmd);
4400 install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
4401 install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
4402 install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
4403 install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
4404 install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
4405 install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
4406 install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
4407 install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004408 install_element (CONFIG_NODE, &debug_mroute_cmd);
4409 install_element (CONFIG_NODE, &no_debug_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004410 install_element (CONFIG_NODE, &debug_pim_cmd);
4411 install_element (CONFIG_NODE, &no_debug_pim_cmd);
4412 install_element (CONFIG_NODE, &undebug_pim_cmd);
4413 install_element (CONFIG_NODE, &debug_pim_events_cmd);
4414 install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
4415 install_element (CONFIG_NODE, &undebug_pim_events_cmd);
4416 install_element (CONFIG_NODE, &debug_pim_packets_cmd);
4417 install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
4418 install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
4419 install_element (CONFIG_NODE, &debug_pim_trace_cmd);
4420 install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
4421 install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004422 install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
4423 install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
4424 install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004425 install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
4426 install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
4427 install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004428}