XML: Add XML_FLAG_ANYDATA to mimic an xml node to be ANYDATA

This commit is contained in:
Olof hagsand 2023-11-23 18:44:17 +01:00
parent cafbe7d200
commit be3001acf5
7 changed files with 19 additions and 14 deletions

View file

@ -180,6 +180,6 @@ loc:
find . -name '*.[chyl]' -type f | xargs wc -l | tail -1 2> /dev/null find . -name '*.[chyl]' -type f | xargs wc -l | tail -1 2> /dev/null
TAGS: 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 -

View file

@ -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_DEFAULT 0x40 /* Added when a value is set as default @see xml_default */
#define XML_FLAG_TOP 0x80 /* Top datastore symbol */ #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_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 * Prototypes

View file

@ -816,7 +816,8 @@ text_modify(clicon_handle h,
Any "operation" attributes present on subelements of an anyxml Any "operation" attributes present on subelements of an anyxml
node are ignored by the NETCONF server.*/ node are ignored by the NETCONF server.*/
if (yang_keyword_get(y0) == Y_ANYXML || 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) if (op == OP_NONE)
break; break;
if (op==OP_MERGE && !permit && xnacm){ 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 */ /* Check if xc is unresolved mountpoint, ie no yang mount binding yet */
if ((ismount = xml_yang_mount_get(h, x1c, NULL, &mount_yspec)) < 0) if ((ismount = xml_yang_mount_get(h, x1c, NULL, &mount_yspec)) < 0)
goto done; goto done;
if (ismount && mount_yspec == NULL){ if (ismount && mount_yspec == NULL &&
!xml_flag(x1c, XML_FLAG_ANYDATA)){
ret = 1; ret = 1;
} }
else{ else{

View file

@ -1585,7 +1585,7 @@ instance_id_resolve(clixon_path *cplist,
* *
* @param[in] xt Top xml-tree where to search * @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] 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 * @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 1 OK with found xml nodes in xvec (if any)
* @retval 0 Fail fail: eg no yang * @retval 0 Fail fail: eg no yang
@ -1779,10 +1779,10 @@ clixon_xml_find_api_path(cxobj *xt,
* @see RFC7950 Sec 9.13 * @see RFC7950 Sec 9.13
*/ */
int int
clixon_xml_find_instance_id(cxobj *xt, clixon_xml_find_instance_id(cxobj *xt,
yang_stmt *yt, yang_stmt *yt,
cxobj ***xvec, cxobj ***xvec,
int *xlen, int *xlen,
const char *format, const char *format,
...) ...)
{ {

View file

@ -2228,7 +2228,7 @@ xml_copy_one(cxobj *x0,
default: default:
break; 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; retval = 0;
done: done:
return retval; return retval;

View file

@ -173,8 +173,7 @@ populate_self_parent(cxobj *xt,
y = xml_spec(xsibling); y = xml_spec(xsibling);
goto set; goto set;
} }
xp = xml_parent(xt); if ((xp = xml_parent(xt)) == NULL){
if (xp == NULL){
if (xerr && if (xerr &&
netconf_bad_element_xml(xerr, "application", name, "Missing parent") < 0) netconf_bad_element_xml(xerr, "application", name, "Missing parent") < 0)
goto done; goto done;
@ -469,8 +468,10 @@ xml_bind_yang0_opt(clicon_handle h,
else{ else{
if ((ret = yang_schema_yanglib_parse_mount(h, xt)) < 0) if ((ret = yang_schema_yanglib_parse_mount(h, xt)) < 0)
goto done; 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; goto ok;
}
/* Try again */ /* Try again */
if ((ret = xml_yang_mount_get(h, xt, NULL, &yspec1)) < 0) if ((ret = xml_yang_mount_get(h, xt, NULL, &yspec1)) < 0)
goto done; goto done;

View file

@ -214,7 +214,7 @@ yang_mount_set(yang_stmt *y,
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] x XML mount-point node * @param[in] x XML mount-point node
* @param[out] vallevel Do or dont do full RFC 7950 validation if given * @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 1 x is a mount-point: yspec may be set
* @retval 0 x is not a mount point * @retval 0 x is not a mount point
* @retval -1 Error * @retval -1 Error
@ -651,7 +651,8 @@ yang_schema_mount_statistics(clicon_handle h,
* *
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] xt * @param[in] xt
* @retval 0 OK * @retval 1 OK
* @retval 0 No yanglib or problem when parsing yanglib
* @retval -1 Error * @retval -1 Error
*/ */
int int