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