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