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
|
|
@ -62,7 +62,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_client.h"
|
||||
|
|
@ -105,11 +105,11 @@ ce_client_descr(struct client_entry *ce,
|
|||
char *id = NULL;
|
||||
|
||||
if (ce == NULL || cbp == NULL){
|
||||
clicon_err(OE_UNIX, EINVAL, "ce or cbp is NULL");
|
||||
clixon_err(OE_UNIX, EINVAL, "ce or cbp is NULL");
|
||||
goto done;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (ce->ce_transport){
|
||||
|
|
@ -137,7 +137,7 @@ ce_client_descr(struct client_entry *ce,
|
|||
* @see stream_ss_add
|
||||
*/
|
||||
int
|
||||
ce_event_cb(clicon_handle h,
|
||||
ce_event_cb(clixon_handle h,
|
||||
int op,
|
||||
cxobj *event,
|
||||
void *arg)
|
||||
|
|
@ -158,7 +158,7 @@ ce_event_cb(clicon_handle h,
|
|||
goto done;
|
||||
if (send_msg_notify_xml(h, ce->ce_s, cbuf_get(cbce), event) < 0){
|
||||
if (errno == ECONNRESET || errno == EPIPE){
|
||||
clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr);
|
||||
clixon_log(h, LOG_WARNING, "client %d reset", ce->ce_nr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ ce_event_cb(clicon_handle h,
|
|||
* @see xmldb_unlock_all unlocks, but does not call user callbacks which is a backend thing
|
||||
*/
|
||||
static int
|
||||
release_all_dbs(clicon_handle h,
|
||||
release_all_dbs(clixon_handle h,
|
||||
uint32_t id)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -224,7 +224,7 @@ release_all_dbs(clicon_handle h,
|
|||
* @see RFC 6022
|
||||
*/
|
||||
int
|
||||
backend_monitoring_state_get(clicon_handle h,
|
||||
backend_monitoring_state_get(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
char *xpath,
|
||||
cvec *nsc,
|
||||
|
|
@ -238,7 +238,7 @@ backend_monitoring_state_get(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;
|
||||
}
|
||||
cprintf(cb, "<netconf-state xmlns=\"%s\">", NETCONF_MONITORING_NAMESPACE);
|
||||
|
|
@ -248,7 +248,7 @@ backend_monitoring_state_get(clicon_handle h,
|
|||
cprintf(cb, "<session-id>%u</session-id>", ce->ce_id);
|
||||
if (ce->ce_transport == NULL){
|
||||
#ifdef NOTYET // XXX: too strict, race conditions in clixon_snmp
|
||||
clicon_err(OE_XML, 0, "Mandatory element transport missing");
|
||||
clixon_err(OE_XML, 0, "Mandatory element transport missing");
|
||||
goto done;
|
||||
#else
|
||||
cprintf(cb, "<transport xmlns:%s=\"%s\">cl:netconf</transport>",
|
||||
|
|
@ -264,7 +264,7 @@ backend_monitoring_state_get(clicon_handle h,
|
|||
cprintf(cb, "<source-host>%s</source-host>", ce->ce_source_host);
|
||||
if (ce->ce_time.tv_sec != 0){
|
||||
if (time2str(&ce->ce_time, timestr, sizeof(timestr)) < 0){
|
||||
clicon_err(OE_UNIX, errno, "time2str");
|
||||
clixon_err(OE_UNIX, errno, "time2str");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<login-time>%s</login-time>", timestr);
|
||||
|
|
@ -304,7 +304,7 @@ backend_monitoring_state_get(clicon_handle h,
|
|||
* @see backend_client_delete for actual deallocation of client entry struct
|
||||
*/
|
||||
int
|
||||
backend_client_rm(clicon_handle h,
|
||||
backend_client_rm(clixon_handle h,
|
||||
struct client_entry *ce)
|
||||
{
|
||||
struct client_entry *c;
|
||||
|
|
@ -316,7 +316,7 @@ backend_client_rm(clicon_handle h,
|
|||
|
||||
/* If the confirmed-commit feature is enabled, rollback any ephemeral commit originated by this client */
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL) {
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
|
||||
|
|
@ -326,7 +326,7 @@ backend_client_rm(clicon_handle h,
|
|||
|
||||
if (myid == confirmed_commit_session_id_get(h)) {
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "ok, rolling back");
|
||||
clicon_log(LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
|
||||
clixon_log(h, LOG_NOTICE, "a client with an active ephemeral confirmed-commit has disconnected; rolling back");
|
||||
|
||||
/* do_rollback errors are logged internally and there is no client to report errors to, so errors are
|
||||
* ignored here.
|
||||
|
|
@ -369,7 +369,7 @@ backend_client_rm(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
clixon_stats_datastore_get(clicon_handle h,
|
||||
clixon_stats_datastore_get(clixon_handle h,
|
||||
char *dbname,
|
||||
cbuf *cb)
|
||||
{
|
||||
|
|
@ -412,7 +412,7 @@ clixon_stats_datastore_get(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
clixon_stats_module_get(clicon_handle h,
|
||||
clixon_stats_module_get(clixon_handle h,
|
||||
yang_stmt *ys,
|
||||
cbuf *cb)
|
||||
{
|
||||
|
|
@ -452,7 +452,7 @@ clixon_stats_module_get(clicon_handle h,
|
|||
* But this could discard other previous changes to candidate.
|
||||
*/
|
||||
static int
|
||||
from_client_edit_config(clicon_handle h,
|
||||
from_client_edit_config(clixon_handle h,
|
||||
cxobj *xn,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -480,7 +480,7 @@ from_client_edit_config(clicon_handle h,
|
|||
|
||||
username = clicon_username_get(h);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec9");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec9");
|
||||
goto done;
|
||||
}
|
||||
if ((target = netconf_db_find(xn, "target")) == NULL){
|
||||
|
|
@ -489,7 +489,7 @@ from_client_edit_config(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* Check if target locked by other client */
|
||||
|
|
@ -572,7 +572,7 @@ from_client_edit_config(clicon_handle h,
|
|||
if (xml_sort_recurse(xc) < 0)
|
||||
goto done;
|
||||
if ((ret = xmldb_put(h, target, operation, xc, username, cbret)) < 0){
|
||||
if (netconf_operation_failed(cbret, "protocol", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "protocol", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -614,14 +614,14 @@ from_client_edit_config(clicon_handle h,
|
|||
}
|
||||
}
|
||||
if ((ret = candidate_commit(h, NULL, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
xmldb_copy(h, "running", "candidate");
|
||||
goto ok;
|
||||
}
|
||||
if (ret == 0){ /* discard */
|
||||
if (xmldb_copy(h, "running", "candidate") < 0){
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -632,13 +632,13 @@ from_client_edit_config(clicon_handle h,
|
|||
if ((attr = xml_find_value(xn, "copystartup")) != NULL &&
|
||||
strcmp(attr,"true") == 0){
|
||||
if (xmldb_copy(h, "running", "startup") < 0){
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
if (cbuf_len(cbret) != 0){
|
||||
clicon_err(OE_NETCONF, EINVAL, "Internal error: cbret is not empty");
|
||||
clixon_err(OE_NETCONF, EINVAL, "Internal error: cbret is not empty");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok", NETCONF_BASE_NAMESPACE);
|
||||
|
|
@ -675,7 +675,7 @@ from_client_edit_config(clicon_handle h,
|
|||
* - access denied if user lacks create/delete/update
|
||||
*/
|
||||
static int
|
||||
from_client_copy_config(clicon_handle h,
|
||||
from_client_copy_config(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -696,7 +696,7 @@ from_client_copy_config(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if ((target = netconf_db_find(xe, "target")) == NULL){
|
||||
|
|
@ -714,10 +714,10 @@ from_client_copy_config(clicon_handle h,
|
|||
}
|
||||
if (xmldb_copy(h, source, target) < 0){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Copy %s datastore to %s: %s", source, target, clicon_err_reason);
|
||||
cprintf(cbmsg, "Copy %s datastore to %s: %s", source, target, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "application", cbuf_get(cbmsg))< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -745,7 +745,7 @@ from_client_copy_config(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_delete_config(clicon_handle h,
|
||||
from_client_delete_config(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -767,7 +767,7 @@ from_client_delete_config(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* Check if target locked by other client */
|
||||
|
|
@ -780,20 +780,20 @@ from_client_delete_config(clicon_handle h,
|
|||
}
|
||||
if (xmldb_delete(h, target) < 0){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Delete %s datastore: %s", target, clicon_err_reason);
|
||||
cprintf(cbmsg, "Delete %s datastore: %s", target, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "protocol", cbuf_get(cbmsg))< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (xmldb_create(h, target) < 0){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Create %s datastore: %s", target, clicon_err_reason);
|
||||
cprintf(cbmsg, "Create %s datastore: %s", target, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "protocol", cbuf_get(cbmsg))< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -821,7 +821,7 @@ from_client_delete_config(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_lock(clicon_handle h,
|
||||
from_client_lock(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -837,7 +837,7 @@ from_client_lock(clicon_handle h,
|
|||
yang_stmt *yspec;
|
||||
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if ((db = netconf_db_find(xe, "target")) == NULL){
|
||||
|
|
@ -846,7 +846,7 @@ from_client_lock(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
|
|
@ -908,7 +908,7 @@ from_client_lock(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_unlock(clicon_handle h,
|
||||
from_client_unlock(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -927,7 +927,7 @@ from_client_unlock(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
iddb = xmldb_islocked(h, db);
|
||||
|
|
@ -978,7 +978,7 @@ from_client_unlock(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_close_session(clicon_handle h,
|
||||
from_client_close_session(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1005,7 +1005,7 @@ from_client_close_session(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_kill_session(clicon_handle h,
|
||||
from_client_kill_session(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1070,7 +1070,7 @@ from_client_kill_session(clicon_handle h,
|
|||
* </create-subscription>
|
||||
*/
|
||||
static int
|
||||
from_client_create_subscription(clicon_handle h,
|
||||
from_client_create_subscription(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1163,7 +1163,7 @@ from_client_create_subscription(clicon_handle h,
|
|||
* @see RFC6022, ietf-netconf-monitoring.yang
|
||||
*/
|
||||
static int
|
||||
from_client_get_schema(clicon_handle h,
|
||||
from_client_get_schema(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1184,7 +1184,7 @@ from_client_get_schema(clicon_handle h,
|
|||
const char *filename;
|
||||
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if ((nsc = xml_nsctx_init(NULL, NETCONF_MONITORING_NAMESPACE)) == NULL)
|
||||
|
|
@ -1229,7 +1229,7 @@ from_client_get_schema(clicon_handle h,
|
|||
}
|
||||
if (ymatch == NULL){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (version)
|
||||
|
|
@ -1242,7 +1242,7 @@ from_client_get_schema(clicon_handle h,
|
|||
}
|
||||
if (format && strcmp(format, "yang") != 0){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Format not supported: %s", format);
|
||||
|
|
@ -1253,7 +1253,7 @@ from_client_get_schema(clicon_handle h,
|
|||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><data xmlns=\"%s\">",
|
||||
NETCONF_BASE_NAMESPACE, NETCONF_MONITORING_NAMESPACE);
|
||||
if ((cbyang = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if ((filename = yang_filename_get(ymatch)) != NULL){
|
||||
|
|
@ -1285,7 +1285,7 @@ from_client_get_schema(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_debug(clicon_handle h,
|
||||
from_client_debug(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1302,9 +1302,9 @@ from_client_debug(clicon_handle h,
|
|||
}
|
||||
level = atoi(valstr);
|
||||
|
||||
clixon_debug_init(level, NULL); /* 0: dont debug, 1:debug */
|
||||
clixon_debug_init(h, level); /* 0: dont debug, 1:debug */
|
||||
setlogmask(LOG_UPTO(level?LOG_DEBUG:LOG_INFO)); /* for syslog */
|
||||
clicon_log(LOG_NOTICE, "%s debug:%d", __FUNCTION__, clixon_debug_get());
|
||||
clixon_log(h, LOG_NOTICE, "%s debug:%d", __FUNCTION__, clixon_debug_get());
|
||||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE);
|
||||
ok:
|
||||
retval = 0;
|
||||
|
|
@ -1323,7 +1323,7 @@ from_client_debug(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_ping(clicon_handle h,
|
||||
from_client_ping(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1344,7 +1344,7 @@ from_client_ping(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_stats(clicon_handle h,
|
||||
from_client_stats(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1437,7 +1437,7 @@ from_client_stats(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_restart_plugin(clicon_handle h,
|
||||
from_client_restart_plugin(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1485,7 +1485,7 @@ from_client_restart_plugin(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_process_control(clicon_handle h,
|
||||
from_client_process_control(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1529,7 +1529,7 @@ from_client_process_control(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_hello(clicon_handle h,
|
||||
from_client_hello(clixon_handle h,
|
||||
cxobj *x,
|
||||
struct client_entry *ce,
|
||||
cbuf *cbret)
|
||||
|
|
@ -1539,13 +1539,13 @@ from_client_hello(clicon_handle h,
|
|||
|
||||
if ((val = xml_find_type_value(x, "cl", "transport", CX_ATTR)) != NULL){
|
||||
if ((ce->ce_transport = strdup(val)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ((val = xml_find_type_value(x, "cl", "source-host", CX_ATTR)) != NULL){
|
||||
if ((ce->ce_source_host = strdup(val)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -1566,7 +1566,7 @@ from_client_hello(clicon_handle h,
|
|||
* propagated back to client.
|
||||
*/
|
||||
static int
|
||||
from_client_msg(clicon_handle h,
|
||||
from_client_msg(clixon_handle h,
|
||||
struct client_entry *ce,
|
||||
struct clicon_msg *msg)
|
||||
{
|
||||
|
|
@ -1598,7 +1598,7 @@ from_client_msg(clicon_handle h,
|
|||
* as wither rpc-error or by positive response.
|
||||
*/
|
||||
if ((cbret = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* Decode msg from client -> xml top (ct) and session id
|
||||
|
|
@ -1627,7 +1627,7 @@ from_client_msg(clicon_handle h,
|
|||
goto reply;
|
||||
}
|
||||
if ((x = xml_child_i_type(xt, 0, CX_ELMNT)) == NULL){ /* Shouldnt happen */
|
||||
clicon_err(OE_XML, EFAULT, "No xml req (shouldnt happen)");
|
||||
clixon_err(OE_XML, EFAULT, "No xml req (shouldnt happen)");
|
||||
goto done;
|
||||
}
|
||||
rpcname = xml_name(x);
|
||||
|
|
@ -1647,7 +1647,7 @@ from_client_msg(clicon_handle h,
|
|||
(ce0 = ce_find_byid(backend_client_list(h), op_id)) != NULL &&
|
||||
ce0->ce_transport){
|
||||
if ((ce->ce_transport = strdup(ce0->ce_transport)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -1665,7 +1665,7 @@ from_client_msg(clicon_handle h,
|
|||
else if (strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){
|
||||
cbuf *cbmsg = NULL;
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "No appropriate namespace found for: %s %s", rpcprefix, rpcname);
|
||||
|
|
@ -1724,7 +1724,7 @@ from_client_msg(clicon_handle h,
|
|||
goto reply;
|
||||
}
|
||||
if ((ymod = ys_module(ye)) == NULL){
|
||||
clicon_err(OE_XML, ENOENT, "rpc yang does not have module");
|
||||
clixon_err(OE_XML, ENOENT, "rpc yang does not have module");
|
||||
goto done;
|
||||
}
|
||||
module = yang_argument_get(ymod);
|
||||
|
|
@ -1762,11 +1762,11 @@ from_client_msg(clicon_handle h,
|
|||
goto reply;
|
||||
}
|
||||
}
|
||||
clicon_err_reset();
|
||||
clixon_err_reset();
|
||||
if ((ret = rpc_callback_call(h, xe, ce, &nr, cbret)) < 0){
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
clicon_log(LOG_NOTICE, "%s Error in rpc_callback_call:%s", __FUNCTION__, xml_name(xe));
|
||||
clixon_log(h, LOG_NOTICE, "%s Error in rpc_callback_call:%s", __FUNCTION__, xml_name(xe));
|
||||
ce->ce_out_rpc_errors++;
|
||||
netconf_monitoring_counter_inc(h, "out-rpc-errors");
|
||||
goto reply; /* Dont quit here on user callbacks */
|
||||
|
|
@ -1792,7 +1792,8 @@ from_client_msg(clicon_handle h,
|
|||
} /* while */
|
||||
reply:
|
||||
if (cbuf_len(cbret) == 0)
|
||||
if (netconf_operation_failed(cbret, "application", clicon_errno?clicon_err_reason:"unknown")< 0)
|
||||
if (netconf_operation_failed(cbret, "application",
|
||||
clixon_err_category()?clixon_err_reason():"unknown")< 0)
|
||||
goto done;
|
||||
// XXX clixon_debug(CLIXON_DBG_MSG, "Reply:%s", cbuf_get(cbret));
|
||||
/* XXX problem here is that cbret has not been parsed so may contain
|
||||
|
|
@ -1810,7 +1811,7 @@ from_client_msg(clicon_handle h,
|
|||
* the (UNIX domain) socket.
|
||||
*/
|
||||
case ECONNRESET:
|
||||
clicon_log(LOG_WARNING, "client rpc reset");
|
||||
clixon_log(h, LOG_WARNING, "client rpc reset");
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
|
|
@ -1833,9 +1834,9 @@ from_client_msg(clicon_handle h,
|
|||
cbuf_free(cbce);
|
||||
if (cbret)
|
||||
cbuf_free(cbret);
|
||||
/* Sanity: log if clicon_err() is not called ! */
|
||||
if (retval < 0 && clicon_errno < 0)
|
||||
clicon_log(LOG_NOTICE, "%s: Internal error: No clicon_err call on RPC error (message: %s)",
|
||||
/* Sanity: log if clixon_err() is not called ! */
|
||||
if (retval < 0 && clixon_err_category() < 0)
|
||||
clixon_log(h, LOG_NOTICE, "%s: Internal error: No clixon_err call on RPC error (message: %s)",
|
||||
__FUNCTION__, rpc?rpc:"");
|
||||
// clixon_debug(CLIXON_DBG_DEFAULT, "%s retval:%d", __FUNCTION__, retval);
|
||||
return retval;// -1 here terminates backend
|
||||
|
|
@ -1856,13 +1857,13 @@ from_client(int s,
|
|||
int retval = -1;
|
||||
struct clicon_msg *msg = NULL;
|
||||
struct client_entry *ce = (struct client_entry *)arg;
|
||||
clicon_handle h = ce->ce_handle;
|
||||
clixon_handle h = ce->ce_handle;
|
||||
int eof = 0;
|
||||
cbuf *cbce = NULL;
|
||||
|
||||
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
if (s != ce->ce_s){
|
||||
clicon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
|
||||
clixon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
|
||||
goto done;
|
||||
}
|
||||
if (ce_client_descr(ce, &cbce) < 0)
|
||||
|
|
@ -1894,7 +1895,7 @@ from_client(int s,
|
|||
* @see ietf-netconf@2011-06-01.yang
|
||||
*/
|
||||
int
|
||||
backend_rpc_init(clicon_handle h)
|
||||
backend_rpc_init(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int backend_monitoring_state_get(clicon_handle h, yang_stmt *yspec, char *xpath, cvec *nsc, cxobj **xret, cxobj **xerr);
|
||||
int backend_client_rm(clicon_handle h, struct client_entry *ce);
|
||||
int backend_monitoring_state_get(clixon_handle h, yang_stmt *yspec, char *xpath, cvec *nsc, cxobj **xret, cxobj **xerr);
|
||||
int backend_client_rm(clixon_handle h, struct client_entry *ce);
|
||||
int from_client(int fd, void *arg);
|
||||
int backend_rpc_init(clicon_handle h);
|
||||
int backend_rpc_init(clixon_handle h);
|
||||
|
||||
#endif /* _BACKEND_CLIENT_H_ */
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
generic_validate(clicon_handle h,
|
||||
generic_validate(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
transaction_data_t *td,
|
||||
cxobj **xret)
|
||||
|
|
@ -158,7 +158,7 @@ generic_validate(clicon_handle h,
|
|||
* @see validate_common for incoming validate/commit
|
||||
*/
|
||||
static int
|
||||
startup_common(clicon_handle h,
|
||||
startup_common(clixon_handle h,
|
||||
char *db,
|
||||
transaction_data_t *td,
|
||||
cbuf *cbret)
|
||||
|
|
@ -189,7 +189,7 @@ startup_common(clicon_handle h,
|
|||
/* Print upgraded db: -q backend switch for debugging/ showing upgraded config only */
|
||||
if (clicon_quit_upgrade_get(h) == 1){
|
||||
xml_print(stderr, xerr);
|
||||
clicon_err(OE_XML, 0, "invalid configuration before upgrade");
|
||||
clixon_err(OE_XML, 0, "invalid configuration before upgrade");
|
||||
exit(0); /* This is fairly abrupt , but need to avoid side-effects of rewinding
|
||||
* See similar clause below
|
||||
*/
|
||||
|
|
@ -205,12 +205,12 @@ startup_common(clicon_handle h,
|
|||
}
|
||||
clixon_debug_xml(CLIXON_DBG_DETAIL, xt, "startup");
|
||||
if (msdiff && msdiff->md_status == 0){ // Possibly check for CLICON_XMLDB_MODSTATE
|
||||
clicon_log(LOG_WARNING, "Modstate expected in startup datastore but not found\n"
|
||||
clixon_log(h, LOG_WARNING, "Modstate expected in startup datastore but not found\n"
|
||||
"This may indicate that the datastore is not initialized corrrectly, such as copy/pasted.\n"
|
||||
"It may also be normal bootstrapping since module state will be written on next datastore save");
|
||||
}
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "Yang spec not set");
|
||||
clixon_err(OE_YANG, 0, "Yang spec not set");
|
||||
goto done;
|
||||
}
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "Reading startup config done");
|
||||
|
|
@ -237,16 +237,16 @@ startup_common(clicon_handle h,
|
|||
if ((ret = xml_bind_yang(h, xt, YB_MODULE, yspec, &xret)) < 1){
|
||||
if (ret == 0){
|
||||
/* invalid */
|
||||
clicon_err(OE_XML, EFAULT, "invalid configuration");
|
||||
clixon_err(OE_XML, EFAULT, "invalid configuration");
|
||||
}
|
||||
else {
|
||||
/* error */
|
||||
xml_print(stderr, xret);
|
||||
clicon_err(OE_XML, 0, "%s: YANG binding error", __func__);
|
||||
clixon_err(OE_XML, 0, "%s: YANG binding error", __func__);
|
||||
}
|
||||
} /* sort yang */
|
||||
else if (xml_sort_recurse(xt) < 0) {
|
||||
clicon_err(OE_XML, EFAULT, "Yang sort error");
|
||||
clixon_err(OE_XML, EFAULT, "Yang sort error");
|
||||
}
|
||||
if (xmldb_dump(h, stdout, xt) < 0)
|
||||
goto done;
|
||||
|
|
@ -345,7 +345,7 @@ startup_common(clicon_handle h,
|
|||
* @retval -1 Error - or validation failed (but cbret not set)
|
||||
*/
|
||||
int
|
||||
startup_validate(clicon_handle h,
|
||||
startup_validate(clixon_handle h,
|
||||
char *db,
|
||||
cxobj **xtr,
|
||||
cbuf *cbret)
|
||||
|
|
@ -396,7 +396,7 @@ startup_validate(clicon_handle h,
|
|||
* Only called from startup_mode_startup
|
||||
*/
|
||||
int
|
||||
startup_commit(clicon_handle h,
|
||||
startup_commit(clixon_handle h,
|
||||
char *db,
|
||||
cbuf *cbret)
|
||||
{
|
||||
|
|
@ -405,7 +405,7 @@ startup_commit(clicon_handle h,
|
|||
transaction_data_t *td = NULL;
|
||||
|
||||
if (strcmp(db,"running")==0){
|
||||
clicon_err(OE_FATAL, 0, "Invalid startup db: %s", db);
|
||||
clixon_err(OE_FATAL, 0, "Invalid startup db: %s", db);
|
||||
goto done;
|
||||
}
|
||||
/* Handcraft a transition with only target and add trees */
|
||||
|
|
@ -479,7 +479,7 @@ startup_commit(clicon_handle h,
|
|||
* @see startup_common for startup scenario
|
||||
*/
|
||||
static int
|
||||
validate_common(clicon_handle h,
|
||||
validate_common(clixon_handle h,
|
||||
char *db,
|
||||
transaction_data_t *td,
|
||||
cxobj **xret)
|
||||
|
|
@ -491,7 +491,7 @@ validate_common(clicon_handle h,
|
|||
int ret;
|
||||
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
clixon_err(OE_FATAL, 0, "No DB_SPEC");
|
||||
goto done;
|
||||
}
|
||||
/* This is the state we are going to */
|
||||
|
|
@ -581,7 +581,7 @@ validate_common(clicon_handle h,
|
|||
* @retval -1 Error - or validation failed
|
||||
*/
|
||||
int
|
||||
candidate_validate(clicon_handle h,
|
||||
candidate_validate(clixon_handle h,
|
||||
char *db,
|
||||
cbuf *cbret)
|
||||
{
|
||||
|
|
@ -592,7 +592,7 @@ candidate_validate(clicon_handle h,
|
|||
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
if (db == NULL || cbret == NULL){
|
||||
clicon_err(OE_CFG, EINVAL, "db or cbret is NULL");
|
||||
clixon_err(OE_CFG, EINVAL, "db or cbret is NULL");
|
||||
goto done;
|
||||
}
|
||||
/* 1. Start transaction */
|
||||
|
|
@ -602,23 +602,23 @@ candidate_validate(clicon_handle h,
|
|||
if ((ret = validate_common(h, db, td, &xret)) < 0){
|
||||
/* A little complex due to several sources of validation fails or errors.
|
||||
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
||||
* use clicon_err.
|
||||
* use clixon_err.
|
||||
* TODO: -1 return should be fatal error, not failed validation
|
||||
*/
|
||||
if (!cbuf_len(cbret) &&
|
||||
netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
if (ret == 0){
|
||||
if (xret == NULL){
|
||||
clicon_err(OE_CFG, EINVAL, "xret is NULL");
|
||||
clixon_err(OE_CFG, EINVAL, "xret is NULL");
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml2cbuf(cbret, xret, 0, 0, NULL, -1, 0) < 0)
|
||||
goto done;
|
||||
if (!cbuf_len(cbret) &&
|
||||
netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ candidate_validate(clicon_handle h,
|
|||
* @retval -1 Error - or validation failed
|
||||
*/
|
||||
int
|
||||
candidate_commit(clicon_handle h,
|
||||
candidate_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
char *db,
|
||||
uint32_t myid,
|
||||
|
|
@ -694,7 +694,7 @@ candidate_commit(clicon_handle h,
|
|||
* to activate it.
|
||||
*/
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL) {
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -786,7 +786,7 @@ candidate_commit(clicon_handle h,
|
|||
* candidate_commit() method.
|
||||
*/
|
||||
int
|
||||
from_client_commit(clicon_handle h,
|
||||
from_client_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -801,7 +801,7 @@ from_client_commit(clicon_handle h,
|
|||
yang_stmt *yspec;
|
||||
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL) {
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
|
||||
|
|
@ -814,7 +814,7 @@ from_client_commit(clicon_handle h,
|
|||
iddb = xmldb_islocked(h, "running");
|
||||
if (iddb && myid != iddb){
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (netconf_in_use(cbret, "protocol", "Operation failed, lock is already held") < 0)
|
||||
|
|
@ -824,7 +824,7 @@ from_client_commit(clicon_handle h,
|
|||
if ((ret = candidate_commit(h, xe, "candidate", myid, 0, cbret)) < 0){ /* Assume validation fail, nofatal */
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "Commit candidate failed");
|
||||
if (ret < 0)
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -852,7 +852,7 @@ from_client_commit(clicon_handle h,
|
|||
* NACM: No datastore permissions are needed.
|
||||
*/
|
||||
int
|
||||
from_client_discard_changes(clicon_handle h,
|
||||
from_client_discard_changes(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -868,7 +868,7 @@ from_client_discard_changes(clicon_handle h,
|
|||
iddb = xmldb_islocked(h, "candidate");
|
||||
if (iddb && myid != iddb){
|
||||
if ((cbx = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbx, "<session-id>%u</session-id>", iddb);
|
||||
|
|
@ -877,7 +877,7 @@ from_client_discard_changes(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
if (xmldb_copy(h, "running", "candidate") < 0){
|
||||
if (netconf_operation_failed(cbret, "application", clicon_err_reason)< 0)
|
||||
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
|
|
@ -903,7 +903,7 @@ from_client_discard_changes(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
from_client_validate(clicon_handle h,
|
||||
from_client_validate(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -935,7 +935,7 @@ from_client_validate(clicon_handle h,
|
|||
* difficult in the general case.
|
||||
*/
|
||||
int
|
||||
from_client_restart_one(clicon_handle h,
|
||||
from_client_restart_one(clixon_handle h,
|
||||
clixon_plugin_t *cp,
|
||||
cbuf *cbret)
|
||||
{
|
||||
|
|
@ -1065,7 +1065,7 @@ running ----|-------+---------------> RUNNING FAILSAFE
|
|||
tmp |---------------------->
|
||||
*/
|
||||
int
|
||||
load_failsafe(clicon_handle h,
|
||||
load_failsafe(clixon_handle h,
|
||||
char *phase)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -1076,13 +1076,13 @@ load_failsafe(clicon_handle h,
|
|||
phase = phase == NULL ? "(unknown)" : phase;
|
||||
|
||||
if ((cbret = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if ((ret = xmldb_exists(h, db)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){ /* No it does not exist, fail */
|
||||
clicon_err(OE_DB, 0, "%s failed and no Failsafe database found, exiting", phase);
|
||||
clixon_err(OE_DB, 0, "%s failed and no Failsafe database found, exiting", phase);
|
||||
goto done;
|
||||
}
|
||||
/* Copy original running to tmp as backup (restore if error) */
|
||||
|
|
@ -1097,10 +1097,10 @@ load_failsafe(clicon_handle h,
|
|||
if (ret < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
clicon_err(OE_DB, 0, "%s failed, Failsafe database validation failed %s", phase, cbuf_get(cbret));
|
||||
clixon_err(OE_DB, 0, "%s failed, Failsafe database validation failed %s", phase, cbuf_get(cbret));
|
||||
goto done;
|
||||
}
|
||||
clicon_log(LOG_NOTICE, "%s failed, Failsafe database loaded ", phase);
|
||||
clixon_log(h, LOG_NOTICE, "%s failed, Failsafe database loaded ", phase);
|
||||
retval = 0;
|
||||
done:
|
||||
if (cbret)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -83,17 +83,17 @@ struct confirmed_commit {
|
|||
char *cc_persist_id; /* a value given by a client in the confirmed-commit */
|
||||
uint32_t cc_session_id; /* the session_id of the client that gave no <persist> value */
|
||||
int (*cc_fn)(int, void*); /* function pointer for rollback event (rollback_fn()) */
|
||||
void *cc_arg; /* clicon_handle that will be passed to rollback_fn() */
|
||||
void *cc_arg; /* clixon_handle that will be passed to rollback_fn() */
|
||||
};
|
||||
|
||||
int
|
||||
confirmed_commit_init(clicon_handle h)
|
||||
confirmed_commit_init(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
||||
if ((cc = calloc(1, sizeof(*cc))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "calloc");
|
||||
clixon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
}
|
||||
cc->cc_state = INACTIVE;
|
||||
|
|
@ -110,7 +110,7 @@ confirmed_commit_init(clicon_handle h)
|
|||
* @retval 0 OK
|
||||
*/
|
||||
int
|
||||
confirmed_commit_free(clicon_handle h)
|
||||
confirmed_commit_free(clixon_handle h)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ confirmed_commit_free(clicon_handle h)
|
|||
* Accessor functions
|
||||
*/
|
||||
enum confirmed_commit_state
|
||||
confirmed_commit_state_get(clicon_handle h)
|
||||
confirmed_commit_state_get(clixon_handle h)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ confirmed_commit_state_get(clicon_handle h)
|
|||
}
|
||||
|
||||
static int
|
||||
confirmed_commit_state_set(clicon_handle h,
|
||||
confirmed_commit_state_set(clixon_handle h,
|
||||
enum confirmed_commit_state state)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
|
@ -148,7 +148,7 @@ confirmed_commit_state_set(clicon_handle h,
|
|||
}
|
||||
|
||||
char *
|
||||
confirmed_commit_persist_id_get(clicon_handle h)
|
||||
confirmed_commit_persist_id_get(clixon_handle h)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ confirmed_commit_persist_id_get(clicon_handle h)
|
|||
}
|
||||
|
||||
static int
|
||||
confirmed_commit_persist_id_set(clicon_handle h,
|
||||
confirmed_commit_persist_id_set(clixon_handle h,
|
||||
char *persist_id)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
|
@ -167,7 +167,7 @@ confirmed_commit_persist_id_set(clicon_handle h,
|
|||
free(cc->cc_persist_id);
|
||||
if (persist_id){
|
||||
if ((cc->cc_persist_id = strdup4(persist_id)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup4");
|
||||
clixon_err(OE_UNIX, errno, "strdup4");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ confirmed_commit_persist_id_set(clicon_handle h,
|
|||
}
|
||||
|
||||
uint32_t
|
||||
confirmed_commit_session_id_get(clicon_handle h)
|
||||
confirmed_commit_session_id_get(clixon_handle h)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ confirmed_commit_session_id_get(clicon_handle h)
|
|||
}
|
||||
|
||||
static int
|
||||
confirmed_commit_session_id_set(clicon_handle h,
|
||||
confirmed_commit_session_id_set(clixon_handle h,
|
||||
uint32_t session_id)
|
||||
{
|
||||
struct confirmed_commit *cc = NULL;
|
||||
|
|
@ -197,7 +197,7 @@ confirmed_commit_session_id_set(clicon_handle h,
|
|||
}
|
||||
|
||||
static int
|
||||
confirmed_commit_fn_arg_get(clicon_handle h,
|
||||
confirmed_commit_fn_arg_get(clixon_handle h,
|
||||
int (**fn)(int, void*),
|
||||
void **arg)
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ confirmed_commit_fn_arg_get(clicon_handle h,
|
|||
}
|
||||
|
||||
static int
|
||||
confirmed_commit_fn_arg_set(clicon_handle h,
|
||||
confirmed_commit_fn_arg_set(clixon_handle h,
|
||||
int (*fn)(int, void*),
|
||||
void *arg)
|
||||
{
|
||||
|
|
@ -300,7 +300,7 @@ xe_timeout(cxobj *xe)
|
|||
* @retval -1 No Rollback event was found
|
||||
*/
|
||||
int
|
||||
cancel_rollback_event(clicon_handle h)
|
||||
cancel_rollback_event(clixon_handle h)
|
||||
{
|
||||
int retval;
|
||||
int (*fn)(int, void*) = NULL;
|
||||
|
|
@ -308,9 +308,9 @@ cancel_rollback_event(clicon_handle h)
|
|||
|
||||
confirmed_commit_fn_arg_get(h, &fn, &arg);
|
||||
if ((retval = clixon_event_unreg_timeout(fn, arg)) == 0) {
|
||||
clicon_log(LOG_INFO, "a scheduled rollback event has been cancelled");
|
||||
clixon_log(h, LOG_INFO, "a scheduled rollback event has been cancelled");
|
||||
} else {
|
||||
clicon_log(LOG_WARNING, "the specified scheduled rollback event was not found");
|
||||
clixon_log(h, LOG_WARNING, "the specified scheduled rollback event was not found");
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
@ -319,7 +319,7 @@ cancel_rollback_event(clicon_handle h)
|
|||
/*! Apply the rollback configuration upon expiration of the confirm-timeout
|
||||
*
|
||||
* @param[in] fd a dummy argument per the event callback semantics
|
||||
* @param[in] arg a void pointer to a clicon_handle
|
||||
* @param[in] arg a void pointer to a clixon_handle
|
||||
* @retval 0 the rollback was successful
|
||||
* @retval -1 the rollback failed
|
||||
* @see do_rollback()
|
||||
|
|
@ -328,9 +328,9 @@ static int
|
|||
rollback_fn(int fd,
|
||||
void *arg)
|
||||
{
|
||||
clicon_handle h = arg;
|
||||
clixon_handle h = arg;
|
||||
|
||||
clicon_log(LOG_CRIT, "a confirming-commit was not received before the confirm-timeout expired; rolling back");
|
||||
clixon_log(NULL, LOG_CRIT, "a confirming-commit was not received before the confirm-timeout expired; rolling back");
|
||||
|
||||
return do_rollback(h, NULL);
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ rollback_fn(int fd,
|
|||
* @retval -1 Rollback event was not scheduled
|
||||
*/
|
||||
static int
|
||||
schedule_rollback_event(clicon_handle h,
|
||||
schedule_rollback_event(clixon_handle h,
|
||||
uint32_t timeout)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -352,7 +352,7 @@ schedule_rollback_event(clicon_handle h,
|
|||
// register a new scheduled event
|
||||
struct timeval t, t1;
|
||||
if (gettimeofday(&t, NULL) < 0) {
|
||||
clicon_err(OE_UNIX, 0, "failed to get time of day: %s", strerror(errno));
|
||||
clixon_err(OE_UNIX, 0, "failed to get time of day: %s", strerror(errno));
|
||||
goto done;
|
||||
};
|
||||
t1.tv_sec = timeout; t1.tv_usec = 0;
|
||||
|
|
@ -383,7 +383,7 @@ schedule_rollback_event(clicon_handle h,
|
|||
* @retval 0 OK
|
||||
*/
|
||||
int
|
||||
cancel_confirmed_commit(clicon_handle h)
|
||||
cancel_confirmed_commit(clixon_handle h)
|
||||
{
|
||||
cancel_rollback_event(h);
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ cancel_confirmed_commit(clicon_handle h)
|
|||
confirmed_commit_state_set(h, INACTIVE);
|
||||
|
||||
if (xmldb_delete(h, "rollback") < 0)
|
||||
clicon_err(OE_DB, 0, "Error deleting the rollback configuration");
|
||||
clixon_err(OE_DB, 0, "Error deleting the rollback configuration");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ cancel_confirmed_commit(clicon_handle h)
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
check_valid_confirming_commit(clicon_handle h,
|
||||
check_valid_confirming_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
uint32_t myid)
|
||||
{
|
||||
|
|
@ -422,7 +422,7 @@ check_valid_confirming_commit(clicon_handle h,
|
|||
char *persist_id = NULL;
|
||||
|
||||
if (xe == NULL){
|
||||
clicon_err(OE_CFG, EINVAL, "xe is NULL");
|
||||
clixon_err(OE_CFG, EINVAL, "xe is NULL");
|
||||
goto done;
|
||||
}
|
||||
if (myid == 0)
|
||||
|
|
@ -435,13 +435,13 @@ check_valid_confirming_commit(clicon_handle h,
|
|||
break; // valid
|
||||
}
|
||||
else {
|
||||
clicon_log(LOG_INFO,
|
||||
clixon_log(h, LOG_INFO,
|
||||
"a persistent confirmed-commit is in progress but the client issued a "
|
||||
"confirming-commit with an incorrect persist-id");
|
||||
goto invalid;
|
||||
}
|
||||
} else {
|
||||
clicon_log(LOG_INFO,
|
||||
clixon_log(h, LOG_INFO,
|
||||
"a persistent confirmed-commit is in progress but the client issued a confirming-commit"
|
||||
"without a persist-id");
|
||||
goto invalid;
|
||||
|
|
@ -453,7 +453,7 @@ check_valid_confirming_commit(clicon_handle h,
|
|||
*/
|
||||
break; // valid
|
||||
}
|
||||
clicon_log(LOG_DEBUG, "an ephemeral confirmed-commit is in progress, but there confirming-commit was"
|
||||
clixon_log(h, LOG_DEBUG, "an ephemeral confirmed-commit is in progress, but there confirming-commit was"
|
||||
"not issued on the same session as the confirmed-commit");
|
||||
goto invalid;
|
||||
default:
|
||||
|
|
@ -485,7 +485,7 @@ check_valid_confirming_commit(clicon_handle h,
|
|||
* actually occur, and if so, if they are correctly handled. The calls are from do_rollback() and load_failsafe()
|
||||
*/
|
||||
int
|
||||
handle_confirmed_commit(clicon_handle h,
|
||||
handle_confirmed_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
uint32_t myid)
|
||||
{
|
||||
|
|
@ -496,7 +496,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
int db_exists;
|
||||
|
||||
if (xe == NULL){
|
||||
clicon_err(OE_CFG, EINVAL, "xe is NULL");
|
||||
clixon_err(OE_CFG, EINVAL, "xe is NULL");
|
||||
goto done;
|
||||
}
|
||||
if (myid == 0)
|
||||
|
|
@ -509,7 +509,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
cc_valid = check_valid_confirming_commit(h, xe, myid);
|
||||
if (cc_valid) {
|
||||
if (cancel_rollback_event(h) < 0) {
|
||||
clicon_err(OE_DAEMON, 0, "A valid confirming-commit was received, but the corresponding rollback event was not found");
|
||||
clixon_err(OE_DAEMON, 0, "A valid confirming-commit was received, but the corresponding rollback event was not found");
|
||||
}
|
||||
|
||||
if (confirmed_commit_state_get(h) == PERSISTENT &&
|
||||
|
|
@ -537,7 +537,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
* <persist-id>
|
||||
*/
|
||||
confirmed_commit_state_set(h, PERSISTENT);
|
||||
clicon_log(LOG_INFO,
|
||||
clixon_log(h, LOG_INFO,
|
||||
"a persistent confirmed-commit has been requested with persist id of '%s' and a timeout of %lu seconds",
|
||||
confirmed_commit_persist_id_get(h), confirm_timeout);
|
||||
}
|
||||
|
|
@ -549,7 +549,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
confirmed_commit_session_id_set(h, myid);
|
||||
confirmed_commit_state_set(h, EPHEMERAL);
|
||||
|
||||
clicon_log(LOG_INFO,
|
||||
clixon_log(h, LOG_INFO,
|
||||
"an ephemeral confirmed-commit has been requested by session-id %u and a timeout of %lu seconds",
|
||||
confirmed_commit_session_id_get(h),
|
||||
confirm_timeout);
|
||||
|
|
@ -586,18 +586,18 @@ handle_confirmed_commit(clicon_handle h,
|
|||
|
||||
db_exists = xmldb_exists(h, "rollback");
|
||||
if (db_exists == -1) {
|
||||
clicon_err(OE_DAEMON, 0, "there was an error while checking existence of the rollback database");
|
||||
clixon_err(OE_DAEMON, 0, "there was an error while checking existence of the rollback database");
|
||||
goto done;
|
||||
} else if (db_exists == 0) {
|
||||
// db does not yet exists
|
||||
if (xmldb_copy(h, "running", "rollback") < 0) {
|
||||
clicon_err(OE_DAEMON, 0, "there was an error while copying the running configuration to rollback database.");
|
||||
clixon_err(OE_DAEMON, 0, "there was an error while copying the running configuration to rollback database.");
|
||||
goto done;
|
||||
};
|
||||
}
|
||||
|
||||
if (schedule_rollback_event(h, confirm_timeout) < 0) {
|
||||
clicon_err(OE_DAEMON, 0, "the rollback event could not be scheduled");
|
||||
clixon_err(OE_DAEMON, 0, "the rollback event could not be scheduled");
|
||||
goto done;
|
||||
};
|
||||
|
||||
|
|
@ -607,7 +607,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
* The new configuration is already committed to running and the rollback database can now be deleted
|
||||
*/
|
||||
if (xmldb_delete(h, "rollback") < 0) {
|
||||
clicon_err(OE_DB, 0, "Error deleting the rollback configuration");
|
||||
clixon_err(OE_DB, 0, "Error deleting the rollback configuration");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -635,7 +635,7 @@ handle_confirmed_commit(clicon_handle h,
|
|||
* @see rollback_fn()
|
||||
*/
|
||||
int
|
||||
do_rollback(clicon_handle h,
|
||||
do_rollback(clixon_handle h,
|
||||
uint8_t *errs)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -643,13 +643,13 @@ do_rollback(clicon_handle h,
|
|||
cbuf *cbret;
|
||||
|
||||
if ((cbret = cbuf_new()) == NULL) {
|
||||
clicon_err(OE_DAEMON, 0, "rollback was not performed. (cbuf_new: %s)", strerror(errno));
|
||||
clixon_err(OE_DAEMON, 0, "rollback was not performed. (cbuf_new: %s)", strerror(errno));
|
||||
/* the rollback_db won't be deleted, so one can try recovery by:
|
||||
* load rollback running
|
||||
* restart the backend, which will try to load the rollback_db, and delete it if successful
|
||||
* (otherwise it will load the failsafe)
|
||||
*/
|
||||
clicon_log(LOG_CRIT, "An error occurred during rollback and the rollback_db wasn't deleted.");
|
||||
clixon_log(h, LOG_CRIT, "An error occurred during rollback and the rollback_db wasn't deleted.");
|
||||
errstate |= ROLLBACK_NOT_APPLIED | ROLLBACK_DB_NOT_DELETED;
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -663,19 +663,19 @@ do_rollback(clicon_handle h,
|
|||
/* theoretically, this should never error, since the rollback database was previously active and therefore
|
||||
* had itself been previously and successfully committed.
|
||||
*/
|
||||
clicon_log(LOG_CRIT, "An error occurred committing the rollback database.");
|
||||
clixon_log(h, LOG_CRIT, "An error occurred committing the rollback database.");
|
||||
errstate |= ROLLBACK_NOT_APPLIED;
|
||||
|
||||
/* Rename the errored rollback database */
|
||||
if (xmldb_rename(h, "rollback", NULL, ".error") < 0) {
|
||||
clicon_log(LOG_CRIT, "An error occurred renaming the rollback database.");
|
||||
clixon_log(h, LOG_CRIT, "An error occurred renaming the rollback database.");
|
||||
errstate |= ROLLBACK_DB_NOT_DELETED;
|
||||
}
|
||||
|
||||
/* Attempt to load the failsafe config */
|
||||
|
||||
if (load_failsafe(h, "Rollback") < 0) {
|
||||
clicon_log(LOG_CRIT, "An error occurred committing the failsafe database. Exiting.");
|
||||
clixon_log(h, LOG_CRIT, "An error occurred committing the failsafe database. Exiting.");
|
||||
/* Invoke our own signal handler to exit */
|
||||
raise(SIGINT);
|
||||
|
||||
|
|
@ -688,7 +688,7 @@ do_rollback(clicon_handle h,
|
|||
cbuf_free(cbret);
|
||||
|
||||
if (xmldb_delete(h, "rollback") < 0) {
|
||||
clicon_log(LOG_WARNING, "A rollback occurred but the rollback_db wasn't deleted.");
|
||||
clixon_log(h, LOG_WARNING, "A rollback occurred but the rollback_db wasn't deleted.");
|
||||
errstate |= ROLLBACK_DB_NOT_DELETED;
|
||||
goto done;
|
||||
};
|
||||
|
|
@ -717,7 +717,7 @@ do_rollback(clicon_handle h,
|
|||
* @see RFC 6241 Sec 8.4
|
||||
*/
|
||||
int
|
||||
from_client_cancel_commit(clicon_handle h,
|
||||
from_client_cancel_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -775,7 +775,7 @@ from_client_cancel_commit(clicon_handle h,
|
|||
if (do_rollback(h, NULL) < 0)
|
||||
goto done;
|
||||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok/></rpc-reply>", NETCONF_BASE_NAMESPACE);
|
||||
clicon_log(LOG_INFO, "a confirmed-commit has been cancelled by client request");
|
||||
clixon_log(h, LOG_INFO, "a confirmed-commit has been cancelled by client request");
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -793,7 +793,7 @@ from_client_cancel_commit(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
from_client_confirmed_commit(clicon_handle h,
|
||||
from_client_confirmed_commit(clixon_handle h,
|
||||
cxobj *xe,
|
||||
uint32_t myid,
|
||||
cbuf *cbret)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_client.h"
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
* @see rfc8040 Sections 9.1
|
||||
*/
|
||||
static int
|
||||
restconf_client_get_capabilities(clicon_handle h,
|
||||
restconf_client_get_capabilities(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
char *xpath,
|
||||
cxobj **xret)
|
||||
|
|
@ -95,11 +95,11 @@ restconf_client_get_capabilities(clicon_handle h,
|
|||
cbuf *cb = NULL;
|
||||
|
||||
if ((xrstate = xpath_first(*xret, NULL, "restconf-state")) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "restconf-state not found in config node");
|
||||
clixon_err(OE_YANG, ENOENT, "restconf-state not found in config node");
|
||||
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, "<capabilities>");
|
||||
|
|
@ -129,7 +129,7 @@ restconf_client_get_capabilities(clicon_handle h,
|
|||
* @retval -1 Error (fatal)
|
||||
*/
|
||||
static int
|
||||
client_get_streams(clicon_handle h,
|
||||
client_get_streams(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
char *xpath,
|
||||
yang_stmt *ymod,
|
||||
|
|
@ -143,11 +143,11 @@ client_get_streams(clicon_handle h,
|
|||
int ret;
|
||||
|
||||
if ((yns = yang_find(ymod, Y_NAMESPACE, NULL)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "%s yang namespace not found", yang_argument_get(ymod));
|
||||
clixon_err(OE_YANG, 0, "%s yang namespace not found", yang_argument_get(ymod));
|
||||
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, "<%s xmlns=\"%s\">", top, yang_argument_get(yns));
|
||||
|
|
@ -159,7 +159,7 @@ client_get_streams(clicon_handle h,
|
|||
cprintf(cb,"</%s>", top);
|
||||
|
||||
if (clixon_xml_parse_string(cbuf_get(cb), YB_MODULE, yspec, &x, NULL) < 0){
|
||||
if (xret && netconf_operation_failed_xml(xret, "protocol", clicon_err_reason)< 0)
|
||||
if (xret && netconf_operation_failed_xml(xret, "protocol", clixon_err_reason())< 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ client_get_streams(clicon_handle h,
|
|||
*
|
||||
*/
|
||||
static int
|
||||
get_statedata(clicon_handle h,
|
||||
get_statedata(clixon_handle h,
|
||||
char *xpath,
|
||||
cvec *nsc,
|
||||
withdefaults_type wdef,
|
||||
|
|
@ -220,20 +220,20 @@ get_statedata(clicon_handle h,
|
|||
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s", __FUNCTION__);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||
goto done;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_option_bool(h, "CLICON_STREAM_DISCOVERY_RFC5277")){
|
||||
if ((ymod = yang_find_module_by_name(yspec, "clixon-rfc5277")) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "yang module clixon-rfc5277 not found");
|
||||
clixon_err(OE_YANG, ENOENT, "yang module clixon-rfc5277 not found");
|
||||
goto done;
|
||||
}
|
||||
if ((namespace = yang_find_mynamespace(ymod)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "clixon-rfc5277 namespace not found");
|
||||
clixon_err(OE_YANG, ENOENT, "clixon-rfc5277 namespace not found");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<netconf xmlns=\"%s\"/>", namespace);
|
||||
|
|
@ -246,11 +246,11 @@ get_statedata(clicon_handle h,
|
|||
}
|
||||
if (clicon_option_bool(h, "CLICON_STREAM_DISCOVERY_RFC8040")){
|
||||
if ((ymod = yang_find_module_by_name(yspec, "ietf-restconf-monitoring")) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "yang module ietf-restconf-monitoring not found");
|
||||
clixon_err(OE_YANG, ENOENT, "yang module ietf-restconf-monitoring not found");
|
||||
goto done;
|
||||
}
|
||||
if ((namespace = yang_find_mynamespace(ymod)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "ietf-restconf-monitoring namespace not found");
|
||||
clixon_err(OE_YANG, ENOENT, "ietf-restconf-monitoring namespace not found");
|
||||
goto done;
|
||||
}
|
||||
cbuf_reset(cb);
|
||||
|
|
@ -406,7 +406,7 @@ get_statedata(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
filter_xpath_again(clicon_handle h,
|
||||
filter_xpath_again(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
cxobj *xret,
|
||||
cxobj **xvec,
|
||||
|
|
@ -418,7 +418,7 @@ filter_xpath_again(clicon_handle h,
|
|||
int i;
|
||||
|
||||
if (xret == NULL){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "xret is NULL");
|
||||
clixon_err(OE_PLUGIN, EINVAL, "xret is NULL");
|
||||
goto done;
|
||||
}
|
||||
/* If vectors are specified then mark the nodes found and
|
||||
|
|
@ -456,7 +456,7 @@ filter_xpath_again(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
get_nacm_and_reply(clicon_handle h,
|
||||
get_nacm_and_reply(clixon_handle h,
|
||||
cxobj *xret,
|
||||
cxobj **xvec,
|
||||
size_t xlen,
|
||||
|
|
@ -505,7 +505,7 @@ get_nacm_and_reply(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
element2value(clicon_handle h,
|
||||
element2value(clixon_handle h,
|
||||
cxobj *xe,
|
||||
char *name,
|
||||
char *defaultstr,
|
||||
|
|
@ -535,7 +535,7 @@ element2value(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
list_pagination_hdr(clicon_handle h,
|
||||
list_pagination_hdr(clixon_handle h,
|
||||
cxobj *xe,
|
||||
uint32_t *offset,
|
||||
uint32_t *limit,
|
||||
|
|
@ -576,7 +576,7 @@ list_pagination_hdr(clicon_handle h,
|
|||
* XXX Lots of this code (in particular at the end) is copy of get_common
|
||||
*/
|
||||
static int
|
||||
get_list_pagination(clicon_handle h,
|
||||
get_list_pagination(clixon_handle h,
|
||||
struct client_entry *ce,
|
||||
cxobj *xe,
|
||||
netconf_content content,
|
||||
|
|
@ -614,7 +614,7 @@ get_list_pagination(clicon_handle h,
|
|||
#endif
|
||||
|
||||
if (cbret == NULL){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "cbret is NULL");
|
||||
clixon_err(OE_PLUGIN, EINVAL, "cbret is NULL");
|
||||
goto done;
|
||||
}
|
||||
/* Check if list/leaf-list */
|
||||
|
|
@ -622,10 +622,10 @@ get_list_pagination(clicon_handle h,
|
|||
goto done;
|
||||
if (ylist == NULL){
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* error reason should be in clicon_err_reason */
|
||||
/* error reason should be in clixon_err_reason() */
|
||||
cprintf(cbmsg, "Netconf get list-pagination: \"%s\" not found", xpath);
|
||||
if (netconf_invalid_value(cbret, "application", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
|
|
@ -686,7 +686,7 @@ get_list_pagination(clicon_handle h,
|
|||
* relational operators <>.
|
||||
*/
|
||||
if ((cbpath = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* This uses xpath. Maybe limit should use parameters */
|
||||
|
|
@ -712,10 +712,10 @@ get_list_pagination(clicon_handle h,
|
|||
/* specific xpath */
|
||||
if (xmldb_get0(h, db, YB_MODULE, nsc, xpath2?xpath2:"/", 1, wdef, &xret, NULL, NULL) < 0) {
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clicon_err_reason);
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "application", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -752,12 +752,12 @@ get_list_pagination(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;
|
||||
}
|
||||
/* error reason should be in clicon_err_reason */
|
||||
/* error reason should be in clixon_err_reason */
|
||||
cprintf(cberr, "Internal error, pagination state callback invalid return : %s",
|
||||
clicon_err_reason);
|
||||
clixon_err_reason());
|
||||
if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0)
|
||||
goto done;
|
||||
if (clixon_xml2cbuf(cbret, xerr, 0, 0, NULL, -1, 0) < 0)
|
||||
|
|
@ -794,7 +794,7 @@ get_list_pagination(clicon_handle h,
|
|||
|
||||
/* Add remaining attribute */
|
||||
if ((cba = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cba, "%u", remaining);
|
||||
|
|
@ -838,7 +838,7 @@ get_list_pagination(clicon_handle h,
|
|||
* @see from_client_get_config
|
||||
*/
|
||||
static int
|
||||
get_common(clicon_handle h,
|
||||
get_common(clixon_handle h,
|
||||
struct client_entry *ce,
|
||||
cxobj *xe,
|
||||
netconf_content content,
|
||||
|
|
@ -875,7 +875,7 @@ get_common(clicon_handle h,
|
|||
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
username = clicon_username_get(h);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, ENOENT, "No yang spec9");
|
||||
clixon_err(OE_YANG, ENOENT, "No yang spec9");
|
||||
goto done;
|
||||
}
|
||||
if ((xfilter = xml_find(xe, "filter")) != NULL){
|
||||
|
|
@ -900,7 +900,7 @@ get_common(clicon_handle h,
|
|||
/* Clixon extensions: depth */
|
||||
if ((attr = xml_find_value(xe, "depth")) != NULL){
|
||||
if ((ret = parse_int32(attr, &depth, &reason)) < 0){
|
||||
clicon_err(OE_XML, errno, "parse_int32");
|
||||
clixon_err(OE_XML, errno, "parse_int32");
|
||||
goto done;
|
||||
}
|
||||
if (ret == 0){
|
||||
|
|
@ -946,10 +946,10 @@ get_common(clicon_handle h,
|
|||
/* specific xpath */
|
||||
if (xmldb_get0(h, db, YB_MODULE, nsc, xpath?xpath:"/", 1, wdef, &xret, NULL, NULL) < 0) {
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clicon_err_reason);
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "application", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -961,10 +961,10 @@ get_common(clicon_handle h,
|
|||
/* Whole config tree, for validate debug */
|
||||
if (xmldb_get0(h, "running", YB_MODULE, nsc, NULL, 1, wdef, &xret, NULL, NULL) < 0) {
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clicon_err_reason);
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "application", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -974,10 +974,10 @@ get_common(clicon_handle h,
|
|||
/* specific xpath */
|
||||
if (xmldb_get0(h, db, YB_MODULE, nsc, xpath?xpath:"/", 1, wdef, &xret, NULL, NULL) < 0) {
|
||||
if ((cbmsg = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clicon_err_reason);
|
||||
cprintf(cbmsg, "Get %s datastore: %s", db, clixon_err_reason());
|
||||
if (netconf_operation_failed(cbret, "application", cbuf_get(cbmsg)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
@ -1083,7 +1083,7 @@ get_common(clicon_handle h,
|
|||
* @see from_client_get
|
||||
*/
|
||||
int
|
||||
from_client_get_config(clicon_handle h,
|
||||
from_client_get_config(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
@ -1094,7 +1094,7 @@ from_client_get_config(clicon_handle h,
|
|||
struct client_entry *ce = (struct client_entry *)arg;
|
||||
|
||||
if ((db = netconf_db_find(xe, "source")) == NULL){
|
||||
clicon_err(OE_XML, 0, "db not found");
|
||||
clixon_err(OE_XML, 0, "db not found");
|
||||
goto done;
|
||||
}
|
||||
retval = get_common(h, ce, xe, CONTENT_CONFIG, db, cbret);
|
||||
|
|
@ -1115,7 +1115,7 @@ from_client_get_config(clicon_handle h,
|
|||
* @see from_client_get_config
|
||||
*/
|
||||
int
|
||||
from_client_get(clicon_handle h,
|
||||
from_client_get(clixon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int from_client_get_config(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_get(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_get_pageable_list(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg); /* XXX */
|
||||
int from_client_get_config(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_get(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_get_pageable_list(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg); /* XXX */
|
||||
|
||||
#endif /* _BACKEND_GET_H_ */
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@
|
|||
* Prototypes
|
||||
* not exported.
|
||||
*/
|
||||
clicon_handle backend_handle_init(void);
|
||||
clixon_handle backend_handle_init(void);
|
||||
|
||||
int backend_handle_exit(clicon_handle h);
|
||||
int backend_handle_exit(clixon_handle h);
|
||||
|
||||
struct client_entry *backend_client_add(clicon_handle h, struct sockaddr *addr);
|
||||
struct client_entry *backend_client_add(clixon_handle h, struct sockaddr *addr);
|
||||
|
||||
struct client_entry *backend_client_list(clicon_handle h);
|
||||
struct client_entry *backend_client_list(clixon_handle h);
|
||||
|
||||
int backend_client_delete(clicon_handle h, struct client_entry *ce);
|
||||
int backend_client_delete(clixon_handle h, struct client_entry *ce);
|
||||
|
||||
int backend_client_print(clicon_handle h, FILE *f);
|
||||
int backend_client_print(clixon_handle h, FILE *f);
|
||||
|
||||
#endif /* _BACKEND_HANDLE_H_ */
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
* @param[in] h Clixon handle
|
||||
*/
|
||||
static int
|
||||
backend_terminate(clicon_handle h)
|
||||
backend_terminate(clixon_handle h)
|
||||
{
|
||||
yang_stmt *yspec;
|
||||
char *pidfile = clicon_backend_pidfile(h);
|
||||
|
|
@ -145,7 +145,7 @@ backend_terminate(clicon_handle h)
|
|||
clixon_event_exit();
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s done", __FUNCTION__);
|
||||
clixon_err_exit();
|
||||
clicon_log_exit();
|
||||
clixon_log_exit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ backend_sig_term(int arg)
|
|||
static int i=0;
|
||||
|
||||
if (i++ == 0)
|
||||
clicon_log(LOG_NOTICE, "%s: %s: pid: %u Signal %d",
|
||||
clixon_log(NULL, LOG_NOTICE, "%s: %s: pid: %u Signal %d",
|
||||
__PROGRAM__, __FUNCTION__, getpid(), arg);
|
||||
else
|
||||
exit(1);
|
||||
|
|
@ -183,7 +183,7 @@ backend_sig_child(int arg)
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
backend_server_socket(clicon_handle h)
|
||||
backend_server_socket(clixon_handle h)
|
||||
{
|
||||
int ss;
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ backend_server_socket(clicon_handle h)
|
|||
/*! Load external NACM file
|
||||
*/
|
||||
static int
|
||||
nacm_load_external(clicon_handle h)
|
||||
nacm_load_external(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
char *filename; /* NACM config file */
|
||||
|
|
@ -213,19 +213,19 @@ nacm_load_external(clicon_handle h)
|
|||
|
||||
filename = clicon_option_str(h, "CLICON_NACM_FILE");
|
||||
if (filename == NULL || strlen(filename)==0){
|
||||
clicon_err(OE_UNIX, errno, "CLICON_NACM_FILE not set in NACM external mode");
|
||||
clixon_err(OE_UNIX, errno, "CLICON_NACM_FILE not set in NACM external mode");
|
||||
goto done;
|
||||
}
|
||||
if (stat(filename, &st) < 0){
|
||||
clicon_err(OE_UNIX, errno, "%s", filename);
|
||||
clixon_err(OE_UNIX, errno, "%s", filename);
|
||||
goto done;
|
||||
}
|
||||
if (!S_ISREG(st.st_mode)){
|
||||
clicon_err(OE_UNIX, 0, "%s is not a regular file", filename);
|
||||
clixon_err(OE_UNIX, 0, "%s is not a regular file", filename);
|
||||
goto done;
|
||||
}
|
||||
if ((f = fopen(filename, "r")) == NULL) {
|
||||
clicon_err(OE_UNIX, errno, "configure file: %s", filename);
|
||||
clixon_err(OE_UNIX, errno, "configure file: %s", filename);
|
||||
return -1;
|
||||
}
|
||||
if ((yspec = yspec_new()) == NULL)
|
||||
|
|
@ -236,7 +236,7 @@ nacm_load_external(clicon_handle h)
|
|||
if (clixon_xml_parse_file(f, YB_MODULE, yspec, &xt, NULL) < 0)
|
||||
goto done;
|
||||
if (xt == NULL){
|
||||
clicon_err(OE_XML, 0, "No xml tree in %s", filename);
|
||||
clixon_err(OE_XML, 0, "No xml tree in %s", filename);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_nacm_ext_yang_set(h, yspec) < 0)
|
||||
|
|
@ -252,7 +252,7 @@ nacm_load_external(clicon_handle h)
|
|||
}
|
||||
|
||||
static int
|
||||
xmldb_drop_priv(clicon_handle h,
|
||||
xmldb_drop_priv(clixon_handle h,
|
||||
const char *db,
|
||||
uid_t uid,
|
||||
gid_t gid)
|
||||
|
|
@ -263,7 +263,7 @@ xmldb_drop_priv(clicon_handle h,
|
|||
if (xmldb_db2file(h, db, &filename) < 0)
|
||||
goto done;
|
||||
if (chown(filename, uid, gid) < 0){
|
||||
clicon_err(OE_UNIX, errno, "chown");
|
||||
clixon_err(OE_UNIX, errno, "chown");
|
||||
goto done;
|
||||
}
|
||||
retval = 0;
|
||||
|
|
@ -287,7 +287,7 @@ xmldb_drop_priv(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
check_drop_priv(clicon_handle h,
|
||||
check_drop_priv(clixon_handle h,
|
||||
gid_t gid,
|
||||
yang_stmt *yspec)
|
||||
{
|
||||
|
|
@ -304,19 +304,19 @@ check_drop_priv(clicon_handle h,
|
|||
/* From here, drop privileges */
|
||||
/* Check backend user exists */
|
||||
if ((backend_user = clicon_backend_user(h)) == NULL){
|
||||
clicon_err(OE_DAEMON, EPERM, "Privileges cannot be dropped without specifying CLICON_BACKEND_USER\n");
|
||||
clixon_err(OE_DAEMON, EPERM, "Privileges cannot be dropped without specifying CLICON_BACKEND_USER\n");
|
||||
goto done;
|
||||
}
|
||||
/* Get (wanted) new backend user id */
|
||||
if (name2uid(backend_user, &newuid) < 0){
|
||||
clicon_err(OE_DAEMON, errno, "'%s' is not a valid user .\n", backend_user);
|
||||
clixon_err(OE_DAEMON, errno, "'%s' is not a valid user .\n", backend_user);
|
||||
goto done;
|
||||
}
|
||||
/* get current backend userid, if already at this level OK */
|
||||
if ((uid = getuid()) == newuid)
|
||||
goto ok;
|
||||
if (uid != 0){
|
||||
clicon_err(OE_DAEMON, EPERM, "Privileges can only be dropped from root user (uid is %u)\n", uid);
|
||||
clixon_err(OE_DAEMON, EPERM, "Privileges can only be dropped from root user (uid is %u)\n", uid);
|
||||
goto done;
|
||||
}
|
||||
/* When dropping privileges, datastores are created if they do not exist.
|
||||
|
|
@ -348,7 +348,7 @@ check_drop_priv(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (setgid(gid) == -1) {
|
||||
clicon_err(OE_DAEMON, errno, "setgid %d", gid);
|
||||
clixon_err(OE_DAEMON, errno, "setgid %d", gid);
|
||||
goto done;
|
||||
}
|
||||
switch (priv_mode){
|
||||
|
|
@ -357,7 +357,7 @@ check_drop_priv(clicon_handle h,
|
|||
goto done;
|
||||
/* Verify you cannot regain root privileges */
|
||||
if (setuid(0) != -1){
|
||||
clicon_err(OE_DAEMON, EPERM, "Could regain root privilieges");
|
||||
clixon_err(OE_DAEMON, EPERM, "Could regain root privilieges");
|
||||
goto done;
|
||||
}
|
||||
break;
|
||||
|
|
@ -381,8 +381,8 @@ check_drop_priv(clicon_handle h,
|
|||
* @retval 0 OK, status set
|
||||
* @retval -1 Fatal error outside scope of startup_status
|
||||
* Transformation rules:
|
||||
* 1) retval -1 assume clicon_errno/suberrno set. Special case from xml parser
|
||||
* is clicon_suberrno = XMLPARSE_ERRNO which assumes an XML (non-fatal) parse
|
||||
* 1) retval -1 assume clixon_err_category/subnr set. Special case from xml parser
|
||||
* is clixon_err_subnr = XMLPARSE_ERRNO which assumes an XML (non-fatal) parse
|
||||
* error which translates to -> STARTUP_ERR
|
||||
* All other error cases translates to fatal error
|
||||
* 2) retval 0 is xml validation fails -> STARTUP_INVALID
|
||||
|
|
@ -397,9 +397,9 @@ ret2status(int ret,
|
|||
|
||||
switch (ret){
|
||||
case -1:
|
||||
if (clicon_suberrno != XMLPARSE_ERRNO)
|
||||
if (clixon_err_subnr() != XMLPARSE_ERRNO)
|
||||
goto done;
|
||||
clicon_err_reset();
|
||||
clixon_err_reset();
|
||||
*status = STARTUP_ERR;
|
||||
break;
|
||||
case 0:
|
||||
|
|
@ -409,7 +409,7 @@ ret2status(int ret,
|
|||
*status = STARTUP_OK;
|
||||
break;
|
||||
default:
|
||||
clicon_err(OE_CFG, EINVAL, "No such retval %d", retval);
|
||||
clixon_err(OE_CFG, EINVAL, "No such retval %d", retval);
|
||||
} /* switch */
|
||||
retval = 0;
|
||||
done:
|
||||
|
|
@ -423,7 +423,7 @@ backend_timer_setup(int fd,
|
|||
void *arg)
|
||||
{
|
||||
int retval = -1;
|
||||
clicon_handle h = (clicon_handle)arg;
|
||||
clixon_handle h = (clixon_handle)arg;
|
||||
struct timeval now;
|
||||
struct timeval t;
|
||||
struct timeval t1 = {10, 0};
|
||||
|
|
@ -451,7 +451,7 @@ backend_timer_setup(int fd,
|
|||
/*! usage
|
||||
*/
|
||||
static void
|
||||
usage(clicon_handle h,
|
||||
usage(clixon_handle h,
|
||||
char *argv0)
|
||||
{
|
||||
char *plgdir = clicon_backend_dir(h);
|
||||
|
|
@ -510,14 +510,14 @@ main(int argc,
|
|||
char *backend_group = NULL;
|
||||
char *argv0 = argv[0];
|
||||
struct stat st;
|
||||
clicon_handle h;
|
||||
clixon_handle h;
|
||||
int help = 0;
|
||||
int pid;
|
||||
char *pidfile;
|
||||
char *sock;
|
||||
int sockfamily;
|
||||
char *nacm_mode;
|
||||
int logdst = CLICON_LOG_SYSLOG|CLICON_LOG_STDERR;
|
||||
int logdst = CLIXON_LOG_SYSLOG|CLIXON_LOG_STDERR;
|
||||
yang_stmt *yspec = NULL;
|
||||
char *str;
|
||||
int ss = -1; /* server socket */
|
||||
|
|
@ -535,11 +535,14 @@ main(int argc,
|
|||
enum format_enum config_dump_format = FORMAT_XML;
|
||||
int print_version = 0;
|
||||
|
||||
/* In the startup, logs to stderr & syslog and debug flag set later */
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||
/* Initiate CLICON handle */
|
||||
if ((h = backend_handle_init()) == NULL)
|
||||
return -1;
|
||||
/* In the startup, logs to stderr & syslog and debug flag set later */
|
||||
if (clixon_log_init(h, __PROGRAM__, LOG_INFO, logdst) < 0)
|
||||
goto done;
|
||||
if (clixon_err_init(h) < 0)
|
||||
goto done;
|
||||
foreground = 0;
|
||||
once = 0;
|
||||
zap = 0;
|
||||
|
|
@ -581,11 +584,11 @@ main(int argc,
|
|||
clicon_option_str_set(h, "CLICON_CONFIGDIR", optarg);
|
||||
break;
|
||||
case 'l': /* Log destination: s|e|o */
|
||||
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||
if ((logdst = clixon_log_opt(optarg[0])) < 0)
|
||||
usage(h, argv[0]);
|
||||
if (logdst == CLICON_LOG_FILE &&
|
||||
if (logdst == CLIXON_LOG_FILE &&
|
||||
strlen(optarg)>1 &&
|
||||
clicon_log_file(optarg+1) < 0)
|
||||
clixon_log_file(optarg+1) < 0)
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
|
@ -596,8 +599,8 @@ main(int argc,
|
|||
* XXX: if started in a start-daemon script, there will be irritating
|
||||
* double syslogs until fork below.
|
||||
*/
|
||||
clicon_log_init(__PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||
clixon_debug_init(dbg, NULL);
|
||||
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||
clixon_debug_init(h, dbg);
|
||||
yang_init(h);
|
||||
|
||||
/* Find and read configfile */
|
||||
|
|
@ -718,8 +721,8 @@ main(int argc,
|
|||
/* Access the remaining argv/argc options (after --) w clicon-argv_get() */
|
||||
clicon_argv_set(h, argv0, argc, argv);
|
||||
|
||||
clicon_log_init(__PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||
|
||||
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||
|
||||
/* Defer: Wait to the last minute to print help message */
|
||||
if (help)
|
||||
usage(h, argv[0]);
|
||||
|
|
@ -730,22 +733,22 @@ main(int argc,
|
|||
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||
|
||||
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||
clicon_log_string_limit_set(sz);
|
||||
clixon_log_string_limit_set(sz);
|
||||
|
||||
#ifndef HAVE_LIBXML2
|
||||
if (clicon_yang_regexp(h) == REGEXP_LIBXML2){
|
||||
clicon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML2 not set (Either change CLICON_YANG_REGEXP to posix, or run: configure --with-libxml2))");
|
||||
clixon_err(OE_FATAL, 0, "CLICON_YANG_REGEXP set to libxml2, but HAVE_LIBXML2 not set (Either change CLICON_YANG_REGEXP to posix, or run: configure --with-libxml2))");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
/* Check pid-file, if zap kil the old daemon, else return here */
|
||||
if ((pidfile = clicon_backend_pidfile(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "pidfile not set");
|
||||
clixon_err(OE_FATAL, 0, "pidfile not set");
|
||||
goto done;
|
||||
}
|
||||
sockfamily = clicon_sock_family(h);
|
||||
if ((sock = clicon_sock_str(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "sock not set");
|
||||
clixon_err(OE_FATAL, 0, "sock not set");
|
||||
goto done;
|
||||
}
|
||||
if (pidfile_get(pidfile, &pid) < 0)
|
||||
|
|
@ -762,7 +765,7 @@ main(int argc,
|
|||
}
|
||||
else
|
||||
if (pid){
|
||||
clicon_err(OE_DAEMON, 0, "Daemon already running with pid %d\n(Try killing it with %s -z)",
|
||||
clixon_err(OE_DAEMON, 0, "Daemon already running with pid %d\n(Try killing it with %s -z)",
|
||||
pid, argv0);
|
||||
return -1; /* goto done deletes pidfile */
|
||||
}
|
||||
|
|
@ -777,11 +780,11 @@ main(int argc,
|
|||
|
||||
/* Sanity check: backend group exists */
|
||||
if ((backend_group = clicon_sock_group(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "clicon_sock_group option not set");
|
||||
clixon_err(OE_FATAL, 0, "clicon_sock_group option not set");
|
||||
return -1;
|
||||
}
|
||||
if (group_name2gid(backend_group, &gid) < 0){
|
||||
clicon_log(LOG_ERR, "'%s' does not seem to be a valid user group.\n" /* \n required here due to multi-line log */
|
||||
clixon_log(h, LOG_ERR, "'%s' does not seem to be a valid user group.\n" /* \n required here due to multi-line log */
|
||||
"The config daemon requires a valid group to create a server UNIX socket\n"
|
||||
"Define a valid CLICON_SOCK_GROUP in %s or via the -g option\n"
|
||||
"or create the group and add the user to it. Check documentation for how to do this on your platform",
|
||||
|
|
@ -899,13 +902,13 @@ main(int argc,
|
|||
/* Startup mode needs to be defined, */
|
||||
startup_mode = clicon_startup_mode(h);
|
||||
if ((int)startup_mode == -1){
|
||||
clicon_log(LOG_ERR, "Startup mode undefined. Specify option CLICON_STARTUP_MODE or specify -s option to clicon_backend.");
|
||||
clixon_log(h, LOG_ERR, "Startup mode undefined. Specify option CLICON_STARTUP_MODE or specify -s option to clicon_backend.");
|
||||
goto done;
|
||||
}
|
||||
/* Check that netconf :startup is enabled */
|
||||
if ((startup_mode == SM_STARTUP || startup_mode == SM_RUNNING_STARTUP) &&
|
||||
!if_feature(yspec, "ietf-netconf", "startup")){
|
||||
clicon_log(LOG_ERR, "Startup mode selected but Netconf :startup feature is not enabled. Enable with option: <CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>");
|
||||
clixon_log(h, LOG_ERR, "Startup mode selected but Netconf :startup feature is not enabled. Enable with option: <CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -924,7 +927,7 @@ main(int argc,
|
|||
xmldb_delete(h, "candidate");
|
||||
/* If startup fails, lib functions report invalidation info in a cbuf */
|
||||
if ((cbret = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
switch (startup_mode){
|
||||
|
|
@ -1003,7 +1006,7 @@ main(int argc,
|
|||
}
|
||||
if (status != STARTUP_OK){
|
||||
if (cbuf_len(cbret))
|
||||
clicon_log(LOG_NOTICE, "%s: %u %s", __PROGRAM__, getpid(), cbuf_get(cbret));
|
||||
clixon_log(h, LOG_NOTICE, "%s: %u %s", __PROGRAM__, getpid(), cbuf_get(cbret));
|
||||
if (load_failsafe(h, "Startup") < 0){
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1022,7 +1025,7 @@ main(int argc,
|
|||
goto done;
|
||||
|
||||
if (status == STARTUP_INVALID && cbuf_len(cbret))
|
||||
clicon_log(LOG_NOTICE, "%s: %u %s", __PROGRAM__, getpid(), cbuf_get(cbret));
|
||||
clixon_log(h, LOG_NOTICE, "%s: %u %s", __PROGRAM__, getpid(), cbuf_get(cbret));
|
||||
|
||||
/* Call backend plugin_start with user -- options */
|
||||
if (clixon_plugin_start_all(h) < 0)
|
||||
|
|
@ -1044,13 +1047,13 @@ main(int argc,
|
|||
daemonized errors OK. Before this stage, errors are logged on stderr
|
||||
also */
|
||||
if (foreground==0){
|
||||
clicon_log_init(__PROGRAM__, dbg?LOG_DEBUG:LOG_INFO,
|
||||
logdst==CLICON_LOG_FILE?CLICON_LOG_FILE:CLICON_LOG_SYSLOG);
|
||||
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO,
|
||||
logdst==CLIXON_LOG_FILE?CLIXON_LOG_FILE:CLIXON_LOG_SYSLOG);
|
||||
/* Call plugin callbacks just before fork/daemonization */
|
||||
if (clixon_plugin_pre_daemon_all(h) < 0)
|
||||
goto done;
|
||||
if (daemon(0, 0) < 0){
|
||||
clicon_err(OE_UNIX, errno, "daemon");
|
||||
clixon_err(OE_UNIX, errno, "daemon");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1065,21 +1068,21 @@ main(int argc,
|
|||
goto done;
|
||||
|
||||
if (set_signal(SIGTERM, backend_sig_term, NULL) < 0){
|
||||
clicon_err(OE_DAEMON, errno, "Setting signal");
|
||||
clixon_err(OE_DAEMON, errno, "Setting signal");
|
||||
goto done;
|
||||
}
|
||||
if (set_signal(SIGINT, backend_sig_term, NULL) < 0){
|
||||
clicon_err(OE_DAEMON, errno, "Setting signal");
|
||||
clixon_err(OE_DAEMON, errno, "Setting signal");
|
||||
goto done;
|
||||
}
|
||||
/* This is in case restconf daemon forked using process-control API */
|
||||
if (set_signal(SIGCHLD, backend_sig_child, NULL) < 0){
|
||||
clicon_err(OE_DAEMON, errno, "Setting signal");
|
||||
clixon_err(OE_DAEMON, errno, "Setting signal");
|
||||
goto done;
|
||||
}
|
||||
/* Client exit in the middle of a transaction, handled in clicon_msg_send */
|
||||
if (set_signal(SIGPIPE, SIG_IGN, NULL) < 0){
|
||||
clicon_err(OE_DAEMON, errno, "Setting signal");
|
||||
clixon_err(OE_DAEMON, errno, "Setting signal");
|
||||
goto done;
|
||||
}
|
||||
/* Initialize server socket and save it to handle */
|
||||
|
|
@ -1106,7 +1109,7 @@ main(int argc,
|
|||
/* Just before event-loop, after socket bind/listen */
|
||||
if (netconf_monitoring_statistics_init(h) < 0)
|
||||
goto done;
|
||||
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
|
||||
clixon_log(h, LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
|
||||
if (clixon_event_loop(h) < 0)
|
||||
goto done;
|
||||
ok:
|
||||
|
|
@ -1114,7 +1117,7 @@ main(int argc,
|
|||
done:
|
||||
if (cbret)
|
||||
cbuf_free(cbret);
|
||||
clicon_log(LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval);
|
||||
clixon_log(h, LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval);
|
||||
backend_terminate(h); /* Cannot use h after this */
|
||||
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
*/
|
||||
int
|
||||
clixon_plugin_reset_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -89,8 +89,8 @@ clixon_plugin_reset_one(clixon_plugin_t *cp,
|
|||
if (fn(h, db) < 0) {
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Reset callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
if (clixon_err_category() < 0)
|
||||
clixon_log(h, LOG_WARNING, "%s: Internal error: Reset callback in plugin: %s returned -1 but did not make a clixon_err call",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ clixon_plugin_reset_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_plugin_reset_all(clicon_handle h,
|
||||
clixon_plugin_reset_all(clixon_handle h,
|
||||
char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -137,7 +137,7 @@ clixon_plugin_reset_all(clicon_handle h,
|
|||
*/
|
||||
static int
|
||||
clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
||||
clicon_handle h)
|
||||
clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||
|
|
@ -150,9 +150,9 @@ clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
|||
if (fn(h) < 0) {
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Pre-daemon callback in plugin:\
|
||||
%s returned -1 but did not make a clicon_err call",
|
||||
if (clixon_err_category() < 0)
|
||||
clixon_log(h, LOG_WARNING, "%s: Internal error: Pre-daemon callback in plugin:\
|
||||
%s returned -1 but did not make a clixon_err call",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_plugin_pre_daemon_all(clicon_handle h)
|
||||
clixon_plugin_pre_daemon_all(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
|
@ -199,7 +199,7 @@ clixon_plugin_pre_daemon_all(clicon_handle h)
|
|||
*/
|
||||
static int
|
||||
clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
||||
clicon_handle h)
|
||||
clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||
|
|
@ -212,8 +212,8 @@ clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
|||
if (fn(h) < 0) {
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: Daemon callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
if (clixon_err_category() < 0)
|
||||
clixon_log(h, LOG_WARNING, "%s: Internal error: Daemon callback in plugin: %s returned -1 but did not make a clixon_err call",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
|||
* @note Also called for non-background mode
|
||||
*/
|
||||
int
|
||||
clixon_plugin_daemon_all(clicon_handle h)
|
||||
clixon_plugin_daemon_all(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin_t *cp = NULL;
|
||||
|
|
@ -280,7 +280,7 @@ clixon_plugin_daemon_all(clicon_handle h)
|
|||
*/
|
||||
static int
|
||||
clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
cvec *nsc,
|
||||
char *xpath,
|
||||
cxobj **xp)
|
||||
|
|
@ -299,8 +299,8 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
|||
if (fn(h, nsc, xpath, x) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (clicon_errno < 0)
|
||||
clicon_log(LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clicon_err call",
|
||||
if (clixon_err_category() < 0)
|
||||
clixon_log(h, LOG_WARNING, "%s: Internal error: State callback in plugin: %s returned -1 but did not make a clixon_err call",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto fail; /* Dont quit here on user callbacks */
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
|||
* @note xret can be replaced in this function
|
||||
*/
|
||||
int
|
||||
clixon_plugin_statedata_all(clicon_handle h,
|
||||
clixon_plugin_statedata_all(clixon_handle h,
|
||||
yang_stmt *yspec,
|
||||
cvec *nsc,
|
||||
char *xpath,
|
||||
|
|
@ -353,12 +353,12 @@ clixon_plugin_statedata_all(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;
|
||||
}
|
||||
/* error reason should be in clicon_err_reason */
|
||||
/* error reason should be in clixon_err_reason */
|
||||
cprintf(cberr, "Internal error, state callback in plugin %s returned invalid XML: %s",
|
||||
clixon_plugin_name_get(cp), clicon_err_reason);
|
||||
clixon_plugin_name_get(cp), clixon_err_reason());
|
||||
if (netconf_operation_failed_xml(&xerr, "application", cbuf_get(cberr)) < 0)
|
||||
goto done;
|
||||
xml_free(*xret);
|
||||
|
|
@ -430,7 +430,7 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
*/
|
||||
static int
|
||||
clixon_plugin_lockdb_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
char *db,
|
||||
int lock,
|
||||
int id)
|
||||
|
|
@ -463,7 +463,7 @@ clixon_plugin_lockdb_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Fatal error
|
||||
*/
|
||||
int
|
||||
clixon_plugin_lockdb_all(clicon_handle h,
|
||||
clixon_plugin_lockdb_all(clixon_handle h,
|
||||
char *db,
|
||||
int lock,
|
||||
int id
|
||||
|
|
@ -491,7 +491,7 @@ clixon_plugin_lockdb_all(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_pagination_cb_call(clicon_handle h,
|
||||
clixon_pagination_cb_call(clixon_handle h,
|
||||
char *xpath,
|
||||
int locked,
|
||||
uint32_t offset,
|
||||
|
|
@ -524,7 +524,7 @@ clixon_pagination_cb_call(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
clixon_pagination_cb_register(clicon_handle h,
|
||||
clixon_pagination_cb_register(clixon_handle h,
|
||||
handler_function fn,
|
||||
char *xpath,
|
||||
void *arg)
|
||||
|
|
@ -535,7 +535,7 @@ clixon_pagination_cb_register(clicon_handle h,
|
|||
|
||||
clicon_ptr_get(h, "pagination-entries", (void**)&htable);
|
||||
if (dispatcher_register_handler(&htable, &x) < 0){
|
||||
clicon_err(OE_PLUGIN, errno, "dispatcher");
|
||||
clixon_err(OE_PLUGIN, errno, "dispatcher");
|
||||
goto done;
|
||||
}
|
||||
if (clicon_ptr_set(h, "pagination-entries", htable) < 0)
|
||||
|
|
@ -550,7 +550,7 @@ clixon_pagination_cb_register(clicon_handle h,
|
|||
* @param[in] h Clixon handle
|
||||
*/
|
||||
int
|
||||
clixon_pagination_free(clicon_handle h)
|
||||
clixon_pagination_free(clixon_handle h)
|
||||
{
|
||||
dispatcher_entry_t *htable = NULL;
|
||||
|
||||
|
|
@ -573,7 +573,7 @@ transaction_new(void)
|
|||
static uint64_t id = 0; /* Global transaction id */
|
||||
|
||||
if ((td = malloc(sizeof(*td))) == NULL){
|
||||
clicon_err(OE_CFG, errno, "malloc");
|
||||
clixon_err(OE_CFG, errno, "malloc");
|
||||
return NULL;
|
||||
}
|
||||
memset(td, 0, sizeof(*td));
|
||||
|
|
@ -614,7 +614,7 @@ transaction_free(transaction_data_t *td)
|
|||
*/
|
||||
int
|
||||
plugin_transaction_begin_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -628,8 +628,8 @@ plugin_transaction_begin_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -651,7 +651,7 @@ plugin_transaction_begin_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error: one of the plugin callbacks returned error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_begin_all(clicon_handle h,
|
||||
plugin_transaction_begin_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -677,7 +677,7 @@ plugin_transaction_begin_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
plugin_transaction_validate_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -691,8 +691,8 @@ plugin_transaction_validate_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
|
||||
goto done;
|
||||
|
|
@ -713,7 +713,7 @@ plugin_transaction_validate_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error: one of the plugin callbacks returned validation fail
|
||||
*/
|
||||
int
|
||||
plugin_transaction_validate_all(clicon_handle h,
|
||||
plugin_transaction_validate_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -739,7 +739,7 @@ plugin_transaction_validate_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
plugin_transaction_complete_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -753,8 +753,8 @@ plugin_transaction_complete_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -776,7 +776,7 @@ plugin_transaction_complete_one(clixon_plugin_t *cp,
|
|||
* @note Rename to transaction_complete?
|
||||
*/
|
||||
int
|
||||
plugin_transaction_complete_all(clicon_handle h,
|
||||
plugin_transaction_complete_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -802,7 +802,7 @@ plugin_transaction_complete_all(clicon_handle h,
|
|||
* plugin 2, then the revert will be made in plugins 1 and 0.
|
||||
*/
|
||||
static int
|
||||
plugin_transaction_revert_all(clicon_handle h,
|
||||
plugin_transaction_revert_all(clixon_handle h,
|
||||
transaction_data_t *td,
|
||||
int nr)
|
||||
{
|
||||
|
|
@ -814,7 +814,7 @@ plugin_transaction_revert_all(clicon_handle h,
|
|||
if ((fn = clixon_plugin_api_get(cp)->ca_trans_revert) == NULL)
|
||||
continue;
|
||||
if ((retval = fn(h, (transaction_data)td)) < 0){
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' trans_revert callback failed",
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' trans_revert callback failed",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
break;
|
||||
}
|
||||
|
|
@ -833,7 +833,7 @@ plugin_transaction_revert_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
plugin_transaction_commit_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -847,8 +847,8 @@ plugin_transaction_commit_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -871,7 +871,7 @@ plugin_transaction_commit_one(clixon_plugin_t *cp,
|
|||
* and in reverse order.
|
||||
*/
|
||||
int
|
||||
plugin_transaction_commit_all(clicon_handle h,
|
||||
plugin_transaction_commit_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -901,7 +901,7 @@ plugin_transaction_commit_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -915,8 +915,8 @@ plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -937,7 +937,7 @@ plugin_transaction_commit_done_one(clixon_plugin_t *cp,
|
|||
* @note no revert is done
|
||||
*/
|
||||
int
|
||||
plugin_transaction_commit_done_all(clicon_handle h,
|
||||
plugin_transaction_commit_done_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -962,7 +962,7 @@ plugin_transaction_commit_done_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
plugin_transaction_end_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -976,8 +976,8 @@ plugin_transaction_end_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -997,7 +997,7 @@ plugin_transaction_end_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_end_all(clicon_handle h,
|
||||
plugin_transaction_end_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -1015,7 +1015,7 @@ plugin_transaction_end_all(clicon_handle h,
|
|||
|
||||
int
|
||||
plugin_transaction_abort_one(clixon_plugin_t *cp,
|
||||
clicon_handle h,
|
||||
clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -1029,8 +1029,8 @@ plugin_transaction_abort_one(clixon_plugin_t *cp,
|
|||
if (fn(h, (transaction_data)td) < 0){
|
||||
if (plugin_context_check(h, &wh, clixon_plugin_name_get(cp), __FUNCTION__) < 0)
|
||||
goto done;
|
||||
if (!clicon_errno) /* sanity: log if clicon_err() is not called ! */
|
||||
clicon_log(LOG_NOTICE, "%s: Plugin '%s' callback does not make clicon_err call on error",
|
||||
if (!clixon_err_category()) /* sanity: log if clixon_err() is not called ! */
|
||||
clixon_log(h, LOG_NOTICE, "%s: Plugin '%s' callback does not make clixon_err call on error",
|
||||
__FUNCTION__, clixon_plugin_name_get(cp));
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -1050,7 +1050,7 @@ plugin_transaction_abort_one(clixon_plugin_t *cp,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
plugin_transaction_abort_all(clicon_handle h,
|
||||
plugin_transaction_abort_all(clixon_handle h,
|
||||
transaction_data_t *td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
restconf_pseudo_set_log(clicon_handle h,
|
||||
restconf_pseudo_set_log(clixon_handle h,
|
||||
cxobj *xt)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -102,7 +102,7 @@ restconf_pseudo_set_log(clicon_handle h,
|
|||
if (argv[i+1])
|
||||
free(argv[i+1]);
|
||||
if ((argv[i+1] = strdup("s")) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ restconf_pseudo_set_log(clicon_handle h,
|
|||
if (argv[i+1])
|
||||
free(argv[i+1]);
|
||||
if ((argv[i+1] = strdup("f/var/log/clixon_restconf.log")) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ restconf_pseudo_set_log(clicon_handle h,
|
|||
if (dbg){
|
||||
free(argv[i+1]);
|
||||
if ((argv[i+1] = strdup(dbg)) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ restconf_pseudo_set_log(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
restconf_pseudo_set_inline(clicon_handle h,
|
||||
restconf_pseudo_set_inline(clixon_handle h,
|
||||
cxobj *xt)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -165,13 +165,13 @@ restconf_pseudo_set_inline(clicon_handle h,
|
|||
char *str;
|
||||
if (strcmp(argv[i], "-R") == 0 && argc > i+1 && argv[i+1]){
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_XML, errno, "cbuf_new");
|
||||
clixon_err(OE_XML, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml2cbuf(cb, xrestconf, 0, 0, NULL, -1, 0) < 0)
|
||||
goto done;
|
||||
if ((str = strdup(cbuf_get(cb))) == NULL){
|
||||
clicon_err(OE_XML, errno, "stdup");
|
||||
clixon_err(OE_XML, errno, "stdup");
|
||||
goto done;
|
||||
}
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "%s str:%s", __FUNCTION__, str);
|
||||
|
|
@ -196,7 +196,7 @@ restconf_pseudo_set_inline(clicon_handle h,
|
|||
* These rules give that if RPC op is start and enable is false -> change op to none
|
||||
*/
|
||||
int
|
||||
restconf_rpc_wrapper(clicon_handle h,
|
||||
restconf_rpc_wrapper(clixon_handle h,
|
||||
process_entry_t *pe,
|
||||
proc_operation *operation)
|
||||
{
|
||||
|
|
@ -248,7 +248,7 @@ restconf_rpc_wrapper(clicon_handle h,
|
|||
* this is ignored.
|
||||
*/
|
||||
static int
|
||||
restconf_pseudo_process_control(clicon_handle h)
|
||||
restconf_pseudo_process_control(clixon_handle h)
|
||||
{
|
||||
int retval = -1;
|
||||
char **argv = NULL;
|
||||
|
|
@ -266,12 +266,12 @@ restconf_pseudo_process_control(clicon_handle h)
|
|||
nr += 2;
|
||||
#endif
|
||||
if ((argv = calloc(nr, sizeof(char *))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "calloc");
|
||||
clixon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
}
|
||||
i = 0;
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
/* Try to figure out where clixon_restconf is installed
|
||||
|
|
@ -303,7 +303,7 @@ restconf_pseudo_process_control(clicon_handle h)
|
|||
clixon_debug(CLIXON_DBG_DEFAULT, "Not found: %s", pgm);
|
||||
}
|
||||
if (!found){
|
||||
clicon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR",
|
||||
clixon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR",
|
||||
dir0, dir1);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ restconf_pseudo_process_control(clicon_handle h)
|
|||
/*! Restconf pseudo-plugin process validate
|
||||
*/
|
||||
static int
|
||||
restconf_pseudo_process_validate(clicon_handle h,
|
||||
restconf_pseudo_process_validate(clixon_handle h,
|
||||
transaction_data td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -357,11 +357,11 @@ restconf_pseudo_process_validate(clicon_handle h,
|
|||
xpath_first(xtarget, NULL, "restconf/socket[ssl='true']")){
|
||||
/* Should filepath be checked? One could claim this is a runtime system,... */
|
||||
if (xpath_first(xtarget, 0, "restconf/server-cert-path") == NULL){
|
||||
clicon_err(OE_CFG, 0, "SSL enabled but server-cert-path not set");
|
||||
clixon_err(OE_CFG, 0, "SSL enabled but server-cert-path not set");
|
||||
return -1; /* induce fail */
|
||||
}
|
||||
if (xpath_first(xtarget, 0, "restconf/server-key-path") == NULL){
|
||||
clicon_err(OE_CFG, 0, "SSL enabled but server-key-path not set");
|
||||
clixon_err(OE_CFG, 0, "SSL enabled but server-key-path not set");
|
||||
return -1; /* induce fail */
|
||||
}
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ restconf_pseudo_process_validate(clicon_handle h,
|
|||
/*! Restconf pseduo-plugin process commit
|
||||
*/
|
||||
static int
|
||||
restconf_pseudo_process_commit(clicon_handle h,
|
||||
restconf_pseudo_process_commit(clixon_handle h,
|
||||
transaction_data td)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -437,7 +437,7 @@ restconf_pseudo_process_commit(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
backend_plugin_restconf_register(clicon_handle h,
|
||||
backend_plugin_restconf_register(clixon_handle h,
|
||||
yang_stmt *yspec)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@
|
|||
#ifndef _BACKEND_PLUGIN_RESTCONF_H_
|
||||
#define _BACKEND_PLUGIN_RESTCONF_H_
|
||||
|
||||
int backend_plugin_restconf_register(clicon_handle h, yang_stmt *yspec);
|
||||
int backend_plugin_restconf_register(clixon_handle h, yang_stmt *yspec);
|
||||
|
||||
#endif /* _BACKEND_PLUGIN_RESTCONF_H_ */
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "backend_socket.h"
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
config_socket_init_ipv4(clicon_handle h,
|
||||
config_socket_init_ipv4(clixon_handle h,
|
||||
char *dst)
|
||||
{
|
||||
int s;
|
||||
|
|
@ -96,7 +96,7 @@ config_socket_init_ipv4(clicon_handle h,
|
|||
|
||||
/* create inet socket */
|
||||
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
clicon_err(OE_UNIX, errno, "socket");
|
||||
clixon_err(OE_UNIX, errno, "socket");
|
||||
return -1;
|
||||
}
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one));
|
||||
|
|
@ -104,16 +104,16 @@ config_socket_init_ipv4(clicon_handle h,
|
|||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port);
|
||||
if (inet_pton(addr.sin_family, dst, &addr.sin_addr) != 1){
|
||||
clicon_err(OE_UNIX, errno, "inet_pton: %s (Expected IPv4 address. Check settings of CLICON_SOCK_FAMILY and CLICON_SOCK)", dst);
|
||||
clixon_err(OE_UNIX, errno, "inet_pton: %s (Expected IPv4 address. Check settings of CLICON_SOCK_FAMILY and CLICON_SOCK)", dst);
|
||||
goto err; /* Could check getaddrinfo */
|
||||
}
|
||||
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0){
|
||||
clicon_err(OE_UNIX, errno, "bind");
|
||||
clixon_err(OE_UNIX, errno, "bind");
|
||||
goto err;
|
||||
}
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "Listen on server socket at %s:%hu", dst, port);
|
||||
if (listen(s, 5) < 0){
|
||||
clicon_err(OE_UNIX, errno, "listen");
|
||||
clixon_err(OE_UNIX, errno, "listen");
|
||||
goto err;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -132,7 +132,7 @@ config_socket_init_ipv4(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
config_socket_init_unix(clicon_handle h,
|
||||
config_socket_init_unix(clixon_handle h,
|
||||
char *sock)
|
||||
{
|
||||
int s;
|
||||
|
|
@ -143,23 +143,23 @@ config_socket_init_unix(clicon_handle h,
|
|||
struct stat st;
|
||||
|
||||
if (lstat(sock, &st) == 0 && unlink(sock) < 0){
|
||||
clicon_err(OE_UNIX, errno, "unlink(%s)", sock);
|
||||
clixon_err(OE_UNIX, errno, "unlink(%s)", sock);
|
||||
return -1;
|
||||
}
|
||||
/* then find configuration group (for clients) and find its groupid */
|
||||
if ((config_group = clicon_sock_group(h)) == NULL){
|
||||
clicon_err(OE_FATAL, 0, "clicon_sock_group option not set");
|
||||
clixon_err(OE_FATAL, 0, "clicon_sock_group option not set");
|
||||
return -1;
|
||||
}
|
||||
if (group_name2gid(config_group, &gid) < 0)
|
||||
return -1;
|
||||
#if 0
|
||||
if (gid == 0)
|
||||
clicon_log(LOG_WARNING, "%s: No such group: %s", __FUNCTION__, config_group);
|
||||
clixon_log(h, LOG_WARNING, "%s: No such group: %s", __FUNCTION__, config_group);
|
||||
#endif
|
||||
/* create unix socket */
|
||||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
clicon_err(OE_UNIX, errno, "socket");
|
||||
clixon_err(OE_UNIX, errno, "socket");
|
||||
return -1;
|
||||
}
|
||||
// setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one));
|
||||
|
|
@ -168,19 +168,19 @@ config_socket_init_unix(clicon_handle h,
|
|||
strncpy(addr.sun_path, sock, sizeof(addr.sun_path)-1);
|
||||
old_mask = umask(S_IRWXO | S_IXGRP | S_IXUSR);
|
||||
if (bind(s, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0){
|
||||
clicon_err(OE_UNIX, errno, "bind");
|
||||
clixon_err(OE_UNIX, errno, "bind");
|
||||
umask(old_mask);
|
||||
goto err;
|
||||
}
|
||||
umask(old_mask);
|
||||
/* change socket path file group */
|
||||
if (lchown(sock, -1, gid) < 0){
|
||||
clicon_err(OE_UNIX, errno, "lchown(%s, %s)", sock, config_group);
|
||||
clixon_err(OE_UNIX, errno, "lchown(%s, %s)", sock, config_group);
|
||||
goto err;
|
||||
}
|
||||
clixon_debug(CLIXON_DBG_DEFAULT, "Listen on server socket at %s", addr.sun_path);
|
||||
if (listen(s, 5) < 0){
|
||||
clicon_err(OE_UNIX, errno, "listen");
|
||||
clixon_err(OE_UNIX, errno, "listen");
|
||||
goto err;
|
||||
}
|
||||
return s;
|
||||
|
|
@ -196,12 +196,12 @@ config_socket_init_unix(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
backend_socket_init(clicon_handle h)
|
||||
backend_socket_init(clixon_handle h)
|
||||
{
|
||||
char *sock; /* unix path or ip address string */
|
||||
|
||||
if ((sock = 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");
|
||||
return -1;
|
||||
}
|
||||
switch (clicon_sock_family(h)){
|
||||
|
|
@ -212,7 +212,7 @@ backend_socket_init(clicon_handle h)
|
|||
return config_socket_init_ipv4(h, sock);
|
||||
break;
|
||||
default:
|
||||
clicon_err(OE_UNIX, EINVAL, "No such address family: %d",
|
||||
clixon_err(OE_UNIX, EINVAL, "No such address family: %d",
|
||||
clicon_sock_family(h));
|
||||
break;
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ backend_socket_init(clicon_handle h)
|
|||
/*! Accept new socket client
|
||||
*
|
||||
* @param[in] fd Socket (unix or ip)
|
||||
* @param[in] arg typecast clicon_handle
|
||||
* @param[in] arg typecast clixon_handle
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
|
|
@ -231,7 +231,7 @@ backend_accept_client(int fd,
|
|||
void *arg)
|
||||
{
|
||||
int retval = -1;
|
||||
clicon_handle h = (clicon_handle)arg;
|
||||
clixon_handle h = (clixon_handle)arg;
|
||||
int s;
|
||||
struct sockaddr from = {0,};
|
||||
socklen_t len;
|
||||
|
|
@ -248,7 +248,7 @@ backend_accept_client(int fd,
|
|||
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
|
||||
len = sizeof(from);
|
||||
if ((s = accept(fd, &from, &len)) < 0){
|
||||
clicon_err(OE_UNIX, errno, "accept");
|
||||
clixon_err(OE_UNIX, errno, "accept");
|
||||
goto done;
|
||||
}
|
||||
if ((ce = backend_client_add(h, &from)) == NULL)
|
||||
|
|
@ -262,7 +262,7 @@ backend_accept_client(int fd,
|
|||
#if defined(HAVE_SO_PEERCRED)
|
||||
clen = sizeof(cr);
|
||||
if(getsockopt(s, SOL_SOCKET, SO_PEERCRED, &cr, &clen) < 0){
|
||||
clicon_err(OE_UNIX, errno, "getsockopt");
|
||||
clixon_err(OE_UNIX, errno, "getsockopt");
|
||||
goto done;
|
||||
}
|
||||
if (uid2name(cr.uid, &name) < 0)
|
||||
|
|
@ -277,7 +277,7 @@ backend_accept_client(int fd,
|
|||
#endif
|
||||
if (name != NULL){
|
||||
if ((ce->ce_username = name) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "strdup");
|
||||
clixon_err(OE_UNIX, errno, "strdup");
|
||||
name = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int backend_socket_init(clicon_handle h);
|
||||
int backend_socket_init(clixon_handle h);
|
||||
int backend_accept_client(int fd, void *arg);
|
||||
|
||||
#endif /* _BACKEND_SOCKET_H_ */
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
db_merge(clicon_handle h,
|
||||
db_merge(clixon_handle h,
|
||||
const char *db1,
|
||||
const char *db2,
|
||||
cbuf *cbret)
|
||||
|
|
@ -130,7 +130,7 @@ startup --+-------------------------------------> BROKEN XML
|
|||
* @note: if commit fails, copy factory to running
|
||||
*/
|
||||
int
|
||||
startup_mode_startup(clicon_handle h,
|
||||
startup_mode_startup(clixon_handle h,
|
||||
char *db,
|
||||
cbuf *cbret)
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ startup_mode_startup(clicon_handle h,
|
|||
yang_stmt *yspec = clicon_dbspec_yang(h);
|
||||
|
||||
if (strcmp(db, "running")==0){
|
||||
clicon_err(OE_FATAL, 0, "Invalid startup db: %s", db);
|
||||
clixon_err(OE_FATAL, 0, "Invalid startup db: %s", db);
|
||||
goto done;
|
||||
}
|
||||
/* If startup does not exist, create it empty */
|
||||
|
|
@ -158,7 +158,7 @@ startup_mode_startup(clicon_handle h,
|
|||
*/
|
||||
if (if_feature(yspec, "ietf-netconf", "confirmed-commit")) {
|
||||
if ((rollback_exists = xmldb_exists(h, "rollback")) < 0) {
|
||||
clicon_err(OE_DAEMON, 0, "Error checking for the existence of the rollback database");
|
||||
clixon_err(OE_DAEMON, 0, "Error checking for the existence of the rollback database");
|
||||
goto done;
|
||||
}
|
||||
if (rollback_exists == 1) {
|
||||
|
|
@ -211,7 +211,7 @@ startup_mode_startup(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
load_extraxml(clicon_handle h,
|
||||
load_extraxml(clixon_handle h,
|
||||
char *filename,
|
||||
const char *db,
|
||||
cbuf *cbret)
|
||||
|
|
@ -226,7 +226,7 @@ load_extraxml(clicon_handle h,
|
|||
if (filename == NULL)
|
||||
return 1;
|
||||
if ((fp = fopen(filename, "r")) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "open(%s)", filename);
|
||||
clixon_err(OE_UNIX, errno, "open(%s)", filename);
|
||||
goto done;
|
||||
}
|
||||
yspec = clicon_dbspec_yang(h);
|
||||
|
|
@ -248,7 +248,6 @@ load_extraxml(clicon_handle h,
|
|||
retval = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Merge user reset state */
|
||||
retval = xmldb_put(h, (char*)db, OP_MERGE, xt, clicon_username_get(h), cbret);
|
||||
done:
|
||||
|
|
@ -280,7 +279,7 @@ tmp |-------+-----+-----+
|
|||
reset extrafile
|
||||
*/
|
||||
int
|
||||
startup_extraxml(clicon_handle h,
|
||||
startup_extraxml(clixon_handle h,
|
||||
char *file,
|
||||
cbuf *cbret)
|
||||
{
|
||||
|
|
@ -352,7 +351,7 @@ startup_extraxml(clicon_handle h,
|
|||
* @retval -1 Error
|
||||
*/
|
||||
int
|
||||
startup_module_state(clicon_handle h,
|
||||
startup_module_state(clixon_handle h,
|
||||
yang_stmt *yspec)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int startup_mode_startup(clicon_handle h, char *db, cbuf *cbret);
|
||||
int startup_extraxml(clicon_handle h, char *file, cbuf *cbret);
|
||||
int startup_module_state(clicon_handle h, yang_stmt *yspec);
|
||||
int startup_mode_startup(clixon_handle h, char *db, cbuf *cbret);
|
||||
int startup_extraxml(clixon_handle h, char *file, cbuf *cbret);
|
||||
int startup_module_state(clixon_handle h, yang_stmt *yspec);
|
||||
|
||||
#endif /* _BACKEND_STARTUP_H_ */
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct client_entry{
|
|||
int ce_nr; /* Client number (for dbg/tracing) */
|
||||
uint32_t ce_id; /* Session id, accessor functions: clicon_session_id_get/set */
|
||||
char *ce_username;/* Translated from peer user cred */
|
||||
clicon_handle ce_handle; /* clicon config handle (all clients have same?) */
|
||||
clixon_handle ce_handle; /* clicon config handle (all clients have same?) */
|
||||
char *ce_transport; /* Identifies the transport for each session.
|
||||
Clixon-lib.yang extends these values by prefixing with
|
||||
"cl:", where cl is ensured to be declared ie by
|
||||
|
|
|
|||
|
|
@ -56,28 +56,28 @@ enum confirmed_commit_state {
|
|||
* Prototypes
|
||||
*/
|
||||
/* backend_confirm.c */
|
||||
int confirmed_commit_init(clicon_handle h);
|
||||
int confirmed_commit_free(clicon_handle h);
|
||||
enum confirmed_commit_state confirmed_commit_state_get(clicon_handle h);
|
||||
uint32_t confirmed_commit_session_id_get(clicon_handle h);
|
||||
int cancel_rollback_event(clicon_handle h);
|
||||
int cancel_confirmed_commit(clicon_handle h);
|
||||
int handle_confirmed_commit(clicon_handle h, cxobj *xe, uint32_t myid);
|
||||
int do_rollback(clicon_handle h, uint8_t *errs);
|
||||
int from_client_cancel_commit(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_confirmed_commit(clicon_handle h, cxobj *xe, uint32_t myid, cbuf *cbret);
|
||||
int confirmed_commit_init(clixon_handle h);
|
||||
int confirmed_commit_free(clixon_handle h);
|
||||
enum confirmed_commit_state confirmed_commit_state_get(clixon_handle h);
|
||||
uint32_t confirmed_commit_session_id_get(clixon_handle h);
|
||||
int cancel_rollback_event(clixon_handle h);
|
||||
int cancel_confirmed_commit(clixon_handle h);
|
||||
int handle_confirmed_commit(clixon_handle h, cxobj *xe, uint32_t myid);
|
||||
int do_rollback(clixon_handle h, uint8_t *errs);
|
||||
int from_client_cancel_commit(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_confirmed_commit(clixon_handle h, cxobj *xe, uint32_t myid, cbuf *cbret);
|
||||
|
||||
/* backend_commit.c */
|
||||
int startup_validate(clicon_handle h, char *db, cxobj **xtr, cbuf *cbret);
|
||||
int startup_commit(clicon_handle h, char *db, cbuf *cbret);
|
||||
int candidate_validate(clicon_handle h, char *db, cbuf *cbret);
|
||||
int candidate_commit(clicon_handle h, cxobj *xe, char *db, uint32_t myid,
|
||||
int startup_validate(clixon_handle h, char *db, cxobj **xtr, cbuf *cbret);
|
||||
int startup_commit(clixon_handle h, char *db, cbuf *cbret);
|
||||
int candidate_validate(clixon_handle h, char *db, cbuf *cbret);
|
||||
int candidate_commit(clixon_handle h, cxobj *xe, char *db, uint32_t myid,
|
||||
validate_level vlev, cbuf *cbret);
|
||||
|
||||
int from_client_commit(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_discard_changes(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_validate(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_restart_one(clicon_handle h, clixon_plugin_t *cp, cbuf *cbret);
|
||||
int load_failsafe(clicon_handle h, char *phase);
|
||||
int from_client_commit(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_discard_changes(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_validate(clixon_handle h, cxobj *xe, cbuf *cbret, void *arg, void *regarg);
|
||||
int from_client_restart_one(clixon_handle h, clixon_plugin_t *cp, cbuf *cbret);
|
||||
int load_failsafe(clixon_handle h, char *phase);
|
||||
|
||||
#endif /* _CLIXON_BACKEND_COMMIT_H_ */
|
||||
|
|
|
|||
|
|
@ -58,21 +58,21 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_client.h"
|
||||
#include "backend_client.h"
|
||||
#include "backend_handle.h"
|
||||
|
||||
/* header part is copied from struct clicon_handle in lib/src/clicon_handle.c */
|
||||
/* header part is copied from struct clixon_handle in lib/src/clixon_handle.c */
|
||||
|
||||
#define CLICON_MAGIC 0x99aafabe
|
||||
|
||||
#define handle(h) (assert(clicon_handle_check(h)==0),(struct backend_handle *)(h))
|
||||
#define handle(h) (assert(clixon_handle_check(h)==0),(struct backend_handle *)(h))
|
||||
|
||||
/* Clicon_handle for backends.
|
||||
* First part of this is header, same for clicon_handle and cli_handle.
|
||||
/* Clixon_handle for backends.
|
||||
* First part of this is header, same for clixon_handle and cli_handle.
|
||||
* Access functions for common fields are found in clicon lib: clicon_options.[ch]
|
||||
* This file should only contain access functions for the _specific_
|
||||
* entries in the struct below.
|
||||
|
|
@ -81,8 +81,8 @@
|
|||
*
|
||||
* This file should only contain access functions for the _specific_
|
||||
* entries in the struct below.
|
||||
* @note The top part must be equivalent to struct clicon_handle in clixon_handle.c
|
||||
* @see struct clicon_handle, struct cli_handle
|
||||
* @note The top part must be equivalent to struct clixon_handle in clixon_handle.c
|
||||
* @see struct clixon_handle, struct cli_handle
|
||||
*/
|
||||
struct backend_handle {
|
||||
int bh_magic; /* magic (HDR)*/
|
||||
|
|
@ -98,14 +98,14 @@ struct backend_handle {
|
|||
|
||||
/*! Creates and returns a clicon config handle for other CLICON API calls
|
||||
*/
|
||||
clicon_handle
|
||||
clixon_handle
|
||||
backend_handle_init(void)
|
||||
{
|
||||
struct backend_handle *bh;
|
||||
|
||||
bh = (struct backend_handle *)clicon_handle_init0(sizeof(struct backend_handle));
|
||||
bh = (struct backend_handle *)clixon_handle_init0(sizeof(struct backend_handle));
|
||||
bh->bh_ce_nr = 1; /* To align with session-id */
|
||||
return (clicon_handle)bh;
|
||||
return (clixon_handle)bh;
|
||||
}
|
||||
|
||||
/*! Deallocates a backend handle, including all client structs
|
||||
|
|
@ -114,7 +114,7 @@ backend_handle_init(void)
|
|||
* @see backend_client_rm
|
||||
*/
|
||||
int
|
||||
backend_handle_exit(clicon_handle h)
|
||||
backend_handle_exit(clixon_handle h)
|
||||
{
|
||||
struct client_entry *ce;
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ backend_handle_exit(clicon_handle h)
|
|||
}
|
||||
backend_client_delete(h, ce);
|
||||
}
|
||||
clicon_handle_exit(h); /* frees h and options (and streams) */
|
||||
clixon_handle_exit(h); /* frees h and options (and streams) */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -138,14 +138,14 @@ backend_handle_exit(clicon_handle h)
|
|||
* @retval NULL Error
|
||||
*/
|
||||
struct client_entry *
|
||||
backend_client_add(clicon_handle h,
|
||||
backend_client_add(clixon_handle h,
|
||||
struct sockaddr *addr)
|
||||
{
|
||||
struct backend_handle *bh = handle(h);
|
||||
struct client_entry *ce;
|
||||
|
||||
if ((ce = (struct client_entry *)malloc(sizeof(*ce))) == NULL){
|
||||
clicon_err(OE_PLUGIN, errno, "malloc");
|
||||
clixon_err(OE_PLUGIN, errno, "malloc");
|
||||
return NULL;
|
||||
}
|
||||
memset(ce, 0, sizeof(*ce));
|
||||
|
|
@ -154,7 +154,7 @@ backend_client_add(clicon_handle h,
|
|||
ce->ce_next = bh->bh_ce_list;
|
||||
ce->ce_handle = h;
|
||||
if (clicon_session_id_get(h, &ce->ce_id) < 0){
|
||||
clicon_err(OE_NETCONF, ENOENT, "session_id not set");
|
||||
clixon_err(OE_NETCONF, ENOENT, "session_id not set");
|
||||
return NULL;
|
||||
}
|
||||
clicon_session_id_set(h, ce->ce_id + 1);
|
||||
|
|
@ -170,7 +170,7 @@ backend_client_add(clicon_handle h,
|
|||
* @retval ce_list Client entry list (all sessions)
|
||||
*/
|
||||
struct client_entry *
|
||||
backend_client_list(clicon_handle h)
|
||||
backend_client_list(clixon_handle h)
|
||||
{
|
||||
struct backend_handle *bh = handle(h);
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ backend_client_list(clicon_handle h)
|
|||
* @see backend_client_rm which is more high-level
|
||||
*/
|
||||
int
|
||||
backend_client_delete(clicon_handle h,
|
||||
backend_client_delete(clixon_handle h,
|
||||
struct client_entry *ce)
|
||||
{
|
||||
struct client_entry *c;
|
||||
|
|
@ -215,7 +215,7 @@ backend_client_delete(clicon_handle h,
|
|||
* @param[in] f UNIX output stream
|
||||
*/
|
||||
int
|
||||
backend_client_print(clicon_handle h,
|
||||
backend_client_print(clixon_handle h,
|
||||
FILE *f)
|
||||
{
|
||||
struct backend_handle *bh = handle(h);
|
||||
|
|
|
|||
|
|
@ -94,44 +94,44 @@ typedef struct {
|
|||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int clixon_plugin_reset_one(clixon_plugin_t *cp, clicon_handle h, char *db);
|
||||
int clixon_plugin_reset_all(clicon_handle h, char *db);
|
||||
int clixon_plugin_reset_one(clixon_plugin_t *cp, clixon_handle h, char *db);
|
||||
int clixon_plugin_reset_all(clixon_handle h, char *db);
|
||||
|
||||
int clixon_plugin_pre_daemon_all(clicon_handle h);
|
||||
int clixon_plugin_daemon_all(clicon_handle h);
|
||||
int clixon_plugin_pre_daemon_all(clixon_handle h);
|
||||
int clixon_plugin_daemon_all(clixon_handle h);
|
||||
|
||||
int clixon_plugin_statedata_all(clicon_handle h, yang_stmt *yspec, cvec *nsc, char *xpath,
|
||||
int clixon_plugin_statedata_all(clixon_handle h, yang_stmt *yspec, cvec *nsc, char *xpath,
|
||||
withdefaults_type wdef, cxobj **xtop);
|
||||
int clixon_plugin_lockdb_all(clicon_handle h, char *db, int lock, int id);
|
||||
int clixon_plugin_lockdb_all(clixon_handle h, char *db, int lock, int id);
|
||||
|
||||
int clixon_pagination_cb_register(clicon_handle h, handler_function fn, char *path, void *arg);
|
||||
int clixon_pagination_cb_call(clicon_handle h, char *xpath, int locked,
|
||||
int clixon_pagination_cb_register(clixon_handle h, handler_function fn, char *path, void *arg);
|
||||
int clixon_pagination_cb_call(clixon_handle h, char *xpath, int locked,
|
||||
uint32_t offset, uint32_t limit,
|
||||
cxobj *xstate);
|
||||
int clixon_pagination_free(clicon_handle h);
|
||||
int clixon_pagination_free(clixon_handle h);
|
||||
|
||||
transaction_data_t * transaction_new(void);
|
||||
int transaction_free(transaction_data_t *);
|
||||
|
||||
int plugin_transaction_begin_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_begin_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_begin_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_begin_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_validate_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_validate_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_validate_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_validate_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_complete_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_complete_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_complete_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_complete_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_commit_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_commit_done_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_done_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_done_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_commit_done_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_end_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_end_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_end_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_end_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
int plugin_transaction_abort_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_abort_all(clicon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_abort_one(clixon_plugin_t *cp, clixon_handle h, transaction_data_t *td);
|
||||
int plugin_transaction_abort_all(clixon_handle h, transaction_data_t *td);
|
||||
|
||||
#endif /* _CLIXON_BACKEND_PLUGIN_H_ */
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
/* cligen */
|
||||
#include <cligen/cligen.h>
|
||||
|
||||
/* clicon */
|
||||
/* clixon */
|
||||
#include <clixon/clixon.h>
|
||||
|
||||
#include "clixon_backend_transaction.h"
|
||||
|
|
@ -258,7 +258,7 @@ transaction_print(FILE *f,
|
|||
* @param[in] msg Debug msg tag
|
||||
*/
|
||||
int
|
||||
transaction_dbg(clicon_handle h,
|
||||
transaction_dbg(clixon_handle h,
|
||||
int dbglevel,
|
||||
transaction_data th,
|
||||
const char *msg)
|
||||
|
|
@ -270,7 +270,7 @@ transaction_dbg(clicon_handle h,
|
|||
|
||||
td = (transaction_data_t *)th;
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_CFG, errno, "cbuf_new");
|
||||
clixon_err(OE_CFG, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
for (i=0; i<td->td_dlen; i++){
|
||||
|
|
@ -313,7 +313,7 @@ transaction_dbg(clicon_handle h,
|
|||
/*! Log a transaction
|
||||
*/
|
||||
int
|
||||
transaction_log(clicon_handle h,
|
||||
transaction_log(clixon_handle h,
|
||||
transaction_data th,
|
||||
int level,
|
||||
const char *op)
|
||||
|
|
@ -325,7 +325,7 @@ transaction_log(clicon_handle h,
|
|||
|
||||
td = (transaction_data_t *)th;
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_CFG, errno, "cbuf_new");
|
||||
clixon_err(OE_CFG, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
for (i=0; i<td->td_dlen; i++){
|
||||
|
|
@ -334,7 +334,7 @@ transaction_log(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s del: %s",
|
||||
clixon_log(h, level, "%s %" PRIu64 " %s del: %s",
|
||||
__FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
cbuf_reset(cb);
|
||||
for (i=0; i<td->td_alen; i++){
|
||||
|
|
@ -343,7 +343,7 @@ transaction_log(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s add: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
clixon_log(h, level, "%s %" PRIu64 " %s add: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
cbuf_reset(cb);
|
||||
for (i=0; i<td->td_clen; i++){
|
||||
if (td->td_scvec){
|
||||
|
|
@ -356,7 +356,7 @@ transaction_log(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
if (i)
|
||||
clicon_log(level, "%s %" PRIu64 " %s change: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
clixon_log(h, level, "%s %" PRIu64 " %s change: %s", __FUNCTION__, td->td_id, op, cbuf_get(cb));
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ cxobj **transaction_tcvec(transaction_data td);
|
|||
size_t transaction_clen(transaction_data td);
|
||||
|
||||
int transaction_print(FILE *f, transaction_data th);
|
||||
int transaction_dbg(clicon_handle h, int dbglevel, transaction_data th, const char *msg);
|
||||
int transaction_log(clicon_handle h, transaction_data th, int level, const char *op);
|
||||
int transaction_dbg(clixon_handle h, int dbglevel, transaction_data th, const char *msg);
|
||||
int transaction_log(clixon_handle h, transaction_data th, int level, const char *op);
|
||||
|
||||
|
||||
/* Pagination callbacks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue