summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-11-09 14:34:42 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-11-27 09:09:35 -0500
commite1a1880de3e9da60f72198924fe3407f7bbc975d (patch)
treecbf777f55ae78c3833290b4213dbd68b53ef6263 /lib/zclient.c
parent7ea7b86e2bab5309f5d431806c9149bdd2ee2ead (diff)
*: Make zapi route install Notifications optional
Allow the higher level protocol to specify if it would like to receive notifications about it's routes that it has installed. I've purposely made it part of zclient_new_notify because we need to track the routes on a per daemon basis only. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index e769906012..655e4e1a80 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -52,8 +52,11 @@ socklen_t zclient_addr_len;
/* This file local debug flag. */
int zclient_debug = 0;
+struct zclient_options zclient_options_default = { .receive_notify = false };
+
/* Allocate zclient structure. */
-struct zclient *zclient_new(struct thread_master *master)
+struct zclient *zclient_new_notify(struct thread_master *master,
+ struct zclient_options *opt)
{
struct zclient *zclient;
zclient = XCALLOC(MTYPE_ZCLIENT, sizeof(struct zclient));
@@ -63,6 +66,8 @@ struct zclient *zclient_new(struct thread_master *master)
zclient->wb = buffer_new(0);
zclient->master = master;
+ zclient->receive_notify = opt->receive_notify;
+
return zclient;
}
@@ -190,7 +195,7 @@ void zclient_reset(struct zclient *zclient)
* @param zclient a pointer to zclient structure
* @return socket fd just to make sure that connection established
* @see zclient_init
- * @see zclient_new
+ * @see zclient_new_notify
*/
int zclient_socket_connect(struct zclient *zclient)
{
@@ -346,6 +351,11 @@ static int zebra_hello_send(struct zclient *zclient)
zclient_create_header(s, ZEBRA_HELLO, VRF_DEFAULT);
stream_putc(s, zclient->redist_default);
stream_putw(s, zclient->instance);
+ if (zclient->receive_notify)
+ stream_putc(s, 1);
+ else
+ stream_putc(s, 0);
+
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
}