Refactored YANG min/max validation code, created new clixon_validate_minmax.[ch]
Added new recursive minmax check for non-presence containers This makes validation checks stricter, including check of incoming RPCs Renamed xml_yang_check_list_unique_minmax() to xml_yang_minmax_recurse() Fixed again: [YANG min-elements within non-presence container does not work](https://github.com/clicon/clixon/issues/355)
This commit is contained in:
parent
c8bf718db8
commit
2eb9c6cda1
17 changed files with 867 additions and 614 deletions
|
|
@ -96,6 +96,7 @@ extern "C" {
|
|||
#include <clixon/clixon_xml_map.h>
|
||||
#include <clixon/clixon_xml_bind.h>
|
||||
#include <clixon/clixon_xml_io.h>
|
||||
#include <clixon/clixon_validate_minmax.h>
|
||||
#include <clixon/clixon_validate.h>
|
||||
#include <clixon/clixon_datastore.h>
|
||||
#include <clixon/clixon_xpath_ctx.h>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
***** END LICENSE BLOCK *****
|
||||
|
||||
*
|
||||
* XML code
|
||||
* Check YANG validation
|
||||
*/
|
||||
|
||||
#ifndef _CLIXON_VALIDATE_H_
|
||||
|
|
@ -45,7 +45,6 @@
|
|||
*/
|
||||
int xml_yang_validate_rpc(clicon_handle h, cxobj *xrpc, cxobj **xret);
|
||||
int xml_yang_validate_rpc_reply(clicon_handle h, cxobj *xrpc, cxobj **xret);
|
||||
int xml_yang_check_list_unique_minmax(cxobj *xt, cxobj **xret);
|
||||
int xml_yang_validate_add(clicon_handle h, cxobj *xt, cxobj **xret);
|
||||
int xml_yang_validate_list_key_only(cxobj *xt, cxobj **xret);
|
||||
int xml_yang_validate_all(clicon_handle h, cxobj *xt, cxobj **xret);
|
||||
|
|
|
|||
48
lib/clixon/clixon_validate_minmax.h
Normal file
48
lib/clixon/clixon_validate_minmax.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||
Copyright (C) 2017-2019 Olof Hagsand
|
||||
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC (Netgate)
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the "GPL"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
*
|
||||
* Check YANG validation for min/max-elements and unique
|
||||
*/
|
||||
|
||||
#ifndef _CLIXON_VALIDATE_MINMAX_H_
|
||||
#define _CLIXON_VALIDATE_MINMAX_H_
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int xml_yang_minmax_recurse(cxobj *xt, cxobj **xret);
|
||||
|
||||
#endif /* _CLIXON_VALIDATE_MINMAX_H_ */
|
||||
|
|
@ -218,7 +218,6 @@ cxobj *xml_child_i_type(cxobj *xn, int i, enum cxobj_type type);
|
|||
cxobj *xml_child_i_set(cxobj *xt, int i, cxobj *xc);
|
||||
int xml_child_order(cxobj *xn, cxobj *xc);
|
||||
cxobj *xml_child_each(cxobj *xparent, cxobj *xprev, enum cxobj_type type);
|
||||
|
||||
int xml_child_insert_pos(cxobj *x, cxobj *xc, int i);
|
||||
int xml_childvec_set(cxobj *x, int len);
|
||||
cxobj **xml_childvec_get(cxobj *x);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue