diff options
author | Christian Hopps <chopps@gmail.com> | 2024-02-14 16:04:11 +0100 |
---|---|---|
committer | Christian Hopps <chopps@labn.net> | 2024-02-19 00:53:37 +0100 |
commit | 4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4 (patch) | |
tree | 6b1b90eace15b70e08b5b487c97b5ebfbe06962f /lib/mgmt_fe_client.c | |
parent | lib: always call new notification hooks too (diff) | |
download | frr-4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4.tar.xz frr-4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4.zip |
lib: mgmtd: add xpath arg to notification message
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/mgmt_fe_client.c')
-rw-r--r-- | lib/mgmt_fe_client.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/mgmt_fe_client.c b/lib/mgmt_fe_client.c index 9f98a241f..bfdecedc4 100644 --- a/lib/mgmt_fe_client.c +++ b/lib/mgmt_fe_client.c @@ -504,7 +504,8 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client, struct mgmt_msg_notify_data *notify_msg; struct mgmt_msg_tree_data *tree_msg; struct mgmt_msg_error *err_msg; - char *notify_data = NULL; + const char *data = NULL; + size_t dlen; debug_fe_client("Got native message for session-id %" PRIu64, msg->refer_id); @@ -563,20 +564,17 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client, return; } - if (notify_msg->result_type != LYD_LYB && - !MGMT_MSG_VALIDATE_NUL_TERM(notify_msg, msg_len)) { + data = mgmt_msg_native_data_decode(notify_msg, msg_len); + if (!data) { log_err_fe_client("Corrupt error msg recv"); return; } - if (notify_msg->result_type == LYD_JSON) - notify_data = (char *)notify_msg->result; - else - notify_data = - yang_convert_lyd_format(notify_msg->result, - msg_len, - notify_msg->result_type, - LYD_JSON, true); - if (!notify_data) { + dlen = mgmt_msg_native_data_len_decode(notify_msg, msg_len); + if (notify_msg->result_type != LYD_JSON) + data = yang_convert_lyd_format(data, dlen, + notify_msg->result_type, + LYD_JSON, true); + if (!data) { log_err_fe_client("Can't convert format %d to JSON", notify_msg->result_type); return; @@ -588,11 +586,10 @@ static void fe_client_handle_native_msg(struct mgmt_fe_client *client, session->client->cbs .async_notification(client, client->user_data, session->client_id, - session->user_ctx, - notify_data); + session->user_ctx, data); } if (notify_msg->result_type != LYD_JSON) - darr_free(notify_data); + darr_free(data); break; default: log_err_fe_client("unknown native message session-id %" PRIu64 |