summaryrefslogtreecommitdiff
path: root/mgmtd
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2024-09-16 21:34:10 -0400
committerChristian Hopps <chopps@labn.net>2024-09-17 22:27:36 -0400
commitc5df98aece868db29743b72e4a24112067944bd4 (patch)
tree93d5d8df353a778755a0e7dac412812f030c5647 /mgmtd
parentda96ad08cd669c8abf856069df66c9d5ef0d1539 (diff)
mgmtd: add ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'mgmtd')
-rw-r--r--mgmtd/mgmt.c3
-rw-r--r--mgmtd/mgmt_fe_adapter.c25
2 files changed, 28 insertions, 0 deletions
diff --git a/mgmtd/mgmt.c b/mgmtd/mgmt.c
index cfadad4829..02c54b9215 100644
--- a/mgmtd/mgmt.c
+++ b/mgmtd/mgmt.c
@@ -57,6 +57,9 @@ void mgmt_init(void)
/* Initialize MGMTD Transaction module */
mgmt_txn_init(mm, mm->master);
+ /* Add yang-library module */
+ yang_module_load("ietf-yang-library", NULL);
+
/* Initialize the MGMTD Frontend Adapter Module */
mgmt_fe_adapter_init(mm->master);
diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c
index 8d305ed52f..32f28a5774 100644
--- a/mgmtd/mgmt_fe_adapter.c
+++ b/mgmtd/mgmt_fe_adapter.c
@@ -1337,6 +1337,31 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session,
goto done;
}
+ /* Check for yang-library shortcut */
+ if (nb_oper_is_yang_lib_query(msg->xpath)) {
+ struct lyd_node *ylib = NULL;
+ LY_ERR err;
+
+ err = ly_ctx_get_yanglib_data(ly_native_ctx, &ylib, "%u",
+ ly_ctx_get_change_count(
+ ly_native_ctx));
+ if (err) {
+ fe_adapter_send_error(session, req_id, false, err,
+ "Error getting yang-library data, session-id: %" PRIu64
+ " error: %s",
+ session->session_id,
+ ly_last_errmsg());
+ } else {
+ yang_lyd_trim_xpath(&ylib, msg->xpath);
+ (void)fe_adapter_send_tree_data(session, req_id, false,
+ msg->result_type,
+ wd_options, ylib, 0);
+ }
+ if (ylib)
+ lyd_free_all(ylib);
+ goto done;
+ }
+
switch (msg->datastore) {
case MGMT_MSG_DATASTORE_CANDIDATE:
ds_id = MGMTD_DS_CANDIDATE;