* Netconf as default namespace has been disabled by default.

* Only requests on the form: `<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config>...` will be accepted
  * All replies will be on the form: `<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">...`
  * Requests such as: `<rpc><edit-config>...` will not  be accepted.
  * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT`
  * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131)
This commit is contained in:
Olof hagsand 2020-09-02 15:40:35 +02:00
parent a01fe04613
commit 81fc7f742b
81 changed files with 976 additions and 830 deletions

View file

@ -704,6 +704,7 @@ text_modify(clicon_handle h,
/*! Modify a top-level base tree x0 with modification tree x1
* @param[in] h Clicon handle
* @param[in] x0 Base xml tree (can be NULL in add scenarios)
* @param[in] x0t
* @param[in] x1 XML tree which modifies base
* @param[in] x1t Request root node (nacm needs this)
* @param[in] yspec Top-level yang spec (if y is NULL)

View file

@ -546,7 +546,8 @@ nacm_data_write_xrule_xml(cxobj *xn,
if (strcmp(module_pattern, "*") != 0){
if (ys_module_by_xml(yspec, xn, &ymod) < 0)
goto done;
if (strcmp(yang_argument_get(ymod), module_pattern) != 0)
/* ymod is NULL (xn is "config") Can this breach the NACM rule? */
if (ymod && strcmp(yang_argument_get(ymod), module_pattern) != 0)
goto nomatch;
}
action = xml_find_body(xrule, "action"); /* mandatory */

View file

@ -88,10 +88,11 @@ netconf_in_use(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>in-use</error-tag>"
"<error-severity>error</error-severity>",
NETCONF_BASE_NAMESPACE,
type) <0)
goto err;
if (message){
@ -127,13 +128,18 @@ netconf_invalid_value_xml(cxobj **xret,
int retval =-1;
cxobj *xerr = NULL;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
goto done;
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL,
@ -197,10 +203,11 @@ netconf_too_big(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>too-big</error-tag>"
"<error-severity>error</error-severity>",
NETCONF_BASE_NAMESPACE,
type) <0)
goto err;
if (message){
@ -238,12 +245,12 @@ netconf_missing_attribute(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>missing-attribute</error-tag>"
"<error-info>%s</error-info>"
"<error-severity>error</error-severity>",
type, info) <0)
NETCONF_BASE_NAMESPACE, type, info) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -308,6 +315,7 @@ netconf_bad_attribute_xml(cxobj **xret,
int retval = -1;
cxobj *xerr = NULL;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -315,6 +323,10 @@ netconf_bad_attribute_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>%s</error-type>"
@ -354,12 +366,12 @@ netconf_unknown_attribute(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>unknown-attribute</error-tag>"
"<error-info>%s</error-info>"
"<error-severity>error</error-severity>",
type, info) <0)
NETCONF_BASE_NAMESPACE, type, info) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -397,13 +409,19 @@ netconf_common_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>%s</error-type>"
@ -647,6 +665,7 @@ netconf_access_denied_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -654,6 +673,10 @@ netconf_access_denied_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>%s</error-type>"
@ -690,12 +713,12 @@ netconf_lock_denied(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>protocol</error-type>"
"<error-tag>lock-denied</error-tag>"
"<error-info>%s</error-info>"
"<error-severity>error</error-severity>",
info) <0)
NETCONF_BASE_NAMESPACE, info) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -730,11 +753,11 @@ netconf_resource_denied(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>resource-denied</error-tag>"
"<error-severity>error</error-severity>",
type) <0)
NETCONF_BASE_NAMESPACE, type) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -770,11 +793,11 @@ netconf_rollback_failed(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>rollback-failed</error-tag>"
"<error-severity>error</error-severity>",
type) <0)
NETCONF_BASE_NAMESPACE, type) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -809,10 +832,11 @@ netconf_data_exists(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>application</error-type>"
"<error-tag>data-exists</error-tag>"
"<error-severity>error</error-severity>") <0)
"<error-severity>error</error-severity>",
NETCONF_BASE_NAMESPACE) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -877,6 +901,7 @@ netconf_data_missing_xml(cxobj **xret,
int retval = -1;
char *encstr = NULL;
cxobj *xerr;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -884,6 +909,10 @@ netconf_data_missing_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL,
@ -929,11 +958,11 @@ netconf_operation_not_supported(cbuf *cb,
int retval = -1;
char *encstr = NULL;
if (cprintf(cb, "<rpc-reply><rpc-error>"
if (cprintf(cb, "<rpc-reply xmlns=\"%s\"><rpc-error>"
"<error-type>%s</error-type>"
"<error-tag>operation-not-supported</error-tag>"
"<error-severity>error</error-severity>",
type) <0)
NETCONF_BASE_NAMESPACE, type) <0)
goto err;
if (message){
if (xml_chardata_encode(&encstr, "%s", message) < 0)
@ -1005,6 +1034,7 @@ netconf_operation_failed_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -1012,6 +1042,10 @@ netconf_operation_failed_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>%s</error-type>"
@ -1084,6 +1118,7 @@ netconf_malformed_message_xml(cxobj **xret,
int retval =-1;
cxobj *xerr;
char *encstr = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -1091,6 +1126,10 @@ netconf_malformed_message_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "<error-type>rpc</error-type>"
@ -1131,6 +1170,7 @@ netconf_data_not_unique_xml(cxobj **xret,
cxobj *xerr;
cxobj *xinfo;
cbuf *cb = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -1138,6 +1178,10 @@ netconf_data_not_unique_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL,
@ -1190,6 +1234,7 @@ netconf_minmax_elements_xml(cxobj **xret,
cxobj *xerr;
char *path = NULL;
cbuf *cb = NULL;
cxobj *xa;
if (*xret == NULL){
if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL)
@ -1197,6 +1242,10 @@ netconf_minmax_elements_xml(cxobj **xret,
}
else if (xml_name_set(*xret, "rpc-reply") < 0)
goto done;
if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL)
goto done;
if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0)
goto done;
if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL)
goto done;
if ((cb = cbuf_new()) == NULL){
@ -1396,9 +1445,10 @@ netconf_err2cb(cxobj *xerr,
cprintf(cberr, "%s ", xml_body(x));
if ((x=xpath_first(xerr, NULL, "//error-message"))!=NULL)
cprintf(cberr, "%s ", xml_body(x));
if ((x=xpath_first(xerr, NULL, "//error-info"))!=NULL &&
xml_child_nr(x) > 0)
clicon_xml2cbuf(cberr, xml_child_i(x,0), 0, 0, -1);
if ((x=xpath_first(xerr, NULL, "//error-info")) != NULL &&
xml_child_nr(x) > 0){
clicon_xml2cbuf(cberr, xml_child_i(x, 0), 0, 0, -1);
}
if ((x=xpath_first(xerr, NULL, "//error-app-tag"))!=NULL)
cprintf(cberr, ": %s ", xml_body(x));
if ((x=xpath_first(xerr, NULL, "//error-path"))!=NULL)

View file

@ -84,7 +84,7 @@
/*! Send internal netconf rpc from client to backend
* @param[in] h CLICON handle
* @param[in] msg Encoded message. Deallocate woth free
* @param[in] msg Encoded message. Deallocate with free
* @param[out] xret0 Return value from backend as xml tree. Free w xml_free
* @param[inout] sock0 If pointer exists, do not close socket to backend on success
* and return it here. For keeping a notify socket open
@ -337,7 +337,7 @@ clicon_rpc_get_config(clicon_handle h,
goto done;
if ((cb = cbuf_new()) == NULL)
goto done;
cprintf(cb, "<rpc");
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
if (username == NULL)
username = clicon_username_get(h);
if (username != NULL)
@ -492,7 +492,9 @@ clicon_rpc_copy_config(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><copy-config><source><%s/></source><target><%s/></target></copy-config></rpc>",
"<rpc xmlns=\"%s\" username=\"%s\">"
"<copy-config><source><%s/></source><target><%s/></target></copy-config></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"",
db1, db2)) == NULL)
goto done;
@ -536,7 +538,9 @@ clicon_rpc_delete_config(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><edit-config><target><%s/></target><default-operation>none</default-operation><config operation=\"delete\"/></edit-config></rpc>",
"<rpc xmlns=\"%s\" username=\"%s\">"
"<edit-config><target><%s/></target><default-operation>none</default-operation><config operation=\"delete\"/></edit-config></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"", db)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
@ -575,7 +579,9 @@ clicon_rpc_lock(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><lock><target><%s/></target></lock></rpc>",
"<rpc xmlns=\"%s\" username=\"%s\">"
"<lock><target><%s/></target></lock></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"", db)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
@ -614,7 +620,10 @@ clicon_rpc_unlock(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><unlock><target><%s/></target></unlock></rpc>", username?username:"", db)) == NULL)
"<rpc xmlns=\"%s\" username=\"%s\">"
"<unlock><target><%s/></target></unlock></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"", db)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
@ -690,7 +699,7 @@ clicon_rpc_get(clicon_handle h,
goto done;
if ((cb = cbuf_new()) == NULL)
goto done;
cprintf(cb, "<rpc");
cprintf(cb, "<rpc xmlns=\"%s\" ", NETCONF_BASE_NAMESPACE);
if ((username = clicon_username_get(h)) != NULL)
cprintf(cb, " username=\"%s\"", username);
cprintf(cb, " xmlns:%s=\"%s\"",
@ -781,8 +790,8 @@ clicon_rpc_close_session(clicon_handle h)
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><close-session/></rpc>",
username?username:"")) == NULL)
"<rpc xmlns=\"%s\" username=\"%s\"><close-session/></rpc>",
NETCONF_BASE_NAMESPACE, username?username:"")) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
@ -820,7 +829,8 @@ clicon_rpc_kill_session(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(my_session_id,
"<rpc username=\"%s\"><kill-session><session-id>%u</session-id></kill-session></rpc>",
"<rpc xmlns=\"%s\" username=\"%s\"><kill-session><session-id>%u</session-id></kill-session></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"", session_id)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
@ -859,7 +869,9 @@ clicon_rpc_validate(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><validate><source><%s/></source></validate></rpc>", username?username:"", db)) == NULL)
"<rpc xmlns=\"%s\" username=\"%s\"><validate><source><%s/></source></validate></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"", db)) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
@ -895,7 +907,9 @@ clicon_rpc_commit(clicon_handle h)
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><commit/></rpc>", username?username:"")) == NULL)
"<rpc xmlns=\"%s\" username=\"%s\"><commit/></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"")) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
@ -931,7 +945,9 @@ clicon_rpc_discard_changes(clicon_handle h)
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><discard-changes/></rpc>", username?username:"")) == NULL)
"<rpc xmlns=\"%s\" username=\"%s\"><discard-changes/></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"")) == NULL)
goto done;
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
@ -975,10 +991,11 @@ clicon_rpc_create_subscription(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><create-subscription xmlns=\"%s\">"
"<rpc xmlns=\"%s\" username=\"%s\"><create-subscription xmlns=\"%s\">"
"<stream>%s</stream>"
"<filter type=\"xpath\" select=\"%s\" />"
"</create-subscription></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"",
EVENT_RFC5277_NAMESPACE,
stream?stream:"", filter?filter:"")) == NULL)
@ -1019,7 +1036,8 @@ clicon_rpc_debug(clicon_handle h,
goto done;
username = clicon_username_get(h);
if ((msg = clicon_msg_encode(session_id,
"<rpc username=\"%s\"><debug xmlns=\"%s\"><level>%d</level></debug></rpc>",
"<rpc xmlns=\"%s\" username=\"%s\"><debug xmlns=\"%s\"><level>%d</level></debug></rpc>",
NETCONF_BASE_NAMESPACE,
username?username:"",
CLIXON_LIB_NS,
level)) == NULL)

View file

@ -64,11 +64,34 @@
#include "clixon_hash.h"
#include "clixon_handle.h"
#include "clixon_log.h"
#include "clixon_options.h"
#include "clixon_yang.h"
#include "clixon_xml.h"
#include "clixon_yang_module.h"
#include "clixon_xml_nsctx.h"
/* Undefine if you want to ensure strict namespace assignment on all netconf
* and XML statements according to the standard RFC 6241.
* If defined, top-level rpc calls need not have namespaces (eg using xmlns=<ns>)
* since the default NETCONF namespace will be assumed. (This is not standard).
* See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0.
*/
static int _USE_NAMESPACE_NETCONF_DEFAULT = 0;
/*! Set if use internal default namespace mechanism or not
*
* This function shouldnt really be here, it sets a local variable from the value of the
* option CLICON_NAMESPACE_NETCONF_DEFAULT, but the code where it is used is deep in the call
* stack and cannot get the clicon handle currently.
* @param[in] h Clicon handle
*/
int
xml_nsctx_namespace_netconf_default(clicon_handle h)
{
_USE_NAMESPACE_NETCONF_DEFAULT = clicon_option_bool(h, "CLICON_NAMESPACE_NETCONF_DEFAULT");
return 0;
}
/*! Create and initialize XML namespace context
* @param[in] prefix Namespace prefix, or NULL for default
* @param[in] ns Set this namespace. If NULL create empty nsctx
@ -220,12 +243,12 @@ xml_nsctx_node1(cxobj *xn,
}
}
if ((xp = xml_parent(xn)) == NULL){
#ifdef USE_NETCONF_NS_AS_DEFAULT
/* If not default namespace defined, use the base netconf ns as default */
if (xml_nsctx_get(nsc, NULL) == NULL)
if (xml_nsctx_add(nsc, NULL, NETCONF_BASE_NAMESPACE) < 0)
goto done;
#endif
if (_USE_NAMESPACE_NETCONF_DEFAULT){
/* If not default namespace defined, use the base netconf ns as default */
if (xml_nsctx_get(nsc, NULL) == NULL)
if (xml_nsctx_add(nsc, NULL, NETCONF_BASE_NAMESPACE) < 0)
goto done;
}
}
else
if (xml_nsctx_node1(xp, nsc) < 0)
@ -450,14 +473,12 @@ xml2ns(cxobj *x,
goto done;
}
/* If no parent, return default namespace if defined */
#ifdef USE_NETCONF_NS_AS_DEFAULT
else{
else if (_USE_NAMESPACE_NETCONF_DEFAULT){
if (prefix == NULL)
ns = NETCONF_BASE_NAMESPACE;
else
ns = NULL;
}
#endif
}
/* Set default namespace cache (since code is at this point,
* no cache was found