From 89f843f919e6a73de43c7a458943a756ba0143eb Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 1 Jul 2021 11:53:46 +0200 Subject: [PATCH] * Fixed: [uses oc-if:interface-ref error with openconfig #233](https://github.com/clicon/clixon/issues/233) --- CHANGELOG.md | 5 +++-- README.md | 4 ++-- lib/src/clixon_validate.c | 11 ++--------- lib/src/clixon_xpath.c | 15 ++++++++++++++- lib/src/clixon_xpath_parse.y | 6 +++--- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdc822c..1ec1c013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Clixon Changelog -* [5.2.0](#520) Expected: June 2021 +* [5.2.0](#520) Expected: July 2021 * [5.1.0](#510) 15 April 2021 * [5.0.0](#500) 27 February 2021 * [5.0.1](#501) 10 March 2021 @@ -30,7 +30,7 @@ * [3.3.1](#331) June 7 2017 ## 5.2.0 -Expected: June 2021 +Expected: July 2021 ### New features @@ -116,6 +116,7 @@ Developers may need to change their code ### Corrected Bugs +* Fixed: [uses oc-if:interface-ref error with openconfig #233](https://github.com/clicon/clixon/issues/233) * Fixed: [need make sure message-id exist in rpc validate #240](https://github.com/clicon/clixon/issues/240) * Netconf message-id attribute changed from optional to mandatory (see API changes) * Fixed: [restconf patch method unable to chage value to empty string #229](https://github.com/clicon/clixon/issues/229) diff --git a/README.md b/README.md index 44a03c24..1a60994b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Clixon is a YANG-based configuration manager, with interactive CLI, NETCONF and RESTCONF interfaces, an embedded database and transaction mechanism. -See [documentation](https://clixon-docs.readthedocs.io), [project page](https://www.clicon.org) and [examples](https://github.com/clicon/clixon-examples), [Travis-CI](https://travis-ci.org/clicon/clixon) +See [documentation](https://clixon-docs.readthedocs.io), [project page](https://www.clicon.org) and [examples](https://github.com/clicon/clixon-examples), [Github actions CI](https://github.com/clicon/clixon/actions/workflows/ci.yml) Clixon is open-source and dual licensed. Either Apache License, Version 2.0 or GNU General Public License Version 2; you choose, see [LICENSE.md](LICENSE.md). @@ -17,6 +17,6 @@ Latest release is 5.1.0. See [CHANGELOG.md](CHANGELOG.md) release history. Clixon interaction is best done posting issues, pull requests, or joining the [slack channel](https://clixondev.slack.com). -[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-qk66zp47-ahdOlEHKEPmb~5ciVJilPQ) (updated 24/5 2021) +[Slack invite](https://join.slack.com/t/clixondev/shared_invite/zt-seopvltv-hs~BS7UrMjRdKoDRlCK97w) (updated 30/6 2021) Clixon is sponsored by [Rubicon Communications LLC(Netgate)](https://www.netgate.com/) diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index dd97facf..274d339a 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -105,7 +105,6 @@ validate_leafref(cxobj *xt, { int retval = -1; yang_stmt *ypath; - yang_stmt *yp; cxobj **xvec = NULL; cxobj *x; int i; @@ -124,14 +123,8 @@ validate_leafref(cxobj *xt, goto fail; } /* See comment^: If path is defined in typedef or not */ - if ((yp = yang_parent_get(ytype)) != NULL && - yang_keyword_get(yp) == Y_TYPEDEF){ - if (xml_nsctx_yang(ys, &nsc) < 0) - goto done; - } - else - if (xml_nsctx_yang(ytype, &nsc) < 0) - goto done; + if (xml_nsctx_node(xt, &nsc) < 0) + goto done; path = yang_argument_get(ypath); if (xpath_vec(xt, nsc, "%s", &xvec, &xlen, path) < 0) goto done; diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 03d08f57..64352055 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -239,7 +239,6 @@ xpath_tree_print(FILE *f, * @param[in] xs XPATH tree * @param[out] xpath XPath string as CLIgen buf * @see xpath_tree_print - * @note XXX Not complete */ int xpath_tree2cbuf(xpath_tree *xs, @@ -247,6 +246,7 @@ xpath_tree2cbuf(xpath_tree *xs, { int retval = -1; + /* 1. Before first child */ switch (xs->xs_type){ case XP_ABSPATH: if (xs->xs_int == A_DESCENDANT_OR_SELF) @@ -283,8 +283,10 @@ xpath_tree2cbuf(xpath_tree *xs, default: break; } + /* 2. First child */ if (xs->xs_c0 && xpath_tree2cbuf(xs->xs_c0, xcb) < 0) goto done; + /* 3. Between first and second child */ switch (xs->xs_type){ case XP_AND: /* and or */ case XP_ADD: /* div mod + * - */ @@ -293,6 +295,13 @@ xpath_tree2cbuf(xpath_tree *xs, if (xs->xs_c1) cprintf(xcb, " %s ", clicon_int2str(xpopmap, xs->xs_int)); break; + case XP_PATHEXPR: + /* [19] PathExpr ::= | FilterExpr '/' RelativeLocationPath + | FilterExpr '//' RelativeLocationPath + */ + if (xs->xs_s0) + cprintf(xcb, "%s", xs->xs_s0); + break; case XP_RELLOCPATH: if (xs->xs_c1){ if (xs->xs_int == A_DESCENDANT_OR_SELF) @@ -311,8 +320,10 @@ xpath_tree2cbuf(xpath_tree *xs, default: break; } + /* 4. Second child */ if (xs->xs_c1 && xpath_tree2cbuf(xs->xs_c1, xcb) < 0) goto done; + /* 5. After second child */ switch (xs->xs_type){ case XP_PRED: if (xs->xs_c1) @@ -915,6 +926,8 @@ xpath_vec_bool(cxobj *xcur, return retval; } +/*! + */ static int traverse_canonical(xpath_tree *xs, yang_stmt *yspec, diff --git a/lib/src/clixon_xpath_parse.y b/lib/src/clixon_xpath_parse.y index 91c383e5..825203aa 100644 --- a/lib/src/clixon_xpath_parse.y +++ b/lib/src/clixon_xpath_parse.y @@ -163,7 +163,7 @@ xpath_parse_exit(clixon_xpath_yacc *xpy) * @param[in] type XPATH tree node type * @param[in] i0 step-> axis_type * @param[in] numstr original string xs_double: numeric value - * @param[in] s0 String 0 set if XP_PRIME_STR, XP_PRIME_FN, XP_NODE[_FN] prefix + * @param[in] s0 String 0 set if XP_PRIME_STR, XP_PRIME_FN, XP_NODE[_FN] PATHEXPRE prefix * @param[in] s1 String 1 set if XP_NODE NAME * @param[in] c0 Child 0 * @param[in] c1 Child 1 @@ -393,8 +393,8 @@ unionexpr : unionexpr '|' pathexpr { $$=xp_new(XP_UNION,XO_UNION,NULL,NULL,NUL pathexpr : locationpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);clicon_debug(3,"pathexpr-> locationpath"); } | filterexpr { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);clicon_debug(3,"pathexpr-> filterexpr"); } - | filterexpr '/' rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, $3);clicon_debug(3,"pathexpr-> filterexpr / rellocpath"); } - /* Filterexpr // relativelocationpath */ + | filterexpr '/' rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("/"),NULL,$1, $3);clicon_debug(3,"pathexpr-> filterexpr / rellocpath"); } + | filterexpr DOUBLESLASH rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("//"),NULL,$1, $3);clicon_debug(3,"pathexpr-> filterexpr // rellocpath"); } ; filterexpr : primaryexpr { $$=xp_new(XP_FILTEREXPR,A_NAN,NULL,NULL,NULL,$1, NULL);clicon_debug(3,"filterexpr-> primaryexpr"); }