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