diff options
Diffstat (limited to 'pimd/pim_cmd.c')
| -rw-r--r-- | pimd/pim_cmd.c | 350 |
1 files changed, 145 insertions, 205 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 430fc738d5..afc42a9561 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1533,8 +1533,9 @@ DEFUN (pim_interface, "Select an interface to configure\n" "Interface's name\n") { + int idx_ifname = 1; struct interface *ifp; - const char *ifname = argv[0]; + const char *ifname = argv[idx_ifname]->arg; size_t sl; sl = strlen(ifname); @@ -2368,13 +2369,14 @@ DEFUN (show_ip_rib, RIB_STR "Unicast address\n") { + int idx_ipv4 = 3; struct in_addr addr; const char *addr_str; struct pim_nexthop nexthop; char nexthop_addr_str[100]; int result; - addr_str = argv[0]; + addr_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, addr_str, &addr); if (result <= 0) { vty_out(vty, "Bad unicast address %s: errno=%d: %s%s", @@ -2466,16 +2468,17 @@ DEFUN (ip_pim_rp, "Rendevous Point\n" "ip address of RP\n") { + int idx_ipv4 = 3; int result; - result = inet_pton(AF_INET, argv[0], &qpim_rp.rpf_addr.s_addr); + result = inet_pton(AF_INET, argv[idx_ipv4]->arg, &qpim_rp.rpf_addr.s_addr); if (result <= 0) { - vty_out(vty, "%% Bad RP address specified: %s", argv[0]); + vty_out(vty, "%% Bad RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { - vty_out(vty, "%% No Path to RP address specified: %s", argv[0]); + vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg); return CMD_WARNING; } @@ -2484,7 +2487,7 @@ DEFUN (ip_pim_rp, DEFUN (no_ip_pim_rp, no_ip_pim_rp_cmd, - "no ip pim rp {A.B.C.D}", + "no ip pim rp [A.B.C.D]", NO_STR IP_STR "pim multicast routing\n" @@ -2498,7 +2501,7 @@ DEFUN (no_ip_pim_rp, DEFUN (ip_multicast_routing, ip_multicast_routing_cmd, - PIM_CMD_IP_MULTICAST_ROUTING, + "ip multicast-routing", IP_STR "Enable IP multicast forwarding\n") { @@ -2511,7 +2514,7 @@ DEFUN (ip_multicast_routing, DEFUN (no_ip_multicast_routing, no_ip_multicast_routing_cmd, - PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING, + "no ip multicast-routing", NO_STR IP_STR "Global IP configuration subcommands\n" @@ -2531,9 +2534,10 @@ DEFUN (ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 2; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2560,9 +2564,10 @@ DEFUN (no_ip_ssmpingd, CONF_SSMPINGD_STR "Source address\n") { + int idx_ipv4 = 3; int result; struct in_addr source_addr; - const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; + const char *source_str = (argc > idx_ipv4) ? argv[idx_ipv4]->arg : "0.0.0.0"; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { @@ -2648,6 +2653,8 @@ DEFUN (interface_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *ifp; const char *group_str; const char *source_str; @@ -2658,7 +2665,7 @@ DEFUN (interface_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[0]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2667,7 +2674,7 @@ DEFUN (interface_ip_igmp_join, } /* Source address */ - source_str = argv[1]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2695,6 +2702,8 @@ DEFUN (interface_no_ip_igmp_join, "Multicast group address\n" "Source address\n") { + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *ifp; const char *group_str; const char *source_str; @@ -2705,7 +2714,7 @@ DEFUN (interface_no_ip_igmp_join, ifp = vty->index; /* Group address */ - group_str = argv[0]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -2714,7 +2723,7 @@ DEFUN (interface_no_ip_igmp_join, } /* Source address */ - source_str = argv[1]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -2865,7 +2874,7 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp, DEFUN (interface_ip_igmp_query_interval, interface_ip_igmp_query_interval_cmd, - PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>", + "ip igmp query-interval (1-1800)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_INTERVAL_STR @@ -2887,7 +2896,7 @@ DEFUN (interface_ip_igmp_query_interval, return CMD_WARNING; } - query_interval = atoi(argv[0]); + query_interval = atoi(argv[4]->arg); query_interval_dsec = 10 * query_interval; /* @@ -2924,7 +2933,7 @@ DEFUN (interface_ip_igmp_query_interval, DEFUN (interface_no_ip_igmp_query_interval, interface_no_ip_igmp_query_interval_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL, + "no ip igmp query-interval", NO_STR IP_STR IFACE_IGMP_STR @@ -2960,7 +2969,7 @@ DEFUN (interface_no_ip_igmp_query_interval, DEFUN (interface_ip_igmp_query_max_response_time, interface_ip_igmp_query_max_response_time_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>", + "ip igmp query-max-response-time (1-25)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR @@ -2981,7 +2990,7 @@ DEFUN (interface_ip_igmp_query_max_response_time, return CMD_WARNING; } - query_max_response_time = atoi(argv[0]); + query_max_response_time = atoi(argv[4]->arg); /* It seems we don't need to check bounds since command.c does it @@ -3017,7 +3026,7 @@ DEFUN (interface_ip_igmp_query_max_response_time, DEFUN (interface_no_ip_igmp_query_max_response_time, interface_no_ip_igmp_query_max_response_time_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME, + "no ip igmp query-max-response-time", NO_STR IP_STR IFACE_IGMP_STR @@ -3053,7 +3062,7 @@ DEFUN (interface_no_ip_igmp_query_max_response_time, DEFUN (interface_ip_igmp_query_max_response_time_dsec, interface_ip_igmp_query_max_response_time_dsec_cmd, - PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>", + "ip igmp query-max-response-time-dsec (10-250)", IP_STR IFACE_IGMP_STR IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR @@ -3075,7 +3084,7 @@ DEFUN (interface_ip_igmp_query_max_response_time_dsec, return CMD_WARNING; } - query_max_response_time_dsec = atoi(argv[0]); + query_max_response_time_dsec = atoi(argv[4]->arg); /* It seems we don't need to check bounds since command.c does it @@ -3113,7 +3122,7 @@ DEFUN (interface_ip_igmp_query_max_response_time_dsec, DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, interface_no_ip_igmp_query_max_response_time_dsec_cmd, - PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, + "no ip igmp query-max-response-time-dsec", NO_STR IP_STR IFACE_IGMP_STR @@ -3146,12 +3155,13 @@ DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, DEFUN (interface_ip_pim_drprio, interface_ip_pim_drprio_cmd, - "ip pim drpriority <1-4294967295>", + "ip pim drpriority (1-4294967295)", IP_STR PIM_STR "Set the Designated Router Election Priority\n" "Value of the new DR Priority\n") { + int idx_number = 3; struct interface *ifp; struct pim_interface *pim_ifp; uint32_t old_dr_prio; @@ -3166,7 +3176,7 @@ DEFUN (interface_ip_pim_drprio, old_dr_prio = pim_ifp->pim_dr_priority; - pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10); + pim_ifp->pim_dr_priority = strtol(argv[idx_number]->arg, NULL, 10); if (old_dr_prio != pim_ifp->pim_dr_priority) { if (pim_if_dr_election(ifp)) @@ -3178,7 +3188,8 @@ DEFUN (interface_ip_pim_drprio, DEFUN (interface_no_ip_pim_drprio, interface_no_ip_pim_drprio_cmd, - "no ip pim drpriority {<1-4294967295>}", + "no ip pim drpriority [(1-4294967295)]", + NO_STR IP_STR PIM_STR "Revert the Designated Router Priority to default\n" @@ -3345,6 +3356,8 @@ DEFUN (interface_ip_mroute, "Outgoing interface name\n" "Group address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; struct interface *iif; struct interface *oif; const char *oifname; @@ -3355,7 +3368,7 @@ DEFUN (interface_ip_mroute, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3363,7 +3376,7 @@ DEFUN (interface_ip_mroute, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3390,6 +3403,9 @@ DEFUN (interface_ip_mroute_source, "Group address\n" "Source address\n") { + int idx_interface = 2; + int idx_ipv4 = 3; + int idx_ipv4_2 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3401,7 +3417,7 @@ DEFUN (interface_ip_mroute_source, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3409,7 +3425,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3417,7 +3433,7 @@ DEFUN (interface_ip_mroute_source, return CMD_WARNING; } - src_str = argv[2]; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3442,6 +3458,8 @@ DEFUN (interface_no_ip_mroute, "Outgoing interface name\n" "Group Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; struct interface *iif; struct interface *oif; const char *oifname; @@ -3452,7 +3470,7 @@ DEFUN (interface_no_ip_mroute, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3460,7 +3478,7 @@ DEFUN (interface_no_ip_mroute, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3488,6 +3506,9 @@ DEFUN (interface_no_ip_mroute_source, "Group Address\n" "Source Address\n") { + int idx_interface = 3; + int idx_ipv4 = 4; + int idx_ipv4_2 = 5; struct interface *iif; struct interface *oif; const char *oifname; @@ -3499,7 +3520,7 @@ DEFUN (interface_no_ip_mroute_source, iif = vty->index; - oifname = argv[0]; + oifname = argv[idx_interface]->arg; oif = if_lookup_by_name(oifname); if (!oif) { vty_out(vty, "No such interface name %s%s", @@ -3507,7 +3528,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -3515,7 +3536,7 @@ DEFUN (interface_no_ip_mroute_source, return CMD_WARNING; } - src_str = argv[2]; + src_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, src_str, &src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -3533,12 +3554,15 @@ DEFUN (interface_no_ip_mroute_source, DEFUN (interface_ip_pim_hello, interface_ip_pim_hello_cmd, - "ip pim hello <1-180>", + "ip pim hello (1-180) [(1-180)]", IP_STR PIM_STR IFACE_PIM_HELLO_STR - IFACE_PIM_HELLO_TIME_STR) + IFACE_PIM_HELLO_TIME_STR + IFACE_PIM_HELLO_HOLD_STR) { + int idx_time = 3; + int idx_hold = 4; struct interface *ifp; struct pim_interface *pim_ifp; @@ -3550,27 +3574,19 @@ DEFUN (interface_ip_pim_hello, return CMD_WARNING; } - pim_ifp->pim_hello_period = strtol(argv[0], NULL, 10); + pim_ifp->pim_hello_period = strtol(argv[idx_time]->arg, NULL, 10); - if (argc == 2) - pim_ifp->pim_default_holdtime = strtol(argv[1], NULL, 10); + if (argc > idx_hold) + pim_ifp->pim_default_holdtime = strtol(argv[idx_hold]->arg, NULL, 10); return CMD_SUCCESS; } -ALIAS (interface_ip_pim_hello, - interface_ip_pim_hello_hold_cmd, - "ip pim hello <1-180> <1-180>", - IP_STR - PIM_STR - IFACE_PIM_HELLO_STR - IFACE_PIM_HELLO_TIME_STR - IFACE_PIM_HELLO_HOLD_STR) DEFUN (interface_no_ip_pim_hello, interface_no_ip_pim_hello_cmd, - "no ip pim hello {<1-180> <1-180>}", + "no ip pim hello [(1-180) (1-180)]", NO_STR IP_STR PIM_STR @@ -3620,11 +3636,6 @@ DEFUN (no_debug_igmp, return CMD_SUCCESS; } -ALIAS (no_debug_igmp, - undebug_igmp_cmd, - "undebug igmp", - UNDEBUG_STR - DEBUG_IGMP_STR) DEFUN (debug_igmp_events, debug_igmp_events_cmd, @@ -3649,12 +3660,6 @@ DEFUN (no_debug_igmp_events, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_events, - undebug_igmp_events_cmd, - "undebug igmp events", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_EVENTS_STR) DEFUN (debug_igmp_packets, debug_igmp_packets_cmd, @@ -3679,12 +3684,6 @@ DEFUN (no_debug_igmp_packets, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_packets, - undebug_igmp_packets_cmd, - "undebug igmp packets", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_PACKETS_STR) DEFUN (debug_igmp_trace, debug_igmp_trace_cmd, @@ -3709,12 +3708,6 @@ DEFUN (no_debug_igmp_trace, return CMD_SUCCESS; } -ALIAS (no_debug_igmp_trace, - undebug_igmp_trace_cmd, - "undebug igmp trace", - UNDEBUG_STR - DEBUG_IGMP_STR - DEBUG_IGMP_TRACE_STR) DEFUN (debug_mroute, debug_mroute_cmd, @@ -3737,11 +3730,6 @@ DEFUN (no_debug_mroute, return CMD_SUCCESS; } -ALIAS (no_debug_mroute, - undebug_mroute_cmd, - "undebug mroute", - UNDEBUG_STR - DEBUG_MROUTE_STR) DEFUN (debug_static, debug_static_cmd, @@ -3764,11 +3752,6 @@ DEFUN (no_debug_static, return CMD_SUCCESS; } -ALIAS (no_debug_static, - undebug_static_cmd, - "undebug static", - UNDEBUG_STR - DEBUG_STATIC_STR) DEFUN (debug_pim, debug_pim_cmd, @@ -3799,11 +3782,6 @@ DEFUN (no_debug_pim, return CMD_SUCCESS; } -ALIAS (no_debug_pim, - undebug_pim_cmd, - "undebug pim", - UNDEBUG_STR - DEBUG_PIM_STR) DEFUN (debug_pim_events, debug_pim_events_cmd, @@ -3828,12 +3806,6 @@ DEFUN (no_debug_pim_events, return CMD_SUCCESS; } -ALIAS (no_debug_pim_events, - undebug_pim_events_cmd, - "undebug pim events", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_EVENTS_STR) DEFUN (debug_pim_packets, debug_pim_packets_cmd, @@ -3849,19 +3821,20 @@ DEFUN (debug_pim_packets, DEFUN (debug_pim_packets_filter, debug_pim_packets_filter_cmd, - "debug pim packets (hello|joins)", + "debug pim packets <hello|joins>", DEBUG_STR DEBUG_PIM_STR DEBUG_PIM_PACKETS_STR DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[0],"h",1) == 0) + int idx_hello_join = 3; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DO_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE); } - else if (strncmp(argv[0],"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DO_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE); @@ -3886,7 +3859,7 @@ DEFUN (no_debug_pim_packets, DEFUN (no_debug_pim_packets_filter, no_debug_pim_packets_filter_cmd, - "no debug pim packets (hello|joins)", + "no debug pim packets <hello|joins>", NO_STR DEBUG_STR DEBUG_PIM_STR @@ -3894,12 +3867,13 @@ DEFUN (no_debug_pim_packets_filter, DEBUG_PIM_HELLO_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR) { - if (strncmp(argv[0],"h",1) == 0) + int idx_hello_join = 4; + if (strncmp(argv[idx_hello_join]->arg,"h",1) == 0) { PIM_DONT_DEBUG_PIM_HELLO; vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE); } - else if (strncmp(argv[0],"j",1) == 0) + else if (strncmp(argv[idx_hello_join]->arg,"j",1) == 0) { PIM_DONT_DEBUG_PIM_J_P; vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE); @@ -3907,12 +3881,6 @@ DEFUN (no_debug_pim_packets_filter, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packets, - undebug_pim_packets_cmd, - "undebug pim packets", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETS_STR) DEFUN (debug_pim_packetdump_send, debug_pim_packetdump_send_cmd, @@ -3939,13 +3907,6 @@ DEFUN (no_debug_pim_packetdump_send, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packetdump_send, - undebug_pim_packetdump_send_cmd, - "undebug pim packet-dump send", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_SEND_STR) DEFUN (debug_pim_packetdump_recv, debug_pim_packetdump_recv_cmd, @@ -3972,13 +3933,6 @@ DEFUN (no_debug_pim_packetdump_recv, return CMD_SUCCESS; } -ALIAS (no_debug_pim_packetdump_recv, - undebug_pim_packetdump_recv_cmd, - "undebug pim packet-dump receive", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_PACKETDUMP_STR - DEBUG_PIM_PACKETDUMP_RECV_STR) DEFUN (debug_pim_trace, debug_pim_trace_cmd, @@ -4003,12 +3957,6 @@ DEFUN (no_debug_pim_trace, return CMD_SUCCESS; } -ALIAS (no_debug_pim_trace, - undebug_pim_trace_cmd, - "undebug pim trace", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_TRACE_STR) DEFUN (debug_ssmpingd, debug_ssmpingd_cmd, @@ -4033,12 +3981,6 @@ DEFUN (no_debug_ssmpingd, return CMD_SUCCESS; } -ALIAS (no_debug_ssmpingd, - undebug_ssmpingd_cmd, - "undebug ssmpingd", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_SSMPINGD_STR) DEFUN (debug_pim_zebra, debug_pim_zebra_cmd, @@ -4063,12 +4005,6 @@ DEFUN (no_debug_pim_zebra, return CMD_SUCCESS; } -ALIAS (no_debug_pim_zebra, - undebug_pim_zebra_cmd, - "undebug pim zebra", - UNDEBUG_STR - DEBUG_PIM_STR - DEBUG_PIM_ZEBRA_STR) DEFUN (show_debugging_pim, show_debugging_pim_cmd, @@ -4107,7 +4043,7 @@ static struct igmp_sock *find_igmp_sock_by_fd(int fd) DEFUN (test_igmp_receive_report, test_igmp_receive_report_cmd, - "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE", + "test igmp receive report (0-65535) A.B.C.D (1-6) LINE...", "Test\n" "Test IGMP protocol\n" "Test IGMP message\n" @@ -4117,6 +4053,10 @@ DEFUN (test_igmp_receive_report, "Record type\n" "Sources\n") { + int idx_number = 4; + int idx_ipv4 = 5; + int idx_number_2 = 6; + int idx_line = 7; char buf[1000]; char *igmp_msg; struct ip *ip_hdr; @@ -4138,7 +4078,7 @@ DEFUN (test_igmp_receive_report, struct in_addr *src_addr; int argi; - socket = argv[0]; + socket = argv[idx_number]->arg; socket_fd = atoi(socket); igmp = find_igmp_sock_by_fd(socket_fd); if (!igmp) { @@ -4147,7 +4087,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - grp_str = argv[1]; + grp_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, grp_str, &grp_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4155,7 +4095,7 @@ DEFUN (test_igmp_receive_report, return CMD_WARNING; } - record_type_str = argv[2]; + record_type_str = argv[idx_number_2]->arg; record_type = atoi(record_type_str); /* @@ -4182,8 +4122,8 @@ DEFUN (test_igmp_receive_report, /* Scan LINE sources */ sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET); src_addr = sources; - for (argi = 3; argi < argc; ++argi,++src_addr) { - src_str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi,++src_addr) { + src_str = argv[argi]->arg; result = inet_pton(AF_INET, src_str, src_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4220,7 +4160,7 @@ static int hexval(uint8_t ch) DEFUN (test_pim_receive_dump, test_pim_receive_dump_cmd, - "test pim receive dump INTERFACE A.B.C.D .LINE", + "test pim receive dump INTERFACE A.B.C.D LINE...", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4229,6 +4169,9 @@ DEFUN (test_pim_receive_dump, "Neighbor address\n" "Packet dump\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_line = 6; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4243,7 +4186,7 @@ DEFUN (test_pim_receive_dump, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4252,7 +4195,7 @@ DEFUN (test_pim_receive_dump, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4277,8 +4220,8 @@ DEFUN (test_pim_receive_dump, pim_msg_size = 0; /* Scan LINE dump into buffer */ - for (argi = 2; argi < argc; ++argi) { - const char *str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi) { + const char *str = argv[argi]->arg; int str_len = strlen(str); int str_last = str_len - 1; int i; @@ -4332,7 +4275,7 @@ DEFUN (test_pim_receive_dump, DEFUN (test_pim_receive_hello, test_pim_receive_hello_cmd, - "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]", + "test pim receive hello INTERFACE A.B.C.D (0-65535) (0-65535) (0-65535) (0-32767) (0-65535) (0-1) [LINE]", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4347,6 +4290,15 @@ DEFUN (test_pim_receive_hello, "Neighbor LAN prune delay T-bit\n" "Neighbor secondary addresses\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_number = 6; + int idx_number_2 = 7; + int idx_number_3 = 8; + int idx_number_4 = 9; + int idx_number_5 = 10; + int idx_number_6 = 11; + int idx_line = 12; uint8_t buf[1000]; uint8_t *pim_msg; struct ip *ip_hdr; @@ -4368,7 +4320,7 @@ DEFUN (test_pim_receive_hello, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4377,7 +4329,7 @@ DEFUN (test_pim_receive_hello, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4385,12 +4337,12 @@ DEFUN (test_pim_receive_hello, return CMD_WARNING; } - neigh_holdtime = atoi(argv[2]); - neigh_dr_priority = atoi(argv[3]); - neigh_generation_id = atoi(argv[4]); - neigh_propagation_delay = atoi(argv[5]); - neigh_override_interval = atoi(argv[6]); - neigh_can_disable_join_suppression = atoi(argv[7]); + neigh_holdtime = atoi(argv[idx_number]->arg); + neigh_dr_priority = atoi(argv[idx_number_2]->arg); + neigh_generation_id = atoi(argv[idx_number_3]->arg); + neigh_propagation_delay = atoi(argv[idx_number_4]->arg); + neigh_override_interval = atoi(argv[idx_number_5]->arg); + neigh_can_disable_join_suppression = atoi(argv[idx_number_6]->arg); /* Tweak IP header @@ -4408,8 +4360,8 @@ DEFUN (test_pim_receive_hello, pim_msg = buf + ip_hlen; /* Scan LINE addresses */ - for (argi = 8; argi < argc; ++argi) { - const char *sec_str = argv[argi]; + for (argi = idx_line; argi < argc; ++argi) { + const char *sec_str = argv[argi]->arg; struct in_addr sec_addr; result = inet_pton(AF_INET, sec_str, &sec_addr); if (result <= 0) { @@ -4459,7 +4411,7 @@ DEFUN (test_pim_receive_hello, DEFUN (test_pim_receive_assert, test_pim_receive_assert_cmd, - "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>", + "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D (0-65535) (0-65535) (0-1)", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4472,6 +4424,13 @@ DEFUN (test_pim_receive_assert, "Assert route metric\n" "Assert RPT bit flag\n") { + int idx_interface = 4; + int idx_ipv4 = 5; + int idx_ipv4_2 = 6; + int idx_ipv4_3 = 7; + int idx_number = 8; + int idx_number_2 = 9; + int idx_number_3 = 10; uint8_t buf[1000]; uint8_t *buf_pastend = buf + sizeof(buf); uint8_t *pim_msg; @@ -4494,7 +4453,7 @@ DEFUN (test_pim_receive_assert, int result; /* Find interface */ - ifname = argv[0]; + ifname = argv[idx_interface]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4503,7 +4462,7 @@ DEFUN (test_pim_receive_assert, } /* Neighbor address */ - neigh_str = argv[1]; + neigh_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, neigh_str, &neigh_addr); if (result <= 0) { vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", @@ -4512,7 +4471,7 @@ DEFUN (test_pim_receive_assert, } /* Group address */ - group_str = argv[2]; + group_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4521,7 +4480,7 @@ DEFUN (test_pim_receive_assert, } /* Source address */ - source_str = argv[3]; + source_str = argv[idx_ipv4_3]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4529,9 +4488,9 @@ DEFUN (test_pim_receive_assert, return CMD_WARNING; } - assert_metric_preference = atoi(argv[4]); - assert_route_metric = atoi(argv[5]); - assert_rpt_bit_flag = atoi(argv[6]); + assert_metric_preference = atoi(argv[idx_number]->arg); + assert_route_metric = atoi(argv[idx_number_2]->arg); + assert_rpt_bit_flag = atoi(argv[idx_number_3]->arg); remain = buf_pastend - buf; if (remain < (int) sizeof(struct ip)) { @@ -4580,7 +4539,7 @@ DEFUN (test_pim_receive_assert, } static int recv_joinprune(struct vty *vty, - const char *argv[], + struct cmd_token **argv, int src_is_join) { uint8_t buf[1000]; @@ -4608,7 +4567,7 @@ static int recv_joinprune(struct vty *vty, uint16_t num_pruned; /* Find interface */ - ifname = argv[0]; + ifname = argv[0]->arg; ifp = if_lookup_by_name(ifname); if (!ifp) { vty_out(vty, "No such interface name %s%s", @@ -4616,10 +4575,10 @@ static int recv_joinprune(struct vty *vty, return CMD_WARNING; } - neigh_holdtime = atoi(argv[1]); + neigh_holdtime = atoi(argv[1]->arg); /* Neighbor destination address */ - neigh_dst_str = argv[2]; + neigh_dst_str = argv[2]->arg; result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr); if (result <= 0) { vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s", @@ -4628,7 +4587,7 @@ static int recv_joinprune(struct vty *vty, } /* Neighbor source address */ - neigh_src_str = argv[3]; + neigh_src_str = argv[3]->arg; result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr); if (result <= 0) { vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s", @@ -4637,7 +4596,7 @@ static int recv_joinprune(struct vty *vty, } /* Multicast group address */ - group_str = argv[4]; + group_str = argv[4]->arg; result = inet_pton(AF_INET, group_str, &group_addr); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4646,7 +4605,7 @@ static int recv_joinprune(struct vty *vty, } /* Multicast source address */ - source_str = argv[5]; + source_str = argv[5]->arg; result = inet_pton(AF_INET, source_str, &source_addr); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4767,7 +4726,7 @@ static int recv_joinprune(struct vty *vty, DEFUN (test_pim_receive_join, test_pim_receive_join_cmd, - "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive join INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4784,7 +4743,7 @@ DEFUN (test_pim_receive_join, DEFUN (test_pim_receive_prune, test_pim_receive_prune_cmd, - "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", + "test pim receive prune INTERFACE (0-65535) A.B.C.D A.B.C.D A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4801,7 +4760,7 @@ DEFUN (test_pim_receive_prune, DEFUN (test_pim_receive_upcall, test_pim_receive_upcall_cmd, - "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D", + "test pim receive upcall <nocache|wrongvif|wholepkt> (0-65535) A.B.C.D A.B.C.D", "Test\n" "Test PIM protocol\n" "Test PIM message reception\n" @@ -4813,13 +4772,17 @@ DEFUN (test_pim_receive_upcall, "Multicast group address\n" "Multicast source address\n") { + int idx_type = 4; + int idx_number = 5; + int idx_ipv4 = 6; + int idx_ipv4_2 = 7; struct igmpmsg msg; const char *upcall_type; const char *group_str; const char *source_str; int result; - upcall_type = argv[0]; + upcall_type = argv[idx_type]->arg; if (upcall_type[0] == 'n') msg.im_msgtype = IGMPMSG_NOCACHE; @@ -4833,10 +4796,10 @@ DEFUN (test_pim_receive_upcall, return CMD_WARNING; } - msg.im_vif = atoi(argv[1]); + msg.im_vif = atoi(argv[idx_number]->arg); /* Group address */ - group_str = argv[2]; + group_str = argv[idx_ipv4]->arg; result = inet_pton(AF_INET, group_str, &msg.im_dst); if (result <= 0) { vty_out(vty, "Bad group address %s: errno=%d: %s%s", @@ -4845,7 +4808,7 @@ DEFUN (test_pim_receive_upcall, } /* Source address */ - source_str = argv[3]; + source_str = argv[idx_ipv4_2]->arg; result = inet_pton(AF_INET, source_str, &msg.im_src); if (result <= 0) { vty_out(vty, "Bad source address %s: errno=%d: %s%s", @@ -4901,7 +4864,6 @@ void pim_cmd_init() install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd); install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd); install_element (INTERFACE_NODE, &interface_ip_pim_hello_cmd); - install_element (INTERFACE_NODE, &interface_ip_pim_hello_hold_cmd); install_element (INTERFACE_NODE, &interface_no_ip_pim_hello_cmd); // Static mroutes NEB @@ -4960,81 +4922,59 @@ void pim_cmd_init() install_element (ENABLE_NODE, &debug_igmp_cmd); install_element (ENABLE_NODE, &no_debug_igmp_cmd); - install_element (ENABLE_NODE, &undebug_igmp_cmd); install_element (ENABLE_NODE, &debug_igmp_events_cmd); install_element (ENABLE_NODE, &no_debug_igmp_events_cmd); - install_element (ENABLE_NODE, &undebug_igmp_events_cmd); install_element (ENABLE_NODE, &debug_igmp_packets_cmd); install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd); - install_element (ENABLE_NODE, &undebug_igmp_packets_cmd); install_element (ENABLE_NODE, &debug_igmp_trace_cmd); install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd); - install_element (ENABLE_NODE, &undebug_igmp_trace_cmd); install_element (ENABLE_NODE, &debug_mroute_cmd); install_element (ENABLE_NODE, &no_debug_mroute_cmd); install_element (ENABLE_NODE, &debug_static_cmd); install_element (ENABLE_NODE, &no_debug_static_cmd); install_element (ENABLE_NODE, &debug_pim_cmd); install_element (ENABLE_NODE, &no_debug_pim_cmd); - install_element (ENABLE_NODE, &undebug_pim_cmd); install_element (ENABLE_NODE, &debug_pim_events_cmd); install_element (ENABLE_NODE, &no_debug_pim_events_cmd); - install_element (ENABLE_NODE, &undebug_pim_events_cmd); install_element (ENABLE_NODE, &debug_pim_packets_cmd); install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd); install_element (ENABLE_NODE, &no_debug_pim_packets_cmd); install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd); - install_element (ENABLE_NODE, &undebug_pim_packets_cmd); install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd); install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd); - install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd); install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd); install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd); - install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd); install_element (ENABLE_NODE, &debug_pim_trace_cmd); install_element (ENABLE_NODE, &no_debug_pim_trace_cmd); - install_element (ENABLE_NODE, &undebug_pim_trace_cmd); install_element (ENABLE_NODE, &debug_ssmpingd_cmd); install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd); - install_element (ENABLE_NODE, &undebug_ssmpingd_cmd); install_element (ENABLE_NODE, &debug_pim_zebra_cmd); install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd); - install_element (ENABLE_NODE, &undebug_pim_zebra_cmd); install_element (CONFIG_NODE, &debug_igmp_cmd); install_element (CONFIG_NODE, &no_debug_igmp_cmd); - install_element (CONFIG_NODE, &undebug_igmp_cmd); install_element (CONFIG_NODE, &debug_igmp_events_cmd); install_element (CONFIG_NODE, &no_debug_igmp_events_cmd); - install_element (CONFIG_NODE, &undebug_igmp_events_cmd); install_element (CONFIG_NODE, &debug_igmp_packets_cmd); install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd); - install_element (CONFIG_NODE, &undebug_igmp_packets_cmd); install_element (CONFIG_NODE, &debug_igmp_trace_cmd); install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd); - install_element (CONFIG_NODE, &undebug_igmp_trace_cmd); install_element (CONFIG_NODE, &debug_mroute_cmd); install_element (CONFIG_NODE, &no_debug_mroute_cmd); install_element (CONFIG_NODE, &debug_static_cmd); install_element (CONFIG_NODE, &no_debug_static_cmd); install_element (CONFIG_NODE, &debug_pim_cmd); install_element (CONFIG_NODE, &no_debug_pim_cmd); - install_element (CONFIG_NODE, &undebug_pim_cmd); install_element (CONFIG_NODE, &debug_pim_events_cmd); install_element (CONFIG_NODE, &no_debug_pim_events_cmd); - install_element (CONFIG_NODE, &undebug_pim_events_cmd); install_element (CONFIG_NODE, &debug_pim_packets_cmd); install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd); install_element (CONFIG_NODE, &no_debug_pim_packets_cmd); install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd); - install_element (CONFIG_NODE, &undebug_pim_packets_cmd); install_element (CONFIG_NODE, &debug_pim_trace_cmd); install_element (CONFIG_NODE, &no_debug_pim_trace_cmd); - install_element (CONFIG_NODE, &undebug_pim_trace_cmd); install_element (CONFIG_NODE, &debug_ssmpingd_cmd); install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd); - install_element (CONFIG_NODE, &undebug_ssmpingd_cmd); install_element (CONFIG_NODE, &debug_pim_zebra_cmd); install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd); - install_element (CONFIG_NODE, &undebug_pim_zebra_cmd); } |
