summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-01-26 10:38:07 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-01-26 10:38:07 -0500
commit7f12cb2b659196bd818b3d5ddd1929d83dc85069 (patch)
treef07849247b6b51088eacc182d91f8fe346a3bf69 /lib/command.c
parentc493f2d83a990b5fec0ea927915c46c47d7ed636 (diff)
parent1e78204400361625235b3e7ea5d2c570b16d7c55 (diff)
Merge remote-tracking branch 'origin/master' into bgpafisafi
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/command.c b/lib/command.c
index b5dae5f28e..9485beddd9 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -43,7 +43,10 @@
DEFINE_MTYPE( LIB, HOST, "Host config")
DEFINE_MTYPE( LIB, STRVEC, "String vector")
-DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
+DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")
+DEFINE_MTYPE_STATIC(LIB, CMD_DESC, "Command Token Text")
+DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help")
+DEFINE_MTYPE( LIB, CMD_ARG, "Command Argument")
/* Command vector which includes some level of command lists. Normally
each daemon maintains each own cmdvec. */
@@ -523,7 +526,7 @@ compare_completions (const void *fst, const void *snd)
* @param completions linked list of cmd_token
* @return deduplicated and sorted vector with
*/
-static vector
+vector
completions_to_vec (struct list *completions)
{
vector comps = vector_init (VECTOR_MIN_SIZE);
@@ -745,6 +748,7 @@ node_parent ( enum node_type node )
case BGP_VPNV6_NODE:
case BGP_ENCAP_NODE:
case BGP_ENCAPV6_NODE:
+ case BGP_VRF_POLICY_NODE:
case BGP_VNC_DEFAULTS_NODE:
case BGP_VNC_NVE_GROUP_NODE:
case BGP_VNC_L2_GROUP_NODE:
@@ -1110,6 +1114,7 @@ cmd_exit (struct vty *vty)
case BGP_VPNV6_NODE:
case BGP_ENCAP_NODE:
case BGP_ENCAPV6_NODE:
+ case BGP_VRF_POLICY_NODE:
case BGP_VNC_DEFAULTS_NODE:
case BGP_VNC_NVE_GROUP_NODE:
case BGP_VNC_L2_GROUP_NODE:
@@ -1173,6 +1178,7 @@ DEFUN (config_end,
case BGP_NODE:
case BGP_ENCAP_NODE:
case BGP_ENCAPV6_NODE:
+ case BGP_VRF_POLICY_NODE:
case BGP_VNC_DEFAULTS_NODE:
case BGP_VNC_NVE_GROUP_NODE:
case BGP_VNC_L2_GROUP_NODE:
@@ -1272,7 +1278,7 @@ permute (struct graph_node *start, struct vty *vty)
for (ALL_LIST_ELEMENTS_RO (position,ln,gnn))
{
struct cmd_token *tt = gnn->data;
- if (tt->type < SELECTOR_TKN)
+ if (tt->type < SPECIAL_TKN)
vty_out (vty, " %s", tt->text);
}
if (gn == start)
@@ -2402,16 +2408,21 @@ cmd_init (int terminal)
vrf_install_commands ();
}
srandom(time(NULL));
+
+#ifdef DEV_BUILD
+ grammar_sandbox_init();
+#endif
}
struct cmd_token *
-new_cmd_token (enum cmd_token_type type, u_char attr, char *text, char *desc)
+new_cmd_token (enum cmd_token_type type, u_char attr,
+ const char *text, const char *desc)
{
struct cmd_token *token = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token));
token->type = type;
token->attr = attr;
- token->text = text;
- token->desc = desc;
+ token->text = text ? XSTRDUP (MTYPE_CMD_TEXT, text) : NULL;
+ token->desc = desc ? XSTRDUP (MTYPE_CMD_DESC, desc) : NULL;
token->arg = NULL;
token->allowrepeat = false;
@@ -2424,11 +2435,11 @@ del_cmd_token (struct cmd_token *token)
if (!token) return;
if (token->text)
- XFREE (MTYPE_CMD_TOKENS, token->text);
+ XFREE (MTYPE_CMD_TEXT, token->text);
if (token->desc)
- XFREE (MTYPE_CMD_TOKENS, token->desc);
+ XFREE (MTYPE_CMD_DESC, token->desc);
if (token->arg)
- XFREE (MTYPE_CMD_TOKENS, token->arg);
+ XFREE (MTYPE_CMD_ARG, token->arg);
XFREE (MTYPE_CMD_TOKENS, token);
}
@@ -2439,9 +2450,9 @@ copy_cmd_token (struct cmd_token *token)
struct cmd_token *copy = new_cmd_token (token->type, token->attr, NULL, NULL);
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;
+ copy->text = token->text ? XSTRDUP (MTYPE_CMD_TEXT, token->text) : NULL;
+ copy->desc = token->desc ? XSTRDUP (MTYPE_CMD_DESC, token->desc) : NULL;
+ copy->arg = token->arg ? XSTRDUP (MTYPE_CMD_ARG, token->arg) : NULL;
return copy;
}