mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 15:51:32 +00:00
vtysh: add CLI timestamp '-t' flag
Example output: flk# show version % 2021/06/29 00:25:01.562 FRRouting 8.1-dev-my-manual-build (flk). Copyright 1996-2005 Kunihiro Ishiguro, et al. ... Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
396b072f9c
commit
744bc17db5
@ -56,6 +56,9 @@ struct vty *vty;
|
|||||||
/* VTY shell pager name. */
|
/* VTY shell pager name. */
|
||||||
char *vtysh_pager_name = NULL;
|
char *vtysh_pager_name = NULL;
|
||||||
|
|
||||||
|
/* VTY should add timestamp */
|
||||||
|
bool vtysh_add_timestamp;
|
||||||
|
|
||||||
/* VTY shell client structure */
|
/* VTY shell client structure */
|
||||||
struct vtysh_client {
|
struct vtysh_client {
|
||||||
int fd;
|
int fd;
|
||||||
@ -483,6 +486,13 @@ static int vtysh_execute_func(const char *line, int pager)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vtysh_add_timestamp && strncmp(line, "exit", 4)) {
|
||||||
|
char ts[48];
|
||||||
|
|
||||||
|
(void)quagga_timestamp(3, ts, sizeof(ts));
|
||||||
|
vty_out(vty, "%% %s\n\n", ts);
|
||||||
|
}
|
||||||
|
|
||||||
saved_ret = ret = cmd_execute(vty, line, &cmd, 1);
|
saved_ret = ret = cmd_execute(vty, line, &cmd, 1);
|
||||||
saved_node = vty->node;
|
saved_node = vty->node;
|
||||||
|
|
||||||
|
@ -113,4 +113,6 @@ extern struct vty *vty;
|
|||||||
|
|
||||||
extern int user_mode;
|
extern int user_mode;
|
||||||
|
|
||||||
|
extern bool vtysh_add_timestamp;
|
||||||
|
|
||||||
#endif /* VTYSH_H */
|
#endif /* VTYSH_H */
|
||||||
|
@ -560,6 +560,7 @@ static int vtysh_read_file(FILE *confp, bool dry_run)
|
|||||||
int vtysh_read_config(const char *config_default_dir, bool dry_run)
|
int vtysh_read_config(const char *config_default_dir, bool dry_run)
|
||||||
{
|
{
|
||||||
FILE *confp = NULL;
|
FILE *confp = NULL;
|
||||||
|
bool save;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
confp = fopen(config_default_dir, "r");
|
confp = fopen(config_default_dir, "r");
|
||||||
@ -570,9 +571,14 @@ int vtysh_read_config(const char *config_default_dir, bool dry_run)
|
|||||||
return CMD_ERR_NO_FILE;
|
return CMD_ERR_NO_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save = vtysh_add_timestamp;
|
||||||
|
vtysh_add_timestamp = false;
|
||||||
|
|
||||||
ret = vtysh_read_file(confp, dry_run);
|
ret = vtysh_read_file(confp, dry_run);
|
||||||
fclose(confp);
|
fclose(confp);
|
||||||
|
|
||||||
|
vtysh_add_timestamp = save;
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +201,7 @@ struct option longopts[] = {
|
|||||||
{"writeconfig", no_argument, NULL, 'w'},
|
{"writeconfig", no_argument, NULL, 'w'},
|
||||||
{"pathspace", required_argument, NULL, 'N'},
|
{"pathspace", required_argument, NULL, 'N'},
|
||||||
{"user", no_argument, NULL, 'u'},
|
{"user", no_argument, NULL, 'u'},
|
||||||
|
{"timestamp", no_argument, NULL, 't'},
|
||||||
{0}};
|
{0}};
|
||||||
|
|
||||||
/* Read a string, and return a pointer to it. Returns NULL on EOF. */
|
/* Read a string, and return a pointer to it. Returns NULL on EOF. */
|
||||||
@ -308,6 +309,7 @@ int main(int argc, char **argv, char **env)
|
|||||||
int opt;
|
int opt;
|
||||||
int dryrun = 0;
|
int dryrun = 0;
|
||||||
int boot_flag = 0;
|
int boot_flag = 0;
|
||||||
|
bool ts_flag = false;
|
||||||
const char *daemon_name = NULL;
|
const char *daemon_name = NULL;
|
||||||
const char *inputfile = NULL;
|
const char *inputfile = NULL;
|
||||||
struct cmd_rec {
|
struct cmd_rec {
|
||||||
@ -346,7 +348,7 @@ int main(int argc, char **argv, char **env)
|
|||||||
|
|
||||||
/* Option handling. */
|
/* Option handling. */
|
||||||
while (1) {
|
while (1) {
|
||||||
opt = getopt_long(argc, argv, "be:c:d:nf:H:mEhCwN:u", longopts,
|
opt = getopt_long(argc, argv, "be:c:d:nf:H:mEhCwN:ut", longopts,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (opt == EOF)
|
if (opt == EOF)
|
||||||
@ -408,6 +410,9 @@ int main(int argc, char **argv, char **env)
|
|||||||
case 'u':
|
case 'u':
|
||||||
user_mode = 1;
|
user_mode = 1;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
ts_flag = true;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
writeconfig = 1;
|
writeconfig = 1;
|
||||||
break;
|
break;
|
||||||
@ -624,6 +629,8 @@ int main(int argc, char **argv, char **env)
|
|||||||
if (!user_mode)
|
if (!user_mode)
|
||||||
vtysh_execute("enable");
|
vtysh_execute("enable");
|
||||||
|
|
||||||
|
vtysh_add_timestamp = ts_flag;
|
||||||
|
|
||||||
while (cmd != NULL) {
|
while (cmd != NULL) {
|
||||||
char *eol;
|
char *eol;
|
||||||
|
|
||||||
@ -712,6 +719,8 @@ int main(int argc, char **argv, char **env)
|
|||||||
if (!user_mode)
|
if (!user_mode)
|
||||||
vtysh_execute("enable");
|
vtysh_execute("enable");
|
||||||
|
|
||||||
|
vtysh_add_timestamp = ts_flag;
|
||||||
|
|
||||||
/* Preparation for longjmp() in sigtstp(). */
|
/* Preparation for longjmp() in sigtstp(). */
|
||||||
sigsetjmp(jmpbuf, 1);
|
sigsetjmp(jmpbuf, 1);
|
||||||
jmpflag = 1;
|
jmpflag = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user