From be329dac6d06168e7c3814ec710d1f0b24643e33 Mon Sep 17 00:00:00 2001 From: Simon Bauer Date: Sun, 13 Dec 2020 18:05:49 +0100 Subject: [PATCH 1/2] Fixed filter namespace in netconf_rpc.o The "filter" node was not detected when an a namespace was used. The fix is similar to https://github.com/clicon/clixon/commit/d045e8abcec2699ac363947b0fe6061fab5794ba and related to bug #154 #143 --- apps/netconf/netconf_rpc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c index e1e2ccf5..dd35700f 100644 --- a/apps/netconf/netconf_rpc.c +++ b/apps/netconf/netconf_rpc.c @@ -164,6 +164,16 @@ netconf_get_config(clicon_handle h, int retval = -1; cxobj *xfilter; /* filter */ char *ftype = NULL; + cvec *nsc = NULL; + char *prefix = NULL; + + if(xml_nsctx_node(xn, &nsc) < 0) + goto done; + + /* Get prefix of netconf base namespace in the incoming message */ + if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){ + goto done; + } /* ie ... */ if ((xfilter = xpath_first(xn, NULL, "filter")) != NULL) @@ -193,6 +203,8 @@ netconf_get_config(clicon_handle h, } retval = 0; done: + if (nsc) + cvec_free(nsc); return retval; } @@ -364,6 +376,16 @@ netconf_get(clicon_handle h, int retval = -1; cxobj *xfilter; /* filter */ char *ftype = NULL; + cvec *nsc = NULL; + char *prefix = NULL; + + if(xml_nsctx_node(xn, &nsc) < 0) + goto done; + + /* Get prefix of netconf base namespace in the incoming message */ + if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){ + goto done; + } /* ie ... */ if ((xfilter = xpath_first(xn, NULL, "filter")) != NULL) @@ -393,6 +415,8 @@ netconf_get(clicon_handle h, } retval = 0; done: + if(nsc) + cvec_free(nsc); return retval; } From 638658c63dcbdd3a1555c9e1c898e12798718126 Mon Sep 17 00:00:00 2001 From: Simon Bauer Date: Sun, 13 Dec 2020 18:07:28 +0100 Subject: [PATCH 2/2] Update netconf_rpc.c --- apps/netconf/netconf_rpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c index dd35700f..072af359 100644 --- a/apps/netconf/netconf_rpc.c +++ b/apps/netconf/netconf_rpc.c @@ -176,7 +176,7 @@ netconf_get_config(clicon_handle h, } /* ie ... */ - if ((xfilter = xpath_first(xn, NULL, "filter")) != NULL) + if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL) ftype = xml_find_value(xfilter, "type"); if (xfilter == NULL || ftype == NULL || strcmp(ftype, "xpath")==0){ if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0) @@ -388,7 +388,7 @@ netconf_get(clicon_handle h, } /* ie ... */ - if ((xfilter = xpath_first(xn, NULL, "filter")) != NULL) + if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL) ftype = xml_find_value(xfilter, "type"); if (xfilter == NULL || ftype == NULL || strcmp(ftype, "xpath")==0){ if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)