Restructured error,debug anf log API
Renamed functions clicon->clixon, replaced global variables w access functions Unified clicon_netconf_error with clixon_err()
This commit is contained in:
parent
261469be16
commit
24a4991ec8
199 changed files with 4668 additions and 4158 deletions
|
|
@ -56,12 +56,14 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
|
||||
/* clixon */
|
||||
#include "clixon_string.h"
|
||||
#include "clixon_queue.h"
|
||||
#include "clixon_hash.h"
|
||||
#include "clixon_handle.h"
|
||||
#include "clixon_log.h"
|
||||
#include "clixon_debug.h"
|
||||
#include "clixon_err.h"
|
||||
#include "clixon_string.h"
|
||||
#include "clixon_yang.h"
|
||||
#include "clixon_xml.h"
|
||||
|
|
@ -73,8 +75,6 @@
|
|||
#include "clixon_xml_nsctx.h"
|
||||
#include "clixon_xpath_ctx.h"
|
||||
#include "clixon_xpath.h"
|
||||
#include "clixon_log.h"
|
||||
#include "clixon_err.h"
|
||||
#include "clixon_netconf_lib.h"
|
||||
#include "clixon_plugin.h"
|
||||
#include "clixon_xml_sort.h"
|
||||
|
|
@ -140,6 +140,7 @@ strip_body_objects(cxobj *xt)
|
|||
|
||||
/*! Associate XML node x with x:s parents yang:s matching child
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] xt XML tree node
|
||||
* @param[in] xsibling
|
||||
* @param[in] yspec Top-level YANG spec / mount-point
|
||||
|
|
@ -152,10 +153,11 @@ strip_body_objects(cxobj *xt)
|
|||
* @see populate_self_top
|
||||
*/
|
||||
static int
|
||||
populate_self_parent(cxobj *xt,
|
||||
cxobj *xsibling,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
populate_self_parent(clixon_handle h,
|
||||
cxobj *xt,
|
||||
cxobj *xsibling,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
{
|
||||
int retval = -1;
|
||||
yang_stmt *y = NULL; /* yang node */
|
||||
|
|
@ -200,13 +202,13 @@ populate_self_parent(cxobj *xt,
|
|||
goto done;
|
||||
xml_spec_set(xt, y);
|
||||
retval = 2; /* treat as anydata */
|
||||
clicon_log(LOG_WARNING,
|
||||
clixon_log(h, LOG_WARNING,
|
||||
"%s: %d: No YANG spec for %s, anydata used",
|
||||
__FUNCTION__, __LINE__, name);
|
||||
goto done;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "Failed to find YANG spec of XML node: %s", name);
|
||||
|
|
@ -228,7 +230,7 @@ populate_self_parent(cxobj *xt,
|
|||
/* Assign spec only if namespaces match */
|
||||
if (strcmp(ns, nsy) != 0){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "Namespace mismatch: %s in XML does not match %s in yang", ns, nsy);
|
||||
|
|
@ -255,6 +257,7 @@ populate_self_parent(cxobj *xt,
|
|||
|
||||
/*! Associate XML node x with yang spec y by going through all top-level modules and finding match
|
||||
*
|
||||
* @param[in] h Clixon handle
|
||||
* @param[in] xt XML tree node
|
||||
* @param[in] yspec Yang spec
|
||||
* @param[out] xerr Reason for failure, or NULL
|
||||
|
|
@ -264,9 +267,10 @@ populate_self_parent(cxobj *xt,
|
|||
* @see populate_self_parent
|
||||
*/
|
||||
static int
|
||||
populate_self_top(cxobj *xt,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
populate_self_top(clixon_handle h,
|
||||
cxobj *xt,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
{
|
||||
int retval = -1;
|
||||
yang_stmt *y = NULL; /* yang node */
|
||||
|
|
@ -292,7 +296,7 @@ populate_self_top(cxobj *xt,
|
|||
if (ymod == NULL){
|
||||
if (xerr){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "Failed to find YANG spec of XML node: %s", name);
|
||||
|
|
@ -313,13 +317,13 @@ populate_self_top(cxobj *xt,
|
|||
goto done;
|
||||
xml_spec_set(xt, y);
|
||||
retval = 2; /* treat as anydata */
|
||||
clicon_log(LOG_WARNING,
|
||||
clixon_log(h, LOG_WARNING,
|
||||
"%s: %d: No YANG spec for %s, anydata used",
|
||||
__FUNCTION__, __LINE__, name);
|
||||
goto done;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "Failed to find YANG spec of XML node: %s", name);
|
||||
|
|
@ -380,7 +384,7 @@ populate_self_top(cxobj *xt,
|
|||
* @note For subs to anyxml nodes will not have spec set
|
||||
*/
|
||||
int
|
||||
xml_bind_yang(clicon_handle h,
|
||||
xml_bind_yang(clixon_handle h,
|
||||
cxobj *xt,
|
||||
yang_bind yb,
|
||||
yang_stmt *yspec,
|
||||
|
|
@ -419,7 +423,7 @@ xml_bind_yang(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
xml_bind_yang0_opt(clicon_handle h,
|
||||
xml_bind_yang0_opt(clixon_handle h,
|
||||
cxobj *xt,
|
||||
yang_bind yb,
|
||||
yang_stmt *yspec,
|
||||
|
|
@ -441,15 +445,15 @@ xml_bind_yang0_opt(clicon_handle h,
|
|||
|
||||
switch (yb){
|
||||
case YB_MODULE:
|
||||
if ((ret = populate_self_top(xt, yspec, xerr)) < 0)
|
||||
if ((ret = populate_self_top(h, xt, yspec, xerr)) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case YB_PARENT:
|
||||
if ((ret = populate_self_parent(xt, xsibling, yspec, xerr)) < 0)
|
||||
if ((ret = populate_self_parent(h, xt, xsibling, yspec, xerr)) < 0)
|
||||
goto done;
|
||||
break;
|
||||
default:
|
||||
clicon_err(OE_XML, EINVAL, "Invalid yang binding: %d", yb);
|
||||
clixon_err(OE_XML, EINVAL, "Invalid yang binding: %d", yb);
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
|
@ -538,7 +542,7 @@ xml_bind_yang0_opt(clicon_handle h,
|
|||
* @see xml_bind_yang If only children of xt should be populated, not xt itself
|
||||
*/
|
||||
int
|
||||
xml_bind_yang0(clicon_handle h,
|
||||
xml_bind_yang0(clixon_handle h,
|
||||
cxobj *xt,
|
||||
yang_bind yb,
|
||||
yang_stmt *yspec,
|
||||
|
|
@ -550,18 +554,18 @@ xml_bind_yang0(clicon_handle h,
|
|||
|
||||
switch (yb){
|
||||
case YB_MODULE:
|
||||
if ((ret = populate_self_top(xt, yspec, xerr)) < 0)
|
||||
if ((ret = populate_self_top(h, xt, yspec, xerr)) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case YB_PARENT:
|
||||
if ((ret = populate_self_parent(xt, NULL, yspec, xerr)) < 0)
|
||||
if ((ret = populate_self_parent(h, xt, NULL, yspec, xerr)) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case YB_NONE:
|
||||
ret = 1;
|
||||
break;
|
||||
default:
|
||||
clicon_err(OE_XML, EINVAL, "Invalid yang binding: %d", yb);
|
||||
clixon_err(OE_XML, EINVAL, "Invalid yang binding: %d", yb);
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
|
@ -597,7 +601,7 @@ xml_bind_yang0(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
xml_bind_yang_rpc_rpc(clicon_handle h,
|
||||
xml_bind_yang_rpc_rpc(clixon_handle h,
|
||||
cxobj *x,
|
||||
yang_stmt *yrpc,
|
||||
char *rpcname,
|
||||
|
|
@ -617,7 +621,7 @@ xml_bind_yang_rpc_rpc(clicon_handle h,
|
|||
xc = xml_child_i_type(x, 0, CX_ELMNT); /* Pick first */
|
||||
name = xml_name(xc);
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "Unrecognized parameter: %s in rpc: %s", name, rpcname);
|
||||
|
|
@ -662,7 +666,7 @@ xml_bind_yang_rpc_rpc(clicon_handle h,
|
|||
* XXX if not more action, consider folding into calling function
|
||||
*/
|
||||
static int
|
||||
xml_bind_yang_rpc_action(clicon_handle h,
|
||||
xml_bind_yang_rpc_action(clixon_handle h,
|
||||
cxobj *xn,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
|
|
@ -708,7 +712,7 @@ xml_bind_yang_rpc_action(clicon_handle h,
|
|||
* @see xml_bind_yang_rpc_reply
|
||||
*/
|
||||
int
|
||||
xml_bind_yang_rpc(clicon_handle h,
|
||||
xml_bind_yang_rpc(clixon_handle h,
|
||||
cxobj *xrpc,
|
||||
yang_stmt *yspec,
|
||||
cxobj **xerr)
|
||||
|
|
@ -752,7 +756,7 @@ xml_bind_yang_rpc(clicon_handle h,
|
|||
if (xerr &&
|
||||
netconf_unknown_element_xml(xerr, "protocol", name, "Unrecognized hello element") < 0)
|
||||
goto done;
|
||||
clicon_err(OE_XML, EFAULT, "Unrecognized hello element: %s", name);
|
||||
clixon_err(OE_XML, EFAULT, "Unrecognized hello element: %s", name);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
|
@ -838,7 +842,7 @@ xml_bind_yang_rpc(clicon_handle h,
|
|||
* @see xml_bind_yang For other generic cases
|
||||
*/
|
||||
int
|
||||
xml_bind_yang_rpc_reply(clicon_handle h,
|
||||
xml_bind_yang_rpc_reply(clixon_handle h,
|
||||
cxobj *xrpc,
|
||||
char *name,
|
||||
yang_stmt *yspec,
|
||||
|
|
@ -858,7 +862,7 @@ xml_bind_yang_rpc_reply(clicon_handle h,
|
|||
opname = xml_name(xrpc);
|
||||
if (strcmp(opname, "rpc-reply")){
|
||||
if ((cberr = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cberr, "Internal error, unrecognized netconf operation in backend reply, expected rpc-reply but received: %s", opname);
|
||||
|
|
@ -896,7 +900,7 @@ xml_bind_yang_rpc_reply(clicon_handle h,
|
|||
goto done;
|
||||
if (ret == 0){
|
||||
if ((cberr = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cberr, "Internal error in backend reply: ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue