]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_cmd.c
pimd: Don't send (S,G)RPT prune
[mirror_frr.git] / pimd / pim_cmd.c
CommitLineData
12e41d03
DL
1/*
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
12e41d03
DL
20*/
21
12e41d03
DL
22#include <zebra.h>
23
9bf3c633 24#include "lib/json.h"
12e41d03
DL
25#include "command.h"
26#include "if.h"
27#include "prefix.h"
28#include "zclient.h"
dfe43e25 29#include "plist.h"
12e41d03
DL
30
31#include "pimd.h"
9867746a 32#include "pim_mroute.h"
12e41d03
DL
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"
38#include "pim_igmp.h"
39#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"
52#include "pim_ssmpingd.h"
53#include "pim_zebra.h"
6250610a 54#include "pim_static.h"
a920d6e7 55#include "pim_rp.h"
05b0d0d0 56#include "pim_zlookup.h"
2a333e0f 57#include "pim_msdp.h"
12e41d03
DL
58
59static struct cmd_node pim_global_node = {
60 PIM_NODE,
61 "",
62 1 /* vtysh ? yes */
63};
64
65static struct cmd_node interface_node = {
66 INTERFACE_NODE,
67 "%s(config-if)# ",
68 1 /* vtysh ? yes */
69};
70
eb7a976a
DS
71static struct cmd_node debug_node =
72{
73 DEBUG_NODE,
74 "",
75 1
76};
77
12e41d03
DL
78static void pim_if_membership_clear(struct interface *ifp)
79{
80 struct pim_interface *pim_ifp;
81
82 pim_ifp = ifp->info;
83 zassert(pim_ifp);
84
85 if (PIM_IF_TEST_PIM(pim_ifp->options) &&
86 PIM_IF_TEST_IGMP(pim_ifp->options)) {
87 return;
88 }
89
90 pim_ifchannel_membership_clear(ifp);
91}
92
93/*
94 When PIM is disabled on interface, IGMPv3 local membership
95 information is not injected into PIM interface state.
96
97 The function pim_if_membership_refresh() fetches all IGMPv3 local
98 membership information into PIM. It is intented to be called
99 whenever PIM is enabled on the interface in order to collect missed
100 local membership information.
101 */
102static void pim_if_membership_refresh(struct interface *ifp)
103{
104 struct pim_interface *pim_ifp;
105 struct listnode *sock_node;
106 struct igmp_sock *igmp;
107
108 pim_ifp = ifp->info;
109 zassert(pim_ifp);
110
111 if (!PIM_IF_TEST_PIM(pim_ifp->options))
112 return;
113 if (!PIM_IF_TEST_IGMP(pim_ifp->options))
114 return;
115
116 /*
117 First clear off membership from all PIM (S,G) entries on the
118 interface
119 */
120
121 pim_ifchannel_membership_clear(ifp);
122
123 /*
124 Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
125 the interface
126 */
127
128 /* scan igmp sockets */
129 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
130 struct listnode *grpnode;
131 struct igmp_group *grp;
132
133 /* scan igmp groups */
134 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
135 struct listnode *srcnode;
136 struct igmp_source *src;
137
138 /* scan group sources */
139 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
140
141 if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) {
4ed0af70 142 struct prefix_sg sg;
69283639 143
4ed0af70
DS
144 memset (&sg, 0, sizeof (struct prefix_sg));
145 sg.src = src->source_addr;
146 sg.grp = grp->group_addr;
69283639 147 pim_ifchannel_local_membership_add(ifp, &sg);
12e41d03
DL
148 }
149
150 } /* scan group sources */
151 } /* scan igmp groups */
152 } /* scan igmp sockets */
153
154 /*
155 Finally delete every PIM (S,G) entry lacking all state info
156 */
157
158 pim_ifchannel_delete_on_noinfo(ifp);
159
160}
161
162static void pim_show_assert(struct vty *vty)
163{
ea4a71fc
DS
164 struct pim_interface *pim_ifp;
165 struct pim_ifchannel *ch;
166 struct listnode *ch_node;
167 struct in_addr ifaddr;
168 time_t now;
12e41d03
DL
169
170 now = pim_time_monotonic_sec();
171
172 vty_out(vty,
173 "Interface Address Source Group State Winner Uptime Timer%s",
174 VTY_NEWLINE);
175
ea4a71fc
DS
176 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
177 char ch_src_str[INET_ADDRSTRLEN];
178 char ch_grp_str[INET_ADDRSTRLEN];
179 char winner_str[INET_ADDRSTRLEN];
180 char uptime[10];
181 char timer[10];
12e41d03 182
ea4a71fc 183 pim_ifp = ch->interface->info;
12e41d03
DL
184
185 if (!pim_ifp)
186 continue;
187
188 ifaddr = pim_ifp->primary_address;
189
ea4a71fc
DS
190 pim_inet4_dump("<ch_src?>", ch->sg.src,
191 ch_src_str, sizeof(ch_src_str));
192 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
193 ch_grp_str, sizeof(ch_grp_str));
194 pim_inet4_dump("<assrt_win?>", ch->ifassert_winner,
195 winner_str, sizeof(winner_str));
196
197 pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
198 pim_time_timer_to_mmss(timer, sizeof(timer),
199 ch->t_ifassert_timer);
200
201 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s",
202 ch->interface->name,
203 inet_ntoa(ifaddr),
204 ch_src_str,
205 ch_grp_str,
206 pim_ifchannel_ifassert_name(ch->ifassert_state),
207 winner_str,
208 uptime,
209 timer,
210 VTY_NEWLINE);
211 } /* scan interface channels */
12e41d03
DL
212}
213
214static void pim_show_assert_internal(struct vty *vty)
215{
ea4a71fc
DS
216 struct pim_interface *pim_ifp;
217 struct listnode *ch_node;
218 struct pim_ifchannel *ch;
219 struct in_addr ifaddr;
12e41d03
DL
220
221 vty_out(vty,
222 "CA: CouldAssert%s"
223 "ECA: Evaluate CouldAssert%s"
224 "ATD: AssertTrackingDesired%s"
225 "eATD: Evaluate AssertTrackingDesired%s%s",
226 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
227
228 vty_out(vty,
229 "Interface Address Source Group CA eCA ATD eATD%s",
230 VTY_NEWLINE);
231
ea4a71fc
DS
232 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
233 pim_ifp = ch->interface->info;
12e41d03
DL
234
235 if (!pim_ifp)
236 continue;
237
238 ifaddr = pim_ifp->primary_address;
239
ea4a71fc
DS
240 char ch_src_str[INET_ADDRSTRLEN];
241 char ch_grp_str[INET_ADDRSTRLEN];
242
243 pim_inet4_dump("<ch_src?>", ch->sg.src,
244 ch_src_str, sizeof(ch_src_str));
245 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
246 ch_grp_str, sizeof(ch_grp_str));
247 vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s",
248 ch->interface->name,
249 inet_ntoa(ifaddr),
250 ch_src_str,
251 ch_grp_str,
252 PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
253 pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
254 PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no",
255 pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no",
256 VTY_NEWLINE);
257 } /* scan interface channels */
12e41d03
DL
258}
259
260static void pim_show_assert_metric(struct vty *vty)
261{
ea4a71fc
DS
262 struct pim_interface *pim_ifp;
263 struct listnode *ch_node;
264 struct pim_ifchannel *ch;
265 struct in_addr ifaddr;
266
12e41d03
DL
267 vty_out(vty,
268 "Interface Address Source Group RPT Pref Metric Address %s",
269 VTY_NEWLINE);
270
ea4a71fc
DS
271 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
272 pim_ifp = ch->interface->info;
12e41d03 273
12e41d03
DL
274 if (!pim_ifp)
275 continue;
276
277 ifaddr = pim_ifp->primary_address;
278
ea4a71fc
DS
279 char ch_src_str[INET_ADDRSTRLEN];
280 char ch_grp_str[INET_ADDRSTRLEN];
281 char addr_str[INET_ADDRSTRLEN];
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->sg.src,
287 ch_src_str, sizeof(ch_src_str));
288 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
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 ch->interface->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);
12e41d03 303 } /* scan interface channels */
12e41d03
DL
304}
305
306static void pim_show_assert_winner_metric(struct vty *vty)
307{
ea4a71fc
DS
308 struct pim_interface *pim_ifp;
309 struct listnode *ch_node;
310 struct pim_ifchannel *ch;
311 struct in_addr ifaddr;
12e41d03
DL
312
313 vty_out(vty,
314 "Interface Address Source Group RPT Pref Metric Address %s",
315 VTY_NEWLINE);
316
ea4a71fc
DS
317 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
318 pim_ifp = ch->interface->info;
12e41d03
DL
319
320 if (!pim_ifp)
321 continue;
322
323 ifaddr = pim_ifp->primary_address;
324
ea4a71fc
DS
325 char ch_src_str[INET_ADDRSTRLEN];
326 char ch_grp_str[INET_ADDRSTRLEN];
327 char addr_str[INET_ADDRSTRLEN];
328 struct pim_assert_metric *am;
329 char pref_str[5];
330 char metr_str[7];
12e41d03 331
ea4a71fc 332 am = &ch->ifassert_winner_metric;
12e41d03 333
ea4a71fc
DS
334 pim_inet4_dump("<ch_src?>", ch->sg.src,
335 ch_src_str, sizeof(ch_src_str));
336 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
337 ch_grp_str, sizeof(ch_grp_str));
338 pim_inet4_dump("<addr?>", am->ip_address,
339 addr_str, sizeof(addr_str));
340
341 if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
342 snprintf(pref_str, sizeof(pref_str), "INFI");
343 else
344 snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference);
345
346 if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
347 snprintf(metr_str, sizeof(metr_str), "INFI");
348 else
349 snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
350
351 vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s",
352 ch->interface->name,
353 inet_ntoa(ifaddr),
354 ch_src_str,
355 ch_grp_str,
356 am->rpt_bit_flag ? "yes" : "no",
357 pref_str,
358 metr_str,
359 addr_str,
360 VTY_NEWLINE);
361 } /* scan interface channels */
12e41d03
DL
362}
363
e775c0a4
DW
364static void json_object_pim_ifp_add(struct json_object *json, struct interface *ifp)
365{
366 struct pim_interface *pim_ifp;
367
368 pim_ifp = ifp->info;
369 json_object_string_add(json, "name", ifp->name);
370 json_object_string_add(json, "state", if_is_up(ifp) ? "up" : "down");
371 json_object_string_add(json, "address", inet_ntoa(pim_ifp->primary_address));
372 json_object_int_add(json, "index", ifp->ifindex);
373
374 if (if_is_multicast(ifp))
375 json_object_boolean_true_add(json, "flagMulticast");
376
377 if (if_is_broadcast(ifp))
378 json_object_boolean_true_add(json, "flagBroadcast");
379
380 if (ifp->flags & IFF_ALLMULTI)
381 json_object_boolean_true_add(json, "flagAllMulticast");
382
383 if (ifp->flags & IFF_PROMISC)
384 json_object_boolean_true_add(json, "flagPromiscuous");
385
386 if (PIM_IF_IS_DELETED(ifp))
387 json_object_boolean_true_add(json, "flagDeleted");
388
389 if (pim_if_lan_delay_enabled(ifp))
390 json_object_boolean_true_add(json, "lanDelayEnabled");
391}
392
393static void pim_show_membership(struct vty *vty, u_char uj)
12e41d03 394{
ea4a71fc
DS
395 struct pim_interface *pim_ifp;
396 struct listnode *ch_node;
397 struct pim_ifchannel *ch;
7e147823 398 enum json_type type;
e775c0a4
DW
399 json_object *json = NULL;
400 json_object *json_iface = NULL;
401 json_object *json_row = NULL;
7e147823 402 json_object *json_tmp = NULL;
12e41d03 403
7e147823 404 json = json_object_new_object();
12e41d03 405
ea4a71fc 406 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
12e41d03 407
ea4a71fc 408 pim_ifp = ch->interface->info;
7e147823 409
12e41d03
DL
410 if (!pim_ifp)
411 continue;
412
ea4a71fc
DS
413 char ch_src_str[INET_ADDRSTRLEN];
414 char ch_grp_str[INET_ADDRSTRLEN];
12e41d03 415
ea4a71fc
DS
416 pim_inet4_dump("<ch_src?>", ch->sg.src,
417 ch_src_str, sizeof(ch_src_str));
418 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
419 ch_grp_str, sizeof(ch_grp_str));
12e41d03 420
ea4a71fc 421 json_object_object_get_ex(json, ch->interface->name, &json_iface);
e775c0a4 422
ea4a71fc
DS
423 if (!json_iface) {
424 json_iface = json_object_new_object();
425 json_object_pim_ifp_add(json_iface, ch->interface);
426 json_object_object_add(json, ch->interface->name, json_iface);
427 }
7e147823 428
ea4a71fc
DS
429 json_row = json_object_new_object();
430 json_object_string_add(json_row, "source", ch_src_str);
431 json_object_string_add(json_row, "group", ch_grp_str);
432 json_object_string_add(json_row, "localMembership",
433 ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ? "NOINFO" : "INCLUDE");
434 json_object_object_add(json_iface, ch_grp_str, json_row);
435 } /* scan interface channels */
12e41d03 436
e775c0a4 437 if (uj) {
17b52be1 438 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
7e147823
DW
439 } else {
440 vty_out(vty,
441 "Interface Address Source Group Membership%s",
442 VTY_NEWLINE);
443
444 /*
445 * Example of the json data we are traversing
446 *
447 * {
448 * "swp3":{
449 * "name":"swp3",
450 * "state":"up",
451 * "address":"10.1.20.1",
452 * "index":5,
453 * "flagMulticast":true,
454 * "flagBroadcast":true,
455 * "lanDelayEnabled":true,
456 * "226.10.10.10":{
457 * "source":"*",
458 * "group":"226.10.10.10",
459 * "localMembership":"INCLUDE"
460 * }
461 * }
462 * }
463 */
464
465 /* foreach interface */
466 json_object_object_foreach(json, key, val) {
467
468 /* Find all of the keys where the val is an object. In the example
469 * above the only one is 226.10.10.10
470 */
471 json_object_object_foreach(val, if_field_key, if_field_val) {
472 type = json_object_get_type(if_field_val);
473
474 if (type == json_type_object) {
475 vty_out(vty, "%-9s ", key);
476
477 json_object_object_get_ex(val, "address", &json_tmp);
478 vty_out(vty, "%-15s ", json_object_get_string(json_tmp));
479
480 json_object_object_get_ex(if_field_val, "source", &json_tmp);
481 vty_out(vty, "%-15s ", json_object_get_string(json_tmp));
482
483 /* Group */
484 vty_out(vty, "%-15s ", if_field_key);
485
486 json_object_object_get_ex(if_field_val, "localMembership", &json_tmp);
487 vty_out(vty, "%-10s%s", json_object_get_string(json_tmp), VTY_NEWLINE);
488 }
489 }
490 }
e775c0a4 491 }
7e147823
DW
492
493 json_object_free(json);
12e41d03
DL
494}
495
a268493f
DW
496static void pim_print_ifp_flags(struct vty *vty, struct interface *ifp, int mloop)
497{
498 vty_out(vty, "Flags%s", VTY_NEWLINE);
499 vty_out(vty, "-----%s", VTY_NEWLINE);
500 vty_out(vty, "All Multicast : %s%s", (ifp->flags & IFF_ALLMULTI) ? "yes" : "no", VTY_NEWLINE);
501 vty_out(vty, "Broadcast : %s%s", if_is_broadcast(ifp)? "yes" : "no", VTY_NEWLINE);
502 vty_out(vty, "Deleted : %s%s", PIM_IF_IS_DELETED(ifp) ? "yes" : "no", VTY_NEWLINE);
503 vty_out(vty, "Interface Index : %d%s", ifp->ifindex, VTY_NEWLINE);
504 vty_out(vty, "Multicast : %s%s", if_is_multicast(ifp) ? "yes" : "no", VTY_NEWLINE);
505 vty_out(vty, "Multicast Loop : %d%s", mloop, VTY_NEWLINE);
506 vty_out(vty, "Promiscuous : %s%s", (ifp->flags & IFF_PROMISC) ? "yes" : "no", VTY_NEWLINE);
507 vty_out(vty, "%s", VTY_NEWLINE);
508 vty_out(vty, "%s", VTY_NEWLINE);
509}
510
a268493f 511static void igmp_show_interfaces(struct vty *vty, u_char uj)
12e41d03
DL
512{
513 struct listnode *node;
514 struct interface *ifp;
515 time_t now;
a268493f
DW
516 json_object *json = NULL;
517 json_object *json_row = NULL;
518
12e41d03
DL
519 now = pim_time_monotonic_sec();
520
a268493f
DW
521 if (uj)
522 json = json_object_new_object();
523 else
524 vty_out(vty,
b05b72e8 525 "Interface State Address V Querier Query Timer Uptime%s",
a268493f 526 VTY_NEWLINE);
12e41d03 527
469351b3 528 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
529 struct pim_interface *pim_ifp;
530 struct listnode *sock_node;
531 struct igmp_sock *igmp;
532
533 pim_ifp = ifp->info;
a268493f 534
12e41d03
DL
535 if (!pim_ifp)
536 continue;
537
538 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
539 char uptime[10];
a268493f 540 char query_hhmmss[10];
12e41d03
DL
541
542 pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
a268493f 543 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
12e41d03 544
a268493f
DW
545 if (uj) {
546 json_row = json_object_new_object();
e775c0a4 547 json_object_pim_ifp_add(json_row, ifp);
a268493f 548 json_object_string_add(json_row, "upTime", uptime);
b05b72e8 549 json_object_int_add(json_row, "version", pim_ifp->igmp_version);
a268493f
DW
550
551 if (igmp->t_igmp_query_timer) {
552 json_object_boolean_true_add(json_row, "querier");
553 json_object_string_add(json_row, "queryTimer", query_hhmmss);
554 }
555
556 json_object_object_add(json, ifp->name, json_row);
557
558 } else {
b05b72e8 559 vty_out(vty, "%-9s %5s %15s %d %7s %11s %8s%s",
a268493f
DW
560 ifp->name,
561 if_is_up(ifp) ? "up" : "down",
562 inet_ntoa(igmp->ifaddr),
b05b72e8 563 pim_ifp->igmp_version,
a268493f
DW
564 igmp->t_igmp_query_timer ? "local" : "other",
565 query_hhmmss,
566 uptime,
567 VTY_NEWLINE);
568 }
569 }
570 }
571
572 if (uj) {
17b52be1 573 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
a268493f
DW
574 json_object_free(json);
575 }
576}
577
578static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_char uj)
579{
580 struct igmp_sock *igmp;
581 struct interface *ifp;
582 struct listnode *node;
583 struct listnode *sock_node;
584 struct pim_interface *pim_ifp;
585 char uptime[10];
586 char query_hhmmss[10];
587 char other_hhmmss[10];
588 int found_ifname = 0;
589 int sqi;
590 int mloop;
591 long gmi_msec; /* Group Membership Interval */
592 long lmqt_msec;
593 long ohpi_msec;
594 long oqpi_msec; /* Other Querier Present Interval */
595 long qri_msec;
596 time_t now;
597
598 json_object *json = NULL;
599 json_object *json_row = NULL;
600
9b91bb50
DW
601 if (uj)
602 json = json_object_new_object();
603
a268493f
DW
604 now = pim_time_monotonic_sec();
605
606 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
607 pim_ifp = ifp->info;
608
609 if (!pim_ifp)
610 continue;
611
9b91bb50 612 if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
a268493f
DW
613 continue;
614
615 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
616 found_ifname = 1;
617 pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
618 pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
619 pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
620
621 gmi_msec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
622 igmp->querier_query_interval,
623 pim_ifp->igmp_query_max_response_time_dsec);
624
625 sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
626
627 oqpi_msec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
628 igmp->querier_query_interval,
629 pim_ifp->igmp_query_max_response_time_dsec);
630
631 lmqt_msec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
632 igmp->querier_robustness_variable);
633
634 ohpi_msec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
635 igmp->querier_query_interval,
636 pim_ifp->igmp_query_max_response_time_dsec) * 100;
637
638 qri_msec = pim_ifp->igmp_query_max_response_time_dsec * 100;
639 mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
640
641 if (uj) {
a268493f 642 json_row = json_object_new_object();
e775c0a4 643 json_object_pim_ifp_add(json_row, ifp);
a268493f
DW
644 json_object_string_add(json_row, "upTime", uptime);
645 json_object_string_add(json_row, "querier", igmp->t_igmp_query_timer ? "local" : "other");
646 json_object_int_add(json_row, "queryStartCount", igmp->startup_query_count);
647 json_object_string_add(json_row, "queryQueryTimer", query_hhmmss);
648 json_object_string_add(json_row, "queryOtherTimer", other_hhmmss);
b05b72e8 649 json_object_int_add(json_row, "version", pim_ifp->igmp_version);
a268493f
DW
650 json_object_int_add(json_row, "timerGroupMembershipIntervalMsec", gmi_msec);
651 json_object_int_add(json_row, "timerLastMemberQueryMsec", lmqt_msec);
652 json_object_int_add(json_row, "timerOlderHostPresentIntervalMsec", ohpi_msec);
653 json_object_int_add(json_row, "timerOtherQuerierPresentIntervalMsec", oqpi_msec);
654 json_object_int_add(json_row, "timerQueryInterval", igmp->querier_query_interval);
655 json_object_int_add(json_row, "timerQueryResponseIntervalMsec", qri_msec);
656 json_object_int_add(json_row, "timerRobustnessVariable", igmp->querier_robustness_variable);
657 json_object_int_add(json_row, "timerStartupQueryInterval", sqi);
658
659 json_object_object_add(json, ifp->name, json_row);
a268493f
DW
660
661 } else {
662 vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
663 vty_out(vty, "State : %s%s", if_is_up(ifp) ? "up" : "down", VTY_NEWLINE);
664 vty_out(vty, "Address : %s%s", inet_ntoa(pim_ifp->primary_address), VTY_NEWLINE);
665 vty_out(vty, "Uptime : %s%s", uptime, VTY_NEWLINE);
b05b72e8 666 vty_out(vty, "Version : %d%s", pim_ifp->igmp_version, VTY_NEWLINE);
a268493f
DW
667 vty_out(vty, "%s", VTY_NEWLINE);
668 vty_out(vty, "%s", VTY_NEWLINE);
669
670 vty_out(vty, "Querier%s", VTY_NEWLINE);
671 vty_out(vty, "-------%s", VTY_NEWLINE);
672 vty_out(vty, "Querier : %s%s", igmp->t_igmp_query_timer ? "local" : "other", VTY_NEWLINE);
673 vty_out(vty, "Start Count : %d%s", igmp->startup_query_count, VTY_NEWLINE);
674 vty_out(vty, "Query Timer : %s%s", query_hhmmss, VTY_NEWLINE);
675 vty_out(vty, "Other Timer : %s%s", other_hhmmss, VTY_NEWLINE);
676 vty_out(vty, "%s", VTY_NEWLINE);
677 vty_out(vty, "%s", VTY_NEWLINE);
678
679 vty_out(vty, "Timers%s", VTY_NEWLINE);
680 vty_out(vty, "------%s", VTY_NEWLINE);
681 vty_out(vty, "Group Membership Interval : %lis%s", gmi_msec/1000, VTY_NEWLINE);
682 vty_out(vty, "Last Member Query Time : %lis%s", lmqt_msec/1000, VTY_NEWLINE);
683 vty_out(vty, "Older Host Present Interval : %lis%s", ohpi_msec/1000, VTY_NEWLINE);
684 vty_out(vty, "Other Querier Present Interval : %lis%s", oqpi_msec/1000, VTY_NEWLINE);
685 vty_out(vty, "Query Interval : %ds%s", igmp->querier_query_interval, VTY_NEWLINE);
686 vty_out(vty, "Query Response Interval : %lis%s", qri_msec/1000, VTY_NEWLINE);
687 vty_out(vty, "Robustness Variable : %d%s", igmp->querier_robustness_variable, VTY_NEWLINE);
688 vty_out(vty, "Startup Query Interval : %ds%s", sqi, VTY_NEWLINE);
689 vty_out(vty, "%s", VTY_NEWLINE);
690 vty_out(vty, "%s", VTY_NEWLINE);
691
692 pim_print_ifp_flags(vty, ifp, mloop);
693 }
12e41d03
DL
694 }
695 }
a268493f 696
9b91bb50 697 if (uj) {
17b52be1 698 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9b91bb50
DW
699 json_object_free(json);
700 } else {
701 if (!found_ifname)
702 vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
703 }
12e41d03
DL
704}
705
706static void igmp_show_interface_join(struct vty *vty)
707{
708 struct listnode *node;
709 struct interface *ifp;
710 time_t now;
711
712 now = pim_time_monotonic_sec();
713
714 vty_out(vty,
715 "Interface Address Source Group Socket Uptime %s",
716 VTY_NEWLINE);
717
469351b3 718 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
719 struct pim_interface *pim_ifp;
720 struct listnode *join_node;
721 struct igmp_join *ij;
722 struct in_addr pri_addr;
eaa54bdb 723 char pri_addr_str[INET_ADDRSTRLEN];
12e41d03
DL
724
725 pim_ifp = ifp->info;
726
727 if (!pim_ifp)
728 continue;
729
730 if (!pim_ifp->igmp_join_list)
731 continue;
732
733 pri_addr = pim_find_primary_addr(ifp);
734 pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
735
736 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, join_node, ij)) {
eaa54bdb
DW
737 char group_str[INET_ADDRSTRLEN];
738 char source_str[INET_ADDRSTRLEN];
12e41d03
DL
739 char uptime[10];
740
741 pim_time_uptime(uptime, sizeof(uptime), now - ij->sock_creation);
742 pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
743 pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
744
745 vty_out(vty, "%-9s %-15s %-15s %-15s %6d %8s%s",
746 ifp->name,
747 pri_addr_str,
748 source_str,
749 group_str,
750 ij->sock_fd,
751 uptime,
752 VTY_NEWLINE);
753 } /* for (pim_ifp->igmp_join_list) */
754
755 } /* for (iflist) */
756
757}
758
a268493f 759static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_char uj)
12e41d03 760{
a268493f 761 struct in_addr ifaddr;
12e41d03 762 struct interface *ifp;
a268493f
DW
763 struct listnode *neighnode;
764 struct listnode*node;
765 struct listnode *upnode;
766 struct pim_interface *pim_ifp;
767 struct pim_neighbor *neigh;
768 struct pim_upstream *up;
769 time_t now;
eaa54bdb 770 char dr_str[INET_ADDRSTRLEN];
a268493f
DW
771 char dr_uptime[10];
772 char expire[10];
eaa54bdb 773 char grp_str[INET_ADDRSTRLEN];
a268493f
DW
774 char hello_period[10];
775 char hello_timer[10];
eaa54bdb
DW
776 char neigh_src_str[INET_ADDRSTRLEN];
777 char src_str[INET_ADDRSTRLEN];
a268493f
DW
778 char stat_uptime[10];
779 char uptime[10];
780 int mloop;
781 int found_ifname = 0;
782 int print_header;
9bf3c633
DW
783 json_object *json = NULL;
784 json_object *json_row = NULL;
a268493f
DW
785 json_object *json_pim_neighbor = NULL;
786 json_object *json_pim_neighbors = NULL;
787 json_object *json_group = NULL;
a268493f 788 json_object *json_group_source = NULL;
e775c0a4 789 json_object *json_fhr_sources = NULL;
7176984f 790 struct pim_secondary_addr *sec_addr;
791 struct listnode *sec_node;
9bf3c633 792
a268493f 793 now = pim_time_monotonic_sec();
12e41d03 794
9b91bb50
DW
795 if (uj)
796 json = json_object_new_object();
797
469351b3 798 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03 799 pim_ifp = ifp->info;
a268493f 800
12e41d03
DL
801 if (!pim_ifp)
802 continue;
803
804 if (pim_ifp->pim_sock_fd < 0)
805 continue;
806
9b91bb50 807 if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
a268493f 808 continue;
12e41d03 809
a268493f
DW
810 found_ifname = 1;
811 ifaddr = pim_ifp->primary_address;
812 pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr, dr_str, sizeof(dr_str));
813 pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime), now, pim_ifp->pim_dr_election_last);
814 pim_time_timer_to_hhmmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
815 pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
816 pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
817 mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
12e41d03 818
9bf3c633
DW
819 if (uj) {
820 json_row = json_object_new_object();
e775c0a4 821 json_object_pim_ifp_add(json_row, ifp);
a268493f 822
4763cd0e 823 if (pim_ifp->update_source.s_addr != INADDR_ANY) {
824 json_object_string_add(json_row, "useSource", inet_ntoa(pim_ifp->update_source));
825 }
7176984f 826 if (pim_ifp->sec_addr_list) {
827 json_object *sec_list = NULL;
828
829 sec_list = json_object_new_array();
830 for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
831 json_object_array_add(sec_list, json_object_new_string(inet_ntoa(sec_addr->addr)));
832 }
833 json_object_object_add(json_row, "secondaryAddressList", sec_list);
834 }
835
a268493f
DW
836 // PIM neighbors
837 if (pim_ifp->pim_neighbor_list->count) {
838 json_pim_neighbors = json_object_new_object();
839
840 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
841 json_pim_neighbor = json_object_new_object();
842 pim_inet4_dump("<src?>", neigh->source_addr, neigh_src_str, sizeof(neigh_src_str));
843 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
844 pim_time_timer_to_hhmmss(expire, sizeof(expire), neigh->t_expire_timer);
845
846 json_object_string_add(json_pim_neighbor, "address", neigh_src_str);
847 json_object_string_add(json_pim_neighbor, "upTime", uptime);
848 json_object_string_add(json_pim_neighbor, "holdtime", expire);
849
850 json_object_object_add(json_pim_neighbors, neigh_src_str, json_pim_neighbor);
851 }
852
853 json_object_object_add(json_row, "neighbors", json_pim_neighbors);
854 }
855
9bf3c633 856 json_object_string_add(json_row, "drAddress", dr_str);
a268493f
DW
857 json_object_int_add(json_row, "drPriority", pim_ifp->pim_dr_priority);
858 json_object_string_add(json_row, "drUptime", dr_uptime);
9bf3c633
DW
859 json_object_int_add(json_row, "drElections", pim_ifp->pim_dr_election_count);
860 json_object_int_add(json_row, "drChanges", pim_ifp->pim_dr_election_changes);
a268493f
DW
861
862 // FHR
0f588989
DS
863 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) {
864 if (ifp == up->rpf.source_nexthop.interface) {
a268493f
DW
865 if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR) {
866 if (!json_fhr_sources) {
867 json_fhr_sources = json_object_new_object();
868 }
869
870 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
871 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
872 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
873
874 /* Does this group live in json_fhr_sources? If not create it. */
9c2df635 875 json_object_object_get_ex(json_fhr_sources, grp_str, &json_group);
a268493f
DW
876
877 if (!json_group) {
878 json_group = json_object_new_object();
879 json_object_object_add(json_fhr_sources, grp_str, json_group);
880 }
881
882 json_group_source = json_object_new_object();
883 json_object_string_add(json_group_source, "source", src_str);
884 json_object_string_add(json_group_source, "group", grp_str);
885 json_object_string_add(json_group_source, "upTime", uptime);
886 json_object_object_add(json_group, src_str, json_group_source);
887 }
888 }
889 }
890
891 if (json_fhr_sources) {
892 json_object_object_add(json_row, "firstHopRouter", json_fhr_sources);
893 }
894
895 json_object_int_add(json_row, "helloPeriod", pim_ifp->pim_hello_period);
896 json_object_string_add(json_row, "helloTimer", hello_timer);
897 json_object_string_add(json_row, "helloStatStart", stat_uptime);
898 json_object_int_add(json_row, "helloReceived", pim_ifp->pim_ifstat_hello_recv);
899 json_object_int_add(json_row, "helloReceivedFailed", pim_ifp->pim_ifstat_hello_recvfail);
900 json_object_int_add(json_row, "helloSend", pim_ifp->pim_ifstat_hello_sent);
901 json_object_int_add(json_row, "hellosendFailed", pim_ifp->pim_ifstat_hello_sendfail);
902 json_object_int_add(json_row, "helloGenerationId", pim_ifp->pim_generation_id);
903 json_object_int_add(json_row, "flagMulticastLoop", mloop);
904
905 json_object_int_add(json_row, "effectivePropagationDelay", pim_if_effective_propagation_delay_msec(ifp));
906 json_object_int_add(json_row, "effectiveOverrideInterval", pim_if_effective_override_interval_msec(ifp));
907 json_object_int_add(json_row, "joinPruneOverrideInterval", pim_if_jp_override_interval_msec(ifp));
908
909 json_object_int_add(json_row, "propagationDelay", pim_ifp->pim_propagation_delay_msec);
910 json_object_int_add(json_row, "propagationDelayHighest", pim_ifp->pim_neighbors_highest_propagation_delay_msec);
911 json_object_int_add(json_row, "overrideInterval", pim_ifp->pim_override_interval_msec);
912 json_object_int_add(json_row, "overrideIntervalHighest", pim_ifp->pim_neighbors_highest_override_interval_msec);
9bf3c633 913 json_object_object_add(json, ifp->name, json_row);
a268493f 914
9bf3c633 915 } else {
4763cd0e 916 vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
917 vty_out(vty, "State : %s%s", if_is_up(ifp) ? "up" : "down", VTY_NEWLINE);
918 if (pim_ifp->update_source.s_addr != INADDR_ANY) {
919 vty_out(vty, "Use Source : %s%s", inet_ntoa(pim_ifp->update_source), VTY_NEWLINE);
920 }
7176984f 921 if (pim_ifp->sec_addr_list) {
4763cd0e 922 vty_out(vty, "Address : %s (primary)%s",
7176984f 923 inet_ntoa(ifaddr), VTY_NEWLINE);
924 for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
4763cd0e 925 vty_out(vty, " %s%s",
7176984f 926 inet_ntoa(sec_addr->addr), VTY_NEWLINE);
927 }
928 } else {
4763cd0e 929 vty_out(vty, "Address : %s%s", inet_ntoa(ifaddr), VTY_NEWLINE);
7176984f 930 }
a268493f 931 vty_out(vty, "%s", VTY_NEWLINE);
9bf3c633 932
a268493f
DW
933 // PIM neighbors
934 print_header = 1;
12e41d03 935
a268493f 936 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
12e41d03 937
a268493f
DW
938 if (print_header) {
939 vty_out(vty, "PIM Neighbors%s", VTY_NEWLINE);
940 vty_out(vty, "-------------%s", VTY_NEWLINE);
941 print_header = 0;
942 }
12e41d03 943
a268493f
DW
944 pim_inet4_dump("<src?>", neigh->source_addr, neigh_src_str, sizeof(neigh_src_str));
945 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
946 pim_time_timer_to_hhmmss(expire, sizeof(expire), neigh->t_expire_timer);
947 vty_out(vty, "%-15s : up for %s, holdtime expires in %s%s", neigh_src_str, uptime, expire, VTY_NEWLINE);
948 }
12e41d03 949
a268493f
DW
950 if (!print_header) {
951 vty_out(vty, "%s", VTY_NEWLINE);
952 vty_out(vty, "%s", VTY_NEWLINE);
953 }
12e41d03 954
a268493f
DW
955 vty_out(vty, "Designated Router%s", VTY_NEWLINE);
956 vty_out(vty, "-----------------%s", VTY_NEWLINE);
957 vty_out(vty, "Address : %s%s", dr_str, VTY_NEWLINE);
958 vty_out(vty, "Priority : %d%s", pim_ifp->pim_dr_priority, VTY_NEWLINE);
959 vty_out(vty, "Uptime : %s%s", dr_uptime, VTY_NEWLINE);
960 vty_out(vty, "Elections : %d%s", pim_ifp->pim_dr_election_count, VTY_NEWLINE);
961 vty_out(vty, "Changes : %d%s", pim_ifp->pim_dr_election_changes, VTY_NEWLINE);
962 vty_out(vty, "%s", VTY_NEWLINE);
963 vty_out(vty, "%s", VTY_NEWLINE);
964
965 // FHR
966 print_header = 1;
0f588989 967 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) {
a268493f
DW
968 if (strcmp(ifp->name, up->rpf.source_nexthop.interface->name) == 0) {
969 if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR) {
970
971 if (print_header) {
972 vty_out(vty, "FHR - First Hop Router%s", VTY_NEWLINE);
973 vty_out(vty, "----------------------%s", VTY_NEWLINE);
974 print_header = 0;
975 }
976
977 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
978 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
979 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
980 vty_out(vty, "%s : %s is a source, uptime is %s%s", grp_str, src_str, uptime, VTY_NEWLINE);
981 }
982 }
983 }
12e41d03 984
a268493f
DW
985 if (!print_header) {
986 vty_out(vty, "%s", VTY_NEWLINE);
987 vty_out(vty, "%s", VTY_NEWLINE);
988 }
12e41d03 989
a268493f
DW
990 vty_out(vty, "Hellos%s", VTY_NEWLINE);
991 vty_out(vty, "------%s", VTY_NEWLINE);
992 vty_out(vty, "Period : %d%s", pim_ifp->pim_hello_period, VTY_NEWLINE);
993 vty_out(vty, "Timer : %s%s", hello_timer, VTY_NEWLINE);
994 vty_out(vty, "StatStart : %s%s", stat_uptime, VTY_NEWLINE);
995 vty_out(vty, "Receive : %d%s", pim_ifp->pim_ifstat_hello_recv, VTY_NEWLINE);
996 vty_out(vty, "Receive Failed : %d%s", pim_ifp->pim_ifstat_hello_recvfail, VTY_NEWLINE);
997 vty_out(vty, "Send : %d%s", pim_ifp->pim_ifstat_hello_sent, VTY_NEWLINE);
998 vty_out(vty, "Send Failed : %d%s", pim_ifp->pim_ifstat_hello_sendfail, VTY_NEWLINE);
999 vty_out(vty, "Generation ID : %08x%s", pim_ifp->pim_generation_id, VTY_NEWLINE);
1000 vty_out(vty, "%s", VTY_NEWLINE);
1001 vty_out(vty, "%s", VTY_NEWLINE);
1002
1003 pim_print_ifp_flags(vty, ifp, mloop);
1004
1005 vty_out(vty, "Join Prune Interval%s", VTY_NEWLINE);
1006 vty_out(vty, "-------------------%s", VTY_NEWLINE);
1007 vty_out(vty, "LAN Delay : %s%s", pim_if_lan_delay_enabled(ifp) ? "yes" : "no", VTY_NEWLINE);
1008 vty_out(vty, "Effective Propagation Delay : %d msec%s", pim_if_effective_propagation_delay_msec(ifp), VTY_NEWLINE);
1009 vty_out(vty, "Effective Override Interval : %d msec%s", pim_if_effective_override_interval_msec(ifp), VTY_NEWLINE);
1010 vty_out(vty, "Join Prune Override Interval : %d msec%s", pim_if_jp_override_interval_msec(ifp), VTY_NEWLINE);
1011 vty_out(vty, "%s", VTY_NEWLINE);
1012 vty_out(vty, "%s", VTY_NEWLINE);
1013
1014 vty_out(vty, "LAN Prune Delay%s", VTY_NEWLINE);
1015 vty_out(vty, "---------------%s", VTY_NEWLINE);
1016 vty_out(vty, "Propagation Delay : %d msec%s", pim_ifp->pim_propagation_delay_msec, VTY_NEWLINE);
1017 vty_out(vty, "Propagation Delay (Highest) : %d msec%s", pim_ifp->pim_neighbors_highest_propagation_delay_msec, VTY_NEWLINE);
1018 vty_out(vty, "Override Interval : %d msec%s", pim_ifp->pim_override_interval_msec, VTY_NEWLINE);
1019 vty_out(vty, "Override Interval (Highest) : %d msec%s", pim_ifp->pim_neighbors_highest_override_interval_msec, VTY_NEWLINE);
1020 vty_out(vty, "%s", VTY_NEWLINE);
1021 vty_out(vty, "%s", VTY_NEWLINE);
9bf3c633
DW
1022 }
1023 }
1024
9b91bb50 1025 if (uj) {
17b52be1 1026 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9b91bb50
DW
1027 json_object_free(json);
1028 } else {
1029 if (!found_ifname)
1030 vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
1031 }
12e41d03
DL
1032}
1033
9bf3c633 1034static void pim_show_interfaces(struct vty *vty, u_char uj)
12e41d03 1035{
12e41d03 1036 struct interface *ifp;
0f588989 1037 struct listnode *node;
a268493f
DW
1038 struct listnode *upnode;
1039 struct pim_interface *pim_ifp;
1040 struct pim_upstream *up;
1041 int fhr = 0;
a268493f 1042 int pim_nbrs = 0;
9bf3c633
DW
1043 json_object *json = NULL;
1044 json_object *json_row = NULL;
7e147823 1045 json_object *json_tmp;
0f588989 1046
7e147823 1047 json = json_object_new_object();
12e41d03 1048
469351b3 1049 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
1050 pim_ifp = ifp->info;
1051
1052 if (!pim_ifp)
1053 continue;
1054
1055 if (pim_ifp->pim_sock_fd < 0)
1056 continue;
1057
a268493f 1058 pim_nbrs = pim_ifp->pim_neighbor_list->count;
a268493f 1059 fhr = 0;
12e41d03 1060
0f588989
DS
1061 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up))
1062 if (ifp == up->rpf.source_nexthop.interface)
a268493f
DW
1063 if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR)
1064 fhr++;
12e41d03 1065
7e147823
DW
1066 json_row = json_object_new_object();
1067 json_object_pim_ifp_add(json_row, ifp);
1068 json_object_int_add(json_row, "pimNeighbors", pim_nbrs);
1069 json_object_int_add(json_row, "firstHopRouter", fhr);
1070 json_object_string_add(json_row, "pimDesignatedRouter", inet_ntoa(pim_ifp->pim_dr_addr));
9bf3c633 1071
7e147823
DW
1072 if (pim_ifp->pim_dr_addr.s_addr == pim_ifp->primary_address.s_addr)
1073 json_object_boolean_true_add(json_row, "pimDesignatedRouterLocal");
1074
1075 json_object_object_add(json, ifp->name, json_row);
9bf3c633
DW
1076 }
1077
1078 if (uj) {
17b52be1 1079 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
7e147823
DW
1080 } else {
1081 vty_out(vty, "Interface State Address PIM Nbrs PIM DR FHR%s", VTY_NEWLINE);
1082
1083 json_object_object_foreach(json, key, val) {
1084 vty_out(vty, "%-9s ", key);
1085
1086 json_object_object_get_ex(val, "state", &json_tmp);
1087 vty_out(vty, "%5s ", json_object_get_string(json_tmp));
1088
1089 json_object_object_get_ex(val, "address", &json_tmp);
1090 vty_out(vty, "%15s ", json_object_get_string(json_tmp));
1091
1092 json_object_object_get_ex(val, "pimNeighbors", &json_tmp);
1093 vty_out(vty, "%8d ", json_object_get_int(json_tmp));
1094
1095 if (json_object_object_get_ex(val, "pimDesignatedRouterLocal", &json_tmp)) {
1096 vty_out(vty, "%15s ", "local");
1097 } else {
1098 json_object_object_get_ex(val, "pimDesignatedRouter", &json_tmp);
1099 vty_out(vty, "%15s ", json_object_get_string(json_tmp));
1100 }
1101
1102 json_object_object_get_ex(val, "firstHopRouter", &json_tmp);
1103 vty_out(vty, "%3d%s", json_object_get_int(json_tmp), VTY_NEWLINE);
1104 }
12e41d03 1105 }
7e147823
DW
1106
1107 json_object_free(json);
12e41d03
DL
1108}
1109
e775c0a4 1110static void pim_show_join(struct vty *vty, u_char uj)
12e41d03 1111{
ea4a71fc
DS
1112 struct pim_interface *pim_ifp;
1113 struct in_addr ifaddr;
1114 struct listnode *ch_node;
1115 struct pim_ifchannel *ch;
12e41d03 1116 time_t now;
e775c0a4
DW
1117 json_object *json = NULL;
1118 json_object *json_iface = NULL;
1119 json_object *json_row = NULL;
5349cf9a 1120 json_object *json_grp = NULL;
12e41d03
DL
1121
1122 now = pim_time_monotonic_sec();
1123
e775c0a4
DW
1124 if (uj)
1125 json = json_object_new_object();
1126 else
1127 vty_out(vty,
1128 "Interface Address Source Group State Uptime Expire Prune%s",
1129 VTY_NEWLINE);
12e41d03 1130
ea4a71fc 1131 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, ch_node, ch)) {
12e41d03 1132
ea4a71fc 1133 pim_ifp = ch->interface->info;
12e41d03
DL
1134
1135 if (!pim_ifp)
1136 continue;
1137
1138 ifaddr = pim_ifp->primary_address;
1139
ea4a71fc
DS
1140 char ch_src_str[INET_ADDRSTRLEN];
1141 char ch_grp_str[INET_ADDRSTRLEN];
1142 char uptime[10];
1143 char expire[10];
1144 char prune[10];
12e41d03 1145
ea4a71fc
DS
1146 pim_inet4_dump("<ch_src?>", ch->sg.src,
1147 ch_src_str, sizeof(ch_src_str));
1148 pim_inet4_dump("<ch_grp?>", ch->sg.grp,
1149 ch_grp_str, sizeof(ch_grp_str));
12e41d03 1150
ea4a71fc
DS
1151 pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation);
1152 pim_time_timer_to_mmss(expire, sizeof(expire),
1153 ch->t_ifjoin_expiry_timer);
1154 pim_time_timer_to_mmss(prune, sizeof(prune),
1155 ch->t_ifjoin_prune_pending_timer);
12e41d03 1156
ea4a71fc
DS
1157 if (uj) {
1158 json_object_object_get_ex(json, ch->interface->name, &json_iface);
e775c0a4 1159
ea4a71fc
DS
1160 if (!json_iface) {
1161 json_iface = json_object_new_object();
1162 json_object_pim_ifp_add(json_iface, ch->interface);
1163 json_object_object_add(json, ch->interface->name, json_iface);
1164 }
e775c0a4 1165
ea4a71fc
DS
1166 json_row = json_object_new_object();
1167 json_object_string_add(json_row, "source", ch_src_str);
1168 json_object_string_add(json_row, "group", ch_grp_str);
1169 json_object_string_add(json_row, "upTime", uptime);
1170 json_object_string_add(json_row, "expire", expire);
1171 json_object_string_add(json_row, "prune", prune);
1172 json_object_string_add(json_row, "channelJoinName", pim_ifchannel_ifjoin_name(ch->ifjoin_state));
637a61fa
DS
1173 if (PIM_IF_FLAG_TEST_S_G_RPT(ch->flags))
1174 json_object_int_add(json_row, "SGRpt", 1);
e775c0a4 1175
5349cf9a
DS
1176 json_object_object_get_ex(json_iface, ch_grp_str, &json_grp);
1177 if (!json_grp)
1178 {
1179 json_grp = json_object_new_object();
1180 json_object_object_add(json_grp, ch_src_str, json_row);
1181 json_object_object_add(json_iface, ch_grp_str, json_grp);
1182 }
1183 else
1184 json_object_object_add(json_grp, ch_src_str, json_row);
ea4a71fc
DS
1185 } else {
1186 vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
1187 ch->interface->name,
1188 inet_ntoa(ifaddr),
1189 ch_src_str,
1190 ch_grp_str,
1191 pim_ifchannel_ifjoin_name(ch->ifjoin_state),
1192 uptime,
1193 expire,
1194 prune,
1195 VTY_NEWLINE);
1196 }
1197 } /* scan interface channels */
12e41d03 1198
e775c0a4 1199 if (uj) {
17b52be1 1200 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
e775c0a4
DW
1201 json_object_free(json);
1202 }
12e41d03
DL
1203}
1204
a268493f 1205static void pim_show_neighbors_single(struct vty *vty, const char *neighbor, u_char uj)
12e41d03
DL
1206{
1207 struct listnode *node;
a268493f 1208 struct listnode *neighnode;
12e41d03 1209 struct interface *ifp;
a268493f
DW
1210 struct pim_interface *pim_ifp;
1211 struct pim_neighbor *neigh;
12e41d03 1212 time_t now;
a268493f
DW
1213 int found_neighbor = 0;
1214 int option_address_list;
1215 int option_dr_priority;
1216 int option_generation_id;
1217 int option_holdtime;
1218 int option_lan_prune_delay;
1219 int option_t_bit;
1220 char uptime[10];
1221 char expire[10];
eaa54bdb 1222 char neigh_src_str[INET_ADDRSTRLEN];
a268493f 1223
9bf3c633 1224 json_object *json = NULL;
a268493f 1225 json_object *json_ifp = NULL;
9bf3c633
DW
1226 json_object *json_row = NULL;
1227
12e41d03
DL
1228 now = pim_time_monotonic_sec();
1229
a268493f 1230 if (uj)
9bf3c633 1231 json = json_object_new_object();
12e41d03 1232
469351b3 1233 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03 1234 pim_ifp = ifp->info;
9bf3c633 1235
12e41d03
DL
1236 if (!pim_ifp)
1237 continue;
1238
1239 if (pim_ifp->pim_sock_fd < 0)
1240 continue;
1241
12e41d03 1242 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
12e41d03
DL
1243 pim_inet4_dump("<src?>", neigh->source_addr,
1244 neigh_src_str, sizeof(neigh_src_str));
a268493f
DW
1245
1246 /*
1247 * The user can specify either the interface name or the PIM neighbor IP.
1248 * If this pim_ifp matches neither then skip.
1249 */
9b91bb50
DW
1250 if (strcmp(neighbor, "detail") &&
1251 strcmp(neighbor, ifp->name) &&
1252 strcmp(neighbor, neigh_src_str))
a268493f
DW
1253 continue;
1254
1255 found_neighbor = 1;
12e41d03 1256 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
a268493f
DW
1257 pim_time_timer_to_hhmmss(expire, sizeof(expire), neigh->t_expire_timer);
1258
1259 option_address_list = 0;
1260 option_dr_priority = 0;
1261 option_generation_id = 0;
1262 option_holdtime = 0;
1263 option_lan_prune_delay = 0;
1264 option_t_bit = 0;
1265
1266 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST))
1267 option_address_list = 1;
1268
1269 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY))
1270 option_dr_priority = 1;
1271
1272 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID))
1273 option_generation_id = 1;
1274
1275 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME))
1276 option_holdtime = 1;
1277
1278 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY))
1279 option_lan_prune_delay = 1;
1280
1281 if (PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION))
1282 option_t_bit = 1;
12e41d03 1283
9bf3c633 1284 if (uj) {
a268493f
DW
1285
1286 /* Does this ifp live in json? If not create it. */
9c2df635 1287 json_object_object_get_ex(json, ifp->name, &json_ifp);
a268493f
DW
1288
1289 if (!json_ifp) {
1290 json_ifp = json_object_new_object();
e775c0a4 1291 json_object_pim_ifp_add(json_ifp, ifp);
a268493f
DW
1292 json_object_object_add(json, ifp->name, json_ifp);
1293 }
1294
9bf3c633
DW
1295 json_row = json_object_new_object();
1296 json_object_string_add(json_row, "interface", ifp->name);
a268493f 1297 json_object_string_add(json_row, "address", neigh_src_str);
9bf3c633 1298 json_object_string_add(json_row, "upTime", uptime);
a268493f 1299 json_object_string_add(json_row, "holdtime", expire);
9bf3c633
DW
1300 json_object_int_add(json_row, "drPriority", neigh->dr_priority);
1301 json_object_int_add(json_row, "generationId", neigh->generation_id);
1302
a268493f
DW
1303 if (option_address_list)
1304 json_object_boolean_true_add(json_row, "helloOptionAddressList");
9bf3c633 1305
a268493f
DW
1306 if (option_dr_priority)
1307 json_object_boolean_true_add(json_row, "helloOptionDrPriority");
9bf3c633 1308
a268493f
DW
1309 if (option_generation_id)
1310 json_object_boolean_true_add(json_row, "helloOptionGenerationId");
9bf3c633 1311
a268493f
DW
1312 if (option_holdtime)
1313 json_object_boolean_true_add(json_row, "helloOptionHoldtime");
9bf3c633 1314
a268493f
DW
1315 if (option_lan_prune_delay)
1316 json_object_boolean_true_add(json_row, "helloOptionLanPruneDelay");
9bf3c633 1317
a268493f
DW
1318 if (option_t_bit)
1319 json_object_boolean_true_add(json_row, "helloOptionTBit");
9bf3c633 1320
a268493f 1321 json_object_object_add(json_ifp, neigh_src_str, json_row);
9bf3c633
DW
1322
1323 } else {
a268493f
DW
1324 vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
1325 vty_out(vty, "Neighbor : %s%s", neigh_src_str, VTY_NEWLINE);
1326 vty_out(vty, " Uptime : %s%s", uptime, VTY_NEWLINE);
1327 vty_out(vty, " Holdtime : %s%s", expire, VTY_NEWLINE);
1328 vty_out(vty, " DR Priority : %d%s", neigh->dr_priority, VTY_NEWLINE);
1329 vty_out(vty, " Generation ID : %08x%s", neigh->generation_id, VTY_NEWLINE);
1330 vty_out(vty, " Override Interval (msec) : %d%s", neigh->override_interval_msec, VTY_NEWLINE);
1331 vty_out(vty, " Propagation Delay (msec) : %d%s", neigh->propagation_delay_msec, VTY_NEWLINE);
1332 vty_out(vty, " Hello Option - Address List : %s%s", option_address_list ? "yes" : "no", VTY_NEWLINE);
1333 vty_out(vty, " Hello Option - DR Priority : %s%s", option_dr_priority ? "yes" : "no", VTY_NEWLINE);
1334 vty_out(vty, " Hello Option - Generation ID : %s%s", option_generation_id? "yes" : "no", VTY_NEWLINE);
1335 vty_out(vty, " Hello Option - Holdtime : %s%s", option_holdtime ? "yes" : "no", VTY_NEWLINE);
1336 vty_out(vty, " Hello Option - LAN Prune Delay : %s%s", option_lan_prune_delay ? "yes" : "no", VTY_NEWLINE);
1337 vty_out(vty, " Hello Option - T-bit : %s%s", option_t_bit ? "yes" : "no", VTY_NEWLINE);
1338 vty_out(vty, "%s", VTY_NEWLINE);
9bf3c633 1339 }
12e41d03 1340 }
9bf3c633 1341 }
12e41d03 1342
9bf3c633 1343 if (uj) {
17b52be1 1344 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9bf3c633 1345 json_object_free(json);
a268493f
DW
1346 } else {
1347 {
1348 if (!found_neighbor)
1349 vty_out (vty, "%% No such interface or neighbor%s", VTY_NEWLINE);
1350 }
12e41d03
DL
1351 }
1352}
1353
31a21c9c
DW
1354static void
1355pim_show_state(struct vty *vty, const char *src_or_group, const char *group, u_char uj)
1356{
1357 struct channel_oil *c_oil;
1358 struct listnode *node;
1359 json_object *json = NULL;
1360 json_object *json_group = NULL;
1361 json_object *json_ifp_in = NULL;
1362 json_object *json_ifp_out = NULL;
1363 json_object *json_source = NULL;
1364 time_t now;
1365 int first_oif;
1366 now = pim_time_monotonic_sec();
1367
1368 if (uj) {
1369 json = json_object_new_object();
1370 } else {
1371 vty_out(vty, "%sSource Group IIF OIL%s", VTY_NEWLINE, VTY_NEWLINE);
1372 }
1373
040d86ad 1374 for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
eaa54bdb
DW
1375 char grp_str[INET_ADDRSTRLEN];
1376 char src_str[INET_ADDRSTRLEN];
31a21c9c
DW
1377 char in_ifname[16];
1378 char out_ifname[16];
1379 int oif_vif_index;
1380 struct interface *ifp_in;
1381 first_oif = 1;
1382
1383 if (!c_oil->installed)
1384 continue;
1385
1386 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, grp_str, sizeof(grp_str));
1387 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, src_str, sizeof(src_str));
1388 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
1389
1390 if (ifp_in)
1391 strcpy(in_ifname, ifp_in->name);
1392 else
1393 strcpy(in_ifname, "<iif?>");
1394
1395 if (src_or_group)
1396 {
1397 if (strcmp(src_or_group, src_str) && strcmp(src_or_group, grp_str))
1398 continue;
1399
1400 if (group && strcmp(group, grp_str))
1401 continue;
1402 }
1403
1404 if (uj) {
1405
1406 /* Find the group, create it if it doesn't exist */
1407 json_object_object_get_ex(json, grp_str, &json_group);
1408
1409 if (!json_group) {
1410 json_group = json_object_new_object();
1411 json_object_object_add(json, grp_str, json_group);
1412 }
1413
1414 /* Find the source nested under the group, create it if it doesn't exist */
1415 json_object_object_get_ex(json_group, src_str, &json_source);
1416
1417 if (!json_source) {
1418 json_source = json_object_new_object();
1419 json_object_object_add(json_group, src_str, json_source);
1420 }
1421
1422 /* Find the inbound interface nested under the source, create it if it doesn't exist */
1423 json_object_object_get_ex(json_source, in_ifname, &json_ifp_in);
1424
1425 if (!json_ifp_in) {
1426 json_ifp_in = json_object_new_object();
1427 json_object_object_add(json_source, in_ifname, json_ifp_in);
1428 }
1429 } else {
1430 vty_out(vty, "%-15s %-15s %-5s ",
1431 src_str,
1432 grp_str,
1433 ifp_in->name);
1434 }
1435
1436 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
1437 struct interface *ifp_out;
1438 char oif_uptime[10];
1439 int ttl;
1440
1441 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
1442 if (ttl < 1)
1443 continue;
1444
1445 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
1446 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
1447
1448 if (ifp_out)
1449 strcpy(out_ifname, ifp_out->name);
1450 else
1451 strcpy(out_ifname, "<oif?>");
1452
1453 if (uj) {
1454 json_ifp_out = json_object_new_object();
1455 json_object_string_add(json_ifp_out, "source", src_str);
1456 json_object_string_add(json_ifp_out, "group", grp_str);
1457 json_object_string_add(json_ifp_out, "inboundInterface", in_ifname);
1458 json_object_string_add(json_ifp_out, "outboundInterface", out_ifname);
1459
1460 json_object_object_add(json_ifp_in, out_ifname, json_ifp_out);
1461 } else {
1462 if (first_oif)
1463 {
1464 first_oif = 0;
1465 vty_out(vty, "%s", out_ifname);
1466 }
1467 else
1468 vty_out(vty, ",%s", out_ifname);
1469 }
1470 }
1471
1472 if (!uj)
1473 vty_out(vty, "%s", VTY_NEWLINE);
1474 }
1475
1476
1477 if (uj) {
72b39b9e 1478 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
31a21c9c
DW
1479 json_object_free(json);
1480 } else {
1481 vty_out(vty, "%s", VTY_NEWLINE);
1482 }
1483}
1484
a268493f 1485static void pim_show_neighbors(struct vty *vty, u_char uj)
12e41d03 1486{
a268493f
DW
1487 struct listnode *node;
1488 struct listnode *neighnode;
12e41d03 1489 struct interface *ifp;
a268493f
DW
1490 struct pim_interface *pim_ifp;
1491 struct pim_neighbor *neigh;
1492 time_t now;
1493 char uptime[10];
1494 char expire[10];
eaa54bdb 1495 char neigh_src_str[INET_ADDRSTRLEN];
a268493f
DW
1496 json_object *json = NULL;
1497 json_object *json_ifp_rows = NULL;
1498 json_object *json_row = NULL;
12e41d03 1499
a268493f 1500 now = pim_time_monotonic_sec();
12e41d03 1501
a268493f
DW
1502 if (uj) {
1503 json = json_object_new_object();
1504 } else {
1505 vty_out(vty, "Interface Neighbor Uptime Holdtime DR Pri%s", VTY_NEWLINE);
1506 }
12e41d03 1507
469351b3 1508 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03 1509 pim_ifp = ifp->info;
a268493f 1510
12e41d03
DL
1511 if (!pim_ifp)
1512 continue;
1513
1514 if (pim_ifp->pim_sock_fd < 0)
1515 continue;
1516
a268493f
DW
1517 if (uj)
1518 json_ifp_rows = json_object_new_object();
12e41d03
DL
1519
1520 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
12e41d03
DL
1521 pim_inet4_dump("<src?>", neigh->source_addr,
1522 neigh_src_str, sizeof(neigh_src_str));
a268493f
DW
1523 pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
1524 pim_time_timer_to_hhmmss(expire, sizeof(expire), neigh->t_expire_timer);
12e41d03 1525
a268493f
DW
1526 if (uj) {
1527 json_row = json_object_new_object();
1528 json_object_string_add(json_row, "interface", ifp->name);
1529 json_object_string_add(json_row, "neighbor", neigh_src_str);
1530 json_object_string_add(json_row, "upTime", uptime);
1531 json_object_string_add(json_row, "holdTime", expire);
1532 json_object_int_add(json_row, "holdTimeMax", neigh->holdtime);
1533 json_object_int_add(json_row, "drPriority", neigh->dr_priority);
1534 json_object_object_add(json_ifp_rows, neigh_src_str, json_row);
1535
1536 } else {
1537 vty_out(vty, "%-9s %15s %8s %8s %6d%s",
1538 ifp->name,
1539 neigh_src_str,
1540 uptime,
1541 expire,
1542 neigh->dr_priority,
1543 VTY_NEWLINE);
1544 }
12e41d03
DL
1545 }
1546
a268493f
DW
1547 if (uj) {
1548 json_object_object_add(json, ifp->name, json_ifp_rows);
1549 json_ifp_rows = NULL;
1550 }
12e41d03 1551 }
12e41d03 1552
a268493f 1553 if (uj) {
17b52be1 1554 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
a268493f 1555 json_object_free(json);
12e41d03
DL
1556 }
1557}
1558
1559static void pim_show_neighbors_secondary(struct vty *vty)
1560{
1561 struct listnode *node;
1562 struct interface *ifp;
1563
1564 vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
1565
469351b3 1566 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
1567 struct pim_interface *pim_ifp;
1568 struct in_addr ifaddr;
1569 struct listnode *neighnode;
1570 struct pim_neighbor *neigh;
1571
1572 pim_ifp = ifp->info;
1573
1574 if (!pim_ifp)
1575 continue;
1576
1577 if (pim_ifp->pim_sock_fd < 0)
1578 continue;
1579
1580 ifaddr = pim_ifp->primary_address;
1581
1582 for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
eaa54bdb 1583 char neigh_src_str[INET_ADDRSTRLEN];
12e41d03
DL
1584 struct listnode *prefix_node;
1585 struct prefix *p;
1586
1587 if (!neigh->prefix_list)
1588 continue;
1589
1590 pim_inet4_dump("<src?>", neigh->source_addr,
1591 neigh_src_str, sizeof(neigh_src_str));
1592
1593 for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
eaa54bdb 1594 char neigh_sec_str[INET_ADDRSTRLEN];
12e41d03
DL
1595
1596 if (p->family != AF_INET)
1597 continue;
1598
1599 pim_inet4_dump("<src?>", p->u.prefix4,
1600 neigh_sec_str, sizeof(neigh_sec_str));
1601
1602 vty_out(vty, "%-9s %-15s %-15s %-15s%s",
1603 ifp->name,
1604 inet_ntoa(ifaddr),
1605 neigh_src_str,
1606 neigh_sec_str,
1607 VTY_NEWLINE);
1608 }
1609 }
1610 }
1611}
1612
9bf3c633 1613static void
e775c0a4 1614json_object_pim_upstream_add (json_object *json, struct pim_upstream *up)
9bf3c633
DW
1615{
1616 if (up->flags & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
e775c0a4 1617 json_object_boolean_true_add(json, "drJoinDesired");
9bf3c633
DW
1618
1619 if (up->flags & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
e775c0a4 1620 json_object_boolean_true_add(json, "drJoinDesiredUpdated");
9bf3c633
DW
1621
1622 if (up->flags & PIM_UPSTREAM_FLAG_MASK_FHR)
e775c0a4 1623 json_object_boolean_true_add(json, "firstHopRouter");
9bf3c633
DW
1624
1625 if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
e775c0a4 1626 json_object_boolean_true_add(json, "sourceIgmp");
9bf3c633
DW
1627
1628 if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
e775c0a4 1629 json_object_boolean_true_add(json, "sourcePim");
9bf3c633
DW
1630
1631 if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
e775c0a4 1632 json_object_boolean_true_add(json, "sourceStream");
7667c556 1633
1634 /* XXX: need to print ths flag in the plain text display as well */
1635 if (up->flags & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
1636 json_object_boolean_true_add(json, "sourceMsdp");
9bf3c633
DW
1637}
1638
1639static void pim_show_upstream(struct vty *vty, u_char uj)
12e41d03
DL
1640{
1641 struct listnode *upnode;
1642 struct pim_upstream *up;
1643 time_t now;
9bf3c633 1644 json_object *json = NULL;
e775c0a4 1645 json_object *json_group = NULL;
9bf3c633 1646 json_object *json_row = NULL;
12e41d03
DL
1647
1648 now = pim_time_monotonic_sec();
1649
9bf3c633
DW
1650 if (uj)
1651 json = json_object_new_object();
1652 else
b3fb2c27 1653 vty_out(vty, "Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt%s", VTY_NEWLINE);
12e41d03 1654
0f588989 1655 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) {
eaa54bdb
DW
1656 char src_str[INET_ADDRSTRLEN];
1657 char grp_str[INET_ADDRSTRLEN];
9bf3c633
DW
1658 char uptime[10];
1659 char join_timer[10];
1660 char rs_timer[10];
1661 char ka_timer[10];
1bf16443 1662 char msdp_reg_timer[10];
12e41d03 1663
9bf3c633
DW
1664 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
1665 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
1666 pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
1667 pim_time_timer_to_hhmmss (join_timer, sizeof(join_timer), up->t_join_timer);
1668 pim_time_timer_to_hhmmss (rs_timer, sizeof (rs_timer), up->t_rs_timer);
1669 pim_time_timer_to_hhmmss (ka_timer, sizeof (ka_timer), up->t_ka_timer);
1bf16443 1670 pim_time_timer_to_hhmmss (msdp_reg_timer, sizeof (msdp_reg_timer), up->t_msdp_reg_timer);
12e41d03 1671
9bf3c633 1672 if (uj) {
e775c0a4 1673 json_object_object_get_ex(json, grp_str, &json_group);
9bf3c633 1674
e775c0a4
DW
1675 if (!json_group) {
1676 json_group = json_object_new_object();
1677 json_object_object_add(json, grp_str, json_group);
9bf3c633
DW
1678 }
1679
9bf3c633 1680 json_row = json_object_new_object();
e775c0a4 1681 json_object_pim_upstream_add(json_row, up);
9bf3c633
DW
1682 json_object_string_add(json_row, "inboundInterface", up->rpf.source_nexthop.interface->name);
1683 json_object_string_add(json_row, "source", src_str);
1684 json_object_string_add(json_row, "group", grp_str);
1685 json_object_string_add(json_row, "state", pim_upstream_state2str (up->join_state));
1686 json_object_string_add(json_row, "upTime", uptime);
1687 json_object_string_add(json_row, "joinTimer", join_timer);
1688 json_object_string_add(json_row, "resetTimer", rs_timer);
1689 json_object_string_add(json_row, "keepaliveTimer", ka_timer);
1bf16443 1690 json_object_string_add(json_row, "msdpRegTimer", msdp_reg_timer);
9bf3c633 1691 json_object_int_add(json_row, "refCount", up->ref_count);
5d84a3bc 1692 json_object_int_add(json_row, "sptBit", up->sptbit);
e775c0a4 1693 json_object_object_add(json_group, src_str, json_row);
9bf3c633 1694 } else {
e775c0a4 1695 vty_out(vty, "%-10s%-15s %-15s %-11s %-8s %-9s %-9s %-9s %6d%s",
9bf3c633
DW
1696 up->rpf.source_nexthop.interface->name,
1697 src_str,
1698 grp_str,
1699 pim_upstream_state2str (up->join_state),
1700 uptime,
1701 join_timer,
1702 rs_timer,
2ecb76d3 1703 ka_timer,
9bf3c633
DW
1704 up->ref_count,
1705 VTY_NEWLINE);
1706 }
1707 }
1708
1709 if (uj) {
17b52be1 1710 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9bf3c633 1711 json_object_free(json);
12e41d03
DL
1712 }
1713}
1714
9bf3c633 1715static void pim_show_join_desired(struct vty *vty, u_char uj)
12e41d03 1716{
12e41d03 1717 struct listnode *chnode;
12e41d03
DL
1718 struct pim_interface *pim_ifp;
1719 struct pim_ifchannel *ch;
eaa54bdb
DW
1720 char src_str[INET_ADDRSTRLEN];
1721 char grp_str[INET_ADDRSTRLEN];
9bf3c633 1722 json_object *json = NULL;
e775c0a4 1723 json_object *json_group = NULL;
9bf3c633
DW
1724 json_object *json_row = NULL;
1725
1726 if (uj)
1727 json = json_object_new_object();
1728 else
1729 vty_out(vty,
1730 "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
1731 VTY_NEWLINE);
12e41d03 1732
ea4a71fc
DS
1733 /* scan per-interface (S,G) state */
1734 for (ALL_LIST_ELEMENTS_RO(pim_ifchannel_list, chnode, ch)) {
1735 /* scan all interfaces */
1736 pim_ifp = ch->interface->info;
12e41d03
DL
1737 if (!pim_ifp)
1738 continue;
1739
ea4a71fc 1740 struct pim_upstream *up = ch->upstream;
12e41d03 1741
ea4a71fc
DS
1742 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
1743 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
12e41d03 1744
ea4a71fc
DS
1745 if (uj) {
1746 json_object_object_get_ex(json, grp_str, &json_group);
9bf3c633 1747
ea4a71fc
DS
1748 if (!json_group) {
1749 json_group = json_object_new_object();
1750 json_object_object_add(json, grp_str, json_group);
1751 }
9bf3c633 1752
ea4a71fc
DS
1753 json_row = json_object_new_object();
1754 json_object_pim_upstream_add(json_row, up);
1755 json_object_string_add(json_row, "interface", ch->interface->name);
1756 json_object_string_add(json_row, "source", src_str);
1757 json_object_string_add(json_row, "group", grp_str);
9bf3c633 1758
ea4a71fc
DS
1759 if (pim_macro_ch_lost_assert(ch))
1760 json_object_boolean_true_add(json_row, "lostAssert");
9bf3c633 1761
ea4a71fc
DS
1762 if (pim_macro_chisin_joins(ch))
1763 json_object_boolean_true_add(json_row, "joins");
9bf3c633 1764
ea4a71fc
DS
1765 if (pim_macro_chisin_pim_include(ch))
1766 json_object_boolean_true_add(json_row, "pimInclude");
9bf3c633 1767
ea4a71fc
DS
1768 if (pim_upstream_evaluate_join_desired(up))
1769 json_object_boolean_true_add(json_row, "evaluateJoinDesired");
9bf3c633 1770
ea4a71fc 1771 json_object_object_add(json_group, src_str, json_row);
9bf3c633 1772
ea4a71fc
DS
1773 } else {
1774 vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
1775 ch->interface->name,
1776 src_str,
1777 grp_str,
1778 pim_macro_ch_lost_assert(ch) ? "yes" : "no",
1779 pim_macro_chisin_joins(ch) ? "yes" : "no",
1780 pim_macro_chisin_pim_include(ch) ? "yes" : "no",
1781 PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
1782 pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
1783 VTY_NEWLINE);
12e41d03
DL
1784 }
1785 }
9bf3c633
DW
1786
1787 if (uj) {
17b52be1 1788 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9bf3c633
DW
1789 json_object_free(json);
1790 }
12e41d03
DL
1791}
1792
9bf3c633 1793static void pim_show_upstream_rpf(struct vty *vty, u_char uj)
12e41d03
DL
1794{
1795 struct listnode *upnode;
1796 struct pim_upstream *up;
9bf3c633 1797 json_object *json = NULL;
e775c0a4 1798 json_object *json_group = NULL;
9bf3c633
DW
1799 json_object *json_row = NULL;
1800
1801 if (uj)
1802 json = json_object_new_object();
1803 else
1804 vty_out(vty,
1805 "Source Group RpfIface RibNextHop RpfAddress %s",
1806 VTY_NEWLINE);
12e41d03 1807
0f588989 1808 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode, up)) {
eaa54bdb
DW
1809 char src_str[INET_ADDRSTRLEN];
1810 char grp_str[INET_ADDRSTRLEN];
1811 char rpf_nexthop_str[PREFIX_STRLEN];
1812 char rpf_addr_str[PREFIX_STRLEN];
12e41d03
DL
1813 struct pim_rpf *rpf;
1814 const char *rpf_ifname;
9bf3c633 1815
12e41d03 1816 rpf = &up->rpf;
9bf3c633 1817
4ed0af70
DS
1818 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
1819 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
63c59d0c
DS
1820 pim_addr_dump("<nexthop?>", &rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
1821 pim_addr_dump("<rpf?>", &rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
9bf3c633 1822
12e41d03 1823 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
9bf3c633
DW
1824
1825 if (uj) {
e775c0a4 1826 json_object_object_get_ex(json, grp_str, &json_group);
9bf3c633 1827
e775c0a4
DW
1828 if (!json_group) {
1829 json_group = json_object_new_object();
1830 json_object_object_add(json, grp_str, json_group);
9bf3c633
DW
1831 }
1832
9bf3c633 1833 json_row = json_object_new_object();
e775c0a4 1834 json_object_pim_upstream_add(json_row, up);
9bf3c633
DW
1835 json_object_string_add(json_row, "source", src_str);
1836 json_object_string_add(json_row, "group", grp_str);
1837 json_object_string_add(json_row, "rpfInterface", rpf_ifname);
1838 json_object_string_add(json_row, "ribNexthop", rpf_nexthop_str);
1839 json_object_string_add(json_row, "rpfAddress", rpf_addr_str);
e775c0a4 1840 json_object_object_add(json_group, src_str, json_row);
9bf3c633
DW
1841 } else {
1842 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
1843 src_str,
1844 grp_str,
1845 rpf_ifname,
1846 rpf_nexthop_str,
1847 rpf_addr_str,
1848 VTY_NEWLINE);
1849 }
1850 }
1851
1852 if (uj) {
17b52be1 1853 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9bf3c633 1854 json_object_free(json);
12e41d03
DL
1855 }
1856}
1857
9bf3c633 1858static void show_rpf_refresh_stats(struct vty *vty, time_t now, json_object *json)
12e41d03
DL
1859{
1860 char refresh_uptime[10];
1861
1862 pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
1863
9bf3c633
DW
1864 if (json) {
1865 json_object_int_add(json, "rpfCacheRefreshDelayMsecs", qpim_rpf_cache_refresh_delay_msec);
1866 json_object_int_add(json, "rpfCacheRefreshTimer", pim_time_timer_remain_msec(qpim_rpf_cache_refresher));
1867 json_object_int_add(json, "rpfCacheRefreshRequests", qpim_rpf_cache_refresh_requests);
1868 json_object_int_add(json, "rpfCacheRefreshEvents", qpim_rpf_cache_refresh_events);
1869 json_object_string_add(json, "rpfCacheRefreshLast", refresh_uptime);
1870 json_object_int_add(json, "nexthopLookups", qpim_nexthop_lookups);
e71bf8f7 1871 json_object_int_add(json, "nexthopLookupsAvoided", nexthop_lookups_avoided);
9bf3c633
DW
1872 } else {
1873 vty_out(vty,
1874 "RPF Cache Refresh Delay: %ld msecs%s"
1875 "RPF Cache Refresh Timer: %ld msecs%s"
1876 "RPF Cache Refresh Requests: %lld%s"
1877 "RPF Cache Refresh Events: %lld%s"
1878 "RPF Cache Refresh Last: %s%s"
e71bf8f7
DS
1879 "Nexthop Lookups: %lld%s"
1880 "Nexthop Lookups Avoided: %lld%s",
9bf3c633
DW
1881 qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
1882 pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
1883 (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
1884 (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
1885 refresh_uptime, VTY_NEWLINE,
e71bf8f7
DS
1886 (long long) qpim_nexthop_lookups, VTY_NEWLINE,
1887 (long long)nexthop_lookups_avoided, VTY_NEWLINE);
9bf3c633 1888 }
12e41d03
DL
1889}
1890
1891static void show_scan_oil_stats(struct vty *vty, time_t now)
1892{
1893 char uptime_scan_oil[10];
1894 char uptime_mroute_add[10];
1895 char uptime_mroute_del[10];
1896
1897 pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last);
1898 pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last);
1899 pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last);
1900
1901 vty_out(vty,
1902 "Scan OIL - Last: %s Events: %lld%s"
1903 "MFC Add - Last: %s Events: %lld%s"
1904 "MFC Del - Last: %s Events: %lld%s",
1905 uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE,
1906 uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE,
1907 uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE);
1908}
1909
9bf3c633 1910static void pim_show_rpf(struct vty *vty, u_char uj)
12e41d03
DL
1911{
1912 struct listnode *up_node;
1913 struct pim_upstream *up;
1914 time_t now = pim_time_monotonic_sec();
9bf3c633 1915 json_object *json = NULL;
e775c0a4 1916 json_object *json_group = NULL;
9bf3c633
DW
1917 json_object *json_row = NULL;
1918
9bf3c633
DW
1919 if (uj) {
1920 json = json_object_new_object();
1921 show_rpf_refresh_stats(vty, now, json);
1922 } else {
1923 show_rpf_refresh_stats(vty, now, json);
1924 vty_out(vty, "%s", VTY_NEWLINE);
1925 vty_out(vty,
1926 "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
1927 VTY_NEWLINE);
1928 }
12e41d03 1929
0f588989 1930 for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, up_node, up)) {
eaa54bdb
DW
1931 char src_str[INET_ADDRSTRLEN];
1932 char grp_str[INET_ADDRSTRLEN];
1933 char rpf_addr_str[PREFIX_STRLEN];
1934 char rib_nexthop_str[PREFIX_STRLEN];
12e41d03
DL
1935 const char *rpf_ifname;
1936 struct pim_rpf *rpf = &up->rpf;
1937
4ed0af70
DS
1938 pim_inet4_dump("<src?>", up->sg.src, src_str, sizeof(src_str));
1939 pim_inet4_dump("<grp?>", up->sg.grp, grp_str, sizeof(grp_str));
63c59d0c
DS
1940 pim_addr_dump("<rpf?>", &rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
1941 pim_addr_dump("<nexthop?>", &rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
12e41d03
DL
1942
1943 rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
1944
9bf3c633 1945 if (uj) {
e775c0a4 1946 json_object_object_get_ex(json, grp_str, &json_group);
9bf3c633 1947
e775c0a4
DW
1948 if (!json_group) {
1949 json_group = json_object_new_object();
1950 json_object_object_add(json, grp_str, json_group);
1951 }
9bf3c633
DW
1952
1953 json_row = json_object_new_object();
1954 json_object_string_add(json_row, "source", src_str);
1955 json_object_string_add(json_row, "group", grp_str);
1956 json_object_string_add(json_row, "rpfInterface", rpf_ifname);
1957 json_object_string_add(json_row, "rpfAddress", rpf_addr_str);
1958 json_object_string_add(json_row, "ribNexthop", rib_nexthop_str);
1959 json_object_int_add(json_row, "routeMetric", rpf->source_nexthop.mrib_route_metric);
1960 json_object_int_add(json_row, "routePreference", rpf->source_nexthop.mrib_metric_preference);
e775c0a4 1961 json_object_object_add(json_group, src_str, json_row);
9bf3c633 1962
9bf3c633
DW
1963 } else {
1964 vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
1965 src_str,
1966 grp_str,
1967 rpf_ifname,
1968 rpf_addr_str,
1969 rib_nexthop_str,
1970 rpf->source_nexthop.mrib_route_metric,
1971 rpf->source_nexthop.mrib_metric_preference,
1972 VTY_NEWLINE);
1973 }
1974 }
1975
1976 if (uj) {
17b52be1 1977 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9bf3c633 1978 json_object_free(json);
12e41d03
DL
1979 }
1980}
1981
9b91bb50 1982static void igmp_show_groups(struct vty *vty, u_char uj)
12e41d03
DL
1983{
1984 struct listnode *ifnode;
1985 struct interface *ifp;
1986 time_t now;
9b91bb50
DW
1987 json_object *json = NULL;
1988 json_object *json_iface = NULL;
1989 json_object *json_row = NULL;
12e41d03
DL
1990
1991 now = pim_time_monotonic_sec();
1992
9b91bb50
DW
1993 if (uj)
1994 json = json_object_new_object();
1995 else
1996 vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
12e41d03
DL
1997
1998 /* scan interfaces */
469351b3 1999 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
2000 struct pim_interface *pim_ifp = ifp->info;
2001 struct listnode *sock_node;
2002 struct igmp_sock *igmp;
2003
2004 if (!pim_ifp)
2005 continue;
2006
2007 /* scan igmp sockets */
2008 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
eaa54bdb 2009 char ifaddr_str[INET_ADDRSTRLEN];
12e41d03
DL
2010 struct listnode *grpnode;
2011 struct igmp_group *grp;
2012
2013 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2014
2015 /* scan igmp groups */
2016 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
eaa54bdb 2017 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2018 char hhmmss[10];
2019 char uptime[10];
2020
2021 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
2022 pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
2023 pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
2024
9b91bb50
DW
2025 if (uj) {
2026 json_object_object_get_ex(json, ifp->name, &json_iface);
12e41d03 2027
9b91bb50
DW
2028 if (!json_iface) {
2029 json_iface = json_object_new_object();
2030 json_object_pim_ifp_add(json_iface, ifp);
2031 json_object_object_add(json, ifp->name, json_iface);
2032 }
2033
2034 json_row = json_object_new_object();
2035 json_object_string_add(json_row, "source", ifaddr_str);
2036 json_object_string_add(json_row, "group", group_str);
b05b72e8
DW
2037
2038 if (grp->igmp_version == 3)
2039 json_object_string_add(json_row, "mode", grp->group_filtermode_isexcl ? "EXCLUDE" : "INCLUDE");
2040
9b91bb50
DW
2041 json_object_string_add(json_row, "timer", hhmmss);
2042 json_object_int_add(json_row, "sourcesCount", grp->group_source_list ? listcount(grp->group_source_list) : 0);
b05b72e8 2043 json_object_int_add(json_row, "version", grp->igmp_version);
9b91bb50
DW
2044 json_object_string_add(json_row, "uptime", uptime);
2045 json_object_object_add(json_iface, group_str, json_row);
2046
2047 } else {
2048 vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
2049 ifp->name,
2050 ifaddr_str,
2051 group_str,
b05b72e8 2052 grp->igmp_version == 3 ? (grp->group_filtermode_isexcl ? "EXCL" : "INCL") : "----",
9b91bb50
DW
2053 hhmmss,
2054 grp->group_source_list ? listcount(grp->group_source_list) : 0,
b05b72e8 2055 grp->igmp_version,
9b91bb50
DW
2056 uptime,
2057 VTY_NEWLINE);
2058 }
12e41d03
DL
2059 } /* scan igmp groups */
2060 } /* scan igmp sockets */
2061 } /* scan interfaces */
9b91bb50
DW
2062
2063 if (uj) {
17b52be1 2064 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
9b91bb50
DW
2065 json_object_free(json);
2066 }
12e41d03
DL
2067}
2068
2069static void igmp_show_group_retransmission(struct vty *vty)
2070{
2071 struct listnode *ifnode;
2072 struct interface *ifp;
2073
2074 vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
2075
2076 /* scan interfaces */
469351b3 2077 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
2078 struct pim_interface *pim_ifp = ifp->info;
2079 struct listnode *sock_node;
2080 struct igmp_sock *igmp;
2081
2082 if (!pim_ifp)
2083 continue;
2084
2085 /* scan igmp sockets */
2086 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
eaa54bdb 2087 char ifaddr_str[INET_ADDRSTRLEN];
12e41d03
DL
2088 struct listnode *grpnode;
2089 struct igmp_group *grp;
2090
2091 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2092
2093 /* scan igmp groups */
2094 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
eaa54bdb 2095 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2096 char grp_retr_mmss[10];
2097 struct listnode *src_node;
2098 struct igmp_source *src;
2099 int grp_retr_sources = 0;
2100
2101 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
2102 pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
2103
2104
2105 /* count group sources with retransmission state */
2106 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
2107 if (src->source_query_retransmit_count > 0) {
2108 ++grp_retr_sources;
2109 }
2110 }
2111
2112 vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
2113 ifp->name,
2114 ifaddr_str,
2115 group_str,
2116 grp_retr_mmss,
2117 grp->group_specific_query_retransmit_count,
2118 grp_retr_sources,
2119 VTY_NEWLINE);
2120
2121 } /* scan igmp groups */
2122 } /* scan igmp sockets */
2123 } /* scan interfaces */
2124}
2125
12e41d03
DL
2126static void igmp_show_sources(struct vty *vty)
2127{
2128 struct listnode *ifnode;
2129 struct interface *ifp;
2130 time_t now;
2131
2132 now = pim_time_monotonic_sec();
2133
2134 vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
2135
2136 /* scan interfaces */
469351b3 2137 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
2138 struct pim_interface *pim_ifp = ifp->info;
2139 struct listnode *sock_node;
2140 struct igmp_sock *igmp;
2141
2142 if (!pim_ifp)
2143 continue;
2144
2145 /* scan igmp sockets */
2146 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
eaa54bdb 2147 char ifaddr_str[INET_ADDRSTRLEN];
12e41d03
DL
2148 struct listnode *grpnode;
2149 struct igmp_group *grp;
2150
2151 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2152
2153 /* scan igmp groups */
2154 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
eaa54bdb 2155 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2156 struct listnode *srcnode;
2157 struct igmp_source *src;
2158
2159 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
2160
2161 /* scan group sources */
2162 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
eaa54bdb 2163 char source_str[INET_ADDRSTRLEN];
12e41d03
DL
2164 char mmss[10];
2165 char uptime[10];
2166
2167 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
2168
2169 pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
2170
2171 pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
2172
2173 vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
2174 ifp->name,
2175 ifaddr_str,
2176 group_str,
2177 source_str,
2178 mmss,
2179 IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
2180 uptime,
2181 VTY_NEWLINE);
2182
2183 } /* scan group sources */
2184 } /* scan igmp groups */
2185 } /* scan igmp sockets */
2186 } /* scan interfaces */
2187}
2188
2189static void igmp_show_source_retransmission(struct vty *vty)
2190{
2191 struct listnode *ifnode;
2192 struct interface *ifp;
2193
2194 vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
2195
2196 /* scan interfaces */
469351b3 2197 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
12e41d03
DL
2198 struct pim_interface *pim_ifp = ifp->info;
2199 struct listnode *sock_node;
2200 struct igmp_sock *igmp;
2201
2202 if (!pim_ifp)
2203 continue;
2204
2205 /* scan igmp sockets */
2206 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
eaa54bdb 2207 char ifaddr_str[INET_ADDRSTRLEN];
12e41d03
DL
2208 struct listnode *grpnode;
2209 struct igmp_group *grp;
2210
2211 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
2212
2213 /* scan igmp groups */
2214 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
eaa54bdb 2215 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2216 struct listnode *srcnode;
2217 struct igmp_source *src;
2218
2219 pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
2220
2221 /* scan group sources */
2222 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
eaa54bdb 2223 char source_str[INET_ADDRSTRLEN];
12e41d03
DL
2224
2225 pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
2226
2227 vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
2228 ifp->name,
2229 ifaddr_str,
2230 group_str,
2231 source_str,
2232 src->source_query_retransmit_count,
2233 VTY_NEWLINE);
2234
2235 } /* scan group sources */
2236 } /* scan igmp groups */
2237 } /* scan igmp sockets */
2238 } /* scan interfaces */
2239}
2240
2241static void clear_igmp_interfaces()
2242{
2243 struct listnode *ifnode;
2244 struct listnode *ifnextnode;
2245 struct interface *ifp;
2246
469351b3 2247 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
2248 pim_if_addr_del_all_igmp(ifp);
2249 }
2250
469351b3 2251 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
2252 pim_if_addr_add_all(ifp);
2253 }
2254}
2255
2256static void clear_pim_interfaces()
2257{
2258 struct listnode *ifnode;
2259 struct listnode *ifnextnode;
2260 struct interface *ifp;
2261
469351b3 2262 for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) {
12e41d03
DL
2263 if (ifp->info) {
2264 pim_neighbor_delete_all(ifp, "interface cleared");
2265 }
2266 }
2267}
2268
2269static void clear_interfaces()
2270{
2271 clear_igmp_interfaces();
2272 clear_pim_interfaces();
2273}
2274
12e41d03
DL
2275DEFUN (clear_ip_interfaces,
2276 clear_ip_interfaces_cmd,
2277 "clear ip interfaces",
2278 CLEAR_STR
2279 IP_STR
2280 "Reset interfaces\n")
2281{
2282 clear_interfaces();
2283
2284 return CMD_SUCCESS;
2285}
2286
2287DEFUN (clear_ip_igmp_interfaces,
2288 clear_ip_igmp_interfaces_cmd,
2289 "clear ip igmp interfaces",
2290 CLEAR_STR
2291 IP_STR
2292 CLEAR_IP_IGMP_STR
2293 "Reset IGMP interfaces\n")
2294{
2295 clear_igmp_interfaces();
2296
2297 return CMD_SUCCESS;
2298}
2299
2300static void mroute_add_all()
2301{
2302 struct listnode *node;
2303 struct channel_oil *c_oil;
2304
040d86ad 2305 for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
6a78764e 2306 if (pim_mroute_add(c_oil, __PRETTY_FUNCTION__)) {
12e41d03 2307 /* just log warning */
eaa54bdb
DW
2308 char source_str[INET_ADDRSTRLEN];
2309 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2310 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2311 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2312 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
2313 __FILE__, __PRETTY_FUNCTION__,
2314 source_str, group_str);
2315 }
2316 }
2317}
2318
2319static void mroute_del_all()
2320{
2321 struct listnode *node;
2322 struct channel_oil *c_oil;
2323
040d86ad 2324 for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
6a78764e 2325 if (pim_mroute_del(c_oil, __PRETTY_FUNCTION__)) {
12e41d03 2326 /* just log warning */
eaa54bdb
DW
2327 char source_str[INET_ADDRSTRLEN];
2328 char group_str[INET_ADDRSTRLEN];
12e41d03
DL
2329 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
2330 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
2331 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
2332 __FILE__, __PRETTY_FUNCTION__,
2333 source_str, group_str);
2334 }
2335 }
2336}
2337
6250610a
JAG
2338static void static_mroute_add_all()
2339{
2340 struct listnode *node;
2341 struct static_route *s_route;
2342
2343 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
6a78764e 2344 if (pim_mroute_add(&s_route->c_oil, __PRETTY_FUNCTION__)) {
6250610a 2345 /* just log warning */
eaa54bdb
DW
2346 char source_str[INET_ADDRSTRLEN];
2347 char group_str[INET_ADDRSTRLEN];
9867746a
DS
2348 pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str));
2349 pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str));
6250610a
JAG
2350 zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
2351 __FILE__, __PRETTY_FUNCTION__,
2352 source_str, group_str);
2353 }
2354 }
2355}
2356
2357static void static_mroute_del_all()
2358{
2359 struct listnode *node;
2360 struct static_route *s_route;
2361
2362 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
6a78764e 2363 if (pim_mroute_del(&s_route->c_oil, __PRETTY_FUNCTION__)) {
6250610a 2364 /* just log warning */
eaa54bdb
DW
2365 char source_str[INET_ADDRSTRLEN];
2366 char group_str[INET_ADDRSTRLEN];
9867746a
DS
2367 pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str));
2368 pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str));
6250610a
JAG
2369 zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
2370 __FILE__, __PRETTY_FUNCTION__,
2371 source_str, group_str);
2372 }
2373 }
2374}
2375
12e41d03
DL
2376DEFUN (clear_ip_mroute,
2377 clear_ip_mroute_cmd,
2378 "clear ip mroute",
2379 CLEAR_STR
2380 IP_STR
2381 "Reset multicast routes\n")
2382{
2383 mroute_del_all();
2384 mroute_add_all();
2385
2386 return CMD_SUCCESS;
2387}
2388
2389DEFUN (clear_ip_pim_interfaces,
2390 clear_ip_pim_interfaces_cmd,
2391 "clear ip pim interfaces",
2392 CLEAR_STR
2393 IP_STR
2394 CLEAR_IP_PIM_STR
2395 "Reset PIM interfaces\n")
2396{
2397 clear_pim_interfaces();
2398
2399 return CMD_SUCCESS;
2400}
2401
2402DEFUN (clear_ip_pim_oil,
2403 clear_ip_pim_oil_cmd,
2404 "clear ip pim oil",
2405 CLEAR_STR
2406 IP_STR
2407 CLEAR_IP_PIM_STR
2408 "Rescan PIM OIL (output interface list)\n")
2409{
2410 pim_scan_oil();
2411
2412 return CMD_SUCCESS;
2413}
2414
2415DEFUN (show_ip_igmp_interface,
2416 show_ip_igmp_interface_cmd,
9b91bb50 2417 "show ip igmp interface [detail|WORD] [json]",
12e41d03
DL
2418 SHOW_STR
2419 IP_STR
2420 IGMP_STR
a268493f 2421 "IGMP interface information\n"
9b91bb50 2422 "Detailed output\n"
a268493f
DW
2423 "interface name\n"
2424 "JavaScript Object Notation\n")
12e41d03 2425{
a268493f
DW
2426 u_char uj = use_json(argc, argv);
2427 if (argv[4]->arg)
2428 igmp_show_interfaces_single(vty, argv[4]->arg, uj);
2429 else
2430 igmp_show_interfaces(vty, uj);
12e41d03
DL
2431
2432 return CMD_SUCCESS;
2433}
2434
2435DEFUN (show_ip_igmp_join,
2436 show_ip_igmp_join_cmd,
2437 "show ip igmp join",
2438 SHOW_STR
2439 IP_STR
2440 IGMP_STR
2441 "IGMP static join information\n")
2442{
2443 igmp_show_interface_join(vty);
2444
2445 return CMD_SUCCESS;
2446}
2447
2448DEFUN (show_ip_igmp_groups,
2449 show_ip_igmp_groups_cmd,
9b91bb50 2450 "show ip igmp groups [json]",
12e41d03
DL
2451 SHOW_STR
2452 IP_STR
2453 IGMP_STR
9b91bb50
DW
2454 IGMP_GROUP_STR
2455 "JavaScript Object Notation\n")
12e41d03 2456{
9b91bb50
DW
2457 u_char uj = use_json(argc, argv);
2458 igmp_show_groups(vty, uj);
12e41d03
DL
2459
2460 return CMD_SUCCESS;
2461}
2462
2463DEFUN (show_ip_igmp_groups_retransmissions,
2464 show_ip_igmp_groups_retransmissions_cmd,
2465 "show ip igmp groups retransmissions",
2466 SHOW_STR
2467 IP_STR
2468 IGMP_STR
2469 IGMP_GROUP_STR
2470 "IGMP group retransmissions\n")
2471{
2472 igmp_show_group_retransmission(vty);
2473
2474 return CMD_SUCCESS;
2475}
2476
12e41d03
DL
2477DEFUN (show_ip_igmp_sources,
2478 show_ip_igmp_sources_cmd,
2479 "show ip igmp sources",
2480 SHOW_STR
2481 IP_STR
2482 IGMP_STR
2483 IGMP_SOURCE_STR)
2484{
2485 igmp_show_sources(vty);
2486
2487 return CMD_SUCCESS;
2488}
2489
2490DEFUN (show_ip_igmp_sources_retransmissions,
2491 show_ip_igmp_sources_retransmissions_cmd,
2492 "show ip igmp sources retransmissions",
2493 SHOW_STR
2494 IP_STR
2495 IGMP_STR
2496 IGMP_SOURCE_STR
2497 "IGMP source retransmissions\n")
2498{
2499 igmp_show_source_retransmission(vty);
2500
2501 return CMD_SUCCESS;
2502}
2503
12e41d03
DL
2504DEFUN (show_ip_pim_assert,
2505 show_ip_pim_assert_cmd,
2506 "show ip pim assert",
2507 SHOW_STR
2508 IP_STR
2509 PIM_STR
2510 "PIM interface assert\n")
2511{
2512 pim_show_assert(vty);
2513
2514 return CMD_SUCCESS;
2515}
2516
2517DEFUN (show_ip_pim_assert_internal,
2518 show_ip_pim_assert_internal_cmd,
2519 "show ip pim assert-internal",
2520 SHOW_STR
2521 IP_STR
2522 PIM_STR
2523 "PIM interface internal assert state\n")
2524{
2525 pim_show_assert_internal(vty);
2526
2527 return CMD_SUCCESS;
2528}
2529
2530DEFUN (show_ip_pim_assert_metric,
2531 show_ip_pim_assert_metric_cmd,
2532 "show ip pim assert-metric",
2533 SHOW_STR
2534 IP_STR
2535 PIM_STR
2536 "PIM interface assert metric\n")
2537{
2538 pim_show_assert_metric(vty);
2539
2540 return CMD_SUCCESS;
2541}
2542
2543DEFUN (show_ip_pim_assert_winner_metric,
2544 show_ip_pim_assert_winner_metric_cmd,
2545 "show ip pim assert-winner-metric",
2546 SHOW_STR
2547 IP_STR
2548 PIM_STR
2549 "PIM interface assert winner metric\n")
2550{
2551 pim_show_assert_winner_metric(vty);
2552
2553 return CMD_SUCCESS;
2554}
2555
2556DEFUN (show_ip_pim_dr,
2557 show_ip_pim_dr_cmd,
9bf3c633 2558 "show ip pim designated-router [json]",
12e41d03
DL
2559 SHOW_STR
2560 IP_STR
2561 PIM_STR
2562 "PIM interface designated router\n")
2563{
9bf3c633
DW
2564 u_char uj = use_json(argc, argv);
2565 pim_show_dr(vty, uj);
12e41d03
DL
2566
2567 return CMD_SUCCESS;
2568}
2569
2570DEFUN (show_ip_pim_hello,
2571 show_ip_pim_hello_cmd,
9bf3c633 2572 "show ip pim hello [json]",
12e41d03
DL
2573 SHOW_STR
2574 IP_STR
2575 PIM_STR
2576 "PIM interface hello information\n")
2577{
9bf3c633
DW
2578 u_char uj = use_json(argc, argv);
2579 pim_show_hello(vty, uj);
12e41d03
DL
2580
2581 return CMD_SUCCESS;
2582}
2583
2584DEFUN (show_ip_pim_interface,
2585 show_ip_pim_interface_cmd,
9b91bb50 2586 "show ip pim interface [detail|WORD] [json]",
12e41d03
DL
2587 SHOW_STR
2588 IP_STR
2589 PIM_STR
a268493f 2590 "PIM interface information\n"
9b91bb50 2591 "Detailed output\n"
a268493f
DW
2592 "interface name\n"
2593 "JavaScript Object Notation\n")
12e41d03 2594{
9bf3c633 2595 u_char uj = use_json(argc, argv);
a268493f
DW
2596 if (argv[4]->arg)
2597 pim_show_interfaces_single(vty, argv[4]->arg, uj);
2598 else
2599 pim_show_interfaces(vty, uj);
12e41d03
DL
2600
2601 return CMD_SUCCESS;
2602}
2603
2604DEFUN (show_ip_pim_join,
2605 show_ip_pim_join_cmd,
e775c0a4 2606 "show ip pim join [json]",
12e41d03
DL
2607 SHOW_STR
2608 IP_STR
2609 PIM_STR
2610 "PIM interface join information\n")
2611{
e775c0a4
DW
2612 u_char uj = use_json(argc, argv);
2613 pim_show_join(vty, uj);
12e41d03
DL
2614
2615 return CMD_SUCCESS;
2616}
2617
12e41d03
DL
2618DEFUN (show_ip_pim_local_membership,
2619 show_ip_pim_local_membership_cmd,
e775c0a4 2620 "show ip pim local-membership [json]",
12e41d03
DL
2621 SHOW_STR
2622 IP_STR
2623 PIM_STR
2624 "PIM interface local-membership\n")
2625{
e775c0a4
DW
2626 u_char uj = use_json(argc, argv);
2627 pim_show_membership(vty, uj);
12e41d03
DL
2628
2629 return CMD_SUCCESS;
2630}
2631
12e41d03
DL
2632DEFUN (show_ip_pim_neighbor,
2633 show_ip_pim_neighbor_cmd,
9b91bb50 2634 "show ip pim neighbor [detail|WORD] [json]",
12e41d03
DL
2635 SHOW_STR
2636 IP_STR
2637 PIM_STR
a268493f 2638 "PIM neighbor information\n"
9b91bb50 2639 "Detailed output\n"
a268493f
DW
2640 "Name of interface or neighbor\n"
2641 "JavaScript Object Notation\n")
12e41d03 2642{
9bf3c633 2643 u_char uj = use_json(argc, argv);
a268493f
DW
2644 if (argv[4]->arg)
2645 pim_show_neighbors_single(vty, argv[4]->arg, uj);
2646 else
2647 pim_show_neighbors(vty, uj);
12e41d03
DL
2648
2649 return CMD_SUCCESS;
2650}
2651
2652DEFUN (show_ip_pim_secondary,
2653 show_ip_pim_secondary_cmd,
2654 "show ip pim secondary",
2655 SHOW_STR
2656 IP_STR
2657 PIM_STR
2658 "PIM neighbor addresses\n")
2659{
2660 pim_show_neighbors_secondary(vty);
2661
2662 return CMD_SUCCESS;
2663}
2664
31a21c9c
DW
2665DEFUN (show_ip_pim_state,
2666 show_ip_pim_state_cmd,
2667 "show ip pim state [A.B.C.D] [A.B.C.D] [json]",
2668 SHOW_STR
2669 IP_STR
2670 PIM_STR
2671 "PIM state information\n"
2672 "Unicast or Multicast address\n"
2673 "Multicast address\n"
2674 "JavaScript Object Notation\n")
2675{
2676 const char *src_or_group = NULL;
2677 const char *group = NULL;
2678 u_char uj = use_json(argc, argv);
2679
2680 src_or_group = argv[4]->arg;
2681 group = argv[5]->arg;
2682
2683 pim_show_state(vty, src_or_group, group, uj);
2684
2685 return CMD_SUCCESS;
2686}
2687
12e41d03
DL
2688DEFUN (show_ip_pim_upstream,
2689 show_ip_pim_upstream_cmd,
9bf3c633 2690 "show ip pim upstream [json]",
12e41d03
DL
2691 SHOW_STR
2692 IP_STR
2693 PIM_STR
a268493f
DW
2694 "PIM upstream information\n"
2695 "JavaScript Object Notation\n")
12e41d03 2696{
9bf3c633
DW
2697 u_char uj = use_json(argc, argv);
2698 pim_show_upstream(vty, uj);
12e41d03
DL
2699
2700 return CMD_SUCCESS;
2701}
2702
2703DEFUN (show_ip_pim_upstream_join_desired,
2704 show_ip_pim_upstream_join_desired_cmd,
9bf3c633 2705 "show ip pim upstream-join-desired [json]",
12e41d03
DL
2706 SHOW_STR
2707 IP_STR
2708 PIM_STR
a268493f
DW
2709 "PIM upstream join-desired\n"
2710 "JavaScript Object Notation\n")
12e41d03 2711{
9bf3c633
DW
2712 u_char uj = use_json(argc, argv);
2713 pim_show_join_desired(vty, uj);
12e41d03
DL
2714
2715 return CMD_SUCCESS;
2716}
2717
2718DEFUN (show_ip_pim_upstream_rpf,
2719 show_ip_pim_upstream_rpf_cmd,
9bf3c633 2720 "show ip pim upstream-rpf [json]",
12e41d03
DL
2721 SHOW_STR
2722 IP_STR
2723 PIM_STR
a268493f
DW
2724 "PIM upstream source rpf\n"
2725 "JavaScript Object Notation\n")
12e41d03 2726{
9bf3c633
DW
2727 u_char uj = use_json(argc, argv);
2728 pim_show_upstream_rpf(vty, uj);
12e41d03
DL
2729
2730 return CMD_SUCCESS;
2731}
2732
00d07c6f
DS
2733DEFUN (show_ip_pim_rp,
2734 show_ip_pim_rp_cmd,
9bf3c633 2735 "show ip pim rp-info [json]",
00d07c6f
DS
2736 SHOW_STR
2737 IP_STR
2738 PIM_STR
a268493f
DW
2739 "PIM RP information\n"
2740 "JavaScript Object Notation\n")
00d07c6f 2741{
9bf3c633
DW
2742 u_char uj = use_json(argc, argv);
2743 pim_rp_show_information (vty, uj);
00d07c6f
DS
2744
2745 return CMD_SUCCESS;
2746}
2747
12e41d03
DL
2748DEFUN (show_ip_pim_rpf,
2749 show_ip_pim_rpf_cmd,
9bf3c633 2750 "show ip pim rpf [json]",
12e41d03
DL
2751 SHOW_STR
2752 IP_STR
2753 PIM_STR
a268493f
DW
2754 "PIM cached source rpf information\n"
2755 "JavaScript Object Notation\n")
12e41d03 2756{
9bf3c633
DW
2757 u_char uj = use_json(argc, argv);
2758 pim_show_rpf(vty, uj);
12e41d03
DL
2759
2760 return CMD_SUCCESS;
2761}
2762
2763static void show_multicast_interfaces(struct vty *vty)
2764{
2765 struct listnode *node;
2766 struct interface *ifp;
2767
2768 vty_out(vty, "%s", VTY_NEWLINE);
2769
2770 vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
2771 VTY_NEWLINE);
2772
469351b3 2773 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
12e41d03
DL
2774 struct pim_interface *pim_ifp;
2775 struct in_addr ifaddr;
2776 struct sioc_vif_req vreq;
2777
2778 pim_ifp = ifp->info;
2779
2780 if (!pim_ifp)
2781 continue;
2782
2783 memset(&vreq, 0, sizeof(vreq));
2784 vreq.vifi = pim_ifp->mroute_vif_index;
2785
2786 if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
6c44fe22
DS
2787 zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s",
2788 (unsigned long)SIOCGETVIFCNT,
2789 ifp->name,
2790 pim_ifp->mroute_vif_index,
2791 errno,
2792 safe_strerror(errno),
2793 VTY_NEWLINE);
12e41d03
DL
2794 }
2795
2796 ifaddr = pim_ifp->primary_address;
2797
2798 vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
2799 ifp->name,
2800 inet_ntoa(ifaddr),
2801 ifp->ifindex,
2802 pim_ifp->mroute_vif_index,
ea8b7c71
RW
2803 (unsigned long) vreq.icount,
2804 (unsigned long) vreq.ocount,
2805 (unsigned long) vreq.ibytes,
2806 (unsigned long) vreq.obytes,
12e41d03
DL
2807 VTY_NEWLINE);
2808 }
2809}
2810
2811DEFUN (show_ip_multicast,
2812 show_ip_multicast_cmd,
2813 "show ip multicast",
2814 SHOW_STR
2815 IP_STR
2816 "Multicast global information\n")
2817{
2818 time_t now = pim_time_monotonic_sec();
2819
2820 if (PIM_MROUTE_IS_ENABLED) {
2821 char uptime[10];
2822
2823 vty_out(vty, "Mroute socket descriptor: %d%s",
2824 qpim_mroute_socket_fd,
2825 VTY_NEWLINE);
2826
2827 pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
2828 vty_out(vty, "Mroute socket uptime: %s%s",
2829 uptime,
2830 VTY_NEWLINE);
2831 }
2832 else {
2833 vty_out(vty, "Multicast disabled%s",
2834 VTY_NEWLINE);
2835 }
2836
2837 vty_out(vty, "%s", VTY_NEWLINE);
2838 vty_out(vty, "Zclient update socket: ");
2839 if (qpim_zclient_update) {
2840 vty_out(vty, "%d failures=%d%s", qpim_zclient_update->sock,
2841 qpim_zclient_update->fail, VTY_NEWLINE);
2842 }
2843 else {
2844 vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
2845 }
05b0d0d0
DS
2846
2847 pim_zlookup_show_ip_multicast (vty);
12e41d03
DL
2848
2849 vty_out(vty, "%s", VTY_NEWLINE);
2850 vty_out(vty, "Current highest VifIndex: %d%s",
2851 qpim_mroute_oif_highest_vif_index,
2852 VTY_NEWLINE);
2853 vty_out(vty, "Maximum highest VifIndex: %d%s",
1865a44a 2854 PIM_MAX_USABLE_VIFS,
12e41d03
DL
2855 VTY_NEWLINE);
2856
2857 vty_out(vty, "%s", VTY_NEWLINE);
2858 vty_out(vty, "Upstream Join Timer: %d secs%s",
2859 qpim_t_periodic,
2860 VTY_NEWLINE);
2861 vty_out(vty, "Join/Prune Holdtime: %d secs%s",
2862 PIM_JP_HOLDTIME,
2863 VTY_NEWLINE);
2864
2865 vty_out(vty, "%s", VTY_NEWLINE);
2866
9bf3c633 2867 show_rpf_refresh_stats(vty, now, NULL);
12e41d03
DL
2868
2869 vty_out(vty, "%s", VTY_NEWLINE);
2870
2871 show_scan_oil_stats(vty, now);
2872
2873 show_multicast_interfaces(vty);
2874
2875 return CMD_SUCCESS;
2876}
2877
b3fb2c27 2878static void show_mroute(struct vty *vty, u_char uj)
12e41d03
DL
2879{
2880 struct listnode *node;
2881 struct channel_oil *c_oil;
6250610a 2882 struct static_route *s_route;
12e41d03 2883 time_t now;
b3fb2c27
DW
2884 json_object *json = NULL;
2885 json_object *json_group = NULL;
2886 json_object *json_source = NULL;
2887 json_object *json_ifp_in = NULL;
2888 json_object *json_ifp_out = NULL;
91c6aec4 2889 int found_oif = 0;
f59a8217 2890 int first = 1;
12e41d03 2891
b3fb2c27
DW
2892 if (uj) {
2893 json = json_object_new_object();
2894 } else {
f59a8217 2895 vty_out(vty, "Source Group Proto Input Output TTL Uptime%s",
b3fb2c27
DW
2896 VTY_NEWLINE);
2897 }
12e41d03
DL
2898
2899 now = pim_time_monotonic_sec();
2900
6250610a 2901 /* print list of PIM and IGMP routes */
040d86ad 2902 for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
eaa54bdb
DW
2903 char grp_str[INET_ADDRSTRLEN];
2904 char src_str[INET_ADDRSTRLEN];
b3fb2c27
DW
2905 char in_ifname[16];
2906 char out_ifname[16];
12e41d03 2907 int oif_vif_index;
f59a8217 2908 char proto[100];
b3fb2c27 2909 struct interface *ifp_in;
91c6aec4 2910 found_oif = 0;
f59a8217 2911 first = 1;
07335c8d 2912 if (!c_oil->installed && !uj)
58302dc7
DS
2913 continue;
2914
b3fb2c27
DW
2915 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, grp_str, sizeof(grp_str));
2916 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, src_str, sizeof(src_str));
2917 ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
2918
2919 if (ifp_in)
2920 strcpy(in_ifname, ifp_in->name);
2921 else
2922 strcpy(in_ifname, "<iif?>");
2923
2924 if (uj) {
2925
2926 /* Find the group, create it if it doesn't exist */
2927 json_object_object_get_ex(json, grp_str, &json_group);
2928
2929 if (!json_group) {
2930 json_group = json_object_new_object();
2931 json_object_object_add(json, grp_str, json_group);
2932 }
2933
2934 /* Find the source nested under the group, create it if it doesn't exist */
2935 json_object_object_get_ex(json_group, src_str, &json_source);
2936
2937 if (!json_source) {
2938 json_source = json_object_new_object();
2939 json_object_object_add(json_group, src_str, json_source);
2940 }
2941
2942 /* Find the inbound interface nested under the source, create it if it doesn't exist */
2943 json_object_object_get_ex(json_source, in_ifname, &json_ifp_in);
07335c8d
DS
2944 json_object_int_add(json_source, "installed", c_oil->installed);
2945 json_object_int_add(json_source, "refCount", c_oil->oil_ref_count);
2946 json_object_int_add(json_source, "oilSize", c_oil->oil_size);
b3fb2c27
DW
2947
2948 if (!json_ifp_in) {
2949 json_ifp_in = json_object_new_object();
2950 json_object_object_add(json_source, in_ifname, json_ifp_in);
2951 }
2952 }
2953
12e41d03 2954 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
12e41d03
DL
2955 struct interface *ifp_out;
2956 char oif_uptime[10];
2957 int ttl;
12e41d03
DL
2958
2959 ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
2960 if (ttl < 1)
2961 continue;
2962
12e41d03 2963 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
12e41d03 2964 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
91c6aec4 2965 found_oif = 1;
12e41d03 2966
b3fb2c27
DW
2967 if (ifp_out)
2968 strcpy(out_ifname, ifp_out->name);
2969 else
2970 strcpy(out_ifname, "<oif?>");
12e41d03 2971
b3fb2c27
DW
2972 if (uj) {
2973 json_ifp_out = json_object_new_object();
2974 json_object_string_add(json_ifp_out, "source", src_str);
2975 json_object_string_add(json_ifp_out, "group", grp_str);
2976
2977 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM)
2978 json_object_boolean_true_add(json_ifp_out, "protocolPim");
2979
2980 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP)
2981 json_object_boolean_true_add(json_ifp_out, "protocolIgmp");
2982
2983 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_SOURCE)
2984 json_object_boolean_true_add(json_ifp_out, "protocolSource");
2985
2986 json_object_string_add(json_ifp_out, "inboundInterface", in_ifname);
2987 json_object_int_add(json_ifp_out, "iVifI", c_oil->oil.mfcc_parent);
2988 json_object_string_add(json_ifp_out, "outboundInterface", out_ifname);
2989 json_object_int_add(json_ifp_out, "oVifI", oif_vif_index);
2990 json_object_int_add(json_ifp_out, "ttl", ttl);
2991 json_object_string_add(json_ifp_out, "upTime", oif_uptime);
2992 json_object_object_add(json_ifp_in, out_ifname, json_ifp_out);
2993 } else {
b3fb2c27 2994 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
f59a8217 2995 strcpy(proto, "PIM");
b3fb2c27
DW
2996 }
2997
2998 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
f59a8217 2999 strcpy(proto, "IGMP");
b3fb2c27
DW
3000 }
3001
3002 if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_SOURCE) {
f59a8217 3003 strcpy(proto, "SRC");
b3fb2c27
DW
3004 }
3005
f59a8217 3006 vty_out(vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s%s",
b3fb2c27
DW
3007 src_str,
3008 grp_str,
3009 proto,
3010 in_ifname,
b3fb2c27 3011 out_ifname,
b3fb2c27
DW
3012 ttl,
3013 oif_uptime,
3014 VTY_NEWLINE);
f59a8217
DS
3015
3016 if (first)
3017 {
3018 src_str[0] = '\0';
3019 grp_str[0] = '\0';
3020 in_ifname[0] = '\0';
3021 first = 0;
3022 }
b3fb2c27 3023 }
12e41d03 3024 }
91c6aec4
DW
3025
3026 if (!uj && !found_oif) {
31a21c9c 3027 vty_out(vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s%s",
91c6aec4
DW
3028 src_str,
3029 grp_str,
31a21c9c 3030 "none",
91c6aec4 3031 in_ifname,
91c6aec4
DW
3032 "none",
3033 0,
91c6aec4
DW
3034 "--:--:--",
3035 VTY_NEWLINE);
3036 }
12e41d03 3037 }
6250610a
JAG
3038
3039 /* Print list of static routes */
3040 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
eaa54bdb
DW
3041 char grp_str[INET_ADDRSTRLEN];
3042 char src_str[INET_ADDRSTRLEN];
b3fb2c27
DW
3043 char in_ifname[16];
3044 char out_ifname[16];
6250610a 3045 int oif_vif_index;
b3fb2c27 3046 struct interface *ifp_in;
f59a8217
DS
3047 char proto[100];
3048 first = 1;
6250610a 3049
58302dc7
DS
3050 if (!s_route->c_oil.installed)
3051 continue;
3052
b3fb2c27
DW
3053 pim_inet4_dump("<group?>", s_route->group, grp_str, sizeof(grp_str));
3054 pim_inet4_dump("<source?>", s_route->source, src_str, sizeof(src_str));
3055 ifp_in = pim_if_find_by_vif_index(s_route->iif);
91c6aec4 3056 found_oif = 0;
b3fb2c27
DW
3057
3058 if (ifp_in)
3059 strcpy(in_ifname, ifp_in->name);
3060 else
3061 strcpy(in_ifname, "<iif?>");
3062
3063 if (uj) {
3064
3065 /* Find the group, create it if it doesn't exist */
3066 json_object_object_get_ex(json, grp_str, &json_group);
3067
3068 if (!json_group) {
3069 json_group = json_object_new_object();
3070 json_object_object_add(json, grp_str, json_group);
3071 }
3072
3073 /* Find the source nested under the group, create it if it doesn't exist */
3074 json_object_object_get_ex(json_group, src_str, &json_source);
3075
3076 if (!json_source) {
3077 json_source = json_object_new_object();
3078 json_object_object_add(json_group, src_str, json_source);
3079 }
3080
3081 /* Find the inbound interface nested under the source, create it if it doesn't exist */
3082 json_object_object_get_ex(json_source, in_ifname, &json_ifp_in);
3083
3084 if (!json_ifp_in) {
3085 json_ifp_in = json_object_new_object();
3086 json_object_object_add(json_source, in_ifname, json_ifp_in);
3087 }
3088
3089 } else {
f59a8217 3090 strcpy(proto, "STATIC");
b3fb2c27 3091 }
6250610a
JAG
3092
3093 for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
6250610a
JAG
3094 struct interface *ifp_out;
3095 char oif_uptime[10];
3096 int ttl;
6250610a
JAG
3097
3098 ttl = s_route->oif_ttls[oif_vif_index];
3099 if (ttl < 1)
3100 continue;
3101
6250610a 3102 ifp_out = pim_if_find_by_vif_index(oif_vif_index);
9867746a 3103 pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - s_route->c_oil.oif_creation[oif_vif_index]);
91c6aec4 3104 found_oif = 1;
6250610a 3105
b3fb2c27
DW
3106 if (ifp_out)
3107 strcpy(out_ifname, ifp_out->name);
3108 else
3109 strcpy(out_ifname, "<oif?>");
6250610a 3110
b3fb2c27
DW
3111 if (uj) {
3112 json_ifp_out = json_object_new_object();
3113 json_object_string_add(json_ifp_out, "source", src_str);
3114 json_object_string_add(json_ifp_out, "group", grp_str);
3115 json_object_boolean_true_add(json_ifp_out, "protocolStatic");
3116 json_object_string_add(json_ifp_out, "inboundInterface", in_ifname);
3117 json_object_int_add(json_ifp_out, "iVifI", c_oil->oil.mfcc_parent);
3118 json_object_string_add(json_ifp_out, "outboundInterface", out_ifname);
3119 json_object_int_add(json_ifp_out, "oVifI", oif_vif_index);
3120 json_object_int_add(json_ifp_out, "ttl", ttl);
3121 json_object_string_add(json_ifp_out, "upTime", oif_uptime);
3122 json_object_object_add(json_ifp_in, out_ifname, json_ifp_out);
3123 } else {
f59a8217 3124 vty_out(vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s%s",
b3fb2c27
DW
3125 src_str,
3126 grp_str,
3127 proto,
3128 in_ifname,
b3fb2c27 3129 out_ifname,
b3fb2c27
DW
3130 ttl,
3131 oif_uptime,
3132 VTY_NEWLINE);
f59a8217
DS
3133 if (first)
3134 {
3135 src_str[0] = '\0';
3136 grp_str[0] = '\0';
3137 in_ifname[0] = '\0';
3138 first = 0;
3139 }
b3fb2c27 3140 }
6250610a 3141 }
91c6aec4
DW
3142
3143 if (!uj && !found_oif) {
f59a8217 3144 vty_out(vty, "%-15s %-15s %-6s %-10s %-10s %-3d %8s%s",
91c6aec4
DW
3145 src_str,
3146 grp_str,
3147 proto,
3148 in_ifname,
91c6aec4
DW
3149 "none",
3150 0,
91c6aec4
DW
3151 "--:--:--",
3152 VTY_NEWLINE);
3153 }
6250610a 3154 }
b3fb2c27
DW
3155
3156 if (uj) {
17b52be1 3157 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
b3fb2c27
DW
3158 json_object_free(json);
3159 }
12e41d03
DL
3160}
3161
3162DEFUN (show_ip_mroute,
3163 show_ip_mroute_cmd,
b3fb2c27 3164 "show ip mroute [json]",
12e41d03
DL
3165 SHOW_STR
3166 IP_STR
3167 MROUTE_STR)
3168{
b3fb2c27
DW
3169 u_char uj = use_json(argc, argv);
3170 show_mroute(vty, uj);
12e41d03
DL
3171 return CMD_SUCCESS;
3172}
3173
3174static void show_mroute_count(struct vty *vty)
3175{
3176 struct listnode *node;
3177 struct channel_oil *c_oil;
6250610a 3178 struct static_route *s_route;
12e41d03
DL
3179
3180 vty_out(vty, "%s", VTY_NEWLINE);
3181
eccf56d2 3182 vty_out(vty, "Source Group LastUsed Packets Bytes WrongIf %s",
12e41d03
DL
3183 VTY_NEWLINE);
3184
6250610a 3185 /* Print PIM and IGMP route counts */
040d86ad 3186 for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
eaa54bdb
DW
3187 char group_str[INET_ADDRSTRLEN];
3188 char source_str[INET_ADDRSTRLEN];
12e41d03 3189
58302dc7
DS
3190 if (!c_oil->installed)
3191 continue;
3192
3667e8a0 3193 pim_mroute_update_counters (c_oil);
12e41d03
DL
3194
3195 pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
3196 pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
3197
eccf56d2 3198 vty_out(vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld%s",
12e41d03
DL
3199 source_str,
3200 group_str,
eccf56d2 3201 c_oil->cc.lastused/100,
3667e8a0
DS
3202 c_oil->cc.pktcnt,
3203 c_oil->cc.bytecnt,
3204 c_oil->cc.wrong_if,
12e41d03 3205 VTY_NEWLINE);
6250610a
JAG
3206 }
3207
3208 /* Print static route counts */
3209 for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
eaa54bdb
DW
3210 char group_str[INET_ADDRSTRLEN];
3211 char source_str[INET_ADDRSTRLEN];
6250610a 3212
58302dc7
DS
3213 if (!s_route->c_oil.installed)
3214 continue;
3215
3667e8a0 3216 pim_mroute_update_counters (&s_route->c_oil);
6250610a 3217
9867746a
DS
3218 pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str));
3219 pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str));
6250610a 3220
eccf56d2 3221 vty_out(vty, "%-15s %-15s %-8llu %-7ld %-10ld %-7ld%s",
6250610a
JAG
3222 source_str,
3223 group_str,
eccf56d2 3224 s_route->c_oil.cc.lastused,
3667e8a0
DS
3225 s_route->c_oil.cc.pktcnt,
3226 s_route->c_oil.cc.bytecnt,
3227 s_route->c_oil.cc.wrong_if,
6250610a 3228 VTY_NEWLINE);
12e41d03
DL
3229 }
3230}
3231
3232DEFUN (show_ip_mroute_count,
3233 show_ip_mroute_count_cmd,
3234 "show ip mroute count",
3235 SHOW_STR
3236 IP_STR
3237 MROUTE_STR
3238 "Route and packet count data\n")
3239{
3240 show_mroute_count(vty);
3241 return CMD_SUCCESS;
3242}
3243
3244DEFUN (show_ip_rib,
3245 show_ip_rib_cmd,
3246 "show ip rib A.B.C.D",
3247 SHOW_STR
3248 IP_STR
3249 RIB_STR
3250 "Unicast address\n")
3251{
b181fa04 3252 int idx_ipv4 = 3;
12e41d03
DL
3253 struct in_addr addr;
3254 const char *addr_str;
3255 struct pim_nexthop nexthop;
eaa54bdb 3256 char nexthop_addr_str[PREFIX_STRLEN];
12e41d03
DL
3257 int result;
3258
580d7612 3259 memset (&nexthop, 0, sizeof (nexthop));
b181fa04 3260 addr_str = argv[idx_ipv4]->arg;
12e41d03
DL
3261 result = inet_pton(AF_INET, addr_str, &addr);
3262 if (result <= 0) {
3263 vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
3264 addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
3265 return CMD_WARNING;
3266 }
3267
63b8f7a3 3268 if (pim_nexthop_lookup(&nexthop, addr, 0)) {
12e41d03
DL
3269 vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
3270 addr_str, VTY_NEWLINE);
3271 return CMD_WARNING;
3272 }
3273
3274 vty_out(vty, "Address NextHop Interface Metric Preference%s",
3275 VTY_NEWLINE);
3276
63c59d0c
DS
3277 pim_addr_dump("<nexthop?>", &nexthop.mrib_nexthop_addr,
3278 nexthop_addr_str, sizeof(nexthop_addr_str));
12e41d03
DL
3279
3280 vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
3281 addr_str,
3282 nexthop_addr_str,
3283 nexthop.interface ? nexthop.interface->name : "<ifname?>",
3284 nexthop.mrib_route_metric,
3285 nexthop.mrib_metric_preference,
3286 VTY_NEWLINE);
3287
3288 return CMD_SUCCESS;
3289}
3290
3291static void show_ssmpingd(struct vty *vty)
3292{
3293 struct listnode *node;
3294 struct ssmpingd_sock *ss;
3295 time_t now;
3296
3297 vty_out(vty, "Source Socket Address Port Uptime Requests%s",
3298 VTY_NEWLINE);
3299
3300 if (!qpim_ssmpingd_list)
3301 return;
3302
3303 now = pim_time_monotonic_sec();
3304
3305 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
eaa54bdb 3306 char source_str[INET_ADDRSTRLEN];
12e41d03
DL
3307 char ss_uptime[10];
3308 struct sockaddr_in bind_addr;
3309 socklen_t len = sizeof(bind_addr);
eaa54bdb 3310 char bind_addr_str[INET_ADDRSTRLEN];
12e41d03
DL
3311
3312 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
3313
3314 if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
3315 vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
3316 source_str, ss->sock_fd, VTY_NEWLINE);
3317 }
3318
3319 pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
3320 pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
3321
3322 vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
3323 source_str,
3324 ss->sock_fd,
3325 bind_addr_str,
3326 ntohs(bind_addr.sin_port),
3327 ss_uptime,
3328 (long long)ss->requests,
3329 VTY_NEWLINE);
3330 }
3331}
3332
3333DEFUN (show_ip_ssmpingd,
3334 show_ip_ssmpingd_cmd,
3335 "show ip ssmpingd",
3336 SHOW_STR
3337 IP_STR
3338 SHOW_SSMPINGD_STR)
3339{
3340 show_ssmpingd(vty);
3341 return CMD_SUCCESS;
3342}
3343
36d6bd7d 3344static int
dfe43e25 3345pim_rp_cmd_worker (struct vty *vty, const char *rp, const char *group, const char *plist)
36d6bd7d
DS
3346{
3347 int result;
36d6bd7d 3348
dfe43e25
DW
3349 result = pim_rp_new (rp, group, plist);
3350
3351 if (result == PIM_MALLOC_FAIL)
3352 {
3353 vty_out (vty, "%% Out of memory%s", VTY_NEWLINE);
3354 return CMD_WARNING;
3355 }
3356
3357 if (result == PIM_GROUP_BAD_ADDRESS)
3358 {
3359 vty_out (vty, "%% Bad group address specified: %s%s", group, VTY_NEWLINE);
3360 return CMD_WARNING;
3361 }
3362
3363 if (result == PIM_RP_BAD_ADDRESS)
36d6bd7d 3364 {
dfe43e25 3365 vty_out (vty, "%% Bad RP address specified: %s%s", rp, VTY_NEWLINE);
36d6bd7d
DS
3366 return CMD_WARNING;
3367 }
3368
dfe43e25 3369 if (result == PIM_RP_NO_PATH)
36d6bd7d 3370 {
dfe43e25
DW
3371 vty_out (vty, "%% No Path to RP address specified: %s%s", rp, VTY_NEWLINE);
3372 return CMD_WARNING;
3373 }
3374
3375 if (result == PIM_GROUP_OVERLAP)
3376 {
3377 vty_out (vty, "%% Group range specified cannot overlap%s", VTY_NEWLINE);
3378 return CMD_WARNING;
3379 }
3380
3381 if (result == PIM_GROUP_PFXLIST_OVERLAP)
3382 {
3383 vty_out (vty, "%% This group is already covered by a RP prefix-list%s", VTY_NEWLINE);
3384 return CMD_WARNING;
36d6bd7d
DS
3385 }
3386
dfe43e25 3387 if (result == PIM_RP_PFXLIST_IN_USE)
36d6bd7d 3388 {
dfe43e25
DW
3389 vty_out (vty, "%% The same prefix-list cannot be applied to multiple RPs%s", VTY_NEWLINE);
3390 return CMD_WARNING;
36d6bd7d
DS
3391 }
3392
3393 return CMD_SUCCESS;
3394}
3395
ee1a0718
DS
3396DEFUN (ip_pim_joinprune_time,
3397 ip_pim_joinprune_time_cmd,
3398 "ip pim join-prune-interval <60-600>",
3399 IP_STR
3400 "pim multicast routing\n"
3401 "Join Prune Send Interval\n"
3402 "Seconds\n")
3403{
3404 qpim_t_periodic = atoi(argv[3]->arg);
3405 return CMD_SUCCESS;
3406}
3407
3408DEFUN (no_ip_pim_joinprune_time,
3409 no_ip_pim_joinprune_time_cmd,
3410 "no ip pim join-prune-interval <60-600>",
3411 NO_STR
3412 IP_STR
3413 "pim multicast routing\n"
3414 "Join Prune Send Interval\n"
3415 "Seconds\n")
3416{
3417 qpim_t_periodic = PIM_DEFAULT_T_PERIODIC;
3418 return CMD_SUCCESS;
3419}
3420
191f5695
DS
3421DEFUN (ip_pim_register_suppress,
3422 ip_pim_register_suppress_cmd,
3423 "ip pim register-suppress-time <5-60000>",
4304f95c
DS
3424 IP_STR
3425 "pim multicast routing\n"
191f5695
DS
3426 "Register Suppress Timer\n"
3427 "Seconds\n")
4304f95c
DS
3428{
3429 qpim_keep_alive_time = atoi (argv[3]->arg);
3430 return CMD_SUCCESS;
3431}
3432
191f5695
DS
3433DEFUN (no_ip_pim_register_suppress,
3434 no_ip_pim_register_suppress_cmd,
3435 "no ip pim register-suppress-time <5-60000>",
4304f95c
DS
3436 NO_STR
3437 IP_STR
3438 "pim multicast routing\n"
191f5695 3439 "Register Suppress Timer\n"
01408ede 3440 "Seconds\n")
4304f95c 3441{
191f5695 3442 qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
4304f95c
DS
3443 return CMD_SUCCESS;
3444}
3445
191f5695
DS
3446DEFUN (ip_pim_keep_alive,
3447 ip_pim_keep_alive_cmd,
3448 "ip pim keep-alive-timer <31-60000>",
01408ede
DS
3449 IP_STR
3450 "pim multicast routing\n"
01408ede
DS
3451 "Keep alive Timer\n"
3452 "Seconds\n")
3453{
3454 qpim_rp_keep_alive_time = atoi (argv[4]->arg);
3455 return CMD_SUCCESS;
3456}
3457
191f5695
DS
3458DEFUN (no_ip_pim_keep_alive,
3459 no_ip_pim_keep_alive_cmd,
3460 "no ip pim keep-alive-timer <31-60000>",
01408ede
DS
3461 NO_STR
3462 IP_STR
3463 "pim multicast routing\n"
01408ede
DS
3464 "Keep alive Timer\n"
3465 "Seconds\n")
3466{
191f5695 3467 qpim_keep_alive_time = PIM_KEEPALIVE_PERIOD;
01408ede
DS
3468 return CMD_SUCCESS;
3469}
3470
8e4c9ef3
DS
3471DEFUN (ip_pim_packets,
3472 ip_pim_packets_cmd,
3473 "ip pim packets <1-100>",
3474 IP_STR
3475 "pim multicast routing\n"
3476 "Number of packets to process at one time per fd\n")
3477{
3478 qpim_packet_process = atoi (argv[3]->arg);
3479 return CMD_SUCCESS;
3480}
3481
3482DEFUN (no_ip_pim_packets,
3483 no_ip_pim_packets_cmd,
3484 "no ip pim packets <1-100>",
3485 NO_STR
3486 IP_STR
3487 "pim multicast routing\n"
3488 "Number of packets to process at one time per fd\n")
3489{
3490 qpim_packet_process = PIM_DEFAULT_PACKET_PROCESS;
3491 return CMD_SUCCESS;
3492}
3493
981d6c7a
DS
3494DEFUN (ip_pim_rp,
3495 ip_pim_rp_cmd,
75a26779 3496 "ip pim rp A.B.C.D [A.B.C.D/M]",
981d6c7a 3497 IP_STR
9b34069d
QY
3498 "pim multicast routing\n"
3499 "Rendevous Point\n"
3500 "ip address of RP\n")
981d6c7a 3501{
b181fa04 3502 int idx_ipv4 = 3;
dfe43e25
DW
3503 return pim_rp_cmd_worker (vty, argv[idx_ipv4]->arg, argv[idx_ipv4 + 1]->arg, NULL);
3504}
3505
3506DEFUN (ip_pim_rp_prefix_list,
3507 ip_pim_rp_prefix_list_cmd,
3508 "ip pim rp A.B.C.D prefix-list WORD",
3509 IP_STR
3510 "pim multicast routing\n"
3511 "Rendevous Point\n"
3512 "ip address of RP\n"
3513 "group prefix-list filter\n"
3514 "Name of a prefix-list\n")
3515{
3516 return pim_rp_cmd_worker (vty, argv[3]->arg, NULL, argv[5]->arg);
36d6bd7d 3517}
981d6c7a 3518
36d6bd7d 3519static int
dfe43e25
DW
3520pim_no_rp_cmd_worker (struct vty *vty, const char *rp, const char *group,
3521 const char *plist)
36d6bd7d 3522{
dfe43e25
DW
3523 int result = pim_rp_del (rp, group, plist);
3524
3525 if (result == PIM_GROUP_BAD_ADDRESS)
3526 {
3527 vty_out (vty, "%% Bad group address specified: %s%s", group, VTY_NEWLINE);
3528 return CMD_WARNING;
3529 }
75a26779 3530
dfe43e25 3531 if (result == PIM_RP_BAD_ADDRESS)
75a26779 3532 {
dfe43e25 3533 vty_out (vty, "%% Bad RP address specified: %s%s", rp, VTY_NEWLINE);
36d6bd7d 3534 return CMD_WARNING;
75a26779 3535 }
981d6c7a 3536
dfe43e25 3537 if (result == PIM_RP_NOT_FOUND)
13afbd05 3538 {
dfe43e25 3539 vty_out (vty, "%% Unable to find specified RP%s", VTY_NEWLINE);
13afbd05
DS
3540 return CMD_WARNING;
3541 }
c8ae3ce8 3542
981d6c7a
DS
3543 return CMD_SUCCESS;
3544}
3545
3546DEFUN (no_ip_pim_rp,
3547 no_ip_pim_rp_cmd,
75a26779 3548 "no ip pim rp A.B.C.D [A.B.C.D/M]",
981d6c7a
DS
3549 NO_STR
3550 IP_STR
9b34069d
QY
3551 "pim multicast routing\n"
3552 "Rendevous Point\n"
3553 "ip address of RP\n")
981d6c7a 3554{
75a26779 3555 int idx_ipv4 = 4;
dfe43e25
DW
3556 return pim_no_rp_cmd_worker (vty, argv[idx_ipv4]->arg, argv[idx_ipv4 + 1]->arg, NULL);
3557}
3558
3559DEFUN (no_ip_pim_rp_prefix_list,
3560 no_ip_pim_rp_prefix_list_cmd,
3561 "no ip pim rp A.B.C.D prefix-list WORD",
3562 NO_STR
3563 IP_STR
3564 "pim multicast routing\n"
3565 "Rendevous Point\n"
3566 "ip address of RP\n"
3567 "group prefix-list filter\n"
3568 "Name of a prefix-list\n")
3569{
3570 return pim_no_rp_cmd_worker (vty, argv[4]->arg, NULL, argv[6]->arg);
981d6c7a
DS
3571}
3572
12e41d03
DL
3573DEFUN (ip_multicast_routing,
3574 ip_multicast_routing_cmd,
9ccf14f7 3575 "ip multicast-routing",
12e41d03
DL
3576 IP_STR
3577 "Enable IP multicast forwarding\n")
3578{
3579 pim_mroute_socket_enable();
3580 pim_if_add_vif_all();
3581 mroute_add_all();
6250610a 3582 static_mroute_add_all();
12e41d03
DL
3583 return CMD_SUCCESS;
3584}
3585
3586DEFUN (no_ip_multicast_routing,
3587 no_ip_multicast_routing_cmd,
9ccf14f7 3588 "no ip multicast-routing",
12e41d03
DL
3589 NO_STR
3590 IP_STR
3591 "Global IP configuration subcommands\n"
3592 "Enable IP multicast forwarding\n")
3593{
3594 mroute_del_all();
6250610a 3595 static_mroute_del_all();
12e41d03
DL
3596 pim_if_del_vif_all();
3597 pim_mroute_socket_disable();
3598 return CMD_SUCCESS;
3599}
3600
3601DEFUN (ip_ssmpingd,
3602 ip_ssmpingd_cmd,
3603 "ip ssmpingd [A.B.C.D]",
3604 IP_STR
3605 CONF_SSMPINGD_STR
3606 "Source address\n")
3607{
b181fa04 3608 int idx_ipv4 = 2;
12e41d03
DL
3609 int result;
3610 struct in_addr source_addr;
abddf075 3611 const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0";
12e41d03
DL
3612
3613 result = inet_pton(AF_INET, source_str, &source_addr);
3614 if (result <= 0) {
3615 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
3616 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
3617 return CMD_WARNING;
3618 }
3619
3620 result = pim_ssmpingd_start(source_addr);
3621 if (result) {
3622 vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
3623 source_str, result, VTY_NEWLINE);
3624 return CMD_WARNING;
3625 }
3626
3627 return CMD_SUCCESS;
3628}
3629
3630DEFUN (no_ip_ssmpingd,
3631 no_ip_ssmpingd_cmd,
3632 "no ip ssmpingd [A.B.C.D]",
3633 NO_STR
3634 IP_STR
3635 CONF_SSMPINGD_STR
3636 "Source address\n")
3637{
b181fa04 3638 int idx_ipv4 = 3;
12e41d03
DL
3639 int result;
3640 struct in_addr source_addr;
abddf075 3641 const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0";
12e41d03
DL
3642
3643 result = inet_pton(AF_INET, source_str, &source_addr);
3644 if (result <= 0) {
3645 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
3646 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
3647 return CMD_WARNING;
3648 }
3649
3650 result = pim_ssmpingd_stop(source_addr);
3651 if (result) {
3652 vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
3653 source_str, result, VTY_NEWLINE);
3654 return CMD_WARNING;
3655 }
3656
3657 return CMD_SUCCESS;
3658}
3659
3660DEFUN (interface_ip_igmp,
3661 interface_ip_igmp_cmd,
3662 "ip igmp",
3663 IP_STR
3664 IFACE_IGMP_STR)
3665{
cdc2d765 3666 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
3667 struct pim_interface *pim_ifp;
3668
12e41d03
DL
3669 pim_ifp = ifp->info;
3670
3671 if (!pim_ifp) {
3672 pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
3673 if (!pim_ifp) {
3674 vty_out(vty, "Could not enable IGMP on interface %s%s",
3675 ifp->name, VTY_NEWLINE);
3676 return CMD_WARNING;
3677 }
3678 }
3679 else {
3680 PIM_IF_DO_IGMP(pim_ifp->options);
3681 }
3682
3683 pim_if_addr_add_all(ifp);
3684 pim_if_membership_refresh(ifp);
3685
3686 return CMD_SUCCESS;
3687}
3688
3689DEFUN (interface_no_ip_igmp,
3690 interface_no_ip_igmp_cmd,
3691 "no ip igmp",
3692 NO_STR
3693 IP_STR
3694 IFACE_IGMP_STR)
3695{
cdc2d765 3696 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
3697 struct pim_interface *pim_ifp;
3698
12e41d03
DL
3699 pim_ifp = ifp->info;
3700 if (!pim_ifp)
3701 return CMD_SUCCESS;
3702
3703 PIM_IF_DONT_IGMP(pim_ifp->options);
3704
3705 pim_if_membership_clear(ifp);
3706
3707 pim_if_addr_del_all_igmp(ifp);
3708
3709 if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
3710 pim_if_delete(ifp);
3711 }
3712
3713 return CMD_SUCCESS;
3714}
3715
3716DEFUN (interface_ip_igmp_join,
3717 interface_ip_igmp_join_cmd,
3718 "ip igmp join A.B.C.D A.B.C.D",
3719 IP_STR
3720 IFACE_IGMP_STR
3721 "IGMP join multicast group\n"
3722 "Multicast group address\n"
3723 "Source address\n")
3724{
cdc2d765 3725 VTY_DECLVAR_CONTEXT(interface, ifp);
b181fa04
DW
3726 int idx_ipv4 = 3;
3727 int idx_ipv4_2 = 4;
12e41d03
DL
3728 const char *group_str;
3729 const char *source_str;
3730 struct in_addr group_addr;
3731 struct in_addr source_addr;
3732 int result;
3733
12e41d03 3734 /* Group address */
b181fa04 3735 group_str = argv[idx_ipv4]->arg;
12e41d03
DL
3736 result = inet_pton(AF_INET, group_str, &group_addr);
3737 if (result <= 0) {
3738 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3739 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
3740 return CMD_WARNING;
3741 }
3742
3743 /* Source address */
b181fa04 3744 source_str = argv[idx_ipv4_2]->arg;
12e41d03
DL
3745 result = inet_pton(AF_INET, source_str, &source_addr);
3746 if (result <= 0) {
3747 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3748 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
3749 return CMD_WARNING;
3750 }
3751
3752 result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
3753 if (result) {
3754 vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
3755 group_str, source_str, ifp->name, result, VTY_NEWLINE);
3756 return CMD_WARNING;
3757 }
3758
3759 return CMD_SUCCESS;
3760}
3761
3762DEFUN (interface_no_ip_igmp_join,
3763 interface_no_ip_igmp_join_cmd,
3764 "no ip igmp join A.B.C.D A.B.C.D",
3765 NO_STR
3766 IP_STR
3767 IFACE_IGMP_STR
3768 "IGMP join multicast group\n"
3769 "Multicast group address\n"
3770 "Source address\n")
3771{
cdc2d765 3772 VTY_DECLVAR_CONTEXT(interface, ifp);
b181fa04
DW
3773 int idx_ipv4 = 4;
3774 int idx_ipv4_2 = 5;
12e41d03
DL
3775 const char *group_str;
3776 const char *source_str;
3777 struct in_addr group_addr;
3778 struct in_addr source_addr;
3779 int result;
3780
12e41d03 3781 /* Group address */
b181fa04 3782 group_str = argv[idx_ipv4]->arg;
12e41d03
DL
3783 result = inet_pton(AF_INET, group_str, &group_addr);
3784 if (result <= 0) {
3785 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
3786 group_str, errno, safe_strerror(errno), VTY_NEWLINE);
3787 return CMD_WARNING;
3788 }
3789
3790 /* Source address */
b181fa04 3791 source_str = argv[idx_ipv4_2]->arg;
12e41d03
DL
3792 result = inet_pton(AF_INET, source_str, &source_addr);
3793 if (result <= 0) {
3794 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
3795 source_str, errno, safe_strerror(errno), VTY_NEWLINE);
3796 return CMD_WARNING;
3797 }
3798
3799 result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
3800 if (result) {
3801 vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
3802 group_str, source_str, ifp->name, result, VTY_NEWLINE);
3803 return CMD_WARNING;
3804 }
3805
3806 return CMD_SUCCESS;
3807}
3808
3809/*
3810 CLI reconfiguration affects the interface level (struct pim_interface).
3811 This function propagates the reconfiguration to every active socket
3812 for that interface.
3813 */
3814static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
3815{
3816 struct interface *ifp;
3817 struct pim_interface *pim_ifp;
3818
3819 zassert(igmp);
3820
3821 /* other querier present? */
3822
3823 if (igmp->t_other_querier_timer)
3824 return;
3825
3826 /* this is the querier */
3827
3828 zassert(igmp->interface);
3829 zassert(igmp->interface->info);
3830
3831 ifp = igmp->interface;
3832 pim_ifp = ifp->info;
3833
3834 if (PIM_DEBUG_IGMP_TRACE) {
eaa54bdb 3835 char ifaddr_str[INET_ADDRSTRLEN];
12e41d03
DL
3836 pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
3837 zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
3838 __PRETTY_FUNCTION__,
3839 ifaddr_str,
3840 ifp->name,
3841 pim_ifp->igmp_default_query_interval);
3842 }
3843
3844 /*
3845 igmp_startup_mode_on() will reset QQI:
3846
3847 igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
3848 */
3849 igmp_startup_mode_on(igmp);
3850}
3851
3852static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
3853{
3854 if (igmp->t_igmp_query_timer) {
3855 /* other querier present */
3856 zassert(igmp->t_igmp_query_timer);
3857 zassert(!igmp->t_other_querier_timer);
3858
3859 pim_igmp_general_query_off(igmp);
3860 pim_igmp_general_query_on(igmp);
3861
3862 zassert(igmp->t_igmp_query_timer);
3863 zassert(!igmp->t_other_querier_timer);
3864 }
3865 else {
3866 /* this is the querier */
3867
3868 zassert(!igmp->t_igmp_query_timer);
3869 zassert(igmp->t_other_querier_timer);
3870
3871 pim_igmp_other_querier_timer_off(igmp);
3872 pim_igmp_other_querier_timer_on(igmp);
3873
3874 zassert(!igmp->t_igmp_query_timer);
3875 zassert(igmp->t_other_querier_timer);
3876 }
3877}
3878
3879static void change_query_interval(struct pim_interface *pim_ifp,
3880 int query_interval)
3881{
3882 struct listnode *sock_node;
3883 struct igmp_sock *igmp;
3884
3885 pim_ifp->igmp_default_query_interval = query_interval;
3886
3887 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
3888 igmp_sock_query_interval_reconfig(igmp);
3889 igmp_sock_query_reschedule(igmp);
3890 }
3891}
3892
3893static void change_query_max_response_time(struct pim_interface *pim_ifp,
3894 int query_max_response_time_dsec)
3895{
3896 struct listnode *sock_node;
3897 struct igmp_sock *igmp;
3898
3899 pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
3900
3901 /*
3902 Below we modify socket/group/source timers in order to quickly
3903 reflect the change. Otherwise, those timers would eventually catch
3904 up.
3905 */
3906
3907 /* scan all sockets */
3908 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
3909 struct listnode *grp_node;
3910 struct igmp_group *grp;
3911
3912 /* reschedule socket general query */
3913 igmp_sock_query_reschedule(igmp);
3914
3915 /* scan socket groups */
3916 for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
3917 struct listnode *src_node;
3918 struct igmp_source *src;
3919
3920 /* reset group timers for groups in EXCLUDE mode */
3921 if (grp->group_filtermode_isexcl) {
3922 igmp_group_reset_gmi(grp);
3923 }
3924
3925 /* scan group sources */
3926 for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
3927
3928 /* reset source timers for sources with running timers */
3929 if (src->t_source_timer) {
3930 igmp_source_reset_gmi(igmp, grp, src);
3931 }
3932 }
3933 }
3934 }
3935}
3936
3937#define IGMP_QUERY_INTERVAL_MIN (1)
3938#define IGMP_QUERY_INTERVAL_MAX (1800)
3939
3940DEFUN (interface_ip_igmp_query_interval,
3941 interface_ip_igmp_query_interval_cmd,
9ccf14f7 3942 "ip igmp query-interval (1-1800)",
12e41d03
DL
3943 IP_STR
3944 IFACE_IGMP_STR
3945 IFACE_IGMP_QUERY_INTERVAL_STR
3946 "Query interval in seconds\n")
3947{
cdc2d765 3948 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
3949 struct pim_interface *pim_ifp;
3950 int query_interval;
3951 int query_interval_dsec;
3952
12e41d03
DL
3953 pim_ifp = ifp->info;
3954
3955 if (!pim_ifp) {
3956 vty_out(vty,
3957 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
3958 ifp->name,
3959 VTY_NEWLINE);
3960 return CMD_WARNING;
3961 }
3962
91ac1d43 3963 query_interval = atoi(argv[4]->arg);
12e41d03
DL
3964 query_interval_dsec = 10 * query_interval;
3965
3966 /*
3967 It seems we don't need to check bounds since command.c does it
3968 already, but we verify them anyway for extra safety.
3969 */
3970 if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
3971 vty_out(vty, "General query interval %d lower than minimum %d%s",
3972 query_interval,
3973 IGMP_QUERY_INTERVAL_MIN,
3974 VTY_NEWLINE);
3975 return CMD_WARNING;
3976 }
3977 if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
3978 vty_out(vty, "General query interval %d higher than maximum %d%s",
3979 query_interval,
3980 IGMP_QUERY_INTERVAL_MAX,
3981 VTY_NEWLINE);
3982 return CMD_WARNING;
3983 }
3984
3985 if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
3986 vty_out(vty,
3987 "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
3988 query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
3989 VTY_NEWLINE);
3990 return CMD_WARNING;
3991 }
3992
3993 change_query_interval(pim_ifp, query_interval);
3994
3995 return CMD_SUCCESS;
3996}
3997
3998DEFUN (interface_no_ip_igmp_query_interval,
3999 interface_no_ip_igmp_query_interval_cmd,
9ccf14f7 4000 "no ip igmp query-interval",
12e41d03
DL
4001 NO_STR
4002 IP_STR
4003 IFACE_IGMP_STR
4004 IFACE_IGMP_QUERY_INTERVAL_STR)
4005{
cdc2d765 4006 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
4007 struct pim_interface *pim_ifp;
4008 int default_query_interval_dsec;
4009
12e41d03
DL
4010 pim_ifp = ifp->info;
4011
4012 if (!pim_ifp)
4013 return CMD_SUCCESS;
4014
4015 default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
4016
4017 if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
4018 vty_out(vty,
4019 "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
4020 default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
4021 VTY_NEWLINE);
4022 return CMD_WARNING;
4023 }
4024
4025 change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
4026
4027 return CMD_SUCCESS;
4028}
4029
b05b72e8
DW
4030DEFUN (interface_ip_igmp_version,
4031 interface_ip_igmp_version_cmd,
4032 "ip igmp version <2-3>",
4033 IP_STR
4034 IFACE_IGMP_STR
4035 "IGMP version\n"
4036 "IGMP version number\n")
4037{
4038 VTY_DECLVAR_CONTEXT(interface,ifp);
4039 struct pim_interface *pim_ifp;
4040 int igmp_version;
4041
4042 pim_ifp = ifp->info;
4043
4044 if (!pim_ifp) {
4045 vty_out(vty,
4046 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
4047 ifp->name,
4048 VTY_NEWLINE);
4049 return CMD_WARNING;
4050 }
4051
4052 igmp_version = atoi(argv[3]->arg);
4053 pim_ifp->igmp_version = igmp_version;
4054
4055 return CMD_SUCCESS;
4056}
4057
4058DEFUN (interface_no_ip_igmp_version,
4059 interface_no_ip_igmp_version_cmd,
4060 "no ip igmp version <2-3>",
4061 NO_STR
4062 IP_STR
4063 IFACE_IGMP_STR
4064 "IGMP version\n"
4065 "IGMP version number\n")
4066{
4067 VTY_DECLVAR_CONTEXT(interface, ifp);
4068 struct pim_interface *pim_ifp;
4069
4070 pim_ifp = ifp->info;
4071
4072 if (!pim_ifp)
4073 return CMD_SUCCESS;
4074
4075 pim_ifp->igmp_version = IGMP_DEFAULT_VERSION;
4076
4077 return CMD_SUCCESS;
4078}
4079
58344b65
DS
4080#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
4081#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
12e41d03
DL
4082
4083DEFUN (interface_ip_igmp_query_max_response_time,
4084 interface_ip_igmp_query_max_response_time_cmd,
58344b65 4085 "ip igmp query-max-response-time (10-250)",
12e41d03
DL
4086 IP_STR
4087 IFACE_IGMP_STR
4088 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
58344b65 4089 "Query response value in deci-seconds\n")
12e41d03 4090{
cdc2d765 4091 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
4092 struct pim_interface *pim_ifp;
4093 int query_max_response_time;
4094
12e41d03
DL
4095 pim_ifp = ifp->info;
4096
4097 if (!pim_ifp) {
4098 vty_out(vty,
4099 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
4100 ifp->name,
4101 VTY_NEWLINE);
4102 return CMD_WARNING;
4103 }
4104
91ac1d43 4105 query_max_response_time = atoi(argv[4]->arg);
12e41d03 4106
58344b65 4107 if (query_max_response_time >= pim_ifp->igmp_default_query_interval * 10) {
12e41d03
DL
4108 vty_out(vty,
4109 "Can't set query max response time %d sec >= general query interval %d sec%s",
4110 query_max_response_time, pim_ifp->igmp_default_query_interval,
4111 VTY_NEWLINE);
4112 return CMD_WARNING;
4113 }
4114
58344b65 4115 change_query_max_response_time(pim_ifp, query_max_response_time);
12e41d03
DL
4116
4117 return CMD_SUCCESS;
4118}
4119
4120DEFUN (interface_no_ip_igmp_query_max_response_time,
4121 interface_no_ip_igmp_query_max_response_time_cmd,
f041117e 4122 "no ip igmp query-max-response-time <10-250>",
12e41d03
DL
4123 NO_STR
4124 IP_STR
4125 IFACE_IGMP_STR
4126 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
4127{
cdc2d765 4128 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03 4129 struct pim_interface *pim_ifp;
12e41d03 4130
12e41d03
DL
4131 pim_ifp = ifp->info;
4132
4133 if (!pim_ifp)
4134 return CMD_SUCCESS;
4135
12e41d03
DL
4136 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
4137
4138 return CMD_SUCCESS;
4139}
4140
4141#define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
4142#define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
4143
58344b65
DS
4144DEFUN_HIDDEN (interface_ip_igmp_query_max_response_time_dsec,
4145 interface_ip_igmp_query_max_response_time_dsec_cmd,
4146 "ip igmp query-max-response-time-dsec (10-250)",
4147 IP_STR
4148 IFACE_IGMP_STR
4149 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
4150 "Query response value in deciseconds\n")
12e41d03 4151{
cdc2d765 4152 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03
DL
4153 struct pim_interface *pim_ifp;
4154 int query_max_response_time_dsec;
4155 int default_query_interval_dsec;
4156
12e41d03
DL
4157 pim_ifp = ifp->info;
4158
4159 if (!pim_ifp) {
4160 vty_out(vty,
4161 "IGMP not enabled on interface %s. Please enable IGMP first.%s",
4162 ifp->name,
4163 VTY_NEWLINE);
4164 return CMD_WARNING;
4165 }
4166
91ac1d43 4167 query_max_response_time_dsec = atoi(argv[4]->arg);
12e41d03 4168
12e41d03
DL
4169 default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
4170
4171 if (query_max_response_time_dsec >= default_query_interval_dsec) {
4172 vty_out(vty,
4173 "Can't set query max response time %d dsec >= general query interval %d dsec%s",
4174 query_max_response_time_dsec, default_query_interval_dsec,
4175 VTY_NEWLINE);
4176 return CMD_WARNING;
4177 }
4178
4179 change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
4180
4181 return CMD_SUCCESS;
4182}
4183
58344b65
DS
4184DEFUN_HIDDEN (interface_no_ip_igmp_query_max_response_time_dsec,
4185 interface_no_ip_igmp_query_max_response_time_dsec_cmd,
4186 "no ip igmp query-max-response-time-dsec",
4187 NO_STR
4188 IP_STR
4189 IFACE_IGMP_STR
4190 IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
12e41d03 4191{
cdc2d765 4192 VTY_DECLVAR_CONTEXT(interface, ifp);
12e41d03 4193 struct pim_interface *pim_ifp;
12e41d03 4194
12e41d03
DL
4195 pim_ifp = ifp->info;
4196
4197 if (!pim_ifp)
4198 return CMD_SUCCESS;
4199
12e41d03
DL
4200 change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
4201
4202 return CMD_SUCCESS;
4203}
4204
dedccda6
DS
4205DEFUN (interface_ip_pim_drprio,
4206 interface_ip_pim_drprio_cmd,
b181fa04 4207 "ip pim drpriority (1-4294967295)",
dedccda6
DS
4208 IP_STR
4209 PIM_STR
4210 "Set the Designated Router Election Priority\n"
4211 "Value of the new DR Priority\n")
4212{
cdc2d765 4213 VTY_DECLVAR_CONTEXT(interface, ifp);
b181fa04 4214 int idx_number = 3;
dedccda6
DS
4215 struct pim_interface *pim_ifp;
4216 uint32_t old_dr_prio;
4217
dedccda6
DS
4218 pim_ifp = ifp->info;
4219
4220 if (!pim_ifp) {
4221 vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE);
4222 return CMD_WARNING;
4223 }
4224
4225 old_dr_prio = pim_ifp->pim_dr_priority;
4226
b181fa04 4227 pim_ifp->pim_dr_priority = strtol(argv[idx_number]->arg, NULL, 10);
dedccda6
DS
4228
4229 if (old_dr_prio != pim_ifp->pim_dr_priority) {
4230 if (pim_if_dr_election(ifp))
4231 pim_hello_restart_now(ifp);
4232 }
4233
4234 return CMD_SUCCESS;
4235}
4236
4237DEFUN (interface_no_ip_pim_drprio,
4238 interface_no_ip_pim_drprio_cmd,
b181fa04 4239 "no ip pim drpriority [(1-4294967295)]",
d7fa34c1 4240 NO_STR
dedccda6
DS
4241 IP_STR
4242 PIM_STR
4243 "Revert the Designated Router Priority to default\n"
4244 "Old Value of the Priority\n")
4245{
cdc2d765 4246 VTY_DECLVAR_CONTEXT(interface, ifp);
dedccda6
DS
4247 struct pim_interface *pim_ifp;
4248
dedccda6
DS
4249 pim_ifp = ifp->info;
4250
4251 if (!pim_ifp) {
7960fa8f 4252 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
dedccda6
DS
4253 return CMD_WARNING;
4254 }
4255
4256 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
4257 pim_ifp->pim_dr_priority = PIM_DEFAULT_DR_PRIORITY;
4258 if (pim_if_dr_election(ifp))
4259 pim_hello_restart_now(ifp);
4260 }
4261
4262 return CMD_SUCCESS;
4263}
4264
981d6c7a
DS
4265static int
4266pim_cmd_interface_add (struct interface *ifp, enum pim_interface_type itype)
12e41d03 4267{
981d6c7a 4268 struct pim_interface *pim_ifp = ifp->info;
12e41d03
DL
4269
4270 if (!pim_ifp) {
4271 pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
4272 if (!pim_ifp) {
981d6c7a 4273 return 0;
12e41d03
DL
4274 }
4275 }
4276 else {
4277 PIM_IF_DO_PIM(pim_ifp->options);
4278 }
4279
981d6c7a 4280 pim_ifp->itype = itype;
12e41d03
DL
4281 pim_if_addr_add_all(ifp);
4282 pim_if_membership_refresh(ifp);
981d6c7a
DS
4283 return 1;
4284}
4285
4286
4287DEFUN (interface_ip_pim_ssm,
4288 interface_ip_pim_ssm_cmd,
4289 "ip pim ssm",
4290 IP_STR
4291 PIM_STR
4292 IFACE_PIM_STR)
4293{
cdc2d765 4294 VTY_DECLVAR_CONTEXT(interface, ifp);
981d6c7a
DS
4295
4296 if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SSM)) {
4297 vty_out(vty, "Could not enable PIM SSM on interface%s", VTY_NEWLINE);
4298 return CMD_WARNING;
4299 }
4300
12e41d03
DL
4301 return CMD_SUCCESS;
4302}
4303
981d6c7a
DS
4304DEFUN (interface_ip_pim_sm,
4305 interface_ip_pim_sm_cmd,
4306 "ip pim sm",
12e41d03
DL
4307 IP_STR
4308 PIM_STR
8371bd60 4309 IFACE_PIM_SM_STR)
12e41d03 4310{
cdc2d765 4311 VTY_DECLVAR_CONTEXT(interface, ifp);
981d6c7a
DS
4312 if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SM)) {
4313 vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE);
4314 return CMD_WARNING;
4315 }
4316
c992c9a0
DS
4317 pim_if_create_pimreg();
4318
981d6c7a
DS
4319 return CMD_SUCCESS;
4320}
4321
4322static int
4323pim_cmd_interface_delete (struct interface *ifp)
4324{
4325 struct pim_interface *pim_ifp = ifp->info;
4326
12e41d03 4327 if (!pim_ifp)
981d6c7a 4328 return 1;
12e41d03
DL
4329
4330 PIM_IF_DONT_PIM(pim_ifp->options);
4331
4332 pim_if_membership_clear(ifp);
4333
12e41d03
DL
4334 /*
4335 pim_sock_delete() removes all neighbors from
4336 pim_ifp->pim_neighbor_list.
4337 */
4338 pim_sock_delete(ifp, "pim unconfigured on interface");
4339
4340 if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
c83778f7 4341 pim_if_addr_del_all(ifp);
12e41d03
DL
4342 pim_if_delete(ifp);
4343 }
4344
981d6c7a
DS
4345 return 1;
4346}
4347
4348DEFUN (interface_no_ip_pim_ssm,
4349 interface_no_ip_pim_ssm_cmd,
4350 "no ip pim ssm",
4351 NO_STR
4352 IP_STR
4353 PIM_STR
4354 IFACE_PIM_STR)
4355{
cdc2d765 4356 VTY_DECLVAR_CONTEXT(interface, ifp);
981d6c7a
DS
4357 if (!pim_cmd_interface_delete(ifp)) {
4358 vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
4359 return CMD_WARNING;
4360 }
4361
4362 return CMD_SUCCESS;
4363}
4364
4365DEFUN (interface_no_ip_pim_sm,
4366 interface_no_ip_pim_sm_cmd,
4367 "no ip pim sm",
4368 NO_STR
4369 IP_STR
4370 PIM_STR
8371bd60 4371 IFACE_PIM_SM_STR)
981d6c7a 4372{
cdc2d765 4373 VTY_DECLVAR_CONTEXT(interface, ifp);
981d6c7a
DS
4374 if (!pim_cmd_interface_delete(ifp)) {
4375 vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE);
4376 return CMD_WARNING;
4377 }
4378
12e41d03
DL
4379 return CMD_SUCCESS;
4380}
4381
6250610a
JAG
4382DEFUN (interface_ip_mroute,
4383 interface_ip_mroute_cmd,
4384 "ip mroute INTERFACE A.B.C.D",
4385 IP_STR
4386 "Add multicast route\n"
4387 "Outgoing interface name\n"
4388 "Group address\n")
4389{
cdc2d765 4390 VTY_DECLVAR_CONTEXT(interface, iif);
b181fa04
DW
4391 int idx_interface = 2;
4392 int idx_ipv4 = 3;
6250610a
JAG
4393 struct interface *oif;
4394 const char *oifname;
4395 const char *grp_str;
4396 struct in_addr grp_addr;
4397 struct in_addr src_addr;
4398 int result;
4399
b181fa04 4400 oifname = argv[idx_interface]->arg;
6250610a
JAG
4401 oif = if_lookup_by_name(oifname);
4402 if (!oif) {
4403 vty_out(vty, "No such interface name %s%s",
4404 oifname, VTY_NEWLINE);
4405 return CMD_WARNING;
4406 }
4407
b181fa04 4408 grp_str = argv[idx_ipv4]->arg;
6250610a
JAG
4409 result = inet_pton(AF_INET, grp_str, &grp_addr);
4410 if (result <= 0) {
4411 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4412 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
4413 return CMD_WARNING;
4414 }
4415
4416 src_addr.s_addr = INADDR_ANY;
4417
4418 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
4419 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
4420 return CMD_WARNING;
4421 }
4422
4423 return CMD_SUCCESS;
4424}
4425
4426DEFUN (interface_ip_mroute_source,
4427 interface_ip_mroute_source_cmd,
4428 "ip mroute INTERFACE A.B.C.D A.B.C.D",
4429 IP_STR
4430 "Add multicast route\n"
4431 "Outgoing interface name\n"
4432 "Group address\n"
4433 "Source address\n")
4434{
cdc2d765 4435 VTY_DECLVAR_CONTEXT(interface, iif);
b181fa04
DW
4436 int idx_interface = 2;
4437 int idx_ipv4 = 3;
4438 int idx_ipv4_2 = 4;
6250610a
JAG
4439 struct interface *oif;
4440 const char *oifname;
4441 const char *grp_str;
4442 struct in_addr grp_addr;
4443 const char *src_str;
4444 struct in_addr src_addr;
4445 int result;
4446
b181fa04 4447 oifname = argv[idx_interface]->arg;
6250610a
JAG
4448 oif = if_lookup_by_name(oifname);
4449 if (!oif) {
4450 vty_out(vty, "No such interface name %s%s",
4451 oifname, VTY_NEWLINE);
4452 return CMD_WARNING;
4453 }
4454
b181fa04 4455 grp_str = argv[idx_ipv4]->arg;
6250610a
JAG
4456 result = inet_pton(AF_INET, grp_str, &grp_addr);
4457 if (result <= 0) {
4458 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4459 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
4460 return CMD_WARNING;
4461 }
4462
b181fa04 4463 src_str = argv[idx_ipv4_2]->arg;
6250610a
JAG
4464 result = inet_pton(AF_INET, src_str, &src_addr);
4465 if (result <= 0) {
4466 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4467 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
4468 return CMD_WARNING;
4469 }
4470
4471 if (pim_static_add(iif, oif, grp_addr, src_addr)) {
4472 vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
4473 return CMD_WARNING;
4474 }
4475
4476 return CMD_SUCCESS;
4477}
4478
4479DEFUN (interface_no_ip_mroute,
4480 interface_no_ip_mroute_cmd,
4481 "no ip mroute INTERFACE A.B.C.D",
4482 NO_STR
4483 IP_STR
4484 "Add multicast route\n"
4485 "Outgoing interface name\n"
4486 "Group Address\n")
4487{
cdc2d765 4488 VTY_DECLVAR_CONTEXT(interface, iif);
b181fa04
DW
4489 int idx_interface = 3;
4490 int idx_ipv4 = 4;
6250610a
JAG
4491 struct interface *oif;
4492 const char *oifname;
4493 const char *grp_str;
4494 struct in_addr grp_addr;
4495 struct in_addr src_addr;
4496 int result;
4497
b181fa04 4498 oifname = argv[idx_interface]->arg;
6250610a
JAG
4499 oif = if_lookup_by_name(oifname);
4500 if (!oif) {
4501 vty_out(vty, "No such interface name %s%s",
4502 oifname, VTY_NEWLINE);
4503 return CMD_WARNING;
4504 }
4505
b181fa04 4506 grp_str = argv[idx_ipv4]->arg;
6250610a
JAG
4507 result = inet_pton(AF_INET, grp_str, &grp_addr);
4508 if (result <= 0) {
4509 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4510 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
4511 return CMD_WARNING;
4512 }
4513
4514 src_addr.s_addr = INADDR_ANY;
4515
4516 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
4517 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
4518 return CMD_WARNING;
4519 }
4520
4521 return CMD_SUCCESS;
4522}
4523
4524DEFUN (interface_no_ip_mroute_source,
4525 interface_no_ip_mroute_source_cmd,
4526 "no ip mroute INTERFACE A.B.C.D A.B.C.D",
4527 NO_STR
4528 IP_STR
4529 "Add multicast route\n"
4530 "Outgoing interface name\n"
4531 "Group Address\n"
4532 "Source Address\n")
4533{
cdc2d765 4534 VTY_DECLVAR_CONTEXT(interface, iif);
b181fa04
DW
4535 int idx_interface = 3;
4536 int idx_ipv4 = 4;
4537 int idx_ipv4_2 = 5;
6250610a
JAG
4538 struct interface *oif;
4539 const char *oifname;
4540 const char *grp_str;
4541 struct in_addr grp_addr;
4542 const char *src_str;
4543 struct in_addr src_addr;
4544 int result;
4545
b181fa04 4546 oifname = argv[idx_interface]->arg;
6250610a
JAG
4547 oif = if_lookup_by_name(oifname);
4548 if (!oif) {
4549 vty_out(vty, "No such interface name %s%s",
4550 oifname, VTY_NEWLINE);
4551 return CMD_WARNING;
4552 }
4553
b181fa04 4554 grp_str = argv[idx_ipv4]->arg;
6250610a
JAG
4555 result = inet_pton(AF_INET, grp_str, &grp_addr);
4556 if (result <= 0) {
4557 vty_out(vty, "Bad group address %s: errno=%d: %s%s",
4558 grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
4559 return CMD_WARNING;
4560 }
4561
b181fa04 4562 src_str = argv[idx_ipv4_2]->arg;
6250610a
JAG
4563 result = inet_pton(AF_INET, src_str, &src_addr);
4564 if (result <= 0) {
4565 vty_out(vty, "Bad source address %s: errno=%d: %s%s",
4566 src_str, errno, safe_strerror(errno), VTY_NEWLINE);
4567 return CMD_WARNING;
4568 }
4569
4570 if (pim_static_del(iif, oif, grp_addr, src_addr)) {
4571 vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
4572 return CMD_WARNING;
4573 }
4574
4575 return CMD_SUCCESS;
4576}
4577
7960fa8f
DS
4578DEFUN (interface_ip_pim_hello,
4579 interface_ip_pim_hello_cmd,
80d3d26b 4580 "ip pim hello (1-180) [(1-180)]",
7960fa8f
DS
4581 IP_STR
4582 PIM_STR
4583 IFACE_PIM_HELLO_STR
80d3d26b
DW
4584 IFACE_PIM_HELLO_TIME_STR
4585 IFACE_PIM_HELLO_HOLD_STR)
7960fa8f 4586{
cdc2d765 4587 VTY_DECLVAR_CONTEXT(interface, ifp);
80d3d26b
DW
4588 int idx_time = 3;
4589 int idx_hold = 4;
7960fa8f
DS
4590 struct pim_interface *pim_ifp;
4591
7960fa8f
DS
4592 pim_ifp = ifp->info;
4593
4594 if (!pim_ifp) {
4595 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
4596 return CMD_WARNING;
4597 }
4598
80d3d26b 4599 pim_ifp->pim_hello_period = strtol(argv[idx_time]->arg, NULL, 10);
7960fa8f 4600
80d3d26b
DW
4601 if (argc > idx_hold)
4602 pim_ifp->pim_default_holdtime = strtol(argv[idx_hold]->arg, NULL, 10);
7960fa8f
DS
4603
4604 return CMD_SUCCESS;
4605}
4606
7960fa8f
DS
4607
4608
4609DEFUN (interface_no_ip_pim_hello,
4610 interface_no_ip_pim_hello_cmd,
b181fa04 4611 "no ip pim hello [(1-180) (1-180)]",
7960fa8f
DS
4612 NO_STR
4613 IP_STR
4614 PIM_STR
4615 IFACE_PIM_HELLO_STR
4616 IFACE_PIM_HELLO_TIME_STR
4617 IFACE_PIM_HELLO_HOLD_STR)
4618{
cdc2d765 4619 VTY_DECLVAR_CONTEXT(interface, ifp);
7960fa8f
DS
4620 struct pim_interface *pim_ifp;
4621
7960fa8f
DS
4622 pim_ifp = ifp->info;
4623
4624 if (!pim_ifp) {
4625 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
4626 return CMD_WARNING;
4627 }
4628
4629 pim_ifp->pim_hello_period = PIM_DEFAULT_HELLO_PERIOD;
4630 pim_ifp->pim_default_holdtime = -1;
4631
4632 return CMD_SUCCESS;
4633}
4634
12e41d03
DL
4635DEFUN (debug_igmp,
4636 debug_igmp_cmd,
4637 "debug igmp",
4638 DEBUG_STR
4639 DEBUG_IGMP_STR)
4640{
4641 PIM_DO_DEBUG_IGMP_EVENTS;
4642 PIM_DO_DEBUG_IGMP_PACKETS;
4643 PIM_DO_DEBUG_IGMP_TRACE;
4644 return CMD_SUCCESS;
4645}
4646
4647DEFUN (no_debug_igmp,
4648 no_debug_igmp_cmd,
4649 "no debug igmp",
4650 NO_STR
4651 DEBUG_STR
4652 DEBUG_IGMP_STR)
4653{
4654 PIM_DONT_DEBUG_IGMP_EVENTS;
4655 PIM_DONT_DEBUG_IGMP_PACKETS;
4656 PIM_DONT_DEBUG_IGMP_TRACE;
4657 return CMD_SUCCESS;
4658}
4659
12e41d03
DL
4660
4661DEFUN (debug_igmp_events,
4662 debug_igmp_events_cmd,
4663 "debug igmp events",
4664 DEBUG_STR
4665 DEBUG_IGMP_STR
4666 DEBUG_IGMP_EVENTS_STR)
4667{
4668 PIM_DO_DEBUG_IGMP_EVENTS;
4669 return CMD_SUCCESS;
4670}
4671
4672DEFUN (no_debug_igmp_events,
4673 no_debug_igmp_events_cmd,
4674 "no debug igmp events",
4675 NO_STR
4676 DEBUG_STR
4677 DEBUG_IGMP_STR
4678 DEBUG_IGMP_EVENTS_STR)
4679{
4680 PIM_DONT_DEBUG_IGMP_EVENTS;
4681 return CMD_SUCCESS;
4682}
4683
12e41d03
DL
4684
4685DEFUN (debug_igmp_packets,
4686 debug_igmp_packets_cmd,
4687 "debug igmp packets",
4688 DEBUG_STR
4689 DEBUG_IGMP_STR
4690 DEBUG_IGMP_PACKETS_STR)
4691{
4692 PIM_DO_DEBUG_IGMP_PACKETS;
4693 return CMD_SUCCESS;
4694}
4695
4696DEFUN (no_debug_igmp_packets,
4697 no_debug_igmp_packets_cmd,
4698 "no debug igmp packets",
4699 NO_STR
4700 DEBUG_STR
4701 DEBUG_IGMP_STR
4702 DEBUG_IGMP_PACKETS_STR)
4703{
4704 PIM_DONT_DEBUG_IGMP_PACKETS;
4705 return CMD_SUCCESS;
4706}
4707
12e41d03
DL
4708
4709DEFUN (debug_igmp_trace,
4710 debug_igmp_trace_cmd,
4711 "debug igmp trace",
4712 DEBUG_STR
4713 DEBUG_IGMP_STR
4714 DEBUG_IGMP_TRACE_STR)
4715{
4716 PIM_DO_DEBUG_IGMP_TRACE;
4717 return CMD_SUCCESS;
4718}
4719
4720DEFUN (no_debug_igmp_trace,
4721 no_debug_igmp_trace_cmd,
4722 "no debug igmp trace",
4723 NO_STR
4724 DEBUG_STR
4725 DEBUG_IGMP_STR
4726 DEBUG_IGMP_TRACE_STR)
4727{
4728 PIM_DONT_DEBUG_IGMP_TRACE;
4729 return CMD_SUCCESS;
4730}
4731
12e41d03
DL
4732
4733DEFUN (debug_mroute,
4734 debug_mroute_cmd,
4735 "debug mroute",
4736 DEBUG_STR
4737 DEBUG_MROUTE_STR)
4738{
4739 PIM_DO_DEBUG_MROUTE;
4740 return CMD_SUCCESS;
4741}
4742
6c7197b1
DS
4743DEFUN (debug_mroute_detail,
4744 debug_mroute_detail_cmd,
4745 "debug mroute detail",
4746 DEBUG_STR
4747 DEBUG_MROUTE_STR
4748 "detailed\n")
4749{
4750 PIM_DO_DEBUG_MROUTE_DETAIL;
4751 return CMD_SUCCESS;
4752}
4753
12e41d03
DL
4754DEFUN (no_debug_mroute,
4755 no_debug_mroute_cmd,
4756 "no debug mroute",
4757 NO_STR
4758 DEBUG_STR
4759 DEBUG_MROUTE_STR)
4760{
4761 PIM_DONT_DEBUG_MROUTE;
4762 return CMD_SUCCESS;
4763}
4764
6c7197b1
DS
4765DEFUN (no_debug_mroute_detail,
4766 no_debug_mroute_detail_cmd,
4767 "no debug mroute detail",
4768 NO_STR
4769 DEBUG_STR
4770 DEBUG_MROUTE_STR
4771 "detailed\n")
4772{
4773 PIM_DONT_DEBUG_MROUTE_DETAIL;
4774 return CMD_SUCCESS;
4775}
12e41d03 4776
6250610a
JAG
4777DEFUN (debug_static,
4778 debug_static_cmd,
4779 "debug static",
4780 DEBUG_STR
4781 DEBUG_STATIC_STR)
4782{
4783 PIM_DO_DEBUG_STATIC;
4784 return CMD_SUCCESS;
4785}
4786
4787DEFUN (no_debug_static,
4788 no_debug_static_cmd,
4789 "no debug static",
4790 NO_STR
4791 DEBUG_STR
4792 DEBUG_STATIC_STR)
4793{
4794 PIM_DONT_DEBUG_STATIC;
4795 return CMD_SUCCESS;
4796}
4797
6250610a 4798
12e41d03
DL
4799DEFUN (debug_pim,
4800 debug_pim_cmd,
4801 "debug pim",
4802 DEBUG_STR
4803 DEBUG_PIM_STR)
4804{
4805 PIM_DO_DEBUG_PIM_EVENTS;
4806 PIM_DO_DEBUG_PIM_PACKETS;
4807 PIM_DO_DEBUG_PIM_TRACE;
886d1e80 4808 PIM_DO_DEBUG_MSDP_EVENTS;
4809 PIM_DO_DEBUG_MSDP_PACKETS;
12e41d03
DL
4810 return CMD_SUCCESS;
4811}
4812
4813DEFUN (no_debug_pim,
4814 no_debug_pim_cmd,
4815 "no debug pim",
4816 NO_STR
4817 DEBUG_STR
4818 DEBUG_PIM_STR)
4819{
4820 PIM_DONT_DEBUG_PIM_EVENTS;
4821 PIM_DONT_DEBUG_PIM_PACKETS;
4822 PIM_DONT_DEBUG_PIM_TRACE;
886d1e80 4823 PIM_DONT_DEBUG_MSDP_EVENTS;
4824 PIM_DONT_DEBUG_MSDP_PACKETS;
12e41d03
DL
4825
4826 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
4827 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
4828
4829 return CMD_SUCCESS;
4830}
4831
12e41d03
DL
4832
4833DEFUN (debug_pim_events,
4834 debug_pim_events_cmd,
4835 "debug pim events",
4836 DEBUG_STR
4837 DEBUG_PIM_STR
4838 DEBUG_PIM_EVENTS_STR)
4839{
4840 PIM_DO_DEBUG_PIM_EVENTS;
4841 return CMD_SUCCESS;
4842}
4843
4844DEFUN (no_debug_pim_events,
4845 no_debug_pim_events_cmd,
4846 "no debug pim events",
4847 NO_STR
4848 DEBUG_STR
4849 DEBUG_PIM_STR
4850 DEBUG_PIM_EVENTS_STR)
4851{
4852 PIM_DONT_DEBUG_PIM_EVENTS;
4853 return CMD_SUCCESS;
4854}
4855
12e41d03
DL
4856
4857DEFUN (debug_pim_packets,
4858 debug_pim_packets_cmd,
4859 "debug pim packets",
4860 DEBUG_STR
4861 DEBUG_PIM_STR
4862 DEBUG_PIM_PACKETS_STR)
4863{
4864 PIM_DO_DEBUG_PIM_PACKETS;
4865 vty_out (vty, "PIM Packet debugging is on %s", VTY_NEWLINE);
4866 return CMD_SUCCESS;
4867}
4868
4869DEFUN (debug_pim_packets_filter,
4870 debug_pim_packets_filter_cmd,
9add3b88 4871 "debug pim packets <hello|joins|register>",
12e41d03
DL
4872 DEBUG_STR
4873 DEBUG_PIM_STR
4874 DEBUG_PIM_PACKETS_STR
4875 DEBUG_PIM_HELLO_PACKETS_STR
9add3b88
DS
4876 DEBUG_PIM_J_P_PACKETS_STR
4877 DEBUG_PIM_PIM_REG_PACKETS_STR)
12e41d03 4878{
b181fa04 4879 int idx_hello_join = 3;
9add3b88 4880 if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0)
12e41d03
DL
4881 {
4882 PIM_DO_DEBUG_PIM_HELLO;
9add3b88 4883 vty_out (vty, "PIM Hello debugging is on%s", VTY_NEWLINE);
12e41d03 4884 }
9add3b88 4885 else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
12e41d03
DL
4886 {
4887 PIM_DO_DEBUG_PIM_J_P;
9add3b88
DS
4888 vty_out (vty, "PIM Join/Prune debugging is on%s", VTY_NEWLINE);
4889 }
4890 else if (strncmp(argv[idx_hello_join]->arg,"r",1) == 0)
4891 {
4892 PIM_DO_DEBUG_PIM_REG;
4893 vty_out (vty, "PIM Register debugging is on%s", VTY_NEWLINE);
12e41d03
DL
4894 }
4895 return CMD_SUCCESS;
4896}
4897
4898DEFUN (no_debug_pim_packets,
4899 no_debug_pim_packets_cmd,
4900 "no debug pim packets",
4901 NO_STR
4902 DEBUG_STR
4903 DEBUG_PIM_STR
4904 DEBUG_PIM_PACKETS_STR
4905 DEBUG_PIM_HELLO_PACKETS_STR
4906 DEBUG_PIM_J_P_PACKETS_STR)
4907{
4908 PIM_DONT_DEBUG_PIM_PACKETS;
4909 vty_out (vty, "PIM Packet debugging is off %s", VTY_NEWLINE);
4910 return CMD_SUCCESS;
4911}
4912
4913DEFUN (no_debug_pim_packets_filter,
4914 no_debug_pim_packets_filter_cmd,
9add3b88 4915 "no debug pim packets <hello|joins|register>",
12e41d03
DL
4916 NO_STR
4917 DEBUG_STR
4918 DEBUG_PIM_STR
4919 DEBUG_PIM_PACKETS_STR
4920 DEBUG_PIM_HELLO_PACKETS_STR
4921 DEBUG_PIM_J_P_PACKETS_STR)
4922{
b181fa04 4923 int idx_hello_join = 4;
9add3b88 4924 if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0)
12e41d03
DL
4925 {
4926 PIM_DONT_DEBUG_PIM_HELLO;
4927 vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
4928 }
9add3b88 4929 else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0)
12e41d03
DL
4930 {
4931 PIM_DONT_DEBUG_PIM_J_P;
4932 vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
4933 }
9add3b88
DS
4934 else if (strncmp (argv[idx_hello_join]->arg, "r", 1) == 0)
4935 {
4936 PIM_DONT_DEBUG_PIM_REG;
4937 vty_out (vty, "PIM Register debugging is off%s", VTY_NEWLINE);
4938 }
4939 return CMD_SUCCESS;
12e41d03
DL
4940}
4941
12e41d03
DL
4942
4943DEFUN (debug_pim_packetdump_send,
4944 debug_pim_packetdump_send_cmd,
4945 "debug pim packet-dump send",
4946 DEBUG_STR
4947 DEBUG_PIM_STR
4948 DEBUG_PIM_PACKETDUMP_STR
4949 DEBUG_PIM_PACKETDUMP_SEND_STR)
4950{
4951 PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
4952 return CMD_SUCCESS;
4953}
4954
4955DEFUN (no_debug_pim_packetdump_send,
4956 no_debug_pim_packetdump_send_cmd,
4957 "no debug pim packet-dump send",
4958 NO_STR
4959 DEBUG_STR
4960 DEBUG_PIM_STR
4961 DEBUG_PIM_PACKETDUMP_STR
4962 DEBUG_PIM_PACKETDUMP_SEND_STR)
4963{
4964 PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
4965 return CMD_SUCCESS;
4966}
4967
12e41d03
DL
4968
4969DEFUN (debug_pim_packetdump_recv,
4970 debug_pim_packetdump_recv_cmd,
4971 "debug pim packet-dump receive",
4972 DEBUG_STR
4973 DEBUG_PIM_STR
4974 DEBUG_PIM_PACKETDUMP_STR
4975 DEBUG_PIM_PACKETDUMP_RECV_STR)
4976{
4977 PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
4978 return CMD_SUCCESS;
4979}
4980
4981DEFUN (no_debug_pim_packetdump_recv,
4982 no_debug_pim_packetdump_recv_cmd,
4983 "no debug pim packet-dump receive",
4984 NO_STR
4985 DEBUG_STR
4986 DEBUG_PIM_STR
4987 DEBUG_PIM_PACKETDUMP_STR
4988 DEBUG_PIM_PACKETDUMP_RECV_STR)
4989{
4990 PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
4991 return CMD_SUCCESS;
4992}
4993
12e41d03
DL
4994
4995DEFUN (debug_pim_trace,
4996 debug_pim_trace_cmd,
4997 "debug pim trace",
4998 DEBUG_STR
4999 DEBUG_PIM_STR
5000 DEBUG_PIM_TRACE_STR)
5001{
5002 PIM_DO_DEBUG_PIM_TRACE;
5003 return CMD_SUCCESS;
5004}
5005
5006DEFUN (no_debug_pim_trace,
5007 no_debug_pim_trace_cmd,
5008 "no debug pim trace",
5009 NO_STR
5010 DEBUG_STR
5011 DEBUG_PIM_STR
5012 DEBUG_PIM_TRACE_STR)
5013{
5014 PIM_DONT_DEBUG_PIM_TRACE;
5015 return CMD_SUCCESS;
5016}
5017
12e41d03
DL
5018
5019DEFUN (debug_ssmpingd,
5020 debug_ssmpingd_cmd,
5021 "debug ssmpingd",
5022 DEBUG_STR
5023 DEBUG_PIM_STR
5024 DEBUG_SSMPINGD_STR)
5025{
5026 PIM_DO_DEBUG_SSMPINGD;
5027 return CMD_SUCCESS;
5028}
5029
5030DEFUN (no_debug_ssmpingd,
5031 no_debug_ssmpingd_cmd,
5032 "no debug ssmpingd",
5033 NO_STR
5034 DEBUG_STR
5035 DEBUG_PIM_STR
5036 DEBUG_SSMPINGD_STR)
5037{
5038 PIM_DONT_DEBUG_SSMPINGD;
5039 return CMD_SUCCESS;
5040}
5041
12e41d03
DL
5042
5043DEFUN (debug_pim_zebra,
5044 debug_pim_zebra_cmd,
5045 "debug pim zebra",
5046 DEBUG_STR
5047 DEBUG_PIM_STR
5048 DEBUG_PIM_ZEBRA_STR)
5049{
5050 PIM_DO_DEBUG_ZEBRA;
5051 return CMD_SUCCESS;
5052}
5053
5054DEFUN (no_debug_pim_zebra,
5055 no_debug_pim_zebra_cmd,
5056 "no debug pim zebra",
5057 NO_STR
5058 DEBUG_STR
5059 DEBUG_PIM_STR
5060 DEBUG_PIM_ZEBRA_STR)
5061{
5062 PIM_DONT_DEBUG_ZEBRA;
5063 return CMD_SUCCESS;
5064}
5065
12e41d03 5066
2a333e0f 5067DEFUN (debug_msdp,
5068 debug_msdp_cmd,
5069 "debug msdp",
5070 DEBUG_STR
5071 DEBUG_MSDP_STR)
5072{
5073 PIM_DO_DEBUG_MSDP_EVENTS;
5074 PIM_DO_DEBUG_MSDP_PACKETS;
5075 return CMD_SUCCESS;
5076}
5077
5078DEFUN (no_debug_msdp,
5079 no_debug_msdp_cmd,
5080 "no debug msdp",
5081 NO_STR
5082 DEBUG_STR
5083 DEBUG_MSDP_STR)
5084{
5085 PIM_DONT_DEBUG_MSDP_EVENTS;
5086 PIM_DONT_DEBUG_MSDP_PACKETS;
5087 return CMD_SUCCESS;
5088}
5089
5090ALIAS (no_debug_msdp,
5091 undebug_msdp_cmd,
5092 "undebug msdp",
5093 UNDEBUG_STR
5094 DEBUG_MSDP_STR)
5095
5096DEFUN (debug_msdp_events,
5097 debug_msdp_events_cmd,
5098 "debug msdp events",
5099 DEBUG_STR
5100 DEBUG_MSDP_STR
5101 DEBUG_MSDP_EVENTS_STR)
5102{
5103 PIM_DO_DEBUG_MSDP_EVENTS;
5104 return CMD_SUCCESS;
5105}
5106
5107DEFUN (no_debug_msdp_events,
5108 no_debug_msdp_events_cmd,
5109 "no debug msdp events",
5110 NO_STR
5111 DEBUG_STR
5112 DEBUG_MSDP_STR
5113 DEBUG_MSDP_EVENTS_STR)
5114{
5115 PIM_DONT_DEBUG_MSDP_EVENTS;
5116 return CMD_SUCCESS;
5117}
5118
5119ALIAS (no_debug_msdp_events,
5120 undebug_msdp_events_cmd,
5121 "undebug msdp events",
5122 UNDEBUG_STR
5123 DEBUG_MSDP_STR
5124 DEBUG_MSDP_EVENTS_STR)
5125
5126DEFUN (debug_msdp_packets,
5127 debug_msdp_packets_cmd,
5128 "debug msdp packets",
5129 DEBUG_STR
5130 DEBUG_MSDP_STR
5131 DEBUG_MSDP_PACKETS_STR)
5132{
5133 PIM_DO_DEBUG_MSDP_PACKETS;
5134 return CMD_SUCCESS;
5135}
5136
5137DEFUN (no_debug_msdp_packets,
5138 no_debug_msdp_packets_cmd,
5139 "no debug msdp packets",
5140 NO_STR
5141 DEBUG_STR
5142 DEBUG_MSDP_STR
5143 DEBUG_MSDP_PACKETS_STR)
5144{
5145 PIM_DONT_DEBUG_MSDP_PACKETS;
5146 return CMD_SUCCESS;
5147}
5148
5149ALIAS (no_debug_msdp_packets,
5150 undebug_msdp_packets_cmd,
5151 "undebug msdp packets",
5152 UNDEBUG_STR
5153 DEBUG_MSDP_STR
5154 DEBUG_MSDP_PACKETS_STR)
5155
7a1d58ce
DS
5156DEFUN (show_debugging_pim,
5157 show_debugging_pim_cmd,
5158 "show debugging pim",
12e41d03 5159 SHOW_STR
7a1d58ce
DS
5160 DEBUG_STR
5161 PIM_STR)
12e41d03
DL
5162{
5163 pim_debug_config_write(vty);
5164 return CMD_SUCCESS;
5165}
5166
4763cd0e 5167static int
5168interface_pim_use_src_cmd_worker(struct vty *vty, const char *source)
5169{
5170 int result;
5171 struct in_addr source_addr;
5172 VTY_DECLVAR_CONTEXT(interface, ifp);
5173
5174 result = inet_pton(AF_INET, source, &source_addr);
5175 if (result <= 0) {
5176 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
5177 source, errno, safe_strerror(errno), VTY_NEWLINE);
5178 return CMD_WARNING;
5179 }
5180
5181 result = pim_update_source_set(ifp, source_addr);
5182 switch (result) {
5183 case PIM_SUCCESS:
5184 break;
7cdb24da 5185 case PIM_IFACE_NOT_FOUND:
5186 vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE);
5187 break;
4763cd0e 5188 case PIM_UPDATE_SOURCE_DUP:
5189 vty_out(vty, "%% Source already set to %s%s", source, VTY_NEWLINE);
5190 break;
5191 default:
5192 vty_out(vty, "%% Source set failed%s", VTY_NEWLINE);
5193 }
5194
5195 return result?CMD_WARNING:CMD_SUCCESS;
5196}
5197
5198DEFUN (interface_pim_use_source,
5199 interface_pim_use_source_cmd,
5200 "ip pim use-source A.B.C.D",
5201 IP_STR
5202 "pim multicast routing\n"
5203 "Configure primary IP address\n"
5204 "source ip address\n")
5205{
5206 return interface_pim_use_src_cmd_worker (vty, argv[3]->arg);
5207}
5208
5209DEFUN (interface_no_pim_use_source,
5210 interface_no_pim_use_source_cmd,
5211 "no ip pim use-source",
5212 NO_STR
5213 IP_STR
5214 "pim multicast routing\n"
5215 "Delete source IP address\n")
5216{
5217 return interface_pim_use_src_cmd_worker (vty, "0.0.0.0");
5218}
5219
2a333e0f 5220static int
5221ip_msdp_peer_cmd_worker (struct vty *vty, const char *peer, const char *local)
5222{
5223 enum pim_msdp_err result;
5224 struct in_addr peer_addr;
5225 struct in_addr local_addr;
5226
5227 result = inet_pton(AF_INET, peer, &peer_addr);
5228 if (result <= 0) {
5229 vty_out(vty, "%% Bad peer address %s: errno=%d: %s%s",
5230 peer, errno, safe_strerror(errno), VTY_NEWLINE);
5231 return CMD_WARNING;
5232 }
5233
5234 result = inet_pton(AF_INET, local, &local_addr);
5235 if (result <= 0) {
5236 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
5237 local, errno, safe_strerror(errno), VTY_NEWLINE);
5238 return CMD_WARNING;
5239 }
5240
977d71cc 5241 result = pim_msdp_peer_add(peer_addr, local_addr, "default", NULL/* mp_p */);
2a333e0f 5242 switch (result) {
5243 case PIM_MSDP_ERR_NONE:
5244 break;
5245 case PIM_MSDP_ERR_OOM:
5246 vty_out(vty, "%% Out of memory%s", VTY_NEWLINE);
5247 break;
5248 case PIM_MSDP_ERR_PEER_EXISTS:
5249 vty_out(vty, "%% Peer exists%s", VTY_NEWLINE);
5250 break;
5251 case PIM_MSDP_ERR_MAX_MESH_GROUPS:
5252 vty_out(vty, "%% Only one mesh-group allowed currently%s", VTY_NEWLINE);
5253 break;
5254 default:
5255 vty_out(vty, "%% peer add failed%s", VTY_NEWLINE);
5256 }
5257
5258 return result?CMD_WARNING:CMD_SUCCESS;
5259}
5260
977d71cc 5261DEFUN_HIDDEN (ip_msdp_peer,
2a333e0f 5262 ip_msdp_peer_cmd,
5263 "ip msdp peer A.B.C.D source A.B.C.D",
5264 IP_STR
5265 CFG_MSDP_STR
5266 "Configure MSDP peer\n"
5267 "peer ip address\n"
5268 "Source address for TCP connection\n"
5269 "local ip address\n")
5270{
5271 return ip_msdp_peer_cmd_worker (vty, argv[3]->arg, argv[5]->arg);
5272}
5273
5274static int
5275ip_no_msdp_peer_cmd_worker (struct vty *vty, const char *peer)
5276{
5277 enum pim_msdp_err result;
5278 struct in_addr peer_addr;
5279
5280 result = inet_pton(AF_INET, peer, &peer_addr);
5281 if (result <= 0) {
5282 vty_out(vty, "%% Bad peer address %s: errno=%d: %s%s",
5283 peer, errno, safe_strerror(errno), VTY_NEWLINE);
5284 return CMD_WARNING;
5285 }
5286
5287 result = pim_msdp_peer_del(peer_addr);
5288 switch (result) {
5289 case PIM_MSDP_ERR_NONE:
5290 break;
5291 case PIM_MSDP_ERR_NO_PEER:
5292 vty_out(vty, "%% Peer does not exist%s", VTY_NEWLINE);
5293 break;
5294 default:
5295 vty_out(vty, "%% peer del failed%s", VTY_NEWLINE);
5296 }
5297
5298 return result?CMD_WARNING:CMD_SUCCESS;
5299}
5300
977d71cc 5301DEFUN_HIDDEN (no_ip_msdp_peer,
2a333e0f 5302 no_ip_msdp_peer_cmd,
5303 "no ip msdp peer A.B.C.D",
977d71cc 5304 NO_STR
2a333e0f 5305 IP_STR
5306 CFG_MSDP_STR
5307 "Delete MSDP peer\n"
5308 "peer ip address\n")
5309{
5310 return ip_no_msdp_peer_cmd_worker (vty, argv[4]->arg);
5311}
5312
977d71cc 5313static int
5314ip_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const char *mbr)
5315{
5316 enum pim_msdp_err result;
5317 struct in_addr mbr_ip;
5318
5319 result = inet_pton(AF_INET, mbr, &mbr_ip);
5320 if (result <= 0) {
5321 vty_out(vty, "%% Bad member address %s: errno=%d: %s%s",
5322 mbr, errno, safe_strerror(errno), VTY_NEWLINE);
5323 return CMD_WARNING;
5324 }
5325
5326 result = pim_msdp_mg_mbr_add(mg, mbr_ip);
5327 switch (result) {
5328 case PIM_MSDP_ERR_NONE:
5329 break;
5330 case PIM_MSDP_ERR_OOM:
5331 vty_out(vty, "%% Out of memory%s", VTY_NEWLINE);
5332 break;
5333 case PIM_MSDP_ERR_MG_MBR_EXISTS:
5334 vty_out(vty, "%% mesh-group member exists%s", VTY_NEWLINE);
5335 break;
5336 case PIM_MSDP_ERR_MAX_MESH_GROUPS:
5337 vty_out(vty, "%% Only one mesh-group allowed currently%s", VTY_NEWLINE);
5338 break;
5339 default:
5340 vty_out(vty, "%% member add failed%s", VTY_NEWLINE);
5341 }
5342
5343 return result?CMD_WARNING:CMD_SUCCESS;
5344}
5345
5346DEFUN (ip_msdp_mesh_group_member,
5347 ip_msdp_mesh_group_member_cmd,
5348 "ip msdp mesh-group WORD member A.B.C.D",
5349 IP_STR
5350 CFG_MSDP_STR
5351 "Configure MSDP mesh-group\n"
5352 "mesh group name\n"
5353 "mesh group member\n"
5354 "peer ip address\n")
5355{
5356 return ip_msdp_mesh_group_member_cmd_worker(vty, argv[3]->arg, argv[5]->arg);
5357}
5358
5359static int
5360ip_no_msdp_mesh_group_member_cmd_worker(struct vty *vty, const char *mg, const char *mbr)
5361{
5362 enum pim_msdp_err result;
5363 struct in_addr mbr_ip;
5364
5365 result = inet_pton(AF_INET, mbr, &mbr_ip);
5366 if (result <= 0) {
5367 vty_out(vty, "%% Bad member address %s: errno=%d: %s%s",
5368 mbr, errno, safe_strerror(errno), VTY_NEWLINE);
5369 return CMD_WARNING;
5370 }
5371
5372 result = pim_msdp_mg_mbr_del(mg, mbr_ip);
5373 switch (result) {
5374 case PIM_MSDP_ERR_NONE:
5375 break;
5376 case PIM_MSDP_ERR_NO_MG:
5377 vty_out(vty, "%% mesh-group does not exist%s", VTY_NEWLINE);
5378 break;
5379 case PIM_MSDP_ERR_NO_MG_MBR:
5380 vty_out(vty, "%% mesh-group member does not exist%s", VTY_NEWLINE);
5381 break;
5382 default:
5383 vty_out(vty, "%% mesh-group member del failed%s", VTY_NEWLINE);
5384 }
5385
5386 return result?CMD_WARNING:CMD_SUCCESS;
5387}
5388DEFUN (no_ip_msdp_mesh_group_member,
5389 no_ip_msdp_mesh_group_member_cmd,
5390 "no ip msdp mesh-group WORD member A.B.C.D",
5391 NO_STR
5392 IP_STR
5393 CFG_MSDP_STR
5394 "Delete MSDP mesh-group member\n"
5395 "mesh group name\n"
5396 "mesh group member\n"
5397 "peer ip address\n")
5398{
5399 return ip_no_msdp_mesh_group_member_cmd_worker(vty, argv[4]->arg, argv[6]->arg);
5400}
5401
5402static int
5403ip_msdp_mesh_group_source_cmd_worker(struct vty *vty, const char *mg, const char *src)
5404{
5405 enum pim_msdp_err result;
5406 struct in_addr src_ip;
5407
5408 result = inet_pton(AF_INET, src, &src_ip);
5409 if (result <= 0) {
5410 vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
5411 src, errno, safe_strerror(errno), VTY_NEWLINE);
5412 return CMD_WARNING;
5413 }
5414
5415 result = pim_msdp_mg_src_add(mg, src_ip);
5416 switch (result) {
5417 case PIM_MSDP_ERR_NONE:
5418 break;
5419 case PIM_MSDP_ERR_OOM:
5420 vty_out(vty, "%% Out of memory%s", VTY_NEWLINE);
5421 break;
5422 case PIM_MSDP_ERR_MAX_MESH_GROUPS:
5423 vty_out(vty, "%% Only one mesh-group allowed currently%s", VTY_NEWLINE);
5424 break;
5425 default:
5426 vty_out(vty, "%% source add failed%s", VTY_NEWLINE);
5427 }
5428
5429 return result?CMD_WARNING:CMD_SUCCESS;
5430}
5431
5432
5433DEFUN (ip_msdp_mesh_group_source,
5434 ip_msdp_mesh_group_source_cmd,
5435 "ip msdp mesh-group WORD source A.B.C.D",
5436 IP_STR
5437 CFG_MSDP_STR
5438 "Configure MSDP mesh-group\n"
5439 "mesh group name\n"
5440 "mesh group local address\n"
5441 "source ip address for the TCP connection\n")
5442{
5443 return ip_msdp_mesh_group_source_cmd_worker(vty, argv[3]->arg, argv[5]->arg);
5444}
5445
5446static int
5447ip_no_msdp_mesh_group_source_cmd_worker(struct vty *vty, const char *mg)
5448{
5449 enum pim_msdp_err result;
5450
5451 result = pim_msdp_mg_src_del(mg);
5452 switch (result) {
5453 case PIM_MSDP_ERR_NONE:
5454 break;
5455 case PIM_MSDP_ERR_NO_MG:
5456 vty_out(vty, "%% mesh-group does not exist%s", VTY_NEWLINE);
5457 break;
5458 default:
5459 vty_out(vty, "%% mesh-group source del failed%s", VTY_NEWLINE);
5460 }
5461
5462 return result?CMD_WARNING:CMD_SUCCESS;
5463}
5464
977d71cc 5465static int
5466ip_no_msdp_mesh_group_cmd_worker(struct vty *vty, const char *mg)
5467{
5468 enum pim_msdp_err result;
5469
5470 result = pim_msdp_mg_del(mg);
5471 switch (result) {
5472 case PIM_MSDP_ERR_NONE:
5473 break;
5474 case PIM_MSDP_ERR_NO_MG:
5475 vty_out(vty, "%% mesh-group does not exist%s", VTY_NEWLINE);
5476 break;
5477 default:
5478 vty_out(vty, "%% mesh-group source del failed%s", VTY_NEWLINE);
5479 }
5480
58344b65 5481 return result ? CMD_WARNING : CMD_SUCCESS;
977d71cc 5482}
5483
58344b65
DS
5484DEFUN (no_ip_msdp_mesh_group_source,
5485 no_ip_msdp_mesh_group_source_cmd,
5486 "no ip msdp mesh-group WORD source [A.B.C.D]",
977d71cc 5487 NO_STR
5488 IP_STR
5489 CFG_MSDP_STR
58344b65
DS
5490 "Delete MSDP mesh-group source\n"
5491 "mesh group name\n"
5492 "mesh group local address\n")
977d71cc 5493{
58344b65
DS
5494 if (argv[6]->arg)
5495 return ip_no_msdp_mesh_group_cmd_worker(vty, argv[6]->arg);
5496 else
5497 return ip_no_msdp_mesh_group_source_cmd_worker(vty, argv[4]->arg);
977d71cc 5498}
5499
1bf16443 5500static void
5501print_empty_json_obj(struct vty *vty)
5502{
5503 json_object *json;
5504 json = json_object_new_object();
5505 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5506 json_object_free(json);
5507}
5508
977d71cc 5509static void
5510ip_msdp_show_mesh_group(struct vty *vty, u_char uj)
5511{
5512 struct listnode *mbrnode;
5513 struct pim_msdp_mg_mbr *mbr;
5514 struct pim_msdp_mg *mg = msdp->mg;
5515 char mbr_str[INET_ADDRSTRLEN];
5516 char src_str[INET_ADDRSTRLEN];
5517 char state_str[PIM_MSDP_STATE_STRLEN];
5518 enum pim_msdp_peer_state state;
5519 json_object *json = NULL;
5520 json_object *json_mg_row = NULL;
5521 json_object *json_row = NULL;
5522
5523 if (!mg) {
1bf16443 5524 if (uj)
5525 print_empty_json_obj(vty);
977d71cc 5526 return;
5527 }
5528
5529 pim_inet4_dump("<source?>", mg->src_ip, src_str, sizeof(src_str));
5530 if (uj) {
5531 json = json_object_new_object();
5532 /* currently there is only one mesh group but we should still make
5533 * it a dict with mg-name as key */
5534 json_mg_row = json_object_new_object();
5535 json_object_string_add(json_mg_row, "name", mg->mesh_group_name);
5536 json_object_string_add(json_mg_row, "source", src_str);
5537 } else {
5538 vty_out(vty, "Mesh group : %s%s", mg->mesh_group_name, VTY_NEWLINE);
5539 vty_out(vty, " Source : %s%s", src_str, VTY_NEWLINE);
5540 vty_out(vty, " Member State%s", VTY_NEWLINE);
5541 }
5542
5543 for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) {
5544 pim_inet4_dump("<mbr?>", mbr->mbr_ip, mbr_str, sizeof(mbr_str));
5545 if (mbr->mp) {
5546 state = mbr->mp->state;
5547 } else {
5548 state = PIM_MSDP_DISABLED;
5549 }
5550 pim_msdp_state_dump(state, state_str, sizeof(state_str));
5551 if (uj) {
5552 json_row = json_object_new_object();
5553 json_object_string_add(json_row, "member", mbr_str);
5554 json_object_string_add(json_row, "state", state_str);
5555 json_object_object_add(json_mg_row, mbr_str, json_row);
5556 } else {
5557 vty_out(vty, " %-15s %11s%s",
5558 mbr_str, state_str, VTY_NEWLINE);
5559 }
5560 }
5561
5562 if (uj) {
5563 json_object_object_add(json, mg->mesh_group_name, json_mg_row);
5564 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5565 json_object_free(json);
5566 }
5567}
5568
5569DEFUN (show_ip_msdp_mesh_group,
5570 show_ip_msdp_mesh_group_cmd,
5571 "show ip msdp mesh-group [json]",
5572 SHOW_STR
5573 IP_STR
5574 MSDP_STR
5575 "MSDP mesh-group information\n"
5576 "JavaScript Object Notation\n")
5577{
5578 u_char uj = use_json(argc, argv);
5579 ip_msdp_show_mesh_group(vty, uj);
5580
5581 return CMD_SUCCESS;
5582}
5583
2a333e0f 5584static void
5585ip_msdp_show_peers(struct vty *vty, u_char uj)
5586{
5587 struct listnode *mpnode;
5588 struct pim_msdp_peer *mp;
5589 char peer_str[INET_ADDRSTRLEN];
5590 char local_str[INET_ADDRSTRLEN];
5591 char state_str[PIM_MSDP_STATE_STRLEN];
5592 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5593 int64_t now;
977d71cc 5594 json_object *json = NULL;
5595 json_object *json_row = NULL;
5596
2a333e0f 5597
5598 if (uj) {
977d71cc 5599 json = json_object_new_object();
2a333e0f 5600 } else {
886d1e80 5601 vty_out(vty, "Peer Local State Uptime SaCnt%s", VTY_NEWLINE);
977d71cc 5602 }
5603
5604 for (ALL_LIST_ELEMENTS_RO(msdp->peer_list, mpnode, mp)) {
5605 if (mp->state == PIM_MSDP_ESTABLISHED) {
5606 now = pim_time_monotonic_sec();
5607 pim_time_uptime(timebuf, sizeof(timebuf), now - mp->uptime);
5608 } else {
5609 strcpy(timebuf, "-");
5610 }
5611 pim_inet4_dump("<peer?>", mp->peer, peer_str, sizeof(peer_str));
5612 pim_inet4_dump("<local?>", mp->local, local_str, sizeof(local_str));
5613 pim_msdp_state_dump(mp->state, state_str, sizeof(state_str));
5614 if (uj) {
5615 json_row = json_object_new_object();
5616 json_object_string_add(json_row, "peer", peer_str);
5617 json_object_string_add(json_row, "local", local_str);
977d71cc 5618 json_object_string_add(json_row, "state", state_str);
5619 json_object_string_add(json_row, "upTime", timebuf);
15ad0c71 5620 json_object_int_add(json_row, "saCount", mp->sa_cnt);
977d71cc 5621 json_object_object_add(json, peer_str, json_row);
5622 } else {
886d1e80 5623 vty_out(vty, "%-15s %15s %11s %8s %6d%s",
15ad0c71 5624 peer_str, local_str, state_str,
5625 timebuf, mp->sa_cnt, VTY_NEWLINE);
2a333e0f 5626 }
5627 }
977d71cc 5628
5629 if (uj) {
5630 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5631 json_object_free(json);
5632 }
2a333e0f 5633}
5634
977d71cc 5635static void
5636ip_msdp_show_peers_detail(struct vty *vty, const char *peer, u_char uj)
5637{
5638 struct listnode *mpnode;
5639 struct pim_msdp_peer *mp;
5640 char peer_str[INET_ADDRSTRLEN];
5641 char local_str[INET_ADDRSTRLEN];
5642 char state_str[PIM_MSDP_STATE_STRLEN];
5643 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5644 char katimer[PIM_MSDP_TIMER_STRLEN];
5645 char crtimer[PIM_MSDP_TIMER_STRLEN];
5646 char holdtimer[PIM_MSDP_TIMER_STRLEN];
5647 int64_t now;
5648 json_object *json = NULL;
5649 json_object *json_row = NULL;
5650
5651 if (uj) {
5652 json = json_object_new_object();
5653 }
5654
5655 for (ALL_LIST_ELEMENTS_RO(msdp->peer_list, mpnode, mp)) {
5656 pim_inet4_dump("<peer?>", mp->peer, peer_str, sizeof(peer_str));
5657 if (strcmp(peer, "detail") &&
5658 strcmp(peer, peer_str))
5659 continue;
5660
5661 if (mp->state == PIM_MSDP_ESTABLISHED) {
5662 now = pim_time_monotonic_sec();
5663 pim_time_uptime(timebuf, sizeof(timebuf), now - mp->uptime);
5664 } else {
5665 strcpy(timebuf, "-");
5666 }
5667 pim_inet4_dump("<local?>", mp->local, local_str, sizeof(local_str));
5668 pim_msdp_state_dump(mp->state, state_str, sizeof(state_str));
5669 pim_time_timer_to_hhmmss(katimer, sizeof(katimer), mp->ka_timer);
5670 pim_time_timer_to_hhmmss(crtimer, sizeof(crtimer), mp->cr_timer);
5671 pim_time_timer_to_hhmmss(holdtimer, sizeof(holdtimer), mp->hold_timer);
5672
5673 if (uj) {
5674 json_row = json_object_new_object();
5675 json_object_string_add(json_row, "peer", peer_str);
5676 json_object_string_add(json_row, "local", local_str);
5677 json_object_string_add(json_row, "meshGroupName", mp->mesh_group_name);
5678 json_object_string_add(json_row, "state", state_str);
5679 json_object_string_add(json_row, "upTime", timebuf);
15ad0c71 5680 json_object_string_add(json_row, "keepAliveTimer", katimer);
5681 json_object_string_add(json_row, "connRetryTimer", crtimer);
5682 json_object_string_add(json_row, "holdTimer", holdtimer);
977d71cc 5683 json_object_string_add(json_row, "lastReset", mp->last_reset);
5684 json_object_int_add(json_row, "connAttempts", mp->conn_attempts);
15ad0c71 5685 json_object_int_add(json_row, "establishedChanges", mp->est_flaps);
5686 json_object_int_add(json_row, "saCount", mp->sa_cnt);
977d71cc 5687 json_object_int_add(json_row, "kaSent", mp->ka_tx_cnt);
5688 json_object_int_add(json_row, "kaRcvd", mp->ka_rx_cnt);
5689 json_object_int_add(json_row, "saSent", mp->sa_tx_cnt);
5690 json_object_int_add(json_row, "saRcvd", mp->sa_rx_cnt);
5691 json_object_object_add(json, peer_str, json_row);
5692 } else {
5693 vty_out(vty, "Peer : %s%s", peer_str, VTY_NEWLINE);
15ad0c71 5694 vty_out(vty, " Local : %s%s", local_str, VTY_NEWLINE);
5695 vty_out(vty, " Mesh Group : %s%s", mp->mesh_group_name, VTY_NEWLINE);
5696 vty_out(vty, " State : %s%s", state_str, VTY_NEWLINE);
5697 vty_out(vty, " Uptime : %s%s", timebuf, VTY_NEWLINE);
5698
5699 vty_out(vty, " Keepalive Timer : %s%s", katimer, VTY_NEWLINE);
5700 vty_out(vty, " Conn Retry Timer : %s%s", crtimer, VTY_NEWLINE);
5701 vty_out(vty, " Hold Timer : %s%s", holdtimer, VTY_NEWLINE);
5702 vty_out(vty, " Last Reset : %s%s", mp->last_reset, VTY_NEWLINE);
5703 vty_out(vty, " Conn Attempts : %d%s", mp->conn_attempts, VTY_NEWLINE);
5704 vty_out(vty, " Established Changes : %d%s", mp->est_flaps, VTY_NEWLINE);
5705 vty_out(vty, " SA Count : %d%s", mp->sa_cnt, VTY_NEWLINE);
5706 vty_out(vty, " Statistics :%s", VTY_NEWLINE);
977d71cc 5707 vty_out(vty, " Sent Rcvd%s", VTY_NEWLINE);
5708 vty_out(vty, " Keepalives : %10d %10d%s",
5709 mp->ka_tx_cnt, mp->ka_rx_cnt, VTY_NEWLINE);
5710 vty_out(vty, " SAs : %10d %10d%s",
5711 mp->sa_tx_cnt, mp->sa_rx_cnt, VTY_NEWLINE);
5712 vty_out(vty, "%s", VTY_NEWLINE);
5713 }
5714 }
5715
5716 if (uj) {
5717 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5718 json_object_free(json);
5719 }
5720}
5721
5722DEFUN (show_ip_msdp_peer_detail,
5723 show_ip_msdp_peer_detail_cmd,
5724 "show ip msdp peer [detail|A.B.C.D] [json]",
2a333e0f 5725 SHOW_STR
5726 IP_STR
5727 MSDP_STR
5728 "MSDP peer information\n"
977d71cc 5729 "Detailed output\n"
5730 "peer ip address\n"
2a333e0f 5731 "JavaScript Object Notation\n")
5732{
5733 u_char uj = use_json(argc, argv);
977d71cc 5734 if (argv[4]->arg)
5735 ip_msdp_show_peers_detail(vty, argv[4]->arg, uj);
5736 else
5737 ip_msdp_show_peers(vty, uj);
2a333e0f 5738
5739 return CMD_SUCCESS;
5740}
5741
3c72d654 5742static void
5743ip_msdp_show_sa(struct vty *vty, u_char uj)
5744{
5745 struct listnode *sanode;
5746 struct pim_msdp_sa *sa;
5747 char src_str[INET_ADDRSTRLEN];
5748 char grp_str[INET_ADDRSTRLEN];
5749 char rp_str[INET_ADDRSTRLEN];
5750 char timebuf[PIM_MSDP_UPTIME_STRLEN];
977d71cc 5751 char spt_str[8];
1bf16443 5752 char local_str[8];
3c72d654 5753 int64_t now;
977d71cc 5754 json_object *json = NULL;
5755 json_object *json_group = NULL;
5756 json_object *json_row = NULL;
3c72d654 5757
5758 if (uj) {
977d71cc 5759 json = json_object_new_object();
3c72d654 5760 } else {
1bf16443 5761 vty_out(vty, "Source Group RP Local SPT Uptime%s", VTY_NEWLINE);
977d71cc 5762 }
5763
5764 for (ALL_LIST_ELEMENTS_RO(msdp->sa_list, sanode, sa)) {
5765 now = pim_time_monotonic_sec();
5766 pim_time_uptime(timebuf, sizeof(timebuf), now - sa->uptime);
5767 pim_inet4_dump("<src?>", sa->sg.src, src_str, sizeof(src_str));
5768 pim_inet4_dump("<grp?>", sa->sg.grp, grp_str, sizeof(grp_str));
1bf16443 5769 if (sa->flags & PIM_MSDP_SAF_PEER) {
977d71cc 5770 pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
977d71cc 5771 if (sa->up) {
5772 strcpy(spt_str, "yes");
3c72d654 5773 } else {
977d71cc 5774 strcpy(spt_str, "no");
5775 }
1bf16443 5776 } else {
5777 strcpy(rp_str, "-");
5778 strcpy(spt_str, "-");
5779 }
5780 if (sa->flags & PIM_MSDP_SAF_LOCAL) {
5781 strcpy(local_str, "yes");
5782 } else {
5783 strcpy(local_str, "no");
5784 }
5785 if (uj) {
977d71cc 5786 json_object_object_get_ex(json, grp_str, &json_group);
5787
5788 if (!json_group) {
5789 json_group = json_object_new_object();
5790 json_object_object_add(json, grp_str, json_group);
5791 }
5792
5793 json_row = json_object_new_object();
5794 json_object_string_add(json_row, "source", src_str);
5795 json_object_string_add(json_row, "group", grp_str);
5796 json_object_string_add(json_row, "rp", rp_str);
1bf16443 5797 json_object_string_add(json_row, "local", local_str);
977d71cc 5798 json_object_string_add(json_row, "sptSetup", spt_str);
5799 json_object_string_add(json_row, "upTime", timebuf);
5800 json_object_object_add(json_group, src_str, json_row);
5801 } else {
1bf16443 5802 vty_out(vty, "%-15s %15s %15s %5c %3c %8s%s",
5803 src_str, grp_str, rp_str, local_str[0], spt_str[0], timebuf, VTY_NEWLINE);
3c72d654 5804 }
5805 }
977d71cc 5806
5807
5808 if (uj) {
5809 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5810 json_object_free(json);
5811 }
3c72d654 5812}
5813
977d71cc 5814static void
5815ip_msdp_show_sa_entry_detail(struct pim_msdp_sa *sa, const char *src_str,
5816 const char *grp_str, struct vty *vty,
5817 u_char uj, json_object *json)
5818{
5819 char rp_str[INET_ADDRSTRLEN];
5820 char peer_str[INET_ADDRSTRLEN];
5821 char timebuf[PIM_MSDP_UPTIME_STRLEN];
5822 char spt_str[8];
1bf16443 5823 char local_str[8];
977d71cc 5824 char statetimer[PIM_MSDP_TIMER_STRLEN];
5825 int64_t now;
5826 json_object *json_group = NULL;
5827 json_object *json_row = NULL;
5828
5829 now = pim_time_monotonic_sec();
5830 pim_time_uptime(timebuf, sizeof(timebuf), now - sa->uptime);
1bf16443 5831 if (sa->flags & PIM_MSDP_SAF_PEER) {
977d71cc 5832 pim_inet4_dump("<rp?>", sa->rp, rp_str, sizeof(rp_str));
5833 pim_inet4_dump("<peer?>", sa->peer, peer_str, sizeof(peer_str));
5834 if (sa->up) {
5835 strcpy(spt_str, "yes");
5836 } else {
5837 strcpy(spt_str, "no");
5838 }
1bf16443 5839 } else {
5840 strcpy(rp_str, "-");
5841 strcpy(peer_str, "-");
5842 strcpy(spt_str, "-");
5843 }
5844 if (sa->flags & PIM_MSDP_SAF_LOCAL) {
5845 strcpy(local_str, "yes");
5846 } else {
5847 strcpy(local_str, "no");
977d71cc 5848 }
5849 pim_time_timer_to_hhmmss(statetimer, sizeof(statetimer), sa->sa_state_timer);
5850 if (uj) {
5851 json_object_object_get_ex(json, grp_str, &json_group);
5852
5853 if (!json_group) {
5854 json_group = json_object_new_object();
5855 json_object_object_add(json, grp_str, json_group);
5856 }
5857
5858 json_row = json_object_new_object();
5859 json_object_string_add(json_row, "source", src_str);
5860 json_object_string_add(json_row, "group", grp_str);
5861 json_object_string_add(json_row, "rp", rp_str);
1bf16443 5862 json_object_string_add(json_row, "local", local_str);
977d71cc 5863 json_object_string_add(json_row, "sptSetup", spt_str);
5864 json_object_string_add(json_row, "upTime", timebuf);
15ad0c71 5865 json_object_string_add(json_row, "stateTimer", statetimer);
977d71cc 5866 json_object_object_add(json_group, src_str, json_row);
5867 } else {
8bfb8b67 5868 vty_out(vty, "SA : %s%s", sa->sg_str, VTY_NEWLINE);
15ad0c71 5869 vty_out(vty, " RP : %s%s", rp_str, VTY_NEWLINE);
5870 vty_out(vty, " Peer : %s%s", peer_str, VTY_NEWLINE);
5871 vty_out(vty, " Local : %s%s", local_str, VTY_NEWLINE);
5872 vty_out(vty, " SPT Setup : %s%s", spt_str, VTY_NEWLINE);
5873 vty_out(vty, " Uptime : %s%s", timebuf, VTY_NEWLINE);
5874 vty_out(vty, " State Timer : %s%s", statetimer, VTY_NEWLINE);
977d71cc 5875 vty_out(vty, "%s", VTY_NEWLINE);
5876 }
5877}
5878
5879static void
5880ip_msdp_show_sa_detail(struct vty *vty, u_char uj)
5881{
5882 struct listnode *sanode;
5883 struct pim_msdp_sa *sa;
5884 char src_str[INET_ADDRSTRLEN];
5885 char grp_str[INET_ADDRSTRLEN];
5886 json_object *json = NULL;
5887
5888 if (uj) {
5889 json = json_object_new_object();
5890 }
5891
5892 for (ALL_LIST_ELEMENTS_RO(msdp->sa_list, sanode, sa)) {
5893 pim_inet4_dump("<src?>", sa->sg.src, src_str, sizeof(src_str));
5894 pim_inet4_dump("<grp?>", sa->sg.grp, grp_str, sizeof(grp_str));
5895 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty, uj, json);
5896 }
5897
5898 if (uj) {
5899 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5900 json_object_free(json);
5901 }
5902}
5903
5904DEFUN (show_ip_msdp_sa_detail,
5905 show_ip_msdp_sa_detail_cmd,
5906 "show ip msdp sa detail [json]",
3c72d654 5907 SHOW_STR
5908 IP_STR
5909 MSDP_STR
5910 "MSDP active-source information\n"
977d71cc 5911 "Detailed output\n"
3c72d654 5912 "JavaScript Object Notation\n")
5913{
5914 u_char uj = use_json(argc, argv);
977d71cc 5915 ip_msdp_show_sa_detail(vty, uj);
5916
5917 return CMD_SUCCESS;
5918}
5919
5920static void
5921ip_msdp_show_sa_addr(struct vty *vty, const char *addr, u_char uj)
5922{
5923 struct listnode *sanode;
5924 struct pim_msdp_sa *sa;
5925 char src_str[INET_ADDRSTRLEN];
5926 char grp_str[INET_ADDRSTRLEN];
5927 json_object *json = NULL;
5928
5929 if (uj) {
5930 json = json_object_new_object();
5931 }
5932
5933 for (ALL_LIST_ELEMENTS_RO(msdp->sa_list, sanode, sa)) {
5934 pim_inet4_dump("<src?>", sa->sg.src, src_str, sizeof(src_str));
5935 pim_inet4_dump("<grp?>", sa->sg.grp, grp_str, sizeof(grp_str));
5936 if (!strcmp(addr, src_str) || !strcmp(addr, grp_str)) {
5937 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty, uj, json);
5938 }
5939 }
5940
5941 if (uj) {
5942 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5943 json_object_free(json);
5944 }
5945}
5946
5947static void
5948ip_msdp_show_sa_sg(struct vty *vty, const char *src, const char *grp, u_char uj)
5949{
5950 struct listnode *sanode;
5951 struct pim_msdp_sa *sa;
5952 char src_str[INET_ADDRSTRLEN];
5953 char grp_str[INET_ADDRSTRLEN];
5954 json_object *json = NULL;
5955
5956 if (uj) {
5957 json = json_object_new_object();
5958 }
5959
5960 for (ALL_LIST_ELEMENTS_RO(msdp->sa_list, sanode, sa)) {
5961 pim_inet4_dump("<src?>", sa->sg.src, src_str, sizeof(src_str));
5962 pim_inet4_dump("<grp?>", sa->sg.grp, grp_str, sizeof(grp_str));
5963 if (!strcmp(src, src_str) && !strcmp(grp, grp_str)) {
5964 ip_msdp_show_sa_entry_detail(sa, src_str, grp_str, vty, uj, json);
5965 }
5966 }
5967
5968 if (uj) {
5969 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5970 json_object_free(json);
5971 }
5972}
5973
5974DEFUN (show_ip_msdp_sa_sg,
5975 show_ip_msdp_sa_sg_cmd,
5976 "show ip msdp sa [A.B.C.D] [A.B.C.D] [json]",
5977 SHOW_STR
5978 IP_STR
5979 MSDP_STR
5980 "MSDP active-source information\n"
5981 "source or group ip\n"
977d71cc 5982 "JavaScript Object Notation\n")
5983{
5984 u_char uj = use_json(argc, argv);
5985 if (argv[5]->arg)
5986 ip_msdp_show_sa_sg(vty, argv[4]->arg, argv[5]->arg, uj);
5987 else if (argv[4]->arg)
5988 ip_msdp_show_sa_addr(vty, argv[4]->arg, uj);
5989 else
5990 ip_msdp_show_sa(vty, uj);
3c72d654 5991
5992 return CMD_SUCCESS;
5993}
5994
12e41d03
DL
5995void pim_cmd_init()
5996{
5997 install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
5998 install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
0b84f294 5999 if_cmd_init ();
12e41d03 6000
eb7a976a
DS
6001 install_node (&debug_node, pim_debug_config_write);
6002
12e41d03
DL
6003 install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
6004 install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
981d6c7a
DS
6005 install_element (CONFIG_NODE, &ip_pim_rp_cmd);
6006 install_element (CONFIG_NODE, &no_ip_pim_rp_cmd);
dfe43e25
DW
6007 install_element (CONFIG_NODE, &ip_pim_rp_prefix_list_cmd);
6008 install_element (CONFIG_NODE, &no_ip_pim_rp_prefix_list_cmd);
191f5695
DS
6009 install_element (CONFIG_NODE, &ip_pim_register_suppress_cmd);
6010 install_element (CONFIG_NODE, &no_ip_pim_register_suppress_cmd);
ee1a0718
DS
6011 install_element (CONFIG_NODE, &ip_pim_joinprune_time_cmd);
6012 install_element (CONFIG_NODE, &no_ip_pim_joinprune_time_cmd);
4304f95c
DS
6013 install_element (CONFIG_NODE, &ip_pim_keep_alive_cmd);
6014 install_element (CONFIG_NODE, &no_ip_pim_keep_alive_cmd);
8e4c9ef3
DS
6015 install_element (CONFIG_NODE, &ip_pim_packets_cmd);
6016 install_element (CONFIG_NODE, &no_ip_pim_packets_cmd);
12e41d03
DL
6017 install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
6018 install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
2a333e0f 6019 install_element (CONFIG_NODE, &ip_msdp_peer_cmd);
6020 install_element (CONFIG_NODE, &no_ip_msdp_peer_cmd);
0b84f294 6021
12e41d03
DL
6022 install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
6023 install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
6024 install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
6025 install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
b05b72e8
DW
6026 install_element (INTERFACE_NODE, &interface_ip_igmp_version_cmd);
6027 install_element (INTERFACE_NODE, &interface_no_ip_igmp_version_cmd);
12e41d03
DL
6028 install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
6029 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
6030 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
6031 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
6032 install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
6033 install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
6034 install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
dedccda6 6035 install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
981d6c7a 6036 install_element (INTERFACE_NODE, &interface_ip_pim_sm_cmd);
8371bd60 6037 install_element (INTERFACE_NODE, &interface_no_ip_pim_sm_cmd);
dedccda6
DS
6038 install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd);
6039 install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd);
7960fa8f 6040 install_element (INTERFACE_NODE, &interface_ip_pim_hello_cmd);
7960fa8f 6041 install_element (INTERFACE_NODE, &interface_no_ip_pim_hello_cmd);
12e41d03 6042
6250610a
JAG
6043 // Static mroutes NEB
6044 install_element (INTERFACE_NODE, &interface_ip_mroute_cmd);
6045 install_element (INTERFACE_NODE, &interface_ip_mroute_source_cmd);
6046 install_element (INTERFACE_NODE, &interface_no_ip_mroute_cmd);
6047 install_element (INTERFACE_NODE, &interface_no_ip_mroute_source_cmd);
6048
12e41d03
DL
6049 install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
6050 install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
12e41d03
DL
6051 install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
6052 install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
6053 install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
6054 install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
12e41d03
DL
6055 install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
6056 install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
6057 install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
6058 install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
12e41d03
DL
6059 install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
6060 install_element (VIEW_NODE, &show_ip_pim_join_cmd);
12e41d03
DL
6061 install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
6062 install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
6063 install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
6064 install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
31a21c9c 6065 install_element (VIEW_NODE, &show_ip_pim_state_cmd);
12e41d03
DL
6066 install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
6067 install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
6068 install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
00d07c6f 6069 install_element (VIEW_NODE, &show_ip_pim_rp_cmd);
12e41d03
DL
6070 install_element (VIEW_NODE, &show_ip_multicast_cmd);
6071 install_element (VIEW_NODE, &show_ip_mroute_cmd);
6072 install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
6073 install_element (VIEW_NODE, &show_ip_rib_cmd);
6074 install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
7a1d58ce 6075 install_element (VIEW_NODE, &show_debugging_pim_cmd);
12e41d03
DL
6076
6077 install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
6078 install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
6079 install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
6080 install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
6081 install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
6082
12e41d03
DL
6083 install_element (ENABLE_NODE, &debug_igmp_cmd);
6084 install_element (ENABLE_NODE, &no_debug_igmp_cmd);
12e41d03
DL
6085 install_element (ENABLE_NODE, &debug_igmp_events_cmd);
6086 install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
12e41d03
DL
6087 install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
6088 install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
12e41d03
DL
6089 install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
6090 install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
12e41d03 6091 install_element (ENABLE_NODE, &debug_mroute_cmd);
6c7197b1 6092 install_element (ENABLE_NODE, &debug_mroute_detail_cmd);
12e41d03 6093 install_element (ENABLE_NODE, &no_debug_mroute_cmd);
6c7197b1 6094 install_element (ENABLE_NODE, &no_debug_mroute_detail_cmd);
6250610a
JAG
6095 install_element (ENABLE_NODE, &debug_static_cmd);
6096 install_element (ENABLE_NODE, &no_debug_static_cmd);
12e41d03
DL
6097 install_element (ENABLE_NODE, &debug_pim_cmd);
6098 install_element (ENABLE_NODE, &no_debug_pim_cmd);
12e41d03
DL
6099 install_element (ENABLE_NODE, &debug_pim_events_cmd);
6100 install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
12e41d03
DL
6101 install_element (ENABLE_NODE, &debug_pim_packets_cmd);
6102 install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd);
6103 install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
6104 install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd);
12e41d03
DL
6105 install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
6106 install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
12e41d03
DL
6107 install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
6108 install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
12e41d03
DL
6109 install_element (ENABLE_NODE, &debug_pim_trace_cmd);
6110 install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
12e41d03
DL
6111 install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
6112 install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
12e41d03
DL
6113 install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
6114 install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
2a333e0f 6115 install_element (ENABLE_NODE, &debug_msdp_cmd);
6116 install_element (ENABLE_NODE, &no_debug_msdp_cmd);
6117 install_element (ENABLE_NODE, &undebug_msdp_cmd);
6118 install_element (ENABLE_NODE, &debug_msdp_events_cmd);
6119 install_element (ENABLE_NODE, &no_debug_msdp_events_cmd);
6120 install_element (ENABLE_NODE, &undebug_msdp_events_cmd);
6121 install_element (ENABLE_NODE, &debug_msdp_packets_cmd);
6122 install_element (ENABLE_NODE, &no_debug_msdp_packets_cmd);
6123 install_element (ENABLE_NODE, &undebug_msdp_packets_cmd);
12e41d03
DL
6124
6125 install_element (CONFIG_NODE, &debug_igmp_cmd);
6126 install_element (CONFIG_NODE, &no_debug_igmp_cmd);
12e41d03
DL
6127 install_element (CONFIG_NODE, &debug_igmp_events_cmd);
6128 install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
12e41d03
DL
6129 install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
6130 install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
12e41d03
DL
6131 install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
6132 install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
12e41d03 6133 install_element (CONFIG_NODE, &debug_mroute_cmd);
6c7197b1 6134 install_element (CONFIG_NODE, &debug_mroute_detail_cmd);
12e41d03 6135 install_element (CONFIG_NODE, &no_debug_mroute_cmd);
6c7197b1 6136 install_element (CONFIG_NODE, &no_debug_mroute_detail_cmd);
6250610a
JAG
6137 install_element (CONFIG_NODE, &debug_static_cmd);
6138 install_element (CONFIG_NODE, &no_debug_static_cmd);
12e41d03
DL
6139 install_element (CONFIG_NODE, &debug_pim_cmd);
6140 install_element (CONFIG_NODE, &no_debug_pim_cmd);
12e41d03
DL
6141 install_element (CONFIG_NODE, &debug_pim_events_cmd);
6142 install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
12e41d03
DL
6143 install_element (CONFIG_NODE, &debug_pim_packets_cmd);
6144 install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd);
6145 install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
6146 install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd);
12e41d03
DL
6147 install_element (CONFIG_NODE, &debug_pim_trace_cmd);
6148 install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
12e41d03
DL
6149 install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
6150 install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
12e41d03
DL
6151 install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
6152 install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
2a333e0f 6153 install_element (CONFIG_NODE, &debug_msdp_cmd);
6154 install_element (CONFIG_NODE, &no_debug_msdp_cmd);
6155 install_element (CONFIG_NODE, &undebug_msdp_cmd);
6156 install_element (CONFIG_NODE, &debug_msdp_events_cmd);
6157 install_element (CONFIG_NODE, &no_debug_msdp_events_cmd);
6158 install_element (CONFIG_NODE, &undebug_msdp_events_cmd);
6159 install_element (CONFIG_NODE, &debug_msdp_packets_cmd);
6160 install_element (CONFIG_NODE, &no_debug_msdp_packets_cmd);
6161 install_element (CONFIG_NODE, &undebug_msdp_packets_cmd);
977d71cc 6162 install_element (CONFIG_NODE, &ip_msdp_peer_cmd);
6163 install_element (CONFIG_NODE, &no_ip_msdp_peer_cmd);
6164 install_element (CONFIG_NODE, &ip_msdp_mesh_group_member_cmd);
6165 install_element (CONFIG_NODE, &no_ip_msdp_mesh_group_member_cmd);
6166 install_element (CONFIG_NODE, &ip_msdp_mesh_group_source_cmd);
6167 install_element (CONFIG_NODE, &no_ip_msdp_mesh_group_source_cmd);
977d71cc 6168 install_element (VIEW_NODE, &show_ip_msdp_peer_detail_cmd);
6169 install_element (VIEW_NODE, &show_ip_msdp_sa_detail_cmd);
6170 install_element (VIEW_NODE, &show_ip_msdp_sa_sg_cmd);
6171 install_element (VIEW_NODE, &show_ip_msdp_mesh_group_cmd);
4763cd0e 6172 install_element (INTERFACE_NODE, &interface_pim_use_source_cmd);
6173 install_element (INTERFACE_NODE, &interface_no_pim_use_source_cmd);
12e41d03 6174}