mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 11:24:42 +00:00
lib: distribute.c, smux.c, vty.c grammar refactor
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
8b3f067710
commit
aa1c90a487
341
lib/distribute.c
341
lib/distribute.c
@ -303,123 +303,39 @@ 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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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 (distribute_list_all,
|
||||
ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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_distribute_list_all,
|
||||
no_ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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_IN : DISTRIBUTE_OUT;
|
||||
|
||||
/* Set appropriate function call */
|
||||
int (*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 (distribute_list,
|
||||
ipv6_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 distribute-list [prefix] WORD <in|out> [WORD]",
|
||||
NO_STR
|
||||
"Filter networks in routing updates\n"
|
||||
"Access-list name\n"
|
||||
@ -427,21 +343,24 @@ DEFUN (no_distribute_list, no_distribute_list_cmd,
|
||||
"Filter outgoing routing updates\n"
|
||||
"Interface name\n")
|
||||
{
|
||||
int ret;
|
||||
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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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_IN : DISTRIBUTE_OUT;
|
||||
|
||||
/* 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. */
|
||||
int ret = distfn (ifname, type, argv[2 + prefix]->arg);
|
||||
|
||||
ret = distribute_list_unset (argv[2], type, argv[0]);
|
||||
if (! ret)
|
||||
{
|
||||
vty_out (vty, "distribute list doesn't exist%s", VTY_NEWLINE);
|
||||
@ -450,179 +369,6 @@ DEFUN (no_distribute_list, no_distribute_list_cmd,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
ALIAS (no_distribute_list, no_ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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 (distribute_list_prefix_all,
|
||||
ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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_distribute_list_prefix_all,
|
||||
no_ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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 (distribute_list_prefix, ipv6_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_IN;
|
||||
else if (strncmp (argv[1], "o", 1) == 0)
|
||||
type = DISTRIBUTE_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_distribute_list_prefix, no_ipv6_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
|
||||
config_show_distribute (struct vty *vty)
|
||||
{
|
||||
@ -770,25 +516,6 @@ distribute_list_init (int node)
|
||||
disthash = hash_create (distribute_hash_make,
|
||||
(int (*) (const void *, const void *)) distribute_cmp);
|
||||
|
||||
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);
|
||||
} else if (node == RIPNG_NODE) {
|
||||
/* WARNING: two identical commands installed do a crash, so be worry with
|
||||
* aliases */
|
||||
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_element (node, &distribute_list_cmd);
|
||||
install_element (node, &no_distribute_list_cmd);
|
||||
}
|
||||
|
29
lib/smux.c
29
lib/smux.c
@ -1370,7 +1370,7 @@ DEFUN (smux_peer,
|
||||
"SNMP MUX peer settings\n"
|
||||
"Object ID used in SMUX peering\n")
|
||||
{
|
||||
if (smux_peer_oid (vty, argv[0], NULL) == 0)
|
||||
if (smux_peer_oid (vty, argv[2]->arg, NULL) == 0)
|
||||
{
|
||||
smux_start();
|
||||
return CMD_SUCCESS;
|
||||
@ -1387,7 +1387,7 @@ DEFUN (smux_peer_password,
|
||||
"SMUX peering object ID\n"
|
||||
"SMUX peering password\n")
|
||||
{
|
||||
if (smux_peer_oid (vty, argv[0], argv[1]) == 0)
|
||||
if (smux_peer_oid (vty, argv[2]->arg, argv[3]->rg) == 0)
|
||||
{
|
||||
smux_start();
|
||||
return CMD_SUCCESS;
|
||||
@ -1398,31 +1398,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)
|
||||
|
13
lib/vty.c
13
lib/vty.c
@ -983,6 +983,8 @@ vty_describe_fold (struct vty *vty, int cmd_width,
|
||||
const char *cmd, *p;
|
||||
int pos;
|
||||
|
||||
cmd = token->text;
|
||||
|
||||
if (desc_width <= 0)
|
||||
{
|
||||
vty_out (vty, " %-*s %s%s", cmd_width, cmd, token->desc, VTY_NEWLINE);
|
||||
@ -2742,7 +2744,7 @@ 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")
|
||||
{
|
||||
@ -2751,7 +2753,7 @@ DEFUN (exec_timeout_min,
|
||||
|
||||
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")
|
||||
@ -2791,7 +2793,8 @@ 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[2]->arg)))
|
||||
const char *accesslist = (argc == 3) ? argv[2]->arg : NULL;
|
||||
if (! vty_accesslist_name || (argc && strcmp(vty_accesslist_name, accesslist)))
|
||||
{
|
||||
vty_out (vty, "Access-class is not currently applied to vty%s",
|
||||
VTY_NEWLINE);
|
||||
@ -2831,8 +2834,10 @@ DEFUN (no_vty_ipv6_access_class,
|
||||
"Filter connections based on an IP access list\n"
|
||||
"IPv6 access list\n")
|
||||
{
|
||||
const char *accesslist = (argc == 4) ? argv[3]->arg : NULL;
|
||||
|
||||
if (! vty_ipv6_accesslist_name ||
|
||||
(argc && strcmp(vty_ipv6_accesslist_name, argv[3]->arg)))
|
||||
(argc && strcmp(vty_ipv6_accesslist_name, accesslist)))
|
||||
{
|
||||
vty_out (vty, "IPv6 access-class is not currently applied to vty%s",
|
||||
VTY_NEWLINE);
|
||||
|
Loading…
Reference in New Issue
Block a user