From be3001acf5f4c5858505b7cf79693c684f600df4 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 23 Nov 2023 18:44:17 +0100 Subject: [PATCH] XML: Add XML_FLAG_ANYDATA to mimic an xml node to be ANYDATA --- Makefile.in | 2 +- lib/clixon/clixon_xml.h | 1 + lib/src/clixon_datastore_write.c | 6 ++++-- lib/src/clixon_path.c | 10 +++++----- lib/src/clixon_xml.c | 2 +- lib/src/clixon_xml_bind.c | 7 ++++--- lib/src/clixon_yang_schema_mount.c | 5 +++-- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4c6000ce..146130a8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -180,6 +180,6 @@ loc: find . -name '*.[chyl]' -type f | xargs wc -l | tail -1 2> /dev/null TAGS: - find $(srcdir) -name '*.[chyl]' -type f | grep -v \.tab\.[ch] | grep -v lex.*.c | grep -v .yy.c | etags - + find $(srcdir) -not \( -type d \( -path './.git' -o -path './docker' -o -path './doc' \) -prune \) -name '*.[chyl]' -type f | grep -v \.tab\.[ch] | grep -v lex.*.c | grep -v .yy.c | etags - diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index 9ef7201d..67312c6a 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -202,6 +202,7 @@ enum format_enum{ #define XML_FLAG_DEFAULT 0x40 /* Added when a value is set as default @see xml_default */ #define XML_FLAG_TOP 0x80 /* Top datastore symbol */ #define XML_FLAG_BODYKEY 0x100 /* Text parsing key to be translated from body to key */ +#define XML_FLAG_ANYDATA 0x200 /* Treat as anydata, eg mount-points before bound */ /* * Prototypes diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index ba590a50..85b136c6 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -816,7 +816,8 @@ text_modify(clicon_handle h, Any "operation" attributes present on subelements of an anyxml node are ignored by the NETCONF server.*/ if (yang_keyword_get(y0) == Y_ANYXML || - yang_keyword_get(y0) == Y_ANYDATA){ + yang_keyword_get(y0) == Y_ANYDATA || + xml_flag(x1, XML_FLAG_ANYDATA)){ if (op == OP_NONE) break; if (op==OP_MERGE && !permit && xnacm){ @@ -932,7 +933,8 @@ text_modify(clicon_handle h, /* Check if xc is unresolved mountpoint, ie no yang mount binding yet */ if ((ismount = xml_yang_mount_get(h, x1c, NULL, &mount_yspec)) < 0) goto done; - if (ismount && mount_yspec == NULL){ + if (ismount && mount_yspec == NULL && + !xml_flag(x1c, XML_FLAG_ANYDATA)){ ret = 1; } else{ diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index eb86ec06..b126a1d3 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -1585,7 +1585,7 @@ instance_id_resolve(clixon_path *cplist, * * @param[in] xt Top xml-tree where to search * @param[in] yt Yang statement of top symbol (can be yang-spec if top-level) - * @param[in] cplist Lisp of clixon-path + * @param[in] cplist List of clixon-path * @param[out] xvec Vector of xml-trees. Vector must be free():d after use * @retval 1 OK with found xml nodes in xvec (if any) * @retval 0 Fail fail: eg no yang @@ -1779,10 +1779,10 @@ clixon_xml_find_api_path(cxobj *xt, * @see RFC7950 Sec 9.13 */ int -clixon_xml_find_instance_id(cxobj *xt, - yang_stmt *yt, - cxobj ***xvec, - int *xlen, +clixon_xml_find_instance_id(cxobj *xt, + yang_stmt *yt, + cxobj ***xvec, + int *xlen, const char *format, ...) { diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 11a2f6d5..8618a33b 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -2228,7 +2228,7 @@ xml_copy_one(cxobj *x0, default: break; } - xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT | XML_FLAG_TOP)); /* Maybe more flags */ + xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT | XML_FLAG_TOP | XML_FLAG_ANYDATA)); /* Maybe more flags */ retval = 0; done: return retval; diff --git a/lib/src/clixon_xml_bind.c b/lib/src/clixon_xml_bind.c index eacfc560..d943aa96 100644 --- a/lib/src/clixon_xml_bind.c +++ b/lib/src/clixon_xml_bind.c @@ -173,8 +173,7 @@ populate_self_parent(cxobj *xt, y = xml_spec(xsibling); goto set; } - xp = xml_parent(xt); - if (xp == NULL){ + if ((xp = xml_parent(xt)) == NULL){ if (xerr && netconf_bad_element_xml(xerr, "application", name, "Missing parent") < 0) goto done; @@ -469,8 +468,10 @@ xml_bind_yang0_opt(clicon_handle h, else{ if ((ret = yang_schema_yanglib_parse_mount(h, xt)) < 0) goto done; - if (ret == 0) + if (ret == 0){ /* Special flag if mount-point but no yanglib */ + xml_flag_set(xt, XML_FLAG_ANYDATA); goto ok; + } /* Try again */ if ((ret = xml_yang_mount_get(h, xt, NULL, &yspec1)) < 0) goto done; diff --git a/lib/src/clixon_yang_schema_mount.c b/lib/src/clixon_yang_schema_mount.c index fc4a05f5..1dbd81fe 100644 --- a/lib/src/clixon_yang_schema_mount.c +++ b/lib/src/clixon_yang_schema_mount.c @@ -214,7 +214,7 @@ yang_mount_set(yang_stmt *y, * @param[in] h Clixon handle * @param[in] x XML mount-point node * @param[out] vallevel Do or dont do full RFC 7950 validation if given - * @param[out] yspec YANG stmt spec + * @param[out] yspec YANG stmt spec of mount-point (if ret is 1) * @retval 1 x is a mount-point: yspec may be set * @retval 0 x is not a mount point * @retval -1 Error @@ -651,7 +651,8 @@ yang_schema_mount_statistics(clicon_handle h, * * @param[in] h Clixon handle * @param[in] xt - * @retval 0 OK + * @retval 1 OK + * @retval 0 No yanglib or problem when parsing yanglib * @retval -1 Error */ int