Merge branch 'vtysh-grammar'

Conflicts:
	isisd/isisd.c
	lib/Makefile.am
	lib/thread.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2016-11-28 17:56:29 +01:00
commit 82992fed8c
136 changed files with 15085 additions and 31071 deletions

View File

@ -27,6 +27,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "vty.h"
#include "log.h"
#include "stream.h"
#include "command.h"
#include "jhash.h"
#include "queue.h"
#include "filter.h"

View File

@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "queue.h"
#include "table.h"
#include "filter.h"
#include "command.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"

View File

@ -555,15 +555,16 @@ bgp_bfd_show_info(struct vty *vty, struct peer *peer, u_char use_json, json_obje
DEFUN (neighbor_bfd,
neighbor_bfd_cmd,
NEIGHBOR_CMD2 "bfd",
"neighbor <A.B.C.D|X:X::X:X|WORD> bfd",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enables BFD support\n")
{
int idx_peer = 1;
struct peer *peer;
int ret;
peer = peer_and_group_lookup_vty (vty, argv[0]);
peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
@ -578,7 +579,7 @@ DEFUN (neighbor_bfd,
DEFUN (neighbor_bfd_param,
neighbor_bfd_param_cmd,
NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
"neighbor <A.B.C.D|X:X::X:X|WORD> bfd (2-255) (50-60000) (50-60000)",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enables BFD support\n"
@ -586,17 +587,21 @@ DEFUN (neighbor_bfd_param,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
int idx_peer = 1;
int idx_number_1 = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct peer *peer;
u_int32_t rx_val;
u_int32_t tx_val;
u_int8_t dm_val;
int ret;
peer = peer_and_group_lookup_vty (vty, argv[0]);
peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (!peer)
return CMD_WARNING;
if ((ret = bfd_validate_param (vty, argv[1], argv[2], argv[3], &dm_val,
if ((ret = bfd_validate_param (vty, argv[idx_number_1]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS)
return ret;
@ -610,23 +615,26 @@ DEFUN (neighbor_bfd_param,
DEFUN_HIDDEN (neighbor_bfd_type,
neighbor_bfd_type_cmd,
NEIGHBOR_CMD2 "bfd " BFD_CMD_TYPE,
"neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enables BFD support\n"
"Session type\n")
"Multihop session\n"
"Single hop session\n")
{
int idx_peer = 1;
int idx_hop = 3;
struct peer *peer;
enum bfd_sess_type type;
int ret;
peer = peer_and_group_lookup_vty (vty, argv[0]);
peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (!peer)
return CMD_WARNING;
if (!strcmp(argv[1], "singlehop"))
if (!strcmp(argv[idx_hop]->arg, "singlehop"))
type = BFD_TYPE_SINGLEHOP;
else if (!strcmp(argv[1], "multihop"))
else if (!strcmp(argv[idx_hop]->arg, "multihop"))
type = BFD_TYPE_MULTIHOP;
else
return CMD_WARNING;
@ -640,16 +648,20 @@ DEFUN_HIDDEN (neighbor_bfd_type,
DEFUN (no_neighbor_bfd,
no_neighbor_bfd_cmd,
NO_NEIGHBOR_CMD2 "bfd",
"no neighbor <A.B.C.D|X:X::X:X|WORD> bfd [(2-255) (50-60000) (50-60000)]",
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Disables BFD support\n")
"Disables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")
{
int idx_peer = 2;
struct peer *peer;
int ret;
peer = peer_and_group_lookup_vty (vty, argv[0]);
peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
@ -660,30 +672,21 @@ DEFUN (no_neighbor_bfd,
return CMD_SUCCESS;
}
ALIAS (no_neighbor_bfd,
no_neighbor_bfd_val_cmd,
NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Disables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")
DEFUN_HIDDEN (no_neighbor_bfd_type,
no_neighbor_bfd_type_cmd,
NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_TYPE,
"no neighbor <A.B.C.D|X:X::X:X|WORD> bfd <multihop|singlehop>",
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Disables BFD support\n"
"Session type\n")
{
int idx_peer = 2;
struct peer *peer;
int ret;
peer = peer_and_group_lookup_vty (vty, argv[0]);
peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
@ -711,6 +714,5 @@ bgp_bfd_init(void)
install_element (BGP_NODE, &neighbor_bfd_param_cmd);
install_element (BGP_NODE, &neighbor_bfd_type_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_val_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_type_cmd);
}

View File

@ -20,6 +20,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include <zebra.h>
#include "command.h"
#include "hash.h"
#include "memory.h"

View File

@ -621,7 +621,7 @@ DEFUN (debug_bgp_neighbor_events,
DEFUN (debug_bgp_neighbor_events_peer,
debug_bgp_neighbor_events_peer_cmd,
"debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)",
"debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
DEBUG_STR
BGP_STR
"BGP Neighbor Events\n"
@ -629,7 +629,8 @@ DEFUN (debug_bgp_neighbor_events_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
const char *host = argv[0];
int idx_peer = 3;
const char *host = argv[idx_peer]->arg;
if (!bgp_debug_neighbor_events_peers)
bgp_debug_neighbor_events_peers = list_new ();
@ -674,7 +675,7 @@ DEFUN (no_debug_bgp_neighbor_events,
DEFUN (no_debug_bgp_neighbor_events_peer,
no_debug_bgp_neighbor_events_peer_cmd,
"no debug bgp neighbor-events (A.B.C.D|X:X::X:X|WORD)",
"no debug bgp neighbor-events <A.B.C.D|X:X::X:X|WORD>",
NO_STR
DEBUG_STR
BGP_STR
@ -683,8 +684,9 @@ DEFUN (no_debug_bgp_neighbor_events_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
int idx_peer = 4;
int found_peer = 0;
const char *host = argv[0];
const char *host = argv[idx_peer]->arg;
if (bgp_debug_neighbor_events_peers && !list_isempty(bgp_debug_neighbor_events_peers))
{
@ -765,7 +767,7 @@ DEFUN (debug_bgp_keepalive,
DEFUN (debug_bgp_keepalive_peer,
debug_bgp_keepalive_peer_cmd,
"debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
"debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
DEBUG_STR
BGP_STR
"BGP Neighbor Events\n"
@ -773,7 +775,8 @@ DEFUN (debug_bgp_keepalive_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
const char *host = argv[0];
int idx_peer = 3;
const char *host = argv[idx_peer]->arg;
if (!bgp_debug_keepalive_peers)
bgp_debug_keepalive_peers = list_new ();
@ -818,7 +821,7 @@ DEFUN (no_debug_bgp_keepalive,
DEFUN (no_debug_bgp_keepalive_peer,
no_debug_bgp_keepalive_peer_cmd,
"no debug bgp keepalives (A.B.C.D|X:X::X:X|WORD)",
"no debug bgp keepalives <A.B.C.D|X:X::X:X|WORD>",
NO_STR
DEBUG_STR
BGP_STR
@ -827,8 +830,9 @@ DEFUN (no_debug_bgp_keepalive_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
int idx_peer = 4;
int found_peer = 0;
const char *host = argv[0];
const char *host = argv[idx_peer]->arg;
if (bgp_debug_keepalive_peers && !list_isempty(bgp_debug_keepalive_peers))
{
@ -854,19 +858,20 @@ DEFUN (no_debug_bgp_keepalive_peer,
/* debug bgp bestpath */
DEFUN (debug_bgp_bestpath_prefix,
debug_bgp_bestpath_prefix_cmd,
"debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)",
"debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
DEBUG_STR
BGP_STR
"BGP bestpath\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 3;
struct prefix *argv_p;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -880,7 +885,7 @@ DEFUN (debug_bgp_bestpath_prefix,
if (bgp_debug_list_has_entry(bgp_debug_bestpath_prefixes, NULL, argv_p))
{
vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP bestptah debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -893,7 +898,7 @@ DEFUN (debug_bgp_bestpath_prefix,
else
{
TERM_DEBUG_ON (bestpath, BESTPATH);
vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP bestpath debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
}
return CMD_SUCCESS;
@ -901,21 +906,22 @@ DEFUN (debug_bgp_bestpath_prefix,
DEFUN (no_debug_bgp_bestpath_prefix,
no_debug_bgp_bestpath_prefix_cmd,
"no debug bgp bestpath (A.B.C.D/M|X:X::X:X/M)",
"no debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>",
NO_STR
DEBUG_STR
BGP_STR
"BGP bestpath\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p;
int found_prefix = 0;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -942,9 +948,9 @@ DEFUN (no_debug_bgp_bestpath_prefix,
}
if (found_prefix)
vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP bestpath debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else
vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP bestpath debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -997,29 +1003,30 @@ DEFUN (debug_bgp_update,
DEFUN (debug_bgp_update_direct,
debug_bgp_update_direct_cmd,
"debug bgp updates (in|out)",
"debug bgp updates <in|out>",
DEBUG_STR
BGP_STR
"BGP updates\n"
"Inbound updates\n"
"Outbound updates\n")
{
int idx_in_out = 3;
if (strncmp ("i", argv[0], 1) == 0)
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
bgp_debug_list_free(bgp_debug_update_in_peers);
else
bgp_debug_list_free(bgp_debug_update_out_peers);
if (vty->node == CONFIG_NODE)
{
if (strncmp ("i", argv[0], 1) == 0)
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
DEBUG_ON (update, UPDATE_IN);
else
DEBUG_ON (update, UPDATE_OUT);
}
else
{
if (strncmp ("i", argv[0], 1) == 0)
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
{
TERM_DEBUG_ON (update, UPDATE_IN);
vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
@ -1035,7 +1042,7 @@ DEFUN (debug_bgp_update_direct,
DEFUN (debug_bgp_update_direct_peer,
debug_bgp_update_direct_peer_cmd,
"debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
"debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
DEBUG_STR
BGP_STR
"BGP updates\n"
@ -1045,7 +1052,9 @@ DEFUN (debug_bgp_update_direct_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
const char *host = argv[1];
int idx_in_out = 3;
int idx_peer = 4;
const char *host = argv[idx_peer]->arg;
int inbound;
if (!bgp_debug_update_in_peers)
@ -1054,7 +1063,7 @@ DEFUN (debug_bgp_update_direct_peer,
if (!bgp_debug_update_out_peers)
bgp_debug_update_out_peers = list_new ();
if (strncmp ("i", argv[0], 1) == 0)
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
inbound = 1;
else
inbound = 0;
@ -1116,12 +1125,12 @@ DEFUN (debug_bgp_update_direct_peer,
if (inbound)
{
TERM_DEBUG_ON (update, UPDATE_IN);
vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging is on (inbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
}
else
{
TERM_DEBUG_ON (update, UPDATE_OUT);
vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging is on (outbound) for %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
}
}
return CMD_SUCCESS;
@ -1129,7 +1138,7 @@ DEFUN (debug_bgp_update_direct_peer,
DEFUN (no_debug_bgp_update_direct,
no_debug_bgp_update_direct_cmd,
"no debug bgp updates (in|out)",
"no debug bgp updates <in|out>",
NO_STR
DEBUG_STR
BGP_STR
@ -1137,7 +1146,8 @@ DEFUN (no_debug_bgp_update_direct,
"Inbound updates\n"
"Outbound updates\n")
{
if (strncmp ("i", argv[0], 1) == 0)
int idx_in_out = 4;
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
{
bgp_debug_list_free(bgp_debug_update_in_peers);
@ -1171,7 +1181,7 @@ DEFUN (no_debug_bgp_update_direct,
DEFUN (no_debug_bgp_update_direct_peer,
no_debug_bgp_update_direct_peer_cmd,
"no debug bgp updates (in|out) (A.B.C.D|X:X::X:X|WORD)",
"no debug bgp updates <in|out> <A.B.C.D|X:X::X:X|WORD>",
NO_STR
DEBUG_STR
BGP_STR
@ -1182,11 +1192,13 @@ DEFUN (no_debug_bgp_update_direct_peer,
"BGP IPv6 neighbor to debug\n"
"BGP neighbor on interface to debug\n")
{
int idx_in_out = 4;
int idx_peer = 5;
int inbound;
int found_peer = 0;
const char *host = argv[1];
const char *host = argv[idx_peer]->arg;
if (strncmp ("i", argv[0], 1) == 0)
if (strncmp ("i", argv[idx_in_out]->arg, 1) == 0)
inbound = 1;
else
inbound = 0;
@ -1261,20 +1273,21 @@ DEFUN (no_debug_bgp_update_direct_peer,
DEFUN (debug_bgp_update_prefix,
debug_bgp_update_prefix_cmd,
"debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
"debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
DEBUG_STR
BGP_STR
"BGP updates\n"
"Specify a prefix to debug\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -1288,7 +1301,7 @@ DEFUN (debug_bgp_update_prefix,
if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p))
{
vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -1301,7 +1314,7 @@ DEFUN (debug_bgp_update_prefix,
else
{
TERM_DEBUG_ON (update, UPDATE_PREFIX);
vty_out (vty, "BGP updates debugging is on for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
}
return CMD_SUCCESS;
@ -1309,22 +1322,23 @@ DEFUN (debug_bgp_update_prefix,
DEFUN (no_debug_bgp_update_prefix,
no_debug_bgp_update_prefix_cmd,
"no debug bgp updates prefix (A.B.C.D/M|X:X::X:X/M)",
"no debug bgp updates prefix <A.B.C.D/M|X:X::X:X/M>",
NO_STR
DEBUG_STR
BGP_STR
"BGP updates\n"
"Specify a prefix to debug\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 5;
struct prefix *argv_p;
int found_prefix = 0;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -1351,9 +1365,9 @@ DEFUN (no_debug_bgp_update_prefix,
}
if (found_prefix)
vty_out (vty, "BGP updates debugging is off for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else
vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP updates debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -1408,20 +1422,21 @@ DEFUN (debug_bgp_zebra,
DEFUN (debug_bgp_zebra_prefix,
debug_bgp_zebra_prefix_cmd,
"debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
"debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
DEBUG_STR
BGP_STR
"BGP Zebra messages\n"
"Specify a prefix to debug\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 4;
struct prefix *argv_p;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -1434,7 +1449,7 @@ DEFUN (debug_bgp_zebra_prefix,
if (bgp_debug_list_has_entry(bgp_debug_zebra_prefixes, NULL, argv_p))
{
vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP zebra debugging is already enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -1445,7 +1460,7 @@ DEFUN (debug_bgp_zebra_prefix,
else
{
TERM_DEBUG_ON (zebra, ZEBRA);
vty_out (vty, "BGP zebra debugging is on for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP zebra debugging is on for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
}
return CMD_SUCCESS;
@ -1473,22 +1488,23 @@ DEFUN (no_debug_bgp_zebra,
DEFUN (no_debug_bgp_zebra_prefix,
no_debug_bgp_zebra_prefix_cmd,
"no debug bgp zebra prefix (A.B.C.D/M|X:X::X:X/M)",
"no debug bgp zebra prefix <A.B.C.D/M|X:X::X:X/M>",
NO_STR
DEBUG_STR
BGP_STR
"BGP Zebra messages\n"
"Specify a prefix to debug\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv6 prefix <network>/<length>\n")
"IPv4 prefix\n"
"IPv6 prefix\n")
{
int idx_ipv4_ipv6_prefixlen = 5;
struct prefix *argv_p;
int found_prefix = 0;
int ret;
argv_p = prefix_new();
ret = str2prefix (argv[0], argv_p);
ret = str2prefix (argv[idx_ipv4_ipv6_prefixlen]->arg, argv_p);
if (!ret)
{
prefix_free(argv_p);
@ -1513,9 +1529,9 @@ DEFUN (no_debug_bgp_zebra_prefix,
}
if (found_prefix)
vty_out (vty, "BGP zebra debugging is off for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP zebra debugging is off for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
else
vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "BGP zebra debugging was not enabled for %s%s", argv[idx_ipv4_ipv6_prefixlen]->arg, VTY_NEWLINE);
return CMD_SUCCESS;
}
@ -1555,12 +1571,6 @@ DEFUN (no_debug_bgp_allow_martians,
return CMD_SUCCESS;
}
ALIAS (no_debug_bgp_allow_martians,
undebug_bgp_allow_martians_cmd,
"undebug bgp allow-martians",
UNDEBUG_STR
BGP_STR
"BGP allow martian next hops\n")
/* debug bgp update-groups */
DEFUN (debug_bgp_update_groups,
@ -1905,7 +1915,6 @@ bgp_debug_init (void)
install_element (ENABLE_NODE, &no_debug_bgp_zebra_cmd);
install_element (CONFIG_NODE, &no_debug_bgp_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_allow_martians_cmd);
install_element (ENABLE_NODE, &undebug_bgp_allow_martians_cmd);
install_element (CONFIG_NODE, &no_debug_bgp_allow_martians_cmd);
install_element (ENABLE_NODE, &no_debug_bgp_update_groups_cmd);
install_element (CONFIG_NODE, &no_debug_bgp_update_groups_cmd);

View File

@ -737,7 +737,7 @@ bgp_dump_unset (struct vty *vty, struct bgp_dump *bgp_dump)
DEFUN (dump_bgp_all,
dump_bgp_all_cmd,
"dump bgp (all|all-et|updates|updates-et|routes-mrt) PATH [INTERVAL]",
"dump bgp <all|all-et|updates|updates-et|routes-mrt> PATH [INTERVAL]",
"Dump packet\n"
"BGP packet dump\n"
"Dump all BGP packets\nDump all BGP packets (Extended Timestamp Header)\n"
@ -746,13 +746,16 @@ DEFUN (dump_bgp_all,
"Output filename\n"
"Interval of output\n")
{
int idx_dump_routes = 2;
int idx_path = 3;
int idx_interval = 4;
int bgp_dump_type = 0;
const char *interval = NULL;
struct bgp_dump *bgp_dump_struct = NULL;
const struct bgp_dump_type_map *map = NULL;
for (map = bgp_dump_type_map; map->str; map++)
if (strcmp(argv[0], map->str) == 0)
if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0)
bgp_dump_type = map->type;
switch (bgp_dump_type)
@ -772,16 +775,16 @@ DEFUN (dump_bgp_all,
}
/* When an interval is given */
if (argc == 3)
interval = argv[2];
if (argc == idx_interval + 1)
interval = argv[idx_interval]->arg;
return bgp_dump_set (vty, bgp_dump_struct, bgp_dump_type,
argv[1], interval);
argv[idx_path]->arg, interval);
}
DEFUN (no_dump_bgp_all,
no_dump_bgp_all_cmd,
"no dump bgp (all|all-et|updates|updates-et|routes-mrt) [PATH] [INTERVAL]",
"no dump bgp <all|all-et|updates|updates-et|routes-mrt> [PATH [INTERVAL]]",
NO_STR
"Stop dump packet\n"
"Stop BGP packet dump\n"
@ -791,12 +794,13 @@ DEFUN (no_dump_bgp_all,
"Stop dump process updates-et\n"
"Stop dump process route-mrt\n")
{
int idx_dump_routes = 3;
int bgp_dump_type = 0;
const struct bgp_dump_type_map *map = NULL;
struct bgp_dump *bgp_dump_struct = NULL;
for (map = bgp_dump_type_map; map->str; map++)
if (strcmp(argv[0], map->str) == 0)
if (strcmp(argv[idx_dump_routes]->arg, map->str) == 0)
bgp_dump_type = map->type;
switch (bgp_dump_type)
@ -880,7 +884,7 @@ config_write_bgp_dump (struct vty *vty)
bgp_dump_updates.filename, bgp_dump_updates.interval_str,
VTY_NEWLINE);
else
vty_out (vty, "dump bgp updates %s%s",
vty_out (vty, "dump bgp %s %s%s", type_str,
bgp_dump_updates.filename, VTY_NEWLINE);
}
if (bgp_dump_routes.filename)
@ -889,6 +893,10 @@ config_write_bgp_dump (struct vty *vty)
vty_out (vty, "dump bgp routes-mrt %s %s%s",
bgp_dump_routes.filename, bgp_dump_routes.interval_str,
VTY_NEWLINE);
else
vty_out (vty, "dump bgp routes-mrt %s%s",
bgp_dump_routes.filename, VTY_NEWLINE);
}
return 0;
}

View File

@ -217,13 +217,16 @@ DEFUN (encap_network,
encap_network_cmd,
"network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"ENCAP Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
return bgp_static_set_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2], NULL);
int idx_ipv4 = 1;
int idx_rd = 3;
int idx_word = 5;
return bgp_static_set_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg, NULL);
}
/* For testing purpose, static route of ENCAP. */
@ -232,13 +235,16 @@ DEFUN (no_encap_network,
"no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
NO_STR
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"ENCAP Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[0], argv[1], argv[2]);
int idx_ipv4 = 2;
int idx_rd = 4;
int idx_word = 6;
return bgp_static_unset_safi (SAFI_ENCAP, vty, argv[idx_ipv4]->arg, argv[idx_rd]->arg, argv[idx_word]->arg);
}
static int
@ -500,10 +506,11 @@ DEFUN (show_bgp_ipv4_encap_rd,
"Display information for a route distinguisher\n"
"ENCAP Route Distinguisher\n")
{
int idx_rd = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -523,10 +530,11 @@ DEFUN (show_bgp_ipv6_encap_rd,
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
int idx_rd = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -572,10 +580,11 @@ DEFUN (show_bgp_ipv4_encap_rd_tags,
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
int idx_rd = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -595,10 +604,11 @@ DEFUN (show_bgp_ipv6_encap_rd_tags,
"ENCAP Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
int idx_rd = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -619,12 +629,13 @@ DEFUN (show_bgp_ipv4_encap_neighbor_routes,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
int idx_peer = 5;
union sockunion su;
struct peer *peer;
if (str2sockunion(argv[0], &su))
if (sockunion_str2su (argv[idx_peer]->arg))
{
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -649,12 +660,13 @@ DEFUN (show_bgp_ipv6_encap_neighbor_routes,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
int idx_peer = 5;
union sockunion su;
struct peer *peer;
if (str2sockunion(argv[0], &su))
if (str2sockunion(argv[idx_peer]->arg, &su))
{
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -671,7 +683,7 @@ DEFUN (show_bgp_ipv6_encap_neighbor_routes,
DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
show_bgp_ipv4_encap_rd_neighbor_routes_cmd,
"show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
"show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
SHOW_STR
BGP_STR
"Address Family\n"
@ -683,21 +695,23 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
int idx_rd = 5;
int idx_peer = 7;
int ret;
union sockunion su;
struct peer *peer;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (str2sockunion(argv[1], &su))
if (str2sockunion(argv[idx_peer]->arg, &su))
{
vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -713,7 +727,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
#ifdef HAVE_IPV6
DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes,
show_bgp_ipv6_encap_rd_neighbor_routes_cmd,
"show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes",
"show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
SHOW_STR
BGP_STR
"Address Family\n"
@ -725,21 +739,23 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes,
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
int idx_rd = 5;
int idx_peer = 7;
int ret;
union sockunion su;
struct peer *peer;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (str2sockunion(argv[1], &su))
if (str2sockunion(argv[idx_peer]->arg, &su))
{
vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -765,14 +781,15 @@ DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes,
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
int idx_peer = 5;
int ret;
struct peer *peer;
union sockunion su;
ret = str2sockunion (argv[0], &su);
ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -796,14 +813,15 @@ DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes,
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
int idx_peer = 5;
int ret;
struct peer *peer;
union sockunion su;
ret = str2sockunion (argv[0], &su);
ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -819,7 +837,7 @@ DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes,
DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd,
"show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
"show bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
SHOW_STR
BGP_STR
"Address Family\n"
@ -831,15 +849,17 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
int idx_rd = 5;
int idx_peer = 7;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
ret = str2sockunion (argv[1], &su);
ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -849,7 +869,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
return CMD_WARNING;
}
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -861,7 +881,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
#ifdef HAVE_IPV6
DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd,
"show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes",
"show bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
SHOW_STR
BGP_STR
"Address Family\n"
@ -873,15 +893,17 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
int idx_rd = 5;
int idx_peer = 7;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
ret = str2sockunion (argv[1], &su);
ret = str2sockunion (argv[idx_peer]->arg, &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed address: %s%s", argv[1], VTY_NEWLINE);
vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -891,7 +913,7 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
return CMD_WARNING;
}
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);

View File

@ -19,6 +19,7 @@
#include <zebra.h>
#include "command.h"
#include "memory.h"
#include "prefix.h"
#include "vty.h"

View File

@ -426,8 +426,9 @@ as_list_dup_check (struct as_list *aslist, struct as_filter *new)
return 0;
}
DEFUN (ip_as_path, ip_as_path_cmd,
"ip as-path access-list WORD (deny|permit) .LINE",
DEFUN (ip_as_path,
ip_as_path_cmd,
"ip as-path access-list WORD <deny|permit> LINE...",
IP_STR
"BGP autonomous system path filter\n"
"Specify an access list name\n"
@ -436,32 +437,28 @@ DEFUN (ip_as_path, ip_as_path_cmd,
"Specify packets to forward\n"
"A regular-expression to match the BGP AS paths\n")
{
int idx = 0;
enum as_filter_type type;
struct as_filter *asfilter;
struct as_list *aslist;
regex_t *regex;
char *regstr;
/* Retrieve access list name */
char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
/* Check the filter type. */
if (strncmp (argv[1], "p", 1) == 0)
type = AS_FILTER_PERMIT;
else if (strncmp (argv[1], "d", 1) == 0)
type = AS_FILTER_DENY;
else
{
vty_out (vty, "filter type must be [permit|deny]%s", VTY_NEWLINE);
return CMD_WARNING;
}
type = argv_find (argv, argc, "deny", &idx) ? AS_FILTER_DENY : AS_FILTER_PERMIT;
/* Check AS path regex. */
regstr = argv_concat(argv, argc, 2);
argv_find (argv, argc, "LINE", &idx);
regstr = argv_concat(argv, argc, idx);
regex = bgp_regcomp (regstr);
if (!regex)
{
vty_out (vty, "can't compile regexp %s%s", regstr, VTY_NEWLINE);
XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
@ -470,7 +467,7 @@ DEFUN (ip_as_path, ip_as_path_cmd,
XFREE (MTYPE_TMP, regstr);
/* Install new filter to the access_list. */
aslist = as_list_get (argv[0]);
aslist = as_list_get (alname);
/* Duplicate insertion check. */;
if (as_list_dup_check (aslist, asfilter))
@ -483,7 +480,7 @@ DEFUN (ip_as_path, ip_as_path_cmd,
DEFUN (no_ip_as_path,
no_ip_as_path_cmd,
"no ip as-path access-list WORD (deny|permit) .LINE",
"no ip as-path access-list WORD <deny|permit> LINE...",
NO_STR
IP_STR
"BGP autonomous system path filter\n"
@ -493,25 +490,28 @@ DEFUN (no_ip_as_path,
"Specify packets to forward\n"
"A regular-expression to match the BGP AS paths\n")
{
int idx = 0;
enum as_filter_type type;
struct as_filter *asfilter;
struct as_list *aslist;
char *regstr;
regex_t *regex;
char *aslistname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
/* Lookup AS list from AS path list. */
aslist = as_list_lookup (argv[0]);
aslist = as_list_lookup (aslistname);
if (aslist == NULL)
{
vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[0],
vty_out (vty, "ip as-path access-list %s doesn't exist%s", aslistname,
VTY_NEWLINE);
return CMD_WARNING;
}
/* Check the filter type. */
if (strncmp (argv[1], "p", 1) == 0)
if (argv_find (argv, argc, "permit", &idx))
type = AS_FILTER_PERMIT;
else if (strncmp (argv[1], "d", 1) == 0)
else if (argv_find (argv, argc, "deny", &idx))
type = AS_FILTER_DENY;
else
{
@ -520,14 +520,14 @@ DEFUN (no_ip_as_path,
}
/* Compile AS path. */
regstr = argv_concat(argv, argc, 2);
argv_find (argv, argc, "LINE", &idx);
regstr = argv_concat(argv, argc, idx);
regex = bgp_regcomp (regstr);
if (!regex)
{
vty_out (vty, "can't compile regexp %s%s", regstr, VTY_NEWLINE);
XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
@ -557,12 +557,13 @@ DEFUN (no_ip_as_path_all,
"Specify an access list name\n"
"Regular expression access list name\n")
{
int idx_word = 4;
struct as_list *aslist;
aslist = as_list_lookup (argv[0]);
aslist = as_list_lookup (argv[idx_word]->arg);
if (aslist == NULL)
{
vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[0],
vty_out (vty, "ip as-path access-list %s doesn't exist%s", argv[idx_word]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -571,7 +572,7 @@ DEFUN (no_ip_as_path_all,
/* Run hook function. */
if (as_list_master.delete_hook)
(*as_list_master.delete_hook) (argv[0]);
(*as_list_master.delete_hook) (argv[idx_word]->arg);
return CMD_SUCCESS;
}
@ -627,9 +628,10 @@ DEFUN (show_ip_as_path_access_list,
"List AS path access lists\n"
"AS path access list name\n")
{
int idx_word = 3;
struct as_list *aslist;
aslist = as_list_lookup (argv[0]);
aslist = as_list_lookup (argv[idx_word]->arg);
if (aslist)
as_list_show (vty, aslist);

View File

@ -33,6 +33,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "workqueue.h"
#include "queue.h"
#include "filter.h"
#include "command.h"
#include "lib/json.h"
#include "bgpd/bgpd.h"

View File

@ -445,20 +445,23 @@ DEFUN (vpnv4_network,
vpnv4_network_cmd,
"network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], NULL);
int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
int idx_word = 5;
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL);
}
DEFUN (vpnv4_network_route_map,
vpnv4_network_route_map_cmd,
"network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD",
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
"BGP tag\n"
@ -466,7 +469,11 @@ DEFUN (vpnv4_network_route_map,
"route map\n"
"route map name\n")
{
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2], argv[3]);
int idx_ipv4_prefixlen = 1;
int idx_ext_community = 3;
int idx_word = 5;
int idx_word_2 = 7;
return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg);
}
/* For testing purpose, static route of MPLS-VPN. */
@ -475,13 +482,16 @@ DEFUN (no_vpnv4_network,
"no network A.B.C.D/M rd ASN:nn_or_IP-address:nn tag WORD",
NO_STR
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"IPv4 prefix\n"
"Specify Route Distinguisher\n"
"VPN Route Distinguisher\n"
"BGP tag\n"
"tag value\n")
{
return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]);
int idx_ipv4_prefixlen = 2;
int idx_ext_community = 4;
int idx_word = 6;
return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg);
}
static int
@ -887,7 +897,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
DEFUN (show_bgp_ivp4_vpn,
show_bgp_ipv4_vpn_cmd,
"show bgp ipv4 vpn {json}",
"show bgp ipv4 vpn [json]",
SHOW_STR
BGP_STR
"Address Family\n"
@ -898,7 +908,7 @@ DEFUN (show_bgp_ivp4_vpn,
DEFUN (show_bgp_ipv6_vpn,
show_bgp_ipv6_vpn_cmd,
"show bgp ipv6 vpn {json}",
"show bgp ipv6 vpn [json]",
SHOW_STR
BGP_STR
"Address Family\n"
@ -909,7 +919,7 @@ DEFUN (show_bgp_ipv6_vpn,
DEFUN (show_bgp_ipv4_vpn_rd,
show_bgp_ipv4_vpn_rd_cmd,
"show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn {json}",
"show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn [json]",
SHOW_STR
BGP_STR
"Address Family\n"
@ -918,10 +928,11 @@ DEFUN (show_bgp_ipv4_vpn_rd,
"VPN Route Distinguisher\n"
JSON_STR)
{
int idx_ext_community = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -932,7 +943,7 @@ DEFUN (show_bgp_ipv4_vpn_rd,
DEFUN (show_bgp_ipv6_vpn_rd,
show_bgp_ipv6_vpn_rd_cmd,
"show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn {json}",
"show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn [json]",
SHOW_STR
BGP_STR
"Address Family\n"
@ -941,10 +952,11 @@ DEFUN (show_bgp_ipv6_vpn_rd,
"VPN Route Distinguisher\n"
JSON_STR)
{
int idx_ext_community = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (!ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -960,7 +972,7 @@ DEFUN (show_ip_bgp_vpnv4_all,
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information about all VPNv4 NLRIs\n")
{
return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0);
@ -972,14 +984,15 @@ DEFUN (show_ip_bgp_vpnv4_rd,
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n")
{
int idx_ext_community = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -994,7 +1007,7 @@ DEFUN (show_ip_bgp_vpnv4_all_tags,
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information about all VPNv4 NLRIs\n"
"Display BGP tags for prefixes\n")
{
@ -1007,15 +1020,16 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags,
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
int idx_ext_community = 5;
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
@ -1026,23 +1040,24 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags,
DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
show_ip_bgp_vpnv4_all_neighbor_routes_cmd,
"show ip bgp vpnv4 all neighbors A.B.C.D routes {json}",
"show ip bgp vpnv4 all neighbors A.B.C.D routes [json]",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information about all VPNv4 NLRIs\n"
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Display routes learned from neighbor\n"
"JavaScript Object Notation\n")
{
int idx_ipv4 = 6;
union sockunion su;
struct peer *peer;
int ret;
u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[0], &su);
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0)
{
if (uj)
@ -1054,7 +1069,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
json_object_free(json_no);
}
else
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -1079,11 +1094,11 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
show_ip_bgp_vpnv4_rd_neighbor_routes_cmd,
"show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes {json}",
"show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
"Detailed information on TCP and BGP neighbor connections\n"
@ -1091,13 +1106,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
"Display routes learned from neighbor\n"
"JavaScript Object Notation\n")
{
int idx_ext_community = 5;
int idx_ipv4 = 7;
int ret;
union sockunion su;
struct peer *peer;
struct prefix_rd prd;
u_char uj = use_json(argc, argv);
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
if (uj)
@ -1113,7 +1130,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
return CMD_WARNING;
}
ret = str2sockunion (argv[1], &su);
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0)
{
if (uj)
@ -1125,7 +1142,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
json_object_free(json_no);
}
else
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -1150,23 +1167,24 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd,
"show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes {json}",
"show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes [json]",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information about all VPNv4 NLRIs\n"
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n"
"JavaScript Object Notation\n")
{
int idx_ipv4 = 6;
int ret;
struct peer *peer;
union sockunion su;
u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[0], &su);
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0)
{
if (uj)
@ -1178,7 +1196,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
json_object_free(json_no);
}
else
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -1202,11 +1220,11 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd,
"show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes {json}",
"show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Address Family\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
"Detailed information on TCP and BGP neighbor connections\n"
@ -1214,13 +1232,15 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
"Display the routes advertised to a BGP neighbor\n"
"JavaScript Object Notation\n")
{
int idx_ext_community = 5;
int idx_ipv4 = 7;
int ret;
struct peer *peer;
struct prefix_rd prd;
union sockunion su;
u_char uj = use_json(argc, argv);
ret = str2sockunion (argv[1], &su);
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0)
{
if (uj)
@ -1232,7 +1252,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
json_object_free(json_no);
}
else
vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
peer = peer_lookup (NULL, &su);
@ -1251,7 +1271,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes,
return CMD_WARNING;
}
ret = str2prefix_rd (argv[0], &prd);
ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd);
if (! ret)
{
if (uj)

View File

@ -494,41 +494,22 @@ bgp_show_all_instances_nexthops_vty (struct vty *vty)
DEFUN (show_ip_bgp_nexthop,
show_ip_bgp_nexthop_cmd,
"show ip bgp nexthop",
SHOW_STR
IP_STR
BGP_STR
"BGP nexthop table\n")
{
return show_ip_bgp_nexthop_table (vty, NULL, 0);
}
DEFUN (show_ip_bgp_nexthop_detail,
show_ip_bgp_nexthop_detail_cmd,
"show ip bgp nexthop detail",
SHOW_STR
IP_STR
BGP_STR
"BGP nexthop table\n")
{
return show_ip_bgp_nexthop_table (vty, NULL, 1);
}
DEFUN (show_ip_bgp_instance_nexthop,
show_ip_bgp_instance_nexthop_cmd,
"show ip bgp " BGP_INSTANCE_CMD " nexthop",
"show [ip] bgp [<view|vrf> VRFNAME] nexthop [detail]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
"BGP nexthop table\n")
{
return show_ip_bgp_nexthop_table (vty, argv[1], 0);
int idx = 0;
char *vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL;
int detail = argv_find (argv, argc, "detail", &idx) ? 1 : 0;
return show_ip_bgp_nexthop_table (vty, vrf, detail);
}
DEFUN (show_ip_bgp_instance_all_nexthop,
show_ip_bgp_instance_all_nexthop_cmd,
"show ip bgp " BGP_INSTANCE_ALL_CMD " nexthop",
"show [ip] bgp <view|vrf> all nexthop",
SHOW_STR
IP_STR
BGP_STR
@ -539,18 +520,6 @@ DEFUN (show_ip_bgp_instance_all_nexthop,
return CMD_SUCCESS;
}
DEFUN (show_ip_bgp_instance_nexthop_detail,
show_ip_bgp_instance_nexthop_detail_cmd,
"show ip bgp " BGP_INSTANCE_CMD " nexthop detail",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
"BGP nexthop table\n")
{
return show_ip_bgp_nexthop_table (vty, argv[1], 1);
}
void
bgp_scan_init (struct bgp *bgp)
{
@ -571,10 +540,7 @@ void
bgp_scan_vty_init (void)
{
install_element (VIEW_NODE, &show_ip_bgp_nexthop_cmd);
install_element (VIEW_NODE, &show_ip_bgp_nexthop_detail_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_all_nexthop_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_detail_cmd);
}
void

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "vty.h"
#include "queue.h"
#include "filter.h"
#include "command.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"

File diff suppressed because it is too large Load Diff

View File

@ -23,11 +23,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
struct bgp;
#define CMD_AS_RANGE "<1-4294967295>"
#define DYNAMIC_NEIGHBOR_LIMIT_RANGE "<1-5000>"
#define BGP_INSTANCE_CMD "(view|vrf) WORD"
#define BGP_INSTANCE_HELP_STR "BGP view\nBGP VRF\nView/VRF name\n"
#define BGP_INSTANCE_ALL_CMD "(view|vrf) all"
#define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n"
extern void bgp_vty_init (void);

View File

@ -20,7 +20,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include <zebra.h>
#include "lib/json.h"
#include "prefix.h"
#include "thread.h"
#include "buffer.h"
@ -42,6 +41,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "hash.h"
#include "jhash.h"
#include "table.h"
#include "lib/json.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"

View File

@ -2543,7 +2543,7 @@ register_add (
************************************************************************/
DEFUN (add_vnc_prefix_cost_life_lnh,
add_vnc_prefix_cost_life_lnh_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295> .LNH_OPTIONS",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295) .LNH_OPTIONS",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2569,7 +2569,7 @@ DEFUN (add_vnc_prefix_cost_life_lnh,
DEFUN (add_vnc_prefix_life_cost_lnh,
add_vnc_prefix_life_cost_lnh_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255> .LNH_OPTIONS",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255) .LNH_OPTIONS",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2595,7 +2595,7 @@ DEFUN (add_vnc_prefix_life_cost_lnh,
DEFUN (add_vnc_prefix_cost_lnh,
add_vnc_prefix_cost_lnh_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> .LNH_OPTIONS",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) .LNH_OPTIONS",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2619,7 +2619,7 @@ DEFUN (add_vnc_prefix_cost_lnh,
DEFUN (add_vnc_prefix_life_lnh,
add_vnc_prefix_life_lnh_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> .LNH_OPTIONS",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) .LNH_OPTIONS",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2643,7 +2643,7 @@ DEFUN (add_vnc_prefix_life_lnh,
DEFUN (add_vnc_prefix_lnh,
add_vnc_prefix_lnh_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) .LNH_OPTIONS",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> .LNH_OPTIONS",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2668,7 +2668,7 @@ DEFUN (add_vnc_prefix_lnh,
************************************************************************/
DEFUN (add_vnc_prefix_cost_life,
add_vnc_prefix_cost_life_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2694,7 +2694,7 @@ DEFUN (add_vnc_prefix_cost_life,
DEFUN (add_vnc_prefix_life_cost,
add_vnc_prefix_life_cost_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255>",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295) cost (0-255)",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2720,7 +2720,7 @@ DEFUN (add_vnc_prefix_life_cost,
DEFUN (add_vnc_prefix_cost,
add_vnc_prefix_cost_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2744,7 +2744,7 @@ DEFUN (add_vnc_prefix_cost,
DEFUN (add_vnc_prefix_life,
add_vnc_prefix_life_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2768,7 +2768,7 @@ DEFUN (add_vnc_prefix_life,
DEFUN (add_vnc_prefix,
add_vnc_prefix_cmd,
"add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)",
"add vnc prefix <A.B.C.D/M|X:X::X:X/M> vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>",
"Add registration\n"
"VNC Information\n"
"Add/modify prefix related infomation\n"
@ -2793,7 +2793,7 @@ DEFUN (add_vnc_prefix,
************************************************************************/
DEFUN (add_vnc_mac_vni_prefix_cost_life,
add_vnc_mac_vni_prefix_cost_life_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255> lifetime <1-4294967295>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255) lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2823,7 +2823,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life,
DEFUN (add_vnc_mac_vni_prefix_life,
add_vnc_mac_vni_prefix_life_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) lifetime <1-4294967295>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2850,7 +2850,7 @@ DEFUN (add_vnc_mac_vni_prefix_life,
DEFUN (add_vnc_mac_vni_prefix_cost,
add_vnc_mac_vni_prefix_cost_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M> cost (0-255)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2876,7 +2876,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost,
DEFUN (add_vnc_mac_vni_prefix,
add_vnc_mac_vni_prefix_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M)",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> prefix <A.B.C.D/M|X:X::X:X/M>",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2900,7 +2900,7 @@ DEFUN (add_vnc_mac_vni_prefix,
DEFUN (add_vnc_mac_vni_cost_life,
add_vnc_mac_vni_cost_life_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255) lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2927,7 +2927,7 @@ DEFUN (add_vnc_mac_vni_cost_life,
DEFUN (add_vnc_mac_vni_cost,
add_vnc_mac_vni_cost_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> cost (0-255)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2951,7 +2951,7 @@ DEFUN (add_vnc_mac_vni_cost,
DEFUN (add_vnc_mac_vni_life,
add_vnc_mac_vni_life_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X> lifetime (1-4294967295)",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -2976,7 +2976,7 @@ DEFUN (add_vnc_mac_vni_life,
DEFUN (add_vnc_mac_vni,
add_vnc_mac_vni_cmd,
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)",
"add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier (1-4294967295) vn <A.B.C.D|X:X::X:X> un <A.B.C.D|X:X::X:X>",
"Add registration\n"
"VNC Information\n"
"Add/modify mac address infomation\n"
@ -3720,7 +3720,7 @@ DEFUN (clear_vnc_nve_all,
DEFUN (clear_vnc_nve_vn_un,
clear_vnc_nve_vn_un_cmd,
"clear vnc nve vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)",
"clear vnc nve vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3750,7 +3750,7 @@ DEFUN (clear_vnc_nve_vn_un,
DEFUN (clear_vnc_nve_un_vn,
clear_vnc_nve_un_vn_cmd,
"clear vnc nve un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)",
"clear vnc nve un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3780,7 +3780,7 @@ DEFUN (clear_vnc_nve_un_vn,
DEFUN (clear_vnc_nve_vn,
clear_vnc_nve_vn_cmd,
"clear vnc nve vn (*|A.B.C.D|X:X::X:X)",
"clear vnc nve vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3805,7 +3805,7 @@ DEFUN (clear_vnc_nve_vn,
DEFUN (clear_vnc_nve_un,
clear_vnc_nve_un_cmd,
"clear vnc nve un (*|A.B.C.D|X:X::X:X)",
"clear vnc nve un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3838,7 +3838,7 @@ DEFUN (clear_vnc_nve_un,
*/
DEFUN (clear_vnc_prefix_vn_un,
clear_vnc_prefix_vn_un_cmd,
"clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)",
"clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3868,7 +3868,7 @@ DEFUN (clear_vnc_prefix_vn_un,
DEFUN (clear_vnc_prefix_un_vn,
clear_vnc_prefix_un_vn_cmd,
"clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)",
"clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3898,7 +3898,7 @@ DEFUN (clear_vnc_prefix_un_vn,
DEFUN (clear_vnc_prefix_un,
clear_vnc_prefix_un_cmd,
"clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X)",
"clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3924,7 +3924,7 @@ DEFUN (clear_vnc_prefix_un,
DEFUN (clear_vnc_prefix_vn,
clear_vnc_prefix_vn_cmd,
"clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X)",
"clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3950,7 +3950,7 @@ DEFUN (clear_vnc_prefix_vn,
DEFUN (clear_vnc_prefix_all,
clear_vnc_prefix_all_cmd,
"clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) *",
"clear vnc prefix <*|A.B.C.D/M|X:X::X:X/M> *",
"clear\n"
"VNC Information\n"
"Clear prefix registration infomation\n"
@ -3980,7 +3980,7 @@ DEFUN (clear_vnc_prefix_all,
*/
DEFUN (clear_vnc_mac_vn_un,
clear_vnc_mac_vn_un_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4015,7 +4015,7 @@ DEFUN (clear_vnc_mac_vn_un,
DEFUN (clear_vnc_mac_un_vn,
clear_vnc_mac_un_vn_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4049,7 +4049,7 @@ DEFUN (clear_vnc_mac_un_vn,
DEFUN (clear_vnc_mac_un,
clear_vnc_mac_un_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4078,7 +4078,7 @@ DEFUN (clear_vnc_mac_un,
DEFUN (clear_vnc_mac_vn,
clear_vnc_mac_vn_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4107,7 +4107,7 @@ DEFUN (clear_vnc_mac_vn,
DEFUN (clear_vnc_mac_all,
clear_vnc_mac_all_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) *",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> *",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4137,7 +4137,7 @@ DEFUN (clear_vnc_mac_all,
DEFUN (clear_vnc_mac_vn_un_prefix,
clear_vnc_mac_vn_un_prefix_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4176,7 +4176,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix,
DEFUN (clear_vnc_mac_un_vn_prefix,
clear_vnc_mac_un_vn_prefix_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M) prefix (*|A.B.C.D/M|X:X::X:X/M)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M> prefix <*|A.B.C.D/M|X:X::X:X/M>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4210,7 +4210,7 @@ DEFUN (clear_vnc_mac_un_vn_prefix,
DEFUN (clear_vnc_mac_un_prefix,
clear_vnc_mac_un_prefix_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> un <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4240,7 +4240,7 @@ DEFUN (clear_vnc_mac_un_prefix,
DEFUN (clear_vnc_mac_vn_prefix,
clear_vnc_mac_vn_prefix_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> vn <*|A.B.C.D|X:X::X:X> prefix <*|A.B.C.D/M|X:X::X:X/M>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4270,7 +4270,7 @@ DEFUN (clear_vnc_mac_vn_prefix,
DEFUN (clear_vnc_mac_all_prefix,
clear_vnc_mac_all_prefix_cmd,
"clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) prefix (*|A.B.C.D/M|X:X::X:X/M)",
"clear vnc mac <*|YY:YY:YY:YY:YY:YY> virtual-network-identifier <*|(1-4294967295)> prefix <*|A.B.C.D/M|X:X::X:X/M>",
"clear\n"
"VNC Information\n"
"Clear mac registration infomation\n"
@ -4554,7 +4554,7 @@ DEFUN (vnc_show_nves,
DEFUN (vnc_show_nves_ptct,
vnc_show_nves_ptct_cmd,
"show vnc nves (vn|un) (A.B.C.D|X:X::X:X)",
"show vnc nves <vn|un> <A.B.C.D|X:X::X:X>",
SHOW_STR
VNC_SHOW_STR
"List known NVEs\n"
@ -4636,7 +4636,7 @@ rfapi_show_registrations (
DEFUN (vnc_show_registrations_pfx,
vnc_show_registrations_pfx_cmd,
"show vnc registrations ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])",
"show vnc registrations <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>",
SHOW_STR
VNC_SHOW_STR
"List active prefix registrations\n"
@ -4749,7 +4749,7 @@ ALIAS (vnc_show_registrations_some_pfx,
DEFUN (vnc_show_responses_pfx,
vnc_show_responses_pfx_cmd,
"show vnc responses ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])",
"show vnc responses <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>",
SHOW_STR
VNC_SHOW_STR
"List recent query responses\n"
@ -4790,7 +4790,7 @@ ALIAS (vnc_show_responses_pfx,
DEFUN (vnc_show_responses_some_pfx,
vnc_show_responses_some_pfx_cmd,
"show vnc responses (active|removed) ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])",
"show vnc responses <active|removed> <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>",
SHOW_STR
VNC_SHOW_STR
"List recent query responses\n"
@ -4855,7 +4855,7 @@ ALIAS (vnc_show_responses_some_pfx,
DEFUN (show_vnc_queries_pfx,
show_vnc_queries_pfx_cmd,
"show vnc queries ([A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY])",
"show vnc queries <[A.B.C.D/M]|[X:X::X:X/M]|[YY:YY:YY:YY:YY:YY]>",
SHOW_STR
VNC_SHOW_STR
"List active queries\n"

View File

@ -56,7 +56,7 @@ struct vnc_debug vncdebug[] =
***********************************************************************/
DEFUN (debug_bgp_vnc,
debug_bgp_vnc_cmd,
"debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)",
"debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote>",
DEBUG_STR
BGP_STR
VNC_STR
@ -90,7 +90,7 @@ DEFUN (debug_bgp_vnc,
DEFUN (no_debug_bgp_vnc,
no_debug_bgp_vnc_cmd,
"no debug bgp vnc (rfapi-query|import-bi-attach|import-del-remote)",
"no debug bgp vnc <rfapi-query|import-bi-attach|import-del-remote>",
NO_STR
DEBUG_STR
BGP_STR

View File

@ -1420,6 +1420,17 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,
AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES])
dnl --------------------------------------
dnl checking for flex and bison
dnl --------------------------------------
AM_PROG_LEX
if test "x$LEX" != xflex; then
LEX="$SHELL $missing_dir/missing flex"
AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
AC_SUBST([LEXLIB], [''])
fi
AC_PROG_YACC
dnl -------------------
dnl capabilities checks
dnl -------------------

2
debian/control vendored
View File

@ -3,7 +3,7 @@ Section: net
Priority: optional
Maintainer: Christian Hammers <ch@debian.org>
Uploaders: Florian Weimer <fw@debian.org>
Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, po-debconf, autotools-dev, hardening-wrapper, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson0, libjson0-dev, dh-systemd, libsystemd-dev, python-ipaddr
Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, po-debconf, autotools-dev, hardening-wrapper, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson0, libjson0-dev, dh-systemd, libsystemd-dev, python-ipaddr, bison, flex
Standards-Version: 3.9.6
Homepage: http://www.quagga.net/
XS-Testsuite: autopkgtest

View File

@ -540,8 +540,7 @@ isis_redist_area_finish(struct isis_area *area)
DEFUN (isis_redistribute,
isis_redistribute_cmd,
"redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
" (level-1|level-2) {metric <0-16777215>|route-map WORD}",
"redistribute <ipv4|ipv6> <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table> <level-1|level-2> [<metric (0-16777215)|route-map WORD>]",
REDIST_STR
"Redistribute IPv4 routes\n"
"Redistribute IPv6 routes\n"
@ -553,18 +552,19 @@ DEFUN (isis_redistribute,
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_afi = 1;
int idx_protocol = 2;
int idx_level = 3;
int idx_metric_rmap = 4;
VTY_DECLVAR_CONTEXT (isis_area, area);
int family;
int afi;
int type;
int level;
unsigned long metric;
const char *routemap;
const char *routemap = NULL;
if (argc < 5)
return CMD_WARNING;
family = str2family(argv[0]);
family = str2family(argv[idx_afi]->arg);
if (family < 0)
return CMD_WARNING;
@ -572,13 +572,13 @@ DEFUN (isis_redistribute,
if (!afi)
return CMD_WARNING;
type = proto_redistnum(afi, argv[1]);
type = proto_redistnum(afi, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_ISIS)
return CMD_WARNING;
if (!strcmp("level-1", argv[2]))
if (!strcmp("level-1", argv[idx_level]->arg))
level = 1;
else if (!strcmp("level-2", argv[2]))
else if (!strcmp("level-2", argv[idx_level]->arg))
level = 2;
else
return CMD_WARNING;
@ -589,28 +589,28 @@ DEFUN (isis_redistribute,
return CMD_WARNING;
}
if (argv[3])
if (strmatch(argv[idx_metric_rmap]->text, "metric"))
{
char *endp;
metric = strtoul(argv[3], &endp, 10);
if (argv[3][0] == '\0' || *endp != '\0')
metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10);
routemap = NULL;
if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0')
return CMD_WARNING;
}
else
{
routemap = argv[idx_metric_rmap + 1]->arg;
metric = 0xffffffff;
}
routemap = argv[4];
isis_redist_set(area, level, family, type, metric, routemap, 0);
return 0;
}
DEFUN (no_isis_redistribute,
no_isis_redistribute_cmd,
"no redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
" (level-1|level-2)",
"no redistribute <ipv4|ipv6> <kernel|connected|static|rip|ripng|ospf|ospf6|bgp|pim|table> <level-1|level-2>",
NO_STR
REDIST_STR
"Redistribute IPv4 routes\n"
@ -619,16 +619,16 @@ DEFUN (no_isis_redistribute,
"Redistribute into level-1\n"
"Redistribute into level-2\n")
{
int idx_afi = 2;
int idx_protocol = 3;
int idx_level = 4;
VTY_DECLVAR_CONTEXT (isis_area, area);
int type;
int level;
int family;
int afi;
if (argc < 3)
return CMD_WARNING;
family = str2family(argv[0]);
family = str2family(argv[idx_afi]->arg);
if (family < 0)
return CMD_WARNING;
@ -636,16 +636,11 @@ DEFUN (no_isis_redistribute,
if (!afi)
return CMD_WARNING;
type = proto_redistnum(afi, argv[1]);
type = proto_redistnum(afi, argv[idx_protocol]->text);
if (type < 0 || type == ZEBRA_ROUTE_ISIS)
return CMD_WARNING;
if (!strcmp("level-1", argv[2]))
level = 1;
else if (!strcmp("level-2", argv[2]))
level = 2;
else
return CMD_WARNING;
level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
isis_redist_unset(area, level, family, type);
return 0;
@ -653,8 +648,7 @@ DEFUN (no_isis_redistribute,
DEFUN (isis_default_originate,
isis_default_originate_cmd,
"default-information originate (ipv4|ipv6) (level-1|level-2) "
"{always|metric <0-16777215>|route-map WORD}",
"default-information originate <ipv4|ipv6> <level-1|level-2> [<always|metric (0-16777215)|route-map WORD>]",
"Control distribution of default information\n"
"Distribute a default route\n"
"Distribute default route for IPv4\n"
@ -667,26 +661,21 @@ DEFUN (isis_default_originate,
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_afi = 2;
int idx_level = 3;
int idx_metric_rmap = 4;
VTY_DECLVAR_CONTEXT (isis_area, area);
int family;
int originate_type;
int originate_type = DEFAULT_ORIGINATE;
int level;
unsigned long metric;
const char *routemap;
unsigned long metric = 0xffffffff;
const char *routemap = NULL;
if (argc < 5)
return CMD_WARNING;
family = str2family(argv[0]);
family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;
if (!strcmp("level-1", argv[1]))
level = 1;
else if (!strcmp("level-2", argv[1]))
level = 2;
else
return CMD_WARNING;
level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
if ((area->is_type & level) != level)
{
@ -694,10 +683,15 @@ DEFUN (isis_default_originate,
return CMD_WARNING;
}
if (argv[2] && *argv[2] != '\0')
if (argc > 4)
{
if (strmatch (argv[idx_metric_rmap]->text, "always"))
originate_type = DEFAULT_ORIGINATE_ALWAYS;
else if (strmatch(argv[idx_metric_rmap]->text, "metric"))
metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10);
else
originate_type = DEFAULT_ORIGINATE;
routemap = argv[idx_metric_rmap + 1]->arg;
}
if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS)
{
@ -705,27 +699,13 @@ DEFUN (isis_default_originate,
vty_out(vty, "so use with care or use default-originate always.%s", VTY_NEWLINE);
}
if (argv[3])
{
char *endp;
metric = strtoul(argv[3], &endp, 10);
if (argv[3][0] == '\0' || *endp != '\0')
return CMD_WARNING;
}
else
{
metric = 0xffffffff;
}
routemap = argv[4];
isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, originate_type);
return 0;
}
DEFUN (no_isis_default_originate,
no_isis_default_originate_cmd,
"no default-information originate (ipv4|ipv6) (level-1|level-2)",
"no default-information originate <ipv4|ipv6> <level-1|level-2>",
NO_STR
"Control distribution of default information\n"
"Distribute a default route\n"
@ -734,20 +714,19 @@ DEFUN (no_isis_default_originate,
"Distribute default route into level-1\n"
"Distribute default route into level-2\n")
{
int idx_afi = 3;
int idx_level = 4;
VTY_DECLVAR_CONTEXT (isis_area, area);
int family;
int level;
if (argc < 2)
return CMD_WARNING;
family = str2family(argv[0]);
family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;
if (!strcmp("level-1", argv[1]))
if (strmatch ("level-1", argv[idx_level]->text))
level = 1;
else if (!strcmp("level-2", argv[1]))
else if (strmatch ("level-2", argv[idx_level]->text))
level = 2;
else
return CMD_WARNING;

View File

@ -250,314 +250,29 @@ static struct route_map_rule_cmd route_set_metric_cmd =
route_set_metric_free
};
/* ------------------------------------------------------------*/
static int
isis_route_match_add(struct vty *vty,
const char *command, const char *arg)
{
VTY_DECLVAR_CONTEXT (route_map_index, index);
int ret;
ret = route_map_add_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
isis_route_match_delete(struct vty *vty,
const char *command, const char *arg)
{
VTY_DECLVAR_CONTEXT (route_map_index, index);
int ret;
ret = route_map_delete_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
isis_route_set_add(struct vty *vty,
const char *command, const char *arg)
{
VTY_DECLVAR_CONTEXT (route_map_index, index);
int ret;
ret = route_map_add_set(index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
isis_route_set_delete (struct vty *vty,
const char *command, const char *arg)
{
VTY_DECLVAR_CONTEXT (route_map_index, index);
int ret;
ret = route_map_delete_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* ------------------------------------------------------------*/
DEFUN (match_ip_address,
match_ip_address_cmd,
"match ip address (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
return isis_route_match_add(vty, "ip address", argv[0]);
}
DEFUN (no_match_ip_address,
no_match_ip_address_val_cmd,
"no match ip address (<1-199>|<1300-2699>|WORD)",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
if (argc == 0)
return isis_route_match_delete(vty, "ip address", NULL);
return isis_route_match_delete(vty, "ip address", argv[0]);
}
ALIAS (no_match_ip_address,
no_match_ip_address_cmd,
"no match ip address",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n")
/* ------------------------------------------------------------*/
DEFUN (match_ip_address_prefix_list,
match_ip_address_prefix_list_cmd,
"match ip address prefix-list WORD",
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return isis_route_match_add(vty, "ip address prefix-list", argv[0]);
}
DEFUN (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_cmd,
"no match ip address prefix-list",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return isis_route_match_delete (vty, "ip address prefix-list", NULL);
return isis_route_match_delete (vty, "ip address prefix-list", argv[0]);
}
ALIAS (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_val_cmd,
"no match ip address prefix-list WORD",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
/* ------------------------------------------------------------*/
DEFUN (match_ipv6_address,
match_ipv6_address_cmd,
"match ipv6 address WORD",
MATCH_STR
IPV6_STR
"Match IPv6 address of route\n"
"IPv6 access-list name\n")
{
return isis_route_match_add(vty, "ipv6 address", argv[0]);
}
DEFUN (no_match_ipv6_address,
no_match_ipv6_address_val_cmd,
"no match ipv6 address WORD",
NO_STR
MATCH_STR
IPV6_STR
"Match IPv6 address of route\n"
"IPv6 access-list name\n")
{
if (argc == 0)
return isis_route_match_delete(vty, "ipv6 address", NULL);
return isis_route_match_delete(vty, "ipv6 address", argv[0]);
}
ALIAS (no_match_ipv6_address,
no_match_ipv6_address_cmd,
"no match ipv6 address",
NO_STR
MATCH_STR
IPV6_STR
"Match IPv6 address of route\n")
/* ------------------------------------------------------------*/
DEFUN (match_ipv6_address_prefix_list,
match_ipv6_address_prefix_list_cmd,
"match ipv6 address prefix-list WORD",
MATCH_STR
IPV6_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return isis_route_match_add(vty, "ipv6 address prefix-list", argv[0]);
}
DEFUN (no_match_ipv6_address_prefix_list,
no_match_ipv6_address_prefix_list_cmd,
"no match ipv6 address prefix-list",
NO_STR
MATCH_STR
IPV6_STR
"Match address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return isis_route_match_delete (vty, "ipv6 address prefix-list", NULL);
return isis_route_match_delete (vty, "ipv6 address prefix-list", argv[0]);
}
ALIAS (no_match_ipv6_address_prefix_list,
no_match_ipv6_address_prefix_list_val_cmd,
"no match ipv6 address prefix-list WORD",
NO_STR
MATCH_STR
IPV6_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
/* ------------------------------------------------------------*/
/* set metric already exists e.g. in the ospf routemap. vtysh doesn't cope well with different
* commands at the same node, therefore add set metric with the same 32-bit range as ospf and
* verify that the input is a valid isis metric */
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
SET_STR
"Metric vale for destination routing protocol\n"
"Metric value\n")
{
return isis_route_set_add(vty, "metric", argv[0]);
}
DEFUN (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
{
if (argc == 0)
return isis_route_set_delete(vty, "metric", NULL);
return isis_route_set_delete(vty, "metric", argv[0]);
}
ALIAS (no_set_metric,
no_set_metric_cmd,
"no set metric",
NO_STR
SET_STR
"Metric vale for destination routing protocol\n");
void
isis_route_map_init(void)
{
route_map_init();
route_map_match_ip_address_hook (generic_match_add);
route_map_no_match_ip_address_hook (generic_match_delete);
route_map_match_ip_address_prefix_list_hook (generic_match_add);
route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
route_map_match_ipv6_address_hook (generic_match_add);
route_map_no_match_ipv6_address_hook (generic_match_delete);
route_map_match_ipv6_address_prefix_list_hook (generic_match_add);
route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete);
route_map_set_metric_hook (generic_set_add);
route_map_no_set_metric_hook (generic_set_delete);
route_map_install_match(&route_match_ip_address_cmd);
install_element(RMAP_NODE, &match_ip_address_cmd);
install_element(RMAP_NODE, &no_match_ip_address_val_cmd);
install_element(RMAP_NODE, &no_match_ip_address_cmd);
route_map_install_match(&route_match_ip_address_prefix_list_cmd);
install_element(RMAP_NODE, &match_ip_address_prefix_list_cmd);
install_element(RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
install_element(RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
route_map_install_match(&route_match_ipv6_address_cmd);
install_element(RMAP_NODE, &match_ipv6_address_cmd);
install_element(RMAP_NODE, &no_match_ipv6_address_val_cmd);
install_element(RMAP_NODE, &no_match_ipv6_address_cmd);
route_map_install_match(&route_match_ipv6_address_prefix_list_cmd);
install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_val_cmd);
install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
route_map_install_set(&route_set_metric_cmd);
install_element(RMAP_NODE, &set_metric_cmd);
install_element(RMAP_NODE, &no_set_metric_val_cmd);
install_element(RMAP_NODE, &no_set_metric_cmd);
}

View File

@ -1163,11 +1163,12 @@ DEFUN (isis_mpls_te_router_addr,
"Stable IP address of the advertising router\n"
"MPLS-TE router address in IPv4 address format\n")
{
int idx_ipv4 = 2;
struct in_addr value;
struct listnode *node;
struct isis_area *area;
if (! inet_aton (argv[0], &value))
if (! inet_aton (argv[idx_ipv4]->arg, &value))
{
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING;
@ -1190,7 +1191,7 @@ DEFUN (isis_mpls_te_router_addr,
DEFUN (isis_mpls_te_inter_as,
isis_mpls_te_inter_as_cmd,
"mpls-te inter-as (level-1|level-1-2|level-2-only)",
"mpls-te inter-as <level-1|level-1-2|level-2-only>",
MPLS_TE_STR
"Configure MPLS-TE Inter-AS support\n"
"AREA native mode self originate INTER-AS LSP with L1 only flooding scope)\n"
@ -1317,11 +1318,12 @@ DEFUN (show_isis_mpls_te_interface,
"Interface information\n"
"Interface name\n")
{
int idx_interface = 4;
struct interface *ifp;
struct listnode *node;
/* Show All Interfaces. */
if (argc == 0)
if (argc == 4)
{
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
show_mpls_te_sub (vty, ifp);
@ -1329,7 +1331,7 @@ DEFUN (show_isis_mpls_te_interface,
/* Interface name is specified. */
else
{
if ((ifp = if_lookup_by_name (argv[0])) == NULL)
if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else
show_mpls_te_sub (vty, ifp);

File diff suppressed because it is too large Load Diff

View File

@ -529,7 +529,8 @@ DEFUN (show_isis_interface_arg,
"ISIS interface\n"
"ISIS interface name\n")
{
return show_isis_interface_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
int idx_word = 3;
return show_isis_interface_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
}
/*
@ -703,7 +704,8 @@ DEFUN (show_isis_neighbor_arg,
"ISIS neighbor adjacencies\n"
"System id\n")
{
return show_isis_neighbor_common (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
int idx_word = 3;
return show_isis_neighbor_common (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
}
DEFUN (clear_isis_neighbor,
@ -724,7 +726,8 @@ DEFUN (clear_isis_neighbor_arg,
"ISIS neighbor adjacencies\n"
"System id\n")
{
return clear_isis_neighbor_common (vty, argv[0]);
int idx_word = 3;
return clear_isis_neighbor_common (vty, argv[idx_word]->arg);
}
/*
@ -895,6 +898,7 @@ DEFUN (debug_isis_adj,
DEFUN (no_debug_isis_adj,
no_debug_isis_adj_cmd,
"no debug isis adj-packets",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS Adjacency related packets\n")
@ -921,6 +925,7 @@ DEFUN (debug_isis_csum,
DEFUN (no_debug_isis_csum,
no_debug_isis_csum_cmd,
"no debug isis checksum-errors",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS LSP checksum errors\n")
@ -947,6 +952,7 @@ DEFUN (debug_isis_lupd,
DEFUN (no_debug_isis_lupd,
no_debug_isis_lupd_cmd,
"no debug isis local-updates",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS local update packets\n")
@ -973,6 +979,7 @@ DEFUN (debug_isis_err,
DEFUN (no_debug_isis_err,
no_debug_isis_err_cmd,
"no debug isis protocol-errors",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS LSP protocol errors\n")
@ -999,6 +1006,7 @@ DEFUN (debug_isis_snp,
DEFUN (no_debug_isis_snp,
no_debug_isis_snp_cmd,
"no debug isis snp-packets",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS CSNP/PSNP packets\n")
@ -1025,6 +1033,7 @@ DEFUN (debug_isis_upd,
DEFUN (no_debug_isis_upd,
no_debug_isis_upd_cmd,
"no debug isis update-packets",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS Update related packets\n")
@ -1051,6 +1060,7 @@ DEFUN (debug_isis_spfevents,
DEFUN (no_debug_isis_spfevents,
no_debug_isis_spfevents_cmd,
"no debug isis spf-events",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS Shortest Path First Events\n")
@ -1077,6 +1087,7 @@ DEFUN (debug_isis_spfstats,
DEFUN (no_debug_isis_spfstats,
no_debug_isis_spfstats_cmd,
"no debug isis spf-statistics",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS SPF Timing and Statistic Data\n")
@ -1103,6 +1114,7 @@ DEFUN (debug_isis_spftrigg,
DEFUN (no_debug_isis_spftrigg,
no_debug_isis_spftrigg_cmd,
"no debug isis spf-triggers",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS SPF triggering events\n")
@ -1129,6 +1141,7 @@ DEFUN (debug_isis_rtevents,
DEFUN (no_debug_isis_rtevents,
no_debug_isis_rtevents_cmd,
"no debug isis route-events",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS Route related events\n")
@ -1155,6 +1168,7 @@ DEFUN (debug_isis_events,
DEFUN (no_debug_isis_events,
no_debug_isis_events_cmd,
"no debug isis events",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS Events\n")
@ -1181,6 +1195,7 @@ DEFUN (debug_isis_packet_dump,
DEFUN (no_debug_isis_packet_dump,
no_debug_isis_packet_dump_cmd,
"no debug isis packet-dump",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS packet dump\n")
@ -1207,6 +1222,7 @@ DEFUN (debug_isis_lsp_gen,
DEFUN (no_debug_isis_lsp_gen,
no_debug_isis_lsp_gen_cmd,
"no debug isis lsp-gen",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS generation of own LSPs\n")
@ -1233,6 +1249,7 @@ DEFUN (debug_isis_lsp_sched,
DEFUN (no_debug_isis_lsp_sched,
no_debug_isis_lsp_sched_cmd,
"no debug isis lsp-sched",
NO_STR
UNDEBUG_STR
"IS-IS information\n"
"IS-IS scheduling of LSP generation\n")
@ -1526,7 +1543,8 @@ DEFUN (show_database_lsp_brief,
"IS-IS link state database\n"
"LSP ID\n")
{
return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_BRIEF);
int idx_word = 3;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_BRIEF);
}
DEFUN (show_database_lsp_detail,
@ -1538,7 +1556,8 @@ DEFUN (show_database_lsp_detail,
"LSP ID\n"
"Detailed information\n")
{
return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
int idx_word = 3;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
}
DEFUN (show_database_detail,
@ -1560,7 +1579,8 @@ DEFUN (show_database_detail_lsp,
"Detailed information\n"
"LSP ID\n")
{
return show_isis_database (vty, argv[0], ISIS_UI_LEVEL_DETAIL);
int idx_word = 4;
return show_isis_database (vty, argv[idx_word]->arg, ISIS_UI_LEVEL_DETAIL);
}
/*
@ -1573,7 +1593,8 @@ DEFUN (router_isis,
"ISO IS-IS\n"
"ISO Routing area tag")
{
return isis_area_get (vty, argv[0]);
int idx_word = 2;
return isis_area_get (vty, argv[idx_word]->arg);
}
/*
@ -1584,7 +1605,8 @@ DEFUN (no_router_isis,
"no router isis WORD",
"no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
{
return isis_area_destroy (vty, argv[0]);
int idx_word = 3;
return isis_area_destroy (vty, argv[idx_word]->arg);
}
/*
@ -1596,7 +1618,8 @@ DEFUN (net,
"A Network Entity Title for this process (OSI only)\n"
"XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{
return area_net_title (vty, argv[0]);
int idx_word = 1;
return area_net_title (vty, argv[idx_word]->arg);
}
/*
@ -1609,7 +1632,8 @@ DEFUN (no_net,
"A Network Entity Title for this process (OSI only)\n"
"XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{
return area_clear_net_title (vty, argv[0]);
int idx_word = 2;
return area_clear_net_title (vty, argv[idx_word]->arg);
}
void isis_area_lsp_mtu_set(struct isis_area *area, unsigned int lsp_mtu)
@ -1873,6 +1897,7 @@ DEFUN (log_adj_changes,
DEFUN (no_log_adj_changes,
no_log_adj_changes_cmd,
"no log-adjacency-changes",
NO_STR
"Stop logging changes in adjacency state\n")
{
VTY_DECLVAR_CONTEXT (isis_area, area);

View File

@ -96,7 +96,7 @@ DEFUN (ldp_address_family_ipv6,
DEFUN (ldp_discovery_hello_holdtime_disc_time,
ldp_discovery_hello_holdtime_disc_time_cmd,
"discovery hello holdtime <1-65535>",
"discovery hello holdtime (1-65535)",
"Configure discovery parameters\n"
"LDP Link Hellos\n"
"Hello holdtime\n"
@ -113,7 +113,7 @@ DEFUN (ldp_discovery_hello_holdtime_disc_time,
DEFUN (ldp_discovery_hello_interval_disc_time,
ldp_discovery_hello_interval_disc_time_cmd,
"discovery hello interval <1-65535>",
"discovery hello interval (1-65535)",
"Configure discovery parameters\n"
"LDP Link Hellos\n"
"Hello interval\n"
@ -130,7 +130,7 @@ DEFUN (ldp_discovery_hello_interval_disc_time,
DEFUN (ldp_discovery_targeted_hello_holdtime_disc_time,
ldp_discovery_targeted_hello_holdtime_disc_time_cmd,
"discovery targeted-hello holdtime <1-65535>",
"discovery targeted-hello holdtime (1-65535)",
"Configure discovery parameters\n"
"LDP Targeted Hellos\n"
"Targeted hello holdtime\n"
@ -147,7 +147,7 @@ DEFUN (ldp_discovery_targeted_hello_holdtime_disc_time,
DEFUN (ldp_discovery_targeted_hello_interval_disc_time,
ldp_discovery_targeted_hello_interval_disc_time_cmd,
"discovery targeted-hello interval <1-65535>",
"discovery targeted-hello interval (1-65535)",
"Configure discovery parameters\n"
"LDP Targeted Hellos\n"
"Targeted hello interval\n"
@ -203,7 +203,7 @@ DEFUN (ldp_neighbor_ipv4_password_word,
DEFUN (ldp_neighbor_ipv4_session_holdtime_session_time,
ldp_neighbor_ipv4_session_holdtime_session_time_cmd,
"neighbor A.B.C.D session holdtime <15-65535>",
"neighbor A.B.C.D session holdtime (15-65535)",
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
"Configure session parameters\n"
@ -237,7 +237,7 @@ DEFUN (ldp_neighbor_ipv4_ttl_security_disable,
DEFUN (ldp_neighbor_ipv4_ttl_security_hops_hops,
ldp_neighbor_ipv4_ttl_security_hops_hops_cmd,
"neighbor A.B.C.D ttl-security hops <1-254>",
"neighbor A.B.C.D ttl-security hops (1-254)",
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
"LDP ttl security check\n"
@ -301,7 +301,7 @@ DEFUN (ldp_no_address_family_ipv6,
DEFUN (ldp_no_discovery_hello_holdtime_disc_time,
ldp_no_discovery_hello_holdtime_disc_time_cmd,
"no discovery hello holdtime <1-65535>",
"no discovery hello holdtime (1-65535)",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Link Hellos\n"
@ -320,7 +320,7 @@ DEFUN (ldp_no_discovery_hello_holdtime_disc_time,
DEFUN (ldp_no_discovery_hello_interval_disc_time,
ldp_no_discovery_hello_interval_disc_time_cmd,
"no discovery hello interval <1-65535>",
"no discovery hello interval (1-65535)",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Link Hellos\n"
@ -339,7 +339,7 @@ DEFUN (ldp_no_discovery_hello_interval_disc_time,
DEFUN (ldp_no_discovery_targeted_hello_holdtime_disc_time,
ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd,
"no discovery targeted-hello holdtime <1-65535>",
"no discovery targeted-hello holdtime (1-65535)",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Targeted Hellos\n"
@ -358,7 +358,7 @@ DEFUN (ldp_no_discovery_targeted_hello_holdtime_disc_time,
DEFUN (ldp_no_discovery_targeted_hello_interval_disc_time,
ldp_no_discovery_targeted_hello_interval_disc_time_cmd,
"no discovery targeted-hello interval <1-65535>",
"no discovery targeted-hello interval (1-65535)",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Targeted Hellos\n"
@ -428,7 +428,7 @@ DEFUN (ldp_no_neighbor_ipv4_password_word,
DEFUN (ldp_no_neighbor_ipv4_session_holdtime_session_time,
ldp_no_neighbor_ipv4_session_holdtime_session_time_cmd,
"no neighbor A.B.C.D session holdtime <15-65535>",
"no neighbor A.B.C.D session holdtime (15-65535)",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
@ -466,7 +466,7 @@ DEFUN (ldp_no_neighbor_ipv4_ttl_security_disable,
DEFUN (ldp_no_neighbor_ipv4_ttl_security_hops_hops,
ldp_no_neighbor_ipv4_ttl_security_hops_hops_cmd,
"no neighbor A.B.C.D ttl-security hops <1-254>",
"no neighbor A.B.C.D ttl-security hops (1-254)",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
@ -539,7 +539,7 @@ DEFUN (ldp_ttl_security_disable,
DEFUN (ldp_session_holdtime_session_time,
ldp_session_holdtime_session_time_cmd,
"session holdtime <15-65535>",
"session holdtime (15-65535)",
"Configure session parameters\n"
"Configure session holdtime\n"
"Time (seconds)\n")
@ -647,7 +647,7 @@ DEFUN (ldp_no_ttl_security_disable,
DEFUN (ldp_no_session_holdtime_session_time,
ldp_no_session_holdtime_session_time_cmd,
"no session holdtime <15-65535>",
"no session holdtime (15-65535)",
"Negate a command or set its defaults\n"
"Configure session parameters\n"
"Configure session holdtime\n"
@ -792,7 +792,7 @@ DEFUN (ldp_bridge_ifname,
DEFUN (ldp_mtu_mtu,
ldp_mtu_mtu_cmd,
"mtu <1500-9180>",
"mtu (1500-9180)",
"set Maximum Transmission Unit\n"
"Maximum Transmission Unit value\n")
{
@ -836,7 +836,7 @@ DEFUN (ldp_member_pseudowire_ifname,
DEFUN (ldp_vc_type_pwtype,
ldp_vc_type_pwtype_cmd,
"vc type (ethernet|ethernet-tagged)",
"vc type <ethernet|ethernet-tagged>",
"Virtual Circuit options\n"
"Virtual Circuit type to use\n"
"Ethernet (type 5)\n"
@ -868,7 +868,7 @@ DEFUN (ldp_no_bridge_ifname,
DEFUN (ldp_no_mtu_mtu,
ldp_no_mtu_mtu_cmd,
"no mtu <1500-9180>",
"no mtu (1500-9180)",
"Negate a command or set its defaults\n"
"set Maximum Transmission Unit\n"
"Maximum Transmission Unit value\n")
@ -918,7 +918,7 @@ DEFUN (ldp_no_member_pseudowire_ifname,
DEFUN (ldp_no_vc_type_pwtype,
ldp_no_vc_type_pwtype_cmd,
"no vc type (ethernet|ethernet-tagged)",
"no vc type <ethernet|ethernet-tagged>",
"Negate a command or set its defaults\n"
"Virtual Circuit options\n"
"Virtual Circuit type to use\n"
@ -936,7 +936,7 @@ DEFUN (ldp_no_vc_type_pwtype,
DEFUN (ldp_control_word_cword,
ldp_control_word_cword_cmd,
"control-word (exclude|include)",
"control-word <exclude|include>",
"Control-word options\n"
"Exclude control-word in pseudowire packets\n"
"Include control-word in pseudowire packets\n")
@ -951,7 +951,7 @@ DEFUN (ldp_control_word_cword,
DEFUN (ldp_neighbor_address_addr,
ldp_neighbor_address_addr_cmd,
"neighbor address (A.B.C.D|X:X::X:X)",
"neighbor address <A.B.C.D|X:X::X:X>",
"Remote endpoint configuration\n"
"Specify the IPv4 or IPv6 address of the remote endpoint\n"
"IPv4 address\n"
@ -982,7 +982,7 @@ DEFUN (ldp_neighbor_lsr_id_ipv4,
DEFUN (ldp_pw_id_pwid,
ldp_pw_id_pwid_cmd,
"pw-id <1-4294967295>",
"pw-id (1-4294967295)",
"Set the Virtual Circuit ID\n"
"Virtual Circuit ID value\n")
{
@ -1006,7 +1006,7 @@ DEFUN (ldp_pw_status_disable,
DEFUN (ldp_no_control_word_cword,
ldp_no_control_word_cword_cmd,
"no control-word (exclude|include)",
"no control-word <exclude|include>",
"Negate a command or set its defaults\n"
"Control-word options\n"
"Exclude control-word in pseudowire packets\n"
@ -1023,7 +1023,7 @@ DEFUN (ldp_no_control_word_cword,
DEFUN (ldp_no_neighbor_address_addr,
ldp_no_neighbor_address_addr_cmd,
"no neighbor address (A.B.C.D|X:X::X:X)",
"no neighbor address <A.B.C.D|X:X::X:X>",
"Negate a command or set its defaults\n"
"Remote endpoint configuration\n"
"Specify the IPv4 or IPv6 address of the remote endpoint\n"
@ -1058,7 +1058,7 @@ DEFUN (ldp_no_neighbor_lsr_id_ipv4,
DEFUN (ldp_no_pw_id_pwid,
ldp_no_pw_id_pwid_cmd,
"no pw-id <1-4294967295>",
"no pw-id (1-4294967295)",
"Negate a command or set its defaults\n"
"Set the Virtual Circuit ID\n"
"Virtual Circuit ID value\n")
@ -1137,7 +1137,7 @@ DEFUN (ldp_show_mpls_ldp_interface,
DEFUN (ldp_show_mpls_ldp_address_family_binding,
ldp_show_mpls_ldp_address_family_binding_cmd,
"show mpls ldp (ipv4|ipv6) binding",
"show mpls ldp <ipv4|ipv6> binding",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@ -1155,7 +1155,7 @@ DEFUN (ldp_show_mpls_ldp_address_family_binding,
DEFUN (ldp_show_mpls_ldp_address_family_discovery,
ldp_show_mpls_ldp_address_family_discovery_cmd,
"show mpls ldp (ipv4|ipv6) discovery",
"show mpls ldp <ipv4|ipv6> discovery",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@ -1173,7 +1173,7 @@ DEFUN (ldp_show_mpls_ldp_address_family_discovery,
DEFUN (ldp_show_mpls_ldp_address_family_interface,
ldp_show_mpls_ldp_address_family_interface_cmd,
"show mpls ldp (ipv4|ipv6) interface",
"show mpls ldp <ipv4|ipv6> interface",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@ -1239,7 +1239,7 @@ DEFUN (ldp_clear_mpls_ldp_neighbor,
DEFUN (ldp_clear_mpls_ldp_neighbor_addr,
ldp_clear_mpls_ldp_neighbor_addr_cmd,
"clear mpls ldp neighbor (A.B.C.D|X:X::X:X)",
"clear mpls ldp neighbor <A.B.C.D|X:X::X:X>",
"Reset functions\n"
"Reset MPLS statistical information\n"
"Clear LDP state\n"
@ -1257,7 +1257,7 @@ DEFUN (ldp_clear_mpls_ldp_neighbor_addr,
DEFUN (ldp_debug_mpls_ldp_discovery_hello_dir,
ldp_debug_mpls_ldp_discovery_hello_dir_cmd,
"debug mpls ldp discovery hello (recv|sent)",
"debug mpls ldp discovery hello <recv|sent>",
"Debugging functions\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@ -1401,7 +1401,7 @@ DEFUN (ldp_debug_mpls_ldp_zebra,
DEFUN (ldp_no_debug_mpls_ldp_discovery_hello_dir,
ldp_no_debug_mpls_ldp_discovery_hello_dir_cmd,
"no debug mpls ldp discovery hello (recv|sent)",
"no debug mpls ldp discovery hello <recv|sent>",
"Negate a command or set its defaults\n"
"Debugging functions\n"
"MPLS information\n"

3
lib/.gitignore vendored
View File

@ -15,4 +15,7 @@ gitversion.h.tmp
*~
*.loT
route_types.h
command_lex.c
command_parse.c
command_parse.h
refix

View File

@ -4,13 +4,16 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \
-DVTY_DEPRECATE_INDEX
AM_CFLAGS = $(WERROR)
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
AM_YFLAGS = -d
lib_LTLIBRARIES = libzebra.la
libzebra_la_LDFLAGS = -version-info 0:0:0
libzebra_la_SOURCES = \
network.c pid_output.c getopt.c getopt1.c \
checksum.c vector.c linklist.c vty.c command.c \
checksum.c vector.c linklist.c vty.c \
graph.c command_parse.y command_lex.l command_match.c \
command.c \
sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \
filter.c routemap.c distribute.c stream.c log.c plist.c \
zclient.c sockopt.c smux.c agentx.c snmp.c md5.c if_rmap.c keychain.c privs.c \
@ -22,13 +25,15 @@ libzebra_la_SOURCES = \
strlcpy.c \
strlcat.c
BUILT_SOURCES = route_types.h gitversion.h
BUILT_SOURCES = route_types.h gitversion.h command_parse.h
libzebra_la_LIBADD = @LIBCAP@
pkginclude_HEADERS = \
buffer.h checksum.h command.h filter.h getopt.h hash.h \
buffer.h checksum.h filter.h getopt.h hash.h \
if.h linklist.h log.h \
graph.h command_match.h \
command.h \
memory.h network.h prefix.h routemap.h distribute.h sockunion.h \
stream.h table.h thread.h vector.h version.h vty.h zebra.h \
plist.h zclient.h sockopt.h smux.h md5.h if_rmap.h keychain.h \

View File

@ -26,11 +26,6 @@
#include "lib/json.h"
#define BFD_CMD_DETECT_MULT_RANGE "<2-255> "
#define BFD_CMD_MIN_RX_RANGE "<50-60000> "
#define BFD_CMD_MIN_TX_RANGE "<50-60000>"
#define BFD_CMD_TYPE "(multihop|singlehop)"
#define BFD_DEF_MIN_RX 300
#define BFD_MIN_MIN_RX 50
#define BFD_MAX_MIN_RX 60000

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#include "vector.h"
#include "vty.h"
#include "lib/route_types.h"
#include "graph.h"
#include "memory.h"
#include "hash.h"
@ -148,6 +149,9 @@ struct cmd_node
/* Node's configuration write function */
int (*func) (struct vty *);
/* Node's command graph */
struct graph *cmdgraph;
/* Vector of this node's command list. */
vector cmd_vector;
@ -155,63 +159,59 @@ struct cmd_node
struct hash *cmd_hash;
};
/**
* Types for tokens.
*
* The type determines what kind of data the token can match (in the
* matching use case) or hold (in the argv use case).
*/
enum cmd_token_type
{
WORD_TKN, // words
VARIABLE_TKN, // almost anything
RANGE_TKN, // integer range
IPV4_TKN, // IPV4 addresses
IPV4_PREFIX_TKN, // IPV4 network prefixes
IPV6_TKN, // IPV6 prefixes
IPV6_PREFIX_TKN, // IPV6 network prefixes
/* plumbing types */
SELECTOR_TKN, // marks beginning of selector
OPTION_TKN, // marks beginning of option
NUL_TKN, // dummy token
START_TKN, // first token in line
END_TKN, // last token in line
};
/* Command attributes */
enum
{
CMD_ATTR_DEPRECATED = 1,
CMD_ATTR_NORMAL,
CMD_ATTR_DEPRECATED,
CMD_ATTR_HIDDEN,
};
/* Comamand token struct. */
struct cmd_token
{
enum cmd_token_type type; // token type
u_char attr; // token attributes
char *text; // token text
char *desc; // token description
long long min, max; // for ranges
char *arg; // user input that matches this token
};
/* Structure of command element. */
struct cmd_element
{
const char *string; /* Command specification by string. */
int (*func) (struct cmd_element *, struct vty *, int, const char *[]);
const char *doc; /* Documentation of this command. */
int daemon; /* Daemon to which this command belong. */
vector tokens; /* Vector of cmd_tokens */
u_char attr; /* Command attributes */
};
enum cmd_token_type
{
TOKEN_TERMINAL = 0,
TOKEN_MULTIPLE,
TOKEN_KEYWORD,
};
enum cmd_terminal_type
{
_TERMINAL_BUG = 0,
TERMINAL_LITERAL,
TERMINAL_OPTION,
TERMINAL_VARIABLE,
TERMINAL_VARARG,
TERMINAL_RANGE,
TERMINAL_IPV4,
TERMINAL_IPV4_PREFIX,
TERMINAL_IPV6,
TERMINAL_IPV6_PREFIX,
};
/* argument to be recorded on argv[] if it's not a literal */
#define TERMINAL_RECORD(t) ((t) >= TERMINAL_OPTION)
/* Command description structure. */
struct cmd_token
{
enum cmd_token_type type;
enum cmd_terminal_type terminal;
/* Used for type == MULTIPLE */
vector multiple; /* vector of cmd_token, type == FINAL */
/* Used for type == KEYWORD */
vector keyword; /* vector of vector of cmd_tokens */
/* Used for type == TERMINAL */
char *cmd; /* Command string. */
char *desc; /* Command's description. */
/* handler function for command */
int (*func) (const struct cmd_element *, struct vty *, int, struct cmd_token *[]);
};
/* Return value of the commands. */
@ -247,179 +247,15 @@ struct cmd_token
};
#define DEFUN_CMD_FUNC_DECL(funcname) \
static int funcname (struct cmd_element *, struct vty *, int, const char *[]);
static int funcname (const struct cmd_element *, struct vty *, int, struct cmd_token *[]);
#define DEFUN_CMD_FUNC_TEXT(funcname) \
static int funcname \
(struct cmd_element *self __attribute__ ((unused)), \
(const struct cmd_element *self __attribute__ ((unused)), \
struct vty *vty __attribute__ ((unused)), \
int argc __attribute__ ((unused)), \
const char *argv[] __attribute__ ((unused)) )
struct cmd_token *argv[] __attribute__ ((unused)) )
/* DEFUN for vty command interafce. Little bit hacky ;-).
*
* DEFUN(funcname, cmdname, cmdstr, helpstr)
*
* funcname
* ========
*
* Name of the function that will be defined.
*
* cmdname
* =======
*
* Name of the struct that will be defined for the command.
*
* cmdstr
* ======
*
* The cmdstr defines the command syntax. It is used by the vty subsystem
* and vtysh to perform matching and completion in the cli. So you have to take
* care to construct it adhering to the following grammar. The names used
* for the production rules losely represent the names used in lib/command.c
*
* cmdstr = cmd_token , { " " , cmd_token } ;
*
* cmd_token = cmd_terminal
* | cmd_multiple
* | cmd_keyword ;
*
* cmd_terminal_fixed = fixed_string
* | variable
* | range
* | ipv4
* | ipv4_prefix
* | ipv6
* | ipv6_prefix ;
*
* cmd_terminal = cmd_terminal_fixed
* | option
* | vararg ;
*
* multiple_part = cmd_terminal_fixed ;
* cmd_multiple = "(" , multiple_part , ( "|" | { "|" , multiple_part } ) , ")" ;
*
* keyword_part = fixed_string , { " " , ( cmd_terminal_fixed | cmd_multiple ) } ;
* cmd_keyword = "{" , keyword_part , { "|" , keyword_part } , "}" ;
*
* lowercase = "a" | ... | "z" ;
* uppercase = "A" | ... | "Z" ;
* digit = "0" | ... | "9" ;
* number = digit , { digit } ;
*
* fixed_string = (lowercase | digit) , { lowercase | digit | uppercase | "-" | "_" } ;
* variable = uppercase , { uppercase | "_" } ;
* range = "<" , number , "-" , number , ">" ;
* ipv4 = "A.B.C.D" ;
* ipv4_prefix = "A.B.C.D/M" ;
* ipv6 = "X:X::X:X" ;
* ipv6_prefix = "X:X::X:X/M" ;
* option = "[" , variable , "]" ;
* vararg = "." , variable ;
*
* To put that all in a textual description: A cmdstr is a sequence of tokens,
* separated by spaces.
*
* Terminal Tokens:
*
* A very simple cmdstring would be something like: "show ip bgp". It consists
* of three Terminal Tokens, each containing a fixed string. When this command
* is called, no arguments will be passed down to the function implementing it,
* as it only consists of fixed strings.
*
* Apart from fixed strings, Terminal Tokens can also contain variables:
* An example would be "show ip bgp A.B.C.D". This command expects an IPv4
* as argument. As this is a variable, the IP address entered by the user will
* be passed down as an argument. Apart from two exceptions, the other options
* for Terminal Tokens behave exactly as we just discussed and only make a
* difference for the CLI. The two exceptions will be discussed in the next
* paragraphs.
*
* A Terminal Token can contain a so called option match. This is a simple
* string variable that the user may omit. An example would be:
* "show interface [IFNAME]". If the user calls this without an interface as
* argument, no arguments will be passed down to the function implementing
* this command. Otherwise, the interface name will be provided to the function
* as a regular argument.
* Also, a Terminal Token can contain a so called vararg. This is used e.g. in
* "show ip bgp regexp .LINE". The last token is a vararg match and will
* consume all the arguments the user inputs on the command line and append
* those to the list of arguments passed down to the function implementing this
* command. (Therefore, it doesn't make much sense to have any tokens after a
* vararg because the vararg will already consume all the words the user entered
* in the CLI)
*
* Multiple Tokens:
*
* The Multiple Token type can be used if there are multiple possibilities what
* arguments may be used for a command, but it should map to the same function
* nonetheless. An example would be "ip route A.B.C.D/M (reject|blackhole)"
* In that case both "reject" and "blackhole" would be acceptable as last
* arguments. The words matched by Multiple Tokens are always added to the
* argument list, even if they are matched by fixed strings. Such a Multiple
* Token can contain almost any type of token that would also be acceptable
* for a Terminal Token, the exception are optional variables and varag.
*
* There is one special case that is used in some places of Quagga that should be
* pointed out here shortly. An example would be "password (8|) WORD". This
* construct is used to have fixed strings communicated as arguments. (The "8"
* will be passed down as an argument in this case) It does not mean that
* the "8" is optional. Another historic and possibly surprising property of
* this construct is that it consumes two parts of helpstr. (Help
* strings will be explained later)
*
* Keyword Tokens:
*
* There are commands that take a lot of different and possibly optional arguments.
* An example from ospf would be the "default-information originate" command. This
* command takes a lot of optional arguments that may be provided in any order.
* To accomodate such commands, the Keyword Token has been implemented.
* Using the keyword token, the "default-information originate" command and all
* its possible options can be represented using this single cmdstr:
* "default-information originate \
* {always|metric <0-16777214>|metric-type (1|2)|route-map WORD}"
*
* Keywords always start with a fixed string and may be followed by arguments.
* Except optional variables and vararg, everything is permitted here.
*
* For the special case of a keyword without arguments, either NULL or the
* keyword itself will be pushed as an argument, depending on whether the
* keyword is present.
* For the other keywords, arguments will be only pushed for
* variables/Multiple Tokens. If the keyword is not present, the arguments that
* would have been pushed will be substituted by NULL.
*
* A few examples:
* "default information originate metric-type 1 metric 1000"
* would yield the following arguments:
* { NULL, "1000", "1", NULL }
*
* "default information originate always route-map RMAP-DEFAULT"
* would yield the following arguments:
* { "always", NULL, NULL, "RMAP-DEFAULT" }
*
* helpstr
* =======
*
* The helpstr is used to show a short explantion for the commands that
* are available when the user presses '?' on the CLI. It is the concatenation
* of the helpstrings for all the tokens that make up the command.
*
* There should be one helpstring for each token in the cmdstr except those
* containing other tokens, like Multiple or Keyword Tokens. For those, there
* will only be the helpstrings of the contained tokens.
*
* The individual helpstrings are expected to be in the same order as their
* respective Tokens appear in the cmdstr. They should each be terminated with
* a linefeed. The last helpstring should be terminated with a linefeed as well.
*
* Care should also be taken to avoid having similar tokens with different
* helpstrings. Imagine e.g. the commands "show ip ospf" and "show ip bgp".
* they both contain a helpstring for "show", but only one will be displayed
* when the user enters "sh?". If those two helpstrings differ, it is not
* defined which one will be shown and the behavior is therefore unpredictable.
*/
#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_FUNC_DECL(funcname) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
@ -499,7 +335,6 @@ struct cmd_token
*/
#define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s)
#define CMD_CREATE_STR_HELPER(s) #s
#define CMD_RANGE_STR(a,s) "<" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ">"
/* Common descriptions. */
#define SHOW_STR "Show running system information\n"
@ -531,17 +366,16 @@ struct cmd_token
#define IFNAME_STR "Interface name(e.g. ep0)\n"
#define IP6_STR "IPv6 Information\n"
#define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n"
#define OSPF6_ROUTER_STR "Enable a routing process\n"
#define OSPF6_INSTANCE_STR "<1-65535> Instance ID\n"
#define SECONDS_STR "<1-65535> Seconds\n"
#define OSPF6_INSTANCE_STR "(1-65535) Instance ID\n"
#define SECONDS_STR "Seconds\n"
#define ROUTE_STR "Routing Table\n"
#define PREFIX_LIST_STR "Build a prefix list\n"
#define OSPF6_DUMP_TYPE_LIST \
"(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)"
"<neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr>"
#define ISIS_STR "IS-IS information\n"
#define AREA_TAG_STR "[area tag]\n"
#define COMMUNITY_AANN_STR "Community number where AA and NN are <0-65535>\n"
#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are <0-65535>) or local-AS|no-advertise|no-export|internet or additive\n"
#define COMMUNITY_AANN_STR "Community number where AA and NN are (0-65535)\n"
#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are (0-65535)) or local-AS|no-advertise|no-export|internet or additive\n"
#define MPLS_TE_STR "MPLS-TE specific commands\n"
#define LINK_PARAMS_STR "Configure interface link parameters\n"
#define OSPF_RI_STR "OSPF Router Information specific commands\n"
@ -553,31 +387,14 @@ struct cmd_token
/* IPv4 only machine should not accept IPv6 address for peer's IP
address. So we replace VTY command string like below. */
#ifdef HAVE_IPV6
#define NEIGHBOR_CMD "neighbor (A.B.C.D|X:X::X:X) "
#define NO_NEIGHBOR_CMD "no neighbor (A.B.C.D|X:X::X:X) "
#define NEIGHBOR_ADDR_STR "Neighbor address\nIPv6 address\n"
#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|X:X::X:X|WORD) "
#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|X:X::X:X|WORD) "
#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nInterface name or neighbor tag\n"
#define NEIGHBOR_ADDR_STR3 "Neighbor address\nIPv6 address\nInterface name\n"
#else
#define NEIGHBOR_CMD "neighbor A.B.C.D "
#define NO_NEIGHBOR_CMD "no neighbor A.B.C.D "
#define NEIGHBOR_ADDR_STR "Neighbor address\n"
#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|WORD) "
#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|WORD) "
#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor tag\n"
#endif /* HAVE_IPV6 */
/* Dynamic neighbor (listen range) configuration */
#ifdef HAVE_IPV6
#define LISTEN_RANGE_CMD "bgp listen range (A.B.C.D/M|X:X::X:X/M) "
#define LISTEN_RANGE_ADDR_STR "Neighbor address\nNeighbor IPv6 address\n"
#else
#define LISTEN_RANGE_CMD "bgp listen range A.B.C.D/M "
#define LISTEN_RANGE_ADDR_STR "Neighbor address\n"
#endif /* HAVE_IPV6 */
/* Prototypes. */
extern void install_node (struct cmd_node *, int (*) (struct vty *));
extern void install_default (enum node_type);
@ -586,22 +403,37 @@ extern void install_element (enum node_type, struct cmd_element *);
/* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated
string with a space between each element (allocated using
XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */
extern char *argv_concat (const char **argv, int argc, int shift);
extern char *argv_concat (struct cmd_token **argv, int argc, int shift);
extern int argv_find (struct cmd_token **argv, int argc, const char *text, int *index);
extern vector cmd_make_strvec (const char *);
extern void cmd_free_strvec (vector);
extern char *cmd_concat_strvec (vector);
extern vector cmd_describe_command (vector, struct vty *, int *status);
extern char **cmd_complete_command (vector, struct vty *, int *status);
extern char **cmd_complete_command_lib (vector, struct vty *, int *status, int islib);
extern const char *cmd_prompt (enum node_type);
extern int command_config_read_one_line (struct vty *vty, struct cmd_element **, int use_config_node);
extern int command_config_read_one_line (struct vty *vty, const struct cmd_element **, int use_config_node);
extern int config_from_file (struct vty *, FILE *, unsigned int *line_num);
extern enum node_type node_parent (enum node_type);
extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int);
extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
extern int cmd_execute_command (vector, struct vty *, const struct cmd_element **, int);
extern int cmd_execute_command_strict (vector, struct vty *, const struct cmd_element **);
extern void cmd_init (int);
extern void cmd_terminate (void);
/* memory management for cmd_element */
void
del_cmd_element(struct cmd_element *);
struct cmd_element *
copy_cmd_element(const struct cmd_element *cmd);
/* memory management for cmd_token */
struct cmd_token *
new_cmd_token (enum cmd_token_type, u_char attr, char *, char *);
void
del_cmd_token (struct cmd_token *);
struct cmd_token *
copy_cmd_token (struct cmd_token *);
/* Export typical functions. */
extern struct cmd_element config_end_cmd;
extern struct cmd_element config_exit_cmd;
@ -618,6 +450,7 @@ extern int cmd_banner_motd_file (const char *);
/* struct host global, ick */
extern struct host host;
/* "<cr>" global */
extern char *command_cr;
/* text for <cr> command */
#define CMD_CR_TEXT "<cr>"
#endif /* _ZEBRA_COMMAND_H */

71
lib/command_lex.l Normal file
View File

@ -0,0 +1,71 @@
/*
* Command format string lexer for CLI backend.
*
* --
* Copyright (C) 2015 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
%{
#include "command_parse.h"
extern void set_lexer_string (const char *);
extern void cleanup_lexer (void);
YY_BUFFER_STATE buffer;
%}
WORD (\-|\+)?[a-z\*][-+_a-zA-Z0-9\*]*
IPV4 A\.B\.C\.D
IPV4_PREFIX A\.B\.C\.D\/M
IPV6 X:X::X:X
IPV6_PREFIX X:X::X:X\/M
VARIABLE [A-Z][-_a-zA-Z:0-9]+
NUMBER (\-|\+)?[0-9]{1,20}
RANGE \({NUMBER}[ ]?\-[ ]?{NUMBER}\)
/* yytext shall be a pointer */
%pointer
%option noyywrap
%option nounput
%option noinput
%option outfile="command_lex.c"
%%
[ /t] /* ignore whitespace */;
{WORD} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return WORD;}
{IPV4} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4;}
{IPV4_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV4_PREFIX;}
{IPV6} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6;}
{IPV6_PREFIX} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return IPV6_PREFIX;}
{VARIABLE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return VARIABLE;}
{RANGE} {yylval.string = XSTRDUP(MTYPE_TMP, yytext); return RANGE;}
. {return yytext[0];}
%%
void
set_lexer_string (const char *string)
{
buffer = yy_scan_string (string);
}
void
cleanup_lexer ()
{
yy_delete_buffer (buffer);
}

868
lib/command_match.c Normal file
View File

@ -0,0 +1,868 @@
/*
* Input matching routines for CLI backend.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <zebra.h>
#include "command_match.h"
#include "command_parse.h"
#include "memory.h"
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")
/* matcher helper prototypes */
static int
add_nexthops (struct list *, struct graph_node *);
static struct list *
command_match_r (struct graph_node *, vector, unsigned int);
static int
score_precedence (enum cmd_token_type);
static enum match_type
min_match_level (enum cmd_token_type);
static void
del_arglist (struct list *);
static struct cmd_token *
disambiguate_tokens (struct cmd_token *, struct cmd_token *, char *);
static struct list *
disambiguate (struct list *, struct list *, vector, unsigned int);
int
compare_completions (const void *, const void *);
/* token matcher prototypes */
static enum match_type
match_token (struct cmd_token *, char *);
static enum match_type
match_ipv4 (const char *);
static enum match_type
match_ipv4_prefix (const char *);
static enum match_type
match_ipv6 (const char *);
static enum match_type
match_ipv6_prefix (const char *);
static enum match_type
match_range (struct cmd_token *, const char *);
static enum match_type
match_word (struct cmd_token *, const char *);
static enum match_type
match_variable (struct cmd_token *, const char *);
/* matching functions */
static enum matcher_rv matcher_rv;
enum matcher_rv
command_match (struct graph *cmdgraph,
vector vline,
struct list **argv,
const struct cmd_element **el)
{
matcher_rv = MATCHER_NO_MATCH;
// prepend a dummy token to match that pesky start node
vector vvline = vector_init (vline->alloced + 1);
vector_set_index (vvline, 0, (void *) XSTRDUP (MTYPE_TMP, "dummy"));
memcpy (vvline->index + 1, vline->index, sizeof (void *) * vline->alloced);
vvline->active = vline->active + 1;
struct graph_node *start = vector_slot (cmdgraph->nodes, 0);
if ((*argv = command_match_r (start, vvline, 0))) // successful match
{
struct listnode *head = listhead (*argv);
struct listnode *tail = listtail (*argv);
// delete dummy start node
del_cmd_token ((struct cmd_token *) head->data);
list_delete_node (*argv, head);
// get cmd_element out of list tail
*el = listgetdata (tail);
list_delete_node (*argv, tail);
// now argv is an ordered list of cmd_token matching the user
// input, with each cmd_token->arg holding the corresponding input
assert (*el);
}
#ifdef TRACE_MATCHER
if (!*el)
fprintf (stdout, "No match\n");
else
fprintf (stdout, "Matched command\n->string %s\n->desc %s\n", (*el)->string, (*el)->doc);
#endif
// free the leader token we alloc'd
XFREE (MTYPE_TMP, vector_slot (vvline, 0));
// free vector
vector_free (vvline);
return matcher_rv;
}
/**
* Builds an argument list given a DFA and a matching input line.
*
* First the function determines if the node it is passed matches the first
* token of input. If it does not, it returns NULL (MATCHER_NO_MATCH). If it
* does match, then it saves the input token as the head of an argument list.
*
* The next step is to see if there is further input in the input line. If
* there is not, the current node's children are searched to see if any of them
* are leaves (type END_TKN). If this is the case, then the bottom of the
* recursion stack has been reached, the leaf is pushed onto the argument list,
* the current node is pushed, and the resulting argument list is
* returned (MATCHER_OK). If it is not the case, NULL is returned, indicating
* that there is no match for the input along this path (MATCHER_INCOMPLETE).
*
* If there is further input, then the function recurses on each of the current
* node's children, passing them the input line minus the token that was just
* matched. For each child, the return value of the recursive call is
* inspected. If it is null, then there is no match for the input along the
* subgraph headed by that child. If it is not null, then there is at least one
* input match in that subgraph (more on this in a moment).
*
* If a recursive call on a child returns a non-null value, then it has matched
* the input given it on the subgraph that starts with that child. However, due
* to the flexibility of the grammar, it is sometimes the case that two or more
* child graphs match the same input (two or more of the recursive calls have
* non-NULL return values). This is not a valid state, since only one true
* match is possible. In order to resolve this conflict, the function keeps a
* reference to the child node that most specifically matches the input. This
* is done by assigning each node type a precedence. If a child is found to
* match the remaining input, then the precedence values of the current
* best-matching child and this new match are compared. The node with higher
* precedence is kept, and the other match is discarded. Due to the recursive
* nature of this function, it is only necessary to compare the precedence of
* immediate children, since all subsequent children will already have been
* disambiguated in this way.
*
* In the event that two children are found to match with the same precedence,
* then the input is ambiguous for the passed cmd_element and NULL is returned.
*
* @param[in] start the start node.
* @param[in] vline the vectorized input line.
* @param[in] n the index of the first input token.
* @return A linked list of n elements. The first n-1 elements are pointers to
* struct cmd_token and represent the sequence of tokens matched by the input.
* The ->arg field of each token points to a copy of the input matched on it.
* The final nth element is a pointer to struct cmd_element, which is the
* command that was matched.
*
* If no match was found, the return value is NULL.
*/
static struct list *
command_match_r (struct graph_node *start, vector vline, unsigned int n)
{
assert (n < vector_active (vline));
// get the minimum match level that can count as a full match
struct cmd_token *token = start->data;
enum match_type minmatch = min_match_level (token->type);
// get the current operating input token
char *input_token = vector_slot (vline, n);
#ifdef TRACE_MATCHER
fprintf (stdout, "\"%-20s\" matches \"%-30s\" ? ", input_token, token->text);
enum match_type mt = match_token (token, input_token);
fprintf (stdout, "min: %d - ", minmatch);
switch (mt)
{
case trivial_match:
fprintf (stdout, "trivial_match ");
break;
case no_match:
fprintf (stdout, "no_match ");
break;
case partly_match:
fprintf (stdout, "partly_match ");
break;
case exact_match:
fprintf (stdout, "exact_match ");
break;
}
if (mt >= minmatch) fprintf (stdout, " MATCH");
fprintf (stdout, "\n");
#endif
// if we don't match this node, die
if (match_token (token, input_token) < minmatch)
return NULL;
// pointers for iterating linklist
struct listnode *ln;
struct graph_node *gn;
// get all possible nexthops
struct list *next = list_new();
add_nexthops (next, start);
// determine the best match
int ambiguous = 0;
struct list *currbest = NULL;
for (ALL_LIST_ELEMENTS_RO (next,ln,gn))
{
// if we've matched all input we're looking for END_TKN
if (n+1 == vector_active (vline))
{
struct cmd_token *tok = gn->data;
if (tok->type == END_TKN)
{
if (currbest) // there is more than one END_TKN in the follow set
{
ambiguous = 1;
break;
}
currbest = list_new();
// node should have one child node with the element
struct graph_node *leaf = vector_slot (gn->to, 0);
// last node in the list will hold the cmd_element;
// this is important because list_delete() expects
// that all nodes have the same data type, so when
// deleting this list the last node must be
// manually deleted
struct cmd_element *el = leaf->data;
listnode_add (currbest, el);
currbest->del = (void (*)(void *)) &del_cmd_token;
// do not break immediately; continue walking through the follow set
// to ensure that there is exactly one END_TKN
}
continue;
}
// else recurse on candidate child node
struct list *result = command_match_r (gn, vline, n+1);
// save the best match
if (result && currbest)
{
// pick the best of two matches
struct list *newbest = disambiguate (currbest, result, vline, n+1);
// set ambiguity flag
ambiguous = !newbest || (ambiguous && newbest == currbest);
// delete the unnecessary result
struct list *todelete = ((newbest && newbest == result) ? currbest : result);
del_arglist (todelete);
currbest = newbest ? newbest : currbest;
}
else if (result)
currbest = result;
}
if (currbest)
{
if (ambiguous)
{
del_arglist (currbest);
currbest = NULL;
matcher_rv = MATCHER_AMBIGUOUS;
}
else
{
// copy token, set arg and prepend to currbest
struct cmd_token *token = start->data;
struct cmd_token *copy = copy_cmd_token (token);
copy->arg = XSTRDUP (MTYPE_CMD_TOKENS, input_token);
listnode_add_before (currbest, currbest->head, copy);
matcher_rv = MATCHER_OK;
}
}
else if (n+1 == vector_active (vline) && matcher_rv == MATCHER_NO_MATCH)
matcher_rv = MATCHER_INCOMPLETE;
// cleanup
list_delete (next);
return currbest;
}
enum matcher_rv
command_complete (struct graph *graph,
vector vline,
struct list **completions)
{
// pointer to next input token to match
char *input_token;
struct list *current = list_new(), // current nodes to match input token against
*next = list_new(); // possible next hops after current input token
// pointers used for iterating lists
struct graph_node *gn;
struct listnode *node;
// add all children of start node to list
struct graph_node *start = vector_slot (graph->nodes, 0);
add_nexthops (next, start);
unsigned int idx;
for (idx = 0; idx < vector_active (vline) && next->count > 0; idx++)
{
list_delete (current);
current = next;
next = list_new();
input_token = vector_slot (vline, idx);
for (ALL_LIST_ELEMENTS_RO (current,node,gn))
{
struct cmd_token *token = gn->data;
if (token->attr == CMD_ATTR_HIDDEN || token->attr == CMD_ATTR_DEPRECATED)
continue;
enum match_type minmatch = min_match_level (token->type);
#ifdef TRACE_MATCHER
fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type);
#endif
switch (match_token (token, input_token))
{
case trivial_match:
#ifdef TRACE_MATCHER
fprintf (stdout, "trivial_match\n");
#endif
case partly_match:
#ifdef TRACE_MATCHER
fprintf (stdout, "partly_match\n");
#endif
if (idx == vector_active (vline) - 1)
{
listnode_add (next, gn);
break;
}
if (minmatch > partly_match)
break;
case exact_match:
#ifdef TRACE_MATCHER
fprintf (stdout, "exact_match\n");
#endif
add_nexthops (next, gn);
break;
default:
#ifdef TRACE_MATCHER
fprintf (stdout, "no_match\n");
#endif
break;
}
}
}
/* Variable summary
* -----------------------------------------------------------------
* token = last input token processed
* idx = index in `command` of last token processed
* current = set of all transitions from the previous input token
* next = set of all nodes reachable from all nodes in `matched`
*/
matcher_rv =
idx == vector_active(vline) && next->count ?
MATCHER_OK :
MATCHER_NO_MATCH;
*completions = NULL;
if (!MATCHER_ERROR(matcher_rv))
{
// extract cmd_token into list
*completions = list_new ();
for (ALL_LIST_ELEMENTS_RO (next,node,gn))
listnode_add (*completions, gn->data);
}
list_delete (current);
list_delete (next);
return matcher_rv;
}
/**
* Adds all children that are reachable by one parser hop to the given list.
* NUL_TKN, SELECTOR_TKN, and OPTION_TKN nodes are treated as transparent.
*
* @param[in] list to add the nexthops to
* @param[in] node to start calculating nexthops from
* @return the number of children added to the list
*/
static int
add_nexthops (struct list *list, struct graph_node *node)
{
int added = 0;
struct graph_node *child;
for (unsigned int i = 0; i < vector_active (node->to); i++)
{
child = vector_slot (node->to, i);
struct cmd_token *token = child->data;
switch (token->type)
{
case OPTION_TKN:
case SELECTOR_TKN:
case NUL_TKN:
added += add_nexthops (list, child);
break;
default:
listnode_add (list, child);
added++;
}
}
return added;
}
/**
* Determines the node types for which a partial match may count as a full
* match. Enables command abbrevations.
*
* @param[in] type node type
* @return minimum match level needed to for a token to fully match
*/
static enum match_type
min_match_level (enum cmd_token_type type)
{
switch (type)
{
// anything matches a start node, for the sake of recursion
case START_TKN:
return no_match;
// allowing words to partly match enables command abbreviation
case WORD_TKN:
return partly_match;
default:
return exact_match;
}
}
/**
* Assigns precedence scores to node types.
*
* @param[in] type node type to score
* @return precedence score
*/
static int
score_precedence (enum cmd_token_type type)
{
switch (type)
{
// some of these are mutually exclusive, so they share
// the same precedence value
case IPV4_TKN:
case IPV4_PREFIX_TKN:
case IPV6_TKN:
case IPV6_PREFIX_TKN:
case RANGE_TKN:
return 2;
case WORD_TKN:
return 3;
case VARIABLE_TKN:
return 4;
default:
return 10;
}
}
/**
* Picks the better of two possible matches for a token.
*
* @param[in] first candidate node matching token
* @param[in] second candidate node matching token
* @param[in] token the token being matched
* @return the best-matching node, or NULL if the two are entirely ambiguous
*/
static struct cmd_token *
disambiguate_tokens (struct cmd_token *first,
struct cmd_token *second,
char *input_token)
{
// if the types are different, simply go off of type precedence
if (first->type != second->type)
{
int firstprec = score_precedence (first->type);
int secndprec = score_precedence (second->type);
if (firstprec != secndprec)
return firstprec < secndprec ? first : second;
else
return NULL;
}
// if they're the same, return the more exact match
enum match_type fmtype = match_token (first, input_token);
enum match_type smtype = match_token (second, input_token);
if (fmtype != smtype)
return fmtype > smtype ? first : second;
return NULL;
}
/**
* Picks the better of two possible matches for an input line.
*
* @param[in] first candidate list of cmd_token matching vline
* @param[in] second candidate list of cmd_token matching vline
* @param[in] vline the input line being matched
* @param[in] n index into vline to start comparing at
* @return the best-matching list, or NULL if the two are entirely ambiguous
*/
static struct list *
disambiguate (struct list *first,
struct list *second,
vector vline,
unsigned int n)
{
// doesn't make sense for these to be inequal length
assert (first->count == second->count);
assert (first->count == vector_active (vline) - n+1);
struct listnode *fnode = listhead (first),
*snode = listhead (second);
struct cmd_token *ftok = listgetdata (fnode),
*stok = listgetdata (snode),
*best = NULL;
// compare each token, if one matches better use that one
for (unsigned int i = n; i < vector_active (vline); i++)
{
char *token = vector_slot(vline, i);
if ((best = disambiguate_tokens (ftok, stok, token)))
return best == ftok ? first : second;
fnode = listnextnode (fnode);
snode = listnextnode (snode);
ftok = listgetdata (fnode);
stok = listgetdata (snode);
}
return NULL;
}
/*
* Deletion function for arglist.
*
* Since list->del for arglists expects all listnode->data to hold cmd_token,
* but arglists have cmd_element as the data for the tail, this function
* manually deletes the tail before deleting the rest of the list as usual.
*
* The cmd_element at the end is *not* a copy. It is the one and only.
*
* @param list the arglist to delete
*/
static void
del_arglist (struct list *list)
{
// manually delete last node
struct listnode *tail = listtail (list);
tail->data = NULL;
list_delete_node (list, tail);
// delete the rest of the list as usual
list_delete (list);
}
/*---------- token level matching functions ----------*/
static enum match_type
match_token (struct cmd_token *token, char *input_token)
{
// nothing trivially matches everything
if (!input_token)
return trivial_match;
switch (token->type) {
case WORD_TKN:
return match_word (token, input_token);
case IPV4_TKN:
return match_ipv4 (input_token);
case IPV4_PREFIX_TKN:
return match_ipv4_prefix (input_token);
case IPV6_TKN:
return match_ipv6 (input_token);
case IPV6_PREFIX_TKN:
return match_ipv6_prefix (input_token);
case RANGE_TKN:
return match_range (token, input_token);
case VARIABLE_TKN:
return match_variable (token, input_token);
case END_TKN:
default:
return no_match;
}
}
#define IPV4_ADDR_STR "0123456789."
#define IPV4_PREFIX_STR "0123456789./"
static enum match_type
match_ipv4 (const char *str)
{
const char *sp;
int dots = 0, nums = 0;
char buf[4];
for (;;)
{
memset (buf, 0, sizeof (buf));
sp = str;
while (*str != '\0')
{
if (*str == '.')
{
if (dots >= 3)
return no_match;
if (*(str + 1) == '.')
return no_match;
if (*(str + 1) == '\0')
return partly_match;
dots++;
break;
}
if (!isdigit ((int) *str))
return no_match;
str++;
}
if (str - sp > 3)
return no_match;
strncpy (buf, sp, str - sp);
if (atoi (buf) > 255)
return no_match;
nums++;
if (*str == '\0')
break;
str++;
}
if (nums < 4)
return partly_match;
return exact_match;
}
static enum match_type
match_ipv4_prefix (const char *str)
{
const char *sp;
int dots = 0;
char buf[4];
for (;;)
{
memset (buf, 0, sizeof (buf));
sp = str;
while (*str != '\0' && *str != '/')
{
if (*str == '.')
{
if (dots == 3)
return no_match;
if (*(str + 1) == '.' || *(str + 1) == '/')
return no_match;
if (*(str + 1) == '\0')
return partly_match;
dots++;
break;
}
if (!isdigit ((int) *str))
return no_match;
str++;
}
if (str - sp > 3)
return no_match;
strncpy (buf, sp, str - sp);
if (atoi (buf) > 255)
return no_match;
if (dots == 3)
{
if (*str == '/')
{
if (*(str + 1) == '\0')
return partly_match;
str++;
break;
}
else if (*str == '\0')
return partly_match;
}
if (*str == '\0')
return partly_match;
str++;
}
sp = str;
while (*str != '\0')
{
if (!isdigit ((int) *str))
return no_match;
str++;
}
if (atoi (sp) > 32)
return no_match;
return exact_match;
}
#ifdef HAVE_IPV6
#define IPV6_ADDR_STR "0123456789abcdefABCDEF:."
#define IPV6_PREFIX_STR "0123456789abcdefABCDEF:./"
static enum match_type
match_ipv6 (const char *str)
{
struct sockaddr_in6 sin6_dummy;
int ret;
if (strspn (str, IPV6_ADDR_STR) != strlen (str))
return no_match;
ret = inet_pton(AF_INET6, str, &sin6_dummy.sin6_addr);
if (ret == 1)
return exact_match;
return no_match;
}
static enum match_type
match_ipv6_prefix (const char *str)
{
struct sockaddr_in6 sin6_dummy;
const char *delim = "/\0";
char *tofree, *dupe, *prefix, *mask, *endptr;
int nmask = -1;
if (strspn (str, IPV6_PREFIX_STR) != strlen (str))
return no_match;
/* tokenize to prefix + mask */
tofree = dupe = XSTRDUP (MTYPE_TMP, str);
prefix = strsep (&dupe, delim);
mask = dupe;
/* validate prefix */
if (inet_pton (AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1)
{
XFREE (MTYPE_TMP, tofree);
return no_match;
}
/* validate mask */
if (!mask)
{
XFREE (MTYPE_TMP, tofree);
return partly_match;
}
nmask = strtoimax (mask, &endptr, 10);
if (*endptr != '\0' || nmask < 0 || nmask > 128)
{
XFREE (MTYPE_TMP, tofree);
return no_match;
}
XFREE (MTYPE_TMP, tofree);
return exact_match;
}
#endif
static enum match_type
match_range (struct cmd_token *token, const char *str)
{
assert (token->type == RANGE_TKN);
char *endptr = NULL;
long long val;
val = strtoll (str, &endptr, 10);
if (*endptr != '\0')
return no_match;
if (val < token->min || val > token->max)
return no_match;
else
return exact_match;
}
static enum match_type
match_word (struct cmd_token *token, const char *word)
{
assert (token->type == WORD_TKN);
// if the passed token is 0 length, partly match
if (!strlen(word))
return partly_match;
// if the passed token is strictly a prefix of the full word, partly match
if (strlen (word) < strlen (token->text))
return !strncmp (token->text, word, strlen (word)) ?
partly_match :
no_match;
// if they are the same length and exactly equal, exact match
else if (strlen (word) == strlen (token->text))
return !strncmp (token->text, word, strlen (word)) ? exact_match : no_match;
return no_match;
}
#define VARIABLE_ALPHABET \
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890:/._-"
static enum match_type
match_variable (struct cmd_token *token, const char *word)
{
assert (token->type == VARIABLE_TKN);
return strlen (word) == strspn(word, VARIABLE_ALPHABET) ?
exact_match : no_match;
}

113
lib/command_match.h Normal file
View File

@ -0,0 +1,113 @@
/*
* Input matching routines for CLI backend.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _ZEBRA_COMMAND_MATCH_H
#define _ZEBRA_COMMAND_MATCH_H
#include "graph.h"
#include "linklist.h"
#include "command.h"
/* These definitions exist in command.c in the current engine but should be
* relocated here in the new engine
*/
enum filter_type
{
FILTER_RELAXED,
FILTER_STRICT
};
/* matcher result value */
enum matcher_rv
{
MATCHER_NO_MATCH,
MATCHER_INCOMPLETE,
MATCHER_AMBIGUOUS,
MATCHER_OK,
};
/* completion match types */
enum match_type
{
trivial_match, // the input is null
no_match, // the input does not match
partly_match, // the input matches but is incomplete
exact_match // the input matches and is complete
};
/* Defines which matcher_rv values constitute an error. Should be used with
* matcher_rv return values to do basic error checking.
*/
#define MATCHER_ERROR(matcher_rv) \
( (matcher_rv) == MATCHER_INCOMPLETE \
|| (matcher_rv) == MATCHER_NO_MATCH \
|| (matcher_rv) == MATCHER_AMBIGUOUS \
)
/**
* Attempt to find an exact command match for a line of user input.
*
* @param[in] cmdgraph command graph to match against
* @param[in] vline vectorized input string
* @param[out] argv pointer to argument list if successful match, NULL
* otherwise. The elements of this list are pointers to struct cmd_token
* and represent the sequence of tokens matched by the inpu. The ->arg
* field of each token points to a copy of the input matched on it. These
* may be safely deleted or modified.
* @param[out] element pointer to matched cmd_element if successful match,
* or NULL when MATCHER_ERROR(rv) is true. The cmd_element may *not* be
* safely deleted or modified; it is the instance initialized on startup.
* @return matcher status
*/
enum matcher_rv
command_match (struct graph *cmdgraph,
vector vline,
struct list **argv,
const struct cmd_element **element);
/**
* Compiles possible completions for a given line of user input.
*
* @param[in] start the start node of the DFA to match against
* @param[in] vline vectorized input string
* @param[out] completions pointer to list of cmd_token representing
* acceptable next inputs, or NULL when MATCHER_ERROR(rv) is true.
* The elements of this list are pointers to struct cmd_token and take on a
* variety of forms depending on the passed vline. If the last element in vline
* is NULL, all previous elements are considered to be complete words (the case
* when a space is the last token of the line) and completions are generated
* based on what could follow that input. If the last element in vline is not
* NULL and each sequential element matches the corresponding tokens of one or
* more commands exactly (e.g. 'encapv4' and not 'en') the same result is
* generated. If the last element is not NULL and the best possible match is a
* partial match, then the result generated will be all possible continuations
* of that element (e.g. 'encapv4', 'encapv6', etc for input 'en').
* @return matcher status
*/
enum matcher_rv
command_complete (struct graph *cmdgraph,
vector vline,
struct list **completions);
#endif /* _ZEBRA_COMMAND_MATCH_H */

573
lib/command_parse.y Normal file
View File

@ -0,0 +1,573 @@
/*
* Command format string parser for CLI backend.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
%{
// compile with debugging facilities
#define YYDEBUG 1
%}
/* names for generated header and parser files */
%defines "command_parse.h"
%output "command_parse.c"
/* required external units */
%code requires {
#include "stdlib.h"
#include "string.h"
#include "command.h"
#include "log.h"
#include "graph.h"
extern int
yylex (void);
extern void
set_lexer_string (const char *);
extern void
cleanup_lexer (void);
}
/* functionality this unit exports */
%code provides {
void
command_parse_format (struct graph *, struct cmd_element *);
/* maximum length of a number, lexer will not match anything longer */
#define DECIMAL_STRLEN_MAX 20
}
/* valid semantic types for tokens and rules */
%union {
long long number;
char *string;
struct graph_node *node;
struct subgraph *subgraph;
}
/* union types for lexed tokens */
%token <string> WORD
%token <string> IPV4
%token <string> IPV4_PREFIX
%token <string> IPV6
%token <string> IPV6_PREFIX
%token <string> VARIABLE
%token <string> RANGE
/* union types for parsed rules */
%type <node> start
%type <node> sentence_root
%type <node> literal_token
%type <node> placeholder_token
%type <node> simple_token
%type <subgraph> option
%type <subgraph> option_token
%type <subgraph> option_token_seq
%type <subgraph> selector
%type <subgraph> selector_token
%type <subgraph> selector_token_seq
%type <subgraph> selector_seq_seq
%type <subgraph> compound_token
%code {
/* bison declarations */
void
yyerror (struct graph *, struct cmd_element *el, char const *msg);
/* subgraph semantic value */
struct subgraph {
struct graph_node *start, *end;
};
struct graph_node *currnode, *startnode;
/* pointers to copy of command docstring */
char *docstr_start, *docstr;
/* helper functions for parser */
static char *
doc_next (struct cmd_element *);
static struct graph_node *
node_adjacent (struct graph_node *, struct graph_node *);
static struct graph_node *
add_edge_dedup (struct graph_node *, struct graph_node *);
static int
cmp_token (struct cmd_token *, struct cmd_token *);
static struct graph_node *
new_token_node (struct graph *,
enum cmd_token_type type,
u_char attr, char *text,
char *doc);
static void
terminate_graph (struct graph *,
struct graph_node *,
struct cmd_element *);
static void
cleanup (void);
}
/* yyparse parameters */
%parse-param { struct graph *graph }
%parse-param { struct cmd_element *el }
/* called automatically before yyparse */
%initial-action {
/* clear state pointers */
currnode = startnode = NULL;
startnode = vector_slot (graph->nodes, 0);
/* set string to parse */
set_lexer_string (el->string);
/* copy docstring and keep a pointer to the copy */
if (el->doc)
{
// allocate a new buffer, making room for a flag
size_t length = (size_t) strlen (el->doc) + 2;
docstr = malloc (length);
memcpy (docstr, el->doc, strlen (el->doc));
// set the flag so doc_next knows when to print a warning
docstr[length - 2] = 0x03;
// null terminate
docstr[length - 1] = 0x00;
}
docstr_start = docstr;
}
%%
start:
sentence_root cmd_token_seq
{
// tack on the command element
terminate_graph (graph, currnode, el);
}
| sentence_root cmd_token_seq placeholder_token '.' '.' '.'
{
if ((currnode = add_edge_dedup (currnode, $3)) != $3)
graph_delete_node (graph, $3);
// adding a node as a child of itself accepts any number
// of the same token, which is what we want for variadics
add_edge_dedup (currnode, currnode);
// tack on the command element
terminate_graph (graph, currnode, el);
}
;
sentence_root: WORD
{
struct graph_node *root =
new_token_node (graph, WORD_TKN, el->attr, strdup ($1), doc_next(el));
if ((currnode = add_edge_dedup (startnode, root)) != root)
graph_delete_node (graph, root);
free ($1);
$$ = currnode;
}
;
cmd_token_seq:
%empty
| cmd_token_seq cmd_token
;
cmd_token:
simple_token
{
if ((currnode = add_edge_dedup (currnode, $1)) != $1)
graph_delete_node (graph, $1);
}
| compound_token
{
graph_add_edge (currnode, $1->start);
currnode = $1->end;
free ($1);
}
;
simple_token:
literal_token
| placeholder_token
;
compound_token:
selector
| option
;
literal_token: WORD
{
$$ = new_token_node (graph, WORD_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
;
placeholder_token:
IPV4
{
$$ = new_token_node (graph, IPV4_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
| IPV4_PREFIX
{
$$ = new_token_node (graph, IPV4_PREFIX_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
| IPV6
{
$$ = new_token_node (graph, IPV6_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
| IPV6_PREFIX
{
$$ = new_token_node (graph, IPV6_PREFIX_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
| VARIABLE
{
$$ = new_token_node (graph, VARIABLE_TKN, el->attr, strdup($1), doc_next(el));
free ($1);
}
| RANGE
{
$$ = new_token_node (graph, RANGE_TKN, el->attr, strdup($1), doc_next(el));
struct cmd_token *token = $$->data;
// get the numbers out
yylval.string++;
token->min = strtoll (yylval.string, &yylval.string, 10);
strsep (&yylval.string, "-");
token->max = strtoll (yylval.string, &yylval.string, 10);
// validate range
if (token->min > token->max) yyerror (graph, el, "Invalid range.");
free ($1);
}
/* <selector|set> productions */
selector: '<' selector_seq_seq '>'
{
$$ = malloc (sizeof (struct subgraph));
$$->start = new_token_node (graph, SELECTOR_TKN, el->attr, NULL, NULL);
$$->end = new_token_node (graph, NUL_TKN, el->attr, NULL, NULL);
for (unsigned int i = 0; i < vector_active ($2->start->to); i++)
{
struct graph_node *sn = vector_slot ($2->start->to, i),
*en = vector_slot ($2->end->from, i);
graph_add_edge ($$->start, sn);
graph_add_edge (en, $$->end);
}
graph_delete_node (graph, $2->start);
graph_delete_node (graph, $2->end);
free ($2);
};
selector_seq_seq:
selector_seq_seq '|' selector_token_seq
{
$$ = malloc (sizeof (struct subgraph));
$$->start = graph_new_node (graph, NULL, NULL);
$$->end = graph_new_node (graph, NULL, NULL);
// link in last sequence
graph_add_edge ($$->start, $3->start);
graph_add_edge ($3->end, $$->end);
for (unsigned int i = 0; i < vector_active ($1->start->to); i++)
{
struct graph_node *sn = vector_slot ($1->start->to, i),
*en = vector_slot ($1->end->from, i);
graph_add_edge ($$->start, sn);
graph_add_edge (en, $$->end);
}
graph_delete_node (graph, $1->start);
graph_delete_node (graph, $1->end);
free ($1);
free ($3);
}
| selector_token_seq '|' selector_token_seq
{
$$ = malloc (sizeof (struct subgraph));
$$->start = graph_new_node (graph, NULL, NULL);
$$->end = graph_new_node (graph, NULL, NULL);
graph_add_edge ($$->start, $1->start);
graph_add_edge ($1->end, $$->end);
graph_add_edge ($$->start, $3->start);
graph_add_edge ($3->end, $$->end);
free ($1);
free ($3);
}
;
selector_token_seq:
simple_token
{
$$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| selector_token_seq selector_token
{
$$ = malloc (sizeof (struct subgraph));
graph_add_edge ($1->end, $2->start);
$$->start = $1->start;
$$->end = $2->end;
free ($1);
free ($2);
}
;
selector_token:
simple_token
{
$$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| option
| selector
;
/* [option] productions */
option: '[' option_token_seq ']'
{
// make a new option
$$ = malloc (sizeof (struct subgraph));
$$->start = new_token_node (graph, OPTION_TKN, el->attr, NULL, NULL);
$$->end = new_token_node (graph, NUL_TKN, el->attr, NULL, NULL);
// add a path through the sequence to the end
graph_add_edge ($$->start, $2->start);
graph_add_edge ($2->end, $$->end);
// add a path directly from the start to the end
graph_add_edge ($$->start, $$->end);
free ($2);
}
;
option_token_seq:
option_token
| option_token_seq option_token
{
$$ = malloc (sizeof (struct subgraph));
graph_add_edge ($1->end, $2->start);
$$->start = $1->start;
$$->end = $2->end;
free ($1);
free ($2);
}
;
option_token:
simple_token
{
$$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| compound_token
;
%%
void
command_parse_format (struct graph *graph, struct cmd_element *cmd)
{
// set to 1 to enable parser traces
yydebug = 0;
// parse command into DFA
yyparse (graph, cmd);
// cleanup
cleanup ();
}
/* parser helper functions */
void
yyerror (struct graph *graph, struct cmd_element *el, char const *msg)
{
zlog_err ("%s: FATAL parse error: %s", __func__, msg);
zlog_err ("while parsing this command definition: \n\t%s\n", el->string);
//exit(EXIT_FAILURE);
}
static void
cleanup()
{
/* free resources */
free (docstr_start);
/* cleanup lexer */
cleanup_lexer ();
/* clear state pointers */
currnode = NULL;
docstr_start = docstr = NULL;
}
static void
terminate_graph (struct graph *graph, struct graph_node *finalnode,
struct cmd_element *element)
{
// end of graph should look like this
// * -> finalnode -> END_TKN -> cmd_element
struct graph_node *end_token_node =
new_token_node (graph,
END_TKN,
element->attr,
strdup (CMD_CR_TEXT),
strdup (""));
struct graph_node *end_element_node =
graph_new_node (graph, element, (void (*)(void *)) &del_cmd_element);
if (node_adjacent (finalnode, end_token_node))
yyerror (graph, element, "Duplicate command.");
graph_add_edge (finalnode, end_token_node);
graph_add_edge (end_token_node, end_element_node);
}
static char *
doc_next (struct cmd_element *el)
{
const char *piece = docstr ? strsep (&docstr, "\n") : "";
if (*piece == 0x03)
{
zlog_debug ("Ran out of docstring while parsing '%s'", el->string);
piece = "";
}
return strdup (piece);
}
static struct graph_node *
new_token_node (struct graph *graph, enum cmd_token_type type,
u_char attr, char *text, char *doc)
{
struct cmd_token *token = new_cmd_token (type, attr, text, doc);
return graph_new_node (graph, token, (void (*)(void *)) &del_cmd_token);
}
/**
* Determines if there is an out edge from the first node to the second
*/
static struct graph_node *
node_adjacent (struct graph_node *first, struct graph_node *second)
{
struct graph_node *adj;
for (unsigned int i = 0; i < vector_active (first->to); i++)
{
adj = vector_slot (first->to, i);
struct cmd_token *ftok = adj->data,
*stok = second->data;
if (cmp_token (ftok, stok))
return adj;
}
return NULL;
}
/**
* Creates an edge betwen two nodes, unless there is already an edge to an
* equivalent node.
*
* The first node's out edges are searched to see if any of them point to a
* node that is equivalent to the second node. If such a node exists, it is
* returned. Otherwise an edge is created from the first node to the second.
*
* @param from start node for edge
* @param to end node for edge
* @return the node which the new edge points to
*/
static struct graph_node *
add_edge_dedup (struct graph_node *from, struct graph_node *to)
{
struct graph_node *existing = node_adjacent (from, to);
if (existing)
{
struct cmd_token *ex_tok = existing->data;
struct cmd_token *to_tok = to->data;
// NORMAL takes precedence over DEPRECATED takes precedence over HIDDEN
ex_tok->attr = (ex_tok->attr < to_tok->attr) ? ex_tok->attr : to_tok->attr;
return existing;
}
else
return graph_add_edge (from, to);
}
/**
* Compares two cmd_token's for equality,
*
* As such, this function is the working definition of token equality
* for parsing purposes and determines overall graph structure.
*/
static int
cmp_token (struct cmd_token *first, struct cmd_token *second)
{
// compare types
if (first->type != second->type) return 0;
switch (first->type) {
case WORD_TKN:
case VARIABLE_TKN:
if (first->text && second->text)
{
if (strcmp (first->text, second->text))
return 0;
}
else if (first->text != second->text) return 0;
break;
case RANGE_TKN:
if (first->min != second->min || first->max != second->max)
return 0;
break;
/* selectors and options should be equal if their subgraphs are equal,
* but the graph isomorphism problem is not known to be solvable in
* polynomial time so we consider selectors and options inequal in all
* cases; ultimately this forks the graph, but the matcher can handle
* this regardless
*/
case SELECTOR_TKN:
case OPTION_TKN:
return 0;
/* end nodes are always considered equal, since each node may only
* have one END_TKN child at a time
*/
case START_TKN:
case END_TKN:
case NUL_TKN:
default:
break;
}
return 1;
}

View File

@ -161,7 +161,7 @@ distribute_cmp (const struct distribute *dist1, const struct distribute *dist2)
}
/* Set access-list name to the distribute list. */
static struct distribute *
static void
distribute_list_set (const char *ifname, enum distribute_type type,
const char *alist_name)
{
@ -175,8 +175,6 @@ distribute_list_set (const char *ifname, enum distribute_type type,
/* Apply this distribute-list to the interface. */
(*distribute_add_hook) (dist);
return dist;
}
/* Unset distribute-list. If matched distribute-list exist then
@ -208,7 +206,7 @@ distribute_list_unset (const char *ifname, enum distribute_type type,
}
/* Set access-list name to the distribute list. */
static struct distribute *
static void
distribute_list_prefix_set (const char *ifname, enum distribute_type type,
const char *plist_name)
{
@ -222,8 +220,6 @@ distribute_list_prefix_set (const char *ifname, enum distribute_type type,
/* Apply this distribute-list to the interface. */
(*distribute_add_hook) (dist);
return dist;
}
/* Unset distribute-list. If matched distribute-list exist then
@ -254,212 +250,70 @@ distribute_list_prefix_unset (const char *ifname, enum distribute_type type,
return 1;
}
DEFUN (distribute_list_all,
distribute_list_all_cmd,
"distribute-list WORD (in|out)",
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Get interface name corresponding distribute list. */
distribute_list_set (NULL, type, argv[0]);
return CMD_SUCCESS;
}
DEFUN (ipv6_distribute_list_all,
ipv6_distribute_list_all_cmd,
"ipv6 distribute-list WORD (in|out)",
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Get interface name corresponding distribute list. */
distribute_list_set (NULL, type, argv[0]);
return CMD_SUCCESS;
}
ALIAS (ipv6_distribute_list_all,
ipv6_as_v4_distribute_list_all_cmd,
"distribute-list WORD (in|out)",
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
DEFUN (no_distribute_list_all,
no_distribute_list_all_cmd,
"no distribute-list WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_unset (NULL, type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
DEFUN (no_ipv6_distribute_list_all,
no_ipv6_distribute_list_all_cmd,
"no ipv6 distribute-list WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_unset (NULL, type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
ALIAS (no_ipv6_distribute_list_all,
no_ipv6_as_v4_distribute_list_all_cmd,
"no distribute-list WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
DEFUN (distribute_list,
distribute_list_cmd,
"distribute-list WORD (in|out) WORD",
"distribute-list [prefix] WORD <in|out> [WORD]",
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
enum distribute_type type;
int prefix = (argv[1]->type == WORD_TKN) ? 1 : 0;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
return CMD_WARNING;
}
enum distribute_type type = argv[2 + prefix]->arg[0] == 'i' ?
DISTRIBUTE_V4_IN : DISTRIBUTE_V4_OUT;
/* Set appropriate function call */
void (*distfn)(const char *, enum distribute_type, const char *) = prefix ?
&distribute_list_prefix_set : &distribute_list_set;
/* if interface is present, get name */
const char *ifname = NULL;
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
/* Get interface name corresponding distribute list. */
distribute_list_set (argv[2], type, argv[0]);
distfn (ifname, type, argv[1 + prefix]->arg);
return CMD_SUCCESS;
}
DEFUN (ipv6_distribute_list,
ipv6_distribute_list_cmd,
"ipv6 distribute-list WORD (in|out) WORD",
"ipv6 distribute-list [prefix] WORD <in|out> [WORD]",
"IPv6\n"
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
enum distribute_type type;
int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
return CMD_WARNING;
}
enum distribute_type type = argv[3 + prefix]->arg[0] == 'i' ?
DISTRIBUTE_V6_IN : DISTRIBUTE_V6_OUT;
/* Set appropriate function call */
void (*distfn)(const char *, enum distribute_type, const char *) = prefix ?
&distribute_list_prefix_set : &distribute_list_set;
/* if interface is present, get name */
const char *ifname = NULL;
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
/* Get interface name corresponding distribute list. */
distribute_list_set (argv[2], type, argv[0]);
distfn (ifname, type, argv[1 + prefix]->arg);
return CMD_SUCCESS;
}
ALIAS (ipv6_distribute_list,
ipv6_as_v4_distribute_list_cmd,
"distribute-list WORD (in|out) WORD",
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
DEFUN (no_distribute_list, no_distribute_list_cmd,
"no distribute-list WORD (in|out) WORD",
DEFUN (no_distribute_list,
no_distribute_list_cmd,
"no [ipv6] distribute-list [prefix] WORD <in|out> [WORD]",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
@ -467,165 +321,29 @@ DEFUN (no_distribute_list, no_distribute_list_cmd,
"Filter outgoing routing updates\n"
"Interface name\n")
{
int ret;
enum distribute_type type;
int ipv6 = strmatch(argv[1]->text, "ipv6");
int prefix = (argv[2 + ipv6]->type == WORD_TKN) ? 1 : 0;
int idx_alname = 2 + ipv6 + prefix;
int idx_disttype = idx_alname + 1;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
return CMD_WARNING;
}
enum distribute_type distin = (ipv6) ? DISTRIBUTE_V6_IN : DISTRIBUTE_V4_IN;
enum distribute_type distout = (ipv6) ? DISTRIBUTE_V6_OUT : DISTRIBUTE_V4_OUT;
ret = distribute_list_unset (argv[2], type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
enum distribute_type type = argv[idx_disttype]->arg[0] == 'i' ? distin : distout;
DEFUN (no_ipv6_distribute_list,
no_ipv6_distribute_list_cmd,
"no ipv6 distribute-list WORD (in|out) WORD",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s", VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_unset (argv[2], type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
ALIAS (no_ipv6_distribute_list,
no_ipv6_as_v4_distribute_list_cmd,
"no distribute-list WORD (in|out) WORD",
NO_STR
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
DEFUN (distribute_list_prefix_all,
distribute_list_prefix_all_cmd,
"distribute-list prefix WORD (in|out)",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Set appropriate function call */
int (*distfn)(const char *, enum distribute_type, const char *) = prefix ?
&distribute_list_prefix_unset : &distribute_list_unset;
/* if interface is present, get name */
const char *ifname = NULL;
if (argv[argc - 1]->type == VARIABLE_TKN)
ifname = argv[argc - 1]->arg;
/* Get interface name corresponding distribute list. */
distribute_list_prefix_set (NULL, type, argv[0]);
int ret = distfn (ifname, type, argv[2 + prefix]->arg);
return CMD_SUCCESS;
}
DEFUN (ipv6_distribute_list_prefix_all,
ipv6_distribute_list_prefix_all_cmd,
"ipv6 distribute-list prefix WORD (in|out)",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Get interface name corresponding distribute list. */
distribute_list_prefix_set (NULL, type, argv[0]);
return CMD_SUCCESS;
}
ALIAS (ipv6_distribute_list_prefix_all,
ipv6_as_v4_distribute_list_prefix_all_cmd,
"distribute-list prefix WORD (in|out)",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
DEFUN (no_distribute_list_prefix_all,
no_distribute_list_prefix_all_cmd,
"no distribute-list prefix WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_prefix_unset (NULL, type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
@ -634,199 +352,6 @@ DEFUN (no_distribute_list_prefix_all,
return CMD_SUCCESS;
}
DEFUN (no_ipv6_distribute_list_prefix_all,
no_ipv6_distribute_list_prefix_all_cmd,
"no ipv6 distribute-list prefix WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_prefix_unset (NULL, type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
ALIAS (no_ipv6_distribute_list_prefix_all,
no_ipv6_as_v4_distribute_list_prefix_all_cmd,
"no distribute-list prefix WORD (in|out)",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n")
DEFUN (distribute_list_prefix, distribute_list_prefix_cmd,
"distribute-list prefix WORD (in|out) WORD",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Get interface name corresponding distribute list. */
distribute_list_prefix_set (argv[2], type, argv[0]);
return CMD_SUCCESS;
}
DEFUN (ipv6_distribute_list_prefix,
ipv6_distribute_list_prefix_cmd,
"ipv6 distribute-list prefix WORD (in|out) WORD",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Get interface name corresponding distribute list. */
distribute_list_prefix_set (argv[2], type, argv[0]);
return CMD_SUCCESS;
}
ALIAS (ipv6_distribute_list_prefix,
ipv6_as_v4_distribute_list_prefix_cmd,
"distribute-list prefix WORD (in|out) WORD",
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
DEFUN (no_distribute_list_prefix, no_distribute_list_prefix_cmd,
"no distribute-list prefix WORD (in|out) WORD",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V4_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V4_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_prefix_unset (argv[2], type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
DEFUN (no_ipv6_distribute_list_prefix,
no_ipv6_distribute_list_prefix_cmd,
"no ipv6 distribute-list prefix WORD (in|out) WORD",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
int ret;
enum distribute_type type;
/* Check of distribute list type. */
if (strncmp (argv[1], "i", 1) == 0)
type = DISTRIBUTE_V6_IN;
else if (strncmp (argv[1], "o", 1) == 0)
type = DISTRIBUTE_V6_OUT;
else
{
vty_out (vty, "distribute list direction must be [in|out]%s",
VTY_NEWLINE);
return CMD_WARNING;
}
ret = distribute_list_prefix_unset (argv[2], type, argv[0]);
if (! ret)
{
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
ALIAS (no_ipv6_distribute_list_prefix,
no_ipv6_as_v4_distribute_list_prefix_cmd,
"no distribute-list prefix WORD (in|out) WORD",
NO_STR
"Filter networks in routing updates\n"
"Filter prefixes in routing updates\n"
"Name of an IP prefix-list\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
static int
distribute_print (struct vty *vty, char *tab[], int is_prefix,
enum distribute_type type, int has_print)
@ -997,39 +522,24 @@ distribute_list_init (int node)
{
disthash = hash_create (distribute_hash_make,
(int (*) (const void *, const void *)) distribute_cmp);
/* install v4 */
if (node == RIP_NODE) {
install_element (node, &distribute_list_all_cmd);
install_element (node, &no_distribute_list_all_cmd);
install_element (node, &distribute_list_cmd);
install_element (node, &no_distribute_list_cmd);
install_element (node, &distribute_list_prefix_all_cmd);
install_element (node, &no_distribute_list_prefix_all_cmd);
install_element (node, &distribute_list_prefix_cmd);
install_element (node, &no_distribute_list_prefix_cmd);
}
/* install v6 */
if (node == RIPNG_NODE) {
install_element (node, &ipv6_distribute_list_all_cmd);
install_element (node, &no_ipv6_distribute_list_all_cmd);
install_element (node, &ipv6_distribute_list_cmd);
install_element (node, &no_ipv6_distribute_list_cmd);
install_element (node, &ipv6_distribute_list_prefix_all_cmd);
install_element (node, &no_ipv6_distribute_list_prefix_all_cmd);
install_element (node, &ipv6_distribute_list_prefix_cmd);
install_element (node, &no_ipv6_distribute_list_prefix_cmd);
}
/* install v4 syntax command for v6 only protocols. */
if (node == RIPNG_NODE) {
install_element (node, &ipv6_as_v4_distribute_list_all_cmd);
install_element (node, &no_ipv6_as_v4_distribute_list_all_cmd);
install_element (node, &ipv6_as_v4_distribute_list_cmd);
install_element (node, &no_ipv6_as_v4_distribute_list_cmd);
install_element (node, &ipv6_as_v4_distribute_list_prefix_all_cmd);
install_element (node, &no_ipv6_as_v4_distribute_list_prefix_all_cmd);
install_element (node, &ipv6_as_v4_distribute_list_prefix_cmd);
install_element (node, &no_ipv6_as_v4_distribute_list_prefix_cmd);
}
/* TODO: install v4 syntax command for v6 only protocols. */
/* if (node == RIPNG_NODE) {
* install_element (node, &ipv6_as_v4_distribute_list_all_cmd);
* install_element (node, &no_ipv6_as_v4_distribute_list_all_cmd);
* install_element (node, &ipv6_as_v4_distribute_list_cmd);
* install_element (node, &no_ipv6_as_v4_distribute_list_cmd);
* install_element (node, &ipv6_as_v4_distribute_list_prefix_all_cmd);
* install_element (node, &no_ipv6_as_v4_distribute_list_prefix_all_cmd);
* install_element (node, &ipv6_as_v4_distribute_list_prefix_cmd);
* install_element (node, &no_ipv6_as_v4_distribute_list_prefix_cmd);
}*/
}

View File

@ -704,7 +704,7 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
/* Standard access-list */
DEFUN (access_list_standard,
access_list_standard_cmd,
"access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D A.B.C.D",
"access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D A.B.C.D",
"Add an access list entry\n"
"IP standard access list\n"
"IP standard access list (expanded range)\n"
@ -713,13 +713,17 @@ DEFUN (access_list_standard,
"Address to match\n"
"Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3],
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 3;
int idx_ipv4_2 = 4;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg,
NULL, NULL, 0, 1);
}
DEFUN (access_list_standard_nomask,
access_list_standard_nomask_cmd,
"access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D",
"access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D",
"Add an access list entry\n"
"IP standard access list\n"
"IP standard access list (expanded range)\n"
@ -727,13 +731,16 @@ DEFUN (access_list_standard_nomask,
"Specify packets to forward\n"
"Address to match\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0",
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 3;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0",
NULL, NULL, 0, 1);
}
DEFUN (access_list_standard_host,
access_list_standard_host_cmd,
"access-list (<1-99>|<1300-1999>) (deny|permit) host A.B.C.D",
"access-list <(1-99)|(1300-1999)> <deny|permit> host A.B.C.D",
"Add an access list entry\n"
"IP standard access list\n"
"IP standard access list (expanded range)\n"
@ -742,13 +749,16 @@ DEFUN (access_list_standard_host,
"A single host address\n"
"Address to match\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0",
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 4;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0",
NULL, NULL, 0, 1);
}
DEFUN (access_list_standard_any,
access_list_standard_any_cmd,
"access-list (<1-99>|<1300-1999>) (deny|permit) any",
"access-list <(1-99)|(1300-1999)> <deny|permit> any",
"Add an access list entry\n"
"IP standard access list\n"
"IP standard access list (expanded range)\n"
@ -756,13 +766,15 @@ DEFUN (access_list_standard_any,
"Specify packets to forward\n"
"Any source host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
int idx_acl = 1;
int idx_permit_deny = 2;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", NULL, NULL, 0, 1);
}
DEFUN (no_access_list_standard,
no_access_list_standard_cmd,
"no access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D A.B.C.D",
"no access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -772,13 +784,17 @@ DEFUN (no_access_list_standard,
"Address to match\n"
"Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], argv[3],
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, argv[idx_ipv4_2]->arg,
NULL, NULL, 0, 0);
}
DEFUN (no_access_list_standard_nomask,
no_access_list_standard_nomask_cmd,
"no access-list (<1-99>|<1300-1999>) (deny|permit) A.B.C.D",
"no access-list <(1-99)|(1300-1999)> <deny|permit> A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -787,13 +803,16 @@ DEFUN (no_access_list_standard_nomask,
"Specify packets to forward\n"
"Address to match\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0",
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 4;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0",
NULL, NULL, 0, 0);
}
DEFUN (no_access_list_standard_host,
no_access_list_standard_host_cmd,
"no access-list (<1-99>|<1300-1999>) (deny|permit) host A.B.C.D",
"no access-list <(1-99)|(1300-1999)> <deny|permit> host A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -803,13 +822,16 @@ DEFUN (no_access_list_standard_host,
"A single host address\n"
"Address to match\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2], "0.0.0.0",
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 5;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg, "0.0.0.0",
NULL, NULL, 0, 0);
}
DEFUN (no_access_list_standard_any,
no_access_list_standard_any_cmd,
"no access-list (<1-99>|<1300-1999>) (deny|permit) any",
"no access-list <(1-99)|(1300-1999)> <deny|permit> any",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -818,14 +840,16 @@ DEFUN (no_access_list_standard_any,
"Specify packets to forward\n"
"Any source host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
int idx_acl = 2;
int idx_permit_deny = 3;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", NULL, NULL, 0, 0);
}
/* Extended access-list */
DEFUN (access_list_extended,
access_list_extended_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -837,13 +861,19 @@ DEFUN (access_list_extended,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5], 1 ,1);
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
int idx_ipv4_3 = 6;
int idx_ipv4_4 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, argv[idx_ipv4_4]->arg, 1 ,1);
}
DEFUN (access_list_extended_mask_any,
access_list_extended_mask_any_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D any",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D any",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -854,14 +884,18 @@ DEFUN (access_list_extended_mask_any,
"Source wildcard bits\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], "0.0.0.0",
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, "0.0.0.0",
"255.255.255.255", 1, 1);
}
DEFUN (access_list_extended_any_mask,
access_list_extended_any_mask_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip any A.B.C.D A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip any A.B.C.D A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -872,14 +906,18 @@ DEFUN (access_list_extended_any_mask,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
"255.255.255.255", argv[2],
argv[3], 1, 1);
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, 1, 1);
}
DEFUN (access_list_extended_any_any,
access_list_extended_any_any_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip any any",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip any any",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -889,14 +927,16 @@ DEFUN (access_list_extended_any_any,
"Any source host\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
int idx_acl = 1;
int idx_permit_deny = 2;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", "0.0.0.0",
"255.255.255.255", 1, 1);
}
DEFUN (access_list_extended_mask_host,
access_list_extended_mask_host_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D host A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D host A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -908,14 +948,19 @@ DEFUN (access_list_extended_mask_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], argv[4],
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 4;
int idx_ipv4_2 = 5;
int idx_ipv4_3 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg,
"0.0.0.0", 1, 1);
}
DEFUN (access_list_extended_host_mask,
access_list_extended_host_mask_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D A.B.C.D A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D A.B.C.D A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -927,14 +972,19 @@ DEFUN (access_list_extended_host_mask,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
"0.0.0.0", argv[3],
argv[4], 1, 1);
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
int idx_ipv4_3 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", argv[idx_ipv4_2]->arg,
argv[idx_ipv4_3]->arg, 1, 1);
}
DEFUN (access_list_extended_host_host,
access_list_extended_host_host_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D host A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D host A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -946,14 +996,18 @@ DEFUN (access_list_extended_host_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
"0.0.0.0", argv[3],
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 5;
int idx_ipv4_2 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", argv[idx_ipv4_2]->arg,
"0.0.0.0", 1, 1);
}
DEFUN (access_list_extended_any_host,
access_list_extended_any_host_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip any host A.B.C.D",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip any host A.B.C.D",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -964,14 +1018,17 @@ DEFUN (access_list_extended_any_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
"255.255.255.255", argv[2],
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 6;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", argv[idx_ipv4]->arg,
"0.0.0.0", 1, 1);
}
DEFUN (access_list_extended_host_any,
access_list_extended_host_any_cmd,
"access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D any",
"access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D any",
"Add an access list entry\n"
"IP extended access list\n"
"IP extended access list (expanded range)\n"
@ -982,14 +1039,17 @@ DEFUN (access_list_extended_host_any,
"Source address\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
int idx_acl = 1;
int idx_permit_deny = 2;
int idx_ipv4 = 5;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", "0.0.0.0",
"255.255.255.255", 1, 1);
}
DEFUN (no_access_list_extended,
no_access_list_extended_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1002,13 +1062,19 @@ DEFUN (no_access_list_extended,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5], 1, 0);
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
int idx_ipv4_3 = 7;
int idx_ipv4_4 = 8;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg, argv[idx_ipv4_4]->arg, 1, 0);
}
DEFUN (no_access_list_extended_mask_any,
no_access_list_extended_mask_any_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D any",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D any",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1020,14 +1086,18 @@ DEFUN (no_access_list_extended_mask_any,
"Source wildcard bits\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], "0.0.0.0",
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, "0.0.0.0",
"255.255.255.255", 1, 0);
}
DEFUN (no_access_list_extended_any_mask,
no_access_list_extended_any_mask_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip any A.B.C.D A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip any A.B.C.D A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1039,14 +1109,18 @@ DEFUN (no_access_list_extended_any_mask,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
"255.255.255.255", argv[2],
argv[3], 1, 0);
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 6;
int idx_ipv4_2 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, 1, 0);
}
DEFUN (no_access_list_extended_any_any,
no_access_list_extended_any_any_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip any any",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip any any",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1057,14 +1131,16 @@ DEFUN (no_access_list_extended_any_any,
"Any source host\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
int idx_acl = 2;
int idx_permit_deny = 3;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", "0.0.0.0",
"255.255.255.255", 1, 0);
}
DEFUN (no_access_list_extended_mask_host,
no_access_list_extended_mask_host_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip A.B.C.D A.B.C.D host A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip A.B.C.D A.B.C.D host A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1077,14 +1153,19 @@ DEFUN (no_access_list_extended_mask_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
argv[3], argv[4],
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 5;
int idx_ipv4_2 = 6;
int idx_ipv4_3 = 8;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
argv[idx_ipv4_2]->arg, argv[idx_ipv4_3]->arg,
"0.0.0.0", 1, 0);
}
DEFUN (no_access_list_extended_host_mask,
no_access_list_extended_host_mask_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D A.B.C.D A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D A.B.C.D A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1097,14 +1178,19 @@ DEFUN (no_access_list_extended_host_mask,
"Destination address\n"
"Destination Wildcard bits\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
"0.0.0.0", argv[3],
argv[4], 1, 0);
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 6;
int idx_ipv4_2 = 7;
int idx_ipv4_3 = 8;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", argv[idx_ipv4_2]->arg,
argv[idx_ipv4_3]->arg, 1, 0);
}
DEFUN (no_access_list_extended_host_host,
no_access_list_extended_host_host_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D host A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D host A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1117,14 +1203,18 @@ DEFUN (no_access_list_extended_host_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
"0.0.0.0", argv[3],
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 6;
int idx_ipv4_2 = 8;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", argv[idx_ipv4_2]->arg,
"0.0.0.0", 1, 0);
}
DEFUN (no_access_list_extended_any_host,
no_access_list_extended_any_host_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip any host A.B.C.D",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip any host A.B.C.D",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1136,14 +1226,17 @@ DEFUN (no_access_list_extended_any_host,
"A single destination host\n"
"Destination address\n")
{
return filter_set_cisco (vty, argv[0], argv[1], "0.0.0.0",
"255.255.255.255", argv[2],
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 7;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, "0.0.0.0",
"255.255.255.255", argv[idx_ipv4]->arg,
"0.0.0.0", 1, 0);
}
DEFUN (no_access_list_extended_host_any,
no_access_list_extended_host_any_cmd,
"no access-list (<100-199>|<2000-2699>) (deny|permit) ip host A.B.C.D any",
"no access-list <(100-199)|(2000-2699)> <deny|permit> ip host A.B.C.D any",
NO_STR
"Add an access list entry\n"
"IP extended access list\n"
@ -1155,7 +1248,10 @@ DEFUN (no_access_list_extended_host_any,
"Source address\n"
"Any destination host\n")
{
return filter_set_cisco (vty, argv[0], argv[1], argv[2],
int idx_acl = 2;
int idx_permit_deny = 3;
int idx_ipv4 = 6;
return filter_set_cisco (vty, argv[idx_acl]->arg, argv[idx_permit_deny]->arg, argv[idx_ipv4]->arg,
"0.0.0.0", "0.0.0.0",
"255.255.255.255", 1, 0);
}
@ -1244,19 +1340,22 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
/* Zebra access-list */
DEFUN (access_list,
access_list_cmd,
"access-list WORD (deny|permit) A.B.C.D/M",
"access-list WORD <deny|permit> A.B.C.D/M",
"Add an access list entry\n"
"IP zebra access-list name\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"Prefix to match. e.g. 10.0.0.0/8\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 1);
int idx_word = 1;
int idx_permit_deny = 2;
int idx_ipv4_prefixlen = 3;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 1);
}
DEFUN (access_list_exact,
access_list_exact_cmd,
"access-list WORD (deny|permit) A.B.C.D/M exact-match",
"access-list WORD <deny|permit> A.B.C.D/M exact-match",
"Add an access list entry\n"
"IP zebra access-list name\n"
"Specify packets to reject\n"
@ -1264,24 +1363,29 @@ DEFUN (access_list_exact,
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 1);
int idx_word = 1;
int idx_permit_deny = 2;
int idx_ipv4_prefixlen = 3;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 1);
}
DEFUN (access_list_any,
access_list_any_cmd,
"access-list WORD (deny|permit) any",
"access-list WORD <deny|permit> any",
"Add an access list entry\n"
"IP zebra access-list name\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"Prefix to match. e.g. 10.0.0.0/8\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 1);
int idx_word = 1;
int idx_permit_deny = 2;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, "0.0.0.0/0", 0, 1);
}
DEFUN (no_access_list,
no_access_list_cmd,
"no access-list WORD (deny|permit) A.B.C.D/M",
"no access-list WORD <deny|permit> A.B.C.D/M",
NO_STR
"Add an access list entry\n"
"IP zebra access-list name\n"
@ -1289,12 +1393,15 @@ DEFUN (no_access_list,
"Specify packets to forward\n"
"Prefix to match. e.g. 10.0.0.0/8\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 0, 0);
int idx_word = 2;
int idx_permit_deny = 3;
int idx_ipv4_prefixlen = 4;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 0);
}
DEFUN (no_access_list_exact,
no_access_list_exact_cmd,
"no access-list WORD (deny|permit) A.B.C.D/M exact-match",
"no access-list WORD <deny|permit> A.B.C.D/M exact-match",
NO_STR
"Add an access list entry\n"
"IP zebra access-list name\n"
@ -1303,12 +1410,15 @@ DEFUN (no_access_list_exact,
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, argv[2], 1, 0);
int idx_word = 2;
int idx_permit_deny = 3;
int idx_ipv4_prefixlen = 4;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 0);
}
DEFUN (no_access_list_any,
no_access_list_any_cmd,
"no access-list WORD (deny|permit) any",
"no access-list WORD <deny|permit> any",
NO_STR
"Add an access list entry\n"
"IP zebra access-list name\n"
@ -1316,12 +1426,14 @@ DEFUN (no_access_list_any,
"Specify packets to forward\n"
"Prefix to match. e.g. 10.0.0.0/8\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP, "0.0.0.0/0", 0, 0);
int idx_word = 2;
int idx_permit_deny = 3;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, "0.0.0.0/0", 0, 0);
}
DEFUN (no_access_list_all,
no_access_list_all_cmd,
"no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD)",
"no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD>",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -1330,14 +1442,15 @@ DEFUN (no_access_list_all,
"IP extended access list (expanded range)\n"
"IP zebra access-list name\n")
{
int idx_acl = 2;
struct access_list *access;
struct access_master *master;
/* Looking up access_list. */
access = access_list_lookup (AFI_IP, argv[0]);
access = access_list_lookup (AFI_IP, argv[idx_acl]->arg);
if (access == NULL)
{
vty_out (vty, "%% access-list %s doesn't exist%s", argv[0],
vty_out (vty, "%% access-list %s doesn't exist%s", argv[idx_acl]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -1357,7 +1470,7 @@ DEFUN (no_access_list_all,
DEFUN (access_list_remark,
access_list_remark_cmd,
"access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark .LINE",
"access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark LINE...",
"Add an access list entry\n"
"IP standard access list\n"
"IP extended access list\n"
@ -1367,23 +1480,25 @@ DEFUN (access_list_remark,
"Access list entry comment\n"
"Comment up to 100 characters\n")
{
int idx_acl = 1;
int idx_remark = 3;
struct access_list *access;
access = access_list_get (AFI_IP, argv[0]);
access = access_list_get (AFI_IP, argv[idx_acl]->arg);
if (access->remark)
{
XFREE (MTYPE_TMP, access->remark);
access->remark = NULL;
}
access->remark = argv_concat(argv, argc, 1);
access->remark = argv_concat(argv, argc, idx_remark);
return CMD_SUCCESS;
}
DEFUN (no_access_list_remark,
no_access_list_remark_cmd,
"no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark",
"no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -1393,12 +1508,14 @@ DEFUN (no_access_list_remark,
"IP zebra access-list\n"
"Access list entry comment\n")
{
return vty_access_list_remark_unset (vty, AFI_IP, argv[0]);
int idx_acl = 2;
return vty_access_list_remark_unset (vty, AFI_IP, argv[idx_acl]->arg);
}
ALIAS (no_access_list_remark,
no_access_list_remark_arg_cmd,
"no access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD) remark .LINE",
/* ALIAS_FIXME */
DEFUN (no_access_list_remark_comment,
no_access_list_remark_comment_cmd,
"no access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD> remark LINE...",
NO_STR
"Add an access list entry\n"
"IP standard access list\n"
@ -1408,38 +1525,48 @@ ALIAS (no_access_list_remark,
"IP zebra access-list\n"
"Access list entry comment\n"
"Comment up to 100 characters\n")
{
return no_access_list_remark (self, vty, argc, argv);
}
#ifdef HAVE_IPV6
DEFUN (ipv6_access_list,
ipv6_access_list_cmd,
"ipv6 access-list WORD (deny|permit) X:X::X:X/M",
"ipv6 access-list WORD <deny|permit> X:X::X:X/M",
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"Prefix to match. e.g. 3ffe:506::/32\n")
"IPv6 prefix\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 1);
int idx = 0;
char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
char *prefix = argv_find (argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL;
return filter_set_zebra (vty, alname, argv[3]->text, AFI_IP6, prefix, 0, 1);
}
DEFUN (ipv6_access_list_exact,
ipv6_access_list_exact_cmd,
"ipv6 access-list WORD (deny|permit) X:X::X:X/M exact-match",
"ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match",
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
"Specify packets to reject\n"
"Specify packets to forward\n"
"Prefix to match. e.g. 3ffe:506::/32\n"
"IPv6 prefix\n"
"Exact match of the prefixes\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 1, 1);
int idx = 0;
char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
char *prefix = argv_find (argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL;
return filter_set_zebra (vty, alname, argv[3]->text, AFI_IP6, prefix, 1, 1);
}
DEFUN (ipv6_access_list_any,
ipv6_access_list_any_cmd,
"ipv6 access-list WORD (deny|permit) any",
"ipv6 access-list WORD <deny|permit> any",
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
@ -1447,12 +1574,14 @@ DEFUN (ipv6_access_list_any,
"Specify packets to forward\n"
"Any prefixi to match\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 1);
int idx_word = 2;
int idx_permit_deny = 3;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, "::/0", 0, 1);
}
DEFUN (no_ipv6_access_list,
no_ipv6_access_list_cmd,
"no ipv6 access-list WORD (deny|permit) X:X::X:X/M",
"no ipv6 access-list WORD <deny|permit> X:X::X:X/M",
NO_STR
IPV6_STR
"Add an access list entry\n"
@ -1461,12 +1590,15 @@ DEFUN (no_ipv6_access_list,
"Specify packets to forward\n"
"Prefix to match. e.g. 3ffe:506::/32\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 0, 0);
int idx_word = 3;
int idx_permit_deny = 4;
int idx_ipv6_prefixlen = 5;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 0, 0);
}
DEFUN (no_ipv6_access_list_exact,
no_ipv6_access_list_exact_cmd,
"no ipv6 access-list WORD (deny|permit) X:X::X:X/M exact-match",
"no ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match",
NO_STR
IPV6_STR
"Add an access list entry\n"
@ -1476,12 +1608,15 @@ DEFUN (no_ipv6_access_list_exact,
"Prefix to match. e.g. 3ffe:506::/32\n"
"Exact match of the prefixes\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, argv[2], 1, 0);
int idx_word = 3;
int idx_permit_deny = 4;
int idx_ipv6_prefixlen = 5;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 1, 0);
}
DEFUN (no_ipv6_access_list_any,
no_ipv6_access_list_any_cmd,
"no ipv6 access-list WORD (deny|permit) any",
"no ipv6 access-list WORD <deny|permit> any",
NO_STR
IPV6_STR
"Add an access list entry\n"
@ -1490,7 +1625,9 @@ DEFUN (no_ipv6_access_list_any,
"Specify packets to forward\n"
"Any prefixi to match\n")
{
return filter_set_zebra (vty, argv[0], argv[1], AFI_IP6, "::/0", 0, 0);
int idx_word = 3;
int idx_permit_deny = 4;
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, "::/0", 0, 0);
}
@ -1502,14 +1639,15 @@ DEFUN (no_ipv6_access_list_all,
"Add an access list entry\n"
"IPv6 zebra access-list\n")
{
int idx_word = 3;
struct access_list *access;
struct access_master *master;
/* Looking up access_list. */
access = access_list_lookup (AFI_IP6, argv[0]);
access = access_list_lookup (AFI_IP6, argv[idx_word]->arg);
if (access == NULL)
{
vty_out (vty, "%% access-list %s doesn't exist%s", argv[0],
vty_out (vty, "%% access-list %s doesn't exist%s", argv[idx_word]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -1529,23 +1667,25 @@ DEFUN (no_ipv6_access_list_all,
DEFUN (ipv6_access_list_remark,
ipv6_access_list_remark_cmd,
"ipv6 access-list WORD remark .LINE",
"ipv6 access-list WORD remark LINE...",
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
"Access list entry comment\n"
"Comment up to 100 characters\n")
{
int idx_word = 2;
int idx_line = 4;
struct access_list *access;
access = access_list_get (AFI_IP6, argv[0]);
access = access_list_get (AFI_IP6, argv[idx_word]->arg);
if (access->remark)
{
XFREE (MTYPE_TMP, access->remark);
access->remark = NULL;
}
access->remark = argv_concat(argv, argc, 1);
access->remark = argv_concat(argv, argc, idx_line);
return CMD_SUCCESS;
}
@ -1559,18 +1699,24 @@ DEFUN (no_ipv6_access_list_remark,
"IPv6 zebra access-list\n"
"Access list entry comment\n")
{
return vty_access_list_remark_unset (vty, AFI_IP6, argv[0]);
int idx_word = 3;
return vty_access_list_remark_unset (vty, AFI_IP6, argv[idx_word]->arg);
}
ALIAS (no_ipv6_access_list_remark,
no_ipv6_access_list_remark_arg_cmd,
"no ipv6 access-list WORD remark .LINE",
/* ALIAS_FIXME */
DEFUN (no_ipv6_access_list_remark_comment,
no_ipv6_access_list_remark_comment_cmd,
"no ipv6 access-list WORD remark LINE...",
NO_STR
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
"Access list entry comment\n"
"Comment up to 100 characters\n")
{
return no_ipv6_access_list_remark (self, vty, argc, argv);
}
#endif /* HAVE_IPV6 */
void config_write_access_zebra (struct vty *, struct filter *);
@ -1695,7 +1841,7 @@ DEFUN (show_ip_access_list,
DEFUN (show_ip_access_list_name,
show_ip_access_list_name_cmd,
"show ip access-list (<1-99>|<100-199>|<1300-1999>|<2000-2699>|WORD)",
"show ip access-list <(1-99)|(100-199)|(1300-1999)|(2000-2699)|WORD>",
SHOW_STR
IP_STR
"List IP access lists\n"
@ -1705,7 +1851,8 @@ DEFUN (show_ip_access_list_name,
"IP extended access list (expanded range)\n"
"IP zebra access-list\n")
{
return filter_show (vty, argv[0], AFI_IP);
int idx_acl = 3;
return filter_show (vty, argv[idx_acl]->arg, AFI_IP);
}
#ifdef HAVE_IPV6
@ -1727,7 +1874,8 @@ DEFUN (show_ipv6_access_list_name,
"List IPv6 access lists\n"
"IPv6 zebra access-list\n")
{
return filter_show (vty, argv[0], AFI_IP6);
int idx_word = 3;
return filter_show (vty, argv[idx_word]->arg, AFI_IP6);
}
#endif /* HAVE_IPV6 */
@ -1958,7 +2106,7 @@ access_list_init_ipv4 (void)
install_element (CONFIG_NODE, &access_list_remark_cmd);
install_element (CONFIG_NODE, &no_access_list_all_cmd);
install_element (CONFIG_NODE, &no_access_list_remark_cmd);
install_element (CONFIG_NODE, &no_access_list_remark_arg_cmd);
install_element (CONFIG_NODE, &no_access_list_remark_comment_cmd);
}
#ifdef HAVE_IPV6
@ -2022,7 +2170,7 @@ access_list_init_ipv6 (void)
install_element (CONFIG_NODE, &no_ipv6_access_list_all_cmd);
install_element (CONFIG_NODE, &ipv6_access_list_remark_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_remark_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_remark_arg_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_remark_comment_cmd);
}
#endif /* HAVE_IPV6 */

386
lib/grammar_sandbox.c Normal file
View File

@ -0,0 +1,386 @@
/*
* Testing shim and API examples for the new CLI backend.
*
* This unit defines a number of commands in the old engine that can
* be used to test and interact with the new engine.
*
* This shim should be removed upon integration. It is currently hooked in
* vtysh/vtysh.c. It has no header, vtysh.c merely includes this entire unit
* since it clutters up the makefiles less and this is only a temporary shim.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include "command.h"
#include "graph.h"
#include "command_parse.h"
#include "command_match.h"
#define GRAMMAR_STR "CLI grammar sandbox\n"
/** headers **/
void
grammar_sandbox_init (void);
void
pretty_print_graph (struct graph_node *, int);
void
init_cmdgraph (struct graph **);
vector
completions_to_vec (struct list *);
int
compare_completions (const void *, const void *);
/** shim interface commands **/
struct graph *nodegraph;
DEFUN (grammar_test,
grammar_test_cmd,
"grammar parse .COMMAND",
GRAMMAR_STR
"command to pass to new parser\n")
{
int idx_command = 2;
// make a string from tokenized command line
char *command = argv_concat (argv, argc, idx_command);
// create cmd_element for parser
struct cmd_element *cmd = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_element));
cmd->string = command;
cmd->doc = NULL;
cmd->func = NULL;
cmd->tokens = vector_init (VECTOR_MIN_SIZE);
// parse the command and install it into the command graph
command_parse_format (nodegraph, cmd);
return CMD_SUCCESS;
}
DEFUN (grammar_test_complete,
grammar_test_complete_cmd,
"grammar complete .COMMAND",
GRAMMAR_STR
"attempt to complete input on DFA\n"
"command to complete")
{
int idx_command = 2;
char *cmdstr = argv_concat (argv, argc, idx_command);
vector command = cmd_make_strvec (cmdstr);
// generate completions of user input
struct list *completions;
enum matcher_rv result = command_complete (nodegraph, command, &completions);
// print completions or relevant error message
if (!MATCHER_ERROR(result))
{
vector comps = completions_to_vec (completions);
struct cmd_token_t *tkn;
// calculate length of longest tkn->text in completions
unsigned int width = 0, i = 0;
for (i = 0; i < vector_active (comps); i++) {
tkn = vector_slot (comps, i);
unsigned int len = strlen (tkn->text);
width = len > width ? len : width;
}
// print completions
for (i = 0; i < vector_active (comps); i++) {
tkn = vector_slot (comps, i);
fprintf (stdout, " %-*s %s%s", width, tkn->text, tkn->desc, "\n");
}
for (i = 0; i < vector_active (comps); i++)
del_cmd_token ((struct cmd_token_t *) vector_slot (comps, i));
vector_free (comps);
}
else
fprintf (stdout, "%% No match%s", "\n");
// free resources
list_delete (completions);
cmd_free_strvec (command);
free (cmdstr);
return CMD_SUCCESS;
}
DEFUN (grammar_test_match,
grammar_test_match_cmd,
"grammar match .COMMAND",
GRAMMAR_STR
"attempt to match input on DFA\n"
"command to match")
{
int idx_command = 2;
if (argv[0][0] == '#')
return CMD_SUCCESS;
char *cmdstr = argv_concat(argv, argc, idx_command);
vector command = cmd_make_strvec (cmdstr);
struct list *argvv = NULL;
struct cmd_element *element = NULL;
enum matcher_rv result = command_match (nodegraph, command, &argvv, &element);
// print completions or relevant error message
if (element)
{
fprintf (stdout, "Matched: %s%s", element->string, "\n");
struct listnode *ln;
struct cmd_token_t *token;
for (ALL_LIST_ELEMENTS_RO(argvv,ln,token))
fprintf (stdout, "%s -- %s%s", token->text, token->arg, "\n");
fprintf (stdout, "func: %p%s", element->func, "\n");
list_delete (argvv);
del_cmd_element (element);
}
else {
assert(MATCHER_ERROR(result));
switch (result) {
case MATCHER_NO_MATCH:
fprintf (stdout, "%% Unknown command%s", "\n");
break;
case MATCHER_INCOMPLETE:
fprintf (stdout, "%% Incomplete command%s", "\n");
break;
case MATCHER_AMBIGUOUS:
fprintf (stdout, "%% Ambiguous command%s", "\n");
break;
default:
fprintf (stdout, "%% Unknown error%s", "\n");
break;
}
}
// free resources
cmd_free_strvec (command);
free (cmdstr);
return CMD_SUCCESS;
}
/**
* Testing shim to test docstrings
*/
DEFUN (grammar_test_doc,
grammar_test_doc_cmd,
"grammar test docstring",
GRAMMAR_STR
"Test function for docstring\n"
"Command end\n")
{
// create cmd_element with docstring
struct cmd_element *cmd = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_element));
cmd->string = XSTRDUP (MTYPE_CMD_TOKENS, "test docstring <example|selector follow> (1-255) end VARIABLE [OPTION|set lol] . VARARG");
cmd->doc = XSTRDUP (MTYPE_CMD_TOKENS,
"Test stuff\n"
"docstring thing\n"
"first example\n"
"second example\n"
"follow\n"
"random range\n"
"end thingy\n"
"variable\n"
"optional variable\n"
"optional set\n"
"optional lol\n"
"vararg!\n");
cmd->func = NULL;
cmd->tokens = vector_init (VECTOR_MIN_SIZE);
// parse element
command_parse_format (nodegraph, cmd);
return CMD_SUCCESS;
}
/**
* Debugging command to print command graph
*/
DEFUN (grammar_test_show,
grammar_test_show_cmd,
"grammar show graph",
GRAMMAR_STR
"print current accumulated DFA\n")
{
if (!nodegraph)
zlog_info("nodegraph uninitialized");
else
pretty_print_graph (vector_slot (nodegraph->nodes, 0), 0);
return CMD_SUCCESS;
}
DEFUN (grammar_init_graph,
grammar_init_graph_cmd,
"grammar init graph",
GRAMMAR_STR
"(re)initialize graph\n")
{
graph_delete_graph (nodegraph);
init_cmdgraph (&nodegraph);
return CMD_SUCCESS;
}
/* this is called in vtysh.c to set up the testing shim */
void grammar_sandbox_init() {
init_cmdgraph (&nodegraph);
// install all enable elements
install_element (ENABLE_NODE, &grammar_test_cmd);
install_element (ENABLE_NODE, &grammar_test_show_cmd);
install_element (ENABLE_NODE, &grammar_test_match_cmd);
install_element (ENABLE_NODE, &grammar_test_complete_cmd);
install_element (ENABLE_NODE, &grammar_test_doc_cmd);
install_element (ENABLE_NODE, &grammar_init_graph_cmd);
}
/**
* Pretty-prints a graph, assuming it is a tree.
*
* @param start the node to take as the root
* @param level indent level for recursive calls, always pass 0
*/
void
pretty_print_graph (struct graph_node *start, int level)
{
// print this node
struct cmd_token_t *tok = start->data;
fprintf (stdout, "%s[%d] ", tok->text, tok->type);
int numto = vector_active (start->to);
if (numto)
{
if (numto > 1)
fprintf (stdout, "\n");
for (unsigned int i = 0; i < vector_active (start->to); i++)
{
struct graph_node *adj = vector_slot (start->to, i);
// if we're listing multiple children, indent!
if (numto > 1)
for (int j = 0; j < level+1; j++)
fprintf (stdout, " ");
// if this node is a vararg, just print *
if (adj == start)
fprintf (stdout, "*");
else
pretty_print_graph (adj, numto > 1 ? level+1 : level);
}
}
else
fprintf(stdout, "\n");
}
/** stuff that should go in command.c + command.h */
void
init_cmdgraph (struct graph **graph)
{
// initialize graph, add start noe
*graph = graph_new ();
struct cmd_token_t *token = new_cmd_token (START_TKN, NULL, NULL);
graph_new_node (*graph, token, (void (*)(void *)) &del_cmd_token);
fprintf (stdout, "initialized graph\n");
}
int
compare_completions (const void *fst, const void *snd)
{
struct cmd_token_t *first = *(struct cmd_token_t **) fst,
*secnd = *(struct cmd_token_t **) snd;
return strcmp (first->text, secnd->text);
}
vector
completions_to_vec (struct list *completions)
{
vector comps = vector_init (VECTOR_MIN_SIZE);
struct listnode *ln;
struct cmd_token_t *token;
unsigned int i, exists;
for (ALL_LIST_ELEMENTS_RO(completions,ln,token))
{
// linear search for token in completions vector
exists = 0;
for (i = 0; i < vector_active (comps) && !exists; i++)
{
struct cmd_token_t *curr = vector_slot (comps, i);
exists = !strcmp (curr->text, token->text) &&
!strcmp (curr->desc, token->desc);
}
if (!exists)
vector_set (comps, copy_cmd_token (token));
}
// sort completions
qsort (comps->index,
vector_active (comps),
sizeof (void *),
&compare_completions);
return comps;
}
struct cmd_token_t *
new_cmd_token (enum cmd_token_type_t type, char *text, char *desc)
{
struct cmd_token_t *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token_t));
token->type = type;
token->text = text;
token->desc = desc;
token->arg = NULL;
return token;
}
void
del_cmd_token (struct cmd_token_t *token)
{
if (!token) return;
if (token->text)
XFREE (MTYPE_CMD_TOKENS, token->text);
if (token->desc)
XFREE (MTYPE_CMD_TOKENS, token->desc);
if (token->arg)
XFREE (MTYPE_CMD_TOKENS, token->arg);
XFREE (MTYPE_CMD_TOKENS, token);
}
struct cmd_token_t *
copy_cmd_token (struct cmd_token_t *token)
{
struct cmd_token_t *copy = new_cmd_token (token->type, NULL, NULL);
copy->value = token->value;
copy->max = token->max;
copy->min = token->min;
copy->text = token->text ? XSTRDUP (MTYPE_CMD_TOKENS, token->text) : NULL;
copy->desc = token->desc ? XSTRDUP (MTYPE_CMD_TOKENS, token->desc) : NULL;
copy->arg = token->arg ? XSTRDUP (MTYPE_CMD_TOKENS, token->arg) : NULL;
return copy;
}

65
lib/grammar_sandbox.h Normal file
View File

@ -0,0 +1,65 @@
#ifndef _GRAMMAR_SANDBOX_H
#define _GRAMMAR_SANDBOX_H
/**
* Houses functionality for testing shim as well as code that should go into
* command.h and command.c during integration.
*/
#include "memory.h"
#define CMD_CR_TEXT "<cr>"
void
grammar_sandbox_init (void);
/**
* Types for tokens.
*
* The type determines what kind of data the token can match (in the
* matching use case) or hold (in the argv use case).
*/
enum cmd_token_type_t
{
WORD_TKN, // words
NUMBER_TKN, // integral numbers
VARIABLE_TKN, // almost anything
RANGE_TKN, // integer range
IPV4_TKN, // IPV4 addresses
IPV4_PREFIX_TKN, // IPV4 network prefixes
IPV6_TKN, // IPV6 prefixes
IPV6_PREFIX_TKN, // IPV6 network prefixes
/* plumbing types */
SELECTOR_TKN, // marks beginning of selector
OPTION_TKN, // marks beginning of option
NUL_TKN, // dummy token
START_TKN, // first token in line
END_TKN, // last token in line
};
/**
* Token struct.
*/
struct cmd_token_t
{
enum cmd_token_type_t type; // token type
char *text; // token text
char *desc; // token description
long long value; // for numeric types
long long min, max; // for ranges
char *arg; // user input that matches this token
};
struct cmd_token_t *
new_cmd_token (enum cmd_token_type_t, char *, char *);
void
del_cmd_token (struct cmd_token_t *);
struct cmd_token_t *
copy_cmd_token (struct cmd_token_t *);
#endif /* _GRAMMAR_SANDBOX_H */

138
lib/graph.c Normal file
View File

@ -0,0 +1,138 @@
/*
* Graph data structure.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <zebra.h>
#include "graph.h"
#include "memory.h"
DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph")
DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node")
struct graph *
graph_new ()
{
struct graph *graph = XCALLOC (MTYPE_GRAPH, sizeof(struct graph));
graph->nodes = vector_init (VECTOR_MIN_SIZE);
return graph;
}
struct graph_node *
graph_new_node (struct graph *graph, void *data, void (*del) (void*))
{
struct graph_node *node =
XCALLOC(MTYPE_GRAPH_NODE, sizeof(struct graph_node));
node->from = vector_init (VECTOR_MIN_SIZE);
node->to = vector_init (VECTOR_MIN_SIZE);
node->data = data;
node->del = del;
vector_set (graph->nodes, node);
return node;
}
static void
vector_remove (vector v, unsigned int ix)
{
vector_unset (v, ix);
if (ix == vector_active (v)) return;
for (; ix < vector_active (v) - 1; ix++)
v->index[ix] = v->index[ix+1];
v->active--;
}
void
graph_delete_node (struct graph *graph, struct graph_node *node)
{
if (!node) return;
// an adjacent node
struct graph_node *adj;
// remove all edges from other nodes to us
vector edges = vector_copy (node->from);
for (unsigned int i = 0; i < vector_active (edges); i++)
{
adj = vector_slot (edges, i);
graph_remove_edge (adj, node);
}
vector_free (edges);
// remove all edges from us to other nodes
edges = vector_copy (node->to);
for (unsigned int i = 0; i < vector_active (edges); i++)
{
adj = vector_slot (edges, i);
graph_remove_edge (node, adj);
}
vector_free (edges);
// if there is a deletion callback, call it
if (node->del && node->data)
(*node->del) (node->data);
// free adjacency lists
vector_free (node->to);
vector_free (node->from);
// remove node from graph->nodes
for (unsigned int i = 0; i < vector_active (graph->nodes); i++)
if (vector_slot (graph->nodes, i) == node)
vector_remove (graph->nodes, i);
// free the node itself
XFREE (MTYPE_GRAPH_NODE, node);
}
struct graph_node *
graph_add_edge (struct graph_node *from, struct graph_node *to)
{
vector_set (from->to, to);
vector_set (to->from, from);
return to;
}
void
graph_remove_edge (struct graph_node *from, struct graph_node *to)
{
// remove from from to->from
for (unsigned int i = 0; i < vector_active (to->from); i++)
if (vector_slot (to->from, i) == from)
vector_remove (to->from, i);
// remove to from from->to
for (unsigned int i = 0; i < vector_active (from->to); i++)
if (vector_slot (from->to, i) == to)
vector_remove (from->to, i);
}
void
graph_delete_graph (struct graph *graph)
{
// delete each node in the graph
for (unsigned int i = 0; i < vector_active (graph->nodes); i++)
graph_delete_node (graph, vector_slot (graph->nodes, i));
vector_free (graph->nodes);
XFREE (MTYPE_GRAPH, graph);
}

101
lib/graph.h Normal file
View File

@ -0,0 +1,101 @@
/*
* Graph data structure.
*
* --
* Copyright (C) 2016 Cumulus Networks, Inc.
*
* This file is part of GNU Zebra.
*
* GNU Zebra is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* GNU Zebra is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _ZEBRA_COMMAND_GRAPH_H
#define _ZEBRA_COMMAND_GRAPH_H
#include "vector.h"
struct graph
{
vector nodes;
};
struct graph_node
{
vector from; // nodes which have edges to this node
vector to; // nodes which this node has edges to
void *data; // node data
void (*del) (void *data); // deletion callback
};
struct graph *
graph_new (void);
/**
* Creates a new node.
*
* @struct graph the graph this node exists in
* @param[in] data this node's data
* @param[in] del data deletion callback
* @return the new node
*/
struct graph_node *
graph_new_node (struct graph *graph, void *data, void (*del) (void*));
/**
* Deletes a node.
*
* Before deletion, this function removes all edges to and from this node from
* any neighbor nodes.
*
* If *data and *del are non-null, the following call is made:
* (*node->del) (node->data);
*
* @param[in] graph the graph this node belongs to
* @param[out] node pointer to node to delete
*/
void
graph_delete_node (struct graph *graph, struct graph_node *node);
/**
* Makes a directed edge between two nodes.
*
* @param[in] from
* @param[in] to
* @return to
*/
struct graph_node *
graph_add_edge (struct graph_node *from, struct graph_node *to);
/**
* Removes a directed edge between two nodes.
*
* @param[in] from
* @param[in] to
*/
void
graph_remove_edge (struct graph_node *from, struct graph_node *to);
/**
* Deletes a graph.
* Calls graph_delete_node on each node before freeing the graph struct itself.
*
* @param graph the graph to delete
*/
void
graph_delete_graph (struct graph *graph);
#endif /* _ZEBRA_COMMAND_GRAPH_H */

View File

@ -678,18 +678,16 @@ if_dump_all (void)
DEFUN (interface_desc,
interface_desc_cmd,
"description .LINE",
"description LINE...",
"Interface specific description\n"
"Characters describing this interface\n")
{
int idx_line = 1;
VTY_DECLVAR_CONTEXT (interface, ifp);
if (argc == 0)
return CMD_SUCCESS;
if (ifp->desc)
XFREE (MTYPE_TMP, ifp->desc);
ifp->desc = argv_concat(argv, argc, 0);
ifp->desc = argv_concat(argv, argc, idx_line);
return CMD_SUCCESS;
}
@ -753,36 +751,42 @@ if_sunwzebra_get (const char *name, size_t nlen, vrf_id_t vrf_id)
DEFUN (interface,
interface_cmd,
"interface IFNAME",
"interface IFNAME [vrf NAME]",
"Select an interface to configure\n"
"Interface's name\n")
"Interface's name\n"
VRF_CMD_HELP_STR)
{
int idx_ifname = 1;
int idx_vrf = 3;
const char *ifname = argv[idx_ifname]->arg;
const char *vrfname = (argc > 2) ? argv[idx_vrf]->arg : NULL;
struct interface *ifp;
size_t sl;
vrf_id_t vrf_id = VRF_DEFAULT;
if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ)
if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ)
{
vty_out (vty, "%% Interface name %s is invalid: length exceeds "
"%d characters%s",
argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE);
ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
return CMD_WARNING;
}
/*Pending: need proper vrf name based lookup/(possible creation of VRF)
Imagine forward reference of a vrf by name in this interface config */
if (argc > 1)
VRF_GET_ID (vrf_id, argv[1]);
if (vrfname)
VRF_GET_ID (vrf_id, vrfname);
#ifdef SUNOS_5
ifp = if_sunwzebra_get (argv[0], sl, vrf_id);
ifp = if_sunwzebra_get (ifname, sl, vrf_id);
#else
ifp = if_get_by_name_len_vrf (argv[0], sl, vrf_id, 1);
ifp = if_get_by_name_len_vrf (ifname, sl, vrf_id, 1);
#endif /* SUNOS_5 */
if (!ifp)
{
vty_out (vty, "%% interface %s not in %s%s", argv[0], argv[1], VTY_NEWLINE);
vty_out (vty, "%% interface %s not in %s%s", ifname, vrfname, VTY_NEWLINE);
return CMD_WARNING;
}
VTY_PUSH_CONTEXT_COMPAT (INTERFACE_NODE, ifp);
@ -790,32 +794,29 @@ DEFUN (interface,
return CMD_SUCCESS;
}
ALIAS (interface,
interface_vrf_cmd,
"interface IFNAME " VRF_CMD_STR,
"Select an interface to configure\n"
"Interface's name\n"
VRF_CMD_HELP_STR)
DEFUN_NOSH (no_interface,
no_interface_cmd,
"no interface IFNAME",
"no interface IFNAME [vrf NAME]",
NO_STR
"Delete a pseudo interface's configuration\n"
"Interface's name\n")
"Interface's name\n"
VRF_CMD_HELP_STR)
{
const char *ifname = argv[2]->arg;
const char *vrfname = (argc > 3) ? argv[3]->arg : NULL;
// deleting interface
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc > 1)
VRF_GET_ID (vrf_id, argv[1]);
if (argc > 3)
VRF_GET_ID (vrf_id, vrfname);
ifp = if_lookup_by_name_vrf (argv[0], vrf_id);
ifp = if_lookup_by_name_vrf (ifname, vrf_id);
if (ifp == NULL)
{
vty_out (vty, "%% Interface %s does not exist%s", argv[0], VTY_NEWLINE);
vty_out (vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
return CMD_WARNING;
}
@ -831,32 +832,27 @@ DEFUN_NOSH (no_interface,
return CMD_SUCCESS;
}
ALIAS (no_interface,
no_interface_vrf_cmd,
"no interface IFNAME " VRF_CMD_STR,
NO_STR
"Delete a pseudo interface's configuration\n"
"Interface's name\n"
VRF_CMD_HELP_STR)
DEFUN (vrf,
vrf_cmd,
"vrf NAME",
"Select a VRF to configure\n"
"VRF's name\n")
{
int idx_name = 1;
const char *vrfname = argv[idx_name]->arg;
struct vrf *vrfp;
size_t sl;
if ((sl = strlen(argv[0])) > VRF_NAMSIZ)
if ((sl = strlen(vrfname)) > VRF_NAMSIZ)
{
vty_out (vty, "%% VRF name %s is invalid: length exceeds "
"%d characters%s",
argv[0], VRF_NAMSIZ, VTY_NEWLINE);
vrfname, VRF_NAMSIZ, VTY_NEWLINE);
return CMD_WARNING;
}
vrfp = vrf_get (VRF_UNKNOWN, argv[0]);
vrfp = vrf_get (VRF_UNKNOWN, vrfname);
VTY_PUSH_CONTEXT_COMPAT (VRF_NODE, vrfp);
@ -870,13 +866,15 @@ DEFUN_NOSH (no_vrf,
"Delete a pseudo VRF's configuration\n"
"VRF's name\n")
{
const char *vrfname = argv[2]->arg;
struct vrf *vrfp;
vrfp = vrf_list_lookup_by_name (argv[0]);
vrfp = vrf_list_lookup_by_name (vrfname);;
if (vrfp == NULL)
{
vty_out (vty, "%% VRF %s does not exist%s", argv[0], VTY_NEWLINE);
vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTY_NEWLINE);
return CMD_WARNING;
}
@ -896,10 +894,12 @@ DEFUN_NOSH (no_vrf,
/* For debug purpose. */
DEFUN (show_address,
show_address_cmd,
"show address",
"show address [vrf NAME]",
SHOW_STR
"address\n")
"address\n"
VRF_CMD_HELP_STR)
{
int idx_vrf = 3;
struct listnode *node;
struct listnode *node2;
struct interface *ifp;
@ -907,8 +907,8 @@ DEFUN (show_address,
struct prefix *p;
vrf_id_t vrf_id = VRF_DEFAULT;
if (argc > 0)
VRF_GET_ID (vrf_id, argv[0]);
if (argc > 2)
VRF_GET_ID (vrf_id, argv[idx_vrf]->arg);
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp))
{
@ -924,16 +924,9 @@ DEFUN (show_address,
return CMD_SUCCESS;
}
ALIAS (show_address,
show_address_vrf_cmd,
"show address " VRF_CMD_STR,
SHOW_STR
"address\n"
VRF_CMD_HELP_STR)
DEFUN (show_address_vrf_all,
show_address_vrf_all_cmd,
"show address " VRF_ALL_CMD_STR,
"show address vrf all",
SHOW_STR
"address\n"
VRF_ALL_CMD_HELP_STR)

View File

@ -211,18 +211,21 @@ if_rmap_unset (const char *ifname, enum if_rmap_type type,
DEFUN (if_rmap,
if_rmap_cmd,
"route-map RMAP_NAME (in|out) IFNAME",
"route-map RMAP_NAME <in|out> IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n"
"Route map interface name\n")
{
int idx_rmap_name = 1;
int idx_in_out = 2;
int idx_ifname = 3;
enum if_rmap_type type;
if (strncmp (argv[1], "i", 1) == 0)
if (strncmp (argv[idx_in_out]->text, "in", 1) == 0)
type = IF_RMAP_IN;
else if (strncmp (argv[1], "o", 1) == 0)
else if (strncmp (argv[idx_in_out]->text, "out", 1) == 0)
type = IF_RMAP_OUT;
else
{
@ -230,23 +233,14 @@ DEFUN (if_rmap,
return CMD_WARNING;
}
if_rmap_set (argv[2], type, argv[0]);
if_rmap_set (argv[idx_ifname]->arg, type, argv[idx_rmap_name]->arg);
return CMD_SUCCESS;
}
ALIAS (if_rmap,
if_ipv6_rmap_cmd,
"route-map RMAP_NAME (in|out) IFNAME",
"Route map set\n"
"Route map name\n"
"Route map set for input filtering\n"
"Route map set for output filtering\n"
"Route map interface name\n")
DEFUN (no_if_rmap,
no_if_rmap_cmd,
"no route-map ROUTEMAP_NAME (in|out) IFNAME",
"no route-map ROUTEMAP_NAME <in|out> IFNAME",
NO_STR
"Route map unset\n"
"Route map name\n"
@ -254,12 +248,15 @@ DEFUN (no_if_rmap,
"Route map for output filtering\n"
"Route map interface name\n")
{
int idx_routemap_name = 2;
int idx_in_out = 3;
int idx_ifname = 4;
int ret;
enum if_rmap_type type;
if (strncmp (argv[1], "i", 1) == 0)
if (strncmp (argv[idx_in_out]->arg, "i", 1) == 0)
type = IF_RMAP_IN;
else if (strncmp (argv[1], "o", 1) == 0)
else if (strncmp (argv[idx_in_out]->arg, "o", 1) == 0)
type = IF_RMAP_OUT;
else
{
@ -267,7 +264,7 @@ DEFUN (no_if_rmap,
return CMD_WARNING;
}
ret = if_rmap_unset (argv[2], type, argv[0]);
ret = if_rmap_unset (argv[idx_ifname]->arg, type, argv[idx_routemap_name]->arg);
if (! ret)
{
vty_out (vty, "route-map doesn't exist%s", VTY_NEWLINE);
@ -276,15 +273,6 @@ DEFUN (no_if_rmap,
return CMD_SUCCESS;
}
ALIAS (no_if_rmap,
no_if_ipv6_rmap_cmd,
"no route-map ROUTEMAP_NAME (in|out) IFNAME",
NO_STR
"Route map unset\n"
"Route map name\n"
"Route map for input filtering\n"
"Route map for output filtering\n"
"Route map interface name\n")
/* Configuration write function. */
int
@ -333,8 +321,6 @@ if_rmap_init (int node)
{
ifrmaphash = hash_create (if_rmap_hash_make, if_rmap_hash_cmp);
if (node == RIPNG_NODE) {
install_element (RIPNG_NODE, &if_ipv6_rmap_cmd);
install_element (RIPNG_NODE, &no_if_ipv6_rmap_cmd);
} else if (node == RIP_NODE) {
install_element (RIP_NODE, &if_rmap_cmd);
install_element (RIP_NODE, &no_if_rmap_cmd);

View File

@ -21,6 +21,7 @@
#include <zebra.h>
#include "command.h"
#include "lib/json.h"
/*
@ -29,12 +30,12 @@
* what.
*/
int
use_json (const int argc, const char *argv[])
use_json (const int argc, struct cmd_token *argv[])
{
if (argc == 0)
return 0;
if (argv[argc-1] && strcmp(argv[argc-1], "json") == 0)
if (argv[argc-1]->arg && strcmp(argv[argc-1]->arg, "json") == 0)
return 1;
return 0;

View File

@ -34,7 +34,7 @@
#define json_object_to_json_string_ext(A, B) json_object_to_json_string (A)
#endif
extern int use_json(const int argc, const char *argv[]);
extern int use_json(const int argc, struct cmd_token *argv[]);
extern void json_object_string_add(struct json_object* obj, const char *key,
const char *s);
extern void json_object_int_add(struct json_object* obj, const char *key,

View File

@ -247,9 +247,10 @@ DEFUN (key_chain,
"Key-chain management\n"
"Key-chain name\n")
{
int idx_word = 2;
struct keychain *keychain;
keychain = keychain_get (argv[0]);
keychain = keychain_get (argv[idx_word]->arg);
VTY_PUSH_CONTEXT_COMPAT (KEYCHAIN_NODE, keychain);
return CMD_SUCCESS;
@ -263,13 +264,14 @@ DEFUN (no_key_chain,
"Key-chain management\n"
"Key-chain name\n")
{
int idx_word = 3;
struct keychain *keychain;
keychain = keychain_lookup (argv[0]);
keychain = keychain_lookup (argv[idx_word]->arg);
if (! keychain)
{
vty_out (vty, "Can't find keychain %s%s", argv[0], VTY_NEWLINE);
vty_out (vty, "Can't find keychain %s%s", argv[idx_word]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -280,15 +282,16 @@ DEFUN (no_key_chain,
DEFUN (key,
key_cmd,
"key <0-2147483647>",
"key (0-2147483647)",
"Configure a key\n"
"Key identifier number\n")
{
int idx_number = 1;
VTY_DECLVAR_CONTEXT (keychain, keychain);
struct key *key;
u_int32_t index;
VTY_GET_INTEGER ("key identifier", index, argv[0]);
VTY_GET_INTEGER ("key identifier", index, argv[idx_number]->arg);
key = key_get (keychain, index);
VTY_PUSH_CONTEXT_SUB (KEYCHAIN_KEY_NODE, key);
@ -297,16 +300,17 @@ DEFUN (key,
DEFUN (no_key,
no_key_cmd,
"no key <0-2147483647>",
"no key (0-2147483647)",
NO_STR
"Delete a key\n"
"Key identifier number\n")
{
int idx_number = 2;
VTY_DECLVAR_CONTEXT (keychain, keychain);
struct key *key;
u_int32_t index;
VTY_GET_INTEGER ("key identifier", index, argv[0]);
VTY_GET_INTEGER ("key identifier", index, argv[idx_number]->arg);
key = key_lookup (keychain, index);
if (! key)
{
@ -327,11 +331,12 @@ DEFUN (key_string,
"Set key string\n"
"The key\n")
{
int idx_line = 1;
VTY_DECLVAR_CONTEXT_SUB (key, key);
if (key->string)
XFREE(MTYPE_KEY, key->string);
key->string = XSTRDUP(MTYPE_KEY, argv[0]);
key->string = XSTRDUP(MTYPE_KEY, argv[idx_line]->arg);
return CMD_SUCCESS;
}
@ -541,7 +546,7 @@ key_lifetime_infinite_set (struct vty *vty, struct key_range *krange,
DEFUN (accept_lifetime_day_month_day_month,
accept_lifetime_day_month_day_month_cmd,
"accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>",
"accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -552,15 +557,23 @@ DEFUN (accept_lifetime_day_month_day_month,
"Month of the year to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_number_3 = 6;
int idx_month_2 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->accept, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[5], argv[6], argv[7]);
return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (accept_lifetime_day_month_month_day,
accept_lifetime_day_month_month_day_cmd,
"accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>",
"accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -571,15 +584,23 @@ DEFUN (accept_lifetime_day_month_month_day,
"Day of th month to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_month_2 = 6;
int idx_number_3 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->accept, argv[0], argv[1], argv[2],
argv[3], argv[4], argv[6], argv[5], argv[7]);
return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (accept_lifetime_month_day_day_month,
accept_lifetime_month_day_day_month_cmd,
"accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>",
"accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -590,15 +611,23 @@ DEFUN (accept_lifetime_month_day_day_month,
"Month of the year to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_number_3 = 6;
int idx_month_2 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->accept, argv[0], argv[2], argv[1],
argv[3], argv[4], argv[5], argv[6], argv[7]);
return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (accept_lifetime_month_day_month_day,
accept_lifetime_month_day_month_day_cmd,
"accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>",
"accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -609,15 +638,23 @@ DEFUN (accept_lifetime_month_day_month_day,
"Day of th month to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_month_2 = 6;
int idx_number_3 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->accept, argv[0], argv[2], argv[1],
argv[3], argv[4], argv[6], argv[5], argv[7]);
return key_lifetime_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (accept_lifetime_infinite_day_month,
accept_lifetime_infinite_day_month_cmd,
"accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> infinite",
"accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) infinite",
"Set accept lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -625,15 +662,19 @@ DEFUN (accept_lifetime_infinite_day_month,
"Year to start\n"
"Never expires")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_infinite_set (vty, &key->accept, argv[0], argv[1],
argv[2], argv[3]);
return key_lifetime_infinite_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg,
argv[idx_month]->arg, argv[idx_number_2]->arg);
}
DEFUN (accept_lifetime_infinite_month_day,
accept_lifetime_infinite_month_day_cmd,
"accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> infinite",
"accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) infinite",
"Set accept lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -641,15 +682,19 @@ DEFUN (accept_lifetime_infinite_month_day,
"Year to start\n"
"Never expires")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_infinite_set (vty, &key->accept, argv[0], argv[2],
argv[1], argv[3]);
return key_lifetime_infinite_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg,
argv[idx_month]->arg, argv[idx_number_2]->arg);
}
DEFUN (accept_lifetime_duration_day_month,
accept_lifetime_duration_day_month_cmd,
"accept-lifetime HH:MM:SS <1-31> MONTH <1993-2035> duration <1-2147483646>",
"accept-lifetime HH:MM:SS (1-31) MONTH (1993-2035) duration (1-2147483646)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -658,15 +703,20 @@ DEFUN (accept_lifetime_duration_day_month,
"Duration of the key\n"
"Duration seconds\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_number_3 = 6;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_duration_set (vty, &key->accept, argv[0], argv[1],
argv[2], argv[3], argv[4]);
return key_lifetime_duration_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg,
argv[idx_month]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
}
DEFUN (accept_lifetime_duration_month_day,
accept_lifetime_duration_month_day_cmd,
"accept-lifetime HH:MM:SS MONTH <1-31> <1993-2035> duration <1-2147483646>",
"accept-lifetime HH:MM:SS MONTH (1-31) (1993-2035) duration (1-2147483646)",
"Set accept lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -675,15 +725,20 @@ DEFUN (accept_lifetime_duration_month_day,
"Duration of the key\n"
"Duration seconds\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 6;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_duration_set (vty, &key->accept, argv[0], argv[2],
argv[1], argv[3], argv[4]);
return key_lifetime_duration_set (vty, &key->accept, argv[idx_hhmmss]->arg, argv[idx_number]->arg,
argv[idx_month]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
}
DEFUN (send_lifetime_day_month_day_month,
send_lifetime_day_month_day_month_cmd,
"send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>",
"send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)",
"Set send lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -694,15 +749,23 @@ DEFUN (send_lifetime_day_month_day_month,
"Month of the year to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_number_3 = 6;
int idx_month_2 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3],
argv[4], argv[5], argv[6], argv[7]);
return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg,
argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (send_lifetime_day_month_month_day,
send_lifetime_day_month_month_day_cmd,
"send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>",
"send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)",
"Set send lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -713,15 +776,23 @@ DEFUN (send_lifetime_day_month_month_day,
"Day of th month to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_month_2 = 6;
int idx_number_3 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->send, argv[0], argv[1], argv[2], argv[3],
argv[4], argv[6], argv[5], argv[7]);
return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg,
argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (send_lifetime_month_day_day_month,
send_lifetime_month_day_day_month_cmd,
"send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS <1-31> MONTH <1993-2035>",
"send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS (1-31) MONTH (1993-2035)",
"Set send lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -732,15 +803,23 @@ DEFUN (send_lifetime_month_day_day_month,
"Month of the year to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_number_3 = 6;
int idx_month_2 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3],
argv[4], argv[5], argv[6], argv[7]);
return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg,
argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (send_lifetime_month_day_month_day,
send_lifetime_month_day_month_day_cmd,
"send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> HH:MM:SS MONTH <1-31> <1993-2035>",
"send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) HH:MM:SS MONTH (1-31) (1993-2035)",
"Set send lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -751,15 +830,23 @@ DEFUN (send_lifetime_month_day_month_day,
"Day of th month to expire\n"
"Year to expire\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_hhmmss_2 = 5;
int idx_month_2 = 6;
int idx_number_3 = 7;
int idx_number_4 = 8;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_set (vty, &key->send, argv[0], argv[2], argv[1], argv[3],
argv[4], argv[6], argv[5], argv[7]);
return key_lifetime_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg, argv[idx_number_2]->arg,
argv[idx_hhmmss_2]->arg, argv[idx_number_3]->arg, argv[idx_month_2]->arg, argv[idx_number_4]->arg);
}
DEFUN (send_lifetime_infinite_day_month,
send_lifetime_infinite_day_month_cmd,
"send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> infinite",
"send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) infinite",
"Set send lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -767,15 +854,19 @@ DEFUN (send_lifetime_infinite_day_month,
"Year to start\n"
"Never expires")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[1], argv[2],
argv[3]);
return key_lifetime_infinite_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg);
}
DEFUN (send_lifetime_infinite_month_day,
send_lifetime_infinite_month_day_cmd,
"send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> infinite",
"send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) infinite",
"Set send lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -783,15 +874,19 @@ DEFUN (send_lifetime_infinite_month_day,
"Year to start\n"
"Never expires")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_infinite_set (vty, &key->send, argv[0], argv[2], argv[1],
argv[3]);
return key_lifetime_infinite_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg);
}
DEFUN (send_lifetime_duration_day_month,
send_lifetime_duration_day_month_cmd,
"send-lifetime HH:MM:SS <1-31> MONTH <1993-2035> duration <1-2147483646>",
"send-lifetime HH:MM:SS (1-31) MONTH (1993-2035) duration (1-2147483646)",
"Set send lifetime of the key\n"
"Time to start\n"
"Day of th month to start\n"
@ -800,15 +895,20 @@ DEFUN (send_lifetime_duration_day_month,
"Duration of the key\n"
"Duration seconds\n")
{
int idx_hhmmss = 1;
int idx_number = 2;
int idx_month = 3;
int idx_number_2 = 4;
int idx_number_3 = 6;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_duration_set (vty, &key->send, argv[0], argv[1], argv[2],
argv[3], argv[4]);
return key_lifetime_duration_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_number_3]->arg);
}
DEFUN (send_lifetime_duration_month_day,
send_lifetime_duration_month_day_cmd,
"send-lifetime HH:MM:SS MONTH <1-31> <1993-2035> duration <1-2147483646>",
"send-lifetime HH:MM:SS MONTH (1-31) (1993-2035) duration (1-2147483646)",
"Set send lifetime of the key\n"
"Time to start\n"
"Month of the year to start\n"
@ -817,10 +917,15 @@ DEFUN (send_lifetime_duration_month_day,
"Duration of the key\n"
"Duration seconds\n")
{
int idx_hhmmss = 1;
int idx_month = 2;
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 6;
VTY_DECLVAR_CONTEXT_SUB (key, key);
return key_lifetime_duration_set (vty, &key->send, argv[0], argv[2], argv[1],
argv[3], argv[4]);
return key_lifetime_duration_set (vty, &key->send, argv[idx_hhmmss]->arg, argv[idx_number]->arg, argv[idx_month]->arg,
argv[idx_number_2]->arg, argv[idx_number_3]->arg);
}
static struct cmd_node keychain_node =

View File

@ -205,8 +205,6 @@ struct timestamp_control {
/* Defines for use in command construction: */
#define LOG_LEVELS "(emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)"
#define LOG_LEVEL_DESC \
"System is unusable\n" \
"Immediate action needed\n" \
@ -217,8 +215,6 @@ struct timestamp_control {
"Informational messages\n" \
"Debugging messages\n"
#define LOG_FACILITIES "(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)"
#define LOG_FACILITY_DESC \
"Kernel\n" \
"User process\n" \

249
lib/memtypes.h Normal file
View File

@ -0,0 +1,249 @@
/* Auto-generated from memtypes.c by gawk. */
/* Do not edit! */
#ifndef _QUAGGA_MEMTYPES_H
#define _QUAGGA_MEMTYPES_H
enum
{
MTYPE_TMP = 1,
MTYPE_STRVEC,
MTYPE_VECTOR,
MTYPE_VECTOR_INDEX,
MTYPE_LINK_LIST,
MTYPE_LINK_NODE,
MTYPE_THREAD,
MTYPE_THREAD_MASTER,
MTYPE_THREAD_STATS,
MTYPE_VTY,
MTYPE_VTY_OUT_BUF,
MTYPE_VTY_HIST,
MTYPE_IF,
MTYPE_CONNECTED,
MTYPE_NBR_CONNECTED,
MTYPE_CONNECTED_LABEL,
MTYPE_BUFFER,
MTYPE_BUFFER_DATA,
MTYPE_STREAM,
MTYPE_STREAM_DATA,
MTYPE_STREAM_FIFO,
MTYPE_PREFIX,
MTYPE_PREFIX_IPV4,
MTYPE_PREFIX_IPV6,
MTYPE_HASH,
MTYPE_HASH_BACKET,
MTYPE_HASH_INDEX,
MTYPE_ROUTE_TABLE,
MTYPE_ROUTE_NODE,
MTYPE_DISTRIBUTE,
MTYPE_DISTRIBUTE_IFNAME,
MTYPE_DISTRIBUTE_NAME,
MTYPE_ACCESS_LIST,
MTYPE_ACCESS_LIST_STR,
MTYPE_ACCESS_FILTER,
MTYPE_PREFIX_LIST,
MTYPE_PREFIX_LIST_ENTRY,
MTYPE_PREFIX_LIST_STR,
MTYPE_PREFIX_LIST_TRIE,
MTYPE_ROUTE_MAP,
MTYPE_ROUTE_MAP_NAME,
MTYPE_ROUTE_MAP_INDEX,
MTYPE_ROUTE_MAP_RULE,
MTYPE_ROUTE_MAP_RULE_STR,
MTYPE_ROUTE_MAP_COMPILED,
MTYPE_ROUTE_MAP_DEP,
MTYPE_CMD_TOKENS,
MTYPE_KEY,
MTYPE_KEYCHAIN,
MTYPE_IF_RMAP,
MTYPE_IF_RMAP_NAME,
MTYPE_SOCKUNION,
MTYPE_PRIVS,
MTYPE_ZLOG,
MTYPE_ZCLIENT,
MTYPE_WORK_QUEUE,
MTYPE_WORK_QUEUE_ITEM,
MTYPE_WORK_QUEUE_NAME,
MTYPE_PQUEUE,
MTYPE_PQUEUE_DATA,
MTYPE_HOST,
MTYPE_BFD_INFO,
MTYPE_VRF,
MTYPE_VRF_NAME,
MTYPE_VRF_BITMAP,
MTYPE_RTADV_PREFIX,
MTYPE_ZEBRA_NS,
MTYPE_ZEBRA_VRF,
MTYPE_NEXTHOP,
MTYPE_RIB,
MTYPE_RIB_QUEUE,
MTYPE_STATIC_ROUTE,
MTYPE_RIB_DEST,
MTYPE_RIB_TABLE_INFO,
MTYPE_RNH,
MTYPE_NETLINK_NAME,
MTYPE_BGP,
MTYPE_BGP_LISTENER,
MTYPE_BGP_PEER,
MTYPE_BGP_PEER_HOST,
MTYPE_BGP_PEER_IFNAME,
MTYPE_BGP_PEER_GROUP,
MTYPE_BGP_PEER_GROUP_HOST,
MTYPE_PEER_DESC,
MTYPE_PEER_PASSWORD,
MTYPE_BGP_PEER_AF,
MTYPE_BGP_UPDGRP,
MTYPE_BGP_UPD_SUBGRP,
MTYPE_BGP_PACKET,
MTYPE_ATTR,
MTYPE_ATTR_EXTRA,
MTYPE_AS_PATH,
MTYPE_AS_SEG,
MTYPE_AS_SEG_DATA,
MTYPE_AS_STR,
MTYPE_BGP_TABLE,
MTYPE_BGP_NODE,
MTYPE_BGP_ROUTE,
MTYPE_BGP_ROUTE_EXTRA,
MTYPE_BGP_CONN,
MTYPE_BGP_STATIC,
MTYPE_BGP_ADVERTISE_ATTR,
MTYPE_BGP_ADVERTISE,
MTYPE_BGP_SYNCHRONISE,
MTYPE_BGP_ADJ_IN,
MTYPE_BGP_ADJ_OUT,
MTYPE_BGP_MPATH_INFO,
MTYPE_AS_LIST,
MTYPE_AS_FILTER,
MTYPE_AS_FILTER_STR,
MTYPE_COMMUNITY,
MTYPE_COMMUNITY_VAL,
MTYPE_COMMUNITY_STR,
MTYPE_ECOMMUNITY,
MTYPE_ECOMMUNITY_VAL,
MTYPE_ECOMMUNITY_STR,
MTYPE_COMMUNITY_LIST,
MTYPE_COMMUNITY_LIST_NAME,
MTYPE_COMMUNITY_LIST_ENTRY,
MTYPE_COMMUNITY_LIST_CONFIG,
MTYPE_COMMUNITY_LIST_HANDLER,
MTYPE_CLUSTER,
MTYPE_CLUSTER_VAL,
MTYPE_BGP_PROCESS_QUEUE,
MTYPE_BGP_CLEAR_NODE_QUEUE,
MTYPE_TRANSIT,
MTYPE_TRANSIT_VAL,
MTYPE_BGP_DEBUG_FILTER,
MTYPE_BGP_DEBUG_STR,
MTYPE_BGP_DISTANCE,
MTYPE_BGP_NEXTHOP_CACHE,
MTYPE_BGP_CONFED_LIST,
MTYPE_PEER_UPDATE_SOURCE,
MTYPE_PEER_CONF_IF,
MTYPE_BGP_DAMP_INFO,
MTYPE_BGP_DAMP_ARRAY,
MTYPE_BGP_REGEXP,
MTYPE_BGP_AGGREGATE,
MTYPE_BGP_ADDR,
MTYPE_BGP_REDIST,
MTYPE_BGP_FILTER_NAME,
MTYPE_BGP_DUMP_STR,
MTYPE_ENCAP_TLV,
MTYPE_RIP,
MTYPE_RIP_INFO,
MTYPE_RIP_INTERFACE,
MTYPE_RIP_PEER,
MTYPE_RIP_OFFSET_LIST,
MTYPE_RIP_DISTANCE,
MTYPE_RIPNG,
MTYPE_RIPNG_ROUTE,
MTYPE_RIPNG_AGGREGATE,
MTYPE_RIPNG_PEER,
MTYPE_RIPNG_OFFSET_LIST,
MTYPE_RIPNG_RTE_DATA,
MTYPE_OSPF_TOP,
MTYPE_OSPF_AREA,
MTYPE_OSPF_AREA_RANGE,
MTYPE_OSPF_NETWORK,
MTYPE_OSPF_NEIGHBOR_STATIC,
MTYPE_OSPF_IF,
MTYPE_OSPF_NEIGHBOR,
MTYPE_OSPF_ROUTE,
MTYPE_OSPF_TMP,
MTYPE_OSPF_LSA,
MTYPE_OSPF_LSA_DATA,
MTYPE_OSPF_LSDB,
MTYPE_OSPF_PACKET,
MTYPE_OSPF_FIFO,
MTYPE_OSPF_VERTEX,
MTYPE_OSPF_VERTEX_PARENT,
MTYPE_OSPF_NEXTHOP,
MTYPE_OSPF_PATH,
MTYPE_OSPF_VL_DATA,
MTYPE_OSPF_CRYPT_KEY,
MTYPE_OSPF_EXTERNAL_INFO,
MTYPE_OSPF_DISTANCE,
MTYPE_OSPF_IF_INFO,
MTYPE_OSPF_IF_PARAMS,
MTYPE_OSPF_MESSAGE,
MTYPE_OSPF6_TOP,
MTYPE_OSPF6_AREA,
MTYPE_OSPF6_IF,
MTYPE_OSPF6_NEIGHBOR,
MTYPE_OSPF6_ROUTE,
MTYPE_OSPF6_PREFIX,
MTYPE_OSPF6_MESSAGE,
MTYPE_OSPF6_LSA,
MTYPE_OSPF6_LSA_SUMMARY,
MTYPE_OSPF6_LSDB,
MTYPE_OSPF6_VERTEX,
MTYPE_OSPF6_SPFTREE,
MTYPE_OSPF6_NEXTHOP,
MTYPE_OSPF6_EXTERNAL_INFO,
MTYPE_OSPF6_OTHER,
MTYPE_ISIS,
MTYPE_ISIS_TMP,
MTYPE_ISIS_CIRCUIT,
MTYPE_ISIS_LSP,
MTYPE_ISIS_ADJACENCY,
MTYPE_ISIS_AREA,
MTYPE_ISIS_AREA_ADDR,
MTYPE_ISIS_TLV,
MTYPE_ISIS_DYNHN,
MTYPE_ISIS_SPFTREE,
MTYPE_ISIS_VERTEX,
MTYPE_ISIS_ROUTE_INFO,
MTYPE_ISIS_NEXTHOP,
MTYPE_ISIS_NEXTHOP6,
MTYPE_ISIS_DICT,
MTYPE_ISIS_DICT_NODE,
MTYPE_PIM_CHANNEL_OIL,
MTYPE_PIM_INTERFACE,
MTYPE_PIM_IGMP_JOIN,
MTYPE_PIM_IGMP_SOCKET,
MTYPE_PIM_IGMP_GROUP,
MTYPE_PIM_IGMP_GROUP_SOURCE,
MTYPE_PIM_NEIGHBOR,
MTYPE_PIM_IFCHANNEL,
MTYPE_PIM_UPSTREAM,
MTYPE_PIM_SSMPINGD,
MTYPE_PIM_STATIC_ROUTE,
MTYPE_PIM_BR,
MTYPE_VTYSH_CONFIG,
MTYPE_VTYSH_CONFIG_LINE,
MTYPE_MAX,
};
extern struct memory_list memory_list_lib[];
extern struct memory_list memory_list_zebra[];
extern struct memory_list memory_list_bgp[];
extern struct memory_list memory_list_rip[];
extern struct memory_list memory_list_ripng[];
extern struct memory_list memory_list_ospf[];
extern struct memory_list memory_list_ospf6[];
extern struct memory_list memory_list_isis[];
extern struct memory_list memory_list_pim[];
extern struct memory_list memory_list_vtysh[];
#endif /* _QUAGGA_MEMTYPES_H */

View File

@ -551,20 +551,22 @@ ns_netns_pathname (struct vty *vty, const char *name)
DEFUN (ns_netns,
ns_netns_cmd,
"logical-router <1-65535> ns NAME",
"logical-router (1-65535) ns NAME",
"Enable a logical-router\n"
"Specify the logical-router indentifier\n"
"The Name Space\n"
"The file name in " NS_RUN_DIR ", or a full pathname\n")
{
int idx_number = 1;
int idx_name = 3;
ns_id_t ns_id = NS_DEFAULT;
struct ns *ns = NULL;
char *pathname = ns_netns_pathname (vty, argv[1]);
char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg);
if (!pathname)
return CMD_WARNING;
VTY_GET_INTEGER ("NS ID", ns_id, argv[0]);
VTY_GET_INTEGER ("NS ID", ns_id, argv[idx_number]->arg);
ns = ns_get (ns_id);
if (ns->name && strcmp (ns->name, pathname) != 0)
@ -589,21 +591,23 @@ DEFUN (ns_netns,
DEFUN (no_ns_netns,
no_ns_netns_cmd,
"no logical-router <1-65535> ns NAME",
"no logical-router (1-65535) ns NAME",
NO_STR
"Enable a Logical-Router\n"
"Specify the Logical-Router identifier\n"
"The Name Space\n"
"The file name in " NS_RUN_DIR ", or a full pathname\n")
{
int idx_number = 2;
int idx_name = 4;
ns_id_t ns_id = NS_DEFAULT;
struct ns *ns = NULL;
char *pathname = ns_netns_pathname (vty, argv[1]);
char *pathname = ns_netns_pathname (vty, argv[idx_name]->arg);
if (!pathname)
return CMD_WARNING;
VTY_GET_INTEGER ("NS ID", ns_id, argv[0]);
VTY_GET_INTEGER ("NS ID", ns_id, argv[idx_number]->arg);
ns = ns_lookup (ns_id);
if (!ns)

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@ ZEBRA_ROUTE_STATIC, static, zebra, 'S', 1, 1, "static"
ZEBRA_ROUTE_RIP, rip, ripd, 'R', 1, 0, "RIP"
ZEBRA_ROUTE_RIPNG, ripng, ripngd, 'R', 0, 1, "RIPng"
ZEBRA_ROUTE_OSPF, ospf, ospfd, 'O', 1, 0, "OSPF"
ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, "OSPFv6"
ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, "OSPFv3"
ZEBRA_ROUTE_ISIS, isis, isisd, 'I', 1, 1, "IS-IS"
ZEBRA_ROUTE_BGP, bgp, bgpd, 'B', 1, 1, "BGP"
ZEBRA_ROUTE_PIM, pim, pimd, 'P', 1, 0, "PIM"

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,8 @@
#include "prefix.h"
#include "memory.h"
#include "qobj.h"
#include "vty.h"
DECLARE_MTYPE(ROUTE_MAP_NAME)
DECLARE_MTYPE(ROUTE_MAP_RULE)
DECLARE_MTYPE(ROUTE_MAP_COMPILED)
@ -234,6 +236,172 @@ extern void route_map_upd8_dependency (route_map_event_t type, const char *arg,
extern void route_map_notify_dependencies (const char *affected_name,
route_map_event_t event);
extern int generic_match_add (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type);
extern int generic_match_delete (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type);
extern int generic_set_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg);
extern int generic_set_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg);
/* match interface */
extern void route_map_match_interface_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match interface */
extern void route_map_no_match_interface_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ip address */
extern void route_map_match_ip_address_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ip address */
extern void route_map_no_match_ip_address_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ip address prefix list */
extern void route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ip address prefix list */
extern void route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ip next hop */
extern void route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ip next hop */
extern void route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ip next hop prefix list */
extern void route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ip next hop prefix list */
extern void route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ipv6 address */
extern void route_map_match_ipv6_address_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ipv6 address */
extern void route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match ipv6 address prefix list */
extern void route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match ipv6 address prefix list */
extern void route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match metric */
extern void route_map_match_metric_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match metric */
extern void route_map_no_match_metric_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* match tag */
extern void route_map_match_tag_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* no match tag */
extern void route_map_no_match_tag_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg,
route_map_event_t type));
/* set ip nexthop */
extern void route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* no set ip nexthop */
extern void route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* set ipv6 nexthop local */
extern void route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* no set ipv6 nexthop local */
extern void route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* set metric */
extern void route_map_set_metric_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* no set metric */
extern void route_map_no_set_metric_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* set tag */
extern void route_map_set_tag_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
/* no set tag */
extern void route_map_no_set_tag_hook (int (*func) (struct vty *vty,
struct route_map_index *index,
const char *command,
const char *arg));
extern void *route_map_rule_tag_compile (const char *arg);
extern void route_map_rule_tag_free (void *rule);

View File

@ -1370,7 +1370,8 @@ DEFUN (smux_peer,
"SNMP MUX peer settings\n"
"Object ID used in SMUX peering\n")
{
if (smux_peer_oid (vty, argv[0], NULL) == 0)
int idx_oid = 2;
if (smux_peer_oid (vty, argv[idx_oid]->arg, NULL) == 0)
{
smux_start();
return CMD_SUCCESS;
@ -1387,7 +1388,8 @@ DEFUN (smux_peer_password,
"SMUX peering object ID\n"
"SMUX peering password\n")
{
if (smux_peer_oid (vty, argv[0], argv[1]) == 0)
int idx_oid = 2;
if (smux_peer_oid (vty, argv[idx_oid]->arg, argv[3]->rg) == 0)
{
smux_start();
return CMD_SUCCESS;
@ -1398,31 +1400,16 @@ DEFUN (smux_peer_password,
DEFUN (no_smux_peer,
no_smux_peer_cmd,
"no smux peer",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n")
{
smux_stop();
return smux_peer_default ();
}
ALIAS (no_smux_peer,
no_smux_peer_oid_cmd,
"no smux peer OID",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n"
"SMUX peering object ID\n")
ALIAS (no_smux_peer,
no_smux_peer_oid_password_cmd,
"no smux peer OID PASSWORD",
"no smux peer [OID [PASSWORD]]",
NO_STR
"SNMP MUX protocol settings\n"
"SNMP MUX peer settings\n"
"SMUX peering object ID\n"
"SMUX peering password\n")
{
smux_stop();
return smux_peer_default ();
}
static int
config_write_smux (struct vty *vty)

View File

@ -287,15 +287,16 @@ DEFUN (show_thread_cpu,
"Thread CPU usage\n"
"Display filter (rwtexb)\n")
{
int idx_filter = 3;
int i = 0;
thread_type filter = (thread_type) -1U;
if (argc > 0)
if (argc > 3)
{
filter = 0;
while (argv[0][i] != '\0')
while (argv[idx_filter]->arg[i] != '\0')
{
switch ( argv[0][i] )
switch ( argv[idx_filter]->arg[i] )
{
case 'r':
case 'R':
@ -330,7 +331,7 @@ DEFUN (show_thread_cpu,
{
vty_out(vty, "Invalid filter \"%s\" specified,"
" must contain at least one of 'RWTEXB'%s",
argv[0], VTY_NEWLINE);
argv[idx_filter]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
}
@ -369,15 +370,16 @@ DEFUN (clear_thread_cpu,
"Thread CPU usage\n"
"Display filter (rwtexb)\n")
{
int idx_filter = 3;
int i = 0;
thread_type filter = (thread_type) -1U;
if (argc > 0)
if (argc > 3)
{
filter = 0;
while (argv[0][i] != '\0')
while (argv[idx_filter]->arg[i] != '\0')
{
switch ( argv[0][i] )
switch ( argv[idx_filter]->arg[i] )
{
case 'r':
case 'R':
@ -412,7 +414,7 @@ DEFUN (clear_thread_cpu,
{
vty_out(vty, "Invalid filter \"%s\" specified,"
" must contain at least one of 'RWTEXB'%s",
argv[0], VTY_NEWLINE);
argv[idx_filter]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
}

View File

@ -51,11 +51,7 @@ enum {
/*
* The command strings
*/
#define VRF_CMD_STR "vrf NAME"
#define VRF_CMD_HELP_STR "Specify the VRF\nThe VRF name\n"
#define VRF_ALL_CMD_STR "vrf all"
#define VRF_ALL_CMD_HELP_STR "Specify the VRF\nAll VRFs\n"
/*

View File

@ -922,7 +922,7 @@ vty_complete_command (struct vty *vty)
if (isspace ((int) vty->buf[vty->length - 1]))
vector_set (vline, NULL);
matched = cmd_complete_command_lib (vline, vty, &ret, 1);
matched = cmd_complete_command (vline, vty, &ret);
cmd_free_strvec (vline);
@ -988,7 +988,7 @@ vty_describe_fold (struct vty *vty, int cmd_width,
const char *cmd, *p;
int pos;
cmd = token->cmd[0] == '.' ? token->cmd + 1 : token->cmd;
cmd = token->text;
if (desc_width <= 0)
{
@ -1065,12 +1065,10 @@ vty_describe_command (struct vty *vty)
{
unsigned int len;
if (token->cmd[0] == '\0')
if (token->text[0] == '\0')
continue;
len = strlen (token->cmd);
if (token->cmd[0] == '.')
len--;
len = strlen (token->text);
if (width < len)
width = len;
@ -1083,10 +1081,10 @@ vty_describe_command (struct vty *vty)
for (i = 0; i < vector_active (describe); i++)
if ((token = vector_slot (describe, i)) != NULL)
{
if (token->cmd[0] == '\0')
if (token->text[0] == '\0')
continue;
if (strcmp (token->cmd, command_cr) == 0)
if (strcmp (token->text, CMD_CR_TEXT) == 0)
{
token_cr = token;
continue;
@ -1094,11 +1092,11 @@ vty_describe_command (struct vty *vty)
if (!token->desc)
vty_out (vty, " %-s%s",
token->cmd[0] == '.' ? token->cmd + 1 : token->cmd,
token->text,
VTY_NEWLINE);
else if (desc_width >= strlen (token->desc))
vty_out (vty, " %-*s %s%s", width,
token->cmd[0] == '.' ? token->cmd + 1 : token->cmd,
token->text,
token->desc, VTY_NEWLINE);
else
vty_describe_fold (vty, width, desc_width, token);
@ -1114,11 +1112,11 @@ vty_describe_command (struct vty *vty)
{
if (!token->desc)
vty_out (vty, " %-s%s",
token->cmd[0] == '.' ? token->cmd + 1 : token->cmd,
token->text,
VTY_NEWLINE);
else if (desc_width >= strlen (token->desc))
vty_out (vty, " %-*s %s%s", width,
token->cmd[0] == '.' ? token->cmd + 1 : token->cmd,
token->text,
token->desc, VTY_NEWLINE);
else
vty_describe_fold (vty, width, desc_width, token);
@ -2385,16 +2383,21 @@ vty_read_file (FILE *confp)
if ( !((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO)) )
{
const char *message = NULL;
switch (ret)
{
case CMD_ERR_AMBIGUOUS:
fprintf (stderr, "*** Error reading config: Ambiguous command.\n");
message = "*** Error reading config: Ambiguous command.";
break;
case CMD_ERR_NO_MATCH:
fprintf (stderr, "*** Error reading config: There is no such command.\n");
message = "*** Error reading config: There is no such command.";
break;
}
fprintf (stderr, "*** Error occured processing line %u, below:\n%s\n",
fprintf (stderr, "%s\n", message);
zlog_err ("%s", message);
fprintf (stderr, "*** Error occurred processing line %u, below:\n%s\n",
line_num, vty->error_buf);
zlog_err ("*** Error occurred processing line %u, below:\n%s",
line_num, vty->error_buf);
}
@ -2778,21 +2781,24 @@ exec_timeout (struct vty *vty, const char *min_str, const char *sec_str)
DEFUN (exec_timeout_min,
exec_timeout_min_cmd,
"exec-timeout <0-35791>",
"exec-timeout (0-35791)",
"Set timeout value\n"
"Timeout value in minutes\n")
{
return exec_timeout (vty, argv[0], NULL);
int idx_number = 1;
return exec_timeout (vty, argv[idx_number]->arg, NULL);
}
DEFUN (exec_timeout_sec,
exec_timeout_sec_cmd,
"exec-timeout <0-35791> <0-2147483>",
"exec-timeout (0-35791) (0-2147483)",
"Set the EXEC timeout\n"
"Timeout in minutes\n"
"Timeout in seconds\n")
{
return exec_timeout (vty, argv[0], argv[1]);
int idx_number = 1;
int idx_number_2 = 2;
return exec_timeout (vty, argv[idx_number]->arg, argv[idx_number_2]->arg);
}
DEFUN (no_exec_timeout,
@ -2811,10 +2817,11 @@ DEFUN (vty_access_class,
"Filter connections based on an IP access list\n"
"IP access list\n")
{
int idx_word = 1;
if (vty_accesslist_name)
XFREE(MTYPE_VTY, vty_accesslist_name);
vty_accesslist_name = XSTRDUP(MTYPE_VTY, argv[0]);
vty_accesslist_name = XSTRDUP(MTYPE_VTY, argv[idx_word]->arg);
return CMD_SUCCESS;
}
@ -2827,7 +2834,9 @@ DEFUN (no_vty_access_class,
"Filter connections based on an IP access list\n"
"IP access list\n")
{
if (! vty_accesslist_name || (argc && strcmp(vty_accesslist_name, argv[0])))
int idx_word = 2;
const char *accesslist = (argc == 3) ? argv[idx_word]->arg : NULL;
if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist)))
{
vty_out (vty, "Access-class is not currently applied to vty%s",
VTY_NEWLINE);
@ -2850,10 +2859,11 @@ DEFUN (vty_ipv6_access_class,
"Filter connections based on an IP access list\n"
"IPv6 access list\n")
{
int idx_word = 2;
if (vty_ipv6_accesslist_name)
XFREE(MTYPE_VTY, vty_ipv6_accesslist_name);
vty_ipv6_accesslist_name = XSTRDUP(MTYPE_VTY, argv[0]);
vty_ipv6_accesslist_name = XSTRDUP(MTYPE_VTY, argv[idx_word]->arg);
return CMD_SUCCESS;
}
@ -2867,8 +2877,11 @@ DEFUN (no_vty_ipv6_access_class,
"Filter connections based on an IP access list\n"
"IPv6 access list\n")
{
int idx_word = 3;
const char *accesslist = (argc == 4) ? argv[idx_word]->arg : NULL;
if (! vty_ipv6_accesslist_name ||
(argc && strcmp(vty_ipv6_accesslist_name, argv[0])))
(argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist)))
{
vty_out (vty, "IPv6 access-class is not currently applied to vty%s",
VTY_NEWLINE);
@ -2945,12 +2958,16 @@ DEFUN (terminal_no_monitor,
return CMD_SUCCESS;
}
ALIAS (terminal_no_monitor,
DEFUN (no_terminal_monitor,
no_terminal_monitor_cmd,
"no terminal monitor",
NO_STR
"Set terminal line parameters\n"
"Copy debug output to the current terminal line\n")
{
return terminal_no_monitor (self, vty, argc, argv);
}
DEFUN (show_history,
show_history_cmd,

View File

@ -435,6 +435,8 @@ extern int proto_redistnum(int afi, const char *s);
extern const char *zserv_command_string (unsigned int command);
#define strmatch(a,b) (!strcmp((a), (b)))
/* Error codes of zebra. */
#define ZEBRA_ERR_NOERROR 0
#define ZEBRA_ERR_RTEXIST -1

View File

@ -435,25 +435,32 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
DEFUN (area_range,
area_range_cmd,
"area A.B.C.D range X:X::X:X/M",
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"area <A.B.C.D|(0-4294967295)> range X:X::X:X/M [<advertise|not-advertise|cost (0-16777215)>]",
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"OSPF6 area ID as a decimal value\n"
"Configured address range\n"
"Specify IPv6 prefix\n"
)
"Advertise\n"
"Do not advertise\n"
"User specified metric for this range\n"
"Advertised metric for this range\n")
{
int idx_ipv4 = 1;
int idx_ipv6_prefixlen = 3;
int idx_type = 4;
int ret;
struct ospf6_area *oa;
struct prefix prefix;
struct ospf6_route *range;
u_int32_t cost = OSPF_AREA_RANGE_COST_UNSPEC;
OSPF6_CMD_AREA_GET (argv[0], oa);
OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa);
ret = str2prefix (argv[1], &prefix);
ret = str2prefix (argv[idx_ipv6_prefixlen]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6)
{
vty_out (vty, "Malformed argument: %s%s", argv[1], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv6_prefixlen]->arg, VNL);
return CMD_SUCCESS;
}
@ -469,26 +476,26 @@ DEFUN (area_range,
(u_int32_t) htonl(ospf6_new_range_ls_id (oa->range_table));
}
if (argc > 2)
if (argc > idx_type)
{
if (strcmp (argv[2], "not-advertise") == 0)
if (strmatch (argv[idx_type]->text, "not-advertise"))
{
SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
}
else if (strcmp (argv[2], "advertise") == 0)
else if (strmatch (argv[idx_type]->text, "advertise"))
{
UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
}
else
{
VTY_GET_INTEGER_RANGE ("cost", cost, argv[2], 0, OSPF_LS_INFINITY);
VTY_GET_INTEGER_RANGE ("cost", cost, argv[5]->arg, 0, OSPF_LS_INFINITY);
UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
}
}
range->path.u.cost_config = cost;
zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[1], range->flag);
zlog_debug ("%s: for prefix %s, flag = %x\n", __func__, argv[idx_ipv6_prefixlen]->arg, range->flag);
if (range->rnode == NULL)
{
ospf6_route_add (range, oa->range_table);
@ -503,64 +510,34 @@ DEFUN (area_range,
return CMD_SUCCESS;
}
ALIAS (area_range,
area_range_advertise_cmd,
"area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Configured address range\n"
"Specify IPv6 prefix\n"
)
ALIAS (area_range,
area_range_cost_cmd,
"area (A.B.C.D|<0-4294967295>) range X:X::X:X/M cost <0-16777215>",
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Summarize routes matching address/mask (border routers only)\n"
"Area range prefix\n"
"User specified metric for this range\n"
"Advertised metric for this range\n")
ALIAS (area_range,
area_range_advertise_cost_cmd,
"area (A.B.C.D|<0-4294967295>) range X:X::X:X/M advertise cost <0-16777215>",
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Summarize routes matching address/mask (border routers only)\n"
"Area range prefix\n"
"User specified metric for this range\n"
"Advertised metric for this range\n")
DEFUN (no_area_range,
no_area_range_cmd,
"no area A.B.C.D range X:X::X:X/M",
"no area A.B.C.D range X:X::X:X/M [<advertise|not-advertise>] [cost (0-16777215)]",
NO_STR
"OSPF area parameters\n"
"OSPF6 area parameters\n"
OSPF6_AREA_ID_STR
"Configured address range\n"
"Specify IPv6 prefix\n")
{
int idx_ipv4 = 2;
int ret;
struct ospf6_area *oa;
struct prefix prefix;
struct ospf6_route *range, *route;
OSPF6_CMD_AREA_GET (argv[0], oa);
argc--;
argv++;
OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, oa);
ret = str2prefix (argv[0], &prefix);
ret = str2prefix (argv[idx_ipv4]->arg, &prefix);
if (ret != 1 || prefix.family != AF_INET6)
{
vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
range = ospf6_route_lookup (&prefix, oa->range_table);
if (range == NULL)
{
vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
vty_out (vty, "Range %s does not exists.%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
@ -584,36 +561,8 @@ DEFUN (no_area_range,
return CMD_SUCCESS;
}
ALIAS (no_area_range,
no_area_range_advertise_cmd,
"no area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
NO_STR
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Configured address range\n"
"Specify IPv6 prefix\n")
ALIAS (no_area_range,
no_area_range_cost_cmd,
"no area (A.B.C.D|<0-4294967295>) range X:X::X:X/M cost <0-16777215>",
NO_STR
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Summarize routes matching address/mask (border routers only)\n"
"Area range prefix\n"
"User specified metric for this range\n"
"Advertised metric for this range\n")
ALIAS (no_area_range,
no_area_range_advertise_cost_cmd,
"no area (A.B.C.D|<0-4294967295>) range X:X::X:X/M advertise cost <0-16777215>",
NO_STR
"OSPF area parameters\n"
OSPF6_AREA_ID_STR
"Summarize routes matching address/mask (border routers only)\n"
"Area range prefix\n"
"User specified metric for this range\n"
"Advertised metric for this range\n")
void
ospf6_area_config_write (struct vty *vty)
@ -668,30 +617,30 @@ ospf6_area_config_write (struct vty *vty)
DEFUN (area_filter_list,
area_filter_list_cmd,
"area A.B.C.D filter-list prefix WORD (in|out)",
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
"Filter networks between OSPFv6 areas\n"
"Filter prefixes between OSPFv6 areas\n"
"area A.B.C.D filter-list prefix WORD <in|out>",
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Filter networks between OSPF6 areas\n"
"Filter prefixes between OSPF6 areas\n"
"Name of an IPv6 prefix-list\n"
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
int idx_ipv4 = 1;
int idx_word = 4;
struct ospf6_area *area;
struct prefix_list *plist;
OSPF6_CMD_AREA_GET (argv[0], area);
argc--;
argv++;
OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area);
plist = prefix_list_lookup (AFI_IP6, argv[0]);
if (strncmp (argv[1], "in", 2) == 0)
plist = prefix_list_lookup (AFI_IP6, argv[idx_ipv4]->arg);
if (strncmp (argv[idx_word]->arg, "in", 2) == 0)
{
PREFIX_LIST_IN (area) = plist;
if (PREFIX_NAME_IN (area))
free (PREFIX_NAME_IN (area));
PREFIX_NAME_IN (area) = strdup (argv[0]);
PREFIX_NAME_IN (area) = strdup (argv[idx_ipv4]->arg);
ospf6_abr_reimport (area);
}
else
@ -700,7 +649,7 @@ DEFUN (area_filter_list,
if (PREFIX_NAME_OUT (area))
free (PREFIX_NAME_OUT (area));
PREFIX_NAME_OUT (area) = strdup (argv[0]);
PREFIX_NAME_OUT (area) = strdup (argv[idx_ipv4]->arg);
ospf6_abr_enable_area (area);
}
@ -709,26 +658,26 @@ DEFUN (area_filter_list,
DEFUN (no_area_filter_list,
no_area_filter_list_cmd,
"no area A.B.C.D filter-list prefix WORD (in|out)",
"no area A.B.C.D filter-list prefix WORD <in|out>",
NO_STR
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
"Filter networks between OSPFv6 areas\n"
"Filter prefixes between OSPFv6 areas\n"
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Filter networks between OSPF6 areas\n"
"Filter prefixes between OSPF6 areas\n"
"Name of an IPv6 prefix-list\n"
"Filter networks sent to this area\n"
"Filter networks sent from this area\n")
{
int idx_ipv4 = 2;
int idx_word = 5;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET (argv[0], area);
argc--;
argv++;
OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area);
if (strncmp (argv[1], "in", 2) == 0)
if (strncmp (argv[idx_word]->arg, "in", 2) == 0)
{
if (PREFIX_NAME_IN (area))
if (strcmp (PREFIX_NAME_IN (area), argv[0]) != 0)
if (strcmp (PREFIX_NAME_IN (area), argv[idx_ipv4]->arg) != 0)
return CMD_SUCCESS;
PREFIX_LIST_IN (area) = NULL;
@ -741,7 +690,7 @@ DEFUN (no_area_filter_list,
else
{
if (PREFIX_NAME_OUT (area))
if (strcmp (PREFIX_NAME_OUT (area), argv[0]) != 0)
if (strcmp (PREFIX_NAME_OUT (area), argv[idx_ipv4]->arg) != 0)
return CMD_SUCCESS;
PREFIX_LIST_OUT (area) = NULL;
@ -758,24 +707,26 @@ DEFUN (no_area_filter_list,
DEFUN (area_import_list,
area_import_list_cmd,
"area A.B.C.D import-list NAME",
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Set the filter for networks from other areas announced to the specified one\n"
"Name of the acess-list\n")
{
int idx_ipv4 = 1;
int idx_name = 3;
struct ospf6_area *area;
struct access_list *list;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
list = access_list_lookup (AFI_IP6, argv[1]);
list = access_list_lookup (AFI_IP6, argv[idx_name]->arg);
IMPORT_LIST (area) = list;
if (IMPORT_NAME (area))
free (IMPORT_NAME (area));
IMPORT_NAME (area) = strdup (argv[1]);
IMPORT_NAME (area) = strdup (argv[idx_name]->arg);
ospf6_abr_reimport (area);
return CMD_SUCCESS;
@ -784,14 +735,16 @@ DEFUN (area_import_list,
DEFUN (no_area_import_list,
no_area_import_list_cmd,
"no area A.B.C.D import-list NAME",
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
NO_STR
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Unset the filter for networks announced to other areas\n"
"NAme of the access-list\n")
"Name of the access-list\n")
{
int idx_ipv4 = 2;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
IMPORT_LIST (area) = 0;
@ -807,24 +760,26 @@ DEFUN (no_area_import_list,
DEFUN (area_export_list,
area_export_list_cmd,
"area A.B.C.D export-list NAME",
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Set the filter for networks announced to other areas\n"
"Name of the acess-list\n")
{
int idx_ipv4 = 1;
int idx_name = 3;
struct ospf6_area *area;
struct access_list *list;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
list = access_list_lookup (AFI_IP6, argv[1]);
list = access_list_lookup (AFI_IP6, argv[idx_name]->arg);
EXPORT_LIST (area) = list;
if (EXPORT_NAME (area))
free (EXPORT_NAME (area));
EXPORT_NAME (area) = strdup (argv[1]);
EXPORT_NAME (area) = strdup (argv[idx_name]->arg);
ospf6_abr_enable_area (area);
return CMD_SUCCESS;
@ -833,14 +788,16 @@ DEFUN (area_export_list,
DEFUN (no_area_export_list,
no_area_export_list_cmd,
"no area A.B.C.D export-list NAME",
"OSPFv6 area parameters\n"
"OSPFv6 area ID in IP address format\n"
NO_STR
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"Unset the filter for networks announced to other areas\n"
"Name of the access-list\n")
{
int idx_ipv4 = 2;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4]->arg, area);
EXPORT_LIST (area) = 0;
@ -899,6 +856,7 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
"Shortest Path First caculation\n"
"Show SPF tree\n")
{
int idx_ipv4 = 4;
u_int32_t area_id;
struct ospf6_area *oa;
struct ospf6_vertex *root;
@ -909,15 +867,15 @@ DEFUN (show_ipv6_ospf6_area_spf_tree,
ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
if (inet_pton (AF_INET, argv[0], &area_id) != 1)
if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{
vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
oa = ospf6_area_lookup (area_id, ospf6);
if (oa == NULL)
{
vty_out (vty, "No such Area: %s%s", argv[0], VNL);
vty_out (vty, "No such Area: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
@ -940,10 +898,14 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
SHOW_STR
IP6_STR
OSPF6_STR
"Shortest Path First caculation\n"
"Shortest Path First calculation\n"
"Show SPF tree\n"
"Specify root's router-id to calculate another router's SPF tree\n")
"Specify root's router-id to calculate another router's SPF tree\n"
"OSPF6 area parameters\n"
OSPF6_AREA_ID_STR)
{
int idx_ipv4 = 5;
int idx_ipv4_2 = 7;
u_int32_t area_id;
struct ospf6_area *oa;
struct ospf6_vertex *root;
@ -955,18 +917,18 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
OSPF6_CMD_CHECK_RUNNING ();
inet_pton (AF_INET, argv[0], &router_id);
inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
if (inet_pton (AF_INET, argv[1], &area_id) != 1)
if (inet_pton (AF_INET, argv[idx_ipv4_2]->arg, &area_id) != 1)
{
vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
vty_out (vty, "Malformed Area-ID: %s%s", argv[idx_ipv4_2]->arg, VNL);
return CMD_SUCCESS;
}
oa = ospf6_area_lookup (area_id, ospf6);
if (oa == NULL)
{
vty_out (vty, "No such Area: %s%s", argv[1], VNL);
vty_out (vty, "No such Area: %s%s", argv[idx_ipv4_2]->arg, VNL);
return CMD_SUCCESS;
}
@ -996,15 +958,16 @@ DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
DEFUN (ospf6_area_stub,
ospf6_area_stub_cmd,
"area (A.B.C.D|<0-4294967295>) stub",
"area <A.B.C.D|(0-4294967295)> stub",
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"OSPF6 area ID as a decimal value\n"
"Configure OSPF6 area as stub\n")
{
int idx_ipv4_number = 1;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
if (!ospf6_area_stub_set (ospf6, area))
{
@ -1020,16 +983,17 @@ DEFUN (ospf6_area_stub,
DEFUN (ospf6_area_stub_no_summary,
ospf6_area_stub_no_summary_cmd,
"area (A.B.C.D|<0-4294967295>) stub no-summary",
"area <A.B.C.D|(0-4294967295)> stub no-summary",
"OSPF6 stub parameters\n"
"OSPF6 area ID in IP address format\n"
"OSPF6 area ID as a decimal value\n"
"Configure OSPF6 area as stub\n"
"Do not inject inter-area routes into stub\n")
{
int idx_ipv4_number = 1;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
if (!ospf6_area_stub_set (ospf6, area))
{
@ -1045,16 +1009,17 @@ DEFUN (ospf6_area_stub_no_summary,
DEFUN (no_ospf6_area_stub,
no_ospf6_area_stub_cmd,
"no area (A.B.C.D|<0-4294967295>) stub",
"no area <A.B.C.D|(0-4294967295)> stub",
NO_STR
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
"OSPF6 area ID as a decimal value\n"
"Configure OSPF6 area as stub\n")
{
int idx_ipv4_number = 2;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
ospf6_area_stub_unset (ospf6, area);
ospf6_area_no_summary_unset (ospf6, area);
@ -1064,7 +1029,7 @@ DEFUN (no_ospf6_area_stub,
DEFUN (no_ospf6_area_stub_no_summary,
no_ospf6_area_stub_no_summary_cmd,
"no area (A.B.C.D|<0-4294967295>) stub no-summary",
"no area <A.B.C.D|(0-4294967295)> stub no-summary",
NO_STR
"OSPF6 area parameters\n"
"OSPF6 area ID in IP address format\n"
@ -1072,9 +1037,10 @@ DEFUN (no_ospf6_area_stub_no_summary,
"Configure OSPF6 area as stub\n"
"Do not inject inter-area routes into area\n")
{
int idx_ipv4_number = 2;
struct ospf6_area *area;
OSPF6_CMD_AREA_GET(argv[0], area);
OSPF6_CMD_AREA_GET(argv[idx_ipv4_number]->arg, area);
ospf6_area_stub_unset (ospf6, area);
ospf6_area_no_summary_unset (ospf6, area);
@ -1090,13 +1056,7 @@ ospf6_area_init (void)
install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
install_element (OSPF6_NODE, &area_range_cmd);
install_element (OSPF6_NODE, &area_range_advertise_cmd);
install_element (OSPF6_NODE, &area_range_cost_cmd);
install_element (OSPF6_NODE, &area_range_advertise_cost_cmd);
install_element (OSPF6_NODE, &no_area_range_cmd);
install_element (OSPF6_NODE, &no_area_range_advertise_cmd);
install_element (OSPF6_NODE, &no_area_range_cost_cmd);
install_element (OSPF6_NODE, &no_area_range_advertise_cost_cmd);
install_element (OSPF6_NODE, &ospf6_area_stub_no_summary_cmd);
install_element (OSPF6_NODE, &ospf6_area_stub_cmd);
install_element (OSPF6_NODE, &no_ospf6_area_stub_no_summary_cmd);

View File

@ -686,14 +686,13 @@ ospf6_asbr_redistribute_remove (int type, ifindex_t ifindex,
DEFUN (ospf6_redistribute,
ospf6_redistribute_cmd,
"redistribute " QUAGGA_REDIST_STR_OSPF6D,
"redistribute <kernel|connected|static|ripng|isis|bgp|table>",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_OSPF6D
)
QUAGGA_REDIST_HELP_STR_OSPF6D)
{
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[2]->arg);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
return CMD_WARNING;
@ -704,36 +703,39 @@ DEFUN (ospf6_redistribute,
DEFUN (ospf6_redistribute_routemap,
ospf6_redistribute_routemap_cmd,
"redistribute " QUAGGA_REDIST_STR_OSPF6D " route-map WORD",
"redistribute <kernel|connected|static|ripng|isis|bgp|table> route-map WORD",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_OSPF6D
"Route map reference\n"
"Route map name\n"
)
"Route map name\n")
{
int idx_protocol = 1;
int idx_word = 3;
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
return CMD_WARNING;
ospf6_asbr_redistribute_unset (type);
ospf6_asbr_routemap_set (type, argv[1]);
ospf6_asbr_routemap_set (type, argv[idx_word]->arg);
ospf6_asbr_redistribute_set (type);
return CMD_SUCCESS;
}
DEFUN (no_ospf6_redistribute,
no_ospf6_redistribute_cmd,
"no redistribute " QUAGGA_REDIST_STR_OSPF6D,
"no redistribute <kernel|connected|static|ripng|isis|bgp|table> [route-map WORD]",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_OSPF6D
)
"Route map reference\n"
"Route map name\n")
{
int idx_protocol = 2;
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
return CMD_WARNING;
@ -742,14 +744,6 @@ DEFUN (no_ospf6_redistribute,
return CMD_SUCCESS;
}
ALIAS (no_ospf6_redistribute,
no_ospf6_redistribute_route_map_cmd,
"no redistribute " QUAGGA_REDIST_STR_OSPF6D " route-map WORD",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_OSPF6D
"Route map reference\n"
"Route map name\n")
int
ospf6_redistribute_config_write (struct vty *vty)
@ -1109,8 +1103,9 @@ DEFUN (ospf6_routemap_match_address_prefixlist,
"Match entries of prefix-lists\n"
"IPv6 prefix-list name\n")
{
int idx_word = 4;
int ret = route_map_add_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[0]);
"ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret);
}
@ -1125,8 +1120,9 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist,
"Match entries of prefix-lists\n"
"IPv6 prefix-list name\n")
{
int idx_word = 5;
int ret = route_map_delete_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[0]);
"ipv6 address prefix-list", argv[idx_word]->arg);
return route_map_command_status (vty, ret);
}
@ -1138,134 +1134,63 @@ DEFUN (ospf6_routemap_match_interface,
"Match first hop interface of route\n"
"Interface name\n")
{
int idx_word = 2;
return route_map_add_match ((struct route_map_index *) vty->index,
"interface", argv[0]);
"interface", argv[idx_word]->arg);
}
/* "no match interface WORD" */
DEFUN (ospf6_routemap_no_match_interface,
ospf6_routemap_no_match_interface_cmd,
"no match interface",
NO_STR
MATCH_STR
"Match first hop interface of route\n")
{
int ret = route_map_delete_match ((struct route_map_index *) vty->index,
"interface", (argc == 0) ? NULL : argv[0]);
return route_map_command_status (vty, ret);
}
ALIAS (ospf6_routemap_no_match_interface,
ospf6_routemap_no_match_interface_val_cmd,
"no match interface WORD",
"no match interface [WORD]",
NO_STR
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
/* add "match tag" */
DEFUN (ospf6_routemap_match_tag,
ospf6_routemap_match_tag_cmd,
"match tag <1-4294967295>",
MATCH_STR
"Tag value for routing protocol\n"
"Tag value\n")
{
int ret = route_map_add_match ((struct route_map_index *) vty->index,
"tag", argv[0]);
int idx_word = 3;
int ret;
if (argc == 4)
ret = route_map_delete_match ((struct route_map_index *) vty->index,
"interface", argv[idx_word]->arg);
else
ret = route_map_delete_match ((struct route_map_index *) vty->index,
"interface", NULL);
return route_map_command_status (vty, ret);
}
/* delete "match tag" */
DEFUN (ospf6_routemap_no_match_tag,
ospf6_routemap_no_match_tag_cmd,
"no match tag",
NO_STR
MATCH_STR
"Tag value for routing protocol\n")
{
int ret = route_map_delete_match ((struct route_map_index *) vty->index,
"tag", argc ? argv[0] : NULL);
return route_map_command_status (vty, ret);
}
ALIAS (ospf6_routemap_no_match_tag,
ospf6_routemap_no_match_tag_val_cmd,
"no match tag <1-4294967295>",
NO_STR
MATCH_STR
"Tag value for routing protocol\n"
"Tag value\n")
/* add "set metric-type" */
DEFUN (ospf6_routemap_set_metric_type,
ospf6_routemap_set_metric_type_cmd,
"set metric-type (type-1|type-2)",
"set metric-type <type-1|type-2>",
"Set value\n"
"Type of metric\n"
"OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n")
{
int idx_external = 2;
int ret = route_map_add_set ((struct route_map_index *) vty->index,
"metric-type", argv[0]);
"metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret);
}
/* delete "set metric-type" */
DEFUN (ospf6_routemap_no_set_metric_type,
ospf6_routemap_no_set_metric_type_cmd,
"no set metric-type (type-1|type-2)",
"no set metric-type <type-1|type-2>",
NO_STR
"Set value\n"
"Type of metric\n"
"OSPF6 external type 1 metric\n"
"OSPF6 external type 2 metric\n")
{
int idx_external = 3;
int ret = route_map_delete_set ((struct route_map_index *) vty->index,
"metric-type", argv[0]);
"metric-type", argv[idx_external]->arg);
return route_map_command_status (vty, ret);
}
/* add "set metric" */
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
"Set value\n"
"Metric value\n"
"Metric value\n")
{
int ret = route_map_add_set ((struct route_map_index *) vty->index,
"metric", argv[0]);
return route_map_command_status (vty, ret);
}
/* delete "set metric" */
DEFUN (no_set_metric,
no_set_metric_cmd,
"no set metric",
NO_STR
SET_STR
"Metric value for destination routing protocol\n")
{
int ret = 0;
if (argc == 0)
ret = route_map_delete_set ((struct route_map_index *) vty->index,
"metric", NULL);
else
ret = route_map_delete_set ((struct route_map_index *) vty->index,
"metric", argv[0]);
return route_map_command_status (vty, ret);
}
ALIAS (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
/* add "set forwarding-address" */
DEFUN (ospf6_routemap_set_forwarding,
ospf6_routemap_set_forwarding_cmd,
@ -1274,8 +1199,9 @@ DEFUN (ospf6_routemap_set_forwarding,
"Forwarding Address\n"
"IPv6 Address\n")
{
int idx_ipv6 = 2;
int ret = route_map_add_set ((struct route_map_index *) vty->index,
"forwarding-address", argv[0]);
"forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret);
}
@ -1288,44 +1214,39 @@ DEFUN (ospf6_routemap_no_set_forwarding,
"Forwarding Address\n"
"IPv6 Address\n")
{
int idx_ipv6 = 3;
int ret = route_map_delete_set ((struct route_map_index *) vty->index,
"forwarding-address", argv[0]);
"forwarding-address", argv[idx_ipv6]->arg);
return route_map_command_status (vty, ret);
}
/* add "set tag" */
DEFUN (ospf6_routemap_set_tag,
ospf6_routemap_set_tag_cmd,
"set tag <1-4294967295>",
"set tag (1-4294967295)",
"Set value\n"
"Tag value for routing protocol\n"
"Tag value\n")
{
int ret = route_map_add_set ((struct route_map_index *) vty->index,
"tag", argv[0]);
"tag", argv[2]->arg);
return route_map_command_status (vty, ret);
}
/* delete "set tag" */
DEFUN (ospf6_routemap_no_set_tag,
ospf6_routemap_no_set_tag_cmd,
"no set tag",
NO_STR
"Set value\n"
"Tag value for routing protocol\n")
{
int ret = route_map_delete_set ((struct route_map_index *) vty->index,
"tag", argc ? argv[0] : NULL);
return route_map_command_status (vty, ret);
}
ALIAS (ospf6_routemap_no_set_tag,
ospf6_routemap_no_set_tag_val_cmd,
"no set tag <1-4294967295>",
"no set tag [(1-4294967295)]",
NO_STR
"Set value\n"
"Tag value for routing protocol\n"
"Tag value\n")
{
char *tag = (argc == 4) ? argv[3]->arg : NULL;
VTY_DECLVAR_CONTEXT (route_map_index, index);
int ret = route_map_delete_set (index, "tag", tag);
return route_map_command_status (vty, ret);
}
static void
ospf6_routemap_init (void)
@ -1335,6 +1256,9 @@ ospf6_routemap_init (void)
route_map_add_hook (ospf6_asbr_routemap_update);
route_map_delete_hook (ospf6_asbr_routemap_update);
route_map_set_metric_hook (generic_set_add);
route_map_no_set_metric_hook (generic_set_delete);
route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd);
route_map_install_match (&ospf6_routemap_rule_match_interface_cmd);
route_map_install_match (&ospf6_routemap_rule_match_tag_cmd);
@ -1351,30 +1275,18 @@ ospf6_routemap_init (void)
/* Match interface */
install_element (RMAP_NODE, &ospf6_routemap_match_interface_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_interface_val_cmd);
/* Match tag */
install_element (RMAP_NODE, &ospf6_routemap_match_tag_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_match_tag_val_cmd);
/* ASE Metric Type (e.g. Type-1/Type-2) */
install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
/* ASE Metric */
install_element (RMAP_NODE, &set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
/* Forwarding address */
install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
/* Tag */
install_element (RMAP_NODE, &ospf6_routemap_set_tag_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_tag_val_cmd);
}
@ -1529,7 +1441,6 @@ ospf6_asbr_init (void)
install_element (OSPF6_NODE, &ospf6_redistribute_cmd);
install_element (OSPF6_NODE, &ospf6_redistribute_routemap_cmd);
install_element (OSPF6_NODE, &no_ospf6_redistribute_cmd);
install_element (OSPF6_NODE, &no_ospf6_redistribute_route_map_cmd);
}
void
@ -1593,5 +1504,3 @@ install_element_ospf6_debug_asbr ()
install_element (CONFIG_NODE, &debug_ospf6_asbr_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_asbr_cmd);
}

View File

@ -346,7 +346,7 @@ DEFUN (ipv6_ospf6_bfd,
DEFUN (ipv6_ospf6_bfd_param,
ipv6_ospf6_bfd_param_cmd,
"ipv6 ospf6 bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
"ipv6 ospf6 bfd (2-255) (50-60000) (50-60000)",
IP6_STR
OSPF6_STR
"Enables BFD support\n"
@ -354,6 +354,9 @@ DEFUN (ipv6_ospf6_bfd_param,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct ospf6_interface *oi;
struct interface *ifp;
u_int32_t rx_val;
@ -369,7 +372,7 @@ DEFUN (ipv6_ospf6_bfd_param,
oi = ospf6_interface_create (ifp);
assert (oi);
if ((ret = bfd_validate_param (vty, argv[0], argv[1], argv[2], &dm_val,
if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS)
return ret;

View File

@ -988,23 +988,23 @@ ospf6_interface_show (struct vty *vty, struct interface *ifp)
/* show interface */
DEFUN (show_ipv6_ospf6_interface,
show_ipv6_ospf6_interface_ifname_cmd,
"show ipv6 ospf6 interface IFNAME",
"show ipv6 ospf6 interface [IFNAME]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
)
IFNAME_STR)
{
int idx_ifname = 4;
struct interface *ifp;
struct listnode *i;
if (argc)
if (argc == 5)
{
ifp = if_lookup_by_name (argv[0]);
ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL)
{
vty_out (vty, "No such Interface: %s%s", argv[0],
vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg,
VNL);
return CMD_WARNING;
}
@ -1019,53 +1019,9 @@ DEFUN (show_ipv6_ospf6_interface,
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_interface,
show_ipv6_ospf6_interface_cmd,
"show ipv6 ospf6 interface",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
)
DEFUN (show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_cmd,
"show ipv6 ospf6 interface IFNAME prefix",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
"Display connected prefixes to advertise\n"
)
{
struct interface *ifp;
struct ospf6_interface *oi;
ifp = if_lookup_by_name (argv[0]);
if (ifp == NULL)
{
vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
return CMD_WARNING;
}
oi = ifp->info;
if (oi == NULL)
{
vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[0], VNL);
return CMD_WARNING;
}
argc--;
argv++;
ospf6_route_table_show (vty, argc, argv, oi->route_connected);
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_detail_cmd,
"show ipv6 ospf6 interface IFNAME prefix (X:X::X:X|X:X::X:X/M|detail)",
"show ipv6 ospf6 interface IFNAME prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]",
SHOW_STR
IP6_STR
OSPF6_STR
@ -1074,33 +1030,47 @@ ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
"Display connected prefixes to advertise\n"
OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR
"Display details of the prefixes\n"
)
ALIAS (show_ipv6_ospf6_interface_ifname_prefix,
show_ipv6_ospf6_interface_ifname_prefix_match_cmd,
"show ipv6 ospf6 interface IFNAME prefix X:X::X:X/M (match|detail)",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
IFNAME_STR
"Display connected prefixes to advertise\n"
OSPF6_ROUTE_PREFIX_STR
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n"
)
"Display details of the prefixes\n")
{
int idx_ifname = 4;
int idx_prefix = 6;
struct interface *ifp;
struct ospf6_interface *oi;
ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL)
{
vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING;
}
oi = ifp->info;
if (oi == NULL)
{
vty_out (vty, "OSPFv3 is not enabled on %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING;
}
ospf6_route_table_show (vty, idx_prefix, argc, argv, oi->route_connected);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_interface_prefix,
show_ipv6_ospf6_interface_prefix_cmd,
"show ipv6 ospf6 interface prefix",
"show ipv6 ospf6 interface prefix [<X:X::X:X|X:X::X:X/M>] [<match|detail>]",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Display connected prefixes to advertise\n"
)
OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n")
{
int idx_prefix = 5;
struct listnode *i;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1111,49 +1081,23 @@ DEFUN (show_ipv6_ospf6_interface_prefix,
if (oi == NULL)
continue;
ospf6_route_table_show (vty, argc, argv, oi->route_connected);
ospf6_route_table_show (vty, idx_prefix, argc, argv, oi->route_connected);
}
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_interface_prefix,
show_ipv6_ospf6_interface_prefix_detail_cmd,
"show ipv6 ospf6 interface prefix (X:X::X:X|X:X::X:X/M|detail)",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Display connected prefixes to advertise\n"
OSPF6_ROUTE_ADDRESS_STR
OSPF6_ROUTE_PREFIX_STR
"Display details of the prefixes\n"
)
ALIAS (show_ipv6_ospf6_interface_prefix,
show_ipv6_ospf6_interface_prefix_match_cmd,
"show ipv6 ospf6 interface prefix X:X::X:X/M (match|detail)",
SHOW_STR
IP6_STR
OSPF6_STR
INTERFACE_STR
"Display connected prefixes to advertise\n"
OSPF6_ROUTE_PREFIX_STR
OSPF6_ROUTE_MATCH_STR
"Display details of the prefixes\n"
)
/* interface variable set command */
DEFUN (ipv6_ospf6_ifmtu,
ipv6_ospf6_ifmtu_cmd,
"ipv6 ospf6 ifmtu <1-65535>",
"ipv6 ospf6 ifmtu (1-65535)",
IP6_STR
OSPF6_STR
"Interface MTU\n"
"OSPFv3 Interface MTU\n"
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
unsigned int ifmtu, iobuflen;
@ -1168,7 +1112,7 @@ DEFUN (ipv6_ospf6_ifmtu,
oi = ospf6_interface_create (ifp);
assert (oi);
ifmtu = strtol (argv[0], NULL, 10);
ifmtu = strtol (argv[idx_number]->arg, NULL, 10);
if (oi->ifmtu == ifmtu)
return CMD_SUCCESS;
@ -1255,13 +1199,14 @@ DEFUN (no_ipv6_ospf6_ifmtu,
DEFUN (ipv6_ospf6_cost,
ipv6_ospf6_cost_cmd,
"ipv6 ospf6 cost <1-65535>",
"ipv6 ospf6 cost (1-65535)",
IP6_STR
OSPF6_STR
"Interface cost\n"
"Outgoing metric of this interface\n"
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
unsigned long int lcost;
@ -1274,7 +1219,7 @@ DEFUN (ipv6_ospf6_cost,
oi = ospf6_interface_create (ifp);
assert (oi);
lcost = strtol (argv[0], NULL, 10);
lcost = strtol (argv[idx_number]->arg, NULL, 10);
if (lcost > UINT32_MAX)
{
@ -1322,18 +1267,19 @@ DEFUN (no_ipv6_ospf6_cost,
DEFUN (auto_cost_reference_bandwidth,
auto_cost_reference_bandwidth_cmd,
"auto-cost reference-bandwidth <1-4294967>",
"auto-cost reference-bandwidth (1-4294967)",
"Calculate OSPF interface cost according to bandwidth\n"
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
int idx_number = 2;
struct ospf6 *o = vty->index;
struct ospf6_area *oa;
struct ospf6_interface *oi;
struct listnode *i, *j;
u_int32_t refbw;
refbw = strtol (argv[0], NULL, 10);
refbw = strtol (argv[idx_number]->arg, NULL, 10);
if (refbw < 1 || refbw > 4294967)
{
vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
@ -1354,10 +1300,11 @@ DEFUN (auto_cost_reference_bandwidth,
DEFUN (no_auto_cost_reference_bandwidth,
no_auto_cost_reference_bandwidth_cmd,
"no auto-cost reference-bandwidth",
"no auto-cost reference-bandwidth [(1-4294967)]",
NO_STR
"Calculate OSPF interface cost according to bandwidth\n"
"Use reference bandwidth method to assign OSPF cost\n")
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
{
struct ospf6 *o = vty->index;
struct ospf6_area *oa;
@ -1375,23 +1322,17 @@ DEFUN (no_auto_cost_reference_bandwidth,
return CMD_SUCCESS;
}
ALIAS (no_auto_cost_reference_bandwidth,
no_auto_cost_reference_bandwidth_val_cmd,
"no auto-cost reference-bandwidth <1-4294967>",
NO_STR
"Calculate OSPF interface cost according to bandwidth\n"
"Use reference bandwidth method to assign OSPF cost\n"
"The reference bandwidth in terms of Mbits per second\n")
DEFUN (ipv6_ospf6_hellointerval,
ipv6_ospf6_hellointerval_cmd,
"ipv6 ospf6 hello-interval <1-65535>",
"ipv6 ospf6 hello-interval (1-65535)",
IP6_STR
OSPF6_STR
"Interval time of Hello packets\n"
"Time between HELLO packets\n"
SECONDS_STR
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1403,20 +1344,21 @@ DEFUN (ipv6_ospf6_hellointerval,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->hello_interval = strtol (argv[0], NULL, 10);
oi->hello_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
/* interface variable set command */
DEFUN (ipv6_ospf6_deadinterval,
ipv6_ospf6_deadinterval_cmd,
"ipv6 ospf6 dead-interval <1-65535>",
"ipv6 ospf6 dead-interval (1-65535)",
IP6_STR
OSPF6_STR
"Interval time after which a neighbor is declared down\n"
SECONDS_STR
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1428,20 +1370,20 @@ DEFUN (ipv6_ospf6_deadinterval,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->dead_interval = strtol (argv[0], NULL, 10);
oi->dead_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
/* interface variable set command */
DEFUN (ipv6_ospf6_transmitdelay,
ipv6_ospf6_transmitdelay_cmd,
"ipv6 ospf6 transmit-delay <1-3600>",
"ipv6 ospf6 transmit-delay (1-3600)",
IP6_STR
OSPF6_STR
"Transmit delay of this interface\n"
SECONDS_STR
)
"Link state transmit delay\n"
SECONDS_STR)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1453,20 +1395,21 @@ DEFUN (ipv6_ospf6_transmitdelay,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->transdelay = strtol (argv[0], NULL, 10);
oi->transdelay = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
/* interface variable set command */
DEFUN (ipv6_ospf6_retransmitinterval,
ipv6_ospf6_retransmitinterval_cmd,
"ipv6 ospf6 retransmit-interval <1-65535>",
"ipv6 ospf6 retransmit-interval (1-65535)",
IP6_STR
OSPF6_STR
"Time between retransmitting lost link state advertisements\n"
SECONDS_STR
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1478,20 +1421,21 @@ DEFUN (ipv6_ospf6_retransmitinterval,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->rxmt_interval = strtol (argv[0], NULL, 10);
oi->rxmt_interval = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
/* interface variable set command */
DEFUN (ipv6_ospf6_priority,
ipv6_ospf6_priority_cmd,
"ipv6 ospf6 priority <0-255>",
"ipv6 ospf6 priority (0-255)",
IP6_STR
OSPF6_STR
"Router priority\n"
"Priority value\n"
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1503,7 +1447,7 @@ DEFUN (ipv6_ospf6_priority,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->priority = strtol (argv[0], NULL, 10);
oi->priority = strtol (argv[idx_number]->arg, NULL, 10);
if (oi->area &&
(oi->state == OSPF6_INTERFACE_DROTHER ||
@ -1516,13 +1460,14 @@ DEFUN (ipv6_ospf6_priority,
DEFUN (ipv6_ospf6_instance,
ipv6_ospf6_instance_cmd,
"ipv6 ospf6 instance-id <0-255>",
"ipv6 ospf6 instance-id (0-255)",
IP6_STR
OSPF6_STR
"Instance ID for this interface\n"
"Instance ID value\n"
)
{
int idx_number = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1534,7 +1479,7 @@ DEFUN (ipv6_ospf6_instance,
oi = ospf6_interface_create (ifp);
assert (oi);
oi->instance_id = strtol (argv[0], NULL, 10);
oi->instance_id = strtol (argv[idx_number]->arg, NULL, 10);
return CMD_SUCCESS;
}
@ -1543,7 +1488,7 @@ DEFUN (ipv6_ospf6_passive,
"ipv6 ospf6 passive",
IP6_STR
OSPF6_STR
"passive interface, No adjacency will be formed on this interface\n"
"Passive interface; no adjacency will be formed on this interface\n"
)
{
struct ospf6_interface *oi;
@ -1604,7 +1549,7 @@ DEFUN (ipv6_ospf6_mtu_ignore,
"ipv6 ospf6 mtu-ignore",
IP6_STR
OSPF6_STR
"Ignore MTU mismatch on this interface\n"
"Disable MTU mismatch detection on this interface\n"
)
{
struct ospf6_interface *oi;
@ -1629,7 +1574,7 @@ DEFUN (no_ipv6_ospf6_mtu_ignore,
NO_STR
IP6_STR
OSPF6_STR
"Ignore MTU mismatch on this interface\n"
"Disable MTU mismatch detection on this interface\n"
)
{
struct ospf6_interface *oi;
@ -1658,6 +1603,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
"Prefix list name\n"
)
{
int idx_word = 4;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1671,7 +1617,7 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
if (oi->plist_name)
XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name);
oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[0]);
oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[idx_word]->arg);
ospf6_interface_connected_route_update (oi->interface);
@ -1734,14 +1680,15 @@ DEFUN (no_ipv6_ospf6_advertise_prefix_list,
DEFUN (ipv6_ospf6_network,
ipv6_ospf6_network_cmd,
"ipv6 ospf6 network (broadcast|point-to-point)",
"ipv6 ospf6 network <broadcast|point-to-point>",
IP6_STR
OSPF6_STR
"Network Type\n"
"Specify OSPFv6 broadcast network\n"
"Network type\n"
"Specify OSPF6 broadcast network\n"
"Specify OSPF6 point-to-point network\n"
)
{
int idx_network = 3;
struct ospf6_interface *oi;
struct interface *ifp;
@ -1754,14 +1701,14 @@ DEFUN (ipv6_ospf6_network,
}
assert (oi);
if (strncmp (argv[0], "b", 1) == 0)
if (strncmp (argv[idx_network]->arg, "b", 1) == 0)
{
if (oi->type == OSPF_IFTYPE_BROADCAST)
return CMD_SUCCESS;
oi->type = OSPF_IFTYPE_BROADCAST;
}
else if (strncmp (argv[0], "point-to-p", 10) == 0)
else if (strncmp (argv[idx_network]->arg, "point-to-p", 10) == 0)
{
if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
return CMD_SUCCESS;
@ -1782,7 +1729,7 @@ DEFUN (no_ipv6_ospf6_network,
NO_STR
IP6_STR
OSPF6_STR
"Network Type\n"
"Network type\n"
"Default to whatever interface type system specifies"
)
{
@ -1899,14 +1846,9 @@ ospf6_interface_init (void)
/* Install interface node. */
install_node (&interface_node, config_write_ospf6_interface);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_prefix_match_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_interface_ifname_prefix_match_cmd);
install_element (CONFIG_NODE, &interface_cmd);
install_default (INTERFACE_NODE);
@ -1938,7 +1880,6 @@ ospf6_interface_init (void)
/* reference bandwidth commands */
install_element (OSPF6_NODE, &auto_cost_reference_bandwidth_cmd);
install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_cmd);
install_element (OSPF6_NODE, &no_auto_cost_reference_bandwidth_val_cmd);
}
/* Clear the specified interface structure */
@ -1974,19 +1915,20 @@ DEFUN (clear_ipv6_ospf6_interface,
IFNAME_STR
)
{
int idx_ifname = 4;
struct interface *ifp;
struct listnode *node;
if (argc == 0) /* Clear all the ospfv3 interfaces. */
if (argc == 4) /* Clear all the ospfv3 interfaces. */
{
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
ospf6_interface_clear (vty, ifp);
}
else /* Interface name is specified. */
{
if ((ifp = if_lookup_by_name (argv[0])) == NULL)
if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg)) == NULL)
{
vty_out (vty, "No such Interface: %s%s", argv[0], VNL);
vty_out (vty, "No such Interface: %s%s", argv[idx_ifname]->arg, VNL);
return CMD_WARNING;
}
ospf6_interface_clear (vty, ifp);

View File

@ -1730,8 +1730,9 @@ DEFUN (debug_ospf6_brouter_router,
"Specify border-router's router-id\n"
)
{
int idx_ipv4 = 4;
u_int32_t router_id;
inet_pton (AF_INET, argv[0], &router_id);
inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON (router_id);
return CMD_SUCCESS;
}
@ -1760,8 +1761,9 @@ DEFUN (debug_ospf6_brouter_area,
"Specify Area-ID\n"
)
{
int idx_ipv4 = 4;
u_int32_t area_id;
inet_pton (AF_INET, argv[0], &area_id);
inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id);
OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON (area_id);
return CMD_SUCCESS;
}

View File

@ -818,26 +818,25 @@ ospf6_lsa_handler_name (struct ospf6_lsa_handler *h)
DEFUN (debug_ospf6_lsa_type,
debug_ospf6_lsa_hex_cmd,
"debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown)",
"debug ospf6 lsa <router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown> [<originate|examine|flooding>]",
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"Specify LS type as Hexadecimal\n"
)
"Specify LS type as Hexadecimal\n")
{
int idx_lsa = 3;
int idx_type = 4;
unsigned int i;
struct ospf6_lsa_handler *handler = NULL;
assert (argc);
for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)
{
handler = vector_slot (ospf6_lsa_handler_vector, i);
if (handler == NULL)
continue;
if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0)
if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0)
break;
if (! strcasecmp (argv[0], handler->name))
if (! strcasecmp (argv[idx_lsa]->arg, handler->name))
break;
handler = NULL;
}
@ -845,13 +844,13 @@ DEFUN (debug_ospf6_lsa_type,
if (handler == NULL)
handler = &unknown_handler;
if (argc >= 2)
if (argc == 5)
{
if (! strcmp (argv[1], "originate"))
if (! strcmp (argv[idx_type]->text, "originate"))
SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
if (! strcmp (argv[1], "examine"))
else if (! strcmp (argv[idx_type]->text, "examine"))
SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
if (! strcmp (argv[1], "flooding"))
else if (! strcmp (argv[idx_type]->text, "flooding"))
SET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
}
else
@ -860,51 +859,49 @@ DEFUN (debug_ospf6_lsa_type,
return CMD_SUCCESS;
}
ALIAS (debug_ospf6_lsa_type,
debug_ospf6_lsa_hex_detail_cmd,
"debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown) (originate|examine|flooding)",
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"Specify LS type as Hexadecimal\n"
)
DEFUN (no_debug_ospf6_lsa_type,
no_debug_ospf6_lsa_hex_cmd,
"no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown)",
"no debug ospf6 lsa <router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown> [<originate|examine|flooding>]",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"Specify LS type as Hexadecimal\n"
)
"Display Router LSAs\n"
"Display Network LSAs\n"
"Display Inter-Area-Prefix LSAs\n"
"Display As-External LSAs\n"
"Display Link LSAs\n"
"Display Intra-Area-Prefix LSAs\n"
"Display details of LSAs\n"
"Dump LSAs\n"
"Display LSA's internal information\n")
{
int idx_lsa = 4;
int idx_type = 5;
u_int i;
struct ospf6_lsa_handler *handler = NULL;
assert (argc);
for (i = 0; i < vector_active (ospf6_lsa_handler_vector); i++)
{
handler = vector_slot (ospf6_lsa_handler_vector, i);
if (handler == NULL)
continue;
if (strncmp (argv[0], ospf6_lsa_handler_name(handler), strlen(argv[0])) == 0)
if (strncmp (argv[idx_lsa]->arg, ospf6_lsa_handler_name(handler), strlen(argv[idx_lsa]->arg)) == 0)
break;
if (! strcasecmp (argv[0], handler->name))
if (! strcasecmp (argv[idx_lsa]->arg, handler->name))
break;
}
if (handler == NULL)
return CMD_SUCCESS;
if (argc >= 2)
if (argc == 6)
{
if (! strcmp (argv[1], "originate"))
if (! strcmp (argv[idx_type]->text, "originate"))
UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
if (! strcmp (argv[1], "examine"))
if (! strcmp (argv[idx_type]->text, "examine"))
UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
if (! strcmp (argv[1], "flooding"))
if (! strcmp (argv[idx_type]->text, "flooding"))
UNSET_FLAG (handler->debug, OSPF6_LSA_DEBUG_FLOOD);
}
else
@ -913,27 +910,14 @@ DEFUN (no_debug_ospf6_lsa_type,
return CMD_SUCCESS;
}
ALIAS (no_debug_ospf6_lsa_type,
no_debug_ospf6_lsa_hex_detail_cmd,
"no debug ospf6 lsa (router|network|inter-prefix|inter-router|as-external|link|intra-prefix) (originate|examine|flooding)",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"Specify LS type as Hexadecimal\n"
)
void
install_element_ospf6_debug_lsa (void)
{
install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
install_element (ENABLE_NODE, &debug_ospf6_lsa_hex_detail_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_lsa_hex_detail_cmd);
install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
install_element (CONFIG_NODE, &debug_ospf6_lsa_hex_detail_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_lsa_hex_detail_cmd);
}
int

View File

@ -2340,7 +2340,7 @@ ospf6_lsack_send_interface (struct thread *thread)
/* Commands */
DEFUN (debug_ospf6_message,
debug_ospf6_message_cmd,
"debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)",
"debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]",
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 message\n"
@ -2351,35 +2351,36 @@ DEFUN (debug_ospf6_message,
"Debug Link State Update message\n"
"Debug Link State Acknowledgement message\n"
"Debug All message\n"
)
"Debug only sending message\n"
"Debug only receiving message\n")
{
int idx_packet = 3;
int idx_send_recv = 4;
unsigned char level = 0;
int type = 0;
int i;
assert (argc > 0);
/* check type */
if (! strncmp (argv[0], "u", 1))
if (! strncmp (argv[idx_packet]->arg, "u", 1))
type = OSPF6_MESSAGE_TYPE_UNKNOWN;
else if (! strncmp (argv[0], "h", 1))
else if (! strncmp (argv[idx_packet]->arg, "h", 1))
type = OSPF6_MESSAGE_TYPE_HELLO;
else if (! strncmp (argv[0], "d", 1))
else if (! strncmp (argv[idx_packet]->arg, "d", 1))
type = OSPF6_MESSAGE_TYPE_DBDESC;
else if (! strncmp (argv[0], "lsr", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsr", 3))
type = OSPF6_MESSAGE_TYPE_LSREQ;
else if (! strncmp (argv[0], "lsu", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsu", 3))
type = OSPF6_MESSAGE_TYPE_LSUPDATE;
else if (! strncmp (argv[0], "lsa", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsa", 3))
type = OSPF6_MESSAGE_TYPE_LSACK;
else if (! strncmp (argv[0], "a", 1))
else if (! strncmp (argv[idx_packet]->arg, "a", 1))
type = OSPF6_MESSAGE_TYPE_ALL;
if (argc == 1)
if (argc == 4)
level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV;
else if (! strncmp (argv[1], "s", 1))
else if (! strncmp (argv[idx_send_recv]->arg, "s", 1))
level = OSPF6_DEBUG_MESSAGE_SEND;
else if (! strncmp (argv[1], "r", 1))
else if (! strncmp (argv[idx_send_recv]->arg, "r", 1))
level = OSPF6_DEBUG_MESSAGE_RECV;
if (type == OSPF6_MESSAGE_TYPE_ALL)
@ -2393,27 +2394,9 @@ DEFUN (debug_ospf6_message,
return CMD_SUCCESS;
}
ALIAS (debug_ospf6_message,
debug_ospf6_message_sendrecv_cmd,
"debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all) (send|recv)",
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 message\n"
"Debug Unknown message\n"
"Debug Hello message\n"
"Debug Database Description message\n"
"Debug Link State Request message\n"
"Debug Link State Update message\n"
"Debug Link State Acknowledgement message\n"
"Debug All message\n"
"Debug only sending message\n"
"Debug only receiving message\n"
)
DEFUN (no_debug_ospf6_message,
no_debug_ospf6_message_cmd,
"no debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)",
"no debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]",
NO_STR
DEBUG_STR
OSPF6_STR
@ -2425,35 +2408,36 @@ DEFUN (no_debug_ospf6_message,
"Debug Link State Update message\n"
"Debug Link State Acknowledgement message\n"
"Debug All message\n"
)
"Debug only sending message\n"
"Debug only receiving message\n")
{
int idx_packet = 4;
int idx_send_recv = 5;
unsigned char level = 0;
int type = 0;
int i;
assert (argc > 0);
/* check type */
if (! strncmp (argv[0], "u", 1))
if (! strncmp (argv[idx_packet]->arg, "u", 1))
type = OSPF6_MESSAGE_TYPE_UNKNOWN;
else if (! strncmp (argv[0], "h", 1))
else if (! strncmp (argv[idx_packet]->arg, "h", 1))
type = OSPF6_MESSAGE_TYPE_HELLO;
else if (! strncmp (argv[0], "d", 1))
else if (! strncmp (argv[idx_packet]->arg, "d", 1))
type = OSPF6_MESSAGE_TYPE_DBDESC;
else if (! strncmp (argv[0], "lsr", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsr", 3))
type = OSPF6_MESSAGE_TYPE_LSREQ;
else if (! strncmp (argv[0], "lsu", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsu", 3))
type = OSPF6_MESSAGE_TYPE_LSUPDATE;
else if (! strncmp (argv[0], "lsa", 3))
else if (! strncmp (argv[idx_packet]->arg, "lsa", 3))
type = OSPF6_MESSAGE_TYPE_LSACK;
else if (! strncmp (argv[0], "a", 1))
else if (! strncmp (argv[idx_packet]->arg, "a", 1))
type = OSPF6_MESSAGE_TYPE_ALL;
if (argc == 1)
if (argc == 5)
level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV;
else if (! strncmp (argv[1], "s", 1))
else if (! strncmp (argv[idx_send_recv]->arg, "s", 1))
level = OSPF6_DEBUG_MESSAGE_SEND;
else if (! strncmp (argv[1], "r", 1))
else if (! strncmp (argv[idx_send_recv]->arg, "r", 1))
level = OSPF6_DEBUG_MESSAGE_RECV;
if (type == OSPF6_MESSAGE_TYPE_ALL)
@ -2467,24 +2451,6 @@ DEFUN (no_debug_ospf6_message,
return CMD_SUCCESS;
}
ALIAS (no_debug_ospf6_message,
no_debug_ospf6_message_sendrecv_cmd,
"no debug ospf6 message "
"(unknown|hello|dbdesc|lsreq|lsupdate|lsack|all) (send|recv)",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 message\n"
"Debug Unknown message\n"
"Debug Hello message\n"
"Debug Database Description message\n"
"Debug Link State Request message\n"
"Debug Link State Update message\n"
"Debug Link State Acknowledgement message\n"
"Debug All message\n"
"Debug only sending message\n"
"Debug only receiving message\n"
)
int
config_write_ospf6_debug_message (struct vty *vty)
@ -2549,12 +2515,8 @@ install_element_ospf6_debug_message (void)
{
install_element (ENABLE_NODE, &debug_ospf6_message_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_message_cmd);
install_element (ENABLE_NODE, &debug_ospf6_message_sendrecv_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_message_sendrecv_cmd);
install_element (CONFIG_NODE, &debug_ospf6_message_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_message_cmd);
install_element (CONFIG_NODE, &debug_ospf6_message_sendrecv_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_message_sendrecv_cmd);
}

View File

@ -829,13 +829,15 @@ ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on)
DEFUN (show_ipv6_ospf6_neighbor,
show_ipv6_ospf6_neighbor_cmd,
"show ipv6 ospf6 neighbor",
"show ipv6 ospf6 neighbor [<detail|drchoice>]",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
)
"Display details\n"
"Display DR choices\n")
{
int idx_type = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
@ -845,11 +847,11 @@ DEFUN (show_ipv6_ospf6_neighbor,
OSPF6_CMD_CHECK_RUNNING ();
showfunc = ospf6_neighbor_show;
if (argc)
if (argc == 5)
{
if (! strncmp (argv[0], "de", 2))
if (! strncmp (argv[idx_type]->arg, "de", 2))
showfunc = ospf6_neighbor_show_detail;
else if (! strncmp (argv[0], "dr", 2))
else if (! strncmp (argv[idx_type]->arg, "dr", 2))
showfunc = ospf6_neighbor_show_drchoice;
}
@ -870,16 +872,6 @@ DEFUN (show_ipv6_ospf6_neighbor,
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_neighbor,
show_ipv6_ospf6_neighbor_detail_cmd,
"show ipv6 ospf6 neighbor (detail|drchoice)",
SHOW_STR
IP6_STR
OSPF6_STR
"Neighbor list\n"
"Display details\n"
"Display DR choices\n"
)
DEFUN (show_ipv6_ospf6_neighbor_one,
show_ipv6_ospf6_neighbor_one_cmd,
@ -891,6 +883,7 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
"Specify Router-ID as IPv4 address notation\n"
)
{
int idx_ipv4 = 4;
struct ospf6_neighbor *on;
struct ospf6_interface *oi;
struct ospf6_area *oa;
@ -901,9 +894,9 @@ DEFUN (show_ipv6_ospf6_neighbor_one,
OSPF6_CMD_CHECK_RUNNING ();
showfunc = ospf6_neighbor_show_detail;
if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)
if ((inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id)) != 1)
{
vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],
vty_out (vty, "Router-ID is not parsable: %s%s", argv[idx_ipv4]->arg,
VNL);
return CMD_SUCCESS;
}
@ -920,23 +913,25 @@ void
ospf6_neighbor_init (void)
{
install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);
}
DEFUN (debug_ospf6_neighbor,
debug_ospf6_neighbor_cmd,
"debug ospf6 neighbor",
"debug ospf6 neighbor [<state|event>]",
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 Neighbor\n"
)
"Debug OSPFv3 Neighbor State Change\n"
"Debug OSPFv3 Neighbor Event\n")
{
int idx_type = 3;
unsigned char level = 0;
if (argc)
if (argc == 4)
{
if (! strncmp (argv[0], "s", 1))
if (! strncmp (argv[idx_type]->arg, "s", 1))
level = OSPF6_DEBUG_NEIGHBOR_STATE;
if (! strncmp (argv[0], "e", 1))
else if (! strncmp (argv[idx_type]->arg, "e", 1))
level = OSPF6_DEBUG_NEIGHBOR_EVENT;
}
else
@ -946,31 +941,25 @@ DEFUN (debug_ospf6_neighbor,
return CMD_SUCCESS;
}
ALIAS (debug_ospf6_neighbor,
debug_ospf6_neighbor_detail_cmd,
"debug ospf6 neighbor (state|event)",
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 Neighbor\n"
"Debug OSPFv3 Neighbor State Change\n"
"Debug OSPFv3 Neighbor Event\n"
)
DEFUN (no_debug_ospf6_neighbor,
no_debug_ospf6_neighbor_cmd,
"no debug ospf6 neighbor",
"no debug ospf6 neighbor [<state|event>]",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 Neighbor\n"
)
"Debug OSPFv3 Neighbor State Change\n"
"Debug OSPFv3 Neighbor Event\n")
{
int idx_type = 4;
unsigned char level = 0;
if (argc)
if (argc == 5)
{
if (! strncmp (argv[0], "s", 1))
if (! strncmp (argv[idx_type]->arg, "s", 1))
level = OSPF6_DEBUG_NEIGHBOR_STATE;
if (! strncmp (argv[0], "e", 1))
if (! strncmp (argv[idx_type]->arg, "e", 1))
level = OSPF6_DEBUG_NEIGHBOR_EVENT;
}
else
@ -980,16 +969,6 @@ DEFUN (no_debug_ospf6_neighbor,
return CMD_SUCCESS;
}
ALIAS (no_debug_ospf6_neighbor,
no_debug_ospf6_neighbor_detail_cmd,
"no debug ospf6 neighbor (state|event)",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug OSPFv3 Neighbor\n"
"Debug OSPFv3 Neighbor State Change\n"
"Debug OSPFv3 Neighbor Event\n"
)
DEFUN (no_debug_ospf6,
no_debug_ospf6_cmd,
@ -1052,14 +1031,10 @@ void
install_element_ospf6_debug_neighbor (void)
{
install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);
install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_cmd);
install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);
install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_cmd);
}

View File

@ -1298,7 +1298,7 @@ ospf6_route_show_table (struct vty *vty, int detail,
}
int
ospf6_route_table_show (struct vty *vty, int argc, const char *argv[],
ospf6_route_table_show (struct vty *vty, int argc_start, int argc, struct cmd_token **argv,
struct ospf6_route_table *table)
{
int summary = 0;
@ -1312,60 +1312,60 @@ ospf6_route_table_show (struct vty *vty, int argc, const char *argv[],
memset (&prefix, 0, sizeof (struct prefix));
for (i = 0; i < argc; i++)
for (i = argc_start; i < argc; i++)
{
if (! strcmp (argv[i], "summary"))
if (! strcmp (argv[i]->arg, "summary"))
{
summary++;
continue;
}
if (! strcmp (argv[i], "intra-area"))
if (! strcmp (argv[i]->arg, "intra-area"))
{
type = OSPF6_PATH_TYPE_INTRA;
continue;
}
if (! strcmp (argv[i], "inter-area"))
if (! strcmp (argv[i]->arg, "inter-area"))
{
type = OSPF6_PATH_TYPE_INTER;
continue;
}
if (! strcmp (argv[i], "external-1"))
if (! strcmp (argv[i]->arg, "external-1"))
{
type = OSPF6_PATH_TYPE_EXTERNAL1;
continue;
}
if (! strcmp (argv[i], "external-2"))
if (! strcmp (argv[i]->arg, "external-2"))
{
type = OSPF6_PATH_TYPE_EXTERNAL2;
continue;
}
if (! strcmp (argv[i], "detail"))
if (! strcmp (argv[i]->arg, "detail"))
{
detail++;
continue;
}
if (! strcmp (argv[i], "match"))
if (! strcmp (argv[i]->arg, "match"))
{
match++;
continue;
}
ret = str2prefix (argv[i], &prefix);
ret = str2prefix (argv[i]->arg, &prefix);
if (ret == 1 && prefix.family == AF_INET6)
{
isprefix++;
if (strchr (argv[i], '/'))
if (strchr (argv[i]->arg, '/'))
slash++;
continue;
}
vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
@ -1473,7 +1473,8 @@ ospf6_linkstate_show_table (struct vty *vty, int detail,
}
int
ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[],
ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc,
struct cmd_token **argv,
struct ospf6_route_table *table)
{
int detail = 0;
@ -1486,9 +1487,9 @@ ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[],
memset (&id, 0, sizeof (struct prefix));
memset (&prefix, 0, sizeof (struct prefix));
for (i = 0; i < argc; i++)
for (i = idx_ipv4; i < argc; i++)
{
if (! strcmp (argv[i], "detail"))
if (! strcmp (argv[i]->arg, "detail"))
{
detail++;
continue;
@ -1496,29 +1497,29 @@ ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[],
if (! is_router)
{
ret = str2prefix (argv[i], &router);
ret = str2prefix (argv[i]->arg, &router);
if (ret == 1 && router.family == AF_INET)
{
is_router++;
continue;
}
vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
if (! is_id)
{
ret = str2prefix (argv[i], &id);
ret = str2prefix (argv[i]->arg, &id);
if (ret == 1 && id.family == AF_INET)
{
is_id++;
continue;
}
vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
@ -1563,25 +1564,26 @@ ospf6_brouter_show (struct vty *vty, struct ospf6_route *route)
DEFUN (debug_ospf6_route,
debug_ospf6_route_cmd,
"debug ospf6 route (table|intra-area|inter-area|memory)",
"debug ospf6 route <table|intra-area|inter-area|memory>",
DEBUG_STR
OSPF6_STR
"Debug routes\n"
"Debug route table calculation\n"
"Debug detail\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n"
)
{
int idx_type = 3;
unsigned char level = 0;
if (! strncmp (argv[0], "table", 5))
if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE;
else if (! strncmp (argv[0], "intra", 5))
else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA;
else if (! strncmp (argv[0], "inter", 5))
else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER;
else if (! strncmp (argv[0], "memor", 5))
else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_ON (level);
return CMD_SUCCESS;
@ -1589,23 +1591,26 @@ DEFUN (debug_ospf6_route,
DEFUN (no_debug_ospf6_route,
no_debug_ospf6_route_cmd,
"no debug ospf6 route (table|intra-area|inter-area|memory)",
"no debug ospf6 route <table|intra-area|inter-area|memory>",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug routes\n"
"Debug route table calculation\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n")
{
int idx_type = 4;
unsigned char level = 0;
if (! strncmp (argv[0], "table", 5))
if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE;
else if (! strncmp (argv[0], "intra", 5))
else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA;
else if (! strncmp (argv[0], "inter", 5))
else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER;
else if (! strncmp (argv[0], "memor", 5))
else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_OFF (level);
return CMD_SUCCESS;

View File

@ -329,10 +329,10 @@ extern void ospf6_route_dump (struct ospf6_route_table *table);
extern void ospf6_route_show (struct vty *vty, struct ospf6_route *route);
extern void ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route);
extern int ospf6_route_table_show (struct vty *, int, const char *[],
extern int ospf6_route_table_show (struct vty *, int, int, struct cmd_token **,
struct ospf6_route_table *);
extern int ospf6_linkstate_table_show (struct vty *vty, int argc,
const char *argv[],
extern int ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc,
struct cmd_token **argv,
struct ospf6_route_table *table);
extern void ospf6_brouter_show_header (struct vty *vty);

View File

@ -877,7 +877,7 @@ ospf6_timers_spf_set (struct vty *vty, unsigned int delay,
DEFUN (ospf6_timers_throttle_spf,
ospf6_timers_throttle_spf_cmd,
"timers throttle spf <0-600000> <0-600000> <0-600000>",
"timers throttle spf (0-600000) (0-600000) (0-600000)",
"Adjust routing timers\n"
"Throttling adaptive timer\n"
"OSPF6 SPF timers\n"
@ -885,28 +885,28 @@ DEFUN (ospf6_timers_throttle_spf,
"Initial hold time (msec) between consecutive SPF calculations\n"
"Maximum hold time (msec)\n")
{
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
unsigned int delay, hold, max;
if (argc != 3)
{
vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
return CMD_WARNING;
}
VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[idx_number]->arg, 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[idx_number_2]->arg, 0, 600000);
VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[idx_number_3]->arg, 0, 600000);
return ospf6_timers_spf_set (vty, delay, hold, max);
}
DEFUN (no_ospf6_timers_throttle_spf,
no_ospf6_timers_throttle_spf_cmd,
"no timers throttle spf",
"no timers throttle spf [(0-600000) (0-600000) (0-600000)]",
NO_STR
"Adjust routing timers\n"
"Throttling adaptive timer\n"
"OSPF6 SPF timers\n")
"OSPF6 SPF timers\n"
"Delay (msec) from first change received till SPF calculation\n"
"Initial hold time (msec) between consecutive SPF calculations\n"
"Maximum hold time (msec)\n")
{
return ospf6_timers_spf_set (vty,
OSPF_SPF_DELAY_DEFAULT,
@ -914,16 +914,6 @@ DEFUN (no_ospf6_timers_throttle_spf,
OSPF_SPF_MAX_HOLDTIME_DEFAULT);
}
ALIAS (no_ospf6_timers_throttle_spf,
no_ospf6_timers_throttle_spf_val_cmd,
"no timers throttle spf <0-600000> <0-600000> <0-600000>",
NO_STR
"Adjust routing timers\n"
"Throttling adaptive timer\n"
"OSPF6 SPF timers\n"
"Delay (msec) from first change received till SPF calculation\n"
"Initial hold time (msec) between consecutive SPF calculations\n"
"Maximum hold time (msec)\n")
int
config_write_ospf6_debug_spf (struct vty *vty)
@ -972,5 +962,4 @@ ospf6_spf_init (void)
{
install_element (OSPF6_NODE, &ospf6_timers_throttle_spf_cmd);
install_element (OSPF6_NODE, &no_ospf6_timers_throttle_spf_cmd);
install_element (OSPF6_NODE, &no_ospf6_timers_throttle_spf_val_cmd);
}

View File

@ -305,16 +305,9 @@ DEFUN (no_router_ospf6,
no_router_ospf6_cmd,
"no router ospf6",
NO_STR
OSPF6_ROUTER_STR)
ROUTER_STR
OSPF6_STR)
{
if (ospf6 == NULL)
vty_out (vty, "OSPFv3 is not configured%s", VNL);
else
{
ospf6_delete (ospf6);
ospf6 = NULL;
}
/* return to config node . */
vty->node = CONFIG_NODE;
vty->index = NULL;
@ -329,16 +322,17 @@ DEFUN (ospf6_router_id,
"Configure OSPF Router-ID\n"
V4NOTATION_STR)
{
int idx_ipv4 = 1;
int ret;
u_int32_t router_id;
struct ospf6 *o;
o = (struct ospf6 *) vty->index;
ret = inet_pton (AF_INET, argv[0], &router_id);
ret = inet_pton (AF_INET, argv[idx_ipv4]->arg, &router_id);
if (ret == 0)
{
vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
@ -403,26 +397,20 @@ DEFUN (no_ospf6_log_adjacency_changes_detail,
DEFUN (ospf6_timers_lsa,
ospf6_timers_lsa_cmd,
"timers lsa min-arrival <0-600000>",
"timers lsa min-arrival (0-600000)",
"Adjust routing timers\n"
"OSPF6 LSA timers\n"
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
{
int idx_number = 3;
unsigned int minarrival;
struct ospf6 *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
if (argc != 1)
{
vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
return CMD_WARNING;
}
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]);
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg);
ospf->lsa_minarrival = minarrival;
return CMD_SUCCESS;
@ -430,21 +418,22 @@ DEFUN (ospf6_timers_lsa,
DEFUN (no_ospf6_timers_lsa,
no_ospf6_timers_lsa_cmd,
"no timers lsa min-arrival",
"no timers lsa min-arrival [(0-600000)]",
NO_STR
"Adjust routing timers\n"
"OSPF6 LSA timers\n"
"Minimum delay in receiving new version of a LSA\n")
{
int idx_number = 4;
unsigned int minarrival;
struct ospf6 *ospf = vty->index;
if (!ospf)
return CMD_SUCCESS;
if (argc)
if (argc == 5)
{
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]);
VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[idx_number]->arg);
if (ospf->lsa_minarrival != minarrival ||
minarrival == OSPF_MIN_LS_ARRIVAL)
@ -456,31 +445,23 @@ DEFUN (no_ospf6_timers_lsa,
return CMD_SUCCESS;
}
ALIAS (no_ospf6_timers_lsa,
no_ospf6_timers_lsa_val_cmd,
"no timers lsa min-arrival <0-600000>",
NO_STR
"Adjust routing timers\n"
"OSPF6 LSA timers\n"
"Minimum delay in receiving new version of a LSA\n"
"Delay in milliseconds\n")
DEFUN (ospf6_distance,
ospf6_distance_cmd,
"distance <1-255>",
"distance (1-255)",
"Administrative distance\n"
"OSPF6 Administrative distance\n")
{
struct ospf6 *o = vty->index;
o->distance_all = atoi (argv[0]);
o->distance_all = atoi (argv[1]->arg);
return CMD_SUCCESS;
}
DEFUN (no_ospf6_distance,
no_ospf6_distance_cmd,
"no distance <1-255>",
"no distance (1-255)",
NO_STR
"Administrative distance\n"
"OSPF6 Administrative distance\n")
@ -494,7 +475,7 @@ DEFUN (no_ospf6_distance,
DEFUN (ospf6_distance_ospf6,
ospf6_distance_ospf6_cmd,
"distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
"distance ospf6 <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>",
"Administrative distance\n"
"OSPF6 distance\n"
"Intra-area routes\n"
@ -502,35 +483,68 @@ DEFUN (ospf6_distance_ospf6,
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n")
{
struct ospf6 *o = vty->index;
if (argc < 3) /* should not happen */
return CMD_WARNING;
char *intra, *inter, *external;
intra = inter = external = NULL;
if (!argv[0] && !argv[1] && !argv[2])
int idx = 0;
if (argv_find (argv, argc, "intra-area", &idx))
intra = argv[++idx]->arg;
if (argv_find (argv, argc, "intra-area", &idx))
{
vty_out(vty, "%% Command incomplete. (Arguments required)%s",
VTY_NEWLINE);
vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argv[0] != NULL)
o->distance_intra = atoi (argv[0]);
idx = 0;
if (argv_find (argv, argc, "inter-area", &idx))
inter = argv[++idx]->arg;
if (argv_find (argv, argc, "inter-area", &idx))
{
vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argv[1] != NULL)
o->distance_inter = atoi (argv[1]);
idx = 0;
if (argv_find (argv, argc, "external", &idx))
external = argv[++idx]->arg;
if (argv_find (argv, argc, "external", &idx))
{
vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argv[2] != NULL)
o->distance_external = atoi (argv[2]);
if (intra)
o->distance_intra = atoi (intra);
if (inter)
o->distance_inter = atoi (inter);
if (external)
o->distance_external = atoi (external);
return CMD_SUCCESS;
}
DEFUN (no_ospf6_distance_ospf6,
no_ospf6_distance_ospf6_cmd,
"no distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
"no distance ospf6 [<intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
NO_STR
"Administrative distance\n"
"OSPF6 distance\n"
@ -539,51 +553,93 @@ DEFUN (no_ospf6_distance_ospf6,
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n"
"Intra-area routes\n"
"Distance for intra-area routes\n"
"Inter-area routes\n"
"Distance for inter-area routes\n"
"External routes\n"
"Distance for external routes\n")
{
struct ospf6 *o = vty->index;
if (argc < 3) /* should not happen */
return CMD_WARNING;
if (argv[0] != NULL)
o->distance_intra = 0;
if (argv[1] != NULL)
o->distance_inter = 0;
if (argv[2] != NULL)
o->distance_external = 0;
if (argv[0] || argv[1] || argv[2])
return CMD_SUCCESS;
char *intra, *inter, *external;
intra = inter = external = NULL;
if (argc == 3)
{
/* If no arguments are given, clear all distance information */
o->distance_intra = 0;
o->distance_inter = 0;
o->distance_external = 0;
return CMD_SUCCESS;
}
int idx = 0;
if (argv_find (argv, argc, "intra-area", &idx))
intra = argv[++idx]->arg;
if (argv_find (argv, argc, "intra-area", &idx))
{
vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
idx = 0;
if (argv_find (argv, argc, "inter-area", &idx))
inter = argv[++idx]->arg;
if (argv_find (argv, argc, "inter-area", &idx))
{
vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
idx = 0;
if (argv_find (argv, argc, "external", &idx))
external = argv[++idx]->arg;
if (argv_find (argv, argc, "external", &idx))
{
vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argc < 3) /* should not happen */
return CMD_WARNING;
if (intra)
o->distance_intra = 0;
if (inter)
o->distance_inter = 0;
if (external)
o->distance_external = 0;
return CMD_SUCCESS;
}
DEFUN (ospf6_distance_source,
ospf6_distance_source_cmd,
"distance <1-255> X:X::X:X/M [WORD]",
"distance (1-255) X:X::X:X/M [WORD]",
"Administrative distance\n"
"Distance value\n"
"IP source prefix\n"
"Access list name\n")
{
struct ospf6 *o = vty->index;
ospf6_distance_set (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL);
char *alname = (argc == 4) ? argv[3]->arg : NULL;
ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname);
return CMD_SUCCESS;
}
DEFUN (no_ospf6_distance_source,
no_ospf6_distance_source_cmd,
"no distance <1-255> X:X::X:X/M [WORD]",
"no distance (1-255) X:X::X:X/M [WORD]",
NO_STR
"Administrative distance\n"
"Distance value\n"
@ -591,8 +647,8 @@ DEFUN (no_ospf6_distance_source,
"Access list name\n")
{
struct ospf6 *o = vty->index;
ospf6_distance_unset (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL);
char *alname = (argc == 5) ? argv[4]->arg : NULL;
ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname);
return CMD_SUCCESS;
}
@ -606,6 +662,8 @@ DEFUN (ospf6_interface_area,
"OSPF6 area ID in IPv4 address notation\n"
)
{
int idx_ifname = 1;
int idx_ipv4 = 3;
struct ospf6 *o;
struct ospf6_area *oa;
struct ospf6_interface *oi;
@ -615,7 +673,7 @@ DEFUN (ospf6_interface_area,
o = (struct ospf6 *) vty->index;
/* find/create ospf6 interface */
ifp = if_get_by_name (argv[0]);
ifp = if_get_by_name (argv[idx_ifname]->arg);
oi = (struct ospf6_interface *) ifp->info;
if (oi == NULL)
oi = ospf6_interface_create (ifp);
@ -627,9 +685,9 @@ DEFUN (ospf6_interface_area,
}
/* parse Area-ID */
if (inet_pton (AF_INET, argv[1], &area_id) != 1)
if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{
vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
@ -668,15 +726,17 @@ DEFUN (no_ospf6_interface_area,
"OSPF6 area ID in IPv4 address notation\n"
)
{
int idx_ifname = 2;
int idx_ipv4 = 4;
struct ospf6_interface *oi;
struct ospf6_area *oa;
struct interface *ifp;
u_int32_t area_id;
ifp = if_lookup_by_name (argv[0]);
ifp = if_lookup_by_name (argv[idx_ifname]->arg);
if (ifp == NULL)
{
vty_out (vty, "No such interface %s%s", argv[0], VNL);
vty_out (vty, "No such interface %s%s", argv[idx_ifname]->arg, VNL);
return CMD_SUCCESS;
}
@ -688,16 +748,16 @@ DEFUN (no_ospf6_interface_area,
}
/* parse Area-ID */
if (inet_pton (AF_INET, argv[1], &area_id) != 1)
if (inet_pton (AF_INET, argv[idx_ipv4]->arg, &area_id) != 1)
{
vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
vty_out (vty, "Invalid Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
/* Verify Area */
if (oi->area == NULL)
{
vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
vty_out (vty, "No such Area-ID: %s%s", argv[idx_ipv4]->arg, VNL);
return CMD_SUCCESS;
}
@ -775,7 +835,7 @@ DEFUN (no_ospf6_stub_router_admin,
DEFUN (ospf6_stub_router_startup,
ospf6_stub_router_startup_cmd,
"stub-router on-startup <5-86400>",
"stub-router on-startup (5-86400)",
"Make router a stub router\n"
"Advertise inability to be a transit router\n"
"Automatically advertise as stub-router on startup of OSPF6\n"
@ -798,7 +858,7 @@ DEFUN (no_ospf6_stub_router_startup,
DEFUN (ospf6_stub_router_shutdown,
ospf6_stub_router_shutdown_cmd,
"stub-router on-shutdown <5-86400>",
"stub-router on-shutdown (5-86400)",
"Make router a stub router\n"
"Advertise inability to be a transit router\n"
"Automatically advertise as stub-router before shutdown\n"
@ -913,56 +973,40 @@ DEFUN (show_ipv6_ospf6,
DEFUN (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_cmd,
"show ipv6 ospf6 route",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
)
{
OSPF6_CMD_CHECK_RUNNING ();
ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_detail_cmd,
"show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
"show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
"Specify IPv6 address\n"
"Specify IPv6 prefix\n"
"Detailed information\n"
"Summary of route table\n"
)
"Summary of route table\n")
{
OSPF6_CMD_CHECK_RUNNING ();
ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
DEFUN (show_ipv6_ospf6_route_match,
show_ipv6_ospf6_route_match_cmd,
"show ipv6 ospf6 route X:X::X:X/M match",
"show ipv6 ospf6 route X:X::X:X/M <match|longer>",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes which match the specified route\n"
)
"Display routes longer than the specified route\n")
{
const char *sargv[CMD_ARGC_MAX];
int i, sargc;
OSPF6_CMD_CHECK_RUNNING ();
/* copy argv to sargv and then append "match" */
for (i = 0; i < argc; i++)
sargv[i] = argv[i];
sargc = argc;
sargv[sargc++] = "match";
sargv[sargc] = NULL;
ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
@ -978,62 +1022,17 @@ DEFUN (show_ipv6_ospf6_route_match_detail,
"Detailed information\n"
)
{
const char *sargv[CMD_ARGC_MAX];
int i, sargc;
/* copy argv to sargv and then append "match" and "detail" */
for (i = 0; i < argc; i++)
sargv[i] = argv[i];
sargc = argc;
sargv[sargc++] = "match";
sargv[sargc++] = "detail";
sargv[sargc] = NULL;
OSPF6_CMD_CHECK_RUNNING ();
ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
ALIAS (show_ipv6_ospf6_route_match,
show_ipv6_ospf6_route_longer_cmd,
"show ipv6 ospf6 route X:X::X:X/M longer",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes longer than the specified route\n"
)
DEFUN (show_ipv6_ospf6_route_match_detail,
show_ipv6_ospf6_route_longer_detail_cmd,
"show ipv6 ospf6 route X:X::X:X/M longer detail",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Specify IPv6 prefix\n"
"Display routes longer than the specified route\n"
"Detailed information\n"
);
ALIAS (show_ipv6_ospf6_route,
show_ipv6_ospf6_route_type_cmd,
"show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
SHOW_STR
IP6_STR
OSPF6_STR
ROUTE_STR
"Display Intra-Area routes\n"
"Display Inter-Area routes\n"
"Display Type-1 External routes\n"
"Display Type-2 External routes\n"
)
DEFUN (show_ipv6_ospf6_route_type_detail,
show_ipv6_ospf6_route_type_detail_cmd,
"show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
"show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail",
SHOW_STR
IP6_STR
OSPF6_STR
@ -1045,19 +1044,9 @@ DEFUN (show_ipv6_ospf6_route_type_detail,
"Detailed information\n"
)
{
const char *sargv[CMD_ARGC_MAX];
int i, sargc;
/* copy argv to sargv and then append "detail" */
for (i = 0; i < argc; i++)
sargv[i] = argv[i];
sargc = argc;
sargv[sargc++] = "detail";
sargv[sargc] = NULL;
OSPF6_CMD_CHECK_RUNNING ();
ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
ospf6_route_table_show (vty, 4, argc, argv, ospf6->route_table);
return CMD_SUCCESS;
}
@ -1118,7 +1107,7 @@ config_write_ospf6 (struct vty *vty)
struct ospf6_area *oa;
struct ospf6_interface *oi;
/* OSPFv6 configuration. */
/* OSPFv3 configuration. */
if (ospf6 == NULL)
return CMD_SUCCESS;
@ -1183,12 +1172,8 @@ ospf6_top_init (void)
install_element (CONFIG_NODE, &no_router_ospf6_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
install_default (OSPF6_NODE);
@ -1201,7 +1186,6 @@ ospf6_top_init (void)
/* LSA timers commands */
install_element (OSPF6_NODE, &ospf6_timers_lsa_cmd);
install_element (OSPF6_NODE, &no_ospf6_timers_lsa_cmd);
install_element (OSPF6_NODE, &no_ospf6_timers_lsa_val_cmd);
install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
@ -1223,5 +1207,3 @@ ospf6_top_init (void)
install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
#endif
}

View File

@ -325,30 +325,6 @@ DEFUN (show_zebra,
return CMD_SUCCESS;
}
DEFUN (router_zebra,
router_zebra_cmd,
"router zebra",
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
vty->node = ZEBRA_NODE;
zclient->enable = 1;
zclient_start (zclient);
return CMD_SUCCESS;
}
DEFUN (no_router_zebra,
no_router_zebra_cmd,
"no router zebra",
NO_STR
"Configure routing process\n"
"Disable connection to zebra daemon\n")
{
zclient->enable = 0;
zclient_stop (zclient);
return CMD_SUCCESS;
}
/* Zebra configuration write function. */
static int
config_write_ospf6_zebra (struct vty *vty)
@ -850,9 +826,6 @@ ospf6_zebra_init (struct thread_master *master)
/* Install command element for zebra node. */
install_element (VIEW_NODE, &show_zebra_cmd);
install_element (CONFIG_NODE, &router_zebra_cmd);
install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &redistribute_ospf6_cmd);
install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd);
@ -864,7 +837,7 @@ ospf6_zebra_init (struct thread_master *master)
DEFUN (debug_ospf6_zebra_sendrecv,
debug_ospf6_zebra_sendrecv_cmd,
"debug ospf6 zebra (send|recv)",
"debug ospf6 zebra [<send|recv>]",
DEBUG_STR
OSPF6_STR
"Debug connection between zebra\n"
@ -872,13 +845,14 @@ DEFUN (debug_ospf6_zebra_sendrecv,
"Debug Receiving zebra\n"
)
{
int idx_send_recv = 3;
unsigned char level = 0;
if (argc)
if (argc == 4)
{
if (! strncmp (argv[0], "s", 1))
if (strmatch(argv[idx_send_recv]->text, "send"))
level = OSPF6_DEBUG_ZEBRA_SEND;
else if (! strncmp (argv[0], "r", 1))
else if (strmatch(argv[idx_send_recv]->text, "recv"))
level = OSPF6_DEBUG_ZEBRA_RECV;
}
else
@ -888,18 +862,9 @@ DEFUN (debug_ospf6_zebra_sendrecv,
return CMD_SUCCESS;
}
ALIAS (debug_ospf6_zebra_sendrecv,
debug_ospf6_zebra_cmd,
"debug ospf6 zebra",
DEBUG_STR
OSPF6_STR
"Debug connection between zebra\n"
)
DEFUN (no_debug_ospf6_zebra_sendrecv,
no_debug_ospf6_zebra_sendrecv_cmd,
"no debug ospf6 zebra (send|recv)",
"no debug ospf6 zebra [<send|recv>]",
NO_STR
DEBUG_STR
OSPF6_STR
@ -908,13 +873,14 @@ DEFUN (no_debug_ospf6_zebra_sendrecv,
"Debug Receiving zebra\n"
)
{
int idx_send_recv = 4;
unsigned char level = 0;
if (argc)
if (argc == 5)
{
if (! strncmp (argv[0], "s", 1))
if (strmatch(argv[idx_send_recv]->text, "send"))
level = OSPF6_DEBUG_ZEBRA_SEND;
else if (! strncmp (argv[0], "r", 1))
else if (strmatch(argv[idx_send_recv]->text, "recv"))
level = OSPF6_DEBUG_ZEBRA_RECV;
}
else
@ -924,14 +890,6 @@ DEFUN (no_debug_ospf6_zebra_sendrecv,
return CMD_SUCCESS;
}
ALIAS (no_debug_ospf6_zebra_sendrecv,
no_debug_ospf6_zebra_cmd,
"no debug ospf6 zebra",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug connection between zebra\n"
)
int
config_write_ospf6_debug_zebra (struct vty *vty)
@ -951,12 +909,8 @@ config_write_ospf6_debug_zebra (struct vty *vty)
void
install_element_ospf6_debug_zebra (void)
{
install_element (ENABLE_NODE, &debug_ospf6_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_zebra_cmd);
install_element (ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd);
install_element (ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
install_element (CONFIG_NODE, &debug_ospf6_zebra_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd);
install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd);
install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
}

File diff suppressed because it is too large Load Diff

View File

@ -379,7 +379,7 @@ DEFUN (ip_ospf_bfd,
DEFUN (ip_ospf_bfd_param,
ip_ospf_bfd_param_cmd,
"ip ospf bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
"ip ospf bfd (2-255) (50-60000) (50-60000)",
"IP Information\n"
"OSPF interface commands\n"
"Enables BFD support\n"
@ -387,6 +387,9 @@ DEFUN (ip_ospf_bfd_param,
"Required min receive interval\n"
"Desired min transmit interval\n")
{
int idx_number = 3;
int idx_number_2 = 4;
int idx_number_3 = 5;
struct interface *ifp = (struct interface *) vty->index;
u_int32_t rx_val;
u_int32_t tx_val;
@ -395,7 +398,7 @@ DEFUN (ip_ospf_bfd_param,
assert (ifp);
if ((ret = bfd_validate_param (vty, argv[0], argv[1], argv[2], &dm_val,
if ((ret = bfd_validate_param (vty, argv[idx_number]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS)
return ret;
@ -406,11 +409,14 @@ DEFUN (ip_ospf_bfd_param,
DEFUN (no_ip_ospf_bfd,
no_ip_ospf_bfd_cmd,
"no ip ospf bfd",
"no ip ospf bfd [(2-255) (50-60000) (50-60000)]",
NO_STR
"IP Information\n"
"OSPF interface commands\n"
"Disables BFD support\n")
"Disables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")
{
struct interface *ifp = (struct interface *)vty->index;
struct ospf_if_params *params;
@ -427,17 +433,6 @@ DEFUN (no_ip_ospf_bfd,
return CMD_SUCCESS;
}
ALIAS (no_ip_ospf_bfd,
no_ip_ospf_bfd_param_cmd,
"no ip ospf bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
NO_STR
"IP Information\n"
"OSPF interface commands\n"
"Enables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")
void
ospf_bfd_init(void)
{
@ -451,5 +446,4 @@ ospf_bfd_init(void)
install_element (INTERFACE_NODE, &ip_ospf_bfd_cmd);
install_element (INTERFACE_NODE, &ip_ospf_bfd_param_cmd);
install_element (INTERFACE_NODE, &no_ip_ospf_bfd_cmd);
install_element (INTERFACE_NODE, &no_ip_ospf_bfd_param_cmd);
}

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@
#include "stream.h"
#include "table.h"
#include "log.h"
#include "command.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"

View File

@ -786,11 +786,14 @@ DEFUN (capability_opaque,
return CMD_SUCCESS;
}
ALIAS (capability_opaque,
ospf_opaque_capable_cmd,
DEFUN (ospf_opaque,
ospf_opaque_cmd,
"ospf opaque-lsa",
"OSPF specific commands\n"
"Enable the Opaque-LSA capability (rfc2370)\n")
{
return capability_opaque (self, vty, argc, argv);
}
DEFUN (no_capability_opaque,
no_capability_opaque_cmd,
@ -816,20 +819,23 @@ DEFUN (no_capability_opaque,
return CMD_SUCCESS;
}
ALIAS (no_capability_opaque,
no_ospf_opaque_capable_cmd,
DEFUN (no_ospf_opaque,
no_ospf_opaque_cmd,
"no ospf opaque-lsa",
NO_STR
"OSPF specific commands\n"
"Disable the Opaque-LSA capability (rfc2370)\n")
"Enable the Opaque-LSA capability (rfc2370)\n")
{
return no_capability_opaque (self, vty, argc, argv);
}
static void
ospf_opaque_register_vty (void)
{
install_element (OSPF_NODE, &capability_opaque_cmd);
install_element (OSPF_NODE, &no_capability_opaque_cmd);
install_element (OSPF_NODE, &ospf_opaque_capable_cmd);
install_element (OSPF_NODE, &no_ospf_opaque_capable_cmd);
install_element (OSPF_NODE, &ospf_opaque_cmd);
install_element (OSPF_NODE, &no_ospf_opaque_cmd);
return;
}

View File

@ -1176,11 +1176,14 @@ ospf_router_info_config_write_router (struct vty *vty)
DEFUN (router_info,
router_info_area_cmd,
"router-info area A.B.C.D",
"router-info <as|area A.B.C.D>",
OSPF_RI_STR
"Enable the Router Information functionality with AS flooding scope\n"
"Enable the Router Information functionality with Area flooding scope\n"
"OSPF area ID in IP format")
{
int idx_ipv4 = 2;
char *area = (argc == 3) ? argv[idx_ipv4]->arg : NULL;
u_int8_t scope;
@ -1188,14 +1191,9 @@ DEFUN (router_info,
return CMD_SUCCESS;
/* Check and get Area value if present */
if (argc == 1)
if (area)
{
if (!inet_aton (argv[0], &OspfRI.area_id))
{
vty_out (vty, "Please specify Router Info Area by A.B.C.D%s",
VTY_NEWLINE);
return CMD_WARNING;
}
inet_aton (area, &OspfRI.area_id);
scope = OSPF_OPAQUE_AREA_LSA;
}
else
@ -1236,11 +1234,6 @@ DEFUN (router_info,
}
ALIAS (router_info,
router_info_as_cmd,
"router-info as",
OSPF_RI_STR
"Enable the Router Information functionality with AS flooding scope\n")
DEFUN (no_router_info,
no_router_info_cmd,
@ -1285,13 +1278,14 @@ DEFUN (pce_address,
"Stable IP address of the PCE\n"
"PCE address in IPv4 address format\n")
{
int idx_ipv4 = 2;
struct in_addr value;
struct ospf_pce_info *pi = &OspfRI.pce_info;
if (!ospf_ri_enabled (vty))
return CMD_WARNING;
if (!inet_aton (argv[0], &value))
if (!inet_aton (argv[idx_ipv4]->arg, &value))
{
vty_out (vty, "Please specify PCE Address by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING;
@ -1313,7 +1307,7 @@ DEFUN (pce_address,
DEFUN (no_pce_address,
no_pce_address_cmd,
"no pce address {A.B.C.D}",
"no pce address [A.B.C.D]",
NO_STR
PCE_STR
"Disable PCE address\n"
@ -1336,13 +1330,14 @@ DEFUN (pce_path_scope,
"Path scope visibilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n")
{
int idx_bitpattern = 2;
uint32_t scope;
struct ospf_pce_info *pi = &OspfRI.pce_info;
if (!ospf_ri_enabled (vty))
return CMD_WARNING;
if (sscanf (argv[0], "0x%x", &scope) != 1)
if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &scope) != 1)
{
vty_out (vty, "pce_path_scope: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1363,7 +1358,7 @@ DEFUN (pce_path_scope,
DEFUN (no_pce_path_scope,
no_pce_path_scope_cmd,
"no pce scope {BITPATTERN}",
"no pce scope [BITPATTERN]",
NO_STR
PCE_STR
"Disable PCE path scope\n"
@ -1381,12 +1376,13 @@ DEFUN (no_pce_path_scope,
DEFUN (pce_domain,
pce_domain_cmd,
"pce domain as <0-65535>",
"pce domain as (0-65535)",
PCE_STR
"Configure PCE domain AS number\n"
"AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 3;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
@ -1396,7 +1392,7 @@ DEFUN (pce_domain,
if (!ospf_ri_enabled (vty))
return CMD_WARNING;
if (sscanf (argv[0], "%d", &as) != 1)
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "pce_domain: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1422,18 +1418,19 @@ DEFUN (pce_domain,
DEFUN (no_pce_domain,
no_pce_domain_cmd,
"no pce domain as <0-65535>",
"no pce domain as (0-65535)",
NO_STR
PCE_STR
"Disable PCE domain AS number\n"
"AS number where the PCE as visibilities for path computation\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 4;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
if (sscanf (argv[0], "%d", &as) != 1)
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "no_pce_domain: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1452,12 +1449,13 @@ DEFUN (no_pce_domain,
DEFUN (pce_neigbhor,
pce_neighbor_cmd,
"pce neighbor as <0-65535>",
"pce neighbor as (0-65535)",
PCE_STR
"Configure PCE neighbor domain AS number\n"
"AS number of PCE neighbors\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 3;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
@ -1467,7 +1465,7 @@ DEFUN (pce_neigbhor,
if (!ospf_ri_enabled (vty))
return CMD_WARNING;
if (sscanf (argv[0], "%d", &as) != 1)
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "pce_neighbor: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1493,18 +1491,19 @@ DEFUN (pce_neigbhor,
DEFUN (no_pce_neighbor,
no_pce_neighbor_cmd,
"no pce neighbor as <0-65535>",
"no pce neighbor as (0-65535)",
NO_STR
PCE_STR
"Disable PCE neighbor AS number\n"
"AS number of PCE neighbor\n"
"AS number in decimal <0-65535>\n")
{
int idx_number = 4;
uint32_t as;
struct ospf_pce_info *pce = &OspfRI.pce_info;
if (sscanf (argv[0], "%d", &as) != 1)
if (sscanf (argv[idx_number]->arg, "%d", &as) != 1)
{
vty_out (vty, "no_pce_neighbor: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1528,6 +1527,7 @@ DEFUN (pce_cap_flag,
"Capabilities of the PCE for path computation\n"
"32-bit Hexadecimal value\n")
{
int idx_bitpattern = 2;
uint32_t cap;
struct ospf_pce_info *pce = &OspfRI.pce_info;
@ -1535,7 +1535,7 @@ DEFUN (pce_cap_flag,
if (!ospf_ri_enabled (vty))
return CMD_WARNING;
if (sscanf (argv[0], "0x%x", &cap) != 1)
if (sscanf (argv[idx_bitpattern]->arg, "0x%x", &cap) != 1)
{
vty_out (vty, "pce_cap_flag: fscanf: %s%s", safe_strerror (errno),
VTY_NEWLINE);
@ -1652,7 +1652,6 @@ ospf_router_info_register_vty (void)
install_element (VIEW_NODE, &show_ip_ospf_router_info_pce_cmd);
install_element (OSPF_NODE, &router_info_area_cmd);
install_element (OSPF_NODE, &router_info_as_cmd);
install_element (OSPF_NODE, &no_router_info_cmd);
install_element (OSPF_NODE, &pce_address_cmd);
install_element (OSPF_NODE, &no_pce_address_cmd);

View File

@ -27,6 +27,7 @@
#include "memory.h"
#include "prefix.h"
#include "table.h"
#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "log.h"
@ -163,53 +164,6 @@ ospf_route_match_add (struct vty *vty, struct route_map_index *index,
return CMD_SUCCESS;
}
static int
ospf_route_set_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_add_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* Delete rip route map rule. */
static int
ospf_route_set_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_delete_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* `match ip netxthop ' */
/* Match function return 1 if match is success else return zero. */
static route_map_result_t
@ -627,7 +581,7 @@ static struct route_map_rule_cmd route_set_tag_cmd =
DEFUN (match_ip_nexthop,
match_ip_nexthop_cmd,
"match ip next-hop (<1-199>|<1300-2699>|WORD)",
"match ip next-hop <(1-199)|(1300-2699)|WORD>",
MATCH_STR
IP_STR
"Match next-hop address of route\n"
@ -635,26 +589,13 @@ DEFUN (match_ip_nexthop,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[0]);
int idx_acl = 3;
return ospf_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg);
}
DEFUN (no_match_ip_nexthop,
no_match_ip_nexthop_cmd,
"no match ip next-hop",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "ip next-hop", NULL);
return ospf_route_match_delete (vty, vty->index, "ip next-hop", argv[0]);
}
ALIAS (no_match_ip_nexthop,
no_match_ip_nexthop_val_cmd,
"no match ip next-hop (<1-199>|<1300-2699>|WORD)",
"no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
NO_STR
MATCH_STR
IP_STR
@ -662,285 +603,36 @@ ALIAS (no_match_ip_nexthop,
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP access-list name\n")
DEFUN (match_ip_next_hop_prefix_list,
match_ip_next_hop_prefix_list_cmd,
"match ip next-hop prefix-list WORD",
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list",
argv[0]);
char *al = (argc == 5) ? argv[4]->arg : NULL;
return ospf_route_match_delete (vty, vty->index, "ip next-hop", al);
}
DEFUN (no_match_ip_next_hop_prefix_list,
no_match_ip_next_hop_prefix_list_cmd,
"no match ip next-hop prefix-list",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list",
NULL);
return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list",
argv[0]);
}
ALIAS (no_match_ip_next_hop_prefix_list,
no_match_ip_next_hop_prefix_list_val_cmd,
"no match ip next-hop prefix-list WORD",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
DEFUN (match_ip_address,
match_ip_address_cmd,
"match ip address (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
return ospf_route_match_add (vty, vty->index, "ip address", argv[0]);
}
DEFUN (no_match_ip_address,
no_match_ip_address_cmd,
"no match ip address",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "ip address", NULL);
return ospf_route_match_delete (vty, vty->index, "ip address", argv[0]);
}
ALIAS (no_match_ip_address,
no_match_ip_address_val_cmd,
"no match ip address (<1-199>|<1300-2699>|WORD)",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP access-list name\n")
DEFUN (match_ip_address_prefix_list,
match_ip_address_prefix_list_cmd,
"match ip address prefix-list WORD",
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return ospf_route_match_add (vty, vty->index, "ip address prefix-list",
argv[0]);
}
DEFUN (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_cmd,
"no match ip address prefix-list",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "ip address prefix-list",
NULL);
return ospf_route_match_delete (vty, vty->index, "ip address prefix-list",
argv[0]);
}
ALIAS (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_val_cmd,
"no match ip address prefix-list WORD",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
DEFUN (match_interface,
match_interface_cmd,
"match interface WORD",
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
{
return ospf_route_match_add (vty, vty->index, "interface", argv[0]);
}
DEFUN (no_match_interface,
no_match_interface_cmd,
"no match interface",
NO_STR
MATCH_STR
"Match first hop interface of route\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "interface", NULL);
return ospf_route_match_delete (vty, vty->index, "interface", argv[0]);
}
ALIAS (no_match_interface,
no_match_interface_val_cmd,
"no match interface WORD",
NO_STR
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
DEFUN (match_tag,
match_tag_cmd,
"match tag <1-4294967295>",
MATCH_STR
"Match tag of route\n"
"Tag value\n")
{
return ospf_route_match_add (vty, vty->index, "tag", argv[0]);
}
DEFUN (no_match_tag,
no_match_tag_cmd,
"no match tag",
NO_STR
MATCH_STR
"Match tag of route\n")
{
if (argc == 0)
return ospf_route_match_delete (vty, vty->index, "tag", NULL);
return ospf_route_match_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_match_tag,
no_match_tag_val_cmd,
"no match tag <1-4294967295>",
NO_STR
MATCH_STR
"Match tag of route\n"
"Tag value\n")
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
{
return ospf_route_set_add (vty, vty->index, "metric", argv[0]);
}
DEFUN (no_set_metric,
no_set_metric_cmd,
"no set metric",
NO_STR
SET_STR
"Metric value for destination routing protocol\n")
{
if (argc == 0)
return ospf_route_set_delete (vty, vty->index, "metric", NULL);
return ospf_route_set_delete (vty, vty->index, "metric", argv[0]);
}
ALIAS (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
DEFUN (set_metric_type,
set_metric_type_cmd,
"set metric-type (type-1|type-2)",
"set metric-type <type-1|type-2>",
SET_STR
"Type of metric for destination routing protocol\n"
"OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n")
{
if (strcmp (argv[0], "1") == 0)
return ospf_route_set_add (vty, vty->index, "metric-type", "type-1");
if (strcmp (argv[0], "2") == 0)
return ospf_route_set_add (vty, vty->index, "metric-type", "type-2");
return ospf_route_set_add (vty, vty->index, "metric-type", argv[0]);
char *ext = argv[2]->text;
return generic_set_add (vty, vty->index, "metric-type", ext);
}
DEFUN (no_set_metric_type,
no_set_metric_type_cmd,
"no set metric-type",
NO_STR
SET_STR
"Type of metric for destination routing protocol\n")
{
if (argc == 0)
return ospf_route_set_delete (vty, vty->index, "metric-type", NULL);
return ospf_route_set_delete (vty, vty->index, "metric-type", argv[0]);
}
ALIAS (no_set_metric_type,
no_set_metric_type_val_cmd,
"no set metric-type (type-1|type-2)",
"no set metric-type [<type-1|type-2>]",
NO_STR
SET_STR
"Type of metric for destination routing protocol\n"
"OSPF[6] external type 1 metric\n"
"OSPF[6] external type 2 metric\n")
DEFUN (set_tag,
set_tag_cmd,
"set tag <1-4294967295>",
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
{
return ospf_route_set_add (vty, vty->index, "tag", argv[0]);
char *ext = (argc == 4) ? argv[3]->text : NULL;
return generic_set_delete (vty, vty->index, "metric-type", ext);
}
DEFUN (no_set_tag,
no_set_tag_cmd,
"no set tag",
NO_STR
SET_STR
"Tag value for routing protocol\n")
{
if (argc == 0)
ospf_route_set_delete(vty, vty->index, "tag", NULL);
return ospf_route_set_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_set_tag,
no_set_tag_val_cmd,
"no set tag <1-4294967295>",
NO_STR
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
/* Route-map init */
void
ospf_route_map_init (void)
@ -951,6 +643,27 @@ ospf_route_map_init (void)
route_map_delete_hook (ospf_route_map_update);
route_map_event_hook (ospf_route_map_event);
route_map_match_interface_hook (generic_match_add);
route_map_no_match_interface_hook (generic_match_delete);
route_map_match_ip_address_hook (generic_match_add);
route_map_no_match_ip_address_hook (generic_match_delete);
route_map_match_ip_address_prefix_list_hook (generic_match_add);
route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
route_map_match_tag_hook (generic_match_add);
route_map_no_match_tag_hook (generic_match_delete);
route_map_set_metric_hook (generic_set_add);
route_map_no_set_metric_hook (generic_set_delete);
route_map_set_tag_hook (generic_set_add);
route_map_no_set_tag_hook (generic_set_delete);
route_map_install_match (&route_match_ip_nexthop_cmd);
route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
route_map_install_match (&route_match_ip_address_cmd);
@ -964,30 +677,7 @@ ospf_route_map_init (void)
install_element (RMAP_NODE, &match_ip_nexthop_cmd);
install_element (RMAP_NODE, &no_match_ip_nexthop_cmd);
install_element (RMAP_NODE, &no_match_ip_nexthop_val_cmd);
install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd);
install_element (RMAP_NODE, &match_ip_address_cmd);
install_element (RMAP_NODE, &no_match_ip_address_cmd);
install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
install_element (RMAP_NODE, &match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_val_cmd);
install_element (RMAP_NODE, &match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_val_cmd);
install_element (RMAP_NODE, &set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
install_element (RMAP_NODE, &set_metric_type_cmd);
install_element (RMAP_NODE, &no_set_metric_type_cmd);
install_element (RMAP_NODE, &no_set_metric_type_val_cmd);
install_element (RMAP_NODE, &set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_val_cmd);
}

View File

@ -2299,7 +2299,7 @@ DEFUN (ospf_mpls_te_on,
DEFUN (no_ospf_mpls_te,
no_ospf_mpls_te_cmd,
"no mpls-te",
"no mpls-tei [on]",
NO_STR
"Disable the MPLS-TE functionality\n")
{
@ -2325,12 +2325,6 @@ DEFUN (no_ospf_mpls_te,
return CMD_SUCCESS;
}
ALIAS (no_ospf_mpls_te,
no_ospf_mpls_te_val_cmd,
"no mpls-te on",
NO_STR
MPLS_TE_STR
"Disable the MPLS-TE functionality\n")
DEFUN (ospf_mpls_te_router_addr,
ospf_mpls_te_router_addr_cmd,
@ -2339,6 +2333,7 @@ DEFUN (ospf_mpls_te_router_addr,
"Stable IP address of the advertising router\n"
"MPLS-TE router address in IPv4 address format\n")
{
int idx_ipv4 = 2;
struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr;
struct in_addr value;
struct ospf *ospf = vty->index;
@ -2346,7 +2341,7 @@ DEFUN (ospf_mpls_te_router_addr,
if (!ospf)
return CMD_SUCCESS;
if (! inet_aton (argv[0], &value))
if (! inet_aton (argv[idx_ipv4]->arg, &value))
{
vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE);
return CMD_WARNING;
@ -2478,14 +2473,15 @@ DEFUN (ospf_mpls_te_inter_as_as,
DEFUN (ospf_mpls_te_inter_as_area,
ospf_mpls_te_inter_as_area_cmd,
"mpls-te inter-as area (A.B.C.D|<0-4294967295>)",
"mpls-te inter-as area <A.B.C.D|(0-4294967295)>",
MPLS_TE_STR
"Configure MPLS-TE Inter-AS support\n"
"AREA native mode self originate INTER_AS LSA with Type 10 (area flooding scope)\n"
"OSPF area ID in IP format\n"
"OSPF area ID as decimal value\n")
{
return set_inter_as_mode (vty, "area", argv[0]);
int idx_ipv4_number = 3;
return set_inter_as_mode (vty, "area", argv[idx_ipv4_number]->arg);
}
DEFUN (no_ospf_mpls_te_inter_as,
@ -2629,11 +2625,12 @@ DEFUN (show_ip_ospf_mpls_te_link,
"Interface information\n"
"Interface name\n")
{
int idx_interface = 5;
struct interface *ifp;
struct listnode *node, *nnode;
/* Show All Interfaces. */
if (argc == 0)
if (argc == 5)
{
for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), node, nnode, ifp))
show_mpls_te_link_sub (vty, ifp);
@ -2641,7 +2638,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
/* Interface name is specified. */
else
{
if ((ifp = if_lookup_by_name (argv[0])) == NULL)
if ((ifp = if_lookup_by_name (argv[idx_interface]->arg)) == NULL)
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
else
show_mpls_te_link_sub (vty, ifp);
@ -2658,7 +2655,6 @@ ospf_mpls_te_register_vty (void)
install_element (OSPF_NODE, &ospf_mpls_te_on_cmd);
install_element (OSPF_NODE, &no_ospf_mpls_te_cmd);
install_element (OSPF_NODE, &no_ospf_mpls_te_val_cmd);
install_element (OSPF_NODE, &ospf_mpls_te_router_addr_cmd);
install_element (OSPF_NODE, &ospf_mpls_te_inter_as_cmd);
install_element (OSPF_NODE, &ospf_mpls_te_inter_as_area_cmd);

View File

@ -253,7 +253,7 @@ struct te_link_subtlv_llri
/* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13) (RFC6827bis) are not yet supported */
/* SUBTLV 14-16 (RFC4203) are not yet supported */
/* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */
/* SUBLV 18-20 are for OSPFv6 TE (RFC5329). see ospf6d */
/* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */
/* For RFC 5392 */
/* Remote AS Number sub-TLV */

File diff suppressed because it is too large Load Diff

View File

@ -42,8 +42,6 @@ struct ospf_distance
};
/* Prototypes */
extern void ospf_zclient_start (void);
extern void ospf_zebra_add (struct prefix_ipv4 *, struct ospf_route *);
extern void ospf_zebra_delete (struct prefix_ipv4 *, struct ospf_route *);

File diff suppressed because it is too large Load Diff

View File

@ -60,12 +60,6 @@
#define MROUTE_STR "IP multicast routing table\n"
#define RIB_STR "IP unicast routing table\n"
#define PIM_CMD_NO "no"
#define PIM_CMD_IP_MULTICAST_ROUTING "ip multicast-routing"
#define PIM_CMD_IP_IGMP_QUERY_INTERVAL "ip igmp query-interval"
#define PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME "ip igmp query-max-response-time"
#define PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC "ip igmp query-max-response-time-dsec"
void pim_cmd_init(void);
#endif /* PIM_CMD_H */

View File

@ -22,6 +22,7 @@
#include <zebra.h>
#include "if.h"
#include "vty.h"
#include "routemap.h"
#include "pimd.h"

View File

@ -98,7 +98,7 @@ int pim_global_config_write(struct vty *vty)
char buffer[32];
if (PIM_MROUTE_IS_ENABLED) {
vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
vty_out(vty, "ip multicast-routing%s", VTY_NEWLINE);
++writes;
}
if (qpim_rp.rpf_addr.s_addr != INADDR_NONE) {
@ -170,8 +170,7 @@ int pim_interface_config_write(struct vty *vty)
/* IF ip igmp query-interval */
if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL)
{
vty_out(vty, " %s %d%s",
PIM_CMD_IP_IGMP_QUERY_INTERVAL,
vty_out(vty, " ip igmp query-interval %d%s",
pim_ifp->igmp_default_query_interval,
VTY_NEWLINE);
++writes;
@ -180,8 +179,7 @@ int pim_interface_config_write(struct vty *vty)
/* IF ip igmp query-max-response-time */
if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC)
{
vty_out(vty, " %s %d%s",
PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
vty_out(vty, " ip igmp query-max-response-time-dsec %d%s",
pim_ifp->igmp_query_max_response_time_dsec,
VTY_NEWLINE);
++writes;

View File

@ -90,37 +90,18 @@ DEFUN (debug_rip_packet,
DEFUN (debug_rip_packet_direct,
debug_rip_packet_direct_cmd,
"debug rip packet (recv|send)",
"debug rip packet <recv|send>",
DEBUG_STR
RIP_STR
"RIP packet\n"
"RIP receive packet\n"
"RIP send packet\n")
{
int idx_recv_send = 3;
rip_debug_packet |= RIP_DEBUG_PACKET;
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
rip_debug_packet |= RIP_DEBUG_SEND;
if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
rip_debug_packet |= RIP_DEBUG_RECV;
return CMD_SUCCESS;
}
/* N.B. the "detail" modifier is a no-op. we leave this command
for legacy compatibility. */
DEFUN_DEPRECATED (debug_rip_packet_detail,
debug_rip_packet_detail_cmd,
"debug rip packet (recv|send) detail",
DEBUG_STR
RIP_STR
"RIP packet\n"
"RIP receive packet\n"
"RIP send packet\n"
"Detailed information display\n")
{
rip_debug_packet |= RIP_DEBUG_PACKET;
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
rip_debug_packet |= RIP_DEBUG_SEND;
if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
rip_debug_packet |= RIP_DEBUG_RECV;
return CMD_SUCCESS;
}
@ -162,7 +143,7 @@ DEFUN (no_debug_rip_packet,
DEFUN (no_debug_rip_packet_direct,
no_debug_rip_packet_direct_cmd,
"no debug rip packet (recv|send)",
"no debug rip packet <recv|send>",
NO_STR
DEBUG_STR
RIP_STR
@ -170,14 +151,15 @@ DEFUN (no_debug_rip_packet_direct,
"RIP option set for receive packet\n"
"RIP option set for send packet\n")
{
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
int idx_recv_send = 4;
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{
if (IS_RIP_DEBUG_RECV)
rip_debug_packet &= ~RIP_DEBUG_SEND;
else
rip_debug_packet = 0;
}
else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{
if (IS_RIP_DEBUG_SEND)
rip_debug_packet &= ~RIP_DEBUG_RECV;
@ -265,7 +247,6 @@ rip_debug_init (void)
install_element (ENABLE_NODE, &debug_rip_events_cmd);
install_element (ENABLE_NODE, &debug_rip_packet_cmd);
install_element (ENABLE_NODE, &debug_rip_packet_direct_cmd);
install_element (ENABLE_NODE, &debug_rip_packet_detail_cmd);
install_element (ENABLE_NODE, &debug_rip_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_rip_events_cmd);
install_element (ENABLE_NODE, &no_debug_rip_packet_cmd);
@ -275,7 +256,6 @@ rip_debug_init (void)
install_element (CONFIG_NODE, &debug_rip_events_cmd);
install_element (CONFIG_NODE, &debug_rip_packet_cmd);
install_element (CONFIG_NODE, &debug_rip_packet_direct_cmd);
install_element (CONFIG_NODE, &debug_rip_packet_detail_cmd);
install_element (CONFIG_NODE, &debug_rip_zebra_cmd);
install_element (CONFIG_NODE, &no_debug_rip_events_cmd);
install_element (CONFIG_NODE, &no_debug_rip_packet_cmd);

View File

@ -1213,24 +1213,25 @@ rip_passive_nondefault_clean (void)
/* RIP enable network or interface configuration. */
DEFUN (rip_network,
rip_network_cmd,
"network (A.B.C.D/M|WORD)",
"network <A.B.C.D/M|WORD>",
"Enable routing on an IP network\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Interface name\n")
{
int idx_ipv4_word = 1;
int ret;
struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p);
if (ret)
ret = rip_enable_network_add ((struct prefix *) &p);
else
ret = rip_enable_if_add (argv[0]);
ret = rip_enable_if_add (argv[idx_ipv4_word]->arg);
if (ret < 0)
{
vty_out (vty, "There is a same network configuration %s%s", argv[0],
vty_out (vty, "There is a same network configuration %s%s", argv[idx_ipv4_word]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -1241,25 +1242,26 @@ DEFUN (rip_network,
/* RIP enable network or interface configuration. */
DEFUN (no_rip_network,
no_rip_network_cmd,
"no network (A.B.C.D/M|WORD)",
"no network <A.B.C.D/M|WORD>",
NO_STR
"Enable routing on an IP network\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Interface name\n")
{
int idx_ipv4_word = 2;
int ret;
struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4_word]->arg, &p);
if (ret)
ret = rip_enable_network_delete ((struct prefix *) &p);
else
ret = rip_enable_if_delete (argv[0]);
ret = rip_enable_if_delete (argv[idx_ipv4_word]->arg);
if (ret < 0)
{
vty_out (vty, "Can't find network configuration %s%s", argv[0],
vty_out (vty, "Can't find network configuration %s%s", argv[idx_ipv4_word]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -1274,10 +1276,11 @@ DEFUN (rip_neighbor,
"Specify a neighbor router\n"
"Neighbor address\n")
{
int idx_ipv4 = 1;
int ret;
struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
if (ret <= 0)
{
@ -1298,10 +1301,11 @@ DEFUN (no_rip_neighbor,
"Specify a neighbor router\n"
"Neighbor address\n")
{
int idx_ipv4 = 2;
int ret;
struct prefix_ipv4 p;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4]->arg, &p);
if (ret <= 0)
{
@ -1316,7 +1320,7 @@ DEFUN (no_rip_neighbor,
DEFUN (ip_rip_receive_version,
ip_rip_receive_version_cmd,
"ip rip receive version (1|2)",
"ip rip receive version (1-2)",
IP_STR
"Routing Information Protocol\n"
"Advertisement reception\n"
@ -1324,6 +1328,7 @@ DEFUN (ip_rip_receive_version,
"RIP version 1\n"
"RIP version 2\n")
{
int idx_type = 4;
struct interface *ifp;
struct rip_interface *ri;
@ -1331,12 +1336,12 @@ DEFUN (ip_rip_receive_version,
ri = ifp->info;
/* Version 1. */
if (atoi (argv[0]) == 1)
if (atoi (argv[idx_type]->arg) == 1)
{
ri->ri_receive = RI_RIP_VERSION_1;
return CMD_SUCCESS;
}
if (atoi (argv[0]) == 2)
if (atoi (argv[idx_type]->arg) == 2)
{
ri->ri_receive = RI_RIP_VERSION_2;
return CMD_SUCCESS;
@ -1346,7 +1351,7 @@ DEFUN (ip_rip_receive_version,
DEFUN (ip_rip_receive_version_1,
ip_rip_receive_version_1_cmd,
"ip rip receive version 1 2",
"ip rip receive version (1-1) (2-2)",
IP_STR
"Routing Information Protocol\n"
"Advertisement reception\n"
@ -1367,7 +1372,7 @@ DEFUN (ip_rip_receive_version_1,
DEFUN (ip_rip_receive_version_2,
ip_rip_receive_version_2_cmd,
"ip rip receive version 2 1",
"ip rip receive version (2-2) (1-1)",
IP_STR
"Routing Information Protocol\n"
"Advertisement reception\n"
@ -1388,12 +1393,14 @@ DEFUN (ip_rip_receive_version_2,
DEFUN (no_ip_rip_receive_version,
no_ip_rip_receive_version_cmd,
"no ip rip receive version",
"no ip rip receive version [(1-2)]",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Advertisement reception\n"
"Version control\n")
"Version control\n"
"Version 1\n"
"Version 2\n")
{
struct interface *ifp;
struct rip_interface *ri;
@ -1405,20 +1412,10 @@ DEFUN (no_ip_rip_receive_version,
return CMD_SUCCESS;
}
ALIAS (no_ip_rip_receive_version,
no_ip_rip_receive_version_num_cmd,
"no ip rip receive version (1|2)",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Advertisement reception\n"
"Version control\n"
"Version 1\n"
"Version 2\n")
DEFUN (ip_rip_send_version,
ip_rip_send_version_cmd,
"ip rip send version (1|2)",
"ip rip send version (1-2)",
IP_STR
"Routing Information Protocol\n"
"Advertisement transmission\n"
@ -1426,6 +1423,7 @@ DEFUN (ip_rip_send_version,
"RIP version 1\n"
"RIP version 2\n")
{
int idx_type = 4;
struct interface *ifp;
struct rip_interface *ri;
@ -1433,12 +1431,12 @@ DEFUN (ip_rip_send_version,
ri = ifp->info;
/* Version 1. */
if (atoi (argv[0]) == 1)
if (atoi (argv[idx_type]->arg) == 1)
{
ri->ri_send = RI_RIP_VERSION_1;
return CMD_SUCCESS;
}
if (atoi (argv[0]) == 2)
if (atoi (argv[idx_type]->arg) == 2)
{
ri->ri_send = RI_RIP_VERSION_2;
return CMD_SUCCESS;
@ -1448,7 +1446,7 @@ DEFUN (ip_rip_send_version,
DEFUN (ip_rip_send_version_1,
ip_rip_send_version_1_cmd,
"ip rip send version 1 2",
"ip rip send version (1-1) (2-2)",
IP_STR
"Routing Information Protocol\n"
"Advertisement transmission\n"
@ -1469,7 +1467,7 @@ DEFUN (ip_rip_send_version_1,
DEFUN (ip_rip_send_version_2,
ip_rip_send_version_2_cmd,
"ip rip send version 2 1",
"ip rip send version (2-2) (1-1)",
IP_STR
"Routing Information Protocol\n"
"Advertisement transmission\n"
@ -1490,12 +1488,14 @@ DEFUN (ip_rip_send_version_2,
DEFUN (no_ip_rip_send_version,
no_ip_rip_send_version_cmd,
"no ip rip send version",
"no ip rip send version [(1-2)]",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Advertisement transmission\n"
"Version control\n")
"Version control\n"
"Version 1\n"
"Version 2\n")
{
struct interface *ifp;
struct rip_interface *ri;
@ -1507,77 +1507,10 @@ DEFUN (no_ip_rip_send_version,
return CMD_SUCCESS;
}
ALIAS (no_ip_rip_send_version,
no_ip_rip_send_version_num_cmd,
"no ip rip send version (1|2)",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Advertisement transmission\n"
"Version control\n"
"Version 1\n"
"Version 2\n")
DEFUN (ip_rip_authentication_mode,
ip_rip_authentication_mode_cmd,
"ip rip authentication mode (md5|text)",
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication mode\n"
"Keyed message digest\n"
"Clear text authentication\n")
{
struct interface *ifp;
struct rip_interface *ri;
int auth_type;
ifp = (struct interface *)vty->index;
ri = ifp->info;
if ( (argc < 1) || (argc > 2) )
{
vty_out (vty, "incorrect argument count%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (strncmp ("md5", argv[0], strlen (argv[0])) == 0)
auth_type = RIP_AUTH_MD5;
else if (strncmp ("text", argv[0], strlen (argv[0])) == 0)
auth_type = RIP_AUTH_SIMPLE_PASSWORD;
else
{
vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (argc == 1)
{
ri->auth_type = auth_type;
return CMD_SUCCESS;
}
if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) )
{
vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (strncmp ("r", argv[1], 1) == 0)
ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
else if (strncmp ("o", argv[1], 1) == 0)
ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
else
return CMD_WARNING;
ri->auth_type = auth_type;
return CMD_SUCCESS;
}
ALIAS (ip_rip_authentication_mode,
ip_rip_authentication_mode_authlen_cmd,
"ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
"ip rip authentication mode <md5|text> [auth-length <rfc|old-ripd>]",
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
@ -1587,15 +1520,57 @@ ALIAS (ip_rip_authentication_mode,
"MD5 authentication data length\n"
"RFC compatible\n"
"Old ripd compatible\n")
{
char *cryptmode = argv[4]->text;
char *authlen = (argc > 5) ? argv[6]->text : NULL;
struct interface *ifp;
struct rip_interface *ri;
int auth_type;
ifp = (struct interface *)vty->index;
ri = ifp->info;
if (strmatch ("md5", cryptmode))
auth_type = RIP_AUTH_MD5;
else {
assert (strmatch ("text", cryptmode));
auth_type = RIP_AUTH_SIMPLE_PASSWORD;
}
ri->auth_type = auth_type;
if (argc > 5)
{
if (auth_type != RIP_AUTH_MD5)
{
vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (strmatch ("rfc", authlen))
ri->md5_auth_len = RIP_AUTH_MD5_SIZE;
else
{
assert (strmatch ("old-ripd", authlen));
ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE;
}
}
return CMD_SUCCESS;
}
DEFUN (no_ip_rip_authentication_mode,
no_ip_rip_authentication_mode_cmd,
"no ip rip authentication mode",
"no ip rip authentication mode [<md5|text> [auth-length <rfc|old-ripd>]]",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication mode\n")
"Authentication mode\n"
"Keyed message digest\n"
"Clear text authentication\n"
"MD5 authentication data length\n"
"RFC compatible\n"
"Old ripd compatible\n")
{
struct interface *ifp;
struct rip_interface *ri;
@ -1609,31 +1584,6 @@ DEFUN (no_ip_rip_authentication_mode,
return CMD_SUCCESS;
}
ALIAS (no_ip_rip_authentication_mode,
no_ip_rip_authentication_mode_type_cmd,
"no ip rip authentication mode (md5|text)",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication mode\n"
"Keyed message digest\n"
"Clear text authentication\n")
ALIAS (no_ip_rip_authentication_mode,
no_ip_rip_authentication_mode_type_authlen_cmd,
"no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication mode\n"
"Keyed message digest\n"
"Clear text authentication\n"
"MD5 authentication data length\n"
"RFC compatible\n"
"Old ripd compatible\n")
DEFUN (ip_rip_authentication_string,
ip_rip_authentication_string_cmd,
"ip rip authentication string LINE",
@ -1643,13 +1593,14 @@ DEFUN (ip_rip_authentication_string,
"Authentication string\n"
"Authentication string\n")
{
int idx_line = 4;
struct interface *ifp;
struct rip_interface *ri;
ifp = (struct interface *)vty->index;
ri = ifp->info;
if (strlen (argv[0]) > 16)
if (strlen (argv[idx_line]->arg) > 16)
{
vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s",
VTY_NEWLINE);
@ -1665,18 +1616,19 @@ DEFUN (ip_rip_authentication_string,
if (ri->auth_str)
free (ri->auth_str);
ri->auth_str = strdup (argv[0]);
ri->auth_str = strdup (argv[idx_line]->arg);
return CMD_SUCCESS;
}
DEFUN (no_ip_rip_authentication_string,
no_ip_rip_authentication_string_cmd,
"no ip rip authentication string",
"no ip rip authentication string [LINE]",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication string\n"
"Authentication string\n")
{
struct interface *ifp;
@ -1693,15 +1645,6 @@ DEFUN (no_ip_rip_authentication_string,
return CMD_SUCCESS;
}
ALIAS (no_ip_rip_authentication_string,
no_ip_rip_authentication_string2_cmd,
"no ip rip authentication string LINE",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication string\n"
"Authentication string\n")
DEFUN (ip_rip_authentication_key_chain,
ip_rip_authentication_key_chain_cmd,
@ -1712,6 +1655,7 @@ DEFUN (ip_rip_authentication_key_chain,
"Authentication key-chain\n"
"name of key-chain\n")
{
int idx_line = 4;
struct interface *ifp;
struct rip_interface *ri;
@ -1728,19 +1672,20 @@ DEFUN (ip_rip_authentication_key_chain,
if (ri->key_chain)
free (ri->key_chain);
ri->key_chain = strdup (argv[0]);
ri->key_chain = strdup (argv[idx_line]->arg);
return CMD_SUCCESS;
}
DEFUN (no_ip_rip_authentication_key_chain,
no_ip_rip_authentication_key_chain_cmd,
"no ip rip authentication key-chain",
"no ip rip authentication key-chain [LINE]",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication key-chain\n")
"Authentication key-chain\n"
"name of key-chain\n")
{
struct interface *ifp;
struct rip_interface *ri;
@ -1756,15 +1701,6 @@ DEFUN (no_ip_rip_authentication_key_chain,
return CMD_SUCCESS;
}
ALIAS (no_ip_rip_authentication_key_chain,
no_ip_rip_authentication_key_chain2_cmd,
"no ip rip authentication key-chain LINE",
NO_STR
IP_STR
"Routing Information Protocol\n"
"Authentication control\n"
"Authentication key-chain\n"
"name of key-chain\n")
/* CHANGED: ip rip split-horizon
Cisco and Zebra's command is
@ -1855,43 +1791,39 @@ DEFUN (no_ip_rip_split_horizon_poisoned_reverse,
DEFUN (rip_passive_interface,
rip_passive_interface_cmd,
"passive-interface (IFNAME|default)",
"passive-interface <IFNAME|default>",
"Suppress routing updates on an interface\n"
"Interface name\n"
"default for all interfaces\n")
{
const char *ifname = argv[0];
if (!strcmp(ifname,"default")) {
if (argv[1]->type == WORD_TKN) { // user passed 'default'
passive_default = 1;
rip_passive_nondefault_clean();
return CMD_SUCCESS;
}
if (passive_default)
return rip_passive_nondefault_unset (vty, ifname);
return rip_passive_nondefault_unset (vty, argv[1]->arg);
else
return rip_passive_nondefault_set (vty, ifname);
return rip_passive_nondefault_set (vty, argv[1]->arg);
}
DEFUN (no_rip_passive_interface,
no_rip_passive_interface_cmd,
"no passive-interface (IFNAME|default)",
"no passive-interface <IFNAME|default>",
NO_STR
"Suppress routing updates on an interface\n"
"Interface name\n"
"default for all interfaces\n")
{
const char *ifname = argv[0];
if (!strcmp(ifname,"default")) {
if (argv[2]->type == WORD_TKN) {
passive_default = 0;
rip_passive_nondefault_clean();
return CMD_SUCCESS;
}
if (passive_default)
return rip_passive_nondefault_set (vty, ifname);
return rip_passive_nondefault_set (vty, argv[2]->arg);
else
return rip_passive_nondefault_unset (vty, ifname);
return rip_passive_nondefault_unset (vty, argv[2]->arg);
}
/* Write rip configuration of each interface. */
@ -2091,27 +2023,20 @@ rip_if_init (void)
install_element (INTERFACE_NODE, &ip_rip_send_version_1_cmd);
install_element (INTERFACE_NODE, &ip_rip_send_version_2_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_send_version_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_send_version_num_cmd);
install_element (INTERFACE_NODE, &ip_rip_receive_version_cmd);
install_element (INTERFACE_NODE, &ip_rip_receive_version_1_cmd);
install_element (INTERFACE_NODE, &ip_rip_receive_version_2_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd);
install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd);
install_element (INTERFACE_NODE, &ip_rip_authentication_mode_authlen_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_authlen_cmd);
install_element (INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain2_cmd);
install_element (INTERFACE_NODE, &ip_rip_authentication_string_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_string_cmd);
install_element (INTERFACE_NODE, &no_ip_rip_authentication_string2_cmd);
install_element (INTERFACE_NODE, &ip_rip_split_horizon_cmd);
install_element (INTERFACE_NODE, &ip_rip_split_horizon_poisoned_reverse_cmd);

View File

@ -282,19 +282,22 @@ rip_offset_list_apply_out (struct prefix_ipv4 *p, struct interface *ifp,
DEFUN (rip_offset_list,
rip_offset_list_cmd,
"offset-list WORD (in|out) <0-16>",
"offset-list WORD <in|out> (0-16)",
"Modify RIP metric\n"
"Access-list name\n"
"For incoming updates\n"
"For outgoing updates\n"
"Metric value\n")
{
return rip_offset_list_set (vty, argv[0], argv[1], argv[2], NULL);
int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
}
DEFUN (rip_offset_list_ifname,
rip_offset_list_ifname_cmd,
"offset-list WORD (in|out) <0-16> IFNAME",
"offset-list WORD <in|out> (0-16) IFNAME",
"Modify RIP metric\n"
"Access-list name\n"
"For incoming updates\n"
@ -302,12 +305,16 @@ DEFUN (rip_offset_list_ifname,
"Metric value\n"
"Interface to match\n")
{
return rip_offset_list_set (vty, argv[0], argv[1], argv[2], argv[3]);
int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
int idx_ifname = 4;
return rip_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
}
DEFUN (no_rip_offset_list,
no_rip_offset_list_cmd,
"no offset-list WORD (in|out) <0-16>",
"no offset-list WORD <in|out> (0-16)",
NO_STR
"Modify RIP metric\n"
"Access-list name\n"
@ -315,12 +322,15 @@ DEFUN (no_rip_offset_list,
"For outgoing updates\n"
"Metric value\n")
{
return rip_offset_list_unset (vty, argv[0], argv[1], argv[2], NULL);
int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
}
DEFUN (no_rip_offset_list_ifname,
no_rip_offset_list_ifname_cmd,
"no offset-list WORD (in|out) <0-16> IFNAME",
"no offset-list WORD <in|out> (0-16) IFNAME",
NO_STR
"Modify RIP metric\n"
"Access-list name\n"
@ -329,7 +339,11 @@ DEFUN (no_rip_offset_list_ifname,
"Metric value\n"
"Interface to match\n")
{
return rip_offset_list_unset (vty, argv[0], argv[1], argv[2], argv[3]);
int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
int idx_ifname = 5;
return rip_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
}
static int

View File

@ -24,6 +24,7 @@
#include "memory.h"
#include "prefix.h"
#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "filter.h"
@ -45,104 +46,6 @@ struct rip_metric_modifier
u_char metric;
};
/* Add rip route map rule. */
static int
rip_route_match_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_add_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* Delete rip route map rule. */
static int
rip_route_match_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_delete_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* Add rip route map rule. */
static int
rip_route_set_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_add_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
/* rip, ripng and other protocols share the set metric command
but only values from 0 to 16 are valid for rip and ripng
if metric is out of range for rip and ripng, it is not for
other protocols. Do not return an error */
if (strcmp(command, "metric")) {
vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
}
return CMD_SUCCESS;
}
/* Delete rip route map rule. */
static int
rip_route_set_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_delete_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* Hook function for updating route_map assignment. */
/* ARGSUSED */
static void
@ -685,380 +588,6 @@ static struct route_map_rule_cmd route_set_tag_cmd =
#define MATCH_STR "Match values from routing table\n"
#define SET_STR "Set values in destination routing protocol\n"
DEFUN (match_metric,
match_metric_cmd,
"match metric <0-4294967295>",
MATCH_STR
"Match metric of route\n"
"Metric value\n")
{
return rip_route_match_add (vty, vty->index, "metric", argv[0]);
}
DEFUN (no_match_metric,
no_match_metric_cmd,
"no match metric",
NO_STR
MATCH_STR
"Match metric of route\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "metric", NULL);
return rip_route_match_delete (vty, vty->index, "metric", argv[0]);
}
ALIAS (no_match_metric,
no_match_metric_val_cmd,
"no match metric <0-4294967295>",
NO_STR
MATCH_STR
"Match metric of route\n"
"Metric value\n")
DEFUN (match_interface,
match_interface_cmd,
"match interface WORD",
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
{
return rip_route_match_add (vty, vty->index, "interface", argv[0]);
}
DEFUN (no_match_interface,
no_match_interface_cmd,
"no match interface",
NO_STR
MATCH_STR
"Match first hop interface of route\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "interface", NULL);
return rip_route_match_delete (vty, vty->index, "interface", argv[0]);
}
ALIAS (no_match_interface,
no_match_interface_val_cmd,
"no match interface WORD",
NO_STR
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
DEFUN (match_ip_next_hop,
match_ip_next_hop_cmd,
"match ip next-hop (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
return rip_route_match_add (vty, vty->index, "ip next-hop", argv[0]);
}
DEFUN (no_match_ip_next_hop,
no_match_ip_next_hop_cmd,
"no match ip next-hop",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "ip next-hop", NULL);
return rip_route_match_delete (vty, vty->index, "ip next-hop", argv[0]);
}
ALIAS (no_match_ip_next_hop,
no_match_ip_next_hop_val_cmd,
"no match ip next-hop (<1-199>|<1300-2699>|WORD)",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
DEFUN (match_ip_next_hop_prefix_list,
match_ip_next_hop_prefix_list_cmd,
"match ip next-hop prefix-list WORD",
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[0]);
}
DEFUN (no_match_ip_next_hop_prefix_list,
no_match_ip_next_hop_prefix_list_cmd,
"no match ip next-hop prefix-list",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", NULL);
return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", argv[0]);
}
ALIAS (no_match_ip_next_hop_prefix_list,
no_match_ip_next_hop_prefix_list_val_cmd,
"no match ip next-hop prefix-list WORD",
NO_STR
MATCH_STR
IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
DEFUN (match_ip_address,
match_ip_address_cmd,
"match ip address (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
{
return rip_route_match_add (vty, vty->index, "ip address", argv[0]);
}
DEFUN (no_match_ip_address,
no_match_ip_address_cmd,
"no match ip address",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "ip address", NULL);
return rip_route_match_delete (vty, vty->index, "ip address", argv[0]);
}
ALIAS (no_match_ip_address,
no_match_ip_address_val_cmd,
"no match ip address (<1-199>|<1300-2699>|WORD)",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
"IP Access-list name\n")
DEFUN (match_ip_address_prefix_list,
match_ip_address_prefix_list_cmd,
"match ip address prefix-list WORD",
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
{
return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[0]);
}
DEFUN (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_cmd,
"no match ip address prefix-list",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "ip address prefix-list", NULL);
return rip_route_match_delete (vty, vty->index, "ip address prefix-list", argv[0]);
}
ALIAS (no_match_ip_address_prefix_list,
no_match_ip_address_prefix_list_val_cmd,
"no match ip address prefix-list WORD",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
DEFUN (match_tag,
match_tag_cmd,
"match tag <1-4294967295>",
MATCH_STR
"Match tag of route\n"
"Metric value\n")
{
return rip_route_match_add (vty, vty->index, "tag", argv[0]);
}
DEFUN (no_match_tag,
no_match_tag_cmd,
"no match tag",
NO_STR
MATCH_STR
"Match tag of route\n")
{
if (argc == 0)
return rip_route_match_delete (vty, vty->index, "tag", NULL);
return rip_route_match_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_match_tag,
no_match_tag_val_cmd,
"no match tag <1-4294967295>",
NO_STR
MATCH_STR
"Match tag of route\n"
"Metric value\n")
/* set functions */
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
{
return rip_route_set_add (vty, vty->index, "metric", argv[0]);
}
ALIAS (set_metric,
set_metric_addsub_cmd,
"set metric <+/-metric>",
SET_STR
"Metric value for destination routing protocol\n"
"Add or subtract metric\n")
DEFUN (no_set_metric,
no_set_metric_cmd,
"no set metric",
NO_STR
SET_STR
"Metric value for destination routing protocol\n")
{
if (argc == 0)
return rip_route_set_delete (vty, vty->index, "metric", NULL);
return rip_route_set_delete (vty, vty->index, "metric", argv[0]);
}
ALIAS (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
ALIAS (no_set_metric,
no_set_metric_addsub_cmd,
"no set metric <+/-metric>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Add or subtract metric\n")
DEFUN (set_ip_nexthop,
set_ip_nexthop_cmd,
"set ip next-hop A.B.C.D",
SET_STR
IP_STR
"Next hop address\n"
"IP address of next hop\n")
{
union sockunion su;
int ret;
ret = str2sockunion (argv[0], &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (su.sin.sin_addr.s_addr == 0 ||
IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
{
vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast "
"or reserved%s", VTY_NEWLINE);
return CMD_WARNING;
}
return rip_route_set_add (vty, vty->index, "ip next-hop", argv[0]);
}
DEFUN (no_set_ip_nexthop,
no_set_ip_nexthop_cmd,
"no set ip next-hop",
NO_STR
SET_STR
IP_STR
"Next hop address\n")
{
if (argc == 0)
return rip_route_set_delete (vty, vty->index, "ip next-hop", NULL);
return rip_route_set_delete (vty, vty->index, "ip next-hop", argv[0]);
}
ALIAS (no_set_ip_nexthop,
no_set_ip_nexthop_val_cmd,
"no set ip next-hop A.B.C.D",
NO_STR
SET_STR
IP_STR
"Next hop address\n"
"IP address of next hop\n")
DEFUN (set_tag,
set_tag_cmd,
"set tag <1-4294967295>",
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
{
return rip_route_set_add (vty, vty->index, "tag", argv[0]);
}
DEFUN (no_set_tag,
no_set_tag_cmd,
"no set tag",
NO_STR
SET_STR
"Tag value for routing protocol\n")
{
if (argc == 0)
return rip_route_set_delete (vty, vty->index, "tag", NULL);
return rip_route_set_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_set_tag,
no_set_tag_val_cmd,
"no set tag <1-4294967295>",
NO_STR
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
void
rip_route_map_reset ()
{
@ -1074,6 +603,36 @@ rip_route_map_init ()
route_map_add_hook (rip_route_map_update);
route_map_delete_hook (rip_route_map_update);
route_map_match_interface_hook (generic_match_add);
route_map_no_match_interface_hook (generic_match_delete);
route_map_match_ip_address_hook (generic_match_add);
route_map_no_match_ip_address_hook (generic_match_delete);
route_map_match_ip_address_prefix_list_hook (generic_match_add);
route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
route_map_match_ip_next_hop_hook (generic_match_add);
route_map_no_match_ip_next_hop_hook (generic_match_delete);
route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
route_map_match_metric_hook (generic_match_add);
route_map_no_match_metric_hook (generic_match_delete);
route_map_match_tag_hook (generic_match_add);
route_map_no_match_tag_hook (generic_match_delete);
route_map_set_ip_nexthop_hook (generic_set_add);
route_map_no_set_ip_nexthop_hook (generic_set_delete);
route_map_set_metric_hook (generic_set_add);
route_map_no_set_metric_hook (generic_set_delete);
route_map_set_tag_hook (generic_set_add);
route_map_no_set_tag_hook (generic_set_delete);
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_ip_next_hop_cmd);
@ -1085,38 +644,4 @@ rip_route_map_init ()
route_map_install_set (&route_set_metric_cmd);
route_map_install_set (&route_set_ip_nexthop_cmd);
route_map_install_set (&route_set_tag_cmd);
install_element (RMAP_NODE, &match_metric_cmd);
install_element (RMAP_NODE, &no_match_metric_cmd);
install_element (RMAP_NODE, &no_match_metric_val_cmd);
install_element (RMAP_NODE, &match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_val_cmd);
install_element (RMAP_NODE, &match_ip_next_hop_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd);
install_element (RMAP_NODE, &match_ip_address_cmd);
install_element (RMAP_NODE, &no_match_ip_address_cmd);
install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
install_element (RMAP_NODE, &match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_val_cmd);
install_element (RMAP_NODE, &set_metric_cmd);
install_element (RMAP_NODE, &set_metric_addsub_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
install_element (RMAP_NODE, &no_set_metric_addsub_cmd);
install_element (RMAP_NODE, &set_ip_nexthop_cmd);
install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
install_element (RMAP_NODE, &set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_val_cmd);
}

View File

@ -263,46 +263,6 @@ static struct {
{0, 0, NULL}
};
DEFUN (router_zebra,
router_zebra_cmd,
"router zebra",
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
vty->node = ZEBRA_NODE;
zclient->enable = 1;
zclient_start (zclient);
return CMD_SUCCESS;
}
DEFUN (no_router_zebra,
no_router_zebra_cmd,
"no router zebra",
NO_STR
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
zclient->enable = 0;
zclient_stop (zclient);
return CMD_SUCCESS;
}
#if 0
static int
rip_redistribute_set (int type)
{
if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT))
return CMD_SUCCESS;
vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT);
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type);
return CMD_SUCCESS;
}
#endif
static int
rip_redistribute_unset (int type)
{
@ -371,7 +331,7 @@ DEFUN (no_rip_redistribute_rip,
DEFUN (rip_redistribute_type,
rip_redistribute_type_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPD,
"redistribute <kernel|connected|static|ospf|isis|bgp|pim|table>",
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD)
{
@ -379,7 +339,7 @@ DEFUN (rip_redistribute_type,
for(i = 0; redist_type[i].str; i++)
{
if (strncmp (redist_type[i].str, argv[0],
if (strncmp (redist_type[i].str, argv[2]->arg,
redist_type[i].str_min_len) == 0)
{
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient,
@ -388,7 +348,7 @@ DEFUN (rip_redistribute_type,
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[2]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -396,7 +356,7 @@ DEFUN (rip_redistribute_type,
DEFUN (no_rip_redistribute_type,
no_rip_redistribute_type_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPD,
"no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table>",
NO_STR
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD)
@ -405,7 +365,7 @@ DEFUN (no_rip_redistribute_type,
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[3]->arg,
redist_type[i].str_min_len) == 0)
{
rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP);
@ -415,7 +375,7 @@ DEFUN (no_rip_redistribute_type,
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[3]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -423,26 +383,28 @@ DEFUN (no_rip_redistribute_type,
DEFUN (rip_redistribute_type_routemap,
rip_redistribute_type_routemap_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD",
"redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> route-map WORD",
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 1;
int idx_word = 3;
int i;
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
rip_routemap_set (redist_type[i].type, argv[1]);
rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
redist_type[i].type, 0, VRF_DEFAULT);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -450,28 +412,30 @@ DEFUN (rip_redistribute_type_routemap,
DEFUN (no_rip_redistribute_type_routemap,
no_rip_redistribute_type_routemap_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD",
"no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> route-map WORD",
NO_STR
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 2;
int idx_word = 4;
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
if (rip_routemap_unset (redist_type[i].type,argv[1]))
if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg))
return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -479,19 +443,21 @@ DEFUN (no_rip_redistribute_type_routemap,
DEFUN (rip_redistribute_type_metric,
rip_redistribute_type_metric_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>",
"redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16)",
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
"Metric\n"
"Metric value\n")
{
int idx_protocol = 1;
int idx_number = 3;
int i;
int metric;
metric = atoi (argv[1]);
metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
rip_redistribute_metric_set (redist_type[i].type, metric);
@ -501,7 +467,7 @@ DEFUN (rip_redistribute_type_metric,
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -509,28 +475,30 @@ DEFUN (rip_redistribute_type_metric,
DEFUN (no_rip_redistribute_type_metric,
no_rip_redistribute_type_metric_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>",
"no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16)",
NO_STR
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
"Metric\n"
"Metric value\n")
{
int idx_protocol = 2;
int idx_number = 4;
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -538,7 +506,7 @@ DEFUN (no_rip_redistribute_type_metric,
DEFUN (rip_redistribute_type_metric_routemap,
rip_redistribute_type_metric_routemap_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16> route-map WORD",
"redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16) route-map WORD",
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
"Metric\n"
@ -546,24 +514,27 @@ DEFUN (rip_redistribute_type_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
int i;
int metric;
metric = atoi (argv[1]);
metric = atoi (argv[idx_number]->arg);
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
rip_redistribute_metric_set (redist_type[i].type, metric);
rip_routemap_set (redist_type[i].type, argv[2]);
rip_routemap_set (redist_type[i].type, argv[idx_word]->arg);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
redist_type[i].type, 0, VRF_DEFAULT);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -572,8 +543,7 @@ DEFUN (rip_redistribute_type_metric_routemap,
DEFUN (no_rip_redistribute_type_metric_routemap,
no_rip_redistribute_type_metric_routemap_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPD
" metric <0-16> route-map WORD",
"no redistribute <kernel|connected|static|ospf|isis|bgp|pim|table> metric (0-16) route-map WORD",
NO_STR
REDIST_STR
QUAGGA_REDIST_HELP_STR_RIPD
@ -582,18 +552,21 @@ DEFUN (no_rip_redistribute_type_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 2;
int idx_number = 4;
int idx_word = 6;
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
if (strncmp(redist_type[i].str, argv[idx_protocol]->arg,
redist_type[i].str_min_len) == 0)
{
if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg)))
return CMD_WARNING;
if (rip_routemap_unset (redist_type[i].type, argv[2]))
if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg))
{
rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1]));
rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg));
return CMD_WARNING;
}
rip_redistribute_unset (redist_type[i].type);
@ -601,7 +574,7 @@ DEFUN (no_rip_redistribute_type_metric_routemap,
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg,
VTY_NEWLINE);
return CMD_WARNING;
@ -744,8 +717,6 @@ rip_zclient_init (struct thread_master *master)
install_node (&zebra_node, config_write_zebra);
/* Install command elements to zebra node. */
install_element (CONFIG_NODE, &router_zebra_cmd);
install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd);
install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd);

View File

@ -2879,13 +2879,14 @@ DEFUN (no_router_rip,
DEFUN (rip_version,
rip_version_cmd,
"version <1-2>",
"version (1-2)",
"Set routing protocol version\n"
"version\n")
{
int idx_number = 1;
int version;
version = atoi (argv[0]);
version = atoi (argv[idx_number]->arg);
if (version != RIPv1 && version != RIPv2)
{
vty_out (vty, "invalid rip version %d%s", version,
@ -2900,9 +2901,10 @@ DEFUN (rip_version,
DEFUN (no_rip_version,
no_rip_version_cmd,
"no version",
"no version [(1-2)]",
NO_STR
"Set routing protocol version\n")
"Set routing protocol version\n"
"Version\n")
{
/* Set RIP version to the default. */
rip->version_send = RI_RIP_VERSION_2;
@ -2911,12 +2913,6 @@ DEFUN (no_rip_version,
return CMD_SUCCESS;
}
ALIAS (no_rip_version,
no_rip_version_val_cmd,
"no version <1-2>",
NO_STR
"Set routing protocol version\n"
"version\n")
DEFUN (rip_route,
rip_route_cmd,
@ -2924,11 +2920,12 @@ DEFUN (rip_route,
"RIP static route configuration\n"
"IP prefix <network>/<length>\n")
{
int idx_ipv4_prefixlen = 1;
int ret;
struct prefix_ipv4 p;
struct route_node *node;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p);
if (ret < 0)
{
vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2960,11 +2957,12 @@ DEFUN (no_rip_route,
"RIP static route configuration\n"
"IP prefix <network>/<length>\n")
{
int idx_ipv4_prefixlen = 2;
int ret;
struct prefix_ipv4 p;
struct route_node *node;
ret = str2prefix_ipv4 (argv[0], &p);
ret = str2prefix_ipv4 (argv[idx_ipv4_prefixlen]->arg, &p);
if (ret < 0)
{
vty_out (vty, "Malformed address%s", VTY_NEWLINE);
@ -2976,7 +2974,7 @@ DEFUN (no_rip_route,
node = route_node_lookup (rip->route, (struct prefix *) &p);
if (! node)
{
vty_out (vty, "Can't find route %s.%s", argv[0],
vty_out (vty, "Can't find route %s.%s", argv[idx_ipv4_prefixlen]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -3009,13 +3007,14 @@ rip_update_default_metric (void)
DEFUN (rip_default_metric,
rip_default_metric_cmd,
"default-metric <1-16>",
"default-metric (1-16)",
"Set a metric of redistribute routes\n"
"Default metric\n")
{
int idx_number = 1;
if (rip)
{
rip->default_metric = atoi (argv[0]);
rip->default_metric = atoi (argv[idx_number]->arg);
/* rip_update_default_metric (); */
}
return CMD_SUCCESS;
@ -3023,7 +3022,7 @@ DEFUN (rip_default_metric,
DEFUN (no_rip_default_metric,
no_rip_default_metric_cmd,
"no default-metric",
"no default-metric [(1-16)]",
NO_STR
"Set a metric of redistribute routes\n"
"Default metric\n")
@ -3036,22 +3035,19 @@ DEFUN (no_rip_default_metric,
return CMD_SUCCESS;
}
ALIAS (no_rip_default_metric,
no_rip_default_metric_val_cmd,
"no default-metric <1-16>",
NO_STR
"Set a metric of redistribute routes\n"
"Default metric\n")
DEFUN (rip_timers,
rip_timers_cmd,
"timers basic <5-2147483647> <5-2147483647> <5-2147483647>",
"timers basic (5-2147483647) (5-2147483647) (5-2147483647)",
"Adjust routing timers\n"
"Basic routing protocol update timers\n"
"Routing table update timer value in second. Default is 30.\n"
"Routing information timeout timer. Default is 180.\n"
"Garbage collection timer. Default is 120.\n")
{
int idx_number = 2;
int idx_number_2 = 3;
int idx_number_3 = 4;
unsigned long update;
unsigned long timeout;
unsigned long garbage;
@ -3059,21 +3055,21 @@ DEFUN (rip_timers,
unsigned long RIP_TIMER_MAX = 2147483647;
unsigned long RIP_TIMER_MIN = 5;
update = strtoul (argv[0], &endptr, 10);
update = strtoul (argv[idx_number]->arg, &endptr, 10);
if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN || *endptr != '\0')
{
vty_out (vty, "update timer value error%s", VTY_NEWLINE);
return CMD_WARNING;
}
timeout = strtoul (argv[1], &endptr, 10);
timeout = strtoul (argv[idx_number_2]->arg, &endptr, 10);
if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN || *endptr != '\0')
{
vty_out (vty, "timeout timer value error%s", VTY_NEWLINE);
return CMD_WARNING;
}
garbage = strtoul (argv[2], &endptr, 10);
garbage = strtoul (argv[idx_number_3]->arg, &endptr, 10);
if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN || *endptr != '\0')
{
vty_out (vty, "garbage timer value error%s", VTY_NEWLINE);
@ -3093,10 +3089,13 @@ DEFUN (rip_timers,
DEFUN (no_rip_timers,
no_rip_timers_cmd,
"no timers basic",
"no timers basic [(0-65535) (0-65535) (0-65535)]",
NO_STR
"Adjust routing timers\n"
"Basic routing protocol update timers\n")
"Basic routing protocol update timers\n"
"Routing table update timer value in second. Default is 30.\n"
"Routing information timeout timer. Default is 180.\n"
"Garbage collection timer. Default is 120.\n")
{
/* Set each timer value to the default. */
rip->update_time = RIP_UPDATE_TIMER_DEFAULT;
@ -3109,15 +3108,6 @@ DEFUN (no_rip_timers,
return CMD_SUCCESS;
}
ALIAS (no_rip_timers,
no_rip_timers_val_cmd,
"no timers basic <0-65535> <0-65535> <0-65535>",
NO_STR
"Adjust routing timers\n"
"Basic routing protocol update timers\n"
"Routing table update timer value in second. Default is 30.\n"
"Routing information timeout timer. Default is 180.\n"
"Garbage collection timer. Default is 120.\n")
struct route_table *rip_distance_table;
@ -3318,17 +3308,18 @@ rip_distance_show (struct vty *vty)
DEFUN (rip_distance,
rip_distance_cmd,
"distance <1-255>",
"distance (1-255)",
"Administrative distance\n"
"Distance value\n")
{
rip->distance = atoi (argv[0]);
int idx_number = 1;
rip->distance = atoi (argv[idx_number]->arg);
return CMD_SUCCESS;
}
DEFUN (no_rip_distance,
no_rip_distance_cmd,
"no distance <1-255>",
"no distance (1-255)",
NO_STR
"Administrative distance\n"
"Distance value\n")
@ -3339,49 +3330,59 @@ DEFUN (no_rip_distance,
DEFUN (rip_distance_source,
rip_distance_source_cmd,
"distance <1-255> A.B.C.D/M",
"distance (1-255) A.B.C.D/M",
"Administrative distance\n"
"Distance value\n"
"IP source prefix\n")
{
rip_distance_set (vty, argv[0], argv[1], NULL);
int idx_number = 1;
int idx_ipv4_prefixlen = 2;
rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL);
return CMD_SUCCESS;
}
DEFUN (no_rip_distance_source,
no_rip_distance_source_cmd,
"no distance <1-255> A.B.C.D/M",
"no distance (1-255) A.B.C.D/M",
NO_STR
"Administrative distance\n"
"Distance value\n"
"IP source prefix\n")
{
rip_distance_unset (vty, argv[0], argv[1], NULL);
int idx_number = 2;
int idx_ipv4_prefixlen = 3;
rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, NULL);
return CMD_SUCCESS;
}
DEFUN (rip_distance_source_access_list,
rip_distance_source_access_list_cmd,
"distance <1-255> A.B.C.D/M WORD",
"distance (1-255) A.B.C.D/M WORD",
"Administrative distance\n"
"Distance value\n"
"IP source prefix\n"
"Access list name\n")
{
rip_distance_set (vty, argv[0], argv[1], argv[2]);
int idx_number = 1;
int idx_ipv4_prefixlen = 2;
int idx_word = 3;
rip_distance_set (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg);
return CMD_SUCCESS;
}
DEFUN (no_rip_distance_source_access_list,
no_rip_distance_source_access_list_cmd,
"no distance <1-255> A.B.C.D/M WORD",
"no distance (1-255) A.B.C.D/M WORD",
NO_STR
"Administrative distance\n"
"Distance value\n"
"IP source prefix\n"
"Access list name\n")
{
rip_distance_unset (vty, argv[0], argv[1], argv[2]);
int idx_number = 2;
int idx_ipv4_prefixlen = 3;
int idx_word = 4;
rip_distance_unset (vty, argv[idx_number]->arg, argv[idx_ipv4_prefixlen]->arg, argv[idx_word]->arg);
return CMD_SUCCESS;
}
@ -4090,13 +4091,10 @@ rip_init (void)
install_default (RIP_NODE);
install_element (RIP_NODE, &rip_version_cmd);
install_element (RIP_NODE, &no_rip_version_cmd);
install_element (RIP_NODE, &no_rip_version_val_cmd);
install_element (RIP_NODE, &rip_default_metric_cmd);
install_element (RIP_NODE, &no_rip_default_metric_cmd);
install_element (RIP_NODE, &no_rip_default_metric_val_cmd);
install_element (RIP_NODE, &rip_timers_cmd);
install_element (RIP_NODE, &no_rip_timers_cmd);
install_element (RIP_NODE, &no_rip_timers_val_cmd);
install_element (RIP_NODE, &rip_route_cmd);
install_element (RIP_NODE, &no_rip_route_cmd);
install_element (RIP_NODE, &rip_distance_cmd);

View File

@ -392,7 +392,6 @@ extern void rip_route_map_init (void);
extern void rip_route_map_reset (void);
extern void rip_snmp_init (void);
extern void rip_zclient_init(struct thread_master *);
extern void rip_zclient_start (void);
extern void rip_zclient_reset (void);
extern void rip_offset_init (void);
extern int if_check_address (struct in_addr addr);

View File

@ -91,38 +91,18 @@ DEFUN (debug_ripng_packet,
DEFUN (debug_ripng_packet_direct,
debug_ripng_packet_direct_cmd,
"debug ripng packet (recv|send)",
"debug ripng packet <recv|send>",
DEBUG_STR
"RIPng configuration\n"
"Debug option set for ripng packet\n"
"Debug option set for receive packet\n"
"Debug option set for send packet\n")
{
int idx_recv_send = 3;
ripng_debug_packet |= RIPNG_DEBUG_PACKET;
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
ripng_debug_packet |= RIPNG_DEBUG_SEND;
if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
ripng_debug_packet |= RIPNG_DEBUG_RECV;
return CMD_SUCCESS;
}
/* N.B. the "detail" modifier is a no-op. we leave this command
for legacy compatibility. */
DEFUN_DEPRECATED (debug_ripng_packet_detail,
debug_ripng_packet_detail_cmd,
"debug ripng packet (recv|send) detail",
DEBUG_STR
"RIPng configuration\n"
"Debug option set for ripng packet\n"
"Debug option set for receive packet\n"
"Debug option set for send packet\n"
"Debug option set detaied information\n")
{
ripng_debug_packet |= RIPNG_DEBUG_PACKET;
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
ripng_debug_packet |= RIPNG_DEBUG_SEND;
if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
ripng_debug_packet |= RIPNG_DEBUG_RECV;
return CMD_SUCCESS;
@ -165,7 +145,7 @@ DEFUN (no_debug_ripng_packet,
DEFUN (no_debug_ripng_packet_direct,
no_debug_ripng_packet_direct_cmd,
"no debug ripng packet (recv|send)",
"no debug ripng packet <recv|send>",
NO_STR
DEBUG_STR
"RIPng configuration\n"
@ -173,14 +153,15 @@ DEFUN (no_debug_ripng_packet_direct,
"Debug option set for receive packet\n"
"Debug option set for send packet\n")
{
if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
int idx_recv_send = 4;
if (strncmp ("send", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{
if (IS_RIPNG_DEBUG_RECV)
ripng_debug_packet &= ~RIPNG_DEBUG_SEND;
else
ripng_debug_packet = 0;
}
else if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
else if (strncmp ("recv", argv[idx_recv_send]->arg, strlen (argv[idx_recv_send]->arg)) == 0)
{
if (IS_RIPNG_DEBUG_SEND)
ripng_debug_packet &= ~RIPNG_DEBUG_RECV;
@ -269,7 +250,6 @@ ripng_debug_init ()
install_element (ENABLE_NODE, &debug_ripng_events_cmd);
install_element (ENABLE_NODE, &debug_ripng_packet_cmd);
install_element (ENABLE_NODE, &debug_ripng_packet_direct_cmd);
install_element (ENABLE_NODE, &debug_ripng_packet_detail_cmd);
install_element (ENABLE_NODE, &debug_ripng_zebra_cmd);
install_element (ENABLE_NODE, &no_debug_ripng_events_cmd);
install_element (ENABLE_NODE, &no_debug_ripng_packet_cmd);
@ -279,7 +259,6 @@ ripng_debug_init ()
install_element (CONFIG_NODE, &debug_ripng_events_cmd);
install_element (CONFIG_NODE, &debug_ripng_packet_cmd);
install_element (CONFIG_NODE, &debug_ripng_packet_direct_cmd);
install_element (CONFIG_NODE, &debug_ripng_packet_detail_cmd);
install_element (CONFIG_NODE, &debug_ripng_zebra_cmd);
install_element (CONFIG_NODE, &no_debug_ripng_events_cmd);
install_element (CONFIG_NODE, &no_debug_ripng_packet_cmd);

View File

@ -953,20 +953,21 @@ DEFUN (ripng_network,
"RIPng enable on specified interface or network.\n"
"Interface or address")
{
int idx_if_or_addr = 1;
int ret;
struct prefix p;
ret = str2prefix (argv[0], &p);
ret = str2prefix (argv[idx_if_or_addr]->arg, &p);
/* Given string is IPv6 network or interface name. */
if (ret)
ret = ripng_enable_network_add (&p);
else
ret = ripng_enable_if_add (argv[0]);
ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg);
if (ret < 0)
{
vty_out (vty, "There is same network configuration %s%s", argv[0],
vty_out (vty, "There is same network configuration %s%s", argv[idx_if_or_addr]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -982,20 +983,21 @@ DEFUN (no_ripng_network,
"RIPng enable on specified interface or network.\n"
"Interface or address")
{
int idx_if_or_addr = 2;
int ret;
struct prefix p;
ret = str2prefix (argv[0], &p);
ret = str2prefix (argv[idx_if_or_addr]->arg, &p);
/* Given string is interface name. */
if (ret)
ret = ripng_enable_network_delete (&p);
else
ret = ripng_enable_if_delete (argv[0]);
ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg);
if (ret < 0)
{
vty_out (vty, "can't find network %s%s", argv[0],
vty_out (vty, "can't find network %s%s", argv[idx_if_or_addr]->arg,
VTY_NEWLINE);
return CMD_WARNING;
}
@ -1040,11 +1042,12 @@ DEFUN (ipv6_ripng_split_horizon_poisoned_reverse,
DEFUN (no_ipv6_ripng_split_horizon,
no_ipv6_ripng_split_horizon_cmd,
"no ipv6 ripng split-horizon",
"no ipv6 ripng split-horizon [poisoned-reverse]",
NO_STR
IPV6_STR
"Routing Information Protocol\n"
"Perform split horizon\n")
"Perform split horizon\n"
"With poisoned-reverse\n")
{
struct interface *ifp;
struct ripng_interface *ri;
@ -1056,22 +1059,14 @@ DEFUN (no_ipv6_ripng_split_horizon,
return CMD_SUCCESS;
}
ALIAS (no_ipv6_ripng_split_horizon,
no_ipv6_ripng_split_horizon_poisoned_reverse_cmd,
"no ipv6 ripng split-horizon poisoned-reverse",
NO_STR
IPV6_STR
"Routing Information Protocol\n"
"Perform split horizon\n"
"With poisoned-reverse\n")
DEFUN (ripng_passive_interface,
ripng_passive_interface_cmd,
"passive-interface IFNAME",
"Suppress routing updates on an interface\n"
"Interface name\n")
{
return ripng_passive_interface_set (vty, argv[0]);
int idx_ifname = 1;
return ripng_passive_interface_set (vty, argv[idx_ifname]->arg);
}
DEFUN (no_ripng_passive_interface,
@ -1081,7 +1076,8 @@ DEFUN (no_ripng_passive_interface,
"Suppress routing updates on an interface\n"
"Interface name\n")
{
return ripng_passive_interface_unset (vty, argv[0]);
int idx_ifname = 2;
return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg);
}
static struct ripng_interface *
@ -1210,5 +1206,4 @@ ripng_if_init ()
install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd);
install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd);
install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd);
install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd);
}

View File

@ -290,19 +290,22 @@ ripng_offset_list_apply_out (struct prefix_ipv6 *p, struct interface *ifp,
DEFUN (ripng_offset_list,
ripng_offset_list_cmd,
"offset-list WORD (in|out) <0-16>",
"offset-list WORD <in|out> (0-16)",
"Modify RIPng metric\n"
"Access-list name\n"
"For incoming updates\n"
"For outgoing updates\n"
"Metric value\n")
{
return ripng_offset_list_set (vty, argv[0], argv[1], argv[2], NULL);
int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
}
DEFUN (ripng_offset_list_ifname,
ripng_offset_list_ifname_cmd,
"offset-list WORD (in|out) <0-16> IFNAME",
"offset-list WORD <in|out> (0-16) IFNAME",
"Modify RIPng metric\n"
"Access-list name\n"
"For incoming updates\n"
@ -310,12 +313,16 @@ DEFUN (ripng_offset_list_ifname,
"Metric value\n"
"Interface to match\n")
{
return ripng_offset_list_set (vty, argv[0], argv[1], argv[2], argv[3]);
int idx_word = 1;
int idx_in_out = 2;
int idx_number = 3;
int idx_ifname = 4;
return ripng_offset_list_set (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
}
DEFUN (no_ripng_offset_list,
no_ripng_offset_list_cmd,
"no offset-list WORD (in|out) <0-16>",
"no offset-list WORD <in|out> (0-16)",
NO_STR
"Modify RIPng metric\n"
"Access-list name\n"
@ -323,12 +330,15 @@ DEFUN (no_ripng_offset_list,
"For outgoing updates\n"
"Metric value\n")
{
return ripng_offset_list_unset (vty, argv[0], argv[1], argv[2], NULL);
int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, NULL);
}
DEFUN (no_ripng_offset_list_ifname,
no_ripng_offset_list_ifname_cmd,
"no offset-list WORD (in|out) <0-16> IFNAME",
"no offset-list WORD <in|out> (0-16) IFNAME",
NO_STR
"Modify RIPng metric\n"
"Access-list name\n"
@ -337,7 +347,11 @@ DEFUN (no_ripng_offset_list_ifname,
"Metric value\n"
"Interface to match\n")
{
return ripng_offset_list_unset (vty, argv[0], argv[1], argv[2], argv[3]);
int idx_word = 2;
int idx_in_out = 3;
int idx_number = 4;
int idx_ifname = 5;
return ripng_offset_list_unset (vty, argv[idx_word]->arg, argv[idx_in_out]->arg, argv[idx_number]->arg, argv[idx_ifname]->arg);
}
static int

View File

@ -24,6 +24,7 @@
#include "if.h"
#include "memory.h"
#include "prefix.h"
#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "sockunion.h"
@ -42,95 +43,6 @@ struct rip_metric_modifier
u_char metric;
};
static int
ripng_route_match_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_add_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
ripng_route_match_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_delete_match (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
ripng_route_set_add (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_add_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
static int
ripng_route_set_delete (struct vty *vty, struct route_map_index *index,
const char *command, const char *arg)
{
int ret;
ret = route_map_delete_set (index, command, arg);
if (ret)
{
switch (ret)
{
case RMAP_RULE_MISSING:
vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
return CMD_WARNING;
case RMAP_COMPILE_ERROR:
vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
return CMD_WARNING;
}
}
return CMD_SUCCESS;
}
/* `match metric METRIC' */
/* Match function return 1 if match is success else return zero. */
static route_map_result_t
@ -462,216 +374,6 @@ static struct route_map_rule_cmd route_set_tag_cmd =
#define MATCH_STR "Match values from routing table\n"
#define SET_STR "Set values in destination routing protocol\n"
DEFUN (match_metric,
match_metric_cmd,
"match metric <0-4294967295>",
MATCH_STR
"Match metric of route\n"
"Metric value\n")
{
return ripng_route_match_add (vty, vty->index, "metric", argv[0]);
}
DEFUN (no_match_metric,
no_match_metric_cmd,
"no match metric",
NO_STR
MATCH_STR
"Match metric of route\n")
{
if (argc == 0)
return ripng_route_match_delete (vty, vty->index, "metric", NULL);
return ripng_route_match_delete (vty, vty->index, "metric", argv[0]);
}
ALIAS (no_match_metric,
no_match_metric_val_cmd,
"no match metric <0-4294967295>",
NO_STR
MATCH_STR
"Match metric of route\n"
"Metric value\n")
DEFUN (match_interface,
match_interface_cmd,
"match interface WORD",
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
{
return ripng_route_match_add (vty, vty->index, "interface", argv[0]);
}
DEFUN (no_match_interface,
no_match_interface_cmd,
"no match interface",
NO_STR
MATCH_STR
"Match first hop interface of route\n")
{
if (argc == 0)
return ripng_route_match_delete (vty, vty->index, "interface", NULL);
return ripng_route_match_delete (vty, vty->index, "interface", argv[0]);
}
ALIAS (no_match_interface,
no_match_interface_val_cmd,
"no match interface WORD",
NO_STR
MATCH_STR
"Match first hop interface of route\n"
"Interface name\n")
DEFUN (match_tag,
match_tag_cmd,
"match tag <1-4294967295>",
MATCH_STR
"Match tag of route\n"
"Metric value\n")
{
return ripng_route_match_add (vty, vty->index, "tag", argv[0]);
}
DEFUN (no_match_tag,
no_match_tag_cmd,
"no match tag",
NO_STR
MATCH_STR
"Match tag of route\n")
{
if (argc == 0)
return ripng_route_match_delete (vty, vty->index, "tag", NULL);
return ripng_route_match_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_match_tag,
no_match_tag_val_cmd,
"no match tag <1-4294967295>",
NO_STR
MATCH_STR
"Match tag of route\n"
"Metric value\n")
/* set functions */
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
"Set value\n"
"Metric value for destination routing protocol\n"
"Metric value\n")
{
return ripng_route_set_add (vty, vty->index, "metric", argv[0]);
}
DEFUN (no_set_metric,
no_set_metric_cmd,
"no set metric",
NO_STR
SET_STR
"Metric value for destination routing protocol\n")
{
if (argc == 0)
return ripng_route_set_delete (vty, vty->index, "metric", NULL);
return ripng_route_set_delete (vty, vty->index, "metric", argv[0]);
}
ALIAS (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n")
DEFUN (set_ipv6_nexthop_local,
set_ipv6_nexthop_local_cmd,
"set ipv6 next-hop local X:X::X:X",
SET_STR
IPV6_STR
"IPv6 next-hop address\n"
"IPv6 local address\n"
"IPv6 address of next hop\n")
{
union sockunion su;
int ret;
ret = str2sockunion (argv[0], &su);
if (ret < 0)
{
vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE);
return CMD_WARNING;
}
if (!IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr))
{
vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE);
return CMD_WARNING;
}
return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]);
}
DEFUN (no_set_ipv6_nexthop_local,
no_set_ipv6_nexthop_local_cmd,
"no set ipv6 next-hop local",
NO_STR
SET_STR
IPV6_STR
"IPv6 next-hop address\n"
"IPv6 local address\n")
{
if (argc == 0)
return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL);
return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]);
}
ALIAS (no_set_ipv6_nexthop_local,
no_set_ipv6_nexthop_local_val_cmd,
"no set ipv6 next-hop local X:X::X:X",
NO_STR
SET_STR
IPV6_STR
"IPv6 next-hop address\n"
"IPv6 local address\n"
"IPv6 address of next hop\n")
DEFUN (set_tag,
set_tag_cmd,
"set tag <1-4294967295>",
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
{
return ripng_route_set_add (vty, vty->index, "tag", argv[0]);
}
DEFUN (no_set_tag,
no_set_tag_cmd,
"no set tag",
NO_STR
SET_STR
"Tag value for routing protocol\n")
{
if (argc == 0)
return ripng_route_set_delete (vty, vty->index, "tag", NULL);
return ripng_route_set_delete (vty, vty->index, "tag", argv[0]);
}
ALIAS (no_set_tag,
no_set_tag_val_cmd,
"no set tag <1-4294967295>",
NO_STR
SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
void
ripng_route_map_reset ()
{
@ -684,31 +386,28 @@ ripng_route_map_init ()
{
route_map_init ();
route_map_match_interface_hook (generic_match_add);
route_map_no_match_interface_hook (generic_match_delete);
route_map_match_metric_hook (generic_match_add);
route_map_no_match_metric_hook (generic_match_delete);
route_map_match_tag_hook (generic_match_add);
route_map_no_match_tag_hook (generic_match_delete);
route_map_set_ipv6_nexthop_local_hook (generic_set_add);
route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete);
route_map_set_metric_hook (generic_set_add);
route_map_no_set_metric_hook (generic_set_delete);
route_map_set_tag_hook (generic_set_add);
route_map_no_set_tag_hook (generic_set_delete);
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_tag_cmd);
route_map_install_set (&route_set_metric_cmd);
route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
route_map_install_set (&route_set_tag_cmd);
install_element (RMAP_NODE, &match_metric_cmd);
install_element (RMAP_NODE, &no_match_metric_cmd);
install_element (RMAP_NODE, &no_match_metric_val_cmd);
install_element (RMAP_NODE, &match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_cmd);
install_element (RMAP_NODE, &no_match_interface_val_cmd);
install_element (RMAP_NODE, &match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_cmd);
install_element (RMAP_NODE, &no_match_tag_val_cmd);
install_element (RMAP_NODE, &set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd);
install_element (RMAP_NODE, &set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_cmd);
install_element (RMAP_NODE, &no_set_tag_val_cmd);
}

View File

@ -292,30 +292,6 @@ ripng_redistribute_clean ()
}
}
DEFUN (router_zebra,
router_zebra_cmd,
"router zebra",
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
vty->node = ZEBRA_NODE;
zclient->enable = 1;
zclient_start (zclient);
return CMD_SUCCESS;
}
DEFUN (no_router_zebra,
no_router_zebra_cmd,
"no router zebra",
NO_STR
"Disable a routing process\n"
"Stop connection to zebra daemon\n")
{
zclient->enable = 0;
zclient_stop (zclient);
return CMD_SUCCESS;
}
DEFUN (ripng_redistribute_ripng,
ripng_redistribute_ripng_cmd,
"redistribute ripng",
@ -339,17 +315,17 @@ DEFUN (no_ripng_redistribute_ripng,
DEFUN (ripng_redistribute_type,
ripng_redistribute_type_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPNGD,
"redistribute <kernel|connected|static|ospf6|isis|bgp|table>",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD)
{
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[2]->arg);
if (type < 0)
{
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE);
return CMD_WARNING;
}
@ -359,18 +335,21 @@ DEFUN (ripng_redistribute_type,
DEFUN (no_ripng_redistribute_type,
no_ripng_redistribute_type_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPNGD,
"no redistribute <kernel|connected|static|ospf6|isis|bgp|table> [metric (0-16)] [route-map WORD]",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD)
QUAGGA_REDIST_HELP_STR_RIPNGD
"Metric\n"
"Metric value\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[2]->text);
if (type < 0)
{
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
vty_out(vty, "Invalid type %s%s", argv[2]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@ -382,21 +361,23 @@ DEFUN (no_ripng_redistribute_type,
DEFUN (ripng_redistribute_type_metric,
ripng_redistribute_type_metric_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>",
"redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric (0-16)",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Metric\n"
"Metric value\n")
{
int idx_protocol = 1;
int idx_number = 3;
int type;
int metric;
metric = atoi (argv[1]);
type = proto_redistnum(AFI_IP6, argv[0]);
metric = atoi (argv[idx_number]->arg);
type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
@ -406,51 +387,37 @@ DEFUN (ripng_redistribute_type_metric,
return CMD_SUCCESS;
}
ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_metric_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Metric\n"
"Metric value\n")
DEFUN (ripng_redistribute_type_routemap,
ripng_redistribute_type_routemap_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD",
"redistribute <kernel|connected|static|ospf6|isis|bgp|table> route-map WORD",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 1;
int idx_word = 3;
int type;
type = proto_redistnum(AFI_IP6, argv[0]);
type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
ripng_redistribute_routemap_set (type, argv[1]);
ripng_redistribute_routemap_set (type, argv[idx_word]->text);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0,
VRF_DEFAULT);
return CMD_SUCCESS;
}
ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_routemap_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Route map reference\n"
"Pointer to route-map entries\n")
DEFUN (ripng_redistribute_type_metric_routemap,
ripng_redistribute_type_metric_routemap_cmd,
"redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD",
"redistribute <kernel|connected|static|ospf6|isis|bgp|table> metric (0-16) route-map WORD",
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Metric\n"
@ -458,32 +425,27 @@ DEFUN (ripng_redistribute_type_metric_routemap,
"Route map reference\n"
"Pointer to route-map entries\n")
{
int idx_protocol = 1;
int idx_number = 3;
int idx_word = 5;
int type;
int metric;
type = proto_redistnum(AFI_IP6, argv[0]);
metric = atoi (argv[1]);
type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
metric = atoi (argv[idx_number]->arg);
if (type < 0)
{
vty_out(vty, "Invalid type %s%s", argv[0], VTY_NEWLINE);
vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE);
return CMD_WARNING;
}
ripng_redistribute_metric_set (type, metric);
ripng_redistribute_routemap_set (type, argv[2]);
ripng_redistribute_routemap_set (type, argv[idx_word]->text);
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
return CMD_SUCCESS;
}
ALIAS (no_ripng_redistribute_type,
no_ripng_redistribute_type_metric_routemap_cmd,
"no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD",
NO_STR
"Redistribute\n"
QUAGGA_REDIST_HELP_STR_RIPNGD
"Route map reference\n"
"Pointer to route-map entries\n")
void
ripng_redistribute_write (struct vty *vty, int config_mode)
@ -576,8 +538,6 @@ zebra_init (struct thread_master *master)
install_node (&zebra_node, zebra_config_write);
/* Install command element for zebra node. */
install_element (CONFIG_NODE, &router_zebra_cmd);
install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd);
install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd);
@ -588,7 +548,4 @@ zebra_init (struct thread_master *master)
install_element (RIPNG_NODE, &ripng_redistribute_type_metric_cmd);
install_element (RIPNG_NODE, &ripng_redistribute_type_metric_routemap_cmd);
install_element (RIPNG_NODE, &no_ripng_redistribute_type_cmd);
install_element (RIPNG_NODE, &no_ripng_redistribute_type_routemap_cmd);
install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_cmd);
install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_routemap_cmd);
}

Some files were not shown because too many files have changed in this diff Show More