summaryrefslogtreecommitdiff
path: root/lib/yang.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-11-02 21:57:20 -0200
committerRenato Westphal <renato@opensourcerouting.org>2018-11-26 17:35:58 -0200
commit5e02643a64fb6aaaf95f6f9049020f392b5563d5 (patch)
treedfb4c936b5ed11d9cfb0f9f6e8a2daf02e41f3e5 /lib/yang.c
parent80243aef050c1f882a169b402ff5c50fed63b451 (diff)
lib: make it possible to create YANG data nodes containing state data
By default the data nodes created by yang_dnode_new() could contain only configuration data (LYD_OPT_CONFIG). Add a 'config_only' option to yang_dnode_new() so that it can create data nodes containing both configuration and state data. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/yang.c')
-rw-r--r--lib/yang.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/yang.c b/lib/yang.c
index 0e7ea3037e..660a54a22a 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -496,12 +496,18 @@ void *yang_dnode_get_entry(const struct lyd_node *dnode)
abort();
}
-struct lyd_node *yang_dnode_new(struct ly_ctx *ly_ctx)
+struct lyd_node *yang_dnode_new(struct ly_ctx *ly_ctx, bool config_only)
{
struct lyd_node *dnode;
+ int options;
+
+ if (config_only)
+ options = LYD_OPT_CONFIG;
+ else
+ options = LYD_OPT_DATA | LYD_OPT_DATA_NO_YANGLIB;
dnode = NULL;
- if (lyd_validate(&dnode, LYD_OPT_CONFIG, ly_ctx) != 0) {
+ if (lyd_validate(&dnode, options, ly_ctx) != 0) {
/* Should never happen. */
flog_err(EC_LIB_LIBYANG, "%s: lyd_validate() failed", __func__);
exit(1);