summaryrefslogtreecommitdiff
path: root/lib/mgmt_be_client.c
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-12-13 17:32:43 -0500
committerChristian Hopps <chopps@labn.net>2023-12-28 17:53:40 +0000
commit4e0147a05ebfa0ba1f262b1e191d3cbf1a44003d (patch)
treeaa2b0429196378f6ec2906a43fd4025ef9332f83 /lib/mgmt_be_client.c
parentad1ccb6e621b2050697e738457b1ac7a465dae71 (diff)
lib: add dedicated API functions for native msgs
- reorg native message header Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/mgmt_be_client.c')
-rw-r--r--lib/mgmt_be_client.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c
index 0200966663..2ffcd8f9fc 100644
--- a/lib/mgmt_be_client.c
+++ b/lib/mgmt_be_client.c
@@ -787,8 +787,8 @@ static enum nb_error be_client_send_tree_data_batch(const struct lyd_node *tree,
struct be_client_tree_data_batch_args *args = arg;
struct mgmt_be_client *client = args->client;
struct mgmt_msg_tree_data *tree_msg = NULL;
- uint8_t *buf = NULL;
bool more = false;
+ uint8_t **darrp;
LY_ERR err;
if (ret == NB_YIELD) {
@@ -798,26 +798,27 @@ static enum nb_error be_client_send_tree_data_batch(const struct lyd_node *tree,
if (ret != NB_OK)
goto done;
- darr_append_nz(buf, offsetof(typeof(*tree_msg), result));
- tree_msg = (typeof(tree_msg))buf;
- tree_msg->txn_id = args->txn_id;
+ tree_msg = mgmt_msg_native_alloc_msg(struct mgmt_msg_tree_data, 0,
+ MTYPE_MSG_NATIVE_TREE_DATA);
+ tree_msg->refer_id = args->txn_id;
tree_msg->req_id = args->req_id;
tree_msg->code = MGMT_MSG_CODE_TREE_DATA;
tree_msg->result_type = args->result_type;
tree_msg->more = more;
- err = yang_print_tree_append(&buf, tree, args->result_type,
+
+ darrp = mgmt_msg_native_get_darrp(tree_msg);
+ err = yang_print_tree_append(darrp, tree, args->result_type,
(LYD_PRINT_WD_EXPLICIT |
LYD_PRINT_WITHSIBLINGS));
- /* buf may have been reallocated and moved */
- tree_msg = (typeof(tree_msg))buf;
-
if (err) {
ret = NB_ERR;
goto done;
}
- (void)be_client_send_native_msg(client, buf, darr_len(buf), false);
+ (void)be_client_send_native_msg(client, tree_msg,
+ mgmt_msg_native_get_msg_len(tree_msg),
+ false);
done:
- darr_free(buf);
+ mgmt_msg_native_free_msg(tree_msg);
if (ret)
be_client_send_error(client, args->txn_id, args->req_id, false,
-EINVAL,
@@ -849,7 +850,7 @@ static void be_client_handle_get_tree(struct mgmt_be_client *client,
args = XMALLOC(MTYPE_MGMTD_BE_GT_CB_ARGS, sizeof(*args));
args->client = client;
- args->txn_id = get_tree_msg->txn_id;
+ args->txn_id = get_tree_msg->refer_id;
args->req_id = get_tree_msg->req_id;
args->result_type = get_tree_msg->result_type;
nb_oper_walk(get_tree_msg->xpath, NULL, 0, true, NULL, NULL,
@@ -865,7 +866,7 @@ static void be_client_handle_native_msg(struct mgmt_be_client *client,
struct mgmt_msg_header *msg,
size_t msg_len)
{
- uint64_t txn_id = msg->txn_id;
+ uint64_t txn_id = msg->refer_id;
switch (msg->code) {
case MGMT_MSG_CODE_GET_TREE:
@@ -876,7 +877,7 @@ static void be_client_handle_native_msg(struct mgmt_be_client *client,
" req-id %" PRIu64 " code %u to client %s",
txn_id, msg->req_id, msg->code,
client->name);
- be_client_send_error(client, msg->txn_id, msg->req_id, false, -1,
+ be_client_send_error(client, msg->refer_id, msg->req_id, false, -1,
"BE cilent %s recv msg unknown txn-id %" PRIu64,
client->name, txn_id);
break;