From f90dde08f364c3d5428b92985a9e7adf490f79da Mon Sep 17 00:00:00 2001 From: Pavel Tvrdik Date: Mon, 25 Apr 2016 16:48:39 +0200 Subject: [PATCH] BIRD daemon notifies the client about new symbol set BIRD pushes notification to the client about new symbol set and then the client should request a package with all symbols (`refresh symbols`). --- client/client.c | 13 ++++++++++--- client/reply_codes.h | 1 + conf/conf.c | 3 +++ sysdep/unix/main.c | 5 +++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client/client.c b/client/client.c index 4f7cce1de..5d8f1b379 100644 --- a/client/client.c +++ b/client/client.c @@ -318,12 +318,18 @@ cli_get_symbol_maxlen(void) } static void -server_got_symbol(int reply_code, const char *name) +process_internal_message(int reply_code, const char *name) { u32 flag = 0; switch (reply_code) { + case RC_NOTIFY: + if (interactive) + retrieve_symbols(); + return; + + /* Symbols */ case RC_CONSTANT_NAME: flag = CLI_SF_CONSTANT; break; case RC_VARIABLE_NAME: flag = CLI_SF_VARIABLE; break; case RC_FILTER_NAME: flag = CLI_SF_FILTER; break; @@ -337,7 +343,8 @@ server_got_symbol(int reply_code, const char *name) return; } - add_to_symbols(flag, name); + if (flag && name && *name) + add_to_symbols(flag, name); } #define PRINTF(LEN, PARGS...) do { if (!skip_input) len = printf(PARGS); } while(0) @@ -358,7 +365,7 @@ server_got_reply(char *x) { if (code >= 3000 && code < 4000) { - server_got_symbol(code, x+5); + process_internal_message(code, x+5); } else if (code) { diff --git a/client/reply_codes.h b/client/reply_codes.h index 5fd399e83..2b2227086 100644 --- a/client/reply_codes.h +++ b/client/reply_codes.h @@ -81,6 +81,7 @@ enum reply_code { RC_VARIABLE_NAME = 3006, RC_TEMPLATE_NAME = 3007, RC_INTERFACE_NAME = 3008, + RC_NOTIFY = 3009, /* Daemon notifies the client about new symbol set */ RC_REPLY_TOO_LONG = 8000, RC_ROUTE_NOT_FOUND = 8001, diff --git a/conf/conf.c b/conf/conf.c index 3fd10ad82..4975c2f3c 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -448,6 +448,7 @@ config_undo(void) } extern void cmd_reconfig_undo_notify(void); +extern void cmd_reconfig_msg(int r); static void config_timeout(struct timer *t) @@ -458,6 +459,8 @@ config_timeout(struct timer *t) int r = config_undo(); if (r < 0) log(L_ERR "Undo request failed"); + + cmd_reconfig_msg(r); } void diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 8796ab9c3..5504a7717 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -33,6 +33,7 @@ #include "nest/locks.h" #include "conf/conf.h" #include "filter/filter.h" +#include "client/reply_codes.h" #include "unix.h" #include "krt.h" @@ -269,12 +270,12 @@ cmd_check_config(char *name) config_free(conf); } -static void +void cmd_reconfig_msg(int r) { switch (r) { - case CONF_DONE: cli_msg( 3, "Reconfigured"); break; + case CONF_DONE: cli_msg( 3, "Reconfigured"); cli_msg(RC_NOTIFY, ""); cli_msg(19, "Nothing to do"); break; case CONF_PROGRESS: cli_msg( 4, "Reconfiguration in progress"); break; case CONF_QUEUED: cli_msg( 5, "Reconfiguration already in progress, queueing new config"); break; case CONF_UNQUEUED: cli_msg(17, "Reconfiguration already in progress, removing queued config"); break; -- 2.47.2