diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb09a7083..43e1f25b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,20 @@ Users may have to change how they access the system
### C/CLI-API changes on existing features
Developers may need to change their code
+* Low-level message functions added `descr` argument for better logging
+ * In this way, message debugs in level 2 are more descriptive
+ * The descr argument can be set to NULL for backward-compability, see the following translations:
+ * clicon_rpc(s, ...) --> clicon_rpc(s, NULL, ...)
+ * clicon_rpc1(s, ...) --> clicon_rpc1(s, NULL, ...)
+ * clicon_msg_send(s, ...) --> clicon_msg_send(s, NULL, ...)
+ * clicon_msg_send1(s, ...) --> clicon_msg_send1(s, NULL, ...)
+ * clicon_msg_rcv(s, ...) --> clicon_msg_rcv(s, NULL, ...)
+ * clicon_msg_rcv1(s, ...) --> clicon_msg_rcv1(s, NULL, ...)
+ * clicon_msg_notify_xml(h, s, ...) --> clicon_msg_notify_xml(h, s, NULL, ...)
+ * send_msg_reply(s, ...) --> send_msg_reply(s, NULL, ...)
+ * clixon_client_lock(s, ...) --> clixon_client_lock(s, NULL, ...)
+ * clixon_client_hello(s, ...) --> clixon_client_hello(s, NULL, ...)
+
* CLI pipe function: added arg to `pipe_tail_fn()`
### Minor features
diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index 8281eb4bc..a1381d074 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -91,7 +91,7 @@ ce_find_byid(struct client_entry *ce_list,
/*! Stream callback for netconf stream notification (RFC 5277)
*
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] op 0:event, 1:rm
* @param[in] event Event as XML
* @param[in] arg Extra argument provided in stream_ss_add
@@ -113,7 +113,7 @@ ce_event_cb(clicon_handle h,
backend_client_rm(h, ce);
break;
default:
- if (send_msg_notify_xml(h, ce->ce_s, event) < 0){
+ if (send_msg_notify_xml(h, ce->ce_s, ce->ce_source_host, event) < 0){
if (errno == ECONNRESET || errno == EPIPE){
clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr);
}
@@ -126,6 +126,44 @@ ce_event_cb(clicon_handle h,
return 0;
}
+/*! Construct a client string from client_entry information for logging
+ *
+ * @param[in] ce Client entry struct
+ * @param[out] cbp Cligen buffer, deallocate with cbuf_free
+ * @retval 0 OK
+ * @retval -1 Error
+ */
+static int
+ce_client_string(struct client_entry *ce,
+ cbuf **cbp)
+{
+ int retval = -1;
+ cbuf *cb = NULL;
+ char *id = NULL;
+
+ if (ce == NULL || cbp == NULL){
+ clicon_err(OE_UNIX, EINVAL, "ce or cbp is NULL");
+ goto done;
+ }
+ if ((cb = cbuf_new()) == NULL){
+ clicon_err(OE_UNIX, errno, "cbuf_new");
+ goto done;
+
+ }
+ if (ce->ce_transport){
+ if (nodeid_split(ce->ce_transport, NULL, &id) < 0)
+ goto done;
+ cprintf(cb, "%s", id);
+ }
+ cprintf(cb, "%u", ce->ce_id);
+ *cbp = cb;
+ retval = 0;
+ done:
+ if (id)
+ free(id);
+ return retval;
+}
+
/*! Unlock all db:s of a client and call user unlock calback
*
* @see xmldb_unlock_all unlocks, but does not call user callbacks which is a backend thing
@@ -164,7 +202,7 @@ release_all_dbs(clicon_handle h,
*
* Backend-specific netconf monitoring state is:
* sessions
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] yspec Yang spec
* @param[in] xpath XML Xpath
* @param[in] nsc XML Namespace context for xpath
@@ -248,7 +286,7 @@ backend_monitoring_state_get(clicon_handle h,
*
* Close down everything wrt clients (eg sockets, subscriptions)
* Finally actually remove client struct in handle
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] ce Client handle
* @retval 0 Ok
* @retval -1 Error (fatal)
@@ -313,7 +351,7 @@ backend_client_rm(clicon_handle h,
/*! Get clixon per datastore stats
*
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] dbname Datastore name
* @param[in,out] cb Cligen buf
* @retval 0 OK
@@ -356,7 +394,7 @@ clixon_stats_datastore_get(clicon_handle h,
/*! Get clixon per datastore stats
*
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] dbname Datastore name
* @param[in,out] cb Cligen buf
* @retval 0 OK
@@ -386,7 +424,7 @@ clixon_stats_module_get(clicon_handle h,
/*! Loads all or part of a specified configuration to target configuration
*
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @param[in] xn Request:
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ...,
* @param[out] cbret Return xml tree, eg ..., ce_s, cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
+ if (ce_client_string(ce, &cbce) < 0)
+ goto done;
+ if (send_msg_reply(ce->ce_s, cbuf_get(cbce), cbuf_get(cbret), cbuf_len(cbret)+1) < 0){
switch (errno){
case EPIPE:
/* man (2) write:
@@ -1767,6 +1808,8 @@ from_client_msg(clicon_handle h,
xml_free(xret);
if (xt)
xml_free(xt);
+ if (cbce)
+ cbuf_free(cbce);
if (cbret)
cbuf_free(cbret);
/* Sanity: log if clicon_err() is not called ! */
@@ -1794,13 +1837,16 @@ from_client(int s,
struct client_entry *ce = (struct client_entry *)arg;
clicon_handle h = ce->ce_handle;
int eof = 0;
+ cbuf *cbce = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (s != ce->ce_s){
clicon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
goto done;
}
- if (clicon_msg_rcv(ce->ce_s, 0, &msg, &eof) < 0)
+ if (ce_client_string(ce, &cbce) < 0)
+ goto done;
+ if (clicon_msg_rcv(ce->ce_s, cbuf_get(cbce), 0, &msg, &eof) < 0)
goto done;
if (eof){
backend_client_rm(h, ce);
@@ -1812,6 +1858,8 @@ from_client(int s,
retval = 0;
done:
clicon_debug(CLIXON_DBG_DETAIL, "%s retval=%d", __FUNCTION__, retval);
+ if (cbce)
+ cbuf_free(cbce);
if (msg)
free(msg);
return retval; /* -1 here terminates backend */
@@ -1819,7 +1867,7 @@ from_client(int s,
/*! Init backend rpc: Set up standard netconf rpc callbacks
*
- * @param[in] h Clicon handle
+ * @param[in] h Clixon handle
* @retval 0 OK
* @retval -1 Error (fatal)
* @see ietf-netconf@2011-06-01.yang
diff --git a/apps/backend/backend_startup.c b/apps/backend/backend_startup.c
index b60be6e83..fd2a2c635 100644
--- a/apps/backend/backend_startup.c
+++ b/apps/backend/backend_startup.c
@@ -72,9 +72,10 @@
#include "backend_startup.h"
/*! Merge db1 into db2 without commit
- * @retval -1 Error
- * @retval 0 Validation failed (with cbret set)
+ *
* @retval 1 Validation OK
+ * @retval 0 Validation failed (with cbret set)
+ * @retval -1 Error
*/
static int
db_merge(clicon_handle h,
@@ -97,12 +98,13 @@ db_merge(clicon_handle h,
}
/*! Clixon startup startup mode: Commit startup configuration into running state
+ *
* @param[in] h Clixon handle
* @param[in] db tmp or startup
* @param[out] cbret If status is invalid contains error message
- * @retval -1 Error
- * @retval 0 Validation failed
* @retval 1 OK
+ * @retval 0 Validation failed
+ * @retval -1 Error
OK:
reset
@@ -203,9 +205,10 @@ startup_mode_startup(clicon_handle h,
}
/*! Merge xml in filename into database
- * @retval -1 Error
- * @retval 0 Validation failed (with cbret set)
+ *
* @retval 1 Validation OK
+ * @retval 0 Validation failed (with cbret set)
+ * @retval -1 Error
*/
static int
load_extraxml(clicon_handle h,
@@ -257,18 +260,21 @@ load_extraxml(clicon_handle h,
}
/*! Load extra XML via file and/or reset callback, and merge with current
+ *
* An application can add extra XML either via the -c option or
* via the .ca_reset callback. This XML is "merged" into running, that is,
* it does not trigger validation calbacks.
* The function uses an extra "tmp" database, loads the file to it, and calls
* the reset function on it.
- * @param[in] h Clicon handle
- * @param[in] file (Optional) extra xml file
+ * @param[in] h Clixon handle
+ * @param[in] file (Optional) extra xml file
* @param[out] status Startup status
* @param[out] cbret If status is invalid contains error message
- * @retval -1 Error
- * @retval 0 Validation failed
* @retval 1 OK
+ * @retval 0 Validation failed
+ * @retval -1 Error
+
+
running -----------------+----+------>
reset loadfile / merge
@@ -341,10 +347,11 @@ startup_extraxml(clicon_handle h,
}
/*! Init modules state of the backend (server). To compare with startup XML
+ *
* Set the modules state as setopt to the datastore module.
* Only if CLICON_XMLDB_MODSTATE is enabled
- * @retval -1 Error
* @retval 0 OK
+ * @retval -1 Error
*/
int
startup_module_state(clicon_handle h,
diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c
index 8fda05e99..d345e42a0 100644
--- a/apps/cli/cli_common.c
+++ b/apps/cli/cli_common.c
@@ -1283,7 +1283,7 @@ cli_notification_cb(int s,
int ret;
/* get msg (this is the reason this function is called) */
- if (clicon_msg_rcv(s, 0, &reply, &eof) < 0)
+ if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
goto done;
if (eof){
clicon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");
diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c
index 2ded279ef..dc13832bc 100644
--- a/apps/netconf/netconf_rpc.c
+++ b/apps/netconf/netconf_rpc.c
@@ -453,7 +453,7 @@ netconf_notification_cb(int s,
clicon_debug(1, "%s", __FUNCTION__);
/* get msg (this is the reason this function is called) */
- if (clicon_msg_rcv(s, 0, &reply, &eof) < 0)
+ if (clicon_msg_rcv(s, NULL, 0, &reply, &eof) < 0)
goto done;
/* handle close from remote end: this will exit the client */
if (eof){
diff --git a/lib/clixon/clixon_client.h b/lib/clixon/clixon_client.h
index 0feb3a847..7e1dfeb2e 100644
--- a/lib/clixon/clixon_client.h
+++ b/lib/clixon/clixon_client.h
@@ -73,8 +73,8 @@ extern "C" {
clixon_handle clixon_client_init(const char *config_file);
int clixon_client_terminate(clixon_handle h);
-int clixon_client_lock(int sock, const int lock, const char *db);
-int clixon_client_hello(int sock, int version);
+int clixon_client_lock(int sock, const char *descr, const int lock, const char *db);
+int clixon_client_hello(int sock, const char *descr, int version);
clixon_client_handle clixon_client_connect(clixon_handle h, clixon_client_type socktype, const char *dest);
int clixon_client_disconnect(clixon_client_handle ch);
int clixon_client_get_bool(clixon_client_handle ch, int *rval, const char *xnamespace, const char *xpath);
diff --git a/lib/clixon/clixon_proto.h b/lib/clixon/clixon_proto.h
index c05a32e8a..6fffeff38 100644
--- a/lib/clixon/clixon_proto.h
+++ b/lib/clixon/clixon_proto.h
@@ -72,21 +72,21 @@ int clicon_rpc_connect_inet(clicon_handle h,
uint16_t port,
int *sock0);
-int clicon_rpc(int sock, struct clicon_msg *msg, char **xret, int *eof);
+int clicon_rpc(int sock, const char *descr, struct clicon_msg *msg, char **xret, int *eof);
-int clicon_rpc1(int sock, cbuf *msgin, cbuf *msgret, int *eof);
+int clicon_rpc1(int sock, const char *descr, cbuf *msgin, cbuf *msgret, int *eof);
-int clicon_msg_send(int s, struct clicon_msg *msg);
+int clicon_msg_send(int s, const char *descr, struct clicon_msg *msg);
-int clicon_msg_send1(int s, cbuf *cb);
+int clicon_msg_send1(int s, const char *descr, cbuf *cb);
-int clicon_msg_rcv(int s, int intr, struct clicon_msg **msg, int *eof);
+int clicon_msg_rcv(int s, const char *descr, int intr, struct clicon_msg **msg, int *eof);
-int clicon_msg_rcv1(int s, cbuf *cb, int *eof);
+int clicon_msg_rcv1(int s, const char *descr, cbuf *cb, int *eof);
-int send_msg_notify_xml(clicon_handle h, int s, cxobj *xev);
+int send_msg_notify_xml(clicon_handle h, int s, const char *descr, cxobj *xev);
-int send_msg_reply(int s, char *data, uint32_t datalen);
+int send_msg_reply(int s, const char *descr, char *data, uint32_t datalen);
int detect_endtag(char *tag, char ch, int *state);
diff --git a/lib/src/clixon_client.c b/lib/src/clixon_client.c
index 2729298c7..08d5ccbe9 100644
--- a/lib/src/clixon_client.c
+++ b/lib/src/clixon_client.c
@@ -86,11 +86,13 @@ struct clixon_client_handle{
uint32_t cch_magic; /* magic number */
clixon_client_type cch_type; /* Clixon socket type */
int cch_socket; /* Input/output socket */
+ char *cch_descr; /* Description of socket / peer for logging XXX NYI */
int cch_pid; /* Sub-process-id Only applies for NETCONF/SSH */
int cch_locked; /* State variable: 1 means locked */
};
/*! Check struct magic number for sanity checks
+ *
* @param[in] h Clicon client handle
* @retval 0 Sanity check OK
* @retval -1 Sanity check failed
@@ -105,9 +107,10 @@ clixon_client_handle_check(clixon_client_handle ch)
}
/*! Initialize Clixon client API
+ *
* @param[in] config_file Clixon configuration file, or NULL for default
- * @retval h Clixon handler
- * @retval NULL Error
+ * @retval h Clixon handler
+ * @retval NULL Error
* @see clixon_client_close
*/
clixon_handle
@@ -129,6 +132,7 @@ clixon_client_init(const char *config_file)
}
/*! Deallocate everything from client_init
+ *
* @param[in] h Clixon handle
* @see clixon_client_init
*/
@@ -141,14 +145,17 @@ clixon_client_terminate(clicon_handle h)
}
/*! Send a lock request (internal)
+ *
* @param[in] sock Open socket
+ * @param[in] descr Description of peer for logging
* @param[in] lock 0: unlock, 1: lock
* @param[in] db Datastore name
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_lock(int sock,
+ const char *descr,
const int lock,
const char *db)
{
@@ -177,7 +184,7 @@ clixon_client_lock(int sock,
NETCONF_BASE_NAMESPACE,
NETCONF_MESSAGE_ID_ATTR,
lock?"":"un", db, lock?"":"un");
- if (clicon_rpc1(sock, msg, msgret, &eof) < 0)
+ if (clicon_rpc1(sock, descr, msg, msgret, &eof) < 0)
goto done;
if (eof){
close(sock);
@@ -205,14 +212,16 @@ clixon_client_lock(int sock,
/*! Internal function to construct the encoding and hello message
*
- * @param[in] sock Socket to netconf server
- * @param[in] version Netconf version for capability announcement
- * @retval 0 OK
- * @retval -1 Error
+ * @param[in] sock Socket to netconf server
+ * @param[in] descr Description of peer for logging
+ * @param[in] version Netconf version for capability announcement
+ * @retval 0 OK
+ * @retval -1 Error
*/
int
-clixon_client_hello(int sock,
- int version)
+clixon_client_hello(int sock,
+ const char *descr,
+ int version)
{
int retval = -1;
cbuf *msg = NULL;
@@ -229,7 +238,7 @@ clixon_client_hello(int sock,
cprintf(msg, "");
cprintf(msg, "");
cprintf(msg, "]]>]]>");
- if (clicon_msg_send1(sock, msg) < 0)
+ if (clicon_msg_send1(sock, descr, msg) < 0)
goto done;
retval = 0;
done:
@@ -331,6 +340,7 @@ clixon_client_connect_ssh(clicon_handle h,
}
/*! Connect client to clixon backend according to config and return a socket
+ *
* @param[in] h Clixon handle
* @param[in] socktype Type of socket, internal/external/netconf/ssh
* @param[in] dest Destination for some types
@@ -384,14 +394,17 @@ clixon_client_connect(clicon_handle h,
}
/*! Connect client to clixon backend according to config and return a socket
- * @param[in] ch Clixon client session handle
+ *
+ * @param[in] ch Clixon client session handle
+ * @retval 0 OK
+ * @retval -1 Error
* @see clixon_client_connect where the handle is created
* The handle is deallocated
*/
int
clixon_client_disconnect(clixon_client_handle ch)
{
- int retval = -1;
+ int retval = -1;
struct clixon_client_handle *cch = chandle(ch);
clicon_debug(1, "%s", __FUNCTION__);
@@ -421,9 +434,10 @@ clixon_client_disconnect(clixon_client_handle ch)
}
/*! Get the bottom-most leaf in an xml tree being a result of xpath
- * @param[in] xtop Pointer to XML top-of-tree
- * @param[out] xbotp Pointer to XML bottom node
- * @retval 0 OK
+ *
+ * @param[in] xtop Pointer to XML top-of-tree
+ * @param[out] xbotp Pointer to XML bottom node
+ * @retval 0 OK
*/
static int
clixon_xml_bottom(cxobj *xtop,
@@ -456,15 +470,17 @@ clixon_xml_bottom(cxobj *xtop,
/*! Internal function to construct a get-config and query a value from the backend
*
* @param[in] sock Socket
+ * @param[in] descr Description of peer for logging
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
* @param[in] xpath XPath
* @param[out] xdata XML data tree (may or may not include the intended data)
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
* @note configurable netconf framing type, now hardwired to 0
*/
static int
clixon_client_get_xdata(int sock,
+ const char *descr,
const char *namespace,
const char *xpath,
cxobj **xdata)
@@ -506,9 +522,9 @@ clixon_client_get_xdata(int sock,
cprintf(msg, "");
if (netconf_output_encap(0, msg) < 0) // XXX configurable session
goto done;
- if (clicon_msg_send1(sock, msg) < 0)
+ if (clicon_msg_send1(sock, descr, msg) < 0)
goto done;
- if (clicon_msg_rcv1(sock, msgret, &eof) < 0)
+ if (clicon_msg_rcv1(sock, descr, msgret, &eof) < 0)
goto done;
if (eof){
close(sock);
@@ -544,15 +560,18 @@ clixon_client_get_xdata(int sock,
}
/*! Generic get value of body
+ *
* @param[in] sock Open socket
+ * @param[in] descr Description of peer for logging
* @param[in] namespace Default namespace used for non-prefixed entries in xpath.
* @param[in] xpath XPath
* @param[out] val Output value
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
static int
clixon_client_get_body_val(int sock,
+ const char *descr,
const char *namespace,
const char *xpath,
char **val)
@@ -566,7 +585,7 @@ clixon_client_get_body_val(int sock,
clicon_err(OE_XML, EINVAL, "Expected val");
goto done;
}
- if (clixon_client_get_xdata(sock, namespace, xpath, &xdata) < 0)
+ if (clixon_client_get_xdata(sock, descr, namespace, xpath, &xdata) < 0)
goto done;
if (xdata == NULL){
clicon_err(OE_XML, EINVAL, "No xml obj found");
@@ -591,12 +610,13 @@ clixon_client_get_body_val(int sock,
}
/*! Client-api get boolean
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_bool(clixon_client_handle ch,
@@ -612,7 +632,7 @@ clixon_client_get_bool(clixon_client_handle ch,
uint8_t val0=0;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
if ((ret = parse_bool(val, &val0, &reason)) < 0){
@@ -632,13 +652,14 @@ clixon_client_get_bool(clixon_client_handle ch,
}
/*! Client-api get string
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value string
- * @param[in] n Length of string
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value string
+ * @param[in] n Length of string
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_str(clixon_client_handle ch,
@@ -652,7 +673,7 @@ clixon_client_get_str(clixon_client_handle ch,
char *val = NULL;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
strncpy(rval, val, n-1);
@@ -663,12 +684,13 @@ clixon_client_get_str(clixon_client_handle ch,
}
/*! Client-api get uint8
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_uint8(clixon_client_handle ch,
@@ -683,7 +705,7 @@ clixon_client_get_uint8(clixon_client_handle ch,
int ret;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
if ((ret = parse_uint8(val, rval, &reason)) < 0){
@@ -702,12 +724,13 @@ clixon_client_get_uint8(clixon_client_handle ch,
}
/*! Client-api get uint16
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_uint16(clixon_client_handle ch,
@@ -722,7 +745,7 @@ clixon_client_get_uint16(clixon_client_handle ch,
int ret;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
if ((ret = parse_uint16(val, rval, &reason)) < 0){
@@ -741,12 +764,13 @@ clixon_client_get_uint16(clixon_client_handle ch,
}
/*! Client-api get uint32
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_uint32(clixon_client_handle ch,
@@ -761,7 +785,7 @@ clixon_client_get_uint32(clixon_client_handle ch,
int ret;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
if (val == NULL){
@@ -785,12 +809,13 @@ clixon_client_get_uint32(clixon_client_handle ch,
}
/*! Client-api get uint64
- * @param[in] ch Clixon client handle
- * @param[out] rval Return value
+ *
+ * @param[in] ch Clixon client handle
+ * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
- * @param[in] xpath XPath
+ * @param[in] xpath XPath
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
clixon_client_get_uint64(clixon_client_handle ch,
@@ -805,7 +830,7 @@ clixon_client_get_uint64(clixon_client_handle ch,
int ret;
clicon_debug(1, "%s", __FUNCTION__);
- if (clixon_client_get_body_val(cch->cch_socket,
+ if (clixon_client_get_body_val(cch->cch_socket, cch->cch_descr,
namespace, xpath, &val) < 0)
goto done;
if ((ret = parse_uint64(val, rval, &reason)) < 0){
@@ -825,6 +850,7 @@ clixon_client_get_uint64(clixon_client_handle ch,
/* Access functions */
/*! Client-api get uint64
+ *
* @param[in] ch Clixon client handle
* @retval s Open socket
* @retval -1 No/closed socket
diff --git a/lib/src/clixon_proto.c b/lib/src/clixon_proto.c
index 630a6be88..6f5f78165 100644
--- a/lib/src/clixon_proto.c
+++ b/lib/src/clixon_proto.c
@@ -100,6 +100,7 @@ static struct formatvec _FORMATS[] = {
};
/*! Translate from numeric format to string representation
+ *
* @param[in] showas Format value (see enum format_enum)
* @retval str String value
*/
@@ -115,6 +116,7 @@ format_int2str(enum format_enum showas)
}
/*! Translate from string to numeric format representation
+ *
* @param[in] str String value
* @retval enum Format value (see enum format_enum)
*/
@@ -130,10 +132,11 @@ format_str2int(char *str)
}
/*! Encode a clicon netconf message using variable argument lists
+ *
* @param[in] id Session id of client
* @param[in] format Variable agrument list format an XML netconf string
- * @retval NULL Error
* @retval msg Clicon message to send to eg clicon_msg_send()
+ * @retval NULL Error
* @note if format includes %, they will be expanded according to printf rules.
* if this is a problem, use ("%s", xml) instaead of (xml)
* Notaly this may an issue of RFC 3896 encoded strings
@@ -171,7 +174,8 @@ clicon_msg_encode(uint32_t id,
}
/*! Decode a clicon netconf message
- * @param[in] msg CLICON msg
+ *
+ * @param[in] msg Clixon msg
* @param[in] yspec Yang specification, (can be NULL)
* @param[out] id Session id
* @param[out] xml XML parse tree
@@ -211,10 +215,11 @@ clicon_msg_decode(struct clicon_msg *msg,
}
/*! Open local connection using unix domain sockets
+ *
* @param[in] h Clicon handle
* @param[in] sockpath Unix domain file path
- * @retval s socket
- * @retval -1 error
+ * @retval s Socket
+ * @retval -1 Error
*/
int
clicon_connect_unix(clicon_handle h,
@@ -255,6 +260,7 @@ atomicio_sig_handler(int arg)
}
/*! Ensure all of data on socket comes through. fn is either read or write
+ *
* @param[in] fn I/O function, ie read/write
* @param[in] fd File descriptor, eg socket
* @param[in] s0 Buffer to read to or write from
@@ -339,21 +345,29 @@ msg_hex(int dbglevel,
return retval;
}
-/*! Send a CLICON netconf message using internal IPC message
+/*! Send a Clixon netconf message using internal IPC message
*
- * @param[in] s socket (unix or inet) to communicate with backend
- * @param[out] msg CLICON msg data reply structure. Free with free()
+ * @param[in] s Socket (unix or inet) to communicate with backend
+ * @param[in] descr Description of peer for logging
+ * @param[in] msg Clixon msg data reply structure
+ * @retval 0 OK
+ * @retval -1 Error
* @see clicon_msg_send1 using plain NETCONF
*/
int
clicon_msg_send(int s,
+ const char *descr,
struct clicon_msg *msg)
{
int retval = -1;
int e;
clicon_debug(CLIXON_DBG_DETAIL, "%s: send msg len=%d", __FUNCTION__, ntohl(msg->op_len));
- clicon_debug(CLIXON_DBG_MSG, "Send: %s", msg->op_body);
+ if (descr)
+ clicon_debug(CLIXON_DBG_MSG, "Send [%s]: %s", descr, msg->op_body);
+ else{
+ clicon_debug(CLIXON_DBG_MSG, "Send: %s", msg->op_body);
+ }
msg_hex(CLIXON_DBG_EXTRA, (char*)msg, ntohl(msg->op_len), __FUNCTION__);
if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, msg, ntohl(msg->op_len)) < 0){
@@ -368,7 +382,7 @@ clicon_msg_send(int s,
return retval;
}
-/*! Receive a CLICON message using IPC message struct
+/*! Receive a Clixon message using IPC message struct
*
* XXX: timeout? and signals?
* There is rudimentary code for turning on signals and handling them
@@ -378,27 +392,29 @@ clicon_msg_send(int s,
* behaviour.
* Now, ^C will interrupt the whole process, and this may not be what you want.
*
- * @param[in] s socket (unix or inet) to communicate with backend
- * @param[in] intr If set, make a ^C cause an error
- * @param[out] msg CLICON msg data reply structure. Free with free()
- * @param[out] eof Set if eof encountered
- * @retval 0 OK
- * @retval -1 Error
+ * @param[in] s Socket (unix or inet) to communicate with backend
+ * @param[in] descr Description of peer for logging
+ * @param[in] intr If set, make a ^C cause an error
+ * @param[out] msg Clixon msg data reply structure. Free with free()
+ * @param[out] eof Set if eof encountered
+ * @retval 0 OK
+ * @retval -1 Error
* Note: caller must ensure that s is closed if eof is set after call.
* @see clicon_msg_rcv1 using plain NETCONF
*/
int
-clicon_msg_rcv(int s,
- int intr,
+clicon_msg_rcv(int s,
+ const char *descr,
+ int intr,
struct clicon_msg **msg,
int *eof)
{
- int retval = -1;
+ int retval = -1;
struct clicon_msg hdr;
- int hlen;
- ssize_t len2;
- sigfn_t oldhandler;
- uint32_t mlen;
+ int hlen;
+ ssize_t len2;
+ sigfn_t oldhandler;
+ uint32_t mlen;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
*eof = 0;
@@ -453,7 +469,10 @@ clicon_msg_rcv(int s,
*eof = 1;
goto ok;
}
- clicon_debug(CLIXON_DBG_MSG, "Recv: %s", (*msg)->op_body);
+ if (descr)
+ clicon_debug(CLIXON_DBG_MSG, "Recv [%s]: %s", descr, (*msg)->op_body);
+ else
+ clicon_debug(CLIXON_DBG_MSG, "Recv: %s", (*msg)->op_body);
ok:
retval = 0;
done:
@@ -468,16 +487,20 @@ clicon_msg_rcv(int s,
/*! Receive a message using plain NETCONF
*
* @param[in] s socket (unix or inet) to communicate with backend
+ * @param[in] descr Description of peer for logging
* @param[out] cb cligen buf struct containing the incoming message
* @param[out] eof Set if eof encountered
+ * @retval 0 OK
+ * @retval -1 Error
* @see netconf_input_cb()
* @see clicon_msg_rcv using IPC message struct
* @note only NETCONF version 1.0 EOM framing
*/
int
-clicon_msg_rcv1(int s,
- cbuf *cb,
- int *eof)
+clicon_msg_rcv1(int s,
+ const char *descr,
+ cbuf *cb,
+ int *eof)
{
int retval = -1;
unsigned char buf[BUFSIZ];
@@ -523,27 +546,37 @@ clicon_msg_rcv1(int s,
break; /* No data to read */
} /* while */
ok:
- clicon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
+ if (descr)
+ clicon_debug(CLIXON_DBG_MSG, "Recv [%s]: %s", descr, cbuf_get(cb));
+ else
+ clicon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
retval = 0;
done:
clicon_debug(CLIXON_DBG_DETAIL, "%s done", __FUNCTION__);
return retval;
}
-/*! Send a CLICON netconf message plain NETCONF
+/*! Send a Clixon netconf message plain NETCONF
*
- * @param[in] s socket (unix or inet) to communicate with backend
- * @param[out] msg CLICON msg data reply structure. Free with free()
+ * @param[in] s socket (unix or inet) to communicate with backend
+ * @param[in] cb data buffer including NETCONF
+ * @param[in] descr Description of peer for logging
+ * @retval 0 OK
+ * @retval -1 Error
* @see clicon_msg_send using internal IPC header
*/
int
-clicon_msg_send1(int s,
- cbuf *cb)
+clicon_msg_send1(int s,
+ const char *descr,
+ cbuf *cb)
{
int retval = -1;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
- clicon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
+ if (descr)
+ clicon_debug(CLIXON_DBG_MSG, "Send [%s]: %s", descr, cbuf_get(cb));
+ else
+ clicon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, cbuf_get(cb), cbuf_len(cb)) < 0){
clicon_err(OE_CFG, errno, "atomicio");
@@ -557,19 +590,19 @@ clicon_msg_send1(int s,
/*! Connect to server, send a clicon_msg message and wait for result using unix socket
*
- * @param[in] h Clicon handle
- * @param[in] msg CLICON msg data structure. It has fixed header and variable body.
+ * @param[in] h Clicon handle
+ * @param[in] msg Internal msg data structure. It has fixed header and variable body.
* @param[in] sockpath Unix domain file path
* @param[out] retdata Returned data as string netconf xml tree.
- * @param[out] sock0 Return socket in case of asynchronous notify
- * @retval 0 OK
- * @retval -1 Error
+ * @param[out] sock0 Return socket in case of asynchronous notify
+ * @retval 0 OK
+ * @retval -1 Error
* @see clicon_rpc But this is one-shot rpc: open, send, get reply and close.
*/
int
-clicon_rpc_connect_unix(clicon_handle h,
- char *sockpath,
- int *sock0)
+clicon_rpc_connect_unix(clicon_handle h,
+ char *sockpath,
+ int *sock0)
{
int retval = -1;
int s = -1;
@@ -602,10 +635,10 @@ clicon_rpc_connect_unix(clicon_handle h,
* @param[in] h Clicon handle (not used)
* @param[in] dst IPv4 address
* @param[in] port TCP port
- * @param[out] retdata Returned data as string netconf xml tree.
+ * @param[out] retdata Returned data as string netconf xml tree.
* @param[out] sock0 Return socket in case of asynchronous notify
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
* @see clicon_rpc But this is one-shot rpc: open, send, get reply and close.
*/
int
@@ -652,16 +685,18 @@ clicon_rpc_connect_inet(clicon_handle h,
* errno set to ENOTCONN/ESHUTDOWN which means that socket is now closed probably
* due to remote peer disconnecting. The caller may have to do something,...
*
- * @param[in] sock Socket / file descriptor
- * @param[in] msg CLICON msg data structure. It has fixed header and variable body.
- * @param[out] xret Returned data as netconf xml tree.
- * @param[out] eof Set if eof encountered
- * @retval 0 OK (check eof)
- * @retval -1 Error
+ * @param[in] sock Socket / file descriptor
+ * @param[in] descr Description of peer for logging
+ * @param[in] msg Clixon msg data structure. It has fixed header and variable body.
+ * @param[out] xret Returned data as netconf xml tree.
+ * @param[out] eof Set if eof encountered
+ * @retval 0 OK (check eof)
+ * @retval -1 Error
* @see clicon_rpc1 using plain NETCONF XML
*/
int
clicon_rpc(int sock,
+ const char *descr,
struct clicon_msg *msg,
char **ret,
int *eof)
@@ -671,9 +706,9 @@ clicon_rpc(int sock,
char *data = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
- if (clicon_msg_send(sock, msg) < 0)
+ if (clicon_msg_send(sock, descr, msg) < 0)
goto done;
- if (clicon_msg_rcv(sock, 0, &reply, eof) < 0)
+ if (clicon_msg_rcv(sock, descr, 0, &reply, eof) < 0)
goto done;
if (*eof)
goto ok;
@@ -695,20 +730,21 @@ clicon_rpc(int sock,
/*! Send a netconf message and recieve result using plain NETCONF
*
* This is mainly used by the client API.
- *
* @param[in] sock Socket / file descriptor
- * @param[in] msgin CLICON msg data structure. It has fixed header and variable body.
+ * @param[in] descr Description of peer for logging
+ * @param[in] msgin Clixon msg data structure. It has fixed header and variable body.
* @param[out] msgret Returned data as netconf xml tree.
* @param[out] eof Set if eof encountered
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
* @see clicon_rpc using clicon_msg protocol header
*/
int
-clicon_rpc1(int sock,
- cbuf *msg,
- cbuf *msgret,
- int *eof)
+clicon_rpc1(int sock,
+ const char *descr,
+ cbuf *msg,
+ cbuf *msgret,
+ int *eof)
{
int retval = -1;
@@ -717,9 +753,9 @@ clicon_rpc1(int sock,
goto done;
if (netconf_framing_postamble(NETCONF_SSH_CHUNKED, msg) < 0)
goto done;
- if (clicon_msg_send1(sock, msg) < 0)
+ if (clicon_msg_send1(sock, descr, msg) < 0)
goto done;
- if (clicon_msg_rcv1(sock, msgret, eof) < 0)
+ if (clicon_msg_rcv1(sock, descr, msgret, eof) < 0)
goto done;
retval = 0;
done:
@@ -730,15 +766,17 @@ clicon_rpc1(int sock,
/*! Send a clicon_msg message as reply to a clicon rpc request
*
* @param[in] s Socket to communicate with client
+ * @param[in] descr Description of peer for logging
* @param[in] data Returned data as byte-string.
* @param[in] datalen Length of returned data XXX may be unecessary if always string?
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
-send_msg_reply(int s,
- char *data,
- uint32_t datalen)
+send_msg_reply(int s,
+ const char *descr,
+ char *data,
+ uint32_t datalen)
{
int retval = -1;
struct clicon_msg *reply = NULL;
@@ -751,7 +789,7 @@ send_msg_reply(int s,
reply->op_len = htonl(len);
if (datalen > 0)
memcpy(reply->op_body, data, datalen);
- if (clicon_msg_send(s, reply) < 0)
+ if (clicon_msg_send(s, descr, reply) < 0)
goto done;
retval = 0;
done:
@@ -763,22 +801,24 @@ send_msg_reply(int s,
/*! Send a clicon_msg NOTIFY message asynchronously to client
*
* @param[in] s Socket to communicate with client
+ * @param[in] descr Description of peer for logging
* @param[in] level
* @param[in] event
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
* @see send_msg_notify_xml
*/
static int
-send_msg_notify(int s,
- char *event)
+send_msg_notify(int s,
+ const char *descr,
+ char *event)
{
int retval = -1;
struct clicon_msg *msg = NULL;
if ((msg=clicon_msg_encode(0, "%s", event)) == NULL)
goto done;
- if (clicon_msg_send(s, msg) < 0)
+ if (clicon_msg_send(s, descr, msg) < 0)
goto done;
retval = 0;
done:
@@ -789,16 +829,18 @@ send_msg_notify(int s,
/*! Send a clicon_msg NOTIFY message asynchronously to client
*
- * @param[in] h Clicon handle
- * @param[in] s Socket to communicate with client
- * @param[in] xev Event as XML
- * @retval 0 OK
- * @retval -1 Error
+ * @param[in] h Clicon handle
+ * @param[in] s Socket to communicate with client
+ * @param[in] descr Description of peer for logging
+ * @param[in] xev Event as XML
+ * @retval 0 OK
+ * @retval -1 Error
* @see send_msg_notify
*/
int
send_msg_notify_xml(clicon_handle h,
int s,
+ const char *descr,
cxobj *xev)
{
int retval = -1;
@@ -810,7 +852,7 @@ send_msg_notify_xml(clicon_handle h,
}
if (clixon_xml2cbuf(cb, xev, 0, 0, NULL, -1, 0) < 0)
goto done;
- if (send_msg_notify(s, cbuf_get(cb)) < 0)
+ if (send_msg_notify(s, descr, cbuf_get(cb)) < 0)
goto done;
retval = 0;
done:
@@ -821,11 +863,12 @@ send_msg_notify_xml(clicon_handle h,
}
/*! Look for a text pattern in an input string, one char at a time
+ *
* @param[in] tag What to look for
* @param[in] ch New input character
* @param[in,out] state A state integer holding how far we have parsed.
- * @retval 0 No, we havent detected end tag
* @retval 1 Yes, we have detected end tag!
+ * @retval 0 No, we havent detected end tag
* @code
* int state = 0;
* char ch;
diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c
index 2affcde11..44306fc45 100644
--- a/lib/src/clixon_proto_client.c
+++ b/lib/src/clixon_proto_client.c
@@ -168,7 +168,7 @@ clicon_rpc_msg_once(clicon_handle h,
}
else if (clicon_rpc_connect(h, &s) < 0)
goto done;
- if (clicon_rpc(s, msg, retdata, eof) < 0){
+ if (clicon_rpc(s, clicon_sock_str(h), msg, retdata, eof) < 0){
/* 2. check socket shutdown AFTER rpc */
close(s);
s = -1;
@@ -184,7 +184,7 @@ clicon_rpc_msg_once(clicon_handle h,
/*! Send internal netconf rpc from client to backend
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] msg Encoded message. Deallocate with free
* @param[out] xret0 Return value from backend as xml tree. Free w xml_free
* @retval 0 OK
@@ -263,13 +263,13 @@ clicon_rpc_msg(clicon_handle h,
/*! Send internal netconf rpc from client to backend and return a persistent socket
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] msg Encoded message. Deallocate with free
* @param[out] xret0 Return value from backend as xml tree. Free w xml_free
* @param[out] sock0 If pointer exists, do not close socket to backend on success
* and return it here. For keeping a notify socket open
- * @retval 0 OK
- * @retval -1 Error
+ * @retval 0 OK
+ * @retval -1 Error
* @note xret is populated with yangspec according to standard handle yangspec
*/
int
@@ -364,6 +364,7 @@ session_id_check(clicon_handle h,
}
/*! Generic xml netconf clicon rpc for persistent
+ *
* Want to go over to use netconf directly between client and server,...
* @param[in] h clicon handle
* @param[in] xmlstr XML netconf tree as string
@@ -484,7 +485,7 @@ clicon_rpc_netconf_xml(clicon_handle h,
/*! Get database configuration
*
* Same as clicon_proto_change just with a cvec instead of lvec
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] username If NULL, use default
* @param[in] db Name of database
* @param[in] xpath XPath (or "")
@@ -492,8 +493,8 @@ clicon_rpc_netconf_xml(clicon_handle h,
* @param[in] defaults Value of the with-defaults mode, rfc6243, or NULL
* @param[out] xt XML tree. Free with xml_free.
* Either or .
- * @retval 0 OK
- * @retval -1 Error, fatal or xml
+ * @retval 0 OK
+ * @retval -1 Error, fatal or xml
* @code
* cxobj *xt = NULL;
* cvec *nsc = NULL;
@@ -619,7 +620,7 @@ clicon_rpc_get_config(clicon_handle h,
/*! Send database entries as XML to backend daemon
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] db Name of database
* @param[in] op Operation on database item: OP_MERGE, OP_REPLACE
* @param[in] xml XML string. Ex: .....
@@ -688,11 +689,11 @@ clicon_rpc_edit_config(clicon_handle h,
*
* Note this assumes the backend can access these files and (usually) assumes
* clients and servers have the access to the same filesystem.
- * @param[in] h CLICON handle
- * @param[in] db1 src database, eg "running"
- * @param[in] db2 dst database, eg "startup"
- * @retval 0 OK
- * @retval -1 Error and logged to syslog
+ * @param[in] h Clixon handle
+ * @param[in] db1 src database, eg "running"
+ * @param[in] db2 dst database, eg "startup"
+ * @retval 0 OK
+ * @retval -1 Error and logged to syslog
* @code
* if (clicon_rpc_copy_config(h, "running", "startup") < 0)
* err;
@@ -748,10 +749,10 @@ clicon_rpc_copy_config(clicon_handle h,
/*! Send a request to backend to delete a config database
*
- * @param[in] h CLICON handle
- * @param[in] db database, eg "running"
- * @retval 0 OK
- * @retval -1 Error and logged to syslog
+ * @param[in] h Clixon handle
+ * @param[in] db database, eg "running"
+ * @retval 0 OK
+ * @retval -1 Error and logged to syslog
* @code
* if (clicon_rpc_delete_config(h, "startup") < 0)
* err;
@@ -805,10 +806,11 @@ clicon_rpc_delete_config(clicon_handle h,
}
/*! Lock a database
- * @param[in] h CLICON handle
- * @param[in] db database, eg "running"
- * @retval 0 OK
- * @retval -1 Error and logged to syslog
+ *
+ * @param[in] h Clixon handle
+ * @param[in] db database, eg "running"
+ * @retval 0 OK
+ * @retval -1 Error and logged to syslog
*/
int
clicon_rpc_lock(clicon_handle h,
@@ -858,10 +860,11 @@ clicon_rpc_lock(clicon_handle h,
}
/*! Unlock a database
- * @param[in] h CLICON handle
- * @param[in] db database, eg "running"
- * @retval 0 OK
- * @retval -1 Error and logged to syslog
+ *
+ * @param[in] h Clixon handle
+ * @param[in] db database, eg "running"
+ * @retval 0 OK
+ * @retval -1 Error and logged to syslog
*/
int
clicon_rpc_unlock(clicon_handle h,
@@ -911,6 +914,7 @@ clicon_rpc_unlock(clicon_handle h,
}
/*! Get database configuration and state data
+ *
* @param[in] h Clicon handle
* @param[in] xpath XPath in a filter stmt (or NULL/"" for no filter)
* @param[in] namespace Namespace associated w xpath
@@ -1073,15 +1077,15 @@ clicon_rpc_get(clicon_handle h,
* @param[in] content Clixon extension: all, config, noconfig. -1 means all
* @param[in] depth Nr of XML levels to get, -1 is all, 0 is none
* @param[in] defaults Value of the with-defaults mode, rfc6243, or NULL
- * @param[in] offset uint32, 0 means none
- * @param[in] limit uint32, 0 means unbounded
+ * @param[in] offset 0 means none
+ * @param[in] limit 0 means unbounded
* @param[in] direction Collection/clixon extension
* @param[in] sort Collection/clixon extension
* @param[in] where Collection/clixon extension
* @param[out] xt XML tree. Free with xml_free.
* Either or .
- * @retval 0 OK
- * @retval -1 Error, fatal or xml
+ * @retval 0 OK
+ * @retval -1 Error, fatal or xml
* @see clicon_rpc_get
* @see draft-ietf-netconf-restconf-collection-00
* @note the netconf return message is yang populated, as well as the return data
@@ -1232,7 +1236,7 @@ clicon_rpc_get_pageable_list(clicon_handle h,
/*! Send a close a netconf user session. Socket is also closed if still open
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @retval 0 OK
* @retval -1 Error and logged to syslog
* Session is implicitly created in eg clicon_rpc_netconf
@@ -1291,7 +1295,7 @@ clicon_rpc_close_session(clicon_handle h)
/*! Kill other user sessions
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] session_id Session id of other user session
* @retval 0 OK
* @retval -1 Error and logged to syslog
@@ -1345,7 +1349,7 @@ clicon_rpc_kill_session(clicon_handle h,
/*! Send validate request to backend daemon
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] db Name of database
* @retval 1 OK
* @retval 0 Invalid, netconf error return, and logged to syslog
@@ -1402,7 +1406,7 @@ clicon_rpc_validate(clicon_handle h,
/*! Commit changes send a commit request to backend daemon
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] confirmed If set, send commit/confirmed
* @param[in] cancel If set, send cancel-commit
* @param[in] timeout For confirmed, a timeout in seconds (default 600s)
@@ -1515,7 +1519,7 @@ clicon_rpc_commit(clicon_handle h,
/*! Discard all changes in candidate / revert to running
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @retval 0 OK
* @retval -1 Error and logged to syslog
*/
@@ -1632,7 +1636,7 @@ clicon_rpc_create_subscription(clicon_handle h,
/*! Send a debug request to backend server
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] level Debug level
* @retval 0 OK
* @retval -1 Error and logged to syslog
@@ -1690,7 +1694,8 @@ clicon_rpc_debug(clicon_handle h,
}
/*! Send a debug request to backend server to set restconf debug
- * @param[in] h CLICON handle
+ *
+ * @param[in] h Clixon handle
* @param[in] level Debug level
* @retval 0 OK
* @retval -1 Error and logged to syslog
@@ -1846,7 +1851,7 @@ clicon_hello_req(clicon_handle h,
/*! Send a restart plugin request to backend server
*
- * @param[in] h CLICON handle
+ * @param[in] h Clixon handle
* @param[in] level Debug level
* @retval 0 OK
* @retval -1 Error and logged to syslog
diff --git a/lib/src/clixon_stream.c b/lib/src/clixon_stream.c
index cdd436e68..62668da79 100644
--- a/lib/src/clixon_stream.c
+++ b/lib/src/clixon_stream.c
@@ -91,6 +91,7 @@
#define STREAM_TIMER_TIMEOUT_S 5
/*! Find an event notification stream given name
+ *
* @param[in] h Clicon handle
* @param[in] name Name of stream
* @retval es Event notification stream structure
@@ -114,6 +115,7 @@ stream_find(clicon_handle h,
}
/*! Add notification event stream
+ *
* @param[in] h Clicon handle
* @param[in] name Name of stream
* @param[in] description Description of stream
@@ -156,6 +158,7 @@ stream_add(clicon_handle h,
}
/*! Delete complete notification event stream list (not just single stream)
+ *
* @param[in] h Clicon handle
* @param[in] force Force deletion of
*/
@@ -189,11 +192,12 @@ stream_delete_all(clicon_handle h,
}
/*! Return stream definition state in XML supporting RFC 8040 and RFC5277
+ *
* @param[in] h Clicon handle
* @param[in] access If set, include access/location
* @param[out] cb Output buffer containing XML on exit
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
stream_get_xml(clicon_handle h,
@@ -231,6 +235,7 @@ stream_get_xml(clicon_handle h,
}
/*! Check all stream subscription stop timers, set up new timer
+ *
* @param[in] fd No-op
* @param[in] arg Clicon handle
* @note format is given by clixon_event_reg_timeout callback function (fd not needed)
@@ -320,6 +325,7 @@ stream_del()
#endif
/*! Add an event notification callback to a stream given a callback function
+ *
* @param[in] h Clicon handle
* @param[in] stream Name of stream
* @param[in] xpath Filter selector - xpath
@@ -328,7 +334,7 @@ stream_del()
* @param[in] fn Callback when event occurs
* @param[in] arg Argument to use with callback. Also handle when deleting
* @retval 0 OK
- * @retval -1 Error, ie no such stream
+ * @retval -1 Error, ie no such stream
*/
struct stream_subscription *
stream_ss_add(clicon_handle h,
@@ -375,12 +381,13 @@ stream_ss_add(clicon_handle h,
}
/*! Delete event stream subscription to a stream given a callback and arg
+ *
* @param[in] h Clicon handle
* @param[in] stream Name of stream or NULL for all streams
* @param[in] fn Callback when event occurs
* @param[in] arg Argument to use with callback. Also handle when deleting
* @retval 0 OK
- * @retval -1 Error
+ * @retval -1 Error
*/
int
stream_ss_rm(clicon_handle h,
@@ -404,6 +411,7 @@ stream_ss_rm(clicon_handle h,
}
/*! Find stream callback given callback function and its (unique) argument
+ *
* @param[in] es Pointer to event stream
* @param[in] fn Stream callback
* @param[in] arg Argument - typically unique client handle
@@ -427,6 +435,7 @@ stream_ss_find(event_stream_t *es,
}
/*! Remove stream subscription identified with fn and arg in all streams
+ *
* @param[in] h Clicon handle
* @param[in] fn Stream callback
* @param[in] arg Argument - typically unique client handle
@@ -456,6 +465,7 @@ stream_ss_delete_all(clicon_handle h,
}
/*! Delete a single stream
+ *
* @see stream_ss_delete_all (merge with this?)
*/
int
@@ -484,12 +494,13 @@ stream_ss_delete(clicon_handle h,
}
/*! Stream notify event and distribute to all registered callbacks
+ *
* @param[in] h Clicon handle
* @param[in] stream Name of event stream. CLICON is predefined as LOG stream
* @param[in] tv Timestamp. Dont notify if subscription has stoptimefaultEthernet0major") < 0)
* err;
@@ -611,11 +623,12 @@ stream_notify(clicon_handle h,
}
/*! Backward compatible function
+ *
* @param[in] h Clicon handle
* @param[in] stream Name of event stream. CLICON is predefined as LOG stream
* @param[in] xml Notification as XML stream. Is copied.
- * @retval 0 OK
- * @retval -1 Error with clicon_err called
+ * @retval 0 OK
+ * @retval -1 Error with clicon_err called
* @see stream_notify Should be merged with this
*/
int
@@ -681,6 +694,7 @@ stream_notify_xml(clicon_handle h,
/*! Replay a stream by sending notification messages
+ *
* @see RFC5277 Sec 2.1.1:
* Start Time:
A parameter, , used to trigger the replay feature
@@ -745,6 +759,7 @@ stream_replay_notify(clicon_handle h,
}
/*! Add replay sample to stream with timestamp
+ *
* @param[in] es Stream
* @param[in] tv Timestamp
* @param[in] xv XML
@@ -781,6 +796,7 @@ struct replay_arg{
};
/*! Timeout callback for replaying stream
+ *
* @param[in] fd Ignore
* @param[in] arg tmp struct including clicon handle, stream and subscription
*/
@@ -816,10 +832,10 @@ stream_replay_cb(int fd,
/*! Schedule stream replay to occur asap, eg "now"
*
- * @param[in] h clicon handle
- * @param[in] stream Name of stream
- * @param[in] fn Stream callback
- * @param[in] arg Argument - typically unique client handle
+ * @param[in] h clicon handle
+ * @param[in] stream Name of stream
+ * @param[in] fn Stream callback
+ * @param[in] arg Argument - typically unique client handle
*/
int
stream_replay_trigger(clicon_handle h,
@@ -892,9 +908,10 @@ curl_get_cb(void *ptr,
}
/*! Send a curl POST request
- * @retval -1 fatal error
- * @retval 0 expect set but did not expected return or other non-fatal error
+ *
* @retval 1 ok
+ * @retval 0 expect set but did not expected return or other non-fatal error
+ * @retval -1 fatal error
* Note: curl_easy_perform blocks
* Note: New handle is created every time, the handle can be re-used for better TCP performance
* @see same function (url_post) in grideye_curl.c
@@ -953,6 +970,7 @@ url_post(char *url,
}
/*! Stream callback for example stream notification
+ *
* Push via curl_post to publish stream event
* @param[in] h Clicon handle
* @param[in] op Operation: 0 OK, 1 Close
diff --git a/test/test_client.sh b/test/test_client.sh
index 6c6983732..223042748 100755
--- a/test/test_client.sh
+++ b/test/test_client.sh
@@ -99,7 +99,7 @@ main(int argc,
if ((ch = clixon_client_connect(h, CLIXON_CLIENT_NETCONF, NULL)) == NULL)
return -1;
s = clixon_client_socket_get(ch);
- if (clixon_client_hello(s, 0) < 0)
+ if (clixon_client_hello(s, NULL, 0) < 0)
return -1;
/* Here are read functions depending on an example YANG
* (Need an example YANG and XML input to confd)
diff --git a/util/clixon_util_socket.c b/util/clixon_util_socket.c
index 4a78efa5e..30c7b0cf3 100644
--- a/util/clixon_util_socket.c
+++ b/util/clixon_util_socket.c
@@ -178,7 +178,7 @@ main(int argc,
else
if (clicon_rpc_connect_inet(h, sockpath, 4535, &s) < 0)
goto done;
- if (clicon_rpc(s, msg, &retdata, &eof) < 0)
+ if (clicon_rpc(s, NULL, msg, &retdata, &eof) < 0)
goto done;
close(s);
fprintf(stdout, "%s\n", retdata);
diff --git a/yang/clixon/clixon-autocli@2023-09-01.yang b/yang/clixon/clixon-autocli@2023-09-01.yang
index 229c12598..dba68e3ac 100644
--- a/yang/clixon/clixon-autocli@2023-09-01.yang
+++ b/yang/clixon/clixon-autocli@2023-09-01.yang
@@ -152,7 +152,7 @@ module clixon-autocli{
}
typedef yang-keywords {
type bits {
- bit list;
+ bit list;
bit listall{ /* NYI */
description
"Variant of list encompassing all list entries, not just an instance";
diff --git a/yang/clixon/clixon-config@2023-05-01.yang b/yang/clixon/clixon-config@2023-05-01.yang
index 748293cb7..873ec1f9f 100644
--- a/yang/clixon/clixon-config@2023-05-01.yang
+++ b/yang/clixon/clixon-config@2023-05-01.yang
@@ -8,7 +8,7 @@ module clixon-config {
}
import clixon-autocli {
prefix autocli;
- }
+ }
import clixon-lib {
prefix cl;
}
@@ -236,7 +236,7 @@ module clixon-config {
Renamed CLICON_XMLDB_CACHE to CLICON_DATASTORE_CACHE (changed type)
Deleted: CLICON_XMLDB_PLUGIN, CLICON_USE_STARTUP_CONFIG";
}
- revision 2019-03-05{
+ revision 2019-03-05{
description
"Changed URN. Changed top-level symbol to clixon-config.
Released in Clixon 3.10";
@@ -680,7 +680,7 @@ module clixon-config {
Both feature clixon-restconf:http-data and restconf/enable-http-data
must be enabled for this match to occur.";
}
- leaf CLICON_HTTP_DATA_ROOT{
+ leaf CLICON_HTTP_DATA_ROOT{
if-feature "clrc:http-data";
type string;
default "/var/www";
diff --git a/yang/clixon/clixon-lib@2023-05-01.yang b/yang/clixon/clixon-lib@2023-05-01.yang
index 34ef792b1..04c689f53 100644
--- a/yang/clixon/clixon-lib@2023-05-01.yang
+++ b/yang/clixon/clixon-lib@2023-05-01.yang
@@ -5,10 +5,10 @@ module clixon-lib {
import ietf-yang-types {
prefix yang;
- }
+ }
import ietf-netconf-monitoring {
prefix ncm;
- }
+ }
import ietf-yang-metadata {
prefix "md";
}