From 39530dfe75a574dbf283ac39fcbee5481bd4aaae Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Wed, 26 Apr 2017 22:39:10 +0000 Subject: Problem with DEFUNSH in vtysh, issue #358 Signed-off-by: Daniel Walton --- vtysh/vtysh.c | 128 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 53 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 1e70858df..682cd99c2 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1134,81 +1134,99 @@ DEFUNSH (VTYSH_BGPD, } DEFUNSH (VTYSH_BGPD, - address_family_encapv4, - address_family_encapv4_cmd, - "address-family ", - "Enter Address Family command mode\n" + address_family_encapv4, + address_family_encapv4_cmd, + "address-family [ipv4] ", + "Enter Address Family command mode\n" + "Address Family\n" "Address Family\n" - "Address Family\n") + "Address Family\n") { vty->node = BGP_ENCAP_NODE; return CMD_SUCCESS; } DEFUNSH (VTYSH_BGPD, - address_family_encapv6, - address_family_encapv6_cmd, - "address-family encapv6", - "Enter Address Family command mode\n" - "Address Family\n") + address_family_encapv6, + address_family_encapv6_cmd, + "address-family [ipv6] encapv6", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family\n") { vty->node = BGP_ENCAPV6_NODE; return CMD_SUCCESS; } DEFUNSH (VTYSH_BGPD, - address_family_ipv4_unicast, - address_family_ipv4_unicast_cmd, - "address-family ipv4 []", - "Enter Address Family command mode\n" - "Address Family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - "Address Family Modifier\n") + address_family_ipv4, + address_family_ipv4_cmd, + "address-family ipv4 [unicast]", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family Modifier\n") { - int idx = 0; - - if (argv_find (argv, argc, "multicast", &idx)) - vty->node = BGP_IPV4M_NODE; - - else if (argv_find (argv, argc, "encap", &idx)) - vty->node = BGP_ENCAP_NODE; - - else if (argv_find (argv, argc, "vpn", &idx)) - vty->node = BGP_VPNV4_NODE; - - else - vty->node = BGP_IPV4_NODE; - + vty->node = BGP_IPV4_NODE; return CMD_SUCCESS; } DEFUNSH (VTYSH_BGPD, - address_family_ipv6, - address_family_ipv6_cmd, - "address-family ipv6 []", - "Enter Address Family command mode\n" - "Address Family\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - "Address Family Modifier\n" - "Address Family Modifier\n") + address_family_ipv4_multicast, + address_family_ipv4_multicast_cmd, + "address-family ipv4 multicast", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") { - int idx = 0; - - if (argv_find (argv, argc, "multicast", &idx)) - vty->node = BGP_IPV6M_NODE; + vty->node = BGP_IPV4M_NODE; + return CMD_SUCCESS; +} - else if (argv_find (argv, argc, "encap", &idx)) - vty->node = BGP_ENCAPV6_NODE; +DEFUNSH (VTYSH_BGPD, + address_family_ipv4_vpn, + address_family_ipv4_vpn_cmd, + "address-family ipv4 vpn", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") +{ + vty->node = BGP_VPNV4_NODE; + return CMD_SUCCESS; +} - else if (argv_find (argv, argc, "vpn", &idx)) - vty->node = BGP_VPNV6_NODE; +DEFUNSH (VTYSH_BGPD, + address_family_ipv6, + address_family_ipv6_cmd, + "address-family ipv6 [unicast]", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") +{ + vty->node = BGP_IPV6_NODE; + return CMD_SUCCESS; +} - else - vty->node = BGP_IPV6_NODE; +DEFUNSH (VTYSH_BGPD, + address_family_ipv6_multicast, + address_family_ipv6_multicast_cmd, + "address-family ipv6 multicast", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") +{ + vty->node = BGP_IPV6M_NODE; + return CMD_SUCCESS; +} +DEFUNSH (VTYSH_BGPD, + address_family_ipv6_vpn, + address_family_ipv6_vpn_cmd, + "address-family ipv6 vpn", + "Enter Address Family command mode\n" + "Address Family\n" + "Address Family modifier\n") +{ + vty->node = BGP_VPNV6_NODE; return CMD_SUCCESS; } @@ -3335,8 +3353,12 @@ vtysh_init_vty (void) install_element (BGP_NODE, &vnc_nve_group_cmd); install_element (BGP_NODE, &vnc_l2_group_cmd); #endif - install_element (BGP_NODE, &address_family_ipv4_unicast_cmd); + install_element (BGP_NODE, &address_family_ipv4_cmd); + install_element (BGP_NODE, &address_family_ipv4_multicast_cmd); + install_element (BGP_NODE, &address_family_ipv4_vpn_cmd); install_element (BGP_NODE, &address_family_ipv6_cmd); + install_element (BGP_NODE, &address_family_ipv6_multicast_cmd); + install_element (BGP_NODE, &address_family_ipv6_vpn_cmd); install_element (BGP_NODE, &address_family_evpn_cmd); install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); -- cgit v1.2.3