pipe protocol, both directions are always reloaded together (<cf/in/ or
<cf/out/ options are ignored in that case).
+ <tag><label id="cli-timeformat">timeformat "<m/format1/" [<m/limit/ "<m/format2/"]</tag>
+ Override format of date/time used by BIRD in this CLI session.
+
+ Meaning of "<m/format1/", <m/limit/, and "<m/format2/" is the same as in the
+ <ref id="opt-timeformat" name="timeformat"> configuration option. Also, the
+ same <cf/iso .../ shorthands may be used.
+
<tag><label id="cli-down">down</tag>
Shut BIRD down.
9000 Command too long
9001 Parse error
9002 Invalid symbol type
+9003 Argument too long
}
}
+/* Set time format override for the current session */
+void
+cli_set_timeformat(cli *c, const struct timeformat tf)
+{
+ size_t len1 = strlen(tf.fmt1) + 1;
+ size_t len2 = tf.fmt2 ? strlen(tf.fmt2) + 1 : 0;
+
+ if (len1 > TM_DATETIME_BUFFER_SIZE || len2 > TM_DATETIME_BUFFER_SIZE)
+ {
+ cli_msg(9003, "Format string too long");
+ return;
+ }
+
+ struct timeformat *old_tf = c->tf;
+ struct timeformat *new_tf = mb_allocz(c->pool, sizeof(struct timeformat));
+ new_tf->fmt1 = memcpy(mb_alloc(c->pool, len1), tf.fmt1, len1);
+ new_tf->fmt2 = tf.fmt2 ? memcpy(mb_alloc(c->pool, len2), tf.fmt2, len2) : NULL;
+ new_tf->limit = tf.limit;
+ c->tf = new_tf;
+
+ if (old_tf)
+ {
+ mb_free((void *) old_tf->fmt1);
+ mb_free((void *) old_tf->fmt2);
+ mb_free(old_tf);
+ }
+
+ cli_msg(0, "");
+}
+
/* Hack for scheduled undo notification */
extern cli *cmd_reconfig_stored_cli;
#include "lib/resource.h"
#include "lib/event.h"
+#include "lib/timer.h"
#include "lib/tlists.h"
#include "conf/conf.h"
void *rover; /* Private to continuation routine */
int last_reply;
int restricted; /* CLI is restricted to read-only commands */
+ struct timeformat *tf; /* Time format override */
struct linpool *parser_pool; /* Pool used during parsing */
struct linpool *show_pool; /* Pool used during route show */
byte *ring_buf; /* Ring buffer for asynchronous messages */
void cli_printf(cli *, int, char *, ...);
#define cli_msg(x...) cli_printf(this_cli, x)
void cli_set_log_echo(cli *, uint mask, uint size);
+void cli_set_timeformat(cli *c, const struct timeformat tf);
static inline void cli_separator(cli *c)
{ if (c->last_reply) cli_printf(c, -c->last_reply, ""); };
void
cmd_show_status(void)
{
+ struct timeformat *tf_base = this_cli->tf ?: &config->tf_base;
byte tim[TM_DATETIME_BUFFER_SIZE];
cli_msg(-1000, "BIRD " BIRD_VERSION);
- tm_format_time(tim, &config->tf_base, current_time());
+ tm_format_time(tim, tf_base, current_time());
cli_msg(-1011, "Router ID is %R", config->router_id);
cli_msg(-1011, "Hostname is %s", config->hostname);
cli_msg(-1011, "Current server time is %s", tim);
- tm_format_time(tim, &config->tf_base, boot_time);
+ tm_format_time(tim, tf_base, boot_time);
cli_msg(-1011, "Last reboot on %s", tim);
- tm_format_time(tim, &config->tf_base, config->load_time);
+ tm_format_time(tim, tf_base, config->load_time);
cli_msg(-1011, "Last reconfiguration on %s", tim);
graceful_restart_show_status();
CF_CLI(RESTRICT,,,[[Restrict current CLI session to safe commands]])
{ this_cli->restricted = 1; cli_msg(16, "Access restricted"); } ;
+CF_CLI_HELP(TIMEFORMAT, ..., [[Set time format for this CLI session]])
+CF_CLI(TIMEFORMAT, timeformat_spec, \"<format1>\" [limit \"format2\"] | iso (short | long) [ ms | us ], [[Set time format for this CLI session]])
+{ cli_set_timeformat(this_cli, $2); } ;
+
+CF_CLI_OPT(TIMEFORMAT ISO)
+CF_CLI_OPT(TIMEFORMAT SHORT)
+CF_CLI_OPT(TIMEFORMAT LONG)
+CF_CLI_OPT(TIMEFORMAT MS)
+CF_CLI_OPT(TIMEFORMAT US)
+
proto_patt:
CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$.ptr = $1; $$.patt = 0; }
| ALL { $$.ptr = NULL; $$.patt = 1; }
buf[0] = 0;
if (p->proto->get_status)
p->proto->get_status(p, buf);
- tm_format_time(tbuf, &config->tf_proto, p->last_state_change);
+ tm_format_time(tbuf, (this_cli->tf ?: &config->tf_proto), p->last_state_change);
cli_msg(-1002, "%-10s %-10s %-10s %-6s %-12s %s",
p->name,
p->proto->name,
void (*get_route_info)(struct rte *, byte *buf);
struct nexthop *nh;
- tm_format_time(tm, &config->tf_route, e->lastmod);
+ tm_format_time(tm, (c->tf ?: &config->tf_route), e->lastmod);
if (ipa_nonzero(a->from) && !ipa_equal(a->from, a->nh.gw))
bsprintf(from, " from %I", a->from);
else
byte dbuf[BFD_DIAG_BUFFER_SIZE];
byte tbuf[TM_DATETIME_BUFFER_SIZE];
- tm_format_time(tbuf, &config->tf_proto, s->last_state_change);
+ tm_format_time(tbuf, (this_cli->tf ?: &config->tf_proto), s->last_state_change);
if (!details)
{