summaryrefslogtreecommitdiff
path: root/lib/mgmt_be_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mgmt_be_client.c')
-rw-r--r--lib/mgmt_be_client.c55
1 files changed, 6 insertions, 49 deletions
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 286555c564..589bf82c95 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -311,13 +311,15 @@ static int be_client_send_error(struct mgmt_be_client *client, uint64_t txn_id,
return ret;
}
-void mgmt_be_send_notification(struct lyd_node *tree)
+static int mgmt_be_send_notification(void *__be_client, const char *xpath,
+ const struct lyd_node *tree)
{
struct mgmt_be_client *client = __be_client;
struct mgmt_msg_notify_data *msg = NULL;
LYD_FORMAT format = LYD_JSON;
uint8_t **darrp;
LY_ERR err;
+ int ret = 0;
assert(tree);
@@ -339,6 +341,7 @@ void mgmt_be_send_notification(struct lyd_node *tree)
flog_err(EC_LIB_LIBYANG,
"%s: error creating notification data: %s", __func__,
ly_strerrcode(err));
+ ret = 1;
goto done;
}
@@ -346,53 +349,7 @@ void mgmt_be_send_notification(struct lyd_node *tree)
mgmt_msg_native_get_msg_len(msg), false);
done:
mgmt_msg_native_free_msg(msg);
- lyd_free_all(tree);
-}
-
-/*
- * Convert old style NB notification data into new MGMTD YANG tree and send.
- */
-static int mgmt_be_notification_send(void *arg, const char *xpath,
- struct list *args)
-{
- struct lyd_node *root = NULL;
- struct lyd_node *dnode;
- struct yang_data *data;
- struct listnode *ln;
- LY_ERR err;
-
- debug_be_client("%s: sending notification: %s", __func__, xpath);
-
- /*
- * Convert yang data args list to a libyang data tree
- */
- for (ALL_LIST_ELEMENTS_RO(args, ln, data)) {
- err = lyd_new_path(root, ly_native_ctx, data->xpath,
- data->value, LYD_NEW_PATH_UPDATE, &dnode);
- if (err != LY_SUCCESS) {
-lyerr:
- flog_err(EC_LIB_LIBYANG,
- "%s: error creating notification data: %s",
- __func__, ly_strerrcode(err));
- if (root)
- lyd_free_all(root);
- return 1;
- }
- if (!root) {
- root = dnode;
- while (root->parent)
- root = lyd_parent(root);
- }
- }
-
- if (!root) {
- err = lyd_new_path(NULL, ly_native_ctx, xpath, "", 0, &root);
- if (err)
- goto lyerr;
- }
-
- mgmt_be_send_notification(root);
- return 0;
+ return ret;
}
static int mgmt_be_send_txn_reply(struct mgmt_be_client *client_ctx,
@@ -1202,7 +1159,7 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
"BE-client", debug_check_be_client());
/* Hook to receive notifications */
- hook_register_arg(nb_notification_send, mgmt_be_notification_send,
+ hook_register_arg(nb_notification_tree_send, mgmt_be_send_notification,
client);
debug_be_client("Initialized client '%s'", client_name);