* C-API: Added vlev validate level parameter to candidate_commit

* `vlev` : validate level
This commit is contained in:
Olof Hagsand 2023-01-29 20:02:56 +01:00
parent a8e13047fc
commit 034ab632f1
13 changed files with 98 additions and 60 deletions

View file

@ -40,6 +40,16 @@
#ifndef _CLIXON_VALIDATE_H_
#define _CLIXON_VALIDATE_H_
/*
* Types
*/
/* Validation level at commit */
enum validate_level_t {
VL_FULL = 0, /* Do full RFC 7950 validation , 0 : backward-compatible */
VL_NONE, /* Do not do any validation */
};
typedef enum validate_level_t validate_level;
/*
* Prototypes
*/

View file

@ -54,6 +54,7 @@
yang_stmt *yang_parse_file(FILE *fp, const char *name, yang_stmt *ysp);
int yang_file_find_match(clicon_handle h, const char *module, const char *revision, cbuf *fbuf);
yang_stmt *yang_parse_filename(const char *filename, yang_stmt *ysp);
yang_stmt *yang_parse_module(clicon_handle h, const char *module, const char *revision, yang_stmt *yspec, char *origname);
int yang_parse_post(clicon_handle h, yang_stmt *yspec, int modmin);
int yang_spec_parse_module(clicon_handle h, const char *module,
const char *revision, yang_stmt *yspec);

View file

@ -50,11 +50,6 @@
*/
#define YANG_SCHEMA_MOUNT_ONLY_PRESENCE_CONTAINERS
/*! Force add ietf-yang-library@2019-01-04 on all mount-points
* This is a limitation of othe current implementation
*/
#define YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
/*
* Prototypes
*/

View file

@ -75,6 +75,7 @@
#include "clixon_xpath.h"
#include "clixon_yang_module.h"
#include "clixon_yang_type.h"
#include "clixon_yang_schema_mount.h"
#include "clixon_xml_default.h"
#include "clixon_xml_map.h"
#include "clixon_xml_bind.h"
@ -1007,6 +1008,15 @@ xml_yang_validate_add(clicon_handle h,
cg_var *cv0;
enum cv_type cvtype;
#ifdef YANG_SCHEMA_MOUNT
/* Do not validate beyond mountpoints */
if ((ret = xml_yang_mount_get(xt, NULL)) < 0)
goto done;
if (ret == 1){
retval = 1;
goto done;
}
#endif
/* if not given by argument (overide) use default link
and !Node has a config sub-statement and it is false */
if ((yt = xml_spec(xt)) != NULL && yang_config(yt) != 0){
@ -1215,6 +1225,13 @@ xml_yang_validate_all(clicon_handle h,
cvec *nsc = NULL;
int hit = 0;
#ifdef YANG_SCHEMA_MOUNT
/* Do not validate beyond mountpoints */
if ((ret = xml_yang_mount_get(xt, NULL)) < 0)
goto done;
if (ret == 1)
goto ok;
#endif
/* if not given by argument (overide) use default link
and !Node has a config sub-statement and it is false */
if ((yt = xml_spec(xt)) == NULL){

View file

@ -82,6 +82,11 @@
#include "clixon_xml_map.h"
#include "clixon_yang_parse_lib.h"
/*! Force add ietf-yang-library@2019-01-04 on all mount-points
* This is a limitation of othe current implementation
*/
#define YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
/*! Create modstate structure
*
* @retval md modstate struct
@ -826,10 +831,10 @@ yang_metadata_init(clicon_handle h)
return retval;
}
/*! Given a yang-lib module-set XML tree, parse all modules into an yspec
/*! Given yang-lib module-set XML tree, parse all modules into an yspec
*
* This function is used where a yang-lib module-set is available to populate an
* XML mount-point.
* This function is used where a yang-lib module-set is available to populate
* an XML mount-point.
* @param[in] h Clicon handle
* @param[in] xylib yang-lib XML tree on the form <yang-lib>...
* @param[in] yspec Will be populated with YANGs, is consumed
@ -860,14 +865,16 @@ yang_lib2yspec(clicon_handle h,
continue;
if ((revision = xml_find_body(xi, "revision")) == NULL)
continue;
if (yang_spec_parse_module(h, name, revision, yspec) < 0)
if (yang_parse_module(h, name, revision, yspec, NULL) == NULL)
goto fail;
}
#ifdef YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
/* XXX: Ensure yang-lib is always there otherwise get state dont work for mountpoint */
if (yang_spec_parse_module(h, "ietf-yang-library", "2019-01-04", yspec) < 0)
if (yang_parse_module(h, "ietf-yang-library", "2019-01-04", yspec, NULL) < 0)
goto fail;
#endif
if (yang_parse_post(h, yspec, 0) < 0)
goto done;
retval = 1;
done:
if (vec)

View file

@ -1059,7 +1059,7 @@ yang_parse_filename(const char *filename,
*
* See top of file for diagram of calling order
*/
static yang_stmt *
yang_stmt *
yang_parse_module(clicon_handle h,
const char *module,
const char *revision,

View file

@ -459,11 +459,6 @@ yang_schema_yanglib_parse_mount(clicon_handle h,
goto done;
if (ret == 0)
goto anydata;
#ifdef YANG_SCHEMA_MOUNT_YANG_LIB_FORCE
/* XXX: Ensure yang-lib is always there otherwise get state dont work for mountpoint */
if (yang_spec_parse_module(h, "ietf-yang-library", "2019-01-04", yspec) < 0)
goto done;
#endif
if (xml_yang_mount_set(xt, yspec) < 0)
goto done;
retval = 1;