summaryrefslogtreecommitdiff
path: root/lib/mgmt_be_client.c
diff options
context:
space:
mode:
authorChristian Hopps <chopps@gmail.com>2024-02-14 10:04:11 -0500
committerChristian Hopps <chopps@labn.net>2024-02-18 18:53:37 -0500
commit4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4 (patch)
tree6b1b90eace15b70e08b5b487c97b5ebfbe06962f /lib/mgmt_be_client.c
parent1d4ea437e4a4fced3fce6e441952fdea8d94af80 (diff)
lib: mgmtd: add xpath arg to notification message
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/mgmt_be_client.c')
-rw-r--r--lib/mgmt_be_client.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 589bf82c95..5896db1e58 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -333,6 +333,8 @@ static int mgmt_be_send_notification(void *__be_client, const char *xpath,
msg->code = MGMT_MSG_CODE_NOTIFY;
msg->result_type = format;
+ mgmt_msg_native_xpath_encode(msg, xpath);
+
darrp = mgmt_msg_native_get_darrp(msg);
err = yang_print_tree_append(darrp, tree, format,
(LYD_PRINT_SHRINK | LYD_PRINT_WD_EXPLICIT |
@@ -921,27 +923,40 @@ static void be_client_handle_notify(struct mgmt_be_client *client, void *msgbuf,
{
struct mgmt_msg_notify_data *notif_msg = msgbuf;
struct nb_node *nb_node;
- char notif[XPATH_MAXLEN];
struct lyd_node *dnode;
+ const char *data;
+ const char *notif;
LY_ERR err;
debug_be_client("Received notification for client %s", client->name);
- err = yang_parse_notification(notif_msg->result_type,
- (char *)notif_msg->result, &dnode);
- if (err)
+ notif = mgmt_msg_native_xpath_data_decode(notif_msg, msg_len, data);
+ if (!notif || !data) {
+ log_err_be_client("Corrupt notify msg");
return;
-
- lysc_path(dnode->schema, LYSC_PATH_DATA, notif, sizeof(notif));
+ }
nb_node = nb_node_find(notif);
- if (!nb_node || !nb_node->cbs.notify) {
- debug_be_client("No notification callback for %s", notif);
- goto cleanup;
+ if (!nb_node) {
+ log_err_be_client("No schema found for notification: %s", notif);
+ return;
+ }
+
+ if (!nb_node->cbs.notify) {
+ debug_be_client("No notification callback for: %s", notif);
+ return;
+ }
+
+ err = yang_parse_notification(notif, notif_msg->result_type, data,
+ &dnode);
+ if (err) {
+ log_err_be_client("Can't parse notification data for: %s",
+ notif);
+ return;
}
nb_callback_notify(nb_node, notif, dnode);
-cleanup:
+
lyd_free_all(dnode);
}