Added YANG RPC support, with example rpc documentation and testcase (test7.sh); Extended example with ietf-routing (not only ietf-ip).
This commit is contained in:
parent
f995f1e268
commit
e56cf607a3
17 changed files with 177 additions and 112 deletions
|
|
@ -54,7 +54,7 @@
|
|||
* - Cant use the symbols in this file because yacc needs token definitions
|
||||
*/
|
||||
enum rfc_6020{
|
||||
Y_ANYXML,
|
||||
Y_ANYXML = 0,
|
||||
Y_ARGUMENT,
|
||||
Y_AUGMENT,
|
||||
Y_BASE,
|
||||
|
|
@ -208,7 +208,8 @@ int yang_print_cbuf(cbuf *cb, yang_node *yn, int marginal);
|
|||
int yang_print(FILE *f, yang_node *yn, int marginal);
|
||||
int yang_parse(clicon_handle h, const char *yang_dir,
|
||||
const char *module, const char *revision, yang_spec *ysp);
|
||||
int yang_apply(yang_node *yn, yang_applyfn_t fn, void *arg);
|
||||
int yang_apply(yang_node *yn, enum rfc_6020 key, yang_applyfn_t fn,
|
||||
void *arg);
|
||||
yang_node *yang_xpath_abs(yang_node *yn, char *xpath);
|
||||
yang_node *yang_xpath(yang_node *yn, char *xpath);
|
||||
cg_var *ys_parse(yang_stmt *ys, enum cv_type cvtype);
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ yn_each(yang_node *yn,
|
|||
*
|
||||
* @param[in] yn Yang node, current context node.
|
||||
* @param[in] keyword if 0 match any keyword
|
||||
* @param[in] argument if NULL, match any argument.
|
||||
* @param[in] argument String compare w wrgument. if NULL, match any.
|
||||
* This however means that if you actually want to match only a yang-stmt with
|
||||
* argument==NULL you cannot, but I have not seen any such examples.
|
||||
* @see yang_find_syntax
|
||||
|
|
@ -1587,15 +1587,15 @@ yang_parse(clicon_handle h,
|
|||
clicon_dbspec_name_set(h, ymod->ys_argument);
|
||||
|
||||
/* Resolve all types */
|
||||
yang_apply((yang_node*)ysp, ys_resolve_type, NULL);
|
||||
yang_apply((yang_node*)ysp, Y_TYPE, ys_resolve_type, NULL);
|
||||
|
||||
/* Step 2: Macro expansion of all grouping/uses pairs. Expansion needs marking */
|
||||
if (yang_expand((yang_node*)ysp) < 0)
|
||||
goto done;
|
||||
yang_apply((yang_node*)ymod, ys_flag_reset, (void*)YANG_FLAG_MARK);
|
||||
yang_apply((yang_node*)ymod, -1, ys_flag_reset, (void*)YANG_FLAG_MARK);
|
||||
|
||||
/* Step 3: Go through parse tree and populate it with cv types */
|
||||
if (yang_apply((yang_node*)ysp, ys_populate, NULL) < 0)
|
||||
if (yang_apply((yang_node*)ysp, -1, ys_populate, NULL) < 0)
|
||||
goto done;
|
||||
|
||||
/* Step 4: Top-level augmentation of all modules */
|
||||
|
|
@ -1615,6 +1615,7 @@ yang_parse(clicon_handle h,
|
|||
* The tree is traversed depth-first, which at least guarantees that a parent is
|
||||
* traversed before a child.
|
||||
* @param[in] yn yang node
|
||||
* @param[in] key yang keyword to use as filer or -1 for all
|
||||
* @param[in] fn Callback
|
||||
* @param[in] arg Argument
|
||||
* @retval -1 Error, aborted at first error encounter
|
||||
|
|
@ -1625,12 +1626,13 @@ yang_parse(clicon_handle h,
|
|||
* {
|
||||
* return 0;
|
||||
* }
|
||||
* yang_apply((yang_node*)ys, ys_fn, NULL);
|
||||
* yang_apply((yang_node*)ys, Y_TYPE, ys_fn, NULL);
|
||||
* @endcode
|
||||
* @note do not delete or move around any children during this function
|
||||
*/
|
||||
int
|
||||
yang_apply(yang_node *yn,
|
||||
enum rfc_6020 keyword,
|
||||
yang_applyfn_t fn,
|
||||
void *arg)
|
||||
{
|
||||
|
|
@ -1641,9 +1643,15 @@ yang_apply(yang_node *yn,
|
|||
|
||||
for (i=0; i<yn->yn_len; i++){
|
||||
ys = yn->yn_stmt[i];
|
||||
if (fn(ys, arg) < 0)
|
||||
goto done;
|
||||
if ((ret = yang_apply((yang_node*)ys, fn, arg)) < 0)
|
||||
if (keyword == -1 || keyword == ys->ys_keyword){
|
||||
if ((ret = fn(ys, arg)) < 0)
|
||||
goto done;
|
||||
if (ret > 0){
|
||||
retval = ret;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ((ret = yang_apply((yang_node*)ys, keyword, fn, arg)) < 0)
|
||||
goto done;
|
||||
if (ret > 0){
|
||||
retval = ret;
|
||||
|
|
|
|||
|
|
@ -218,8 +218,6 @@ ys_resolve_type(yang_stmt *ys,
|
|||
uint8_t fraction = 0;
|
||||
yang_stmt *resolved = NULL;
|
||||
|
||||
if (ys->ys_keyword != Y_TYPE)
|
||||
return 0;
|
||||
if (yang_type_resolve((yang_stmt*)ys->ys_parent, ys, &resolved,
|
||||
&options, &mincv, &maxcv, &pattern, &fraction) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue