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