summaryrefslogtreecommitdiffstats
path: root/mgmtd/mgmt_fe_adapter.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-29 21:50:26 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2024-01-31 01:20:13 +0100
commit4317c8ffa6675c9f91b710c7c75739706e1edfef (patch)
treecac992fbf82d4f96cb323a2f4746c9c870dec17d /mgmtd/mgmt_fe_adapter.c
parentyang: add more ietf models (diff)
downloadfrr-4317c8ffa6675c9f91b710c7c75739706e1edfef.tar.xz
frr-4317c8ffa6675c9f91b710c7c75739706e1edfef.zip
mgmtd: add support for with-defaults parameter to get-data
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'mgmtd/mgmt_fe_adapter.c')
-rw-r--r--mgmtd/mgmt_fe_adapter.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c
index 95f925d30..acf77f552 100644
--- a/mgmtd/mgmt_fe_adapter.c
+++ b/mgmtd/mgmt_fe_adapter.c
@@ -1080,7 +1080,7 @@ mgmt_fe_adapter_handle_msg(struct mgmt_fe_client_adapter *adapter,
*/
static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
uint64_t req_id, bool short_circuit_ok,
- uint8_t result_type,
+ uint8_t result_type, uint32_t wd_options,
const struct lyd_node *tree,
int partial_error)
@@ -1105,8 +1105,7 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
darrp = mgmt_msg_native_get_darrp(msg);
ret = yang_print_tree_append(darrp, tree, result_type,
- (LYD_PRINT_WD_EXPLICIT |
- LYD_PRINT_WITHSIBLINGS));
+ (wd_options | LYD_PRINT_WITHSIBLINGS));
if (ret != LY_SUCCESS) {
MGMTD_FE_ADAPTER_ERR("Error building get-tree result for client %s session-id %" PRIu64
" req-id %" PRIu64
@@ -1147,6 +1146,7 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
char *xpath_resolved = NULL;
uint64_t req_id = msg->req_id;
uint64_t clients;
+ uint32_t wd_options;
bool simple_xpath;
LY_ERR err;
int ret;
@@ -1171,6 +1171,25 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
goto done;
}
+ switch (msg->defaults) {
+ case GET_DATA_DEFAULTS_EXPLICIT:
+ wd_options = LYD_PRINT_WD_EXPLICIT;
+ break;
+ case GET_DATA_DEFAULTS_TRIM:
+ wd_options = LYD_PRINT_WD_TRIM;
+ break;
+ case GET_DATA_DEFAULTS_ALL:
+ wd_options = LYD_PRINT_WD_ALL;
+ break;
+ case GET_DATA_DEFAULTS_ALL_ADD_TAG:
+ wd_options = LYD_PRINT_WD_IMPL_TAG;
+ break;
+ default:
+ fe_adapter_send_error(session, req_id, false, -EINVAL,
+ "Invalid defaults value %u for session-id: %" PRIu64,
+ msg->defaults, session->session_id);
+ goto done;
+ }
err = yang_resolve_snode_xpath(ly_native_ctx, msg->xpath, &snodes,
&simple_xpath);
@@ -1190,7 +1209,7 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
session->session_id);
fe_adapter_send_tree_data(session, req_id, false,
- msg->result_type, NULL, 0);
+ msg->result_type, wd_options, NULL, 0);
goto done;
}
@@ -1210,7 +1229,7 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
/* Create a GET-TREE request under the transaction */
ret = mgmt_txn_send_get_tree_oper(session->txn_id, req_id, clients,
msg->result_type, msg->flags,
- simple_xpath, msg->xpath);
+ wd_options, simple_xpath, msg->xpath);
if (ret) {
/* destroy the just created txn */
mgmt_destroy_txn(&session->txn_id);
@@ -1469,6 +1488,7 @@ int mgmt_fe_send_get_reply(uint64_t session_id, uint64_t txn_id,
int mgmt_fe_adapter_send_tree_data(uint64_t session_id, uint64_t txn_id,
uint64_t req_id, LYD_FORMAT result_type,
+ uint32_t wd_options,
const struct lyd_node *tree,
int partial_error, bool short_circuit_ok)
{
@@ -1480,7 +1500,8 @@ int mgmt_fe_adapter_send_tree_data(uint64_t session_id, uint64_t txn_id,
return -1;
ret = fe_adapter_send_tree_data(session, req_id, short_circuit_ok,
- result_type, tree, partial_error);
+ result_type, wd_options, tree,
+ partial_error);
mgmt_destroy_txn(&session->txn_id);