#include "nest/cli.h"
#include "conf/conf.h"
#include "lib/string.h"
+#include "client/reply_codes.h"
pool *cli_pool;
+static list cli_client_list;
static byte *
cli_alloc_out(cli *c, int size)
c->parser_pool = lp_new(c->pool, 4096);
c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE);
ev_schedule(c->event);
+ add_tail(&cli_client_list, &c->cli_client_node);
return c;
}
c->cleanup(c);
if (c == cmd_reconfig_stored_cli)
cmd_reconfig_stored_cli = NULL;
+ rem2_node(&c->cli_client_node);
rfree(c->pool);
}
cli_pool = rp_new(&root_pool, "CLI");
init_list(&cli_log_hooks);
cli_log_inited = 1;
+ init_list(&cli_client_list);
+}
+
+/**
+ * cli_notify_all_clients - send push notification to all cli clients
+ *
+ * Send a notification to all command line clients about some news.
+ * Client could then send a request for pulling symbols.
+ */
+void
+cli_notify_all_clients(void)
+{
+ struct cli *cli;
+ node *n;
+ WALK_LIST2(cli, n, cli_client_list, cli_client_node)
+ {
+ cli_printf(cli, RC_NOTIFY, "");
+ cli_write_trigger(cli);
+ }
}
typedef struct cli {
node n; /* Node in list of all log hooks */
+ node cli_client_node; /* Node in list of all cli clients */
pool *pool;
void *priv; /* Private to sysdep layer */
byte *rx_buf, *rx_pos, *rx_aux; /* sysdep */
void cli_kick(cli *);
void cli_written(cli *);
void cli_echo(uint class, byte *msg);
+void cli_notify_all_clients(void);
static inline int cli_access_restricted(void)
{
struct iface *i;
WALK_LIST(i, iface_list)
- cli_msg(RC_INTERFACE_NAME, "\"%s\"", i->name);
+ if (!(i->flags & IF_SHUTDOWN))
+ cli_msg(RC_INTERFACE_NAME, "\"%s\"", i->name);
cli_msg(0, "");
}
#endif
if (c & IF_CHANGE_DOWN)
+ {
neigh_if_down(i);
- if (c & IF_CHANGE_DOWN)
WALK_LIST(a, i->addrs)
{
a->flags = (i->flags & ~IA_FLAGS) | (a->flags & IA_FLAGS);
ifa_notify_change_(IF_CHANGE_DOWN, a);
}
+ cli_notify_all_clients();
+ }
+
WALK_LIST(p, proto_list)
if_send_notify(p, c, i);
if (c & IF_CHANGE_UP)
+ {
WALK_LIST(a, i->addrs)
{
a->flags = (i->flags & ~IA_FLAGS) | (a->flags & IA_FLAGS);
ifa_notify_change_(IF_CHANGE_UP, a);
}
- if (c & IF_CHANGE_UP)
neigh_if_up(i);
+ cli_notify_all_clients();
+ }
if ((c & (IF_CHANGE_UP | IF_CHANGE_DOWN | IF_CHANGE_LINK)) == IF_CHANGE_LINK)
neigh_if_link(i);