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