netopeer2: Add upstream patch to get submodules when listing modules

This commit is contained in:
Mattias Walström
2023-12-11 09:10:52 +01:00
committed by Tobias Waldekranz
parent 797d69e774
commit 5adff79ad7
@@ -0,0 +1,38 @@
diff --git a/src/netconf_monitoring.c b/src/netconf_monitoring.c
index 467338b..4280a7f 100644
--- a/src/netconf_monitoring.c
+++ b/src/netconf_monitoring.c
@@ -273,11 +273,14 @@ np2srv_ncm_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const cha
{
struct lyd_node *root = NULL, *cont, *list;
const struct lys_module *mod;
+ const struct lysp_submodule *submod;
sr_conn_ctx_t *conn;
struct ly_ctx *ly_ctx;
char **cpblts;
char *time_str, buf[11];
uint32_t i;
+ LY_ARRAY_COUNT_TYPE u;
+ struct timespec ts;
/* context is locked while the callback is executed */
conn = sr_session_get_connection(session);
@@ -320,6 +323,18 @@ np2srv_ncm_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const cha
lyd_new_list(cont, NULL, "schema", 0, &list, mod->name, mod->revision ? mod->revision : "", "yin");
lyd_new_term(list, NULL, "namespace", mod->ns, 0, NULL);
lyd_new_term(list, NULL, "location", "NETCONF", 0, NULL);
+
+ LY_ARRAY_FOR(mod->parsed->includes, u) {
+ submod = mod->parsed->includes[u].submodule;
+
+ lyd_new_list(cont, NULL, "schema", 0, &list, submod->name, submod->revs ? submod->revs[0].date : "", "yang");
+ lyd_new_term(list, NULL, "namespace", mod->ns, 0, NULL);
+ lyd_new_term(list, NULL, "location", "NETCONF", 0, NULL);
+
+ lyd_new_list(cont, NULL, "schema", 0, &list, submod->name, submod->revs ? submod->revs[0].date : "", "yin");
+ lyd_new_term(list, NULL, "namespace", mod->ns, 0, NULL);
+ lyd_new_term(list, NULL, "location", "NETCONF", 0, NULL);
+ }
}
/* sessions */