blob: 33644540350141a777a5f758944f7fad5f4a4919 [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,
Donald Sharp6ae80e02015-06-18 18:14:20 -0700566 "NonPri: Number of neighbors missing DR Priority hello option%s"
567 "DrPri: Designated Router Priority sent%s%s",
568 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -0300569
Donald Sharp6ae80e02015-06-18 18:14:20 -0700570 vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri DrPri%s", VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -0300571
572 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
573 struct pim_interface *pim_ifp;
574 struct in_addr ifaddr;
575 char dr_str[100];
576 char dr_uptime[10];
577
578 pim_ifp = ifp->info;
579
580 if (!pim_ifp)
581 continue;
582
583 if (pim_ifp->pim_sock_fd < 0)
584 continue;
585
586 ifaddr = pim_ifp->primary_address;
587
Everton Marques5c55a492014-07-02 12:12:16 -0300588 pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime),
589 now, pim_ifp->pim_dr_election_last);
Everton Marques871dbcf2009-08-11 15:43:05 -0300590
591 pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
592 dr_str, sizeof(dr_str));
593
Donald Sharp6ae80e02015-06-18 18:14:20 -0700594 vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d %10d%s",
Everton Marques871dbcf2009-08-11 15:43:05 -0300595 ifp->name,
596 inet_ntoa(ifaddr),
597 dr_str,
598 dr_uptime,
599 pim_ifp->pim_dr_election_count,
Everton Marques777fe1f2014-02-14 14:16:07 -0200600 pim_ifp->pim_dr_election_changes,
Everton Marques871dbcf2009-08-11 15:43:05 -0300601 pim_ifp->pim_dr_num_nondrpri_neighbors,
Donald Sharp6ae80e02015-06-18 18:14:20 -0700602 pim_ifp->pim_dr_priority,
Everton Marques871dbcf2009-08-11 15:43:05 -0300603 VTY_NEWLINE);
604 }
605}
606
607static void pim_show_hello(struct vty *vty)
608{
609 struct listnode *node;
610 struct interface *ifp;
611 time_t now;
612
613 now = pim_time_monotonic_sec();
614
615 vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
616
617 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
618 struct pim_interface *pim_ifp;
619 struct in_addr ifaddr;
620 char hello_period[10];
621 char hello_timer[10];
622 char stat_uptime[10];
623
624 pim_ifp = ifp->info;
625
626 if (!pim_ifp)
627 continue;
628
629 if (pim_ifp->pim_sock_fd < 0)
630 continue;
631
632 ifaddr = pim_ifp->primary_address;
633
634 pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
635 pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
636 pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
637
638 vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
639 ifp->name,
640 inet_ntoa(ifaddr),
641 hello_period,
642 hello_timer,
643 stat_uptime,
644 pim_ifp->pim_ifstat_hello_recv,
645 pim_ifp->pim_ifstat_hello_recvfail,
646 pim_ifp->pim_ifstat_hello_sent,
647 pim_ifp->pim_ifstat_hello_sendfail,
648 VTY_NEWLINE);
649 }
650}
651
652static void pim_show_interfaces(struct vty *vty)
653{
654 struct listnode *node;
655 struct interface *ifp;
656 time_t now;
657
658 now = pim_time_monotonic_sec();
659
660 vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
661
662 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
663 struct pim_interface *pim_ifp;
664 struct in_addr ifaddr;
665 char uptime[10];
666 int mloop;
667
668 pim_ifp = ifp->info;
669
670 if (!pim_ifp)
671 continue;
672
673 if (pim_ifp->pim_sock_fd < 0)
674 continue;
675
676 ifaddr = pim_ifp->primary_address;
677
678 pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
679
680 mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
681
682 vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
683 ifp->name,
684 inet_ntoa(ifaddr),
685 ifp->ifindex,
686 pim_ifp->pim_sock_fd,
687 uptime,
688 if_is_multicast(ifp) ? "yes" : "no",
689 if_is_broadcast(ifp) ? "yes" : "no",
690 (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
691 (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
692 (ifp->flags & IFF_PROMISC) ? "yes" : "no",
693 PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
694 VTY_NEWLINE);
695 }
696}
697
698static void pim_show_join(struct vty *vty)
699{
700 struct listnode *ifnode;
701 struct interface *ifp;
702 time_t now;
703
704 now = pim_time_monotonic_sec();
705
706 vty_out(vty,
707 "Interface Address Source Group State Uptime Expire Prune%s",
708 VTY_NEWLINE);
709
710 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
711 struct pim_interface *pim_ifp;
712 struct in_addr ifaddr;
713 struct listnode *ch_node;
714 struct pim_ifchannel *ch;
715
716 pim_ifp = ifp->info;
717
718 if (!pim_ifp)
719 continue;
720
721 ifaddr = pim_ifp->primary_address;
722
723 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
724 char ch_src_str[100];
725 char ch_grp_str[100];
726 char uptime[10];
727 char expire[10];
728 char prune[10];
729
730 pim_inet4_dump("<ch_src?>", ch->source_addr,
731 ch_src_str, sizeof(ch_src_str));
732 pim_inet4_dump("<ch_grp?>", ch->group_addr,
733 ch_grp_str, sizeof(ch_grp_str));
734
Everton Marquesd1a87ee2014-02-14 16:51:05 -0200735 pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation);
Everton Marques871dbcf2009-08-11 15:43:05 -0300736 pim_time_timer_to_mmss(expire, sizeof(expire),
737 ch->t_ifjoin_expiry_timer);
738 pim_time_timer_to_mmss(prune, sizeof(prune),
739 ch->t_ifjoin_prune_pending_timer);
740
741 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
742 ifp->name,
743 inet_ntoa(ifaddr),
744 ch_src_str,
745 ch_grp_str,
746 pim_ifchannel_ifjoin_name(ch->ifjoin_state),
747 uptime,
748 expire,
749 prune,
750 VTY_NEWLINE);
751 } /* scan interface channels */
752 } /* scan interfaces */
753
754}
755
756static void pim_show_neighbors(struct vty *vty)
757{
758 struct listnode *node;
759 struct interface *ifp;
760 time_t now;
761
762 now = pim_time_monotonic_sec();
763
764 vty_out(vty,
765 "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
766 " T=can_disable_join_suppression%s%s",
767 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
768
769 vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
770
771 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
772 struct pim_interface *pim_ifp;
773 struct in_addr ifaddr;
774 struct listnode *neighnode;
775 struct pim_neighbor *neigh;
776
777 pim_ifp = ifp->info;
778
779 if (!pim_ifp)
780 continue;
781
782 if (pim_ifp->pim_sock_fd < 0)
783 continue;
784
785 ifaddr = pim_ifp->primary_address;
786
787 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
788 char uptime[10];
789 char holdtime[10];
790 char expire[10];
791 char neigh_src_str[100];
792 char recv[7];
793
794 pim_inet4_dump("<src?>", neigh->source_addr,
795 neigh_src_str, sizeof(neigh_src_str));
796 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
797 pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
798 pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
799
800 recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
801 recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
802 recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
803 recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
804 recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
805 recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
806 recv[6] = '\0';
807
808 vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
809 ifp->name,
810 inet_ntoa(ifaddr),
811 neigh_src_str,
812 uptime,
813 expire,
814 holdtime,
815 neigh->dr_priority,
816 neigh->generation_id,
817 recv,
818 VTY_NEWLINE);
819 }
820
821
822 }
823}
824
825static void pim_show_lan_prune_delay(struct vty *vty)
826{
827 struct listnode *node;
828 struct interface *ifp;
829
830 vty_out(vty,
831 "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
832 "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
833 "NoDly=number_of_non_lan_delay_neighbors%s"
834 "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
835 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
836
Everton Marques21d1e262014-10-01 18:34:04 -0300837 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 -0300838
839 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
840 struct pim_interface *pim_ifp;
841 struct in_addr ifaddr;
842 struct listnode *neighnode;
843 struct pim_neighbor *neigh;
844
845 pim_ifp = ifp->info;
846
847 if (!pim_ifp)
848 continue;
849
850 if (pim_ifp->pim_sock_fd < 0)
851 continue;
852
853 ifaddr = pim_ifp->primary_address;
854
855 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
856 char neigh_src_str[100];
857
858 pim_inet4_dump("<src?>", neigh->source_addr,
859 neigh_src_str, sizeof(neigh_src_str));
860
Everton Marques21d1e262014-10-01 18:34:04 -0300861 vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u | %-15s %-3s %5u %5u %1u%s",
Everton Marques871dbcf2009-08-11 15:43:05 -0300862 ifp->name,
863 inet_ntoa(ifaddr),
864 pim_ifp->pim_propagation_delay_msec,
865 pim_ifp->pim_override_interval_msec,
866 pim_ifp->pim_number_of_nonlandelay_neighbors,
867 pim_ifp->pim_neighbors_highest_propagation_delay_msec,
868 pim_ifp->pim_neighbors_highest_override_interval_msec,
869 PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
870 neigh_src_str,
871 PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
872 neigh->propagation_delay_msec,
873 neigh->override_interval_msec,
874 PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
875 PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
876 VTY_NEWLINE);
877 }
878
879 }
880}
881
882static void pim_show_jp_override_interval(struct vty *vty)
883{
884 struct listnode *node;
885 struct interface *ifp;
886
887 vty_out(vty,
888 "EffPDelay=effective_propagation_delay (msec)%s"
889 "EffOvrInt=override_interval (msec)%s"
890 "JPOvrInt=jp_override_interval (msec)%s%s",
891 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
892
893 vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
894
895 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
896 struct pim_interface *pim_ifp;
897 struct in_addr ifaddr;
898
899 pim_ifp = ifp->info;
900
901 if (!pim_ifp)
902 continue;
903
904 if (pim_ifp->pim_sock_fd < 0)
905 continue;
906
907 ifaddr = pim_ifp->primary_address;
908
909 vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
910 ifp->name,
911 inet_ntoa(ifaddr),
912 pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
913 pim_if_effective_propagation_delay_msec(ifp),
914 pim_if_effective_override_interval_msec(ifp),
915 pim_if_jp_override_interval_msec(ifp),
916 VTY_NEWLINE);
917 }
918}
919
920static void pim_show_neighbors_secondary(struct vty *vty)
921{
922 struct listnode *node;
923 struct interface *ifp;
924
925 vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
926
927 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
928 struct pim_interface *pim_ifp;
929 struct in_addr ifaddr;
930 struct listnode *neighnode;
931 struct pim_neighbor *neigh;
932
933 pim_ifp = ifp->info;
934
935 if (!pim_ifp)
936 continue;
937
938 if (pim_ifp->pim_sock_fd < 0)
939 continue;
940
941 ifaddr = pim_ifp->primary_address;
942
943 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
944 char neigh_src_str[100];
945 struct listnode *prefix_node;
946 struct prefix *p;
947
948 if (!neigh->prefix_list)
949 continue;
950
951 pim_inet4_dump("<src?>", neigh->source_addr,
952 neigh_src_str, sizeof(neigh_src_str));
953
954 for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
955 char neigh_sec_str[100];
956
957 if (p->family != AF_INET)
958 continue;
959
960 pim_inet4_dump("<src?>", p->u.prefix4,
961 neigh_sec_str, sizeof(neigh_sec_str));
962
963 vty_out(vty, "%-9s %-15s %-15s %-15s%s",
964 ifp->name,
965 inet_ntoa(ifaddr),
966 neigh_src_str,
967 neigh_sec_str,
968 VTY_NEWLINE);
969 }
970 }
971 }
972}
973
974static void pim_show_upstream(struct vty *vty)
975{
976 struct listnode *upnode;
977 struct pim_upstream *up;
978 time_t now;
979
980 now = pim_time_monotonic_sec();
981
982 vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
983
984 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
985 char src_str[100];
986 char grp_str[100];
987 char uptime[10];
988 char join_timer[10];
989
990 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
991 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
992 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
993 pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
994
995 vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
996 src_str,
997 grp_str,
998 up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
999 uptime,
1000 join_timer,
1001 up->ref_count,
1002 VTY_NEWLINE);
1003 }
1004}
1005
1006static void pim_show_join_desired(struct vty *vty)
1007{
1008 struct listnode *ifnode;
1009 struct listnode *chnode;
1010 struct interface *ifp;
1011 struct pim_interface *pim_ifp;
1012 struct pim_ifchannel *ch;
Everton Marques871dbcf2009-08-11 15:43:05 -03001013 char src_str[100];
1014 char grp_str[100];
1015
1016 vty_out(vty,
1017 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
1018 VTY_NEWLINE);
1019
1020 /* scan all interfaces */
1021 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1022 pim_ifp = ifp->info;
1023 if (!pim_ifp)
1024 continue;
1025
Everton Marques871dbcf2009-08-11 15:43:05 -03001026 /* scan per-interface (S,G) state */
1027 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
1028 struct pim_upstream *up = ch->upstream;
1029
1030 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1031 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1032
1033 vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
1034 ifp->name,
1035 src_str,
1036 grp_str,
1037 pim_macro_ch_lost_assert(ch) ? "yes" : "no",
1038 pim_macro_chisin_joins(ch) ? "yes" : "no",
1039 pim_macro_chisin_pim_include(ch) ? "yes" : "no",
1040 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
1041 pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
1042 VTY_NEWLINE);
1043 }
1044 }
1045}
1046
1047static void pim_show_upstream_rpf(struct vty *vty)
1048{
1049 struct listnode *upnode;
1050 struct pim_upstream *up;
1051
1052 vty_out(vty,
1053 "Source Group RpfIface RibNextHop RpfAddress %s",
1054 VTY_NEWLINE);
1055
1056 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
1057 char src_str[100];
1058 char grp_str[100];
1059 char rpf_nexthop_str[100];
1060 char rpf_addr_str[100];
1061 struct pim_rpf *rpf;
1062 const char *rpf_ifname;
1063
1064 rpf = &up->rpf;
1065
1066 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1067 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1068 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
1069 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1070
1071 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1072
1073 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
1074 src_str,
1075 grp_str,
1076 rpf_ifname,
1077 rpf_nexthop_str,
1078 rpf_addr_str,
1079 VTY_NEWLINE);
1080 }
1081}
1082
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001083static void show_rpf_refresh_stats(struct vty *vty, time_t now)
Everton Marques613938d2009-08-13 15:39:31 -03001084{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001085 char refresh_uptime[10];
1086
Everton Marquesff752d42010-03-17 10:34:24 -03001087 pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001088
Everton Marques613938d2009-08-13 15:39:31 -03001089 vty_out(vty,
1090 "RPF Cache Refresh Delay: %ld msecs%s"
1091 "RPF Cache Refresh Timer: %ld msecs%s"
1092 "RPF Cache Refresh Requests: %lld%s"
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001093 "RPF Cache Refresh Events: %lld%s"
1094 "RPF Cache Refresh Last: %s%s",
Everton Marques613938d2009-08-13 15:39:31 -03001095 qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
1096 pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
David Lamparter5c697982012-02-16 04:47:56 +01001097 (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
1098 (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001099 refresh_uptime, VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03001100}
1101
Everton Marquesf24200d2014-02-14 16:40:34 -02001102static void show_scan_oil_stats(struct vty *vty, time_t now)
1103{
1104 char uptime_scan_oil[10];
1105 char uptime_mroute_add[10];
1106 char uptime_mroute_del[10];
1107
1108 pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last);
1109 pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last);
1110 pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last);
1111
1112 vty_out(vty,
1113 "Scan OIL - Last: %s Events: %lld%s"
1114 "MFC Add - Last: %s Events: %lld%s"
1115 "MFC Del - Last: %s Events: %lld%s",
1116 uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE,
1117 uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE,
1118 uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE);
1119}
1120
Everton Marques871dbcf2009-08-11 15:43:05 -03001121static void pim_show_rpf(struct vty *vty)
1122{
1123 struct listnode *up_node;
1124 struct pim_upstream *up;
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001125 time_t now = pim_time_monotonic_sec();
Everton Marques871dbcf2009-08-11 15:43:05 -03001126
Everton Marquesbcc4abe2009-08-17 18:18:59 -03001127 show_rpf_refresh_stats(vty, now);
Everton Marques613938d2009-08-13 15:39:31 -03001128
1129 vty_out(vty, "%s", VTY_NEWLINE);
1130
Everton Marques871dbcf2009-08-11 15:43:05 -03001131 vty_out(vty,
1132 "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
1133 VTY_NEWLINE);
1134
Everton Marques871dbcf2009-08-11 15:43:05 -03001135 for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
1136 char src_str[100];
1137 char grp_str[100];
1138 char rpf_addr_str[100];
1139 char rib_nexthop_str[100];
1140 const char *rpf_ifname;
1141 struct pim_rpf *rpf = &up->rpf;
1142
1143 pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
1144 pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
1145 pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1146 pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
1147
1148 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1149
1150 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
1151 src_str,
1152 grp_str,
1153 rpf_ifname,
1154 rpf_addr_str,
1155 rib_nexthop_str,
1156 rpf->source_nexthop.mrib_route_metric,
1157 rpf->source_nexthop.mrib_metric_preference,
1158 VTY_NEWLINE);
1159 }
1160}
1161
1162static void igmp_show_querier(struct vty *vty)
1163{
1164 struct listnode *node;
1165 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001166
1167 vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
1168
1169 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
1170 struct pim_interface *pim_ifp = ifp->info;
1171 struct listnode *sock_node;
1172 struct igmp_sock *igmp;
1173
1174 if (!pim_ifp)
1175 continue;
1176
1177 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1178 char query_hhmmss[10];
1179 char other_hhmmss[10];
1180
1181 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
1182 pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
1183
Everton Marquese96f0af2009-08-11 15:48:02 -03001184 vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03001185 ifp->name,
1186 inet_ntoa(igmp->ifaddr),
1187 igmp->t_igmp_query_timer ? "THIS" : "OTHER",
1188 igmp->startup_query_count,
1189 query_hhmmss,
1190 other_hhmmss,
1191 VTY_NEWLINE);
1192 }
1193 }
1194}
1195
1196static void igmp_show_groups(struct vty *vty)
1197{
1198 struct listnode *ifnode;
1199 struct interface *ifp;
1200 time_t now;
1201
1202 now = pim_time_monotonic_sec();
1203
1204 vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
1205
1206 /* scan interfaces */
1207 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1208 struct pim_interface *pim_ifp = ifp->info;
1209 struct listnode *sock_node;
1210 struct igmp_sock *igmp;
1211
1212 if (!pim_ifp)
1213 continue;
1214
1215 /* scan igmp sockets */
1216 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1217 char ifaddr_str[100];
1218 struct listnode *grpnode;
1219 struct igmp_group *grp;
1220
1221 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1222
1223 /* scan igmp groups */
1224 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1225 char group_str[100];
1226 char hhmmss[10];
1227 char uptime[10];
1228
1229 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1230 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
1231 pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
1232
1233 vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
1234 ifp->name,
1235 ifaddr_str,
1236 group_str,
1237 grp->group_filtermode_isexcl ? "EXCL" : "INCL",
1238 hhmmss,
1239 grp->group_source_list ? listcount(grp->group_source_list) : 0,
1240 igmp_group_compat_mode(igmp, grp),
1241 uptime,
1242 VTY_NEWLINE);
1243
1244 } /* scan igmp groups */
1245 } /* scan igmp sockets */
1246 } /* scan interfaces */
1247}
1248
1249static void igmp_show_group_retransmission(struct vty *vty)
1250{
1251 struct listnode *ifnode;
1252 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001253
1254 vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
1255
1256 /* scan interfaces */
1257 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1258 struct pim_interface *pim_ifp = ifp->info;
1259 struct listnode *sock_node;
1260 struct igmp_sock *igmp;
1261
1262 if (!pim_ifp)
1263 continue;
1264
1265 /* scan igmp sockets */
1266 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1267 char ifaddr_str[100];
1268 struct listnode *grpnode;
1269 struct igmp_group *grp;
1270
1271 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1272
1273 /* scan igmp groups */
1274 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1275 char group_str[100];
1276 char grp_retr_mmss[10];
1277 struct listnode *src_node;
1278 struct igmp_source *src;
1279 int grp_retr_sources = 0;
1280
1281 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1282 pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
1283
1284
1285 /* count group sources with retransmission state */
1286 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
1287 if (src->source_query_retransmit_count > 0) {
1288 ++grp_retr_sources;
1289 }
1290 }
1291
1292 vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
1293 ifp->name,
1294 ifaddr_str,
1295 group_str,
1296 grp_retr_mmss,
1297 grp->group_specific_query_retransmit_count,
1298 grp_retr_sources,
1299 VTY_NEWLINE);
1300
1301 } /* scan igmp groups */
1302 } /* scan igmp sockets */
1303 } /* scan interfaces */
1304}
1305
1306static void igmp_show_parameters(struct vty *vty)
1307{
1308 struct listnode *ifnode;
1309 struct interface *ifp;
1310
1311 vty_out(vty,
1312 "QRV: Robustness Variable SQI: Startup Query Interval%s"
1313 "QQI: Query Interval OQPI: Other Querier Present Interval%s"
1314 "QRI: Query Response Interval LMQT: Last Member Query Time%s"
1315 "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
1316 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1317
1318 vty_out(vty,
1319 "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
1320 VTY_NEWLINE);
1321
1322 /* scan interfaces */
1323 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1324 struct pim_interface *pim_ifp = ifp->info;
1325 struct listnode *sock_node;
1326 struct igmp_sock *igmp;
1327
1328 if (!pim_ifp)
1329 continue;
1330
1331 /* scan igmp sockets */
1332 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1333 char ifaddr_str[100];
1334 long gmi_dsec; /* Group Membership Interval */
1335 long oqpi_dsec; /* Other Querier Present Interval */
1336 int sqi;
1337 long lmqt_dsec;
1338 long ohpi_dsec;
1339 long qri_dsec;
1340
1341 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1342
1343 gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
1344 igmp->querier_query_interval,
1345 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1346
1347 sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
1348
1349 oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
1350 igmp->querier_query_interval,
1351 pim_ifp->igmp_query_max_response_time_dsec) / 100;
1352
1353 lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
1354 igmp->querier_robustness_variable) / 100;
1355
1356 ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
1357 igmp->querier_query_interval,
1358 pim_ifp->igmp_query_max_response_time_dsec);
1359
1360 qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
1361
1362 vty_out(vty,
1363 "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
1364 ifp->name,
1365 ifaddr_str,
1366 igmp->querier_robustness_variable,
1367 igmp->querier_query_interval,
1368 qri_dsec / 10, qri_dsec % 10,
1369 gmi_dsec / 10, gmi_dsec % 10,
1370 sqi,
1371 oqpi_dsec / 10, oqpi_dsec % 10,
1372 lmqt_dsec / 10, lmqt_dsec % 10,
1373 ohpi_dsec / 10, ohpi_dsec % 10,
1374 VTY_NEWLINE);
1375
1376 } /* scan igmp sockets */
1377 } /* scan interfaces */
1378}
1379
1380static void igmp_show_sources(struct vty *vty)
1381{
1382 struct listnode *ifnode;
1383 struct interface *ifp;
1384 time_t now;
1385
1386 now = pim_time_monotonic_sec();
1387
1388 vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
1389
1390 /* scan interfaces */
1391 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1392 struct pim_interface *pim_ifp = ifp->info;
1393 struct listnode *sock_node;
1394 struct igmp_sock *igmp;
1395
1396 if (!pim_ifp)
1397 continue;
1398
1399 /* scan igmp sockets */
1400 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1401 char ifaddr_str[100];
1402 struct listnode *grpnode;
1403 struct igmp_group *grp;
1404
1405 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1406
1407 /* scan igmp groups */
1408 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1409 char group_str[100];
1410 struct listnode *srcnode;
1411 struct igmp_source *src;
1412
1413 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1414
1415 /* scan group sources */
1416 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1417 char source_str[100];
1418 char mmss[10];
1419 char uptime[10];
1420
1421 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1422
1423 pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
1424
1425 pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
1426
1427 vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
1428 ifp->name,
1429 ifaddr_str,
1430 group_str,
1431 source_str,
1432 mmss,
1433 IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
1434 uptime,
1435 VTY_NEWLINE);
1436
1437 } /* scan group sources */
1438 } /* scan igmp groups */
1439 } /* scan igmp sockets */
1440 } /* scan interfaces */
1441}
1442
1443static void igmp_show_source_retransmission(struct vty *vty)
1444{
1445 struct listnode *ifnode;
1446 struct interface *ifp;
Everton Marques871dbcf2009-08-11 15:43:05 -03001447
1448 vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
1449
1450 /* scan interfaces */
1451 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
1452 struct pim_interface *pim_ifp = ifp->info;
1453 struct listnode *sock_node;
1454 struct igmp_sock *igmp;
1455
1456 if (!pim_ifp)
1457 continue;
1458
1459 /* scan igmp sockets */
1460 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
1461 char ifaddr_str[100];
1462 struct listnode *grpnode;
1463 struct igmp_group *grp;
1464
1465 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
1466
1467 /* scan igmp groups */
1468 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
1469 char group_str[100];
1470 struct listnode *srcnode;
1471 struct igmp_source *src;
1472
1473 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
1474
1475 /* scan group sources */
1476 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
1477 char source_str[100];
1478
1479 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
1480
1481 vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
1482 ifp->name,
1483 ifaddr_str,
1484 group_str,
1485 source_str,
1486 src->source_query_retransmit_count,
1487 VTY_NEWLINE);
1488
1489 } /* scan group sources */
1490 } /* scan igmp groups */
1491 } /* scan igmp sockets */
1492 } /* scan interfaces */
1493}
1494
1495static void clear_igmp_interfaces()
1496{
1497 struct listnode *ifnode;
1498 struct listnode *ifnextnode;
1499 struct interface *ifp;
1500
1501 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1502 pim_if_addr_del_all_igmp(ifp);
1503 }
1504
1505 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1506 pim_if_addr_add_all(ifp);
1507 }
1508}
1509
1510static void clear_pim_interfaces()
1511{
1512 struct listnode *ifnode;
1513 struct listnode *ifnextnode;
1514 struct interface *ifp;
1515
1516 for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
1517 if (ifp->info) {
1518 pim_neighbor_delete_all(ifp, "interface cleared");
1519 }
1520 }
1521}
1522
1523static void clear_interfaces()
1524{
1525 clear_igmp_interfaces();
1526 clear_pim_interfaces();
1527}
1528
1529DEFUN (pim_interface,
1530 pim_interface_cmd,
1531 "interface IFNAME",
1532 "Select an interface to configure\n"
1533 "Interface's name\n")
1534{
1535 struct interface *ifp;
1536 const char *ifname = argv[0];
1537 size_t sl;
1538
1539 sl = strlen(ifname);
1540 if (sl > INTERFACE_NAMSIZ) {
1541 vty_out(vty, "%% Interface name %s is invalid: length exceeds "
1542 "%d characters%s",
1543 ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546
1547 ifp = if_lookup_by_name_len(ifname, sl);
1548 if (!ifp) {
1549 vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
1550
1551 /* Returning here would prevent pimd from booting when there are
1552 interface commands in pimd.conf, since all interfaces are
1553 unknown at pimd boot time (the zebra daemon has not been
1554 contacted for interface discovery). */
1555
1556 ifp = if_get_by_name_len(ifname, sl);
1557 if (!ifp) {
1558 vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
1559 return CMD_WARNING;
1560 }
1561 }
1562
1563 vty->index = ifp;
1564 vty->node = INTERFACE_NODE;
1565
1566 return CMD_SUCCESS;
1567}
1568
1569DEFUN (clear_ip_interfaces,
1570 clear_ip_interfaces_cmd,
1571 "clear ip interfaces",
1572 CLEAR_STR
1573 IP_STR
1574 "Reset interfaces\n")
1575{
1576 clear_interfaces();
1577
1578 return CMD_SUCCESS;
1579}
1580
1581DEFUN (clear_ip_igmp_interfaces,
1582 clear_ip_igmp_interfaces_cmd,
1583 "clear ip igmp interfaces",
1584 CLEAR_STR
1585 IP_STR
1586 CLEAR_IP_IGMP_STR
1587 "Reset IGMP interfaces\n")
1588{
1589 clear_igmp_interfaces();
1590
1591 return CMD_SUCCESS;
1592}
1593
Everton Marquesf24200d2014-02-14 16:40:34 -02001594static void mroute_add_all()
1595{
1596 struct listnode *node;
1597 struct channel_oil *c_oil;
1598
1599 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1600 if (pim_mroute_add(&c_oil->oil)) {
1601 /* just log warning */
1602 char source_str[100];
1603 char group_str[100];
1604 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1605 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1606 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
1607 __FILE__, __PRETTY_FUNCTION__,
1608 source_str, group_str);
1609 }
1610 }
1611}
1612
1613static void mroute_del_all()
1614{
1615 struct listnode *node;
1616 struct channel_oil *c_oil;
1617
1618 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
1619 if (pim_mroute_del(&c_oil->oil)) {
1620 /* just log warning */
1621 char source_str[100];
1622 char group_str[100];
1623 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
1624 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
1625 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
1626 __FILE__, __PRETTY_FUNCTION__,
1627 source_str, group_str);
1628 }
1629 }
1630}
1631
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05001632static void static_mroute_add_all()
1633{
1634 struct listnode *node;
1635 struct static_route *s_route;
1636
1637 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
1638 if (pim_mroute_add(&s_route->mc)) {
1639 /* just log warning */
1640 char source_str[100];
1641 char group_str[100];
1642 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
1643 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
1644 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
1645 __FILE__, __PRETTY_FUNCTION__,
1646 source_str, group_str);
1647 }
1648 }
1649}
1650
1651static void static_mroute_del_all()
1652{
1653 struct listnode *node;
1654 struct static_route *s_route;
1655
1656 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
1657 if (pim_mroute_del(&s_route->mc)) {
1658 /* just log warning */
1659 char source_str[100];
1660 char group_str[100];
1661 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
1662 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
1663 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
1664 __FILE__, __PRETTY_FUNCTION__,
1665 source_str, group_str);
1666 }
1667 }
1668}
1669
Everton Marquesf24200d2014-02-14 16:40:34 -02001670DEFUN (clear_ip_mroute,
1671 clear_ip_mroute_cmd,
1672 "clear ip mroute",
1673 CLEAR_STR
1674 IP_STR
1675 "Reset multicast routes\n")
1676{
1677 mroute_del_all();
1678 mroute_add_all();
1679
1680 return CMD_SUCCESS;
1681}
1682
Everton Marques871dbcf2009-08-11 15:43:05 -03001683DEFUN (clear_ip_pim_interfaces,
1684 clear_ip_pim_interfaces_cmd,
1685 "clear ip pim interfaces",
1686 CLEAR_STR
1687 IP_STR
1688 CLEAR_IP_PIM_STR
1689 "Reset PIM interfaces\n")
1690{
1691 clear_pim_interfaces();
1692
1693 return CMD_SUCCESS;
1694}
1695
Everton Marquesf24200d2014-02-14 16:40:34 -02001696DEFUN (clear_ip_pim_oil,
1697 clear_ip_pim_oil_cmd,
1698 "clear ip pim oil",
1699 CLEAR_STR
1700 IP_STR
1701 CLEAR_IP_PIM_STR
1702 "Rescan PIM OIL (output interface list)\n")
1703{
1704 pim_scan_oil();
1705
1706 return CMD_SUCCESS;
1707}
1708
Everton Marques871dbcf2009-08-11 15:43:05 -03001709DEFUN (show_ip_igmp_interface,
1710 show_ip_igmp_interface_cmd,
1711 "show ip igmp interface",
1712 SHOW_STR
1713 IP_STR
1714 IGMP_STR
1715 "IGMP interface information\n")
1716{
1717 igmp_show_interfaces(vty);
1718
1719 return CMD_SUCCESS;
1720}
1721
Everton Marques567f9272010-02-19 19:07:00 -02001722DEFUN (show_ip_igmp_join,
1723 show_ip_igmp_join_cmd,
1724 "show ip igmp join",
1725 SHOW_STR
1726 IP_STR
1727 IGMP_STR
1728 "IGMP static join information\n")
1729{
1730 igmp_show_interface_join(vty);
1731
1732 return CMD_SUCCESS;
1733}
1734
Everton Marques871dbcf2009-08-11 15:43:05 -03001735DEFUN (show_ip_igmp_groups,
1736 show_ip_igmp_groups_cmd,
1737 "show ip igmp groups",
1738 SHOW_STR
1739 IP_STR
1740 IGMP_STR
1741 IGMP_GROUP_STR)
1742{
1743 igmp_show_groups(vty);
1744
1745 return CMD_SUCCESS;
1746}
1747
1748DEFUN (show_ip_igmp_groups_retransmissions,
1749 show_ip_igmp_groups_retransmissions_cmd,
1750 "show ip igmp groups retransmissions",
1751 SHOW_STR
1752 IP_STR
1753 IGMP_STR
1754 IGMP_GROUP_STR
1755 "IGMP group retransmissions\n")
1756{
1757 igmp_show_group_retransmission(vty);
1758
1759 return CMD_SUCCESS;
1760}
1761
1762DEFUN (show_ip_igmp_parameters,
1763 show_ip_igmp_parameters_cmd,
1764 "show ip igmp parameters",
1765 SHOW_STR
1766 IP_STR
1767 IGMP_STR
1768 "IGMP parameters information\n")
1769{
1770 igmp_show_parameters(vty);
1771
1772 return CMD_SUCCESS;
1773}
1774
1775DEFUN (show_ip_igmp_sources,
1776 show_ip_igmp_sources_cmd,
1777 "show ip igmp sources",
1778 SHOW_STR
1779 IP_STR
1780 IGMP_STR
1781 IGMP_SOURCE_STR)
1782{
1783 igmp_show_sources(vty);
1784
1785 return CMD_SUCCESS;
1786}
1787
1788DEFUN (show_ip_igmp_sources_retransmissions,
1789 show_ip_igmp_sources_retransmissions_cmd,
1790 "show ip igmp sources retransmissions",
1791 SHOW_STR
1792 IP_STR
1793 IGMP_STR
1794 IGMP_SOURCE_STR
1795 "IGMP source retransmissions\n")
1796{
1797 igmp_show_source_retransmission(vty);
1798
1799 return CMD_SUCCESS;
1800}
1801
1802DEFUN (show_ip_igmp_querier,
1803 show_ip_igmp_querier_cmd,
1804 "show ip igmp querier",
1805 SHOW_STR
1806 IP_STR
1807 IGMP_STR
1808 "IGMP querier information\n")
1809{
1810 igmp_show_querier(vty);
1811
1812 return CMD_SUCCESS;
1813}
1814
1815DEFUN (show_ip_pim_address,
1816 show_ip_pim_address_cmd,
1817 "show ip pim address",
1818 SHOW_STR
1819 IP_STR
1820 PIM_STR
1821 "PIM interface address\n")
1822{
1823 show_interface_address(vty);
1824
1825 return CMD_SUCCESS;
1826}
1827
1828DEFUN (show_ip_pim_assert,
1829 show_ip_pim_assert_cmd,
1830 "show ip pim assert",
1831 SHOW_STR
1832 IP_STR
1833 PIM_STR
1834 "PIM interface assert\n")
1835{
1836 pim_show_assert(vty);
1837
1838 return CMD_SUCCESS;
1839}
1840
1841DEFUN (show_ip_pim_assert_internal,
1842 show_ip_pim_assert_internal_cmd,
1843 "show ip pim assert-internal",
1844 SHOW_STR
1845 IP_STR
1846 PIM_STR
1847 "PIM interface internal assert state\n")
1848{
1849 pim_show_assert_internal(vty);
1850
1851 return CMD_SUCCESS;
1852}
1853
1854DEFUN (show_ip_pim_assert_metric,
1855 show_ip_pim_assert_metric_cmd,
1856 "show ip pim assert-metric",
1857 SHOW_STR
1858 IP_STR
1859 PIM_STR
1860 "PIM interface assert metric\n")
1861{
1862 pim_show_assert_metric(vty);
1863
1864 return CMD_SUCCESS;
1865}
1866
1867DEFUN (show_ip_pim_assert_winner_metric,
1868 show_ip_pim_assert_winner_metric_cmd,
1869 "show ip pim assert-winner-metric",
1870 SHOW_STR
1871 IP_STR
1872 PIM_STR
1873 "PIM interface assert winner metric\n")
1874{
1875 pim_show_assert_winner_metric(vty);
1876
1877 return CMD_SUCCESS;
1878}
1879
1880DEFUN (show_ip_pim_dr,
1881 show_ip_pim_dr_cmd,
1882 "show ip pim designated-router",
1883 SHOW_STR
1884 IP_STR
1885 PIM_STR
1886 "PIM interface designated router\n")
1887{
1888 pim_show_dr(vty);
1889
1890 return CMD_SUCCESS;
1891}
1892
1893DEFUN (show_ip_pim_hello,
1894 show_ip_pim_hello_cmd,
1895 "show ip pim hello",
1896 SHOW_STR
1897 IP_STR
1898 PIM_STR
1899 "PIM interface hello information\n")
1900{
1901 pim_show_hello(vty);
1902
1903 return CMD_SUCCESS;
1904}
1905
1906DEFUN (show_ip_pim_interface,
1907 show_ip_pim_interface_cmd,
1908 "show ip pim interface",
1909 SHOW_STR
1910 IP_STR
1911 PIM_STR
1912 "PIM interface information\n")
1913{
1914 pim_show_interfaces(vty);
1915
1916 return CMD_SUCCESS;
1917}
1918
1919DEFUN (show_ip_pim_join,
1920 show_ip_pim_join_cmd,
1921 "show ip pim join",
1922 SHOW_STR
1923 IP_STR
1924 PIM_STR
1925 "PIM interface join information\n")
1926{
1927 pim_show_join(vty);
1928
1929 return CMD_SUCCESS;
1930}
1931
1932DEFUN (show_ip_pim_lan_prune_delay,
1933 show_ip_pim_lan_prune_delay_cmd,
1934 "show ip pim lan-prune-delay",
1935 SHOW_STR
1936 IP_STR
1937 PIM_STR
1938 "PIM neighbors LAN prune delay parameters\n")
1939{
1940 pim_show_lan_prune_delay(vty);
1941
1942 return CMD_SUCCESS;
1943}
1944
1945DEFUN (show_ip_pim_local_membership,
1946 show_ip_pim_local_membership_cmd,
1947 "show ip pim local-membership",
1948 SHOW_STR
1949 IP_STR
1950 PIM_STR
1951 "PIM interface local-membership\n")
1952{
1953 pim_show_membership(vty);
1954
1955 return CMD_SUCCESS;
1956}
1957
1958DEFUN (show_ip_pim_jp_override_interval,
1959 show_ip_pim_jp_override_interval_cmd,
1960 "show ip pim jp-override-interval",
1961 SHOW_STR
1962 IP_STR
1963 PIM_STR
1964 "PIM interface J/P override interval\n")
1965{
1966 pim_show_jp_override_interval(vty);
1967
1968 return CMD_SUCCESS;
1969}
1970
1971DEFUN (show_ip_pim_neighbor,
1972 show_ip_pim_neighbor_cmd,
1973 "show ip pim neighbor",
1974 SHOW_STR
1975 IP_STR
1976 PIM_STR
1977 "PIM neighbor information\n")
1978{
1979 pim_show_neighbors(vty);
1980
1981 return CMD_SUCCESS;
1982}
1983
1984DEFUN (show_ip_pim_secondary,
1985 show_ip_pim_secondary_cmd,
1986 "show ip pim secondary",
1987 SHOW_STR
1988 IP_STR
1989 PIM_STR
1990 "PIM neighbor addresses\n")
1991{
1992 pim_show_neighbors_secondary(vty);
1993
1994 return CMD_SUCCESS;
1995}
1996
1997DEFUN (show_ip_pim_upstream,
1998 show_ip_pim_upstream_cmd,
1999 "show ip pim upstream",
2000 SHOW_STR
2001 IP_STR
2002 PIM_STR
2003 "PIM upstream information\n")
2004{
2005 pim_show_upstream(vty);
2006
2007 return CMD_SUCCESS;
2008}
2009
2010DEFUN (show_ip_pim_upstream_join_desired,
2011 show_ip_pim_upstream_join_desired_cmd,
2012 "show ip pim upstream-join-desired",
2013 SHOW_STR
2014 IP_STR
2015 PIM_STR
2016 "PIM upstream join-desired\n")
2017{
2018 pim_show_join_desired(vty);
2019
2020 return CMD_SUCCESS;
2021}
2022
2023DEFUN (show_ip_pim_upstream_rpf,
2024 show_ip_pim_upstream_rpf_cmd,
2025 "show ip pim upstream-rpf",
2026 SHOW_STR
2027 IP_STR
2028 PIM_STR
2029 "PIM upstream source rpf\n")
2030{
2031 pim_show_upstream_rpf(vty);
2032
2033 return CMD_SUCCESS;
2034}
2035
2036DEFUN (show_ip_pim_rpf,
2037 show_ip_pim_rpf_cmd,
2038 "show ip pim rpf",
2039 SHOW_STR
2040 IP_STR
2041 PIM_STR
2042 "PIM cached source rpf information\n")
2043{
2044 pim_show_rpf(vty);
2045
2046 return CMD_SUCCESS;
2047}
2048
2049static void show_multicast_interfaces(struct vty *vty)
2050{
2051 struct listnode *node;
2052 struct interface *ifp;
2053
2054 vty_out(vty, "%s", VTY_NEWLINE);
2055
Everton Marques613938d2009-08-13 15:39:31 -03002056 vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03002057 VTY_NEWLINE);
2058
2059 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
2060 struct pim_interface *pim_ifp;
2061 struct in_addr ifaddr;
2062 struct sioc_vif_req vreq;
2063
2064 pim_ifp = ifp->info;
2065
2066 if (!pim_ifp)
2067 continue;
2068
2069 memset(&vreq, 0, sizeof(vreq));
2070 vreq.vifi = pim_ifp->mroute_vif_index;
2071
2072 if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
Donald Sharpd2c6da22015-07-02 09:53:59 -04002073 zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s",
2074 (unsigned long)SIOCGETVIFCNT,
2075 ifp->name,
2076 pim_ifp->mroute_vif_index,
2077 errno,
2078 safe_strerror(errno),
2079 VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002080 }
2081
2082 ifaddr = pim_ifp->primary_address;
2083
Everton Marques613938d2009-08-13 15:39:31 -03002084 vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03002085 ifp->name,
2086 inet_ntoa(ifaddr),
2087 ifp->ifindex,
2088 pim_ifp->mroute_vif_index,
2089 vreq.icount,
2090 vreq.ocount,
2091 vreq.ibytes,
2092 vreq.obytes,
2093 VTY_NEWLINE);
2094 }
2095}
2096
2097DEFUN (show_ip_multicast,
2098 show_ip_multicast_cmd,
2099 "show ip multicast",
2100 SHOW_STR
2101 IP_STR
2102 "Multicast global information\n")
2103{
Everton Marquesbcc4abe2009-08-17 18:18:59 -03002104 time_t now = pim_time_monotonic_sec();
2105
Everton Marques871dbcf2009-08-11 15:43:05 -03002106 if (PIM_MROUTE_IS_ENABLED) {
Everton Marques871dbcf2009-08-11 15:43:05 -03002107 char uptime[10];
2108
2109 vty_out(vty, "Mroute socket descriptor: %d%s",
2110 qpim_mroute_socket_fd,
2111 VTY_NEWLINE);
2112
Everton Marques871dbcf2009-08-11 15:43:05 -03002113 pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
2114 vty_out(vty, "Mroute socket uptime: %s%s",
2115 uptime,
2116 VTY_NEWLINE);
2117 }
2118 else {
2119 vty_out(vty, "Multicast disabled%s",
2120 VTY_NEWLINE);
2121 }
2122
2123 vty_out(vty, "%s", VTY_NEWLINE);
Everton Marquese324ddc2014-09-29 17:59:02 -03002124 vty_out(vty, "Zclient update socket: ");
2125 if (qpim_zclient_update) {
Everton Marquesddc66592014-09-30 16:49:36 -03002126 vty_out(vty, "%d failures=%d%s", qpim_zclient_update->sock,
2127 qpim_zclient_update->fail, VTY_NEWLINE);
Everton Marquese324ddc2014-09-29 17:59:02 -03002128 }
2129 else {
2130 vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
2131 }
2132 vty_out(vty, "Zclient lookup socket: ");
2133 if (qpim_zclient_lookup) {
Everton Marquesddc66592014-09-30 16:49:36 -03002134 vty_out(vty, "%d failures=%d%s", qpim_zclient_lookup->sock,
2135 qpim_zclient_lookup->fail, VTY_NEWLINE);
Everton Marquese324ddc2014-09-29 17:59:02 -03002136 }
2137 else {
2138 vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
2139 }
2140
2141 vty_out(vty, "%s", VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002142 vty_out(vty, "Current highest VifIndex: %d%s",
2143 qpim_mroute_oif_highest_vif_index,
2144 VTY_NEWLINE);
2145 vty_out(vty, "Maximum highest VifIndex: %d%s",
2146 MAXVIFS - 1,
2147 VTY_NEWLINE);
2148
2149 vty_out(vty, "%s", VTY_NEWLINE);
2150 vty_out(vty, "Upstream Join Timer: %d secs%s",
2151 qpim_t_periodic,
2152 VTY_NEWLINE);
2153 vty_out(vty, "Join/Prune Holdtime: %d secs%s",
2154 PIM_JP_HOLDTIME,
2155 VTY_NEWLINE);
2156
2157 vty_out(vty, "%s", VTY_NEWLINE);
Everton Marques613938d2009-08-13 15:39:31 -03002158
Everton Marquesbcc4abe2009-08-17 18:18:59 -03002159 show_rpf_refresh_stats(vty, now);
Everton Marques871dbcf2009-08-11 15:43:05 -03002160
Everton Marquesf24200d2014-02-14 16:40:34 -02002161 vty_out(vty, "%s", VTY_NEWLINE);
2162
2163 show_scan_oil_stats(vty, now);
2164
Everton Marques871dbcf2009-08-11 15:43:05 -03002165 show_multicast_interfaces(vty);
2166
2167 return CMD_SUCCESS;
2168}
2169
2170static void show_mroute(struct vty *vty)
2171{
2172 struct listnode *node;
2173 struct channel_oil *c_oil;
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002174 struct static_route *s_route;
Everton Marques871dbcf2009-08-11 15:43:05 -03002175 time_t now;
2176
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002177 vty_out(vty, "Proto: I=IGMP P=PIM S=STATIC%s%s", VTY_NEWLINE, VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002178
2179 vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
2180 VTY_NEWLINE);
2181
2182 now = pim_time_monotonic_sec();
2183
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002184 /* print list of PIM and IGMP routes */
Everton Marques871dbcf2009-08-11 15:43:05 -03002185 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2186 char group_str[100];
2187 char source_str[100];
2188 int oif_vif_index;
2189
2190 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2191 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2192
2193 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2194 struct interface *ifp_in;
2195 struct interface *ifp_out;
2196 char oif_uptime[10];
2197 int ttl;
2198 char proto[5];
2199
2200 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
2201 if (ttl < 1)
2202 continue;
2203
2204 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
2205 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2206
2207 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
2208
2209 proto[0] = '\0';
2210 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
2211 strcat(proto, "P");
2212 }
2213 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
2214 strcat(proto, "I");
2215 }
2216
2217 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2218 source_str,
2219 group_str,
2220 proto,
2221 ifp_in ? ifp_in->name : "<iif?>",
2222 c_oil->oil.mfcc_parent,
2223 ifp_out ? ifp_out->name : "<oif?>",
2224 oif_vif_index,
2225 ttl,
2226 oif_uptime,
2227 VTY_NEWLINE);
2228 }
2229 }
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002230
2231 /* Print list of static routes */
2232 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
2233 char group_str[100];
2234 char source_str[100];
2235 int oif_vif_index;
2236
2237 pim_inet4_dump("<group?>", s_route->group, group_str, sizeof(group_str));
2238 pim_inet4_dump("<source?>", s_route->source, source_str, sizeof(source_str));
2239
2240 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
2241 struct interface *ifp_in;
2242 struct interface *ifp_out;
2243 char oif_uptime[10];
2244 int ttl;
2245 char proto[5];
2246
2247 ttl = s_route->oif_ttls[oif_vif_index];
2248 if (ttl < 1)
2249 continue;
2250
2251 ifp_in = pim_if_find_by_vif_index(s_route->iif);
2252 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
2253
2254 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - s_route->creation[oif_vif_index]);
2255
2256 proto[0] = '\0';
2257 strcat(proto, "S");
2258
2259 vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
2260 source_str,
2261 group_str,
2262 proto,
2263 ifp_in ? ifp_in->name : "<iif?>",
2264 s_route->iif,
2265 ifp_out ? ifp_out->name : "<oif?>",
2266 oif_vif_index,
2267 ttl,
2268 oif_uptime,
2269 VTY_NEWLINE);
2270 }
2271 }
Everton Marques871dbcf2009-08-11 15:43:05 -03002272}
2273
2274DEFUN (show_ip_mroute,
2275 show_ip_mroute_cmd,
2276 "show ip mroute",
2277 SHOW_STR
2278 IP_STR
2279 MROUTE_STR)
2280{
2281 show_mroute(vty);
2282 return CMD_SUCCESS;
2283}
2284
2285static void show_mroute_count(struct vty *vty)
2286{
2287 struct listnode *node;
2288 struct channel_oil *c_oil;
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002289 struct static_route *s_route;
Everton Marques871dbcf2009-08-11 15:43:05 -03002290
2291 vty_out(vty, "%s", VTY_NEWLINE);
2292
2293 vty_out(vty, "Source Group Packets Bytes WrongIf %s",
2294 VTY_NEWLINE);
2295
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002296 /* Print PIM and IGMP route counts */
Everton Marques871dbcf2009-08-11 15:43:05 -03002297 for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
2298 char group_str[100];
2299 char source_str[100];
2300 struct sioc_sg_req sgreq;
2301
2302 memset(&sgreq, 0, sizeof(sgreq));
2303 sgreq.src = c_oil->oil.mfcc_origin;
2304 sgreq.grp = c_oil->oil.mfcc_mcastgrp;
2305
2306 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2307 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2308
2309 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2310 int e = errno;
2311 vty_out(vty,
David Lamparterc7879ea2015-03-04 06:37:20 +01002312 "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2313 (unsigned long)SIOCGETSGCNT,
Everton Marques871dbcf2009-08-11 15:43:05 -03002314 source_str,
2315 group_str,
2316 e,
Everton Marquese96f0af2009-08-11 15:48:02 -03002317 safe_strerror(e),
Everton Marques871dbcf2009-08-11 15:43:05 -03002318 VTY_NEWLINE);
2319 continue;
2320 }
2321
2322 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2323 source_str,
2324 group_str,
2325 sgreq.pktcnt,
2326 sgreq.bytecnt,
2327 sgreq.wrong_if,
2328 VTY_NEWLINE);
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002329 }
Everton Marques871dbcf2009-08-11 15:43:05 -03002330
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002331 /* Print static route counts */
2332 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
2333 char group_str[100];
2334 char source_str[100];
2335 struct sioc_sg_req sgreq;
2336
2337 memset(&sgreq, 0, sizeof(sgreq));
2338 sgreq.src = s_route->mc.mfcc_origin;
2339 sgreq.grp = s_route->mc.mfcc_mcastgrp;
2340
2341 pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
2342 pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
2343
2344 if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
2345 int e = errno;
2346 vty_out(vty,
2347 "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
2348 SIOCGETSGCNT,
2349 source_str,
2350 group_str,
2351 e,
2352 safe_strerror(e),
2353 VTY_NEWLINE);
2354 continue;
2355 }
2356
2357 vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
2358 source_str,
2359 group_str,
2360 sgreq.pktcnt,
2361 sgreq.bytecnt,
2362 sgreq.wrong_if,
2363 VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002364 }
2365}
2366
2367DEFUN (show_ip_mroute_count,
2368 show_ip_mroute_count_cmd,
2369 "show ip mroute count",
2370 SHOW_STR
2371 IP_STR
2372 MROUTE_STR
2373 "Route and packet count data\n")
2374{
2375 show_mroute_count(vty);
2376 return CMD_SUCCESS;
2377}
2378
Everton Marques05e573d2010-04-20 12:20:46 -03002379DEFUN (show_ip_rib,
2380 show_ip_rib_cmd,
2381 "show ip rib A.B.C.D",
Everton Marques871dbcf2009-08-11 15:43:05 -03002382 SHOW_STR
2383 IP_STR
Everton Marques05e573d2010-04-20 12:20:46 -03002384 RIB_STR
Everton Marques871dbcf2009-08-11 15:43:05 -03002385 "Unicast address\n")
2386{
2387 struct in_addr addr;
2388 const char *addr_str;
2389 struct pim_nexthop nexthop;
2390 char nexthop_addr_str[100];
2391 int result;
2392
2393 addr_str = argv[0];
2394 result = inet_pton(AF_INET, addr_str, &addr);
2395 if (result <= 0) {
2396 vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002397 addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002398 return CMD_WARNING;
2399 }
2400
2401 if (pim_nexthop_lookup(&nexthop, addr)) {
2402 vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
2403 addr_str, VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 vty_out(vty, "Address NextHop Interface Metric Preference%s",
2408 VTY_NEWLINE);
2409
2410 pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
2411 nexthop_addr_str, sizeof(nexthop_addr_str));
2412
2413 vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
2414 addr_str,
2415 nexthop_addr_str,
2416 nexthop.interface ? nexthop.interface->name : "<ifname?>",
2417 nexthop.mrib_route_metric,
2418 nexthop.mrib_metric_preference,
2419 VTY_NEWLINE);
2420
2421 return CMD_SUCCESS;
2422}
2423
Everton Marques824adbe2009-10-08 09:16:27 -03002424static void show_ssmpingd(struct vty *vty)
2425{
2426 struct listnode *node;
2427 struct ssmpingd_sock *ss;
2428 time_t now;
2429
Everton Marquese8c11bb2009-10-08 15:06:32 -03002430 vty_out(vty, "Source Socket Address Port Uptime Requests%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002431 VTY_NEWLINE);
2432
2433 if (!qpim_ssmpingd_list)
2434 return;
2435
2436 now = pim_time_monotonic_sec();
2437
2438 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
2439 char source_str[100];
2440 char ss_uptime[10];
Everton Marquese8c11bb2009-10-08 15:06:32 -03002441 struct sockaddr_in bind_addr;
David Lampartere269b962012-02-16 04:32:08 +00002442 socklen_t len = sizeof(bind_addr);
Everton Marquese8c11bb2009-10-08 15:06:32 -03002443 char bind_addr_str[100];
Everton Marques824adbe2009-10-08 09:16:27 -03002444
2445 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
Everton Marquese8c11bb2009-10-08 15:06:32 -03002446
2447 if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
2448 vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
2449 source_str, ss->sock_fd, VTY_NEWLINE);
2450 }
2451
2452 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
Everton Marques824adbe2009-10-08 09:16:27 -03002453 pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
2454
Everton Marquese8c11bb2009-10-08 15:06:32 -03002455 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
Everton Marques824adbe2009-10-08 09:16:27 -03002456 source_str,
2457 ss->sock_fd,
Everton Marquese8c11bb2009-10-08 15:06:32 -03002458 bind_addr_str,
2459 ntohs(bind_addr.sin_port),
Everton Marques824adbe2009-10-08 09:16:27 -03002460 ss_uptime,
David Lamparter5c697982012-02-16 04:47:56 +01002461 (long long)ss->requests,
Everton Marques824adbe2009-10-08 09:16:27 -03002462 VTY_NEWLINE);
2463 }
2464}
2465
2466DEFUN (show_ip_ssmpingd,
2467 show_ip_ssmpingd_cmd,
2468 "show ip ssmpingd",
2469 SHOW_STR
2470 IP_STR
2471 SHOW_SSMPINGD_STR)
2472{
2473 show_ssmpingd(vty);
2474 return CMD_SUCCESS;
2475}
2476
Everton Marques871dbcf2009-08-11 15:43:05 -03002477DEFUN (ip_multicast_routing,
2478 ip_multicast_routing_cmd,
2479 PIM_CMD_IP_MULTICAST_ROUTING,
2480 IP_STR
2481 "Enable IP multicast forwarding\n")
2482{
2483 pim_mroute_socket_enable();
2484 pim_if_add_vif_all();
2485 mroute_add_all();
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002486 static_mroute_add_all();
Everton Marques871dbcf2009-08-11 15:43:05 -03002487 return CMD_SUCCESS;
2488}
2489
2490DEFUN (no_ip_multicast_routing,
2491 no_ip_multicast_routing_cmd,
2492 PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
2493 NO_STR
2494 IP_STR
2495 "Global IP configuration subcommands\n"
2496 "Enable IP multicast forwarding\n")
2497{
2498 mroute_del_all();
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05002499 static_mroute_del_all();
Everton Marques871dbcf2009-08-11 15:43:05 -03002500 pim_if_del_vif_all();
2501 pim_mroute_socket_disable();
2502 return CMD_SUCCESS;
2503}
2504
Everton Marques96f91ae2009-10-07 18:41:45 -03002505DEFUN (ip_ssmpingd,
2506 ip_ssmpingd_cmd,
2507 "ip ssmpingd [A.B.C.D]",
2508 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002509 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002510 "Source address\n")
2511{
2512 int result;
2513 struct in_addr source_addr;
2514 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2515
2516 result = inet_pton(AF_INET, source_str, &source_addr);
2517 if (result <= 0) {
2518 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2519 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2520 return CMD_WARNING;
2521 }
2522
2523 result = pim_ssmpingd_start(source_addr);
2524 if (result) {
2525 vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
2526 source_str, result, VTY_NEWLINE);
2527 return CMD_WARNING;
2528 }
2529
2530 return CMD_SUCCESS;
2531}
2532
2533DEFUN (no_ip_ssmpingd,
2534 no_ip_ssmpingd_cmd,
2535 "no ip ssmpingd [A.B.C.D]",
2536 NO_STR
2537 IP_STR
Everton Marques824adbe2009-10-08 09:16:27 -03002538 CONF_SSMPINGD_STR
Everton Marques96f91ae2009-10-07 18:41:45 -03002539 "Source address\n")
2540{
2541 int result;
2542 struct in_addr source_addr;
2543 const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
2544
2545 result = inet_pton(AF_INET, source_str, &source_addr);
2546 if (result <= 0) {
2547 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
2548 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
2549 return CMD_WARNING;
2550 }
2551
2552 result = pim_ssmpingd_stop(source_addr);
2553 if (result) {
2554 vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
2555 source_str, result, VTY_NEWLINE);
2556 return CMD_WARNING;
2557 }
2558
2559 return CMD_SUCCESS;
2560}
2561
Everton Marques871dbcf2009-08-11 15:43:05 -03002562DEFUN (interface_ip_igmp,
2563 interface_ip_igmp_cmd,
2564 "ip igmp",
2565 IP_STR
2566 IFACE_IGMP_STR)
2567{
2568 struct interface *ifp;
2569 struct pim_interface *pim_ifp;
2570
2571 ifp = vty->index;
2572 pim_ifp = ifp->info;
2573
2574 if (!pim_ifp) {
2575 pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
2576 if (!pim_ifp) {
2577 vty_out(vty, "Could not enable IGMP on interface %s%s",
2578 ifp->name, VTY_NEWLINE);
2579 return CMD_WARNING;
2580 }
2581 }
2582 else {
2583 PIM_IF_DO_IGMP(pim_ifp->options);
2584 }
2585
2586 pim_if_addr_add_all(ifp);
2587 pim_if_membership_refresh(ifp);
2588
2589 return CMD_SUCCESS;
2590}
2591
2592DEFUN (interface_no_ip_igmp,
2593 interface_no_ip_igmp_cmd,
2594 "no ip igmp",
2595 NO_STR
2596 IP_STR
2597 IFACE_IGMP_STR)
2598{
2599 struct interface *ifp;
2600 struct pim_interface *pim_ifp;
2601
2602 ifp = vty->index;
2603 pim_ifp = ifp->info;
2604 if (!pim_ifp)
2605 return CMD_SUCCESS;
2606
2607 PIM_IF_DONT_IGMP(pim_ifp->options);
2608
2609 pim_if_membership_clear(ifp);
2610
Everton Marques275e24d2014-08-22 11:12:23 -03002611 pim_if_addr_del_all_igmp(ifp);
Everton Marques871dbcf2009-08-11 15:43:05 -03002612
2613 if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
2614 pim_if_delete(ifp);
2615 }
2616
2617 return CMD_SUCCESS;
2618}
2619
2620DEFUN (interface_ip_igmp_join,
2621 interface_ip_igmp_join_cmd,
2622 "ip igmp join A.B.C.D A.B.C.D",
2623 IP_STR
2624 IFACE_IGMP_STR
2625 "IGMP join multicast group\n"
2626 "Multicast group address\n"
2627 "Source address\n")
2628{
2629 struct interface *ifp;
2630 const char *group_str;
2631 const char *source_str;
2632 struct in_addr group_addr;
2633 struct in_addr source_addr;
2634 int result;
2635
2636 ifp = vty->index;
2637
2638 /* Group address */
2639 group_str = argv[0];
2640 result = inet_pton(AF_INET, group_str, &group_addr);
2641 if (result <= 0) {
2642 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002643 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002644 return CMD_WARNING;
2645 }
2646
2647 /* Source address */
2648 source_str = argv[1];
2649 result = inet_pton(AF_INET, source_str, &source_addr);
2650 if (result <= 0) {
2651 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002652 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002653 return CMD_WARNING;
2654 }
2655
2656 result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
2657 if (result) {
2658 vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
2659 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2660 return CMD_WARNING;
2661 }
2662
2663 return CMD_SUCCESS;
2664}
2665
2666DEFUN (interface_no_ip_igmp_join,
2667 interface_no_ip_igmp_join_cmd,
2668 "no ip igmp join A.B.C.D A.B.C.D",
2669 NO_STR
2670 IP_STR
2671 IFACE_IGMP_STR
2672 "IGMP join multicast group\n"
2673 "Multicast group address\n"
2674 "Source address\n")
2675{
2676 struct interface *ifp;
2677 const char *group_str;
2678 const char *source_str;
2679 struct in_addr group_addr;
2680 struct in_addr source_addr;
2681 int result;
2682
2683 ifp = vty->index;
2684
2685 /* Group address */
2686 group_str = argv[0];
2687 result = inet_pton(AF_INET, group_str, &group_addr);
2688 if (result <= 0) {
2689 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002690 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002691 return CMD_WARNING;
2692 }
2693
2694 /* Source address */
2695 source_str = argv[1];
2696 result = inet_pton(AF_INET, source_str, &source_addr);
2697 if (result <= 0) {
2698 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03002699 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03002700 return CMD_WARNING;
2701 }
2702
2703 result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
2704 if (result) {
2705 vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
2706 group_str, source_str, ifp->name, result, VTY_NEWLINE);
2707 return CMD_WARNING;
2708 }
2709
2710 return CMD_SUCCESS;
2711}
2712
2713/*
2714 CLI reconfiguration affects the interface level (struct pim_interface).
2715 This function propagates the reconfiguration to every active socket
2716 for that interface.
2717 */
2718static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
2719{
2720 struct interface *ifp;
2721 struct pim_interface *pim_ifp;
2722
2723 zassert(igmp);
2724
2725 /* other querier present? */
2726
2727 if (igmp->t_other_querier_timer)
2728 return;
2729
2730 /* this is the querier */
2731
2732 zassert(igmp->interface);
2733 zassert(igmp->interface->info);
2734
2735 ifp = igmp->interface;
2736 pim_ifp = ifp->info;
2737
2738 if (PIM_DEBUG_IGMP_TRACE) {
2739 char ifaddr_str[100];
2740 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2741 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
2742 __PRETTY_FUNCTION__,
2743 ifaddr_str,
2744 ifp->name,
2745 pim_ifp->igmp_default_query_interval);
2746 }
2747
2748 /*
2749 igmp_startup_mode_on() will reset QQI:
2750
2751 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
2752 */
2753 igmp_startup_mode_on(igmp);
2754}
2755
2756static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
2757{
2758 if (igmp->t_igmp_query_timer) {
2759 /* other querier present */
2760 zassert(igmp->t_igmp_query_timer);
2761 zassert(!igmp->t_other_querier_timer);
2762
2763 pim_igmp_general_query_off(igmp);
2764 pim_igmp_general_query_on(igmp);
2765
2766 zassert(igmp->t_igmp_query_timer);
2767 zassert(!igmp->t_other_querier_timer);
2768 }
2769 else {
2770 /* this is the querier */
2771
2772 zassert(!igmp->t_igmp_query_timer);
2773 zassert(igmp->t_other_querier_timer);
2774
2775 pim_igmp_other_querier_timer_off(igmp);
2776 pim_igmp_other_querier_timer_on(igmp);
2777
2778 zassert(!igmp->t_igmp_query_timer);
2779 zassert(igmp->t_other_querier_timer);
2780 }
2781}
2782
2783static void change_query_interval(struct pim_interface *pim_ifp,
2784 int query_interval)
2785{
2786 struct listnode *sock_node;
2787 struct igmp_sock *igmp;
2788
2789 pim_ifp->igmp_default_query_interval = query_interval;
2790
2791 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2792 igmp_sock_query_interval_reconfig(igmp);
2793 igmp_sock_query_reschedule(igmp);
2794 }
2795}
2796
2797static void change_query_max_response_time(struct pim_interface *pim_ifp,
2798 int query_max_response_time_dsec)
2799{
2800 struct listnode *sock_node;
2801 struct igmp_sock *igmp;
2802
2803 pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
2804
2805 /*
2806 Below we modify socket/group/source timers in order to quickly
2807 reflect the change. Otherwise, those timers would eventually catch
2808 up.
2809 */
2810
2811 /* scan all sockets */
2812 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
2813 struct listnode *grp_node;
2814 struct igmp_group *grp;
2815
2816 /* reschedule socket general query */
2817 igmp_sock_query_reschedule(igmp);
2818
2819 /* scan socket groups */
2820 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
2821 struct listnode *src_node;
2822 struct igmp_source *src;
2823
2824 /* reset group timers for groups in EXCLUDE mode */
2825 if (grp->group_filtermode_isexcl) {
2826 igmp_group_reset_gmi(grp);
2827 }
2828
2829 /* scan group sources */
2830 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
2831
2832 /* reset source timers for sources with running timers */
2833 if (src->t_source_timer) {
2834 igmp_source_reset_gmi(igmp, grp, src);
2835 }
2836 }
2837 }
2838 }
2839}
2840
2841#define IGMP_QUERY_INTERVAL_MIN (1)
2842#define IGMP_QUERY_INTERVAL_MAX (1800)
2843
2844DEFUN (interface_ip_igmp_query_interval,
2845 interface_ip_igmp_query_interval_cmd,
2846 PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
2847 IP_STR
2848 IFACE_IGMP_STR
2849 IFACE_IGMP_QUERY_INTERVAL_STR
2850 "Query interval in seconds\n")
2851{
2852 struct interface *ifp;
2853 struct pim_interface *pim_ifp;
2854 int query_interval;
2855 int query_interval_dsec;
2856
2857 ifp = vty->index;
2858 pim_ifp = ifp->info;
2859
2860 if (!pim_ifp) {
2861 vty_out(vty,
2862 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2863 ifp->name,
2864 VTY_NEWLINE);
2865 return CMD_WARNING;
2866 }
2867
2868 query_interval = atoi(argv[0]);
2869 query_interval_dsec = 10 * query_interval;
2870
2871 /*
2872 It seems we don't need to check bounds since command.c does it
2873 already, but we verify them anyway for extra safety.
2874 */
2875 if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
2876 vty_out(vty, "General query interval %d lower than minimum %d%s",
2877 query_interval,
2878 IGMP_QUERY_INTERVAL_MIN,
2879 VTY_NEWLINE);
2880 return CMD_WARNING;
2881 }
2882 if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
2883 vty_out(vty, "General query interval %d higher than maximum %d%s",
2884 query_interval,
2885 IGMP_QUERY_INTERVAL_MAX,
2886 VTY_NEWLINE);
2887 return CMD_WARNING;
2888 }
2889
2890 if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2891 vty_out(vty,
2892 "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
2893 query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2894 VTY_NEWLINE);
2895 return CMD_WARNING;
2896 }
2897
2898 change_query_interval(pim_ifp, query_interval);
2899
2900 return CMD_SUCCESS;
2901}
2902
2903DEFUN (interface_no_ip_igmp_query_interval,
2904 interface_no_ip_igmp_query_interval_cmd,
2905 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
2906 NO_STR
2907 IP_STR
2908 IFACE_IGMP_STR
2909 IFACE_IGMP_QUERY_INTERVAL_STR)
2910{
2911 struct interface *ifp;
2912 struct pim_interface *pim_ifp;
2913 int default_query_interval_dsec;
2914
2915 ifp = vty->index;
2916 pim_ifp = ifp->info;
2917
2918 if (!pim_ifp)
2919 return CMD_SUCCESS;
2920
2921 default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
2922
2923 if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
2924 vty_out(vty,
2925 "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
2926 default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
2927 VTY_NEWLINE);
2928 return CMD_WARNING;
2929 }
2930
2931 change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
2932
2933 return CMD_SUCCESS;
2934}
2935
2936#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
2937#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
2938
2939DEFUN (interface_ip_igmp_query_max_response_time,
2940 interface_ip_igmp_query_max_response_time_cmd,
2941 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
2942 IP_STR
2943 IFACE_IGMP_STR
2944 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
2945 "Query response value in seconds\n")
2946{
2947 struct interface *ifp;
2948 struct pim_interface *pim_ifp;
2949 int query_max_response_time;
2950
2951 ifp = vty->index;
2952 pim_ifp = ifp->info;
2953
2954 if (!pim_ifp) {
2955 vty_out(vty,
2956 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
2957 ifp->name,
2958 VTY_NEWLINE);
2959 return CMD_WARNING;
2960 }
2961
2962 query_max_response_time = atoi(argv[0]);
2963
2964 /*
2965 It seems we don't need to check bounds since command.c does it
2966 already, but we verify them anyway for extra safety.
2967 */
2968 if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
2969 vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
2970 query_max_response_time,
2971 IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
2972 VTY_NEWLINE);
2973 return CMD_WARNING;
2974 }
2975 if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
2976 vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
2977 query_max_response_time,
2978 IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
2979 VTY_NEWLINE);
2980 return CMD_WARNING;
2981 }
2982
2983 if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
2984 vty_out(vty,
2985 "Can't set query max response time %d sec >= general query interval %d sec%s",
2986 query_max_response_time, pim_ifp->igmp_default_query_interval,
2987 VTY_NEWLINE);
2988 return CMD_WARNING;
2989 }
2990
2991 change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
2992
2993 return CMD_SUCCESS;
2994}
2995
2996DEFUN (interface_no_ip_igmp_query_max_response_time,
2997 interface_no_ip_igmp_query_max_response_time_cmd,
2998 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
2999 NO_STR
3000 IP_STR
3001 IFACE_IGMP_STR
3002 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
3003{
3004 struct interface *ifp;
3005 struct pim_interface *pim_ifp;
3006 int default_query_interval_dsec;
3007
3008 ifp = vty->index;
3009 pim_ifp = ifp->info;
3010
3011 if (!pim_ifp)
3012 return CMD_SUCCESS;
3013
3014 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3015
3016 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
3017 vty_out(vty,
3018 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
3019 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
3020 VTY_NEWLINE);
3021 return CMD_WARNING;
3022 }
3023
3024 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
3025
3026 return CMD_SUCCESS;
3027}
3028
3029#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
3030#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
3031
3032DEFUN (interface_ip_igmp_query_max_response_time_dsec,
3033 interface_ip_igmp_query_max_response_time_dsec_cmd,
3034 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
3035 IP_STR
3036 IFACE_IGMP_STR
3037 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
3038 "Query response value in deciseconds\n")
3039{
3040 struct interface *ifp;
3041 struct pim_interface *pim_ifp;
3042 int query_max_response_time_dsec;
3043 int default_query_interval_dsec;
3044
3045 ifp = vty->index;
3046 pim_ifp = ifp->info;
3047
3048 if (!pim_ifp) {
3049 vty_out(vty,
3050 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
3051 ifp->name,
3052 VTY_NEWLINE);
3053 return CMD_WARNING;
3054 }
3055
3056 query_max_response_time_dsec = atoi(argv[0]);
3057
3058 /*
3059 It seems we don't need to check bounds since command.c does it
3060 already, but we verify them anyway for extra safety.
3061 */
3062 if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
3063 vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
3064 query_max_response_time_dsec,
3065 IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
3066 VTY_NEWLINE);
3067 return CMD_WARNING;
3068 }
3069 if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
3070 vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
3071 query_max_response_time_dsec,
3072 IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
3073 VTY_NEWLINE);
3074 return CMD_WARNING;
3075 }
3076
3077 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3078
3079 if (query_max_response_time_dsec >= default_query_interval_dsec) {
3080 vty_out(vty,
3081 "Can't set query max response time %d dsec >= general query interval %d dsec%s",
3082 query_max_response_time_dsec, default_query_interval_dsec,
3083 VTY_NEWLINE);
3084 return CMD_WARNING;
3085 }
3086
3087 change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
3088
3089 return CMD_SUCCESS;
3090}
3091
3092DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
3093 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
3094 PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
3095 NO_STR
3096 IP_STR
3097 IFACE_IGMP_STR
3098 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
3099{
3100 struct interface *ifp;
3101 struct pim_interface *pim_ifp;
3102 int default_query_interval_dsec;
3103
3104 ifp = vty->index;
3105 pim_ifp = ifp->info;
3106
3107 if (!pim_ifp)
3108 return CMD_SUCCESS;
3109
3110 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
3111
3112 if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
3113 vty_out(vty,
3114 "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
3115 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
3116 VTY_NEWLINE);
3117 return CMD_WARNING;
3118 }
3119
3120 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
3121
3122 return CMD_SUCCESS;
3123}
3124
Donald Sharp6ae80e02015-06-18 18:14:20 -07003125DEFUN (interface_ip_pim_drprio,
3126 interface_ip_pim_drprio_cmd,
3127 "ip pim drpriority <1-4294967295>",
3128 IP_STR
3129 PIM_STR
3130 "Set the Designated Router Election Priority\n"
3131 "Value of the new DR Priority\n")
3132{
3133 struct interface *ifp;
3134 struct pim_interface *pim_ifp;
3135 uint32_t old_dr_prio;
3136
3137 ifp = vty->index;
3138 pim_ifp = ifp->info;
3139
3140 if (!pim_ifp) {
3141 vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE);
3142 return CMD_WARNING;
3143 }
3144
3145 old_dr_prio = pim_ifp->pim_dr_priority;
3146
3147 pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10);
3148
3149 if (old_dr_prio != pim_ifp->pim_dr_priority) {
3150 if (pim_if_dr_election(ifp))
3151 pim_hello_restart_now(ifp);
3152 }
3153
3154 return CMD_SUCCESS;
3155}
3156
3157DEFUN (interface_no_ip_pim_drprio,
3158 interface_no_ip_pim_drprio_cmd,
3159 "no ip pim drpriority {<1-4294967295>}",
3160 IP_STR
3161 PIM_STR
3162 "Revert the Designated Router Priority to default\n"
3163 "Old Value of the Priority\n")
3164{
3165 struct interface *ifp;
3166 struct pim_interface *pim_ifp;
3167
3168 ifp = vty->index;
3169 pim_ifp = ifp->info;
3170
3171 if (!pim_ifp) {
3172 vty_out(vty, "Pim no enabled on this interface%s", VTY_NEWLINE);
3173 return CMD_WARNING;
3174 }
3175
3176 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
3177 pim_ifp->pim_dr_priority = PIM_DEFAULT_DR_PRIORITY;
3178 if (pim_if_dr_election(ifp))
3179 pim_hello_restart_now(ifp);
3180 }
3181
3182 return CMD_SUCCESS;
3183}
3184
Everton Marques871dbcf2009-08-11 15:43:05 -03003185DEFUN (interface_ip_pim_ssm,
3186 interface_ip_pim_ssm_cmd,
3187 "ip pim ssm",
3188 IP_STR
3189 PIM_STR
3190 IFACE_PIM_STR)
3191{
3192 struct interface *ifp;
3193 struct pim_interface *pim_ifp;
3194
3195 ifp = vty->index;
3196 pim_ifp = ifp->info;
3197
3198 if (!pim_ifp) {
3199 pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
3200 if (!pim_ifp) {
3201 vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
3202 return CMD_WARNING;
3203 }
3204 }
3205 else {
3206 PIM_IF_DO_PIM(pim_ifp->options);
3207 }
3208
3209 pim_if_addr_add_all(ifp);
3210 pim_if_membership_refresh(ifp);
3211
3212 return CMD_SUCCESS;
3213}
3214
3215DEFUN (interface_no_ip_pim_ssm,
3216 interface_no_ip_pim_ssm_cmd,
3217 "no ip pim ssm",
3218 NO_STR
3219 IP_STR
3220 PIM_STR
3221 IFACE_PIM_STR)
3222{
3223 struct interface *ifp;
3224 struct pim_interface *pim_ifp;
3225
3226 ifp = vty->index;
3227 pim_ifp = ifp->info;
3228 if (!pim_ifp)
3229 return CMD_SUCCESS;
3230
3231 PIM_IF_DONT_PIM(pim_ifp->options);
3232
3233 pim_if_membership_clear(ifp);
3234
3235 /*
3236 pim_if_addr_del_all() removes all sockets from
3237 pim_ifp->igmp_socket_list.
3238 */
3239 pim_if_addr_del_all(ifp);
3240
3241 /*
3242 pim_sock_delete() removes all neighbors from
3243 pim_ifp->pim_neighbor_list.
3244 */
3245 pim_sock_delete(ifp, "pim unconfigured on interface");
3246
3247 if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
3248 pim_if_delete(ifp);
3249 }
3250
3251 return CMD_SUCCESS;
3252}
3253
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05003254DEFUN (interface_ip_mroute,
3255 interface_ip_mroute_cmd,
3256 "ip mroute INTERFACE A.B.C.D",
3257 IP_STR
3258 "Add multicast route\n"
3259 "Outgoing interface name\n"
3260 "Group address\n")
3261{
3262 struct interface *iif;
3263 struct interface *oif;
3264 const char *oifname;
3265 const char *grp_str;
3266 struct in_addr grp_addr;
3267 struct in_addr src_addr;
3268 int result;
3269
3270 iif = vty->index;
3271
3272 oifname = argv[0];
3273 oif = if_lookup_by_name(oifname);
3274 if (!oif) {
3275 vty_out(vty, "No such interface name %s%s",
3276 oifname, VTY_NEWLINE);
3277 return CMD_WARNING;
3278 }
3279
3280 grp_str = argv[1];
3281 result = inet_pton(AF_INET, grp_str, &grp_addr);
3282 if (result <= 0) {
3283 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3284 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3285 return CMD_WARNING;
3286 }
3287
3288 src_addr.s_addr = INADDR_ANY;
3289
3290 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
3291 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
3292 return CMD_WARNING;
3293 }
3294
3295 return CMD_SUCCESS;
3296}
3297
3298DEFUN (interface_ip_mroute_source,
3299 interface_ip_mroute_source_cmd,
3300 "ip mroute INTERFACE A.B.C.D A.B.C.D",
3301 IP_STR
3302 "Add multicast route\n"
3303 "Outgoing interface name\n"
3304 "Group address\n"
3305 "Source address\n")
3306{
3307 struct interface *iif;
3308 struct interface *oif;
3309 const char *oifname;
3310 const char *grp_str;
3311 struct in_addr grp_addr;
3312 const char *src_str;
3313 struct in_addr src_addr;
3314 int result;
3315
3316 iif = vty->index;
3317
3318 oifname = argv[0];
3319 oif = if_lookup_by_name(oifname);
3320 if (!oif) {
3321 vty_out(vty, "No such interface name %s%s",
3322 oifname, VTY_NEWLINE);
3323 return CMD_WARNING;
3324 }
3325
3326 grp_str = argv[1];
3327 result = inet_pton(AF_INET, grp_str, &grp_addr);
3328 if (result <= 0) {
3329 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3330 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3331 return CMD_WARNING;
3332 }
3333
3334 src_str = argv[2];
3335 result = inet_pton(AF_INET, src_str, &src_addr);
3336 if (result <= 0) {
3337 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3338 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
3339 return CMD_WARNING;
3340 }
3341
3342 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
3343 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
3344 return CMD_WARNING;
3345 }
3346
3347 return CMD_SUCCESS;
3348}
3349
3350DEFUN (interface_no_ip_mroute,
3351 interface_no_ip_mroute_cmd,
3352 "no ip mroute INTERFACE A.B.C.D",
3353 NO_STR
3354 IP_STR
3355 "Add multicast route\n"
3356 "Outgoing interface name\n"
3357 "Group Address\n")
3358{
3359 struct interface *iif;
3360 struct interface *oif;
3361 const char *oifname;
3362 const char *grp_str;
3363 struct in_addr grp_addr;
3364 struct in_addr src_addr;
3365 int result;
3366
3367 iif = vty->index;
3368
3369 oifname = argv[0];
3370 oif = if_lookup_by_name(oifname);
3371 if (!oif) {
3372 vty_out(vty, "No such interface name %s%s",
3373 oifname, VTY_NEWLINE);
3374 return CMD_WARNING;
3375 }
3376
3377 grp_str = argv[1];
3378 result = inet_pton(AF_INET, grp_str, &grp_addr);
3379 if (result <= 0) {
3380 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3381 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3382 return CMD_WARNING;
3383 }
3384
3385 src_addr.s_addr = INADDR_ANY;
3386
3387 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
3388 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
3389 return CMD_WARNING;
3390 }
3391
3392 return CMD_SUCCESS;
3393}
3394
3395DEFUN (interface_no_ip_mroute_source,
3396 interface_no_ip_mroute_source_cmd,
3397 "no ip mroute INTERFACE A.B.C.D A.B.C.D",
3398 NO_STR
3399 IP_STR
3400 "Add multicast route\n"
3401 "Outgoing interface name\n"
3402 "Group Address\n"
3403 "Source Address\n")
3404{
3405 struct interface *iif;
3406 struct interface *oif;
3407 const char *oifname;
3408 const char *grp_str;
3409 struct in_addr grp_addr;
3410 const char *src_str;
3411 struct in_addr src_addr;
3412 int result;
3413
3414 iif = vty->index;
3415
3416 oifname = argv[0];
3417 oif = if_lookup_by_name(oifname);
3418 if (!oif) {
3419 vty_out(vty, "No such interface name %s%s",
3420 oifname, VTY_NEWLINE);
3421 return CMD_WARNING;
3422 }
3423
3424 grp_str = argv[1];
3425 result = inet_pton(AF_INET, grp_str, &grp_addr);
3426 if (result <= 0) {
3427 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3428 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
3429 return CMD_WARNING;
3430 }
3431
3432 src_str = argv[2];
3433 result = inet_pton(AF_INET, src_str, &src_addr);
3434 if (result <= 0) {
3435 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3436 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
3437 return CMD_WARNING;
3438 }
3439
3440 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
3441 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
3442 return CMD_WARNING;
3443 }
3444
3445 return CMD_SUCCESS;
3446}
3447
Everton Marques871dbcf2009-08-11 15:43:05 -03003448DEFUN (debug_igmp,
3449 debug_igmp_cmd,
3450 "debug igmp",
3451 DEBUG_STR
3452 DEBUG_IGMP_STR)
3453{
3454 PIM_DO_DEBUG_IGMP_EVENTS;
3455 PIM_DO_DEBUG_IGMP_PACKETS;
3456 PIM_DO_DEBUG_IGMP_TRACE;
3457 return CMD_SUCCESS;
3458}
3459
3460DEFUN (no_debug_igmp,
3461 no_debug_igmp_cmd,
3462 "no debug igmp",
3463 NO_STR
3464 DEBUG_STR
3465 DEBUG_IGMP_STR)
3466{
3467 PIM_DONT_DEBUG_IGMP_EVENTS;
3468 PIM_DONT_DEBUG_IGMP_PACKETS;
3469 PIM_DONT_DEBUG_IGMP_TRACE;
3470 return CMD_SUCCESS;
3471}
3472
3473ALIAS (no_debug_igmp,
3474 undebug_igmp_cmd,
3475 "undebug igmp",
3476 UNDEBUG_STR
3477 DEBUG_IGMP_STR)
3478
3479DEFUN (debug_igmp_events,
3480 debug_igmp_events_cmd,
3481 "debug igmp events",
3482 DEBUG_STR
3483 DEBUG_IGMP_STR
3484 DEBUG_IGMP_EVENTS_STR)
3485{
3486 PIM_DO_DEBUG_IGMP_EVENTS;
3487 return CMD_SUCCESS;
3488}
3489
3490DEFUN (no_debug_igmp_events,
3491 no_debug_igmp_events_cmd,
3492 "no debug igmp events",
3493 NO_STR
3494 DEBUG_STR
3495 DEBUG_IGMP_STR
3496 DEBUG_IGMP_EVENTS_STR)
3497{
3498 PIM_DONT_DEBUG_IGMP_EVENTS;
3499 return CMD_SUCCESS;
3500}
3501
3502ALIAS (no_debug_igmp_events,
3503 undebug_igmp_events_cmd,
3504 "undebug igmp events",
3505 UNDEBUG_STR
3506 DEBUG_IGMP_STR
3507 DEBUG_IGMP_EVENTS_STR)
3508
3509DEFUN (debug_igmp_packets,
3510 debug_igmp_packets_cmd,
3511 "debug igmp packets",
3512 DEBUG_STR
3513 DEBUG_IGMP_STR
3514 DEBUG_IGMP_PACKETS_STR)
3515{
3516 PIM_DO_DEBUG_IGMP_PACKETS;
3517 return CMD_SUCCESS;
3518}
3519
3520DEFUN (no_debug_igmp_packets,
3521 no_debug_igmp_packets_cmd,
3522 "no debug igmp packets",
3523 NO_STR
3524 DEBUG_STR
3525 DEBUG_IGMP_STR
3526 DEBUG_IGMP_PACKETS_STR)
3527{
3528 PIM_DONT_DEBUG_IGMP_PACKETS;
3529 return CMD_SUCCESS;
3530}
3531
3532ALIAS (no_debug_igmp_packets,
3533 undebug_igmp_packets_cmd,
3534 "undebug igmp packets",
3535 UNDEBUG_STR
3536 DEBUG_IGMP_STR
3537 DEBUG_IGMP_PACKETS_STR)
3538
3539DEFUN (debug_igmp_trace,
3540 debug_igmp_trace_cmd,
3541 "debug igmp trace",
3542 DEBUG_STR
3543 DEBUG_IGMP_STR
3544 DEBUG_IGMP_TRACE_STR)
3545{
3546 PIM_DO_DEBUG_IGMP_TRACE;
3547 return CMD_SUCCESS;
3548}
3549
3550DEFUN (no_debug_igmp_trace,
3551 no_debug_igmp_trace_cmd,
3552 "no debug igmp trace",
3553 NO_STR
3554 DEBUG_STR
3555 DEBUG_IGMP_STR
3556 DEBUG_IGMP_TRACE_STR)
3557{
3558 PIM_DONT_DEBUG_IGMP_TRACE;
3559 return CMD_SUCCESS;
3560}
3561
3562ALIAS (no_debug_igmp_trace,
3563 undebug_igmp_trace_cmd,
3564 "undebug igmp trace",
3565 UNDEBUG_STR
3566 DEBUG_IGMP_STR
3567 DEBUG_IGMP_TRACE_STR)
3568
Everton Marques67faabc2010-02-23 12:11:11 -03003569DEFUN (debug_mroute,
3570 debug_mroute_cmd,
3571 "debug mroute",
3572 DEBUG_STR
3573 DEBUG_MROUTE_STR)
3574{
3575 PIM_DO_DEBUG_MROUTE;
3576 return CMD_SUCCESS;
3577}
3578
3579DEFUN (no_debug_mroute,
3580 no_debug_mroute_cmd,
3581 "no debug mroute",
3582 NO_STR
3583 DEBUG_STR
3584 DEBUG_MROUTE_STR)
3585{
3586 PIM_DONT_DEBUG_MROUTE;
3587 return CMD_SUCCESS;
3588}
3589
3590ALIAS (no_debug_mroute,
3591 undebug_mroute_cmd,
3592 "undebug mroute",
3593 UNDEBUG_STR
3594 DEBUG_MROUTE_STR)
3595
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05003596DEFUN (debug_static,
3597 debug_static_cmd,
3598 "debug static",
3599 DEBUG_STR
3600 DEBUG_STATIC_STR)
3601{
3602 PIM_DO_DEBUG_STATIC;
3603 return CMD_SUCCESS;
3604}
3605
3606DEFUN (no_debug_static,
3607 no_debug_static_cmd,
3608 "no debug static",
3609 NO_STR
3610 DEBUG_STR
3611 DEBUG_STATIC_STR)
3612{
3613 PIM_DONT_DEBUG_STATIC;
3614 return CMD_SUCCESS;
3615}
3616
3617ALIAS (no_debug_static,
3618 undebug_static_cmd,
3619 "undebug static",
3620 UNDEBUG_STR
3621 DEBUG_STATIC_STR)
3622
Everton Marques871dbcf2009-08-11 15:43:05 -03003623DEFUN (debug_pim,
3624 debug_pim_cmd,
3625 "debug pim",
3626 DEBUG_STR
3627 DEBUG_PIM_STR)
3628{
3629 PIM_DO_DEBUG_PIM_EVENTS;
3630 PIM_DO_DEBUG_PIM_PACKETS;
3631 PIM_DO_DEBUG_PIM_TRACE;
3632 return CMD_SUCCESS;
3633}
3634
3635DEFUN (no_debug_pim,
3636 no_debug_pim_cmd,
3637 "no debug pim",
3638 NO_STR
3639 DEBUG_STR
3640 DEBUG_PIM_STR)
3641{
3642 PIM_DONT_DEBUG_PIM_EVENTS;
3643 PIM_DONT_DEBUG_PIM_PACKETS;
3644 PIM_DONT_DEBUG_PIM_TRACE;
Everton Marques62738042009-11-18 10:44:13 -02003645
3646 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3647 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3648
Everton Marques871dbcf2009-08-11 15:43:05 -03003649 return CMD_SUCCESS;
3650}
3651
3652ALIAS (no_debug_pim,
3653 undebug_pim_cmd,
3654 "undebug pim",
3655 UNDEBUG_STR
3656 DEBUG_PIM_STR)
3657
3658DEFUN (debug_pim_events,
3659 debug_pim_events_cmd,
3660 "debug pim events",
3661 DEBUG_STR
3662 DEBUG_PIM_STR
3663 DEBUG_PIM_EVENTS_STR)
3664{
3665 PIM_DO_DEBUG_PIM_EVENTS;
3666 return CMD_SUCCESS;
3667}
3668
3669DEFUN (no_debug_pim_events,
3670 no_debug_pim_events_cmd,
3671 "no debug pim events",
3672 NO_STR
3673 DEBUG_STR
3674 DEBUG_PIM_STR
3675 DEBUG_PIM_EVENTS_STR)
3676{
3677 PIM_DONT_DEBUG_PIM_EVENTS;
3678 return CMD_SUCCESS;
3679}
3680
3681ALIAS (no_debug_pim_events,
3682 undebug_pim_events_cmd,
3683 "undebug pim events",
3684 UNDEBUG_STR
3685 DEBUG_PIM_STR
3686 DEBUG_PIM_EVENTS_STR)
3687
3688DEFUN (debug_pim_packets,
3689 debug_pim_packets_cmd,
3690 "debug pim packets",
3691 DEBUG_STR
3692 DEBUG_PIM_STR
3693 DEBUG_PIM_PACKETS_STR)
3694{
Balaji.Ged14fa02014-10-08 01:11:31 -03003695 PIM_DO_DEBUG_PIM_PACKETS;
3696 vty_out (vty, "PIM Packet debugging is on %s", VTY_NEWLINE);
3697 return CMD_SUCCESS;
3698}
3699
3700DEFUN (debug_pim_packets_filter,
3701 debug_pim_packets_filter_cmd,
3702 "debug pim packets (hello|joins)",
3703 DEBUG_STR
3704 DEBUG_PIM_STR
3705 DEBUG_PIM_PACKETS_STR
3706 DEBUG_PIM_HELLO_PACKETS_STR
3707 DEBUG_PIM_J_P_PACKETS_STR)
3708{
3709 if (strncmp(argv[0],"h",1) == 0)
3710 {
3711 PIM_DO_DEBUG_PIM_HELLO;
3712 vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE);
3713 }
3714 else if (strncmp(argv[0],"j",1) == 0)
3715 {
3716 PIM_DO_DEBUG_PIM_J_P;
3717 vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE);
3718 }
Everton Marques871dbcf2009-08-11 15:43:05 -03003719 return CMD_SUCCESS;
3720}
3721
3722DEFUN (no_debug_pim_packets,
3723 no_debug_pim_packets_cmd,
3724 "no debug pim packets",
3725 NO_STR
3726 DEBUG_STR
3727 DEBUG_PIM_STR
Balaji.Ged14fa02014-10-08 01:11:31 -03003728 DEBUG_PIM_PACKETS_STR
3729 DEBUG_PIM_HELLO_PACKETS_STR
3730 DEBUG_PIM_J_P_PACKETS_STR)
Everton Marques871dbcf2009-08-11 15:43:05 -03003731{
3732 PIM_DONT_DEBUG_PIM_PACKETS;
Balaji.Ged14fa02014-10-08 01:11:31 -03003733 vty_out (vty, "PIM Packet debugging is off %s", VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03003734 return CMD_SUCCESS;
3735}
3736
Balaji.Ged14fa02014-10-08 01:11:31 -03003737DEFUN (no_debug_pim_packets_filter,
3738 no_debug_pim_packets_filter_cmd,
3739 "no debug pim packets (hello|joins)",
3740 NO_STR
3741 DEBUG_STR
3742 DEBUG_PIM_STR
3743 DEBUG_PIM_PACKETS_STR
3744 DEBUG_PIM_HELLO_PACKETS_STR
3745 DEBUG_PIM_J_P_PACKETS_STR)
3746{
3747 if (strncmp(argv[0],"h",1) == 0)
3748 {
3749 PIM_DONT_DEBUG_PIM_HELLO;
3750 vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
3751 }
3752 else if (strncmp(argv[0],"j",1) == 0)
3753 {
3754 PIM_DONT_DEBUG_PIM_J_P;
3755 vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
3756 }
3757 return CMD_SUCCESS;
3758}
3759
Everton Marques871dbcf2009-08-11 15:43:05 -03003760ALIAS (no_debug_pim_packets,
3761 undebug_pim_packets_cmd,
3762 "undebug pim packets",
3763 UNDEBUG_STR
3764 DEBUG_PIM_STR
3765 DEBUG_PIM_PACKETS_STR)
3766
Everton Marques62738042009-11-18 10:44:13 -02003767DEFUN (debug_pim_packetdump_send,
3768 debug_pim_packetdump_send_cmd,
3769 "debug pim packet-dump send",
3770 DEBUG_STR
3771 DEBUG_PIM_STR
3772 DEBUG_PIM_PACKETDUMP_STR
3773 DEBUG_PIM_PACKETDUMP_SEND_STR)
3774{
3775 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
3776 return CMD_SUCCESS;
3777}
3778
3779DEFUN (no_debug_pim_packetdump_send,
3780 no_debug_pim_packetdump_send_cmd,
3781 "no debug pim packet-dump send",
3782 NO_STR
3783 DEBUG_STR
3784 DEBUG_PIM_STR
3785 DEBUG_PIM_PACKETDUMP_STR
3786 DEBUG_PIM_PACKETDUMP_SEND_STR)
3787{
3788 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
3789 return CMD_SUCCESS;
3790}
3791
3792ALIAS (no_debug_pim_packetdump_send,
3793 undebug_pim_packetdump_send_cmd,
3794 "undebug pim packet-dump send",
3795 UNDEBUG_STR
3796 DEBUG_PIM_STR
3797 DEBUG_PIM_PACKETDUMP_STR
3798 DEBUG_PIM_PACKETDUMP_SEND_STR)
3799
3800DEFUN (debug_pim_packetdump_recv,
3801 debug_pim_packetdump_recv_cmd,
3802 "debug pim packet-dump receive",
3803 DEBUG_STR
3804 DEBUG_PIM_STR
3805 DEBUG_PIM_PACKETDUMP_STR
3806 DEBUG_PIM_PACKETDUMP_RECV_STR)
3807{
3808 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
3809 return CMD_SUCCESS;
3810}
3811
3812DEFUN (no_debug_pim_packetdump_recv,
3813 no_debug_pim_packetdump_recv_cmd,
3814 "no debug pim packet-dump receive",
3815 NO_STR
3816 DEBUG_STR
3817 DEBUG_PIM_STR
3818 DEBUG_PIM_PACKETDUMP_STR
3819 DEBUG_PIM_PACKETDUMP_RECV_STR)
3820{
3821 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
3822 return CMD_SUCCESS;
3823}
3824
3825ALIAS (no_debug_pim_packetdump_recv,
3826 undebug_pim_packetdump_recv_cmd,
3827 "undebug pim packet-dump receive",
3828 UNDEBUG_STR
3829 DEBUG_PIM_STR
3830 DEBUG_PIM_PACKETDUMP_STR
3831 DEBUG_PIM_PACKETDUMP_RECV_STR)
3832
Everton Marques871dbcf2009-08-11 15:43:05 -03003833DEFUN (debug_pim_trace,
3834 debug_pim_trace_cmd,
3835 "debug pim trace",
3836 DEBUG_STR
3837 DEBUG_PIM_STR
3838 DEBUG_PIM_TRACE_STR)
3839{
3840 PIM_DO_DEBUG_PIM_TRACE;
3841 return CMD_SUCCESS;
3842}
3843
3844DEFUN (no_debug_pim_trace,
3845 no_debug_pim_trace_cmd,
3846 "no debug pim trace",
3847 NO_STR
3848 DEBUG_STR
3849 DEBUG_PIM_STR
3850 DEBUG_PIM_TRACE_STR)
3851{
3852 PIM_DONT_DEBUG_PIM_TRACE;
3853 return CMD_SUCCESS;
3854}
3855
3856ALIAS (no_debug_pim_trace,
3857 undebug_pim_trace_cmd,
3858 "undebug pim trace",
3859 UNDEBUG_STR
3860 DEBUG_PIM_STR
3861 DEBUG_PIM_TRACE_STR)
3862
Everton Marques824adbe2009-10-08 09:16:27 -03003863DEFUN (debug_ssmpingd,
3864 debug_ssmpingd_cmd,
3865 "debug ssmpingd",
3866 DEBUG_STR
3867 DEBUG_PIM_STR
3868 DEBUG_SSMPINGD_STR)
3869{
3870 PIM_DO_DEBUG_SSMPINGD;
3871 return CMD_SUCCESS;
3872}
3873
3874DEFUN (no_debug_ssmpingd,
3875 no_debug_ssmpingd_cmd,
3876 "no debug ssmpingd",
3877 NO_STR
3878 DEBUG_STR
3879 DEBUG_PIM_STR
3880 DEBUG_SSMPINGD_STR)
3881{
3882 PIM_DONT_DEBUG_SSMPINGD;
3883 return CMD_SUCCESS;
3884}
3885
3886ALIAS (no_debug_ssmpingd,
3887 undebug_ssmpingd_cmd,
3888 "undebug ssmpingd",
3889 UNDEBUG_STR
3890 DEBUG_PIM_STR
3891 DEBUG_SSMPINGD_STR)
3892
Everton Marques871dbcf2009-08-11 15:43:05 -03003893DEFUN (debug_pim_zebra,
3894 debug_pim_zebra_cmd,
3895 "debug pim zebra",
3896 DEBUG_STR
3897 DEBUG_PIM_STR
3898 DEBUG_PIM_ZEBRA_STR)
3899{
3900 PIM_DO_DEBUG_ZEBRA;
3901 return CMD_SUCCESS;
3902}
3903
3904DEFUN (no_debug_pim_zebra,
3905 no_debug_pim_zebra_cmd,
3906 "no debug pim zebra",
3907 NO_STR
3908 DEBUG_STR
3909 DEBUG_PIM_STR
3910 DEBUG_PIM_ZEBRA_STR)
3911{
3912 PIM_DONT_DEBUG_ZEBRA;
3913 return CMD_SUCCESS;
3914}
3915
3916ALIAS (no_debug_pim_zebra,
3917 undebug_pim_zebra_cmd,
3918 "undebug pim zebra",
3919 UNDEBUG_STR
3920 DEBUG_PIM_STR
3921 DEBUG_PIM_ZEBRA_STR)
3922
Donald Sharpcd557c32015-05-27 17:40:46 -07003923DEFUN (show_debugging_pim,
3924 show_debugging_pim_cmd,
3925 "show debugging pim",
Everton Marques871dbcf2009-08-11 15:43:05 -03003926 SHOW_STR
Donald Sharpcd557c32015-05-27 17:40:46 -07003927 DEBUG_STR
3928 PIM_STR)
Everton Marques871dbcf2009-08-11 15:43:05 -03003929{
3930 pim_debug_config_write(vty);
3931 return CMD_SUCCESS;
3932}
3933
3934static struct igmp_sock *find_igmp_sock_by_fd(int fd)
3935{
3936 struct listnode *ifnode;
3937 struct interface *ifp;
3938
3939 /* scan all interfaces */
3940 for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
3941 struct pim_interface *pim_ifp;
3942 struct igmp_sock *igmp;
3943
3944 if (!ifp->info)
3945 continue;
3946
3947 pim_ifp = ifp->info;
3948
3949 /* lookup igmp socket under current interface */
3950 igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
3951 if (igmp)
3952 return igmp;
3953 }
3954
3955 return 0;
3956}
3957
3958DEFUN (test_igmp_receive_report,
3959 test_igmp_receive_report_cmd,
3960 "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
3961 "Test\n"
3962 "Test IGMP protocol\n"
3963 "Test IGMP message\n"
3964 "Test IGMP report\n"
3965 "Socket\n"
3966 "IGMP group address\n"
3967 "Record type\n"
3968 "Sources\n")
3969{
3970 char buf[1000];
3971 char *igmp_msg;
3972 struct ip *ip_hdr;
3973 size_t ip_hlen; /* ip header length in bytes */
3974 int ip_msg_len;
3975 int igmp_msg_len;
3976 const char *socket;
3977 int socket_fd;
3978 const char *grp_str;
3979 struct in_addr grp_addr;
3980 const char *record_type_str;
3981 int record_type;
3982 const char *src_str;
3983 int result;
3984 struct igmp_sock *igmp;
3985 char *group_record;
3986 int num_sources;
3987 struct in_addr *sources;
3988 struct in_addr *src_addr;
3989 int argi;
3990
3991 socket = argv[0];
3992 socket_fd = atoi(socket);
3993 igmp = find_igmp_sock_by_fd(socket_fd);
3994 if (!igmp) {
3995 vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
3996 socket, socket_fd, VTY_NEWLINE);
3997 return CMD_WARNING;
3998 }
3999
4000 grp_str = argv[1];
4001 result = inet_pton(AF_INET, grp_str, &grp_addr);
4002 if (result <= 0) {
4003 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004004 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004005 return CMD_WARNING;
4006 }
4007
4008 record_type_str = argv[2];
4009 record_type = atoi(record_type_str);
4010
4011 /*
4012 Tweak IP header
4013 */
4014 ip_hdr = (struct ip *) buf;
4015 ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
4016 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4017 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4018 ip_hdr->ip_src = igmp->ifaddr;
4019 ip_hdr->ip_dst = igmp->ifaddr;
4020
4021 /*
4022 Build IGMP v3 report message
4023 */
4024 igmp_msg = buf + ip_hlen;
4025 group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
4026 *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
4027 *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
4028 *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
4029 *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
Klemen Sladic3defeb32014-02-07 16:23:44 +13004030 memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr));
Everton Marques871dbcf2009-08-11 15:43:05 -03004031
4032 /* Scan LINE sources */
4033 sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
4034 src_addr = sources;
4035 for (argi = 3; argi < argc; ++argi,++src_addr) {
4036 src_str = argv[argi];
4037 result = inet_pton(AF_INET, src_str, src_addr);
4038 if (result <= 0) {
4039 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004040 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004041 return CMD_WARNING;
4042 }
4043 }
4044 num_sources = src_addr - sources;
4045
4046 *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
4047
4048 igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
4049
4050 /* compute checksum */
Everton Marques93911262014-09-18 11:10:58 -03004051 *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = in_cksum(igmp_msg, igmp_msg_len);
Everton Marques871dbcf2009-08-11 15:43:05 -03004052
4053 /* "receive" message */
4054
4055 ip_msg_len = ip_hlen + igmp_msg_len;
4056 result = pim_igmp_packet(igmp, buf, ip_msg_len);
4057 if (result) {
4058 vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
4059 ip_msg_len, result, VTY_NEWLINE);
4060 return CMD_WARNING;
4061 }
4062
4063 return CMD_SUCCESS;
4064}
4065
Everton Marquesdba77582009-11-19 10:32:19 -02004066static int hexval(uint8_t ch)
4067{
4068 return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a');
4069}
4070
Everton Marques3e92c452009-11-18 16:26:38 -02004071DEFUN (test_pim_receive_dump,
4072 test_pim_receive_dump_cmd,
4073 "test pim receive dump INTERFACE A.B.C.D .LINE",
4074 "Test\n"
4075 "Test PIM protocol\n"
4076 "Test PIM message reception\n"
4077 "Test PIM packet dump reception from neighbor\n"
4078 "Interface\n"
4079 "Neighbor address\n"
4080 "Packet dump\n")
4081{
David Lamparterf8cfeb22012-02-16 04:31:08 +00004082 uint8_t buf[1000];
4083 uint8_t *pim_msg;
Everton Marques3e92c452009-11-18 16:26:38 -02004084 struct ip *ip_hdr;
4085 size_t ip_hlen; /* ip header length in bytes */
4086 int ip_msg_len;
4087 int pim_msg_size;
4088 const char *neigh_str;
4089 struct in_addr neigh_addr;
4090 const char *ifname;
4091 struct interface *ifp;
4092 int argi;
4093 int result;
4094
4095 /* Find interface */
4096 ifname = argv[0];
4097 ifp = if_lookup_by_name(ifname);
4098 if (!ifp) {
4099 vty_out(vty, "No such interface name %s%s",
4100 ifname, VTY_NEWLINE);
4101 return CMD_WARNING;
4102 }
4103
4104 /* Neighbor address */
4105 neigh_str = argv[1];
4106 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4107 if (result <= 0) {
4108 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
4109 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
4110 return CMD_WARNING;
4111 }
4112
4113 /*
4114 Tweak IP header
4115 */
4116 ip_hdr = (struct ip *) buf;
4117 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4118 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4119 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4120 ip_hdr->ip_src = neigh_addr;
4121 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4122
4123 /*
4124 Build PIM hello message
4125 */
4126 pim_msg = buf + ip_hlen;
4127 pim_msg_size = 0;
4128
4129 /* Scan LINE dump into buffer */
Everton Marquesdba77582009-11-19 10:32:19 -02004130 for (argi = 2; argi < argc; ++argi) {
4131 const char *str = argv[argi];
4132 int str_len = strlen(str);
4133 int str_last = str_len - 1;
4134 int i;
Everton Marques3e92c452009-11-18 16:26:38 -02004135
Everton Marquesdba77582009-11-19 10:32:19 -02004136 if (str_len % 2) {
4137 vty_out(vty, "%% Uneven hex array arg %d=%s%s",
4138 argi, str, VTY_NEWLINE);
Everton Marques3e92c452009-11-18 16:26:38 -02004139 return CMD_WARNING;
4140 }
4141
Everton Marquesdba77582009-11-19 10:32:19 -02004142 for (i = 0; i < str_last; i += 2) {
4143 uint8_t octet;
4144 int left;
4145 uint8_t h1 = str[i];
4146 uint8_t h2 = str[i + 1];
4147
4148 if (!isxdigit(h1) || !isxdigit(h2)) {
4149 vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s",
4150 h1, h2, argi, str, VTY_NEWLINE);
4151 return CMD_WARNING;
4152 }
4153 octet = (hexval(h1) << 4) + hexval(h2);
4154
4155 left = sizeof(buf) - ip_hlen - pim_msg_size;
4156 if (left < 1) {
David Lamparter5c697982012-02-16 04:47:56 +01004157 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 -02004158 sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
4159 return CMD_WARNING;
4160 }
4161
4162 pim_msg[pim_msg_size++] = octet;
4163 }
Everton Marques3e92c452009-11-18 16:26:38 -02004164 }
4165
4166 ip_msg_len = ip_hlen + pim_msg_size;
4167
David Lamparter5c697982012-02-16 04:47:56 +01004168 vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
Everton Marques3e92c452009-11-18 16:26:38 -02004169 sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
4170
4171 /* "receive" message */
4172
4173 result = pim_pim_packet(ifp, buf, ip_msg_len);
4174 if (result) {
4175 vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s",
4176 ip_msg_len, result, VTY_NEWLINE);
4177 return CMD_WARNING;
4178 }
4179
4180 return CMD_SUCCESS;
4181}
4182
Everton Marques871dbcf2009-08-11 15:43:05 -03004183DEFUN (test_pim_receive_hello,
4184 test_pim_receive_hello_cmd,
4185 "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
4186 "Test\n"
4187 "Test PIM protocol\n"
4188 "Test PIM message reception\n"
4189 "Test PIM hello reception from neighbor\n"
4190 "Interface\n"
4191 "Neighbor address\n"
4192 "Neighbor holdtime\n"
4193 "Neighbor DR priority\n"
4194 "Neighbor generation ID\n"
4195 "Neighbor propagation delay (msec)\n"
4196 "Neighbor override interval (msec)\n"
4197 "Neighbor LAN prune delay T-bit\n"
4198 "Neighbor secondary addresses\n")
4199{
David Lamparterf8cfeb22012-02-16 04:31:08 +00004200 uint8_t buf[1000];
4201 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03004202 struct ip *ip_hdr;
4203 size_t ip_hlen; /* ip header length in bytes */
4204 int ip_msg_len;
4205 int pim_tlv_size;
4206 int pim_msg_size;
4207 const char *neigh_str;
4208 struct in_addr neigh_addr;
4209 const char *ifname;
4210 struct interface *ifp;
4211 uint16_t neigh_holdtime;
4212 uint16_t neigh_propagation_delay;
4213 uint16_t neigh_override_interval;
4214 int neigh_can_disable_join_suppression;
4215 uint32_t neigh_dr_priority;
4216 uint32_t neigh_generation_id;
4217 int argi;
4218 int result;
4219
4220 /* Find interface */
4221 ifname = argv[0];
4222 ifp = if_lookup_by_name(ifname);
4223 if (!ifp) {
4224 vty_out(vty, "No such interface name %s%s",
4225 ifname, VTY_NEWLINE);
4226 return CMD_WARNING;
4227 }
4228
4229 /* Neighbor address */
4230 neigh_str = argv[1];
4231 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4232 if (result <= 0) {
4233 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004234 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004235 return CMD_WARNING;
4236 }
4237
4238 neigh_holdtime = atoi(argv[2]);
4239 neigh_dr_priority = atoi(argv[3]);
4240 neigh_generation_id = atoi(argv[4]);
4241 neigh_propagation_delay = atoi(argv[5]);
4242 neigh_override_interval = atoi(argv[6]);
4243 neigh_can_disable_join_suppression = atoi(argv[7]);
4244
4245 /*
4246 Tweak IP header
4247 */
4248 ip_hdr = (struct ip *) buf;
4249 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4250 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4251 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4252 ip_hdr->ip_src = neigh_addr;
4253 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4254
4255 /*
4256 Build PIM hello message
4257 */
4258 pim_msg = buf + ip_hlen;
4259
4260 /* Scan LINE addresses */
4261 for (argi = 8; argi < argc; ++argi) {
4262 const char *sec_str = argv[argi];
4263 struct in_addr sec_addr;
4264 result = inet_pton(AF_INET, sec_str, &sec_addr);
4265 if (result <= 0) {
4266 vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004267 sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004268 return CMD_WARNING;
4269 }
4270
4271 vty_out(vty,
4272 "FIXME WRITEME consider neighbor secondary address %s%s",
4273 sec_str, VTY_NEWLINE);
4274 }
4275
4276 pim_tlv_size = pim_hello_build_tlv(ifp->name,
4277 pim_msg + PIM_PIM_MIN_LEN,
4278 sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
4279 neigh_holdtime,
4280 neigh_dr_priority,
4281 neigh_generation_id,
4282 neigh_propagation_delay,
4283 neigh_override_interval,
4284 neigh_can_disable_join_suppression,
4285 0 /* FIXME secondary address list */);
4286 if (pim_tlv_size < 0) {
4287 vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
4288 pim_tlv_size, VTY_NEWLINE);
4289 return CMD_WARNING;
4290 }
4291
4292 pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
4293
4294 pim_msg_build_header(pim_msg, pim_msg_size,
4295 PIM_MSG_TYPE_HELLO);
4296
4297 /* "receive" message */
4298
4299 ip_msg_len = ip_hlen + pim_msg_size;
4300 result = pim_pim_packet(ifp, buf, ip_msg_len);
4301 if (result) {
4302 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4303 ip_msg_len, result, VTY_NEWLINE);
4304 return CMD_WARNING;
4305 }
4306
4307 return CMD_SUCCESS;
4308}
4309
4310DEFUN (test_pim_receive_assert,
4311 test_pim_receive_assert_cmd,
4312 "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
4313 "Test\n"
4314 "Test PIM protocol\n"
4315 "Test PIM message reception\n"
4316 "Test reception of PIM assert\n"
4317 "Interface\n"
4318 "Neighbor address\n"
4319 "Assert multicast group address\n"
4320 "Assert unicast source address\n"
4321 "Assert metric preference\n"
4322 "Assert route metric\n"
4323 "Assert RPT bit flag\n")
4324{
David Lamparterf8cfeb22012-02-16 04:31:08 +00004325 uint8_t buf[1000];
4326 uint8_t *buf_pastend = buf + sizeof(buf);
4327 uint8_t *pim_msg;
Everton Marques871dbcf2009-08-11 15:43:05 -03004328 struct ip *ip_hdr;
4329 size_t ip_hlen; /* ip header length in bytes */
4330 int ip_msg_len;
4331 int pim_msg_size;
4332 const char *neigh_str;
4333 struct in_addr neigh_addr;
4334 const char *group_str;
4335 struct in_addr group_addr;
4336 const char *source_str;
4337 struct in_addr source_addr;
4338 const char *ifname;
4339 struct interface *ifp;
4340 uint32_t assert_metric_preference;
4341 uint32_t assert_route_metric;
4342 uint32_t assert_rpt_bit_flag;
4343 int remain;
4344 int result;
4345
4346 /* Find interface */
4347 ifname = argv[0];
4348 ifp = if_lookup_by_name(ifname);
4349 if (!ifp) {
4350 vty_out(vty, "No such interface name %s%s",
4351 ifname, VTY_NEWLINE);
4352 return CMD_WARNING;
4353 }
4354
4355 /* Neighbor address */
4356 neigh_str = argv[1];
4357 result = inet_pton(AF_INET, neigh_str, &neigh_addr);
4358 if (result <= 0) {
4359 vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004360 neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004361 return CMD_WARNING;
4362 }
4363
4364 /* Group address */
4365 group_str = argv[2];
4366 result = inet_pton(AF_INET, group_str, &group_addr);
4367 if (result <= 0) {
4368 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004369 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004370 return CMD_WARNING;
4371 }
4372
4373 /* Source address */
4374 source_str = argv[3];
4375 result = inet_pton(AF_INET, source_str, &source_addr);
4376 if (result <= 0) {
4377 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004378 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004379 return CMD_WARNING;
4380 }
4381
4382 assert_metric_preference = atoi(argv[4]);
4383 assert_route_metric = atoi(argv[5]);
4384 assert_rpt_bit_flag = atoi(argv[6]);
4385
4386 remain = buf_pastend - buf;
4387 if (remain < (int) sizeof(struct ip)) {
David Lamparter5c697982012-02-16 04:47:56 +01004388 vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03004389 remain, sizeof(struct ip), VTY_NEWLINE);
4390 return CMD_WARNING;
4391 }
4392
4393 /*
4394 Tweak IP header
4395 */
4396 ip_hdr = (struct ip *) buf;
4397 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4398 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4399 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4400 ip_hdr->ip_src = neigh_addr;
4401 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4402
4403 /*
4404 Build PIM assert message
4405 */
4406 pim_msg = buf + ip_hlen; /* skip ip header */
4407
4408 pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
4409 group_addr, source_addr,
4410 assert_metric_preference,
4411 assert_route_metric,
4412 assert_rpt_bit_flag);
4413 if (pim_msg_size < 0) {
4414 vty_out(vty, "Failure building PIM assert message: size=%d%s",
4415 pim_msg_size, VTY_NEWLINE);
4416 return CMD_WARNING;
4417 }
4418
4419 /* "receive" message */
4420
4421 ip_msg_len = ip_hlen + pim_msg_size;
4422 result = pim_pim_packet(ifp, buf, ip_msg_len);
4423 if (result) {
4424 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4425 ip_msg_len, result, VTY_NEWLINE);
4426 return CMD_WARNING;
4427 }
4428
4429 return CMD_SUCCESS;
4430}
4431
4432static int recv_joinprune(struct vty *vty,
4433 const char *argv[],
4434 int src_is_join)
4435{
David Lamparterf8cfeb22012-02-16 04:31:08 +00004436 uint8_t buf[1000];
4437 const uint8_t *buf_pastend = buf + sizeof(buf);
4438 uint8_t *pim_msg;
4439 uint8_t *pim_msg_curr;
Everton Marques871dbcf2009-08-11 15:43:05 -03004440 int pim_msg_size;
4441 struct ip *ip_hdr;
4442 size_t ip_hlen; /* ip header length in bytes */
4443 int ip_msg_len;
4444 uint16_t neigh_holdtime;
4445 const char *neigh_dst_str;
4446 struct in_addr neigh_dst_addr;
4447 const char *neigh_src_str;
4448 struct in_addr neigh_src_addr;
4449 const char *group_str;
4450 struct in_addr group_addr;
4451 const char *source_str;
4452 struct in_addr source_addr;
4453 const char *ifname;
4454 struct interface *ifp;
4455 int result;
4456 int remain;
4457 uint16_t num_joined;
4458 uint16_t num_pruned;
4459
4460 /* Find interface */
4461 ifname = argv[0];
4462 ifp = if_lookup_by_name(ifname);
4463 if (!ifp) {
4464 vty_out(vty, "No such interface name %s%s",
4465 ifname, VTY_NEWLINE);
4466 return CMD_WARNING;
4467 }
4468
4469 neigh_holdtime = atoi(argv[1]);
4470
4471 /* Neighbor destination address */
4472 neigh_dst_str = argv[2];
4473 result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
4474 if (result <= 0) {
4475 vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004476 neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004477 return CMD_WARNING;
4478 }
4479
4480 /* Neighbor source address */
4481 neigh_src_str = argv[3];
4482 result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
4483 if (result <= 0) {
4484 vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004485 neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004486 return CMD_WARNING;
4487 }
4488
4489 /* Multicast group address */
4490 group_str = argv[4];
4491 result = inet_pton(AF_INET, group_str, &group_addr);
4492 if (result <= 0) {
4493 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004494 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004495 return CMD_WARNING;
4496 }
4497
4498 /* Multicast source address */
4499 source_str = argv[5];
4500 result = inet_pton(AF_INET, source_str, &source_addr);
4501 if (result <= 0) {
4502 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004503 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004504 return CMD_WARNING;
4505 }
4506
4507 /*
4508 Tweak IP header
4509 */
4510 ip_hdr = (struct ip *) buf;
4511 ip_hdr->ip_p = PIM_IP_PROTO_PIM;
4512 ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
4513 ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
4514 ip_hdr->ip_src = neigh_src_addr;
4515 ip_hdr->ip_dst = qpim_all_pim_routers_addr;
4516
4517 /*
4518 Build PIM message
4519 */
4520 pim_msg = buf + ip_hlen;
4521
4522 /* skip room for pim header */
4523 pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
4524
4525 remain = buf_pastend - pim_msg_curr;
4526 pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
4527 remain,
4528 neigh_dst_addr);
4529 if (!pim_msg_curr) {
4530 vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
4531 neigh_dst_str, remain, VTY_NEWLINE);
4532 return CMD_WARNING;
4533 }
4534
4535 remain = buf_pastend - pim_msg_curr;
4536 if (remain < 4) {
4537 vty_out(vty, "Group will not fit: space left=%d%s",
4538 remain, VTY_NEWLINE);
4539 return CMD_WARNING;
4540 }
4541
4542 *pim_msg_curr = 0; /* reserved */
4543 ++pim_msg_curr;
4544 *pim_msg_curr = 1; /* number of groups */
4545 ++pim_msg_curr;
4546 *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
4547 ++pim_msg_curr;
4548 ++pim_msg_curr;
4549
4550 remain = buf_pastend - pim_msg_curr;
4551 pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
4552 remain,
4553 group_addr);
4554 if (!pim_msg_curr) {
4555 vty_out(vty, "Failure encoding group address %s: space left=%d%s",
4556 group_str, remain, VTY_NEWLINE);
4557 return CMD_WARNING;
4558 }
4559
4560 remain = buf_pastend - pim_msg_curr;
4561 if (remain < 4) {
4562 vty_out(vty, "Sources will not fit: space left=%d%s",
4563 remain, VTY_NEWLINE);
4564 return CMD_WARNING;
4565 }
4566
4567 if (src_is_join) {
4568 num_joined = 1;
4569 num_pruned = 0;
4570 }
4571 else {
4572 num_joined = 0;
4573 num_pruned = 1;
4574 }
4575
4576 /* number of joined sources */
4577 *((uint16_t *) pim_msg_curr) = htons(num_joined);
4578 ++pim_msg_curr;
4579 ++pim_msg_curr;
4580
4581 /* number of pruned sources */
4582 *((uint16_t *) pim_msg_curr) = htons(num_pruned);
4583 ++pim_msg_curr;
4584 ++pim_msg_curr;
4585
4586 remain = buf_pastend - pim_msg_curr;
4587 pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
4588 remain,
4589 source_addr);
4590 if (!pim_msg_curr) {
4591 vty_out(vty, "Failure encoding source address %s: space left=%d%s",
4592 source_str, remain, VTY_NEWLINE);
4593 return CMD_WARNING;
4594 }
4595
4596 /* Add PIM header */
4597
4598 pim_msg_size = pim_msg_curr - pim_msg;
4599
4600 pim_msg_build_header(pim_msg, pim_msg_size,
4601 PIM_MSG_TYPE_JOIN_PRUNE);
4602
4603 /*
4604 "Receive" message
4605 */
4606
4607 ip_msg_len = ip_hlen + pim_msg_size;
4608 result = pim_pim_packet(ifp, buf, ip_msg_len);
4609 if (result) {
4610 vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
4611 ip_msg_len, result, VTY_NEWLINE);
4612 return CMD_WARNING;
4613 }
4614
4615 return CMD_SUCCESS;
4616}
4617
4618DEFUN (test_pim_receive_join,
4619 test_pim_receive_join_cmd,
4620 "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4621 "Test\n"
4622 "Test PIM protocol\n"
4623 "Test PIM message reception\n"
4624 "Test PIM join reception from neighbor\n"
4625 "Interface\n"
4626 "Neighbor holdtime\n"
4627 "Upstream neighbor unicast destination address\n"
4628 "Downstream neighbor unicast source address\n"
4629 "Multicast group address\n"
4630 "Unicast source address\n")
4631{
4632 return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
4633}
4634
4635DEFUN (test_pim_receive_prune,
4636 test_pim_receive_prune_cmd,
4637 "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
4638 "Test\n"
4639 "Test PIM protocol\n"
4640 "Test PIM message reception\n"
4641 "Test PIM prune reception from neighbor\n"
4642 "Interface\n"
4643 "Neighbor holdtime\n"
4644 "Upstream neighbor unicast destination address\n"
4645 "Downstream neighbor unicast source address\n"
4646 "Multicast group address\n"
4647 "Unicast source address\n")
4648{
4649 return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
4650}
4651
4652DEFUN (test_pim_receive_upcall,
4653 test_pim_receive_upcall_cmd,
4654 "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
4655 "Test\n"
4656 "Test PIM protocol\n"
4657 "Test PIM message reception\n"
4658 "Test reception of kernel upcall\n"
4659 "NOCACHE kernel upcall\n"
4660 "WRONGVIF kernel upcall\n"
4661 "WHOLEPKT kernel upcall\n"
4662 "Input interface vif index\n"
4663 "Multicast group address\n"
4664 "Multicast source address\n")
4665{
4666 struct igmpmsg msg;
4667 const char *upcall_type;
4668 const char *group_str;
4669 const char *source_str;
4670 int result;
4671
4672 upcall_type = argv[0];
4673
4674 if (upcall_type[0] == 'n')
4675 msg.im_msgtype = IGMPMSG_NOCACHE;
4676 else if (upcall_type[1] == 'r')
4677 msg.im_msgtype = IGMPMSG_WRONGVIF;
4678 else if (upcall_type[1] == 'h')
4679 msg.im_msgtype = IGMPMSG_WHOLEPKT;
4680 else {
4681 vty_out(vty, "Unknown kernel upcall type: %s%s",
4682 upcall_type, VTY_NEWLINE);
4683 return CMD_WARNING;
4684 }
4685
4686 msg.im_vif = atoi(argv[1]);
4687
4688 /* Group address */
4689 group_str = argv[2];
4690 result = inet_pton(AF_INET, group_str, &msg.im_dst);
4691 if (result <= 0) {
4692 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004693 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004694 return CMD_WARNING;
4695 }
4696
4697 /* Source address */
4698 source_str = argv[3];
4699 result = inet_pton(AF_INET, source_str, &msg.im_src);
4700 if (result <= 0) {
4701 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
Everton Marquese96f0af2009-08-11 15:48:02 -03004702 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
Everton Marques871dbcf2009-08-11 15:43:05 -03004703 return CMD_WARNING;
4704 }
4705
4706 msg.im_mbz = 0; /* Must be zero */
4707
4708 result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
4709 if (result) {
David Lamparter5c697982012-02-16 04:47:56 +01004710 vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
Everton Marques871dbcf2009-08-11 15:43:05 -03004711 sizeof(msg), result, VTY_NEWLINE);
4712 return CMD_WARNING;
4713 }
4714
4715 return CMD_SUCCESS;
4716}
4717
4718void pim_cmd_init()
4719{
Leonard Herve596470f2009-08-11 15:45:26 -03004720 install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
4721 install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
Everton Marques871dbcf2009-08-11 15:43:05 -03004722
Leonard Herve596470f2009-08-11 15:45:26 -03004723 install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
4724 install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
Everton Marques96f91ae2009-10-07 18:41:45 -03004725 install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
4726 install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004727#if 0
Leonard Herve596470f2009-08-11 15:45:26 -03004728 install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004729#else
Leonard Herve596470f2009-08-11 15:45:26 -03004730 install_element (CONFIG_NODE, &pim_interface_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004731#endif
Leonard Herve596470f2009-08-11 15:45:26 -03004732 install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
Everton Marques871dbcf2009-08-11 15:43:05 -03004733
Leonard Herve596470f2009-08-11 15:45:26 -03004734 install_default (INTERFACE_NODE);
4735 install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
4736 install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
4737 install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
4738 install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
4739 install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
4740 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
4741 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
4742 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
4743 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
4744 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
4745 install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
Donald Sharp6ae80e02015-06-18 18:14:20 -07004746 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
4747 install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd);
4748 install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004749
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05004750 // Static mroutes NEB
4751 install_element (INTERFACE_NODE, &interface_ip_mroute_cmd);
4752 install_element (INTERFACE_NODE, &interface_ip_mroute_source_cmd);
4753 install_element (INTERFACE_NODE, &interface_no_ip_mroute_cmd);
4754 install_element (INTERFACE_NODE, &interface_no_ip_mroute_source_cmd);
4755
Leonard Herve596470f2009-08-11 15:45:26 -03004756 install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004757 install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004758 install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
4759 install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
4760 install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4761 install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
4762 install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4763 install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
4764 install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
4765 install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
4766 install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
4767 install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
4768 install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
4769 install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
4770 install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
4771 install_element (VIEW_NODE, &show_ip_pim_join_cmd);
4772 install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
4773 install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
4774 install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
4775 install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
4776 install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
4777 install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
4778 install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
4779 install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
4780 install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
4781 install_element (VIEW_NODE, &show_ip_multicast_cmd);
4782 install_element (VIEW_NODE, &show_ip_mroute_cmd);
4783 install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004784 install_element (VIEW_NODE, &show_ip_rib_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004785 install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
Donald Sharpcd557c32015-05-27 17:40:46 -07004786 install_element (VIEW_NODE, &show_debugging_pim_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004787
Leonard Herve596470f2009-08-11 15:45:26 -03004788 install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
4789 install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
Everton Marquesf24200d2014-02-14 16:40:34 -02004790 install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004791 install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
Everton Marquesf24200d2014-02-14 16:40:34 -02004792 install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004793
Leonard Herve596470f2009-08-11 15:45:26 -03004794 install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
Everton Marques567f9272010-02-19 19:07:00 -02004795 install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004796 install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
4797 install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
4798 install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
4799 install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
4800 install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
4801 install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
4802 install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
4803 install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
4804 install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
4805 install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
4806 install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
4807 install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
4808 install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
4809 install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
4810 install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
4811 install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
4812 install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
4813 install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
4814 install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
4815 install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
4816 install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
4817 install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
4818 install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
4819 install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
4820 install_element (ENABLE_NODE, &show_ip_multicast_cmd);
4821 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
4822 install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
Everton Marques05e573d2010-04-20 12:20:46 -03004823 install_element (ENABLE_NODE, &show_ip_rib_cmd);
Everton Marquese8c11bb2009-10-08 15:06:32 -03004824 install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd);
Donald Sharpcd557c32015-05-27 17:40:46 -07004825 install_element (ENABLE_NODE, &show_debugging_pim_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004826
Leonard Herve596470f2009-08-11 15:45:26 -03004827 install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
4828 install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
Everton Marques3e92c452009-11-18 16:26:38 -02004829 install_element (ENABLE_NODE, &test_pim_receive_dump_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004830 install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
4831 install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
4832 install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
4833 install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004834
Leonard Herve596470f2009-08-11 15:45:26 -03004835 install_element (ENABLE_NODE, &debug_igmp_cmd);
4836 install_element (ENABLE_NODE, &no_debug_igmp_cmd);
4837 install_element (ENABLE_NODE, &undebug_igmp_cmd);
4838 install_element (ENABLE_NODE, &debug_igmp_events_cmd);
4839 install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
4840 install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
4841 install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
4842 install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
4843 install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
4844 install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
4845 install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
4846 install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004847 install_element (ENABLE_NODE, &debug_mroute_cmd);
4848 install_element (ENABLE_NODE, &no_debug_mroute_cmd);
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05004849 install_element (ENABLE_NODE, &debug_static_cmd);
4850 install_element (ENABLE_NODE, &no_debug_static_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004851 install_element (ENABLE_NODE, &debug_pim_cmd);
4852 install_element (ENABLE_NODE, &no_debug_pim_cmd);
4853 install_element (ENABLE_NODE, &undebug_pim_cmd);
4854 install_element (ENABLE_NODE, &debug_pim_events_cmd);
4855 install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
4856 install_element (ENABLE_NODE, &undebug_pim_events_cmd);
4857 install_element (ENABLE_NODE, &debug_pim_packets_cmd);
Balaji.Ged14fa02014-10-08 01:11:31 -03004858 install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004859 install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
Balaji.Ged14fa02014-10-08 01:11:31 -03004860 install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004861 install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
Everton Marques62738042009-11-18 10:44:13 -02004862 install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
4863 install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
4864 install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd);
4865 install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
4866 install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
4867 install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004868 install_element (ENABLE_NODE, &debug_pim_trace_cmd);
4869 install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
4870 install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004871 install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
4872 install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
4873 install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004874 install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
4875 install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
4876 install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004877
Leonard Herve596470f2009-08-11 15:45:26 -03004878 install_element (CONFIG_NODE, &debug_igmp_cmd);
4879 install_element (CONFIG_NODE, &no_debug_igmp_cmd);
4880 install_element (CONFIG_NODE, &undebug_igmp_cmd);
4881 install_element (CONFIG_NODE, &debug_igmp_events_cmd);
4882 install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
4883 install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
4884 install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
4885 install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
4886 install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
4887 install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
4888 install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
4889 install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
Everton Marques67faabc2010-02-23 12:11:11 -03004890 install_element (CONFIG_NODE, &debug_mroute_cmd);
4891 install_element (CONFIG_NODE, &no_debug_mroute_cmd);
Jafar Al-Gharaibeh030674d2015-06-11 18:29:02 -05004892 install_element (CONFIG_NODE, &debug_static_cmd);
4893 install_element (CONFIG_NODE, &no_debug_static_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004894 install_element (CONFIG_NODE, &debug_pim_cmd);
4895 install_element (CONFIG_NODE, &no_debug_pim_cmd);
4896 install_element (CONFIG_NODE, &undebug_pim_cmd);
4897 install_element (CONFIG_NODE, &debug_pim_events_cmd);
4898 install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
4899 install_element (CONFIG_NODE, &undebug_pim_events_cmd);
4900 install_element (CONFIG_NODE, &debug_pim_packets_cmd);
Balaji.Ged14fa02014-10-08 01:11:31 -03004901 install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004902 install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
Balaji.Ged14fa02014-10-08 01:11:31 -03004903 install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004904 install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
4905 install_element (CONFIG_NODE, &debug_pim_trace_cmd);
4906 install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
4907 install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
Everton Marques824adbe2009-10-08 09:16:27 -03004908 install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
4909 install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
4910 install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
Leonard Herve596470f2009-08-11 15:45:26 -03004911 install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
4912 install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
4913 install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
Everton Marques871dbcf2009-08-11 15:43:05 -03004914}