summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/mgmt_be_client.c21
-rw-r--r--lib/mgmt_msg_native.c3
-rw-r--r--lib/mgmt_msg_native.h1
-rw-r--r--lib/northbound.h9
-rw-r--r--lib/northbound_notif.c18
5 files changed, 49 insertions, 3 deletions
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 155d56aa6..a443d83b5 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -322,8 +322,6 @@ static int __send_notification(struct mgmt_be_client *client, const char *xpath,
LY_ERR err;
int ret = 0;
- assert(tree);
-
debug_be_client("%s: sending %sYANG %snotification: %s", __func__,
op == NOTIFY_OP_DS_DELETE ? "delete "
: op == NOTIFY_OP_DS_REPLACE ? "replace "
@@ -1155,6 +1153,22 @@ static void be_client_handle_notify(struct mgmt_be_client *client, void *msgbuf,
}
/*
+ * Process a notify select msg
+ */
+static void be_client_handle_notify_select(struct mgmt_be_client *client, void *msgbuf,
+ size_t msg_len)
+{
+ struct mgmt_msg_notify_select *msg = msgbuf;
+ const char **selectors = NULL;
+
+ debug_be_client("Received notify-select for client %s", client->name);
+
+ if (msg_len >= sizeof(*msg))
+ selectors = mgmt_msg_native_strings_decode(msg, msg_len, msg->selectors);
+ nb_notif_set_filters(selectors, msg->replace);
+}
+
+/*
* Handle a native encoded message
*
* We don't create transactions with native messaging.
@@ -1175,6 +1189,9 @@ static void be_client_handle_native_msg(struct mgmt_be_client *client,
case MGMT_MSG_CODE_NOTIFY:
be_client_handle_notify(client, msg, msg_len);
break;
+ case MGMT_MSG_CODE_NOTIFY_SELECT:
+ be_client_handle_notify_select(client, msg, msg_len);
+ break;
default:
log_err_be_client("unknown native message txn-id %" PRIu64
" req-id %" PRIu64 " code %u to client %s",
diff --git a/lib/mgmt_msg_native.c b/lib/mgmt_msg_native.c
index b85c7d1b6..46dfe7f2e 100644
--- a/lib/mgmt_msg_native.c
+++ b/lib/mgmt_msg_native.c
@@ -14,7 +14,8 @@ DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_ERROR, "native error msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_GET_TREE, "native get tree msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_TREE_DATA, "native tree data msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_GET_DATA, "native get data msg");
-DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_NOTIFY, "native get data msg");
+DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_NOTIFY, "native notify msg");
+DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_NOTIFY_SELECT, "native notify select msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_EDIT, "native edit msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_EDIT_REPLY, "native edit reply msg");
DEFINE_MTYPE(MSG_NATIVE, MSG_NATIVE_RPC, "native RPC msg");
diff --git a/lib/mgmt_msg_native.h b/lib/mgmt_msg_native.h
index 4076977a2..73303846e 100644
--- a/lib/mgmt_msg_native.h
+++ b/lib/mgmt_msg_native.h
@@ -159,6 +159,7 @@ DECLARE_MTYPE(MSG_NATIVE_GET_TREE);
DECLARE_MTYPE(MSG_NATIVE_TREE_DATA);
DECLARE_MTYPE(MSG_NATIVE_GET_DATA);
DECLARE_MTYPE(MSG_NATIVE_NOTIFY);
+DECLARE_MTYPE(MSG_NATIVE_NOTIFY_SELECT);
DECLARE_MTYPE(MSG_NATIVE_EDIT);
DECLARE_MTYPE(MSG_NATIVE_EDIT_REPLY);
DECLARE_MTYPE(MSG_NATIVE_RPC);
diff --git a/lib/northbound.h b/lib/northbound.h
index b65cc1000..bd802e088 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -1815,6 +1815,15 @@ extern struct lyd_node *nb_op_updatef(struct lyd_node *tree, const char *path, c
extern struct lyd_node *nb_op_vupdatef(struct lyd_node *tree, const char *path, const char *val_fmt,
va_list ap);
+/**
+ * nb_notif_set_filters() - add or replace notification filters
+ * @selectors: darr array of selector (filter) xpath strings, can be NULL if
+ * @replace is true. nb_notif_set_filters takes ownership of this
+ * array and the contained darr strings.
+ * @replace: true to replace existing set otherwise append.
+ */
+extern void nb_notif_set_filters(const char **selectors, bool replace);
+
extern void nb_notif_init(struct event_loop *loop);
extern void nb_notif_terminate(void);
diff --git a/lib/northbound_notif.c b/lib/northbound_notif.c
index c64771ebe..b75c86561 100644
--- a/lib/northbound_notif.c
+++ b/lib/northbound_notif.c
@@ -64,6 +64,8 @@ struct event_loop *nb_notif_master;
struct event *nb_notif_timer;
void *nb_notif_walk;
+const char **nb_notif_filters;
+
/*
* We maintain a queue of change lists one entry per query and notification send
* action
@@ -635,6 +637,20 @@ static void nb_notif_set_walk_timer(void)
&nb_notif_timer);
}
+void nb_notif_set_filters(const char **selectors, bool replace)
+{
+ const char **csp;
+
+ if (replace) {
+ darr_free_free(nb_notif_filters);
+ nb_notif_filters = selectors;
+ return;
+ }
+ darr_foreach_p (selectors, csp)
+ *darr_append(nb_notif_filters) = *csp;
+ darr_free(selectors);
+}
+
void nb_notif_init(struct event_loop *tm)
{
nb_notif_master = tm;
@@ -659,4 +675,6 @@ void nb_notif_terminate(void)
while ((group = op_changes_group_next()))
op_changes_group_free(group);
+
+ darr_free_free(nb_notif_filters);
}