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:
Olof hagsand 2023-11-13 10:12:52 +01:00
parent 261469be16
commit 24a4991ec8
199 changed files with 4668 additions and 4158 deletions

View file

@ -57,11 +57,13 @@
/* cligen */
#include <cligen/cligen.h>
/* clicon */
/* clixon */
#include "clixon_queue.h"
#include "clixon_hash.h"
#include "clixon_handle.h"
#include "clixon_err.h"
#include "clixon_log.h"
#include "clixon_debug.h"
#include "clixon_yang.h"
#include "clixon_xml.h"
#include "clixon_options.h"
@ -72,7 +74,6 @@
#include "clixon_xpath_ctx.h"
#include "clixon_xpath.h"
#include "clixon_proto.h"
#include "clixon_err.h"
#include "clixon_event.h"
#include "clixon_stream.h"
#include "clixon_err_string.h"
@ -95,7 +96,7 @@
* @retval -1 Error
*/
int
clicon_rpc_connect(clicon_handle h,
clicon_rpc_connect(clixon_handle h,
int *sockp)
{
int retval = -1;
@ -103,7 +104,7 @@ clicon_rpc_connect(clicon_handle h,
int port;
if ((sockstr = clicon_sock_str(h)) == NULL){
clicon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
clixon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
goto done;
}
/* What to do if inet socket? */
@ -121,11 +122,11 @@ clicon_rpc_connect(clicon_handle h,
break;
case AF_INET:
if ((port = clicon_sock_port(h)) < 0){
clicon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
clixon_err(OE_FATAL, 0, "CLICON_SOCK option not set");
goto done;
}
if (port < 0){
clicon_err(OE_FATAL, 0, "CLICON_SOCK_PORT not set");
clixon_err(OE_FATAL, 0, "CLICON_SOCK_PORT not set");
goto done;
}
if (clicon_rpc_connect_inet(h, sockstr, port, sockp) < 0)
@ -149,7 +150,7 @@ clicon_rpc_connect(clicon_handle h,
* @retval -1 Error
*/
static int
clicon_rpc_msg_once(clicon_handle h,
clicon_rpc_msg_once(clixon_handle h,
struct clicon_msg *msg,
int cache,
char **retdata,
@ -195,7 +196,7 @@ clicon_rpc_msg_once(clicon_handle h,
* @see clicon_rpc_close_session
*/
int
clicon_rpc_msg(clicon_handle h,
clicon_rpc_msg(clixon_handle h,
struct clicon_msg *msg,
cxobj **xret0)
{
@ -225,16 +226,16 @@ clicon_rpc_msg(clicon_handle h,
close(s);
s = -1;
clicon_client_socket_set(h, -1);
clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
clixon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
goto done;
}
/* To disable this restart, unset PROTO_RESTART_RECONNECT */
clicon_session_id_del(h);
clicon_log(LOG_WARNING, "The backend was probably restarted and the client has reconnected to the backend. Any locks or candidate edits are lost.");
clixon_log(h, LOG_WARNING, "The backend was probably restarted and the client has reconnected to the backend. Any locks or candidate edits are lost.");
}
#else
clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
clixon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
goto done;
#endif
}
@ -272,7 +273,7 @@ clicon_rpc_msg(clicon_handle h,
* @note xret is populated with yangspec according to standard handle yangspec
*/
int
clicon_rpc_msg_persistent(clicon_handle h,
clicon_rpc_msg_persistent(clixon_handle h,
struct clicon_msg *msg,
cxobj **xret0,
int *sock0)
@ -284,7 +285,7 @@ clicon_rpc_msg_persistent(clicon_handle h,
int eof = 0;
if (sock0 == NULL){
clicon_err(OE_NETCONF, EINVAL, "Missing socket pointer");
clixon_err(OE_NETCONF, EINVAL, "Missing socket pointer");
goto done;
}
#ifdef RPC_USERNAME_ASSERT
@ -302,7 +303,7 @@ clicon_rpc_msg_persistent(clicon_handle h,
/* Note here one could try a restart as done in clicon_rpc_msg, but seems not
* right since if backend is restarted, the notification stream is gone.
*/
clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
clixon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed.");
goto done;
}
clixon_debug(CLIXON_DBG_DEFAULT, "%s retdata:%s", __FUNCTION__, retdata);
@ -345,7 +346,7 @@ clicon_rpc_msg_persistent(clicon_handle h,
* @note This function may send a synchronous(blocking) HELLO request to the backend as a side-effect
*/
static int
session_id_check(clicon_handle h,
session_id_check(clixon_handle h,
uint32_t *session_id)
{
int retval = -1;
@ -381,7 +382,7 @@ session_id_check(clicon_handle h,
* @see clicon_rpc_netconf_xml xml as tree instead of string
*/
int
clicon_rpc_netconf(clicon_handle h,
clicon_rpc_netconf(clixon_handle h,
char *xmlstr,
cxobj **xret,
int *sp)
@ -427,7 +428,7 @@ clicon_rpc_netconf(clicon_handle h,
* @see clicon_rpc_netconf xml as string instead of tree
*/
int
clicon_rpc_netconf_xml(clicon_handle h,
clicon_rpc_netconf_xml(clixon_handle h,
cxobj *xml,
cxobj **xret,
int *sp)
@ -442,11 +443,11 @@ clicon_rpc_netconf_xml(clicon_handle h,
int ret;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
if ((xname = xml_child_i_type(xml, 0, 0)) == NULL){
clicon_err(OE_NETCONF, EINVAL, "Missing rpc name");
clixon_err(OE_NETCONF, EINVAL, "Missing rpc name");
goto done;
}
rpcname = xml_name(xname); /* Store rpc name and use in yang binding after reply */
@ -512,7 +513,7 @@ clicon_rpc_netconf_xml(clicon_handle h,
* @note the netconf return message is yang populated, as well as the return data
*/
int
clicon_rpc_get_config(clicon_handle h,
clicon_rpc_get_config(clixon_handle h,
char *username, // XXX: why is this only rpc call with username parameter?
char *db,
char *xpath,
@ -534,7 +535,7 @@ clicon_rpc_get_config(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -586,7 +587,7 @@ clicon_rpc_get_config(clicon_handle h,
NULL) < 0)
goto done;
if ((xd = xpath_first(xerr, NULL, "rpc-error")) == NULL){
clicon_err(OE_XML, ENOENT, "Expected rpc-error tag but none found(internal)");
clixon_err(OE_XML, ENOENT, "Expected rpc-error tag but none found(internal)");
goto done;
}
}
@ -633,7 +634,7 @@ clicon_rpc_get_config(clicon_handle h,
* @endcode
*/
int
clicon_rpc_edit_config(clicon_handle h,
clicon_rpc_edit_config(clixon_handle h,
char *db,
enum operation_type op,
char *xmlstr)
@ -649,7 +650,7 @@ clicon_rpc_edit_config(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -670,7 +671,11 @@ clicon_rpc_edit_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Editing configuration");
#else
clixon_netconf_error(h, xerr, "Editing configuration", NULL);
#endif
goto done;
}
retval = 0;
@ -699,7 +704,7 @@ clicon_rpc_edit_config(clicon_handle h,
* @endcode
*/
int
clicon_rpc_copy_config(clicon_handle h,
clicon_rpc_copy_config(clixon_handle h,
char *db1,
char *db2)
{
@ -714,7 +719,7 @@ clicon_rpc_copy_config(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -732,7 +737,11 @@ clicon_rpc_copy_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Copying configuration");
#else
clixon_netconf_error(h, xerr, "Copying configuration", NULL);
#endif
goto done;
}
retval = 0;
@ -758,7 +767,7 @@ clicon_rpc_copy_config(clicon_handle h,
* @endcode
*/
int
clicon_rpc_delete_config(clicon_handle h,
clicon_rpc_delete_config(clixon_handle h,
char *db)
{
int retval = -1;
@ -772,7 +781,7 @@ clicon_rpc_delete_config(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -790,7 +799,11 @@ clicon_rpc_delete_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Deleting configuration");
#else
clixon_netconf_error(h, xerr, "Deleting configuration", NULL);
#endif
goto done;
}
retval = 0;
@ -812,7 +825,7 @@ clicon_rpc_delete_config(clicon_handle h,
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_lock(clicon_handle h,
clicon_rpc_lock(clixon_handle h,
char *db)
{
int retval = -1;
@ -826,7 +839,7 @@ clicon_rpc_lock(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -844,7 +857,11 @@ clicon_rpc_lock(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Locking configuration");
#else
clixon_netconf_error(h, xerr, "Locking configuration", NULL);
#endif
goto done;
}
retval = 0;
@ -866,7 +883,7 @@ clicon_rpc_lock(clicon_handle h,
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_unlock(clicon_handle h,
clicon_rpc_unlock(clixon_handle h,
char *db)
{
int retval = -1;
@ -880,7 +897,7 @@ clicon_rpc_unlock(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -898,7 +915,11 @@ clicon_rpc_unlock(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Unlocking configuration");
#else
clixon_netconf_error(h, xerr, "Configuration unlock", NULL);
#endif
goto done;
}
retval = 0;
@ -936,7 +957,7 @@ clicon_rpc_unlock(clicon_handle h,
* if (clicon_rpc_get(h, "/hello/world", nsc, CONTENT_ALL, -1, &xt) < 0)
* err;
* if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
* clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
* clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration");
* err;
* }
* if (xt)
@ -945,11 +966,11 @@ clicon_rpc_unlock(clicon_handle h,
* xml_nsctx_free(nsc);
* @endcode
* @see clicon_rpc_get_config which is almost the same as with content=config, but you can also select dbname
* @see clixon_netconf_error
* @see clixon_err_netconf
* @note the netconf return message is yang populated, as well as the return data
*/
int
clicon_rpc_get(clicon_handle h,
clicon_rpc_get(clixon_handle h,
char *xpath,
cvec *nsc, /* namespace context for filter */
netconf_content content,
@ -984,7 +1005,7 @@ clicon_rpc_get(clicon_handle h,
* if (clicon_rpc_get(h, "/hello/world", nsc, CONTENT_ALL, -1, &xt) < 0)
* err;
* if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
* clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
* clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration");
* err;
* }
* if (xt)
@ -993,11 +1014,11 @@ clicon_rpc_get(clicon_handle h,
* xml_nsctx_free(nsc);
* @endcode
* @see clicon_rpc_get_config which is almost the same as with content=config, but you can also select dbname
* @see clixon_netconf_error
* @see clixon_err_netconf
* @note the netconf return message is yang populated, as well as the return data
*/
int
clicon_rpc_get2(clicon_handle h,
clicon_rpc_get2(clixon_handle h,
char *xpath,
cvec *nsc, /* namespace context for filter */
netconf_content content,
@ -1022,7 +1043,7 @@ clicon_rpc_get2(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1141,7 +1162,7 @@ clicon_rpc_get2(clicon_handle h,
* @note the netconf return message is yang populated, as well as the return data
*/
int
clicon_rpc_get_pageable_list(clicon_handle h,
clicon_rpc_get_pageable_list(clixon_handle h,
char *datastore,
char *xpath,
cvec *nsc, /* namespace context for xpath */
@ -1168,13 +1189,13 @@ clicon_rpc_get_pageable_list(clicon_handle h,
cvec *nscd = NULL;
if (datastore == NULL){
clicon_err(OE_XML, EINVAL, "datastore not given");
clixon_err(OE_XML, EINVAL, "datastore not given");
goto done;
}
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1253,7 +1274,7 @@ clicon_rpc_get_pageable_list(clicon_handle h,
NULL) < 0)
goto done;
if ((xd = xpath_first(xerr, NULL, "rpc-error")) == NULL){
clicon_err(OE_XML, ENOENT, "Expected rpc-error tag but none found(internal)");
clixon_err(OE_XML, ENOENT, "Expected rpc-error tag but none found(internal)");
goto done;
}
}
@ -1293,7 +1314,7 @@ clicon_rpc_get_pageable_list(clicon_handle h,
* @note Maybe separate closing session and closing socket.
*/
int
clicon_rpc_close_session(clicon_handle h)
clicon_rpc_close_session(clixon_handle h)
{
int retval = -1;
struct clicon_msg *msg = NULL;
@ -1307,7 +1328,7 @@ clicon_rpc_close_session(clicon_handle h)
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1329,7 +1350,11 @@ clicon_rpc_close_session(clicon_handle h)
clicon_client_socket_set(h, -1);
}
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Close session");
#else
clixon_netconf_error(h, xerr, "Close session", NULL);
#endif
goto done;
}
retval = 0;
@ -1351,7 +1376,7 @@ clicon_rpc_close_session(clicon_handle h)
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_kill_session(clicon_handle h,
clicon_rpc_kill_session(clixon_handle h,
uint32_t session_id)
{
int retval = -1;
@ -1365,7 +1390,7 @@ clicon_rpc_kill_session(clicon_handle h,
if (session_id_check(h, &my_session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1383,7 +1408,11 @@ clicon_rpc_kill_session(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Kill session");
#else
clixon_netconf_error(h, xerr, "Kill session", NULL);
#endif
goto done;
}
retval = 0;
@ -1407,7 +1436,7 @@ clicon_rpc_kill_session(clicon_handle h,
* @note error returns are logged but not returned
*/
int
clicon_rpc_validate(clicon_handle h,
clicon_rpc_validate(clixon_handle h,
char *db)
{
int retval = -1;
@ -1421,7 +1450,7 @@ clicon_rpc_validate(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1439,7 +1468,11 @@ clicon_rpc_validate(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_VALIDATE_FAILED);
#else
clixon_netconf_error(h, xerr, CLIXON_ERRSTR_VALIDATE_FAILED, NULL);
#endif
retval = 0;
goto done;
}
@ -1469,7 +1502,7 @@ clicon_rpc_validate(clicon_handle h,
* @note error returns are logged but not returned
*/
int
clicon_rpc_commit(clicon_handle h,
clicon_rpc_commit(clixon_handle h,
int confirmed,
int cancel,
uint32_t timeout,
@ -1489,14 +1522,14 @@ clicon_rpc_commit(clicon_handle h,
if (persist_id) {
if ((persist_id_xml = malloc(strlen(persist_id) + strlen(PERSIST_ID_XML_FMT) + 1)) == NULL) {
clicon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
clixon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
}
sprintf(persist_id_xml, PERSIST_ID_XML_FMT, persist_id);
}
if (persist) {
if ((persist_xml = malloc(strlen(persist) + strlen(PERSIST_XML_FMT) + 1)) == NULL) {
clicon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
clixon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
};
sprintf(persist_xml, PERSIST_XML_FMT, persist);
}
@ -1508,7 +1541,7 @@ clicon_rpc_commit(clicon_handle h,
*/
if ((timeout_xml = malloc(10 + 1 + strlen(TIMEOUT_XML_FMT))) == NULL) {
clicon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
clixon_err(OE_UNIX, 0, "malloc: %s", strerror(errno));
};
sprintf(timeout_xml, TIMEOUT_XML_FMT, timeout);
}
@ -1516,7 +1549,7 @@ clicon_rpc_commit(clicon_handle h,
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1546,7 +1579,11 @@ clicon_rpc_commit(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_COMMIT_FAILED);
#else
clixon_netconf_error(h, xerr, CLIXON_ERRSTR_COMMIT_FAILED, NULL);
#endif
retval = 0;
goto done;
}
@ -1574,7 +1611,7 @@ clicon_rpc_commit(clicon_handle h,
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_discard_changes(clicon_handle h)
clicon_rpc_discard_changes(clixon_handle h)
{
int retval = -1;
struct clicon_msg *msg = NULL;
@ -1587,7 +1624,7 @@ clicon_rpc_discard_changes(clicon_handle h)
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1605,7 +1642,11 @@ clicon_rpc_discard_changes(clicon_handle h)
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Discard changes");
#else
clixon_netconf_error(h, xerr, "Discard changes", NULL);
#endif
goto done;
}
retval = 0;
@ -1630,7 +1671,7 @@ clicon_rpc_discard_changes(clicon_handle h)
* @note When using netconf create-subsrciption,status and format is not supported
*/
int
clicon_rpc_create_subscription(clicon_handle h,
clicon_rpc_create_subscription(clixon_handle h,
char *stream,
char *filter,
int *s0)
@ -1646,7 +1687,7 @@ clicon_rpc_create_subscription(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1670,7 +1711,11 @@ clicon_rpc_create_subscription(clicon_handle h,
if (clicon_rpc_msg_persistent(h, msg, &xret, s0) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Create subscription");
#else
clixon_netconf_error(h, xerr, "Create subscription", NULL);
#endif
goto done;
}
retval = 0;
@ -1692,7 +1737,7 @@ clicon_rpc_create_subscription(clicon_handle h,
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_debug(clicon_handle h,
clicon_rpc_debug(clixon_handle h,
int level)
{
int retval = -1;
@ -1706,7 +1751,7 @@ clicon_rpc_debug(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1725,11 +1770,15 @@ clicon_rpc_debug(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug");
#else
clixon_netconf_error(h, xerr, "Debug", NULL);
#endif
goto done;
}
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
clicon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
clixon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
goto done;
}
retval = 0;
@ -1755,7 +1804,7 @@ clicon_rpc_debug(clicon_handle h,
* 3 CLICON_BACKEND_RESTCONF_PROCESS is true (so that backend restarts restconf)
*/
int
clicon_rpc_restconf_debug(clicon_handle h,
clicon_rpc_restconf_debug(clixon_handle h,
int level)
{
int retval = -1;
@ -1769,7 +1818,7 @@ clicon_rpc_restconf_debug(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1791,11 +1840,15 @@ clicon_rpc_restconf_debug(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug");
#else
clixon_netconf_error(h, xerr, "Debug", NULL);
#endif
goto done;
}
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
clicon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
clixon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
goto done;
}
if ((retval = clicon_rpc_commit(h, 0, 0, 0, NULL, NULL)) < 1)
@ -1826,7 +1879,7 @@ clicon_rpc_restconf_debug(clicon_handle h,
* Example: cl:cli, cl:restconf, cl:netconf
*/
int
clicon_hello_req(clicon_handle h,
clicon_hello_req(clixon_handle h,
char *transport,
char *source_host,
uint32_t *id)
@ -1845,7 +1898,7 @@ clicon_hello_req(clicon_handle h,
char *prefix = NULL;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<hello xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1880,16 +1933,20 @@ clicon_hello_req(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Hello");
#else
clixon_netconf_error(h, xerr, "Hello", NULL);
#endif
goto done;
}
if ((x = xpath_first(xret, NULL, "hello/session-id")) == NULL){
clicon_err(OE_XML, 0, "hello session-id");
clixon_err(OE_XML, 0, "hello session-id");
goto done;
}
b = xml_body(x);
if ((ret = parse_uint32(b, id, NULL)) <= 0){
clicon_err(OE_XML, errno, "parse_uint32");
clixon_err(OE_XML, errno, "parse_uint32");
goto done;
}
retval = 0;
@ -1911,7 +1968,7 @@ clicon_hello_req(clicon_handle h,
* @retval -1 Error and logged to syslog
*/
int
clicon_rpc_restart_plugin(clicon_handle h,
clicon_rpc_restart_plugin(clixon_handle h,
char *plugin)
{
int retval = -1;
@ -1925,7 +1982,7 @@ clicon_rpc_restart_plugin(clicon_handle h,
if (session_id_check(h, &session_id) < 0)
goto done;
if ((cb = cbuf_new()) == NULL){
clicon_err(OE_XML, errno, "cbuf_new");
clixon_err(OE_XML, errno, "cbuf_new");
goto done;
}
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
@ -1944,11 +2001,11 @@ clicon_rpc_restart_plugin(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(h, xerr, "Debug", NULL);
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug");
goto done;
}
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
clicon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
clixon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
goto done;
}
retval = 0;