summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-07-14 14:24:46 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-07-14 14:24:46 +0200
commit1ea6b3f237295a7e7dae3a46a4d07b41a6453c04 (patch)
treea8803b2d31a56e6d5296c1d1880205525a015c45 /lib
parentMerge remote-tracking branch 'origin/master' into evpn_plus_struct_attr (diff)
parentMerge pull request #813 from opensourcerouting/newline-redux (diff)
downloadfrr-1ea6b3f237295a7e7dae3a46a4d07b41a6453c04.tar.xz
frr-1ea6b3f237295a7e7dae3a46a4d07b41a6453c04.zip
Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr
Diffstat (limited to 'lib')
-rw-r--r--lib/agentx.c6
-rw-r--r--lib/bfd.c10
-rw-r--r--lib/buffer.c44
-rw-r--r--lib/buffer.h2
-rw-r--r--lib/command.c147
-rw-r--r--lib/command.h2
-rw-r--r--lib/distribute.c22
-rw-r--r--lib/filter.c52
-rw-r--r--lib/grammar_sandbox.c52
-rw-r--r--lib/hash.c16
-rw-r--r--lib/if.c20
-rw-r--r--lib/if_rmap.c10
-rw-r--r--lib/keychain.c26
-rw-r--r--lib/memory_vty.c39
-rw-r--r--lib/ns.c16
-rw-r--r--lib/plist.c70
-rwxr-xr-xlib/route_types.pl12
-rw-r--r--lib/routemap.c82
-rw-r--r--lib/skiplist.c4
-rw-r--r--lib/smux.c4
-rw-r--r--lib/spf_backoff.c26
-rw-r--r--lib/thread.c34
-rw-r--r--lib/vrf.c11
-rw-r--r--lib/vrf.h4
-rw-r--r--lib/vty.c165
-rw-r--r--lib/vty.h49
-rw-r--r--lib/workqueue.c10
27 files changed, 487 insertions, 448 deletions
diff --git a/lib/agentx.c b/lib/agentx.c
index 53e5f2bc5..30c03e6cf 100644
--- a/lib/agentx.c
+++ b/lib/agentx.c
@@ -168,7 +168,7 @@ static int
config_write_agentx (struct vty *vty)
{
if (agentx_enabled)
- vty_outln (vty, "agentx");
+ vty_out (vty, "agentx\n");
return 1;
}
@@ -185,7 +185,7 @@ DEFUN (agentx_enable,
agentx_enabled = 1;
return CMD_SUCCESS;
}
- vty_outln (vty, "SNMP AgentX already enabled");
+ vty_out (vty, "SNMP AgentX already enabled\n");
return CMD_SUCCESS;
}
@@ -196,7 +196,7 @@ DEFUN (no_agentx,
"SNMP AgentX protocol settings\n")
{
if (!agentx_enabled) return CMD_SUCCESS;
- vty_outln (vty, "SNMP AgentX support cannot be disabled once enabled");
+ vty_out (vty, "SNMP AgentX support cannot be disabled once enabled\n");
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/lib/bfd.c b/lib/bfd.c
index e6f881c99..4fbb93ebd 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -394,8 +394,8 @@ bfd_show_param(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag,
}
else
{
- vty_outln (vty, " %s%sDetect Mul: %d, Min Rx interval: %d,"
- " Min Tx interval: %d",
+ vty_out (vty, " %s%sDetect Mul: %d, Min Rx interval: %d,"
+ " Min Tx interval: %d\n",
(extra_space) ? " ": "", (bfd_tag) ? "BFD: " : " ",
bfd_info->detect_mult, bfd_info->required_min_rx,
bfd_info->desired_min_tx);
@@ -423,7 +423,7 @@ bfd_show_status(struct vty *vty, struct bfd_info *bfd_info, int bfd_tag,
}
else
{
- vty_outln (vty, " %s%sStatus: %s, Last update: %s",
+ vty_out (vty, " %s%sStatus: %s, Last update: %s\n",
(extra_space) ? " ": "", (bfd_tag) ? "BFD: " : " ",
bfd_get_status_str(bfd_info->status), time_buf);
}
@@ -451,7 +451,7 @@ bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop,
}
else
{
- vty_outln (vty, " %sBFD: Type: %s", (extra_space) ? " " : "",
+ vty_out (vty, " %sBFD: Type: %s\n", (extra_space) ? " " : "",
(multihop) ? "multi hop" : "single hop");
}
@@ -461,7 +461,7 @@ bfd_show_info(struct vty *vty, struct bfd_info *bfd_info, int multihop,
if (use_json)
json_object_object_add(json_obj, "peerBfdInfo", json_bfd);
else
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
/*
diff --git a/lib/buffer.c b/lib/buffer.c
index 649677fc9..5d458901e 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -199,6 +199,50 @@ buffer_putstr (struct buffer *b, const char *c)
buffer_put(b, c, strlen(c));
}
+/* Expand \n to \r\n */
+void
+buffer_put_crlf(struct buffer *b, const void *origp, size_t origsize)
+{
+ struct buffer_data *data = b->tail;
+ const char *p = origp, *end = p + origsize, *lf;
+ size_t size;
+
+ lf = memchr(p, '\n', end - p);
+
+ /* We use even last one byte of data buffer. */
+ while (p < end)
+ {
+ size_t avail, chunk;
+
+ /* If there is no data buffer add it. */
+ if (data == NULL || data->cp == b->size)
+ data = buffer_add (b);
+
+ size = (lf ? lf : end) - p;
+ avail = b->size - data->cp;
+
+ chunk = (size <= avail) ? size : avail;
+ memcpy (data->data + data->cp, p, chunk);
+
+ p += chunk;
+ data->cp += chunk;
+
+ if (lf && size <= avail)
+ {
+ /* we just copied up to (including) a '\n' */
+ if (data->cp == b->size)
+ data = buffer_add (b);
+ data->data[data->cp++] = '\r';
+ if (data->cp == b->size)
+ data = buffer_add (b);
+ data->data[data->cp++] = '\n';
+
+ p++;
+ lf = memchr(p, '\n', end - p);
+ }
+ }
+}
+
/* Keep flushing data to the fd until the buffer is empty or an error is
encountered or the operation would block. */
buffer_status_t
diff --git a/lib/buffer.h b/lib/buffer.h
index 67ac71cad..059f2cf33 100644
--- a/lib/buffer.h
+++ b/lib/buffer.h
@@ -41,6 +41,8 @@ extern void buffer_put (struct buffer *, const void *, size_t);
extern void buffer_putc (struct buffer *, u_char);
/* Add a NUL-terminated string to the end of the buffer. */
extern void buffer_putstr (struct buffer *, const char *);
+/* Add given data, inline-expanding \n to \r\n */
+extern void buffer_put_crlf(struct buffer *b, const void *p, size_t size);
/* Combine all accumulated (and unflushed) data inside the buffer into a
single NUL-terminated string allocated using XMALLOC(MTYPE_TMP). Note
diff --git a/lib/command.c b/lib/command.c
index e15275423..a631cf1c6 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -433,27 +433,27 @@ static int
config_write_host (struct vty *vty)
{
if (host.name)
- vty_outln (vty, "hostname %s", host.name);
+ vty_out (vty, "hostname %s\n", host.name);
if (host.encrypt)
{
if (host.password_encrypt)
- vty_outln (vty, "password 8 %s", host.password_encrypt);
+ vty_out (vty, "password 8 %s\n", host.password_encrypt);
if (host.enable_encrypt)
- vty_outln (vty, "enable password 8 %s", host.enable_encrypt);
+ vty_out (vty, "enable password 8 %s\n", host.enable_encrypt);
}
else
{
if (host.password)
- vty_outln (vty, "password %s", host.password);
+ vty_out (vty, "password %s\n", host.password);
if (host.enable)
- vty_outln (vty, "enable password %s", host.enable);
+ vty_out (vty, "enable password %s\n", host.enable);
}
if (zlog_default->default_lvl != LOG_DEBUG)
{
- vty_outln (vty,"! N.B. The 'log trap' command is deprecated.");
- vty_outln (vty, "log trap %s",
+ vty_out (vty,"! N.B. The 'log trap' command is deprecated.\n");
+ vty_out (vty, "log trap %s\n",
zlog_priority[zlog_default->default_lvl]);
}
@@ -463,7 +463,7 @@ config_write_host (struct vty *vty)
if (zlog_default->maxlvl[ZLOG_DEST_FILE] != zlog_default->default_lvl)
vty_out (vty, " %s",
zlog_priority[zlog_default->maxlvl[ZLOG_DEST_FILE]]);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != ZLOG_DISABLED)
@@ -472,13 +472,13 @@ config_write_host (struct vty *vty)
if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != zlog_default->default_lvl)
vty_out (vty, " %s",
zlog_priority[zlog_default->maxlvl[ZLOG_DEST_STDOUT]]);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED)
- vty_outln (vty,"no log monitor");
+ vty_out (vty,"no log monitor\n");
else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl)
- vty_outln (vty,"log monitor %s",
+ vty_out (vty,"log monitor %s\n",
zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]]);
if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED)
@@ -487,33 +487,33 @@ config_write_host (struct vty *vty)
if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != zlog_default->default_lvl)
vty_out (vty, " %s",
zlog_priority[zlog_default->maxlvl[ZLOG_DEST_SYSLOG]]);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (zlog_default->facility != LOG_DAEMON)
- vty_outln (vty, "log facility %s",
+ vty_out (vty, "log facility %s\n",
facility_name(zlog_default->facility));
if (zlog_default->record_priority == 1)
- vty_outln (vty, "log record-priority");
+ vty_out (vty, "log record-priority\n");
if (zlog_default->timestamp_precision > 0)
- vty_outln (vty, "log timestamp precision %d",
+ vty_out (vty, "log timestamp precision %d\n",
zlog_default->timestamp_precision);
if (host.advanced)
- vty_outln (vty, "service advanced-vty");
+ vty_out (vty, "service advanced-vty\n");
if (host.encrypt)
- vty_outln (vty, "service password-encryption");
+ vty_out (vty, "service password-encryption\n");
if (host.lines >= 0)
- vty_outln (vty, "service terminal-length %d",host.lines);
+ vty_out (vty, "service terminal-length %d\n",host.lines);
if (host.motdfile)
- vty_outln (vty, "banner motd file %s", host.motdfile);
+ vty_out (vty, "banner motd file %s\n", host.motdfile);
else if (! host.motd)
- vty_outln (vty, "no banner motd");
+ vty_out (vty, "no banner motd\n");
return 1;
}
@@ -718,13 +718,12 @@ cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps)
#define AUTOCOMP_INDENT 5
char *
-cmd_variable_comp2str(vector comps, unsigned short cols, const char nl[])
+cmd_variable_comp2str(vector comps, unsigned short cols)
{
size_t bsz = 16;
char *buf = XCALLOC(MTYPE_TMP, bsz);
int lc = AUTOCOMP_INDENT;
size_t cs = AUTOCOMP_INDENT;
- size_t nllen = strlen(nl);
size_t itemlen;
snprintf(buf, bsz, "%*s", AUTOCOMP_INDENT, "");
for (size_t j = 0; j < vector_active (comps); j++)
@@ -732,12 +731,12 @@ cmd_variable_comp2str(vector comps, unsigned short cols, const char nl[])
char *item = vector_slot (comps, j);
itemlen = strlen(item);
- if (cs + itemlen + nllen + AUTOCOMP_INDENT + 2 >= bsz)
+ if (cs + itemlen + AUTOCOMP_INDENT + 3 >= bsz)
buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2));
if (lc + itemlen + 1 >= cols)
{
- cs += snprintf(&buf[cs], bsz - cs, "%s%*s", nl, AUTOCOMP_INDENT, "");
+ cs += snprintf(&buf[cs], bsz - cs, "\n%*s", AUTOCOMP_INDENT, "");
lc = AUTOCOMP_INDENT;
}
@@ -1187,7 +1186,7 @@ DEFUN (config_terminal,
vty->node = CONFIG_NODE;
else
{
- vty_outln (vty, "VTY configuration is locked by other VTY");
+ vty_out (vty, "VTY configuration is locked by other VTY\n");
return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
@@ -1388,10 +1387,10 @@ DEFUN (show_version,
SHOW_STR
"Displays zebra version\n")
{
- vty_outln (vty, "%s %s (%s).", FRR_FULL_NAME, FRR_VERSION,
+ vty_out (vty, "%s %s (%s).\n", FRR_FULL_NAME, FRR_VERSION,
host.name ? host.name : "");
- vty_outln (vty, "%s%s", FRR_COPYRIGHT, GIT_INFO);
- vty_outln (vty, "configured with:%s %s", VTYNL,
+ vty_out (vty, "%s%s\n", FRR_COPYRIGHT, GIT_INFO);
+ vty_out (vty, "configured with:\n %s\n",
FRR_CONFIG_ARGS);
return CMD_SUCCESS;
@@ -1415,21 +1414,19 @@ DEFUN (config_help,
"help",
"Description of the interactive help system\n")
{
- vty_outln (vty,
- "Quagga VTY provides advanced help feature. When you need help,%s\
-anytime at the command line please press '?'.%s\
-%s\
-If nothing matches, the help list will be empty and you must backup%s\
- until entering a '?' shows the available options.%s\
-Two styles of help are provided:%s\
-1. Full help is available when you are ready to enter a%s\
-command argument (e.g. 'show ?') and describes each possible%s\
-argument.%s\
-2. Partial help is provided when an abbreviated argument is entered%s\
- and you want to know what arguments match the input%s\
- (e.g. 'show me?'.)%s", VTYNL, VTYNL, VTYNL,
- VTYNL, VTYNL, VTYNL, VTYNL, VTYNL,
- VTYNL, VTYNL, VTYNL, VTYNL);
+ vty_out (vty,
+ "Quagga VTY provides advanced help feature. When you need help,\n\
+anytime at the command line please press '?'.\n\
+\n\
+If nothing matches, the help list will be empty and you must backup\n\
+ until entering a '?' shows the available options.\n\
+Two styles of help are provided:\n\
+1. Full help is available when you are ready to enter a\n\
+command argument (e.g. 'show ?') and describes each possible\n\
+argument.\n\
+2. Partial help is provided when an abbreviated argument is entered\n\
+ and you want to know what arguments match the input\n\
+ (e.g. 'show me?'.)\n\n");
return CMD_SUCCESS;
}
@@ -1463,7 +1460,7 @@ permute (struct graph_node *start, struct vty *vty)
}
if (gn == start)
vty_out (vty, "...");
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
else
{
@@ -1497,7 +1494,7 @@ cmd_list_cmds (struct vty *vty, int do_permute)
if ((element = vector_slot (node->cmd_vector, i)) &&
element->attr != CMD_ATTR_DEPRECATED &&
element->attr != CMD_ATTR_HIDDEN)
- vty_outln (vty, " %s", element->string);
+ vty_out (vty, " %s\n", element->string);
}
return CMD_SUCCESS;
}
@@ -1530,25 +1527,25 @@ vty_write_config (struct vty *vty)
if (vty->type == VTY_TERM)
{
- vty_outln (vty, "%sCurrent configuration:",VTYNL);
- vty_outln (vty, "!");
+ vty_out (vty, "\nCurrent configuration:\n");
+ vty_out (vty, "!\n");
}
- vty_outln (vty, "frr version %s", FRR_VER_SHORT);
- vty_outln (vty, "frr defaults %s", DFLT_NAME);
- vty_outln (vty, "!");
+ vty_out (vty, "frr version %s\n", FRR_VER_SHORT);
+ vty_out (vty, "frr defaults %s\n", DFLT_NAME);
+ vty_out (vty, "!\n");
for (i = 0; i < vector_active (cmdvec); i++)
if ((node = vector_slot (cmdvec, i)) && node->func
&& (node->vtysh || vty->type != VTY_SHELL))
{
if ((*node->func) (vty))
- vty_outln (vty, "!");
+ vty_out (vty, "!\n");
}
if (vty->type == VTY_TERM)
{
- vty_outln (vty, "end");
+ vty_out (vty, "end\n");
}
}
@@ -1585,7 +1582,7 @@ DEFUN (config_write,
/* Check and see if we are operating under vtysh configuration */
if (host.config == NULL)
{
- vty_outln (vty,"Can't save to configuration file, using vtysh.");
+ vty_out (vty,"Can't save to configuration file, using vtysh.\n");
return CMD_WARNING;
}
@@ -1620,12 +1617,12 @@ DEFUN (config_write,
fd = mkstemp (config_file_tmp);
if (fd < 0)
{
- vty_outln (vty, "Can't open configuration file %s.",config_file_tmp);
+ vty_out (vty, "Can't open configuration file %s.\n",config_file_tmp);
goto finished;
}
if (fchmod (fd, CONFIGFILE_MASK) != 0)
{
- vty_outln (vty, "Can't chmod configuration file %s: %s (%d).",
+ vty_out (vty, "Can't chmod configuration file %s: %s (%d).\n",
config_file_tmp, safe_strerror(errno), errno);
goto finished;
}
@@ -1647,13 +1644,13 @@ DEFUN (config_write,
if (unlink (config_file_sav) != 0)
if (errno != ENOENT)
{
- vty_outln (vty, "Can't unlink backup configuration file %s.",
+ vty_out (vty, "Can't unlink backup configuration file %s.\n",
config_file_sav);
goto finished;
}
if (link (config_file, config_file_sav) != 0)
{
- vty_outln (vty, "Can't backup old configuration file %s.",
+ vty_out (vty, "Can't backup old configuration file %s.\n",
config_file_sav);
goto finished;
}
@@ -1662,13 +1659,13 @@ DEFUN (config_write,
}
if (rename (config_file_tmp, config_file) != 0)
{
- vty_outln (vty, "Can't save configuration file %s.",config_file);
+ vty_out (vty, "Can't save configuration file %s.\n",config_file);
goto finished;
}
if (dirfd >= 0)
fsync (dirfd);
- vty_outln (vty, "Configuration saved to %s",config_file);
+ vty_out (vty, "Configuration saved to %s\n",config_file);
ret = CMD_SUCCESS;
finished:
@@ -1723,7 +1720,7 @@ DEFUN (show_startup_config,
confp = fopen (host.config, "r");
if (confp == NULL)
{
- vty_outln (vty, "Can't open configuration file [%s] due to '%s'",
+ vty_out (vty, "Can't open configuration file [%s] due to '%s'\n",
host.config, safe_strerror(errno));
return CMD_WARNING;
}
@@ -1736,7 +1733,7 @@ DEFUN (show_startup_config,
cp++;
*cp = '\0';
- vty_outln (vty, "%s", buf);
+ vty_out (vty, "%s\n", buf);
}
fclose (confp);
@@ -1763,7 +1760,7 @@ DEFUN (config_hostname,
if (!isalpha((int) word->arg[0]))
{
- vty_outln (vty, "Please specify string starting with alphabet");
+ vty_out (vty, "Please specify string starting with alphabet\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1803,8 +1800,8 @@ DEFUN (config_password,
if (!isalnum (argv[idx_8]->arg[0]))
{
- vty_outln (vty,
- "Please specify string starting with alphanumeric");
+ vty_out (vty,
+ "Please specify string starting with alphanumeric\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1853,15 +1850,15 @@ DEFUN (config_enable_password,
}
else
{
- vty_outln (vty, "Unknown encryption type.");
+ vty_out (vty, "Unknown encryption type.\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
if (!isalnum (argv[idx_8]->arg[0]))
{
- vty_outln (vty,
- "Please specify string starting with alphanumeric");
+ vty_out (vty,
+ "Please specify string starting with alphanumeric\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2010,7 +2007,7 @@ DEFUN_HIDDEN (do_echo,
{
char *message;
- vty_outln (vty, "%s",
+ vty_out (vty, "%s\n",
((message = argv_concat(argv, argc, 1)) ? message : ""));
if (message)
XFREE(MTYPE_TMP, message);
@@ -2054,7 +2051,7 @@ DEFUN (show_logging,
vty_out (vty, "level %s, facility %s, ident %s",
zlog_priority[zl->maxlvl[ZLOG_DEST_SYSLOG]],
facility_name(zl->facility), zl->ident);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_out (vty, "Stdout logging: ");
if (zl->maxlvl[ZLOG_DEST_STDOUT] == ZLOG_DISABLED)
@@ -2062,7 +2059,7 @@ DEFUN (show_logging,
else
vty_out (vty, "level %s",
zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_out (vty, "Monitor logging: ");
if (zl->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED)
@@ -2070,7 +2067,7 @@ DEFUN (show_logging,
else
vty_out (vty, "level %s",
zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_out (vty, "File logging: ");
if ((zl->maxlvl[ZLOG_DEST_FILE] == ZLOG_DISABLED) ||
@@ -2080,13 +2077,13 @@ DEFUN (show_logging,
vty_out (vty, "level %s, filename %s",
zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]],
zl->filename);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
- vty_outln (vty, "Protocol name: %s",
+ vty_out (vty, "Protocol name: %s\n",
zl->protoname);
- vty_outln (vty, "Record priority: %s",
+ vty_out (vty, "Record priority: %s\n",
(zl->record_priority ? "enabled" : "disabled"));
- vty_outln (vty, "Timestamp precision: %d",
+ vty_out (vty, "Timestamp precision: %d\n",
zl->timestamp_precision);
return CMD_SUCCESS;
diff --git a/lib/command.h b/lib/command.h
index d60c8581a..4c2c5716b 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -407,6 +407,6 @@ struct cmd_variable_handler {
extern void cmd_variable_complete (struct cmd_token *token, const char *arg, vector comps);
extern void cmd_variable_handler_register (const struct cmd_variable_handler *cvh);
-extern char *cmd_variable_comp2str (vector comps, unsigned short cols, const char nl[]);
+extern char *cmd_variable_comp2str (vector comps, unsigned short cols);
#endif /* _ZEBRA_COMMAND_H */
diff --git a/lib/distribute.c b/lib/distribute.c
index 02c888b69..34ccfb4c7 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -349,7 +349,7 @@ DEFUN (no_distribute_list,
if (! ret)
{
- vty_outln (vty, "distribute list doesn't exist");
+ vty_out (vty, "distribute list doesn't exist\n");
return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
@@ -393,9 +393,9 @@ config_show_distribute (struct vty *vty)
DISTRIBUTE_V6_OUT, has_print);
}
if (has_print)
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
else
- vty_outln (vty, " not set");
+ vty_out (vty, " not set\n");
for (i = 0; i < disthash->size; i++)
for (mp = disthash->index[i]; mp; mp = mp->next)
@@ -414,9 +414,9 @@ config_show_distribute (struct vty *vty)
has_print = distribute_print(vty, dist->prefix, 1,
DISTRIBUTE_V6_OUT, has_print);
if (has_print)
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
else
- vty_outln (vty, " nothing");
+ vty_out (vty, " nothing\n");
}
}
@@ -437,9 +437,9 @@ config_show_distribute (struct vty *vty)
DISTRIBUTE_V6_IN, has_print);
}
if (has_print)
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
else
- vty_outln (vty, " not set");
+ vty_out (vty, " not set\n");
for (i = 0; i < disthash->size; i++)
for (mp = disthash->index[i]; mp; mp = mp->next)
@@ -458,9 +458,9 @@ config_show_distribute (struct vty *vty)
has_print = distribute_print(vty, dist->prefix, 1,
DISTRIBUTE_V6_IN, has_print);
if (has_print)
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
else
- vty_outln (vty, " nothing");
+ vty_out (vty, " nothing\n");
}
}
return 0;
@@ -487,7 +487,7 @@ config_write_distribute (struct vty *vty)
if (dist->list[j]) {
output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT;
v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT;
- vty_outln (vty, " %sdistribute-list %s %s %s",
+ vty_out (vty, " %sdistribute-list %s %s %s\n",
v6 ? "ipv6 " : "",
dist->list[j],
output ? "out" : "in",
@@ -499,7 +499,7 @@ config_write_distribute (struct vty *vty)
if (dist->prefix[j]) {
output = j == DISTRIBUTE_V4_OUT || j == DISTRIBUTE_V6_OUT;
v6 = j == DISTRIBUTE_V6_IN || j == DISTRIBUTE_V6_OUT;
- vty_outln (vty, " %sdistribute-list prefix %s %s %s",
+ vty_out (vty, " %sdistribute-list prefix %s %s %s\n",
v6 ? "ipv6 " : "",
dist->prefix[j],
output ? "out" : "in",
diff --git a/lib/filter.c b/lib/filter.c
index d2c80fc2a..c1e922f5b 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -576,7 +576,7 @@ vty_access_list_remark_unset (struct vty *vty, afi_t afi, const char *name)
access = access_list_lookup (afi, name);
if (! access)
{
- vty_outln (vty, "%% access-list %s doesn't exist",name);
+ vty_out (vty, "%% access-list %s doesn't exist\n",name);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -615,21 +615,21 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
type = FILTER_DENY;
else
{
- vty_outln (vty, "%% filter type must be permit or deny");
+ vty_out (vty, "%% filter type must be permit or deny\n");
return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (addr_str, &addr);
if (ret <= 0)
{
- vty_outln (vty,"%%Inconsistent address and mask");
+ vty_out (vty,"%%Inconsistent address and mask\n");
return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (addr_mask_str, &addr_mask);
if (ret <= 0)
{
- vty_outln (vty,"%%Inconsistent address and mask");
+ vty_out (vty,"%%Inconsistent address and mask\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -638,14 +638,14 @@ filter_set_cisco (struct vty *vty, const char *name_str, const char *type_str,
ret = inet_aton (mask_str, &mask);
if (ret <= 0)
{
- vty_outln (vty,"%%Inconsistent address and mask");
+ vty_out (vty,"%%Inconsistent address and mask\n");
return CMD_WARNING_CONFIG_FAILED;
}
ret = inet_aton (mask_mask_str, &mask_mask);
if (ret <= 0)
{
- vty_outln (vty,"%%Inconsistent address and mask");
+ vty_out (vty,"%%Inconsistent address and mask\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1256,8 +1256,8 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
if (strlen(name_str) > ACL_NAMSIZ)
{
- vty_outln (vty, "%% ACL name %s is invalid: length exceeds "
- "%d characters",
+ vty_out (vty, "%% ACL name %s is invalid: length exceeds "
+ "%d characters\n",
name_str, ACL_NAMSIZ);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1269,7 +1269,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
type = FILTER_DENY;
else
{
- vty_outln (vty, "filter type must be [permit|deny]");
+ vty_out (vty, "filter type must be [permit|deny]\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1279,7 +1279,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
ret = str2prefix_ipv4 (prefix_str, (struct prefix_ipv4 *)&p);
if (ret <= 0)
{
- vty_outln (vty,"IP address prefix/prefixlen is malformed");
+ vty_out (vty,"IP address prefix/prefixlen is malformed\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1288,7 +1288,7 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
ret = str2prefix_ipv6 (prefix_str, (struct prefix_ipv6 *) &p);
if (ret <= 0)
{
- vty_outln (vty,"IPv6 address prefix/prefixlen is malformed");
+ vty_out (vty,"IPv6 address prefix/prefixlen is malformed\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1424,7 +1424,7 @@ DEFUN (no_access_list_all,
access = access_list_lookup (AFI_IP, argv[idx_acl]->arg);
if (access == NULL)
{
- vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_acl]->arg);
+ vty_out (vty, "%% access-list %s doesn't exist\n",argv[idx_acl]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1601,7 +1601,7 @@ DEFUN (no_ipv6_access_list_all,
access = access_list_lookup (AFI_IP6, argv[idx_word]->arg);
if (access == NULL)
{
- vty_outln (vty, "%% access-list %s doesn't exist",argv[idx_word]->arg);
+ vty_out (vty, "%% access-list %s doesn't exist\n",argv[idx_word]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1688,7 +1688,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
return 0;
/* Print the name of the protocol */
- vty_outln (vty, "%s:", frr_protoname);
+ vty_out (vty, "%s:\n", frr_protoname);
for (access = master->num.head; access; access = access->next)
{
@@ -1703,7 +1703,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
if (write)
{
- vty_outln (vty, "%s IP%s access list %s",
+ vty_out (vty, "%s IP%s access list %s\n",
mfilter->cisco ?
(filter->extended ? "Extended" : "Standard") : "Zebra",
afi == AFI_IP6 ? "v6" : "",
@@ -1721,13 +1721,13 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
else
{
if (filter->addr_mask.s_addr == 0xffffffff)
- vty_outln (vty, " any");
+ vty_out (vty, " any\n");
else
{
vty_out (vty, " %s", inet_ntoa (filter->addr));
if (filter->addr_mask.s_addr != 0)
vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask));
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
}
@@ -1746,7 +1746,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
if (write)
{
- vty_outln (vty, "%s IP%s access list %s",
+ vty_out (vty, "%s IP%s access list %s\n",
mfilter->cisco ?
(filter->extended ? "Extended" : "Standard") : "Zebra",
afi == AFI_IP6 ? "v6" : "",
@@ -1764,13 +1764,13 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
else
{
if (filter->addr_mask.s_addr == 0xffffffff)
- vty_outln (vty, " any");
+ vty_out (vty, " any\n");
else
{
vty_out (vty, " %s", inet_ntoa (filter->addr));
if (filter->addr_mask.s_addr != 0)
vty_out (vty, ", wildcard bits %s", inet_ntoa (filter->addr_mask));
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
}
@@ -1855,18 +1855,18 @@ config_write_access_cisco (struct vty *vty, struct filter *mfilter)
vty_out (vty, " %s", inet_ntoa (filter->mask));
vty_out (vty, " %s", inet_ntoa (filter->mask_mask));
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
else
{
if (filter->addr_mask.s_addr == 0xffffffff)
- vty_outln (vty, " any");
+ vty_out (vty, " any\n");
else
{
vty_out (vty, " %s", inet_ntoa (filter->addr));
if (filter->addr_mask.s_addr != 0)
vty_out (vty, " %s", inet_ntoa (filter->addr_mask));
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
}
@@ -1889,7 +1889,7 @@ config_write_access_zebra (struct vty *vty, struct filter *mfilter)
p->prefixlen,
filter->exact ? " exact-match" : "");
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
static int
@@ -1908,7 +1908,7 @@ config_write_access (struct vty *vty, afi_t afi)
{
if (access->remark)
{
- vty_outln (vty, "%saccess-list %s remark %s",
+ vty_out (vty, "%saccess-list %s remark %s\n",
afi == AFI_IP ? "" : "ipv6 ",
access->name,access->remark);
write++;
@@ -1934,7 +1934,7 @@ config_write_access (struct vty *vty, afi_t afi)
{
if (access->remark)
{
- vty_outln (vty, "%saccess-list %s remark %s",
+ vty_out (vty, "%saccess-list %s remark %s\n",
afi == AFI_IP ? "" : "ipv6 ",
access->name,access->remark);
write++;
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c
index 7962b5aef..9f4c071ab 100644
--- a/lib/grammar_sandbox.c
+++ b/lib/grammar_sandbox.c
@@ -52,7 +52,7 @@ struct graph *nodegraph = NULL, *nodegraph_free = NULL;
#define check_nodegraph() \
do { if (!nodegraph) { \
- vty_outln(vty, "nodegraph not initialized"); \
+ vty_out(vty, "nodegraph not initialized\n"); \
return CMD_WARNING; \
} } while (0)
@@ -128,7 +128,7 @@ DEFUN (grammar_test_complete,
// print completions
for (i = 0; i < vector_active (comps); i++) {
tkn = vector_slot (comps, i);
- vty_outln (vty, " %-*s %s", width, tkn->text, tkn->desc);
+ vty_out (vty, " %-*s %s\n", width, tkn->text, tkn->desc);
}
for (i = 0; i < vector_active (comps); i++)
@@ -136,7 +136,7 @@ DEFUN (grammar_test_complete,
vector_free (comps);
}
else
- vty_outln (vty, "%% No match");
+ vty_out (vty, "%% No match\n");
// free resources
list_delete (completions);
@@ -176,13 +176,13 @@ DEFUN (grammar_test_match,
// print completions or relevant error message
if (element)
{
- vty_outln (vty, "Matched: %s", element->string);
+ vty_out (vty, "Matched: %s\n", element->string);
struct listnode *ln;
struct cmd_token *token;
for (ALL_LIST_ELEMENTS_RO(argvv,ln,token))
- vty_outln (vty, "%s -- %s", token->text, token->arg);
+ vty_out (vty, "%s -- %s\n", token->text, token->arg);
- vty_outln (vty, "func: %p", element->func);
+ vty_out (vty, "func: %p\n", element->func);
list_delete (argvv);
}
@@ -190,16 +190,16 @@ DEFUN (grammar_test_match,
assert(MATCHER_ERROR(result));
switch (result) {
case MATCHER_NO_MATCH:
- vty_outln (vty, "%% Unknown command");
+ vty_out (vty, "%% Unknown command\n");
break;
case MATCHER_INCOMPLETE:
- vty_outln (vty, "%% Incomplete command");
+ vty_out (vty, "%% Incomplete command\n");
break;
case MATCHER_AMBIGUOUS:
- vty_outln (vty, "%% Ambiguous command");
+ vty_out (vty, "%% Ambiguous command\n");
break;
default:
- vty_outln (vty, "%% Unknown error");
+ vty_out (vty, "%% Unknown error\n");
break;
}
}
@@ -411,7 +411,7 @@ DEFUN (grammar_findambig,
nodegraph = cnode->cmdgraph;
if (!nodegraph)
continue;
- vty_outln (vty, "scanning node %d", scannode - 1);
+ vty_out (vty, "scanning node %d\n", scannode - 1);
}
commands = cmd_graph_permutations (nodegraph);
@@ -420,25 +420,25 @@ DEFUN (grammar_findambig,
{
int same = prev && !strcmp (prev->cmd, cur->cmd);
if (printall && !same)
- vty_outln (vty, "'%s' [%x]", cur->cmd, cur->el->daemon);
+ vty_out (vty, "'%s' [%x]\n", cur->cmd, cur->el->daemon);
if (same)
{
- vty_outln (vty, "'%s' AMBIGUOUS:", cur->cmd);
- vty_outln (vty, " %s%s '%s'", prev->el->name, VTYNL,
+ vty_out (vty, "'%s' AMBIGUOUS:\n", cur->cmd);
+ vty_out (vty, " %s\n '%s'\n", prev->el->name,
prev->el->string);
- vty_outln (vty, " %s%s '%s'", cur->el->name, VTYNL,
+ vty_out (vty, " %s\n '%s'\n", cur->el->name,
cur->el->string);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
ambig++;
}
prev = cur;
}
list_delete (commands);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
} while (scan && scannode < LINK_PARAMS_NODE);
- vty_outln (vty, "%d ambiguous commands found.", ambig);
+ vty_out (vty, "%d ambiguous commands found.\n", ambig);
if (scan)
nodegraph = NULL;
@@ -475,11 +475,11 @@ DEFUN (grammar_access,
cnode = vector_slot (cmdvec, atoi (argv[2]->arg));
if (!cnode)
{
- vty_outln (vty, "%% no such node");
+ vty_out (vty, "%% no such node\n");
return CMD_WARNING_CONFIG_FAILED;
}
- vty_outln (vty, "node %d", (int)cnode->node);
+ vty_out (vty, "node %d\n", (int)cnode->node);
nodegraph = cnode->cmdgraph;
return CMD_SUCCESS;
}
@@ -542,7 +542,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level,
if (stackpos == MAXDEPTH)
{
- vty_outln (vty, " -aborting! (depth limit)");
+ vty_out (vty, " -aborting! (depth limit)\n");
return;
}
stack[stackpos++] = start;
@@ -551,7 +551,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level,
if (numto)
{
if (numto > 1)
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
for (unsigned int i = 0; i < vector_active (start->to); i++)
{
struct graph_node *adj = vector_slot (start->to, i);
@@ -563,12 +563,12 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level,
if (adj == start)
vty_out(vty, "*");
else if (((struct cmd_token *)adj->data)->type == END_TKN)
- vty_outln (vty, "--END");
+ vty_out (vty, "--END\n");
else {
size_t k;
for (k = 0; k < stackpos; k++)
if (stack[k] == adj) {
- vty_outln (vty, "<<loop@%zu ", k);
+ vty_out (vty, "<<loop@%zu \n", k);
break;
}
if (k == stackpos)
@@ -577,7 +577,7 @@ pretty_print_graph (struct vty *vty, struct graph_node *start, int level,
}
}
else
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
static void
@@ -660,5 +660,5 @@ init_cmdgraph (struct vty *vty, struct graph **graph)
struct cmd_token *token = cmd_token_new (START_TKN, 0, NULL, NULL);
graph_new_node (*graph, token, (void (*)(void *)) &cmd_token_del);
if (vty)
- vty_outln (vty, "initialized graph");
+ vty_out (vty, "initialized graph\n");
}
diff --git a/lib/hash.c b/lib/hash.c
index bdb2e097c..7c355b2d8 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -426,7 +426,7 @@ DEFUN(show_hash_stats,
if (!_hashes)
{
pthread_mutex_unlock (&_hashes_mtx);
- vty_outln (vty, "No hash tables in use.");
+ vty_out (vty, "No hash tables in use.\n");
return CMD_SUCCESS;
}
@@ -460,21 +460,21 @@ DEFUN(show_hash_stats,
char underln[sizeof(header) + strlen(frr_protonameinst)];
memset (underln, '-', sizeof(underln));
underln[sizeof(underln) - 1] = '\0';
- vty_outln (vty, "%s%s", header, frr_protonameinst);
- vty_outln (vty, "%s", underln);
+ vty_out (vty, "%s%s\n", header, frr_protonameinst);
+ vty_out (vty, "%s\n", underln);
- vty_outln (vty, "# allocated: %d", _hashes->count);
- vty_outln (vty, "# named: %d%s", tt->nrows - 1, VTYNL);
+ vty_out (vty, "# allocated: %d\n", _hashes->count);
+ vty_out (vty, "# named: %d\n\n", tt->nrows - 1);
if (tt->nrows > 1)
{
ttable_colseps (tt, 0, RIGHT, true, '|');
- char *table = ttable_dump (tt, VTYNL);
- vty_out (vty, "%s%s", table, VTYNL);
+ char *table = ttable_dump (tt, "\n");
+ vty_out (vty, "%s\n", table);
XFREE (MTYPE_TMP, table);
}
else
- vty_outln (vty, "No named hash tables to display.");
+ vty_out (vty, "No named hash tables to display.\n");
ttable_del (tt);
diff --git a/lib/if.c b/lib/if.c
index cea05643e..8b64aef9a 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -690,8 +690,8 @@ DEFUN (interface,
if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ)
{
- vty_outln (vty, "%% Interface name %s is invalid: length exceeds "
- "%d characters",
+ vty_out (vty, "%% Interface name %s is invalid: length exceeds "
+ "%d characters\n",
ifname, INTERFACE_NAMSIZ);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -709,7 +709,7 @@ DEFUN (interface,
if (!ifp)
{
- vty_outln (vty, "%% interface %s not in %s", ifname, vrfname);
+ vty_out (vty, "%% interface %s not in %s\n", ifname, vrfname);
return CMD_WARNING_CONFIG_FAILED;
}
VTY_PUSH_CONTEXT (INTERFACE_NODE, ifp);
@@ -739,14 +739,13 @@ DEFUN_NOSH (no_interface,
if (ifp == NULL)
{
- vty_out (vty, "%% Interface %s does not exist%s", ifname, VTYNL);
+ vty_out (vty, "%% Interface %s does not exist\n", ifname);
return CMD_WARNING_CONFIG_FAILED;
}
if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
- vty_out (vty, "%% Only inactive interfaces can be deleted%s",
- VTYNL);
+ vty_out (vty, "%% Only inactive interfaces can be deleted\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -793,8 +792,7 @@ DEFUN (show_address,
p = ifc->address;
if (p->family == AF_INET)
- vty_out (vty, "%s/%d%s", inet_ntoa (p->u.prefix4), p->prefixlen,
- VTYNL);
+ vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
}
}
return CMD_SUCCESS;
@@ -819,8 +817,7 @@ DEFUN (show_address_vrf_all,
if (!vrf->iflist || !listcount (vrf->iflist))
continue;
- vty_out (vty, "%sVRF %u%s%s", VTYNL, vrf->vrf_id, VTYNL,
- VTYNL);
+ vty_out (vty, "\nVRF %u\n\n", vrf->vrf_id);
for (ALL_LIST_ELEMENTS_RO (vrf->iflist, node, ifp))
{
@@ -829,8 +826,7 @@ DEFUN (show_address_vrf_all,
p = ifc->address;
if (p->family == AF_INET)
- vty_out (vty, "%s/%d%s", inet_ntoa (p->u.prefix4), p->prefixlen,
- VTYNL);
+ vty_out (vty, "%s/%d\n", inet_ntoa (p->u.prefix4), p->prefixlen);
}
}
}
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 492c39c6a..a0c40d5af 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -228,7 +228,7 @@ DEFUN (if_rmap,
type = IF_RMAP_OUT;
else
{
- vty_outln (vty, "route-map direction must be [in|out]");
+ vty_out (vty, "route-map direction must be [in|out]\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -259,14 +259,14 @@ DEFUN (no_if_rmap,
type = IF_RMAP_OUT;
else
{
- vty_outln (vty, "route-map direction must be [in|out]");
+ vty_out (vty, "route-map direction must be [in|out]\n");
return CMD_WARNING_CONFIG_FAILED;
}
ret = if_rmap_unset (argv[idx_ifname]->arg, type, argv[idx_routemap_name]->arg);
if (! ret)
{
- vty_outln (vty, "route-map doesn't exist");
+ vty_out (vty, "route-map doesn't exist\n");
return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
@@ -290,7 +290,7 @@ config_write_if_rmap (struct vty *vty)
if (if_rmap->routemap[IF_RMAP_IN])
{
- vty_outln (vty, " route-map %s in %s",
+ vty_out (vty, " route-map %s in %s\n",
if_rmap->routemap[IF_RMAP_IN],
if_rmap->ifname);
write++;
@@ -298,7 +298,7 @@ config_write_if_rmap (struct vty *vty)
if (if_rmap->routemap[IF_RMAP_OUT])
{
- vty_outln (vty, " route-map %s out %s",
+ vty_out (vty, " route-map %s out %s\n",
if_rmap->routemap[IF_RMAP_OUT],
if_rmap->ifname);
write++;
diff --git a/lib/keychain.c b/lib/keychain.c
index ab2ad3262..f768933b7 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -271,7 +271,7 @@ DEFUN (no_key_chain,
if (! keychain)
{
- vty_outln (vty, "Can't find keychain %s", argv[idx_word]->arg);
+ vty_out (vty, "Can't find keychain %s\n", argv[idx_word]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -314,7 +314,7 @@ DEFUN (no_key,
key = key_lookup (keychain, index);
if (! key)
{
- vty_outln (vty, "Can't find key %d", index);
+ vty_out (vty, "Can't find key %d\n", index);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -477,20 +477,20 @@ key_lifetime_set (struct vty *vty, struct key_range *krange,
time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0)
{
- vty_outln (vty, "Malformed time value");
+ vty_out (vty, "Malformed time value\n");
return CMD_WARNING_CONFIG_FAILED;
}
time_end = key_str2time (etime_str, eday_str, emonth_str, eyear_str);
if (time_end < 0)
{
- vty_outln (vty, "Malformed time value");
+ vty_out (vty, "Malformed time value\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (time_end <= time_start)
{
- vty_outln (vty, "Expire time is not later than start time");
+ vty_out (vty, "Expire time is not later than start time\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -512,7 +512,7 @@ key_lifetime_duration_set (struct vty *vty, struct key_range *krange,
time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0)
{
- vty_outln (vty, "Malformed time value");
+ vty_out (vty, "Malformed time value\n");
return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
@@ -534,7 +534,7 @@ key_lifetime_infinite_set (struct vty *vty, struct key_range *krange,
time_start = key_str2time (stime_str, sday_str, smonth_str, syear_str);
if (time_start < 0)
{
- vty_outln (vty, "Malformed time value");
+ vty_out (vty, "Malformed time value\n");
return CMD_WARNING_CONFIG_FAILED;
}
krange->start = time_start;
@@ -966,14 +966,14 @@ keychain_config_write (struct vty *vty)
for (ALL_LIST_ELEMENTS_RO (keychain_list, node, keychain))
{
- vty_outln (vty, "key chain %s", keychain->name);
+ vty_out (vty, "key chain %s\n", keychain->name);
for (ALL_LIST_ELEMENTS_RO (keychain->key, knode, key))
{
- vty_outln (vty, " key %d", key->index);
+ vty_out (vty, " key %d\n", key->index);
if (key->string)
- vty_outln (vty, " key-string %s", key->string);
+ vty_out (vty, " key-string %s\n", key->string);
if (key->accept.start)
{
@@ -990,7 +990,7 @@ keychain_config_write (struct vty *vty)
keychain_strftime (buf, BUFSIZ, &key->accept.end);
vty_out (vty, " %s", buf);
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
if (key->send.start)
@@ -1007,10 +1007,10 @@ keychain_config_write (struct vty *vty)
keychain_strftime (buf, BUFSIZ, &key->send.end);
vty_out (vty, " %s", buf);
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
- vty_outln (vty, "!");
+ vty_out (vty, "!\n");
}
return 0;
diff --git a/lib/memory_vty.c b/lib/memory_vty.c
index 5983efbdc..f65952e8a 100644
--- a/lib/memory_vty.c
+++ b/lib/memory_vty.c
@@ -44,26 +44,26 @@ show_memory_mallinfo (struct vty *vty)
struct mallinfo minfo = mallinfo();
char buf[MTYPE_MEMSTR_LEN];
- vty_outln (vty, "System allocator statistics:");
- vty_outln (vty, " Total heap allocated: %s",
+ vty_out (vty, "System allocator statistics:\n");
+ vty_out (vty, " Total heap allocated: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.arena));
- vty_outln (vty, " Holding block headers: %s",
+ vty_out (vty, " Holding block headers: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.hblkhd));
- vty_outln (vty, " Used small blocks: %s",
+ vty_out (vty, " Used small blocks: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.usmblks));
- vty_outln (vty, " Used ordinary blocks: %s",
+ vty_out (vty, " Used ordinary blocks: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.uordblks));
- vty_outln (vty, " Free small blocks: %s",
+ vty_out (vty, " Free small blocks: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.fsmblks));
- vty_outln (vty, " Free ordinary blocks: %s",
+ vty_out (vty, " Free ordinary blocks: %s\n",
mtype_memstr(buf, MTYPE_MEMSTR_LEN, minfo.fordblks));
- vty_outln (vty, " Ordinary blocks: %ld",
+ vty_out (vty, " Ordinary blocks: %ld\n",
(unsigned long)minfo.ordblks);
- vty_outln (vty, " Small blocks: %ld",
+ vty_out (vty, " Small blocks: %ld\n",
(unsigned long)minfo.smblks);
- vty_outln (vty, " Holding blocks: %ld",
+ vty_out (vty, " Holding blocks: %ld\n",
(unsigned long)minfo.hblks);
- vty_outln (vty,"(see system documentation for 'mallinfo' for meaning)");
+ vty_out (vty,"(see system documentation for 'mallinfo' for meaning)\n");
return 1;
}
#endif /* HAVE_MALLINFO */
@@ -72,12 +72,12 @@ static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt)
{
struct vty *vty = arg;
if (!mt)
- vty_outln (vty, "--- qmem %s ---", mg->name);
+ vty_out (vty, "--- qmem %s ---\n", mg->name);
else {
if (mt->n_alloc != 0) {
char size[32];
snprintf(size, sizeof(size), "%6zu", mt->size);
- vty_outln (vty, "%-30s: %10zu %s",
+ vty_out (vty, "%-30s: %10zu %s\n",
mt->name, mt->n_alloc,
mt->size == 0 ? "" : mt->size == SIZE_VAR ? "(variably sized)" : size);
}
@@ -108,14 +108,13 @@ DEFUN (show_modules,
{
struct frrmod_runtime *plug = frrmod_list;
- vty_outln (vty, "%-12s %-25s %s%s",
- "Module Name", "Version", "Description",
- VTYNL);
+ vty_out (vty, "%-12s %-25s %s\n\n",
+ "Module Name", "Version", "Description");
while (plug)
{
const struct frrmod_info *i = plug->info;
- vty_outln (vty, "%-12s %-25s %s", i->name, i->version,i->description);
+ vty_out (vty, "%-12s %-25s %s\n", i->name, i->version,i->description);
if (plug->dl_handle)
{
#ifdef HAVE_DLINFO_ORIGIN
@@ -129,13 +128,13 @@ DEFUN (show_modules,
{
name = strrchr(lm->l_name, '/');
name = name ? name + 1 : lm->l_name;
- vty_outln (vty, "\tfrom: %s/%s", origin, name);
+ vty_out (vty, "\tfrom: %s/%s\n", origin, name);
}
# else
- vty_outln (vty, "\tfrom: %s ", origin, plug->load_name);
+ vty_out (vty, "\tfrom: %s \n", origin, plug->load_name);
# endif
#else
- vty_outln (vty, "\tfrom: %s", plug->load_name);
+ vty_out (vty, "\tfrom: %s\n", plug->load_name);
#endif
}
plug = plug->next;
diff --git a/lib/ns.c b/lib/ns.c
index 71f2b3ab6..583fe95b7 100644
--- a/lib/ns.c
+++ b/lib/ns.c
@@ -296,7 +296,7 @@ ns_netns_pathname (struct vty *vty, const char *name)
if (! result)
{
- vty_outln (vty, "Invalid pathname: %s",safe_strerror(errno));
+ vty_out (vty, "Invalid pathname: %s\n",safe_strerror(errno));
return NULL;
}
return pathname;
@@ -324,8 +324,8 @@ DEFUN_NOSH (ns_netns,
if (ns->name && strcmp (ns->name, pathname) != 0)
{
- vty_out (vty, "NS %u is already configured with NETNS %s%s",
- ns->ns_id, ns->name, VTYNL);
+ vty_out (vty, "NS %u is already configured with NETNS %s\n",
+ ns->ns_id, ns->name);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -334,8 +334,8 @@ DEFUN_NOSH (ns_netns,
if (!ns_enable (ns))
{
- vty_out (vty, "Can not associate NS %u with NETNS %s%s",
- ns->ns_id, ns->name, VTYNL);
+ vty_out (vty, "Can not associate NS %u with NETNS %s\n",
+ ns->ns_id, ns->name);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -365,13 +365,13 @@ DEFUN (no_ns_netns,
if (!ns)
{
- vty_outln (vty, "NS %u is not found", ns_id);
+ vty_out (vty, "NS %u is not found\n", ns_id);
return CMD_SUCCESS;
}
if (ns->name && strcmp (ns->name, pathname) != 0)
{
- vty_outln (vty, "Incorrect NETNS file name");
+ vty_out (vty, "Incorrect NETNS file name\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -405,7 +405,7 @@ ns_config_write (struct vty *vty)
if (ns->ns_id == NS_DEFAULT || ns->name == NULL)
continue;
- vty_outln (vty, "logical-router %u netns %s", ns->ns_id,ns->name);
+ vty_out (vty, "logical-router %u netns %s\n", ns->ns_id,ns->name);
write = 1;
}
diff --git a/lib/plist.c b/lib/plist.c
index 88788b14b..96c60a489 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -882,7 +882,7 @@ prefix_entry_dup_check (struct prefix_list *plist,
static int
vty_invalid_prefix_range (struct vty *vty, const char *prefix)
{
- vty_outln (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value",
+ vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value\n",
prefix);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -920,7 +920,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
type = PREFIX_DENY;
else
{
- vty_outln (vty, "%% prefix type must be permit or deny");
+ vty_out (vty, "%% prefix type must be permit or deny\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -940,7 +940,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
- vty_outln (vty, "%% Malformed IPv4 prefix");
+ vty_out (vty, "%% Malformed IPv4 prefix\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -962,7 +962,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
- vty_outln (vty, "%% Malformed IPv6 prefix");
+ vty_out (vty, "%% Malformed IPv6 prefix\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -973,7 +973,7 @@ vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
break;
case AFI_L2VPN:
default:
- vty_outln (vty, "%% Unrecognized AFI (%d)", afi);
+ vty_out (vty, "%% Unrecognized AFI (%d)\n", afi);
return CMD_WARNING_CONFIG_FAILED;
break;
}
@@ -1042,7 +1042,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
plist = prefix_list_lookup (afi, name);
if (! plist)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1057,7 +1057,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
/* We must have, at a minimum, both the type and prefix here */
if ((typestr == NULL) || (prefix == NULL))
{
- vty_outln (vty, "%% Both prefix and type required");
+ vty_out (vty, "%% Both prefix and type required\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1078,7 +1078,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
type = PREFIX_DENY;
else
{
- vty_outln (vty, "%% prefix type must be permit or deny");
+ vty_out (vty, "%% prefix type must be permit or deny\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1096,7 +1096,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
- vty_outln (vty, "%% Malformed IPv4 prefix");
+ vty_out (vty, "%% Malformed IPv4 prefix\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1113,7 +1113,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (ret <= 0)
{
- vty_outln (vty, "%% Malformed IPv6 prefix");
+ vty_out (vty, "%% Malformed IPv6 prefix\n");
return CMD_WARNING_CONFIG_FAILED;
}
}
@@ -1123,7 +1123,7 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
if (pentry == NULL)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1141,7 +1141,7 @@ vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
plist = prefix_list_lookup (afi, name);
if (! plist)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1179,21 +1179,21 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
if (dtype == normal_display)
{
- vty_outln (vty, "ip%s prefix-list %s: %d entries",
+ vty_out (vty, "ip%s prefix-list %s: %d entries\n",
afi == AFI_IP ? "" : "v6",
plist->name, plist->count);
if (plist->desc)
- vty_outln (vty, " Description: %s", plist->desc);
+ vty_out (vty, " Description: %s\n", plist->desc);
}
else if (dtype == summary_display || dtype == detail_display)
{
- vty_outln (vty, "ip%s prefix-list %s:",
+ vty_out (vty, "ip%s prefix-list %s:\n",
afi == AFI_IP ? "" : "v6", plist->name);
if (plist->desc)
- vty_outln (vty, " Description: %s", plist->desc);
+ vty_out (vty, " Description: %s\n", plist->desc);
- vty_outln (vty, " count: %d, range entries: %d, sequences: %u - %u",
+ vty_out (vty, " count: %d, range entries: %d, sequences: %u - %u\n",
plist->count, plist->rangecount,
plist->head ? plist->head->seq : 0,
plist->tail ? plist->tail->seq : 0);
@@ -1234,7 +1234,7 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
vty_out (vty, " (hit count: %ld, refcount: %ld)",
pentry->hitcnt, pentry->refcnt);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
}
@@ -1259,7 +1259,7 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
plist = prefix_list_lookup (afi, name);
if (! plist)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING;
}
vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);
@@ -1269,7 +1269,7 @@ vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
if (dtype == detail_display || dtype == summary_display)
{
if (master->recent)
- vty_outln (vty, "Prefix-list with the last deletion/insertion: %s",
+ vty_out (vty, "Prefix-list with the last deletion/insertion: %s\n",
master->recent->name);
}
@@ -1296,14 +1296,14 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
plist = prefix_list_lookup (afi, name);
if (! plist)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING;
}
ret = str2prefix (prefix, &p);
if (ret <= 0)
{
- vty_outln (vty, "%% prefix is malformed");
+ vty_out (vty, "%% prefix is malformed\n");
return CMD_WARNING;
}
@@ -1346,7 +1346,7 @@ vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
vty_out (vty, " (hit count: %ld, refcount: %ld)",
pentry->hitcnt, pentry->refcnt);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
if (type == first_match_display)
return CMD_SUCCESS;
@@ -1384,7 +1384,7 @@ vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
plist = prefix_list_lookup (afi, name);
if (! plist)
{
- vty_outln (vty, "%% Can't find specified prefix-list");
+ vty_out (vty, "%% Can't find specified prefix-list\n");
return CMD_WARNING;
}
@@ -1393,7 +1393,7 @@ vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
ret = str2prefix (prefix, &p);
if (ret <= 0)
{
- vty_outln (vty, "%% prefix is malformed");
+ vty_out (vty, "%% prefix is malformed\n");
return CMD_WARNING;
}
}
@@ -1816,16 +1816,16 @@ config_write_prefix_afi (afi_t afi, struct vty *vty)
if (! master->seqnum)
{
- vty_outln (vty, "no ip%s prefix-list sequence-number",
+ vty_out (vty, "no ip%s prefix-list sequence-number\n",
afi == AFI_IP ? "" : "v6");
- vty_outln (vty, "!");
+ vty_out (vty, "!\n");
}
for (plist = master->num.head; plist; plist = plist->next)
{
if (plist->desc)
{
- vty_outln (vty, "ip%s prefix-list %s description %s",
+ vty_out (vty, "ip%s prefix-list %s description %s\n",
afi == AFI_IP ? "" : "v6",
plist->name, plist->desc);
write++;
@@ -1858,17 +1858,17 @@ config_write_prefix_afi (afi_t afi, struct vty *vty)
if (pentry->le)
vty_out (vty, " le %d", pentry->le);
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
write++;
}
- /* vty_out (vty, "!%s", VTYNL); */
+ /* vty_out (vty, "!\n"); */
}
for (plist = master->str.head; plist; plist = plist->next)
{
if (plist->desc)
{
- vty_outln (vty, "ip%s prefix-list %s description %s",
+ vty_out (vty, "ip%s prefix-list %s description %s\n",
afi == AFI_IP ? "" : "v6",
plist->name, plist->desc);
write++;
@@ -1901,7 +1901,7 @@ config_write_prefix_afi (afi_t afi, struct vty *vty)
if (pentry->le)
vty_out (vty, " le %d", pentry->le);
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
write++;
}
}
@@ -2046,13 +2046,13 @@ prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_
else
json_object_object_add(json, "ipv6PrefixList", json_prefix);
- vty_outln (vty, "%s",
+ vty_out (vty, "%s\n",
json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
else
{
- vty_outln (vty, "ip%s prefix-list %s: %d entries",
+ vty_out (vty, "ip%s prefix-list %s: %d entries\n",
afi == AFI_IP ? "" : "v6",
plist->name, plist->count);
@@ -2071,7 +2071,7 @@ prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_
if (pentry->le)
vty_out (vty, " le %d", pentry->le);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
}
}
return plist->count;
diff --git a/lib/route_types.pl b/lib/route_types.pl
index 29bcd3a67..9d50acaae 100755
--- a/lib/route_types.pl
+++ b/lib/route_types.pl
@@ -113,19 +113,15 @@ sub codelist {
$protodetail{$p}->{"shorthelp"});
if (length($str . $s) > 70) {
$str =~ s/ $//;
- push @lines, $str . "%s\" \\\n";
+ push @lines, $str . "\\n\" \\\n";
$str = " \" ";
}
$str .= $s;
}
$str =~ s/ $//;
- push @lines, $str . "%s\" \\\n";
- push @lines, " \" > - selected route, * - FIB route%s%s\", \\\n";
- my @nl = ();
- for (my $c = 0; $c < @lines + 1; $c++) {
- push @nl, "VTYNL"
- }
- return join("", @lines) ." ". join(", ", @nl);
+ push @lines, $str . "\\n\" \\\n";
+ push @lines, " \" > - selected route, * - FIB route\\n\\n\"";
+ return join("", @lines);
}
print "\n";
diff --git a/lib/routemap.c b/lib/routemap.c
index da8d48192..9ceaa1115 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -521,10 +521,10 @@ generic_match_add (struct vty *vty, struct route_map_index *index,
switch (ret)
{
case RMAP_RULE_MISSING:
- vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
+ vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
+ vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -568,10 +568,10 @@ generic_match_delete (struct vty *vty, struct route_map_index *index,
switch (ret)
{
case RMAP_RULE_MISSING:
- vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
+ vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
break;
case RMAP_COMPILE_ERROR:
- vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
+ vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
break;
}
@@ -605,10 +605,10 @@ generic_set_add (struct vty *vty, struct route_map_index *index,
switch (ret)
{
case RMAP_RULE_MISSING:
- vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
+ vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
+ vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -628,10 +628,10 @@ generic_set_delete (struct vty *vty, struct route_map_index *index,
switch (ret)
{
case RMAP_RULE_MISSING:
- vty_outln (vty, "%% [%s] Can't find rule.", frr_protonameinst);
+ vty_out (vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_ERROR:
- vty_outln (vty, "%% [%s] Argument form is unsupported or malformed.",
+ vty_out (vty, "%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -993,43 +993,43 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
struct route_map_index *index;
struct route_map_rule *rule;
- vty_outln (vty, "%s:", frr_protonameinst);
+ vty_out (vty, "%s:\n", frr_protonameinst);
for (index = map->head; index; index = index->next)
{
- vty_outln (vty, "route-map %s, %s, sequence %d",
+ vty_out (vty, "route-map %s, %s, sequence %d\n",
map->name, route_map_type_str (index->type),
index->pref);
/* Description */
if (index->description)
- vty_outln (vty, " Description:%s %s", VTYNL,
+ vty_out (vty, " Description:\n %s\n",
index->description);
/* Match clauses */
- vty_outln (vty, " Match clauses:");
+ vty_out (vty, " Match clauses:\n");
for (rule = index->match_list.head; rule; rule = rule->next)
- vty_outln (vty, " %s %s",
+ vty_out (vty, " %s %s\n",
rule->cmd->str, rule->rule_str);
- vty_outln (vty, " Set clauses:");
+ vty_out (vty, " Set clauses:\n");
for (rule = index->set_list.head; rule; rule = rule->next)
- vty_outln (vty, " %s %s",
+ vty_out (vty, " %s %s\n",
rule->cmd->str, rule->rule_str);
/* Call clause */
- vty_outln (vty, " Call clause:");
+ vty_out (vty, " Call clause:\n");
if (index->nextrm)
- vty_outln (vty, " Call %s", index->nextrm);
+ vty_out (vty, " Call %s\n", index->nextrm);
/* Exit Policy */
- vty_outln (vty, " Action:");
+ vty_out (vty, " Action:\n");
if (index->exitpolicy == RMAP_GOTO)
- vty_outln (vty, " Goto %d", index->nextpref);
+ vty_out (vty, " Goto %d\n", index->nextpref);
else if (index->exitpolicy == RMAP_NEXT)
- vty_outln (vty, " Continue to next entry");
+ vty_out (vty, " Continue to next entry\n");
else if (index->exitpolicy == RMAP_EXIT)
- vty_outln (vty, " Exit routemap");
+ vty_out (vty, " Exit routemap\n");
}
}
@@ -1049,7 +1049,7 @@ vty_show_route_map (struct vty *vty, const char *name)
}
else
{
- vty_outln (vty, "%s: 'route-map %s' not found", frr_protonameinst,
+ vty_out (vty, "%s: 'route-map %s' not found\n", frr_protonameinst,
name);
return CMD_SUCCESS;
}
@@ -2359,14 +2359,14 @@ DEFUN (set_ip_nexthop,
ret = str2sockunion (argv[idx_ipv4]->arg, &su);
if (ret < 0)
{
- vty_outln (vty, "%% Malformed nexthop address");
+ vty_out (vty, "%% Malformed nexthop address\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (su.sin.sin_addr.s_addr == 0 ||
IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
{
- vty_outln (vty,
- "%% nexthop address cannot be 0.0.0.0, multicast " "or reserved");
+ vty_out (vty,
+ "%% nexthop address cannot be 0.0.0.0, multicast or reserved\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2416,12 +2416,12 @@ DEFUN (set_ipv6_nexthop_local,
ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
if (!ret)
{
- vty_outln (vty, "%% Malformed nexthop address");
+ vty_out (vty, "%% Malformed nexthop address\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (!IN6_IS_ADDR_LINKLOCAL(&addr))
{
- vty_outln (vty, "%% Invalid link-local nexthop address");
+ vty_out (vty, "%% Invalid link-local nexthop address\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2577,7 +2577,7 @@ DEFUN (no_route_map_all,
map = route_map_lookup_by_name (mapname);
if (map == NULL)
{
- vty_outln (vty, "%% Could not find route-map %s", mapname);
+ vty_out (vty, "%% Could not find route-map %s\n", mapname);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2612,7 +2612,7 @@ DEFUN (no_route_map,
map = route_map_lookup_by_name (mapname);
if (map == NULL)
{
- vty_outln (vty, "%% Could not find route-map %s", mapname);
+ vty_out (vty, "%% Could not find route-map %s\n", mapname);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2620,7 +2620,7 @@ DEFUN (no_route_map,
index = route_map_index_lookup (map, permit, pref);
if (index == NULL)
{
- vty_outln (vty, "%% Could not find route-map entry %s %s",
+ vty_out (vty, "%% Could not find route-map entry %s %s\n",
mapname, prefstr);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2648,7 +2648,7 @@ DEFUN (rmap_onmatch_next,
if (index->type == RMAP_DENY)
{
/* Under a deny clause, match means it's finished. No need to set next */
- vty_outln (vty,"on-match next not supported under route-map deny");
+ vty_out (vty,"on-match next not supported under route-map deny\n");
return CMD_WARNING_CONFIG_FAILED;
}
index->exitpolicy = RMAP_NEXT;
@@ -2689,7 +2689,7 @@ DEFUN (rmap_onmatch_goto,
if (index->type == RMAP_DENY)
{
/* Under a deny clause, match means it's finished. No need to go anywhere */
- vty_outln (vty,"on-match goto not supported under route-map deny");
+ vty_out (vty,"on-match goto not supported under route-map deny\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2701,7 +2701,7 @@ DEFUN (rmap_onmatch_goto,
if (d <= index->pref)
{
/* Can't allow you to do that, Dave */
- vty_outln (vty, "can't jump backwards in route-maps");
+ vty_out (vty, "can't jump backwards in route-maps\n");
return CMD_WARNING_CONFIG_FAILED;
}
else
@@ -2860,31 +2860,31 @@ route_map_config_write (struct vty *vty)
for (index = map->head; index; index = index->next)
{
if (!first)
- vty_outln (vty, "!");
+ vty_out (vty, "!\n");
else
first = 0;
- vty_outln (vty, "route-map %s %s %d",
+ vty_out (vty, "route-map %s %s %d\n",
map->name,
route_map_type_str (index->type),
index->pref);
if (index->description)
- vty_outln (vty, " description %s", index->description);
+ vty_out (vty, " description %s\n", index->description);
for (rule = index->match_list.head; rule; rule = rule->next)
- vty_outln (vty, " match %s %s", rule->cmd->str,
+ vty_out (vty, " match %s %s\n", rule->cmd->str,
rule->rule_str ? rule->rule_str : "");
for (rule = index->set_list.head; rule; rule = rule->next)
- vty_outln (vty, " set %s %s", rule->cmd->str,
+ vty_out (vty, " set %s %s\n", rule->cmd->str,
rule->rule_str ? rule->rule_str : "");
if (index->nextrm)
- vty_outln (vty, " call %s", index->nextrm);
+ vty_out (vty, " call %s\n", index->nextrm);
if (index->exitpolicy == RMAP_GOTO)
- vty_outln (vty, " on-match goto %d", index->nextpref);
+ vty_out (vty, " on-match goto %d\n", index->nextpref);
if (index->exitpolicy == RMAP_NEXT)
- vty_outln (vty," on-match next");
+ vty_out (vty," on-match next\n");
write++;
}
diff --git a/lib/skiplist.c b/lib/skiplist.c
index 5ba1c80e4..fd772b64c 100644
--- a/lib/skiplist.c
+++ b/lib/skiplist.c
@@ -602,9 +602,9 @@ skiplist_debug(struct vty *vty, struct skiplist *l)
if (!l)
l = skiplist_last_created;
- vty_outln (vty, "Skiplist %p has max level %d", l, l->level);
+ vty_out (vty, "Skiplist %p has max level %d\n", l, l->level);
for (i = l->level; i >= 0; --i)
- vty_outln (vty, " @%d: %ld",
+ vty_out (vty, " @%d: %ld\n",
i,(long)((l->stats->forward[i]) - (struct skiplistnode *)NULL));
}
diff --git a/lib/smux.c b/lib/smux.c
index 77092cdc2..d7d99cc8a 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -1278,7 +1278,7 @@ smux_peer_oid (struct vty *vty, const char *oid_str, const char *passwd_str)
ret = smux_str2oid (oid_str, oid, &oid_len);
if (ret != 0)
{
- vty_out (vty, "object ID malformed%s", VTYNL);
+ vty_out (vty, "object ID malformed\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -1387,7 +1387,7 @@ config_write_smux (struct vty *vty)
vty_out (vty, "%s%d", first ? "" : ".", (int) smux_oid[i]);
first = 0;
}
- vty_outln (vty, " %s", smux_passwd);
+ vty_out (vty, " %s\n", smux_passwd);
}
return 0;
}
diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c
index 7cbb300c5..10f00426c 100644
--- a/lib/spf_backoff.c
+++ b/lib/spf_backoff.c
@@ -223,43 +223,43 @@ void
spf_backoff_show(struct spf_backoff *backoff, struct vty *vty,
const char *prefix)
{
- vty_outln (vty, "%sCurrent state: %s", prefix,
+ vty_out (vty, "%sCurrent state: %s\n", prefix,
spf_backoff_state2str(backoff->state));
- vty_outln (vty, "%sInit timer: %ld msec", prefix,
+ vty_out (vty, "%sInit timer: %ld msec\n", prefix,
backoff->init_delay);
- vty_outln (vty, "%sShort timer: %ld msec", prefix,
+ vty_out (vty, "%sShort timer: %ld msec\n", prefix,
backoff->short_delay);
- vty_outln (vty, "%sLong timer: %ld msec", prefix,
+ vty_out (vty, "%sLong timer: %ld msec\n", prefix,
backoff->long_delay);
- vty_outln (vty, "%sHolddown timer: %ld msec", prefix,
+ vty_out (vty, "%sHolddown timer: %ld msec\n", prefix,
backoff->holddown);
if (backoff->t_holddown)
{
struct timeval remain = thread_timer_remain(backoff->t_holddown);
- vty_outln (vty, "%s Still runs for %ld msec",
+ vty_out (vty, "%s Still runs for %ld msec\n",
prefix, remain.tv_sec * 1000 + remain.tv_usec / 1000);
}
else
{
- vty_outln (vty, "%s Inactive", prefix);
+ vty_out (vty, "%s Inactive\n", prefix);
}
- vty_outln (vty, "%sTimeToLearn timer: %ld msec", prefix,
+ vty_out (vty, "%sTimeToLearn timer: %ld msec\n", prefix,
backoff->timetolearn);
if (backoff->t_timetolearn)
{
struct timeval remain = thread_timer_remain(backoff->t_timetolearn);
- vty_outln (vty, "%s Still runs for %ld msec",
+ vty_out (vty, "%s Still runs for %ld msec\n",
prefix, remain.tv_sec * 1000 + remain.tv_usec / 1000);
}
else
{
- vty_outln (vty, "%s Inactive", prefix);
+ vty_out (vty, "%s Inactive\n", prefix);
}
- vty_outln (vty, "%sFirst event: %s", prefix,
+ vty_out (vty, "%sFirst event: %s\n", prefix,
timeval_format(&backoff->first_event_time));
- vty_outln (vty, "%sLast event: %s", prefix,
+ vty_out (vty, "%sLast event: %s\n", prefix,
timeval_format(&backoff->last_event_time));
}
@@ -291,7 +291,7 @@ spf_backoff_write_config(struct vty *vty)
if (debug_spf_backoff)
{
- vty_outln (vty, "debug spf-delay-ietf");
+ vty_out (vty, "debug spf-delay-ietf\n");
written++;
}
diff --git a/lib/thread.c b/lib/thread.c
index 26fb46e49..2c87c099d 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -95,7 +95,7 @@ vty_out_cpu_thread_history(struct vty* vty,
a->total_active, a->cpu.total/1000, a->cpu.total%1000, a->total_calls,
a->cpu.total/a->total_calls, a->cpu.max,
a->real.total/a->total_calls, a->real.max);
- vty_outln (vty, " %c%c%c%c%c %s",
+ vty_out (vty, " %c%c%c%c%c %s\n",
a->types & (1 << THREAD_READ) ? 'R':' ',
a->types & (1 << THREAD_WRITE) ? 'W':' ',
a->types & (1 << THREAD_TIMER) ? 'T':' ',
@@ -147,13 +147,13 @@ cpu_record_print(struct vty *vty, thread_type filter)
memset (underline, '-', sizeof (underline));
underline[sizeof(underline)] = '\0';
- vty_out (vty, VTYNL);
- vty_outln(vty, "Showing statistics for pthread %s", name);
- vty_outln(vty, "-------------------------------%s", underline);
- vty_outln(vty, "%21s %18s %18s", "", "CPU (user+system):", "Real (wall-clock):");
+ vty_out (vty, "\n");
+ vty_out(vty, "Showing statistics for pthread %s\n", name);
+ vty_out(vty, "-------------------------------%s\n", underline);
+ vty_out(vty, "%21s %18s %18s\n", "", "CPU (user+system):", "Real (wall-clock):");
vty_out(vty, "Active Runtime(ms) Invoked Avg uSec Max uSecs");
vty_out(vty, " Avg uSec Max uSecs");
- vty_outln(vty, " Type Thread");
+ vty_out(vty, " Type Thread\n");
if (m->cpu_record->count)
hash_iterate(m->cpu_record,
@@ -161,20 +161,20 @@ cpu_record_print(struct vty *vty, thread_type filter)
cpu_record_hash_print,
args);
else
- vty_outln(vty, "No data to display yet.");
+ vty_out(vty, "No data to display yet.\n");
- vty_out(vty, VTYNL);
+ vty_out(vty, "\n");
}
}
pthread_mutex_unlock (&masters_mtx);
- vty_out(vty, VTYNL);
- vty_outln(vty, "Total thread statistics");
- vty_outln(vty, "-------------------------");
- vty_outln(vty, "%21s %18s %18s", "", "CPU (user+system):", "Real (wall-clock):");
+ vty_out(vty, "\n");
+ vty_out(vty, "Total thread statistics\n");
+ vty_out(vty, "-------------------------\n");
+ vty_out(vty, "%21s %18s %18s\n", "", "CPU (user+system):", "Real (wall-clock):");
vty_out(vty, "Active Runtime(ms) Invoked Avg uSec Max uSecs");
vty_out(vty, " Avg uSec Max uSecs");
- vty_outln(vty, " Type Thread");
+ vty_out(vty, " Type Thread\n");
if (tmp.total_calls > 0)
vty_out_cpu_thread_history(vty, &tmp);
@@ -270,8 +270,8 @@ DEFUN (show_thread_cpu,
if (argv_find (argv, argc, "FILTER", &idx)) {
filter = parse_filter (argv[idx]->arg);
if (!filter) {
- vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least"
- "one of 'RWTEXB'", argv[idx]->arg);
+ vty_out(vty, "Invalid filter \"%s\" specified; must contain at least"
+ "one of 'RWTEXB'\n", argv[idx]->arg);
return CMD_WARNING;
}
}
@@ -294,8 +294,8 @@ DEFUN (clear_thread_cpu,
if (argv_find (argv, argc, "FILTER", &idx)) {
filter = parse_filter (argv[idx]->arg);
if (!filter) {
- vty_outln(vty, "Invalid filter \"%s\" specified; must contain at least"
- "one of 'RWTEXB'", argv[idx]->arg);
+ vty_out(vty, "Invalid filter \"%s\" specified; must contain at least"
+ "one of 'RWTEXB'\n", argv[idx]->arg);
return CMD_WARNING;
}
}
diff --git a/lib/vrf.c b/lib/vrf.c
index d19151491..e13e87898 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -474,8 +474,8 @@ DEFUN_NOSH (vrf,
if (strlen(vrfname) > VRF_NAMSIZ)
{
vty_out (vty, "%% VRF name %s is invalid: length exceeds "
- "%d characters%s",
- vrfname, VRF_NAMSIZ, VTYNL);
+ "%d characters\n",
+ vrfname, VRF_NAMSIZ);
return CMD_WARNING_CONFIG_FAILED;
}
@@ -501,14 +501,13 @@ DEFUN_NOSH (no_vrf,
if (vrfp == NULL)
{
- vty_out (vty, "%% VRF %s does not exist%s", vrfname, VTYNL);
+ vty_out (vty, "%% VRF %s does not exist\n", vrfname);
return CMD_WARNING_CONFIG_FAILED;
}
if (CHECK_FLAG (vrfp->status, VRF_ACTIVE))
{
- vty_out (vty, "%% Only inactive VRFs can be deleted%s",
- VTYNL);
+ vty_out (vty, "%% Only inactive VRFs can be deleted\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -555,7 +554,7 @@ static int
vrf_write_host (struct vty *vty)
{
if (debug_vrf)
- vty_outln (vty, "debug vrf");
+ vty_out (vty, "debug vrf\n");
return 1;
}
diff --git a/lib/vrf.h b/lib/vrf.h
index 8baa15c96..dcbc9b5e6 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -115,12 +115,12 @@ extern vrf_id_t vrf_name_to_id (const char *);
struct vrf *vrf; \
if (!(vrf = vrf_lookup_by_name(NAME))) \
{ \
- vty_out (vty, "%% VRF %s not found%s", NAME, VTYNL);\
+ vty_out (vty, "%% VRF %s not found\n", NAME);\
return CMD_WARNING; \
} \
if (vrf->vrf_id == VRF_UNKNOWN) \
{ \
- vty_out (vty, "%% VRF %s not active%s", NAME, VTYNL);\
+ vty_out (vty, "%% VRF %s not active\n", NAME);\
return CMD_WARNING; \
} \
(V) = vrf->vrf_id; \
diff --git a/lib/vty.c b/lib/vty.c
index a6cd75f1c..be2f2a6e5 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -92,23 +92,28 @@ char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
static int do_log_commands = 0;
-static int
-vty_out_variadic (struct vty *vty, const char *format, va_list args)
+/* VTY standard output function. */
+int
+vty_out (struct vty *vty, const char *format, ...)
{
+ va_list args;
int len = 0;
int size = 1024;
char buf[1024];
char *p = NULL;
- va_list cp;
if (vty_shell (vty))
- vprintf (format, args);
+ {
+ va_start (args, format);
+ vprintf (format, args);
+ va_end (args);
+ }
else
{
/* Try to write to initial buffer. */
- va_copy (cp, args);
- len = vsnprintf (buf, sizeof(buf), format, cp);
- va_end (cp);
+ va_start (args, format);
+ len = vsnprintf (buf, sizeof(buf), format, args);
+ va_end (args);
/* Initial buffer is not enough. */
if (len < 0 || len >= size)
@@ -124,9 +129,9 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args)
if (! p)
return -1;
- va_copy (cp, args);
- len = vsnprintf (p, size, format, cp);
- va_end (cp);
+ va_start (args, format);
+ len = vsnprintf (p, size, format, args);
+ va_end (args);
if (len > -1 && len < size)
break;
@@ -138,7 +143,10 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args)
p = buf;
/* Pointer p must point out buffer. */
- buffer_put (vty->obuf, (u_char *) p, len);
+ if (vty->type != VTY_TERM)
+ buffer_put (vty->obuf, (u_char *) p, len);
+ else
+ buffer_put_crlf (vty->obuf, (u_char *) p, len);
/* If p is not different with buf, it is allocated buffer. */
if (p != buf)
@@ -147,32 +155,6 @@ vty_out_variadic (struct vty *vty, const char *format, va_list args)
return len;
}
-/* VTY standard output function. */
-int
-vty_out (struct vty *vty, const char *format, ...)
-{
- int len;
- va_list args;
-
- va_start (args, format);
- len = vty_out_variadic (vty, format, args);
- va_end (args);
-
- return len;
-}
-
-int
-vty_outln (struct vty *vty, const char *format, ...)
-{
- int len;
- va_list args;
-
- va_start (args, format);
- len = vty_out_variadic (vty, format, args);
- va_end (args);
-
- return len + vty_out (vty, "%s", VTYNL);
-}
static int
vty_log_out (struct vty *vty, const char *level, const char *proto_str,
@@ -265,12 +247,12 @@ vty_hello (struct vty *vty)
for (s = buf + strlen (buf); (s > buf) && isspace ((int)*(s - 1));
s--);
*s = '\0';
- vty_outln (vty, "%s", buf);
+ vty_out (vty, "%s\n", buf);
}
fclose (f);
}
else
- vty_outln (vty, "MOTD file not found");
+ vty_out (vty, "MOTD file not found\n");
}
else if (host.motd)
vty_out (vty, "%s", host.motd);
@@ -403,14 +385,14 @@ vty_auth (struct vty *vty, char *buf)
{
if (vty->node == AUTH_NODE)
{
- vty_outln (vty, "%% Bad passwords, too many failures!");
+ vty_out (vty, "%% Bad passwords, too many failures!\n");
vty->status = VTY_CLOSE;
}
else
{
/* AUTH_ENABLE_NODE */
vty->fail = 0;
- vty_outln (vty, "%% Bad enable passwords, too many failures!");
+ vty_out (vty, "%% Bad enable passwords, too many failures!\n");
vty->status = VTY_CLOSE;
}
}
@@ -495,16 +477,16 @@ vty_command (struct vty *vty, char *buf)
{
case CMD_WARNING:
if (vty->type == VTY_FILE)
- vty_outln (vty, "Warning...");
+ vty_out (vty, "Warning...\n");
break;
case CMD_ERR_AMBIGUOUS:
- vty_outln (vty, "%% Ambiguous command.");
+ vty_out (vty, "%% Ambiguous command.\n");
break;
case CMD_ERR_NO_MATCH:
- vty_outln (vty, "%% [%s] Unknown command: %s", protocolname, buf);
+ vty_out (vty, "%% [%s] Unknown command: %s\n", protocolname, buf);
break;
case CMD_ERR_INCOMPLETE:
- vty_outln (vty, "%% Command incomplete.");
+ vty_out (vty, "%% Command incomplete.\n");
break;
}
cmd_free_strvec (vline);
@@ -732,7 +714,7 @@ vty_backward_word (struct vty *vty)
static void
vty_down_level (struct vty *vty)
{
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
cmd_exit (vty);
vty_prompt (vty);
vty->cp = 0;
@@ -742,7 +724,7 @@ vty_down_level (struct vty *vty)
static void
vty_end_config (struct vty *vty)
{
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
switch (vty->node)
{
@@ -948,16 +930,16 @@ vty_complete_command (struct vty *vty)
cmd_free_strvec (vline);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
switch (ret)
{
case CMD_ERR_AMBIGUOUS:
- vty_outln (vty, "%% Ambiguous command.");
+ vty_out (vty, "%% Ambiguous command.\n");
vty_prompt (vty);
vty_redraw_line (vty);
break;
case CMD_ERR_NO_MATCH:
- /* vty_out (vty, "%% There is no matched command.%s", VTYNL); */
+ /* vty_out (vty, "%% There is no matched command.\n"); */
vty_prompt (vty);
vty_redraw_line (vty);
break;
@@ -965,7 +947,7 @@ vty_complete_command (struct vty *vty)
if (!matched[0])
{
/* 2016-11-28 equinox -- need to debug, SEGV here */
- vty_outln (vty, "%% CLI BUG: FULL_MATCH with NULL str");
+ vty_out (vty, "%% CLI BUG: FULL_MATCH with NULL str\n");
vty_prompt (vty);
vty_redraw_line (vty);
break;
@@ -988,11 +970,11 @@ vty_complete_command (struct vty *vty)
for (i = 0; matched[i] != NULL; i++)
{
if (i != 0 && ((i % 6) == 0))
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_out (vty, "%-10s ", matched[i]);
XFREE (MTYPE_COMPLETION, matched[i]);
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_prompt (vty);
vty_redraw_line (vty);
@@ -1020,7 +1002,7 @@ vty_describe_fold (struct vty *vty, int cmd_width,
if (desc_width <= 0)
{
- vty_outln (vty, " %-*s %s", cmd_width, cmd, token->desc);
+ vty_out (vty, " %-*s %s\n", cmd_width, cmd, token->desc);
return;
}
@@ -1037,12 +1019,12 @@ vty_describe_fold (struct vty *vty, int cmd_width,
strncpy (buf, p, pos);
buf[pos] = '\0';
- vty_outln (vty, " %-*s %s", cmd_width, cmd, buf);
+ vty_out (vty, " %-*s %s\n", cmd_width, cmd, buf);
cmd = "";
}
- vty_outln (vty, " %-*s %s", cmd_width, cmd, p);
+ vty_out (vty, " %-*s %s\n", cmd_width, cmd, p);
XFREE (MTYPE_TMP, buf);
}
@@ -1071,17 +1053,17 @@ vty_describe_command (struct vty *vty)
describe = cmd_describe_command (vline, vty, &ret);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
/* Ambiguous error. */
switch (ret)
{
case CMD_ERR_AMBIGUOUS:
- vty_outln (vty, "%% Ambiguous command.");
+ vty_out (vty, "%% Ambiguous command.\n");
goto out;
break;
case CMD_ERR_NO_MATCH:
- vty_outln (vty, "%% There is no matched command.");
+ vty_out (vty, "%% There is no matched command.\n");
goto out;
break;
}
@@ -1119,10 +1101,10 @@ vty_describe_command (struct vty *vty)
}
if (!token->desc)
- vty_outln (vty, " %-s",
+ vty_out (vty, " %-s\n",
token->text);
else if (desc_width >= strlen (token->desc))
- vty_outln (vty, " %-*s %s", width,
+ vty_out (vty, " %-*s %s\n", width,
token->text,
token->desc);
else
@@ -1137,27 +1119,27 @@ vty_describe_command (struct vty *vty)
if (vector_active (varcomps) > 0)
{
- char *ac = cmd_variable_comp2str(varcomps, vty->width, VTYNL);
- vty_outln(vty, "%s", ac);
+ char *ac = cmd_variable_comp2str(varcomps, vty->width);
+ vty_out(vty, "%s\n", ac);
XFREE(MTYPE_TMP, ac);
}
vector_free(varcomps);
}
#if 0
- vty_out (vty, " %-*s %s%s", width
+ vty_out (vty, " %-*s %s\n", width
desc->cmd[0] == '.' ? desc->cmd + 1 : desc->cmd,
- desc->str ? desc->str : "", VTYNL);
+ desc->str ? desc->str : "");
#endif /* 0 */
}
if ((token = token_cr))
{
if (!token->desc)
- vty_outln (vty, " %-s",
+ vty_out (vty, " %-s\n",
token->text);
else if (desc_width >= strlen (token->desc))
- vty_outln (vty, " %-*s %s", width,
+ vty_out (vty, " %-*s %s\n", width,
token->text,
token->desc);
else
@@ -1185,7 +1167,7 @@ vty_stop_input (struct vty *vty)
{
vty->cp = vty->length = 0;
vty_clear_buf (vty);
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
switch (vty->node)
{
@@ -1296,20 +1278,20 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes)
vty_out (vty, "SE ");
break;
case TELOPT_ECHO:
- vty_outln (vty, "TELOPT_ECHO ");
+ vty_out (vty, "TELOPT_ECHO \n");
break;
case TELOPT_SGA:
- vty_outln (vty, "TELOPT_SGA ");
+ vty_out (vty, "TELOPT_SGA \n");
break;
case TELOPT_NAWS:
- vty_outln (vty, "TELOPT_NAWS ");
+ vty_out (vty, "TELOPT_NAWS \n");
break;
default:
vty_out (vty, "%x ", buf[i]);
break;
}
}
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
#endif /* TELNET_OPTION_DEBUG */
@@ -1346,8 +1328,8 @@ vty_telnet_option (struct vty *vty, unsigned char *buf, int nbytes)
vty->width = ((vty->sb_buf[1] << 8)|vty->sb_buf[2]);
vty->height = ((vty->sb_buf[3] << 8)|vty->sb_buf[4]);
#ifdef TELNET_OPTION_DEBUG
- vty_outln (vty, "TELNET NAWS window size negotiation completed: "
- "width %d, height %d",
+ vty_out (vty, "TELNET NAWS window size negotiation completed: "
+ "width %d, height %d\n",
vty->width, vty->height);
#endif
}
@@ -1605,7 +1587,7 @@ vty_read (struct thread *thread)
break;
case '\n':
case '\r':
- vty_out (vty, VTYNL);
+ vty_out (vty, "\n");
vty_execute (vty);
break;
case '\t':
@@ -1764,7 +1746,7 @@ vty_create (int vty_sock, union sockunion *su)
/* Vty is not available if password isn't set. */
if (host.password == NULL && host.password_encrypt == NULL)
{
- vty_outln (vty, "Vty password is not set.");
+ vty_out (vty, "Vty password is not set.\n");
vty->status = VTY_CLOSE;
vty_close (vty);
return NULL;
@@ -1774,8 +1756,7 @@ vty_create (int vty_sock, union sockunion *su)
/* Say hello to the world. */
vty_hello (vty);
if (! no_password_check)
- vty_outln (vty, "%sUser Access Verification%s", VTYNL,
- VTYNL);
+ vty_out (vty, "\nUser Access Verification\n\n");
/* Setting up terminal. */
vty_will_echo (vty);
@@ -2192,7 +2173,7 @@ vtysh_read (struct thread *thread)
/* Clear command line buffer. */
vty->cp = vty->length = 0;
vty_clear_buf (vty);
- vty_outln (vty, "%% Command is too long.");
+ vty_out (vty, "%% Command is too long.\n");
}
else
{
@@ -2335,7 +2316,7 @@ vty_timeout (struct thread *thread)
/* Clear buffer*/
buffer_reset (vty->obuf);
- vty_outln (vty, "%sVty connection is timed out.", VTYNL);
+ vty_out (vty, "\nVty connection is timed out.\n");
/* Close connection. */
vty->status = VTY_CLOSE;
@@ -2716,9 +2697,9 @@ DEFUN_NOSH (config_who,
for (i = 0; i < vector_active (vtyvec); i++)
if ((v = vector_slot (vtyvec, i)) != NULL)
- vty_out (vty, "%svty[%d] connected from %s.%s",
+ vty_out (vty, "%svty[%d] connected from %s.\n",
v->config ? "*" : " ",
- i, v->address, VTYNL);
+ i, v->address);
return CMD_SUCCESS;
}
@@ -2816,7 +2797,7 @@ DEFUN (no_vty_access_class,
const char *accesslist = (argc == 3) ? argv[idx_word]->arg : NULL;
if (! vty_accesslist_name || (argc == 3 && strcmp(vty_accesslist_name, accesslist)))
{
- vty_outln (vty,"Access-class is not currently applied to vty");
+ vty_out (vty,"Access-class is not currently applied to vty\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2859,7 +2840,7 @@ DEFUN (no_vty_ipv6_access_class,
if (! vty_ipv6_accesslist_name ||
(argc == 4 && strcmp(vty_ipv6_accesslist_name, accesslist)))
{
- vty_outln (vty,"IPv6 access-class is not currently applied to vty");
+ vty_out (vty,"IPv6 access-class is not currently applied to vty\n");
return CMD_WARNING_CONFIG_FAILED;
}
@@ -2960,7 +2941,7 @@ DEFUN_NOSH (show_history,
}
if (vty->hist[index] != NULL)
- vty_out (vty, " %s%s", vty->hist[index], VTYNL);
+ vty_out (vty, " %s\n", vty->hist[index]);
index++;
}
@@ -2983,30 +2964,30 @@ DEFUN (log_commands,
static int
vty_config_write (struct vty *vty)
{
- vty_outln (vty, "line vty");
+ vty_out (vty, "line vty\n");
if (vty_accesslist_name)
- vty_outln (vty, " access-class %s",
+ vty_out (vty, " access-class %s\n",
vty_accesslist_name);
if (vty_ipv6_accesslist_name)
- vty_outln (vty, " ipv6 access-class %s",
+ vty_out (vty, " ipv6 access-class %s\n",
vty_ipv6_accesslist_name);
/* exec-timeout */
if (vty_timeout_val != VTY_TIMEOUT_DEFAULT)
- vty_outln (vty, " exec-timeout %ld %ld",
+ vty_out (vty, " exec-timeout %ld %ld\n",
vty_timeout_val / 60,
vty_timeout_val % 60);
/* login */
if (no_password_check)
- vty_outln (vty, " no login");
+ vty_out (vty, " no login\n");
if (do_log_commands)
- vty_outln (vty, "log commands");
+ vty_out (vty, "log commands\n");
- vty_outln (vty, "!");
+ vty_out (vty, "!\n");
return CMD_SUCCESS;
}
diff --git a/lib/vty.h b/lib/vty.h
index b4a55180d..66450065f 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -156,7 +156,7 @@ static inline void vty_push_context(struct vty *vty,
#define VTY_CHECK_CONTEXT(ptr) \
if (!ptr) { \
vty_out (vty, "Current configuration object was deleted " \
- "by another process.%s", VTYNL); \
+ "by another process.\n"); \
return CMD_WARNING; \
}
@@ -179,17 +179,43 @@ struct vty_arg
/* Integrated configuration file. */
#define INTEGRATE_DEFAULT_CONFIG "frr.conf"
-/* Small macro to determine newline is newline only or linefeed needed. */
-#define VTYNL ((vty->type == VTY_TERM) ? "\r\n" : "\n")
-
/* for compatibility */
-#define VTY_NEWLINE VTYNL
-#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);}
-#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v))
-#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v))
+#if defined(__ICC)
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text))
+
+#elif (defined(__GNUC__) && \
+ (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
+ (defined(__clang__) && \
+ (__clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 5)))
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text))
+
+#else
+#define CPP_WARN(text)
+#endif
+
+#define VNL "\n" \
+ CPP_WARN("VNL has been replaced with \\n.")
+#define VTYNL "\n" \
+ CPP_WARN("VTYNL has been replaced with \\n.")
+#define VTY_NEWLINE "\n" \
+ CPP_WARN("VTY_NEWLINE has been replaced with \\n.")
+#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_INTEGER is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_INTEGER_RANGE is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_ULONG is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_ULL is no longer useful, use strtoull() or DEFPY.")
+#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v)) \
+ CPP_WARN("VTY_GET_IPV4_ADDRESS is no longer useful, use inet_aton() or DEFPY.")
+#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v)) \
+ CPP_WARN("VTY_GET_IPV4_PREFIX is no longer useful, use str2prefix_ipv4() or DEFPY.")
+#define vty_outln(vty, str, ...) \
+ vty_out(vty, str "\n", ## __VA_ARGS__) \
+ CPP_WARN("vty_outln is no longer useful, use vty_out(...\\n...)")
/* Default time out value */
#define VTY_TIMEOUT_DEFAULT 600
@@ -217,7 +243,6 @@ extern void vty_reset (void);
extern struct vty *vty_new (void);
extern struct vty *vty_stdio (void (*atclose)(void));
extern int vty_out (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
-extern int vty_outln (struct vty *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
extern void vty_read_config (const char *, char *);
extern void vty_time_print (struct vty *, int);
extern void vty_serv_sock (const char *, unsigned short, const char *);
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 374934419..3600df2f2 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -191,11 +191,11 @@ DEFUN (show_work_queues,
struct listnode *node;
struct work_queue *wq;
- vty_outln (vty,
- "%c %8s %5s %8s %8s %21s",
+ vty_out (vty,
+ "%c %8s %5s %8s %8s %21s\n",
' ', "List","(ms) ","Q. Runs","Yields","Cycle Counts ");
- vty_outln (vty,
- "%c %8s %5s %8s %8s %7s %6s %8s %6s %s",
+ vty_out (vty,
+ "%c %8s %5s %8s %8s %7s %6s %8s %6s %s\n",
'P',
"Items",
"Hold",
@@ -205,7 +205,7 @@ DEFUN (show_work_queues,
for (ALL_LIST_ELEMENTS_RO (work_queues, node, wq))
{
- vty_outln (vty,"%c %8d %5d %8ld %8ld %7d %6d %8ld %6u %s",
+ vty_out (vty,"%c %8d %5d %8ld %8ld %7d %6d %8ld %6u %s\n",
(CHECK_FLAG (wq->flags, WQ_UNPLUGGED) ? ' ' : 'P'),
listcount (wq->items),
wq->spec.hold,