Low-level message functions added descr argument for better logging C-API change

This commit is contained in:
Olof hagsand 2023-09-11 18:48:20 +02:00
parent 17b64f0bab
commit 9091582087
16 changed files with 397 additions and 236 deletions

View file

@ -53,6 +53,20 @@ Users may have to change how they access the system
### C/CLI-API changes on existing features ### C/CLI-API changes on existing features
Developers may need to change their code 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()` * CLI pipe function: added arg to `pipe_tail_fn()`
### Minor features ### Minor features

View file

@ -91,7 +91,7 @@ ce_find_byid(struct client_entry *ce_list,
/*! Stream callback for netconf stream notification (RFC 5277) /*! 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] op 0:event, 1:rm
* @param[in] event Event as XML * @param[in] event Event as XML
* @param[in] arg Extra argument provided in stream_ss_add * @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); backend_client_rm(h, ce);
break; break;
default: 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){ if (errno == ECONNRESET || errno == EPIPE){
clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr); clicon_log(LOG_WARNING, "client %d reset", ce->ce_nr);
} }
@ -126,6 +126,44 @@ ce_event_cb(clicon_handle h,
return 0; 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 /*! 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 * @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: * Backend-specific netconf monitoring state is:
* sessions * sessions
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] yspec Yang spec * @param[in] yspec Yang spec
* @param[in] xpath XML Xpath * @param[in] xpath XML Xpath
* @param[in] nsc XML Namespace context for 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) * Close down everything wrt clients (eg sockets, subscriptions)
* Finally actually remove client struct in handle * Finally actually remove client struct in handle
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] ce Client handle * @param[in] ce Client handle
* @retval 0 Ok * @retval 0 Ok
* @retval -1 Error (fatal) * @retval -1 Error (fatal)
@ -313,7 +351,7 @@ backend_client_rm(clicon_handle h,
/*! Get clixon per datastore stats /*! Get clixon per datastore stats
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] dbname Datastore name * @param[in] dbname Datastore name
* @param[in,out] cb Cligen buf * @param[in,out] cb Cligen buf
* @retval 0 OK * @retval 0 OK
@ -356,7 +394,7 @@ clixon_stats_datastore_get(clicon_handle h,
/*! Get clixon per datastore stats /*! Get clixon per datastore stats
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] dbname Datastore name * @param[in] dbname Datastore name
* @param[in,out] cb Cligen buf * @param[in,out] cb Cligen buf
* @retval 0 OK * @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 /*! 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: <rpc><xn></rpc> * @param[in] xn Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -614,7 +652,7 @@ from_client_edit_config(clicon_handle h,
/*! Create or replace an entire config with another complete config db /*! Create or replace an entire config with another complete config db
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -688,7 +726,7 @@ from_client_copy_config(clicon_handle h,
/*! Delete a configuration datastore. /*! Delete a configuration datastore.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -764,7 +802,7 @@ from_client_delete_config(clicon_handle h,
/*! Lock the configuration system of a device /*! Lock the configuration system of a device
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -851,7 +889,7 @@ from_client_lock(clicon_handle h,
/*! Release a configuration lock previously obtained with the 'lock' operation /*! Release a configuration lock previously obtained with the 'lock' operation
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -921,7 +959,7 @@ from_client_unlock(clicon_handle h,
/*! Request graceful termination of a NETCONF session. /*! Request graceful termination of a NETCONF session.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -948,7 +986,7 @@ from_client_close_session(clicon_handle h,
/*! Internal message: Force the termination of a NETCONF session. /*! Internal message: Force the termination of a NETCONF session.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1005,7 +1043,7 @@ from_client_kill_session(clicon_handle h,
/*! Create a notification subscription /*! Create a notification subscription
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1105,7 +1143,7 @@ from_client_create_subscription(clicon_handle h,
/*! Retrieve a schema from the NETCONF server. /*! Retrieve a schema from the NETCONF server.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1228,7 +1266,7 @@ from_client_get_schema(clicon_handle h,
/*! Set debug level. /*! Set debug level.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1266,7 +1304,7 @@ from_client_debug(clicon_handle h,
/*! Check liveness of backend daemon, just send a reply /*! Check liveness of backend daemon, just send a reply
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1287,7 +1325,7 @@ from_client_ping(clicon_handle h,
/*! Check liveness of backend daemon, just send a reply /*! Check liveness of backend daemon, just send a reply
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1380,7 +1418,7 @@ from_client_stats(clicon_handle h,
/*! Request restart of specific plugins /*! Request restart of specific plugins
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1428,7 +1466,7 @@ from_client_restart_plugin(clicon_handle h,
/*! Control a specific process or daemon: start/stop, etc /*! Control a specific process or daemon: start/stop, etc
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] xe Request: <rpc><xn></rpc> * @param[in] xe Request: <rpc><xn></rpc>
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error.. * @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg client-entry * @param[in] arg client-entry
@ -1510,7 +1548,7 @@ from_client_hello(clicon_handle h,
/*! An internal clixon NETCONF message has arrived from a local client. Receive and dispatch. /*! An internal clixon NETCONF message has arrived from a local client. Receive and dispatch.
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] ce Client entry (from) * @param[in] ce Client entry (from)
* @param[in] msg Incoming message * @param[in] msg Incoming message
* @retval 0 OK * @retval 0 OK
@ -1542,6 +1580,7 @@ from_client_msg(clicon_handle h,
char *rpcprefix; char *rpcprefix;
char *namespace = NULL; char *namespace = NULL;
int nr = 0; int nr = 0;
cbuf *cbce = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__); clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
yspec = clicon_dbspec_yang(h); yspec = clicon_dbspec_yang(h);
@ -1737,7 +1776,9 @@ from_client_msg(clicon_handle h,
// XXX clicon_debug(CLIXON_DBG_MSG, "Reply:%s", cbuf_get(cbret)); // XXX clicon_debug(CLIXON_DBG_MSG, "Reply:%s", cbuf_get(cbret));
/* XXX problem here is that cbret has not been parsed so may contain /* XXX problem here is that cbret has not been parsed so may contain
parse errors */ parse errors */
if (send_msg_reply(ce->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){ switch (errno){
case EPIPE: case EPIPE:
/* man (2) write: /* man (2) write:
@ -1767,6 +1808,8 @@ from_client_msg(clicon_handle h,
xml_free(xret); xml_free(xret);
if (xt) if (xt)
xml_free(xt); xml_free(xt);
if (cbce)
cbuf_free(cbce);
if (cbret) if (cbret)
cbuf_free(cbret); cbuf_free(cbret);
/* Sanity: log if clicon_err() is not called ! */ /* Sanity: log if clicon_err() is not called ! */
@ -1794,13 +1837,16 @@ from_client(int s,
struct client_entry *ce = (struct client_entry *)arg; struct client_entry *ce = (struct client_entry *)arg;
clicon_handle h = ce->ce_handle; clicon_handle h = ce->ce_handle;
int eof = 0; int eof = 0;
cbuf *cbce = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__); clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (s != ce->ce_s){ if (s != ce->ce_s){
clicon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s"); clicon_err(OE_NETCONF, EINVAL, "Internal error: s != ce->ce_s");
goto done; 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; goto done;
if (eof){ if (eof){
backend_client_rm(h, ce); backend_client_rm(h, ce);
@ -1812,6 +1858,8 @@ from_client(int s,
retval = 0; retval = 0;
done: done:
clicon_debug(CLIXON_DBG_DETAIL, "%s retval=%d", __FUNCTION__, retval); clicon_debug(CLIXON_DBG_DETAIL, "%s retval=%d", __FUNCTION__, retval);
if (cbce)
cbuf_free(cbce);
if (msg) if (msg)
free(msg); free(msg);
return retval; /* -1 here terminates backend */ return retval; /* -1 here terminates backend */
@ -1819,7 +1867,7 @@ from_client(int s,
/*! Init backend rpc: Set up standard netconf rpc callbacks /*! Init backend rpc: Set up standard netconf rpc callbacks
* *
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @retval 0 OK * @retval 0 OK
* @retval -1 Error (fatal) * @retval -1 Error (fatal)
* @see ietf-netconf@2011-06-01.yang * @see ietf-netconf@2011-06-01.yang

View file

@ -72,9 +72,10 @@
#include "backend_startup.h" #include "backend_startup.h"
/*! Merge db1 into db2 without commit /*! Merge db1 into db2 without commit
* @retval -1 Error *
* @retval 0 Validation failed (with cbret set)
* @retval 1 Validation OK * @retval 1 Validation OK
* @retval 0 Validation failed (with cbret set)
* @retval -1 Error
*/ */
static int static int
db_merge(clicon_handle h, db_merge(clicon_handle h,
@ -97,12 +98,13 @@ db_merge(clicon_handle h,
} }
/*! Clixon startup startup mode: Commit startup configuration into running state /*! Clixon startup startup mode: Commit startup configuration into running state
*
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] db tmp or startup * @param[in] db tmp or startup
* @param[out] cbret If status is invalid contains error message * @param[out] cbret If status is invalid contains error message
* @retval -1 Error
* @retval 0 Validation failed
* @retval 1 OK * @retval 1 OK
* @retval 0 Validation failed
* @retval -1 Error
OK: OK:
reset reset
@ -203,9 +205,10 @@ startup_mode_startup(clicon_handle h,
} }
/*! Merge xml in filename into database /*! Merge xml in filename into database
* @retval -1 Error *
* @retval 0 Validation failed (with cbret set)
* @retval 1 Validation OK * @retval 1 Validation OK
* @retval 0 Validation failed (with cbret set)
* @retval -1 Error
*/ */
static int static int
load_extraxml(clicon_handle h, 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 /*! Load extra XML via file and/or reset callback, and merge with current
*
* An application can add extra XML either via the -c <file> option or * An application can add extra XML either via the -c <file> option or
* via the .ca_reset callback. This XML is "merged" into running, that is, * via the .ca_reset callback. This XML is "merged" into running, that is,
* it does not trigger validation calbacks. * it does not trigger validation calbacks.
* The function uses an extra "tmp" database, loads the file to it, and calls * The function uses an extra "tmp" database, loads the file to it, and calls
* the reset function on it. * the reset function on it.
* @param[in] h Clicon handle * @param[in] h Clixon handle
* @param[in] file (Optional) extra xml file * @param[in] file (Optional) extra xml file
* @param[out] status Startup status * @param[out] status Startup status
* @param[out] cbret If status is invalid contains error message * @param[out] cbret If status is invalid contains error message
* @retval -1 Error
* @retval 0 Validation failed
* @retval 1 OK * @retval 1 OK
* @retval 0 Validation failed
* @retval -1 Error
running -----------------+----+------> running -----------------+----+------>
reset loadfile / merge reset loadfile / merge
@ -341,10 +347,11 @@ startup_extraxml(clicon_handle h,
} }
/*! Init modules state of the backend (server). To compare with startup XML /*! Init modules state of the backend (server). To compare with startup XML
*
* Set the modules state as setopt to the datastore module. * Set the modules state as setopt to the datastore module.
* Only if CLICON_XMLDB_MODSTATE is enabled * Only if CLICON_XMLDB_MODSTATE is enabled
* @retval -1 Error
* @retval 0 OK * @retval 0 OK
* @retval -1 Error
*/ */
int int
startup_module_state(clicon_handle h, startup_module_state(clicon_handle h,

View file

@ -1283,7 +1283,7 @@ cli_notification_cb(int s,
int ret; int ret;
/* get msg (this is the reason this function is called) */ /* 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; goto done;
if (eof){ if (eof){
clicon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close"); clicon_err(OE_PROTO, ESHUTDOWN, "Socket unexpected close");

View file

@ -453,7 +453,7 @@ netconf_notification_cb(int s,
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
/* get msg (this is the reason this function is called) */ /* 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; goto done;
/* handle close from remote end: this will exit the client */ /* handle close from remote end: this will exit the client */
if (eof){ if (eof){

View file

@ -73,8 +73,8 @@ extern "C" {
clixon_handle clixon_client_init(const char *config_file); clixon_handle clixon_client_init(const char *config_file);
int clixon_client_terminate(clixon_handle h); int clixon_client_terminate(clixon_handle h);
int clixon_client_lock(int sock, const int lock, const char *db); int clixon_client_lock(int sock, const char *descr, const int lock, const char *db);
int clixon_client_hello(int sock, int version); 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); 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_disconnect(clixon_client_handle ch);
int clixon_client_get_bool(clixon_client_handle ch, int *rval, const char *xnamespace, const char *xpath); int clixon_client_get_bool(clixon_client_handle ch, int *rval, const char *xnamespace, const char *xpath);

View file

@ -72,21 +72,21 @@ int clicon_rpc_connect_inet(clicon_handle h,
uint16_t port, uint16_t port,
int *sock0); 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); int detect_endtag(char *tag, char ch, int *state);

View file

@ -86,11 +86,13 @@ struct clixon_client_handle{
uint32_t cch_magic; /* magic number */ uint32_t cch_magic; /* magic number */
clixon_client_type cch_type; /* Clixon socket type */ clixon_client_type cch_type; /* Clixon socket type */
int cch_socket; /* Input/output socket */ 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_pid; /* Sub-process-id Only applies for NETCONF/SSH */
int cch_locked; /* State variable: 1 means locked */ int cch_locked; /* State variable: 1 means locked */
}; };
/*! Check struct magic number for sanity checks /*! Check struct magic number for sanity checks
*
* @param[in] h Clicon client handle * @param[in] h Clicon client handle
* @retval 0 Sanity check OK * @retval 0 Sanity check OK
* @retval -1 Sanity check failed * @retval -1 Sanity check failed
@ -105,6 +107,7 @@ clixon_client_handle_check(clixon_client_handle ch)
} }
/*! Initialize Clixon client API /*! Initialize Clixon client API
*
* @param[in] config_file Clixon configuration file, or NULL for default * @param[in] config_file Clixon configuration file, or NULL for default
* @retval h Clixon handler * @retval h Clixon handler
* @retval NULL Error * @retval NULL Error
@ -129,6 +132,7 @@ clixon_client_init(const char *config_file)
} }
/*! Deallocate everything from client_init /*! Deallocate everything from client_init
*
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @see clixon_client_init * @see clixon_client_init
*/ */
@ -141,7 +145,9 @@ clixon_client_terminate(clicon_handle h)
} }
/*! Send a lock request (internal) /*! Send a lock request (internal)
*
* @param[in] sock Open socket * @param[in] sock Open socket
* @param[in] descr Description of peer for logging
* @param[in] lock 0: unlock, 1: lock * @param[in] lock 0: unlock, 1: lock
* @param[in] db Datastore name * @param[in] db Datastore name
* @retval 0 OK * @retval 0 OK
@ -149,6 +155,7 @@ clixon_client_terminate(clicon_handle h)
*/ */
int int
clixon_client_lock(int sock, clixon_client_lock(int sock,
const char *descr,
const int lock, const int lock,
const char *db) const char *db)
{ {
@ -177,7 +184,7 @@ clixon_client_lock(int sock,
NETCONF_BASE_NAMESPACE, NETCONF_BASE_NAMESPACE,
NETCONF_MESSAGE_ID_ATTR, NETCONF_MESSAGE_ID_ATTR,
lock?"":"un", db, lock?"":"un"); lock?"":"un", db, lock?"":"un");
if (clicon_rpc1(sock, msg, msgret, &eof) < 0) if (clicon_rpc1(sock, descr, msg, msgret, &eof) < 0)
goto done; goto done;
if (eof){ if (eof){
close(sock); close(sock);
@ -206,12 +213,14 @@ clixon_client_lock(int sock,
/*! Internal function to construct the encoding and hello message /*! Internal function to construct the encoding and hello message
* *
* @param[in] sock Socket to netconf server * @param[in] sock Socket to netconf server
* @param[in] descr Description of peer for logging
* @param[in] version Netconf version for capability announcement * @param[in] version Netconf version for capability announcement
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
*/ */
int int
clixon_client_hello(int sock, clixon_client_hello(int sock,
const char *descr,
int version) int version)
{ {
int retval = -1; int retval = -1;
@ -229,7 +238,7 @@ clixon_client_hello(int sock,
cprintf(msg, "</capabilities>"); cprintf(msg, "</capabilities>");
cprintf(msg, "</hello>"); cprintf(msg, "</hello>");
cprintf(msg, "]]>]]>"); cprintf(msg, "]]>]]>");
if (clicon_msg_send1(sock, msg) < 0) if (clicon_msg_send1(sock, descr, msg) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: done:
@ -331,6 +340,7 @@ clixon_client_connect_ssh(clicon_handle h,
} }
/*! Connect client to clixon backend according to config and return a socket /*! Connect client to clixon backend according to config and return a socket
*
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] socktype Type of socket, internal/external/netconf/ssh * @param[in] socktype Type of socket, internal/external/netconf/ssh
* @param[in] dest Destination for some types * @param[in] dest Destination for some types
@ -384,7 +394,10 @@ clixon_client_connect(clicon_handle h,
} }
/*! Connect client to clixon backend according to config and return a socket /*! 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 * @see clixon_client_connect where the handle is created
* The handle is deallocated * The handle is deallocated
*/ */
@ -421,6 +434,7 @@ clixon_client_disconnect(clixon_client_handle ch)
} }
/*! Get the bottom-most leaf in an xml tree being a result of xpath /*! Get the bottom-most leaf in an xml tree being a result of xpath
*
* @param[in] xtop Pointer to XML top-of-tree * @param[in] xtop Pointer to XML top-of-tree
* @param[out] xbotp Pointer to XML bottom node * @param[out] xbotp Pointer to XML bottom node
* @retval 0 OK * @retval 0 OK
@ -456,6 +470,7 @@ clixon_xml_bottom(cxobj *xtop,
/*! Internal function to construct a get-config and query a value from the backend /*! Internal function to construct a get-config and query a value from the backend
* *
* @param[in] sock Socket * @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] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
* @param[in] xpath XPath * @param[in] xpath XPath
* @param[out] xdata XML data tree (may or may not include the intended data) * @param[out] xdata XML data tree (may or may not include the intended data)
@ -465,6 +480,7 @@ clixon_xml_bottom(cxobj *xtop,
*/ */
static int static int
clixon_client_get_xdata(int sock, clixon_client_get_xdata(int sock,
const char *descr,
const char *namespace, const char *namespace,
const char *xpath, const char *xpath,
cxobj **xdata) cxobj **xdata)
@ -506,9 +522,9 @@ clixon_client_get_xdata(int sock,
cprintf(msg, "</get-config></rpc>"); cprintf(msg, "</get-config></rpc>");
if (netconf_output_encap(0, msg) < 0) // XXX configurable session if (netconf_output_encap(0, msg) < 0) // XXX configurable session
goto done; goto done;
if (clicon_msg_send1(sock, msg) < 0) if (clicon_msg_send1(sock, descr, msg) < 0)
goto done; goto done;
if (clicon_msg_rcv1(sock, msgret, &eof) < 0) if (clicon_msg_rcv1(sock, descr, msgret, &eof) < 0)
goto done; goto done;
if (eof){ if (eof){
close(sock); close(sock);
@ -544,7 +560,9 @@ clixon_client_get_xdata(int sock,
} }
/*! Generic get value of body /*! Generic get value of body
*
* @param[in] sock Open socket * @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] namespace Default namespace used for non-prefixed entries in xpath.
* @param[in] xpath XPath * @param[in] xpath XPath
* @param[out] val Output value * @param[out] val Output value
@ -553,6 +571,7 @@ clixon_client_get_xdata(int sock,
*/ */
static int static int
clixon_client_get_body_val(int sock, clixon_client_get_body_val(int sock,
const char *descr,
const char *namespace, const char *namespace,
const char *xpath, const char *xpath,
char **val) char **val)
@ -566,7 +585,7 @@ clixon_client_get_body_val(int sock,
clicon_err(OE_XML, EINVAL, "Expected val"); clicon_err(OE_XML, EINVAL, "Expected val");
goto done; 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; goto done;
if (xdata == NULL){ if (xdata == NULL){
clicon_err(OE_XML, EINVAL, "No xml obj found"); clicon_err(OE_XML, EINVAL, "No xml obj found");
@ -591,6 +610,7 @@ clixon_client_get_body_val(int sock,
} }
/*! Client-api get boolean /*! Client-api get boolean
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc) * @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
@ -612,7 +632,7 @@ clixon_client_get_bool(clixon_client_handle ch,
uint8_t val0=0; uint8_t val0=0;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
if ((ret = parse_bool(val, &val0, &reason)) < 0){ if ((ret = parse_bool(val, &val0, &reason)) < 0){
@ -632,6 +652,7 @@ clixon_client_get_bool(clixon_client_handle ch,
} }
/*! Client-api get string /*! Client-api get string
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value string * @param[out] rval Return value string
* @param[in] n Length of string * @param[in] n Length of string
@ -652,7 +673,7 @@ clixon_client_get_str(clixon_client_handle ch,
char *val = NULL; char *val = NULL;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
strncpy(rval, val, n-1); strncpy(rval, val, n-1);
@ -663,6 +684,7 @@ clixon_client_get_str(clixon_client_handle ch,
} }
/*! Client-api get uint8 /*! Client-api get uint8
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc) * @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
@ -683,7 +705,7 @@ clixon_client_get_uint8(clixon_client_handle ch,
int ret; int ret;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
if ((ret = parse_uint8(val, rval, &reason)) < 0){ if ((ret = parse_uint8(val, rval, &reason)) < 0){
@ -702,6 +724,7 @@ clixon_client_get_uint8(clixon_client_handle ch,
} }
/*! Client-api get uint16 /*! Client-api get uint16
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc) * @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
@ -722,7 +745,7 @@ clixon_client_get_uint16(clixon_client_handle ch,
int ret; int ret;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
if ((ret = parse_uint16(val, rval, &reason)) < 0){ if ((ret = parse_uint16(val, rval, &reason)) < 0){
@ -741,6 +764,7 @@ clixon_client_get_uint16(clixon_client_handle ch,
} }
/*! Client-api get uint32 /*! Client-api get uint32
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc) * @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
@ -761,7 +785,7 @@ clixon_client_get_uint32(clixon_client_handle ch,
int ret; int ret;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
if (val == NULL){ if (val == NULL){
@ -785,6 +809,7 @@ clixon_client_get_uint32(clixon_client_handle ch,
} }
/*! Client-api get uint64 /*! Client-api get uint64
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @param[out] rval Return value * @param[out] rval Return value
* @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc) * @param[in] namespace Default namespace used for non-prefixed entries in xpath. (Alt use nsc)
@ -805,7 +830,7 @@ clixon_client_get_uint64(clixon_client_handle ch,
int ret; int ret;
clicon_debug(1, "%s", __FUNCTION__); 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) namespace, xpath, &val) < 0)
goto done; goto done;
if ((ret = parse_uint64(val, rval, &reason)) < 0){ if ((ret = parse_uint64(val, rval, &reason)) < 0){
@ -825,6 +850,7 @@ clixon_client_get_uint64(clixon_client_handle ch,
/* Access functions */ /* Access functions */
/*! Client-api get uint64 /*! Client-api get uint64
*
* @param[in] ch Clixon client handle * @param[in] ch Clixon client handle
* @retval s Open socket * @retval s Open socket
* @retval -1 No/closed socket * @retval -1 No/closed socket

View file

@ -100,6 +100,7 @@ static struct formatvec _FORMATS[] = {
}; };
/*! Translate from numeric format to string representation /*! Translate from numeric format to string representation
*
* @param[in] showas Format value (see enum format_enum) * @param[in] showas Format value (see enum format_enum)
* @retval str String value * @retval str String value
*/ */
@ -115,6 +116,7 @@ format_int2str(enum format_enum showas)
} }
/*! Translate from string to numeric format representation /*! Translate from string to numeric format representation
*
* @param[in] str String value * @param[in] str String value
* @retval enum Format value (see enum format_enum) * @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 /*! Encode a clicon netconf message using variable argument lists
*
* @param[in] id Session id of client * @param[in] id Session id of client
* @param[in] format Variable agrument list format an XML netconf string * @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 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. * @note if format includes %, they will be expanded according to printf rules.
* if this is a problem, use ("%s", xml) instaead of (xml) * if this is a problem, use ("%s", xml) instaead of (xml)
* Notaly this may an issue of RFC 3896 encoded strings * 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 /*! Decode a clicon netconf message
* @param[in] msg CLICON msg *
* @param[in] msg Clixon msg
* @param[in] yspec Yang specification, (can be NULL) * @param[in] yspec Yang specification, (can be NULL)
* @param[out] id Session id * @param[out] id Session id
* @param[out] xml XML parse tree * @param[out] xml XML parse tree
@ -211,10 +215,11 @@ clicon_msg_decode(struct clicon_msg *msg,
} }
/*! Open local connection using unix domain sockets /*! Open local connection using unix domain sockets
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] sockpath Unix domain file path * @param[in] sockpath Unix domain file path
* @retval s socket * @retval s Socket
* @retval -1 error * @retval -1 Error
*/ */
int int
clicon_connect_unix(clicon_handle h, 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 /*! 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] fn I/O function, ie read/write
* @param[in] fd File descriptor, eg socket * @param[in] fd File descriptor, eg socket
* @param[in] s0 Buffer to read to or write from * @param[in] s0 Buffer to read to or write from
@ -339,21 +345,29 @@ msg_hex(int dbglevel,
return retval; 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[in] s Socket (unix or inet) to communicate with backend
* @param[out] msg CLICON msg data reply structure. Free with free() * @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 * @see clicon_msg_send1 using plain NETCONF
*/ */
int int
clicon_msg_send(int s, clicon_msg_send(int s,
const char *descr,
struct clicon_msg *msg) struct clicon_msg *msg)
{ {
int retval = -1; int retval = -1;
int e; int e;
clicon_debug(CLIXON_DBG_DETAIL, "%s: send msg len=%d", __FUNCTION__, ntohl(msg->op_len)); clicon_debug(CLIXON_DBG_DETAIL, "%s: send msg len=%d", __FUNCTION__, ntohl(msg->op_len));
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); clicon_debug(CLIXON_DBG_MSG, "Send: %s", msg->op_body);
}
msg_hex(CLIXON_DBG_EXTRA, (char*)msg, ntohl(msg->op_len), __FUNCTION__); msg_hex(CLIXON_DBG_EXTRA, (char*)msg, ntohl(msg->op_len), __FUNCTION__);
if (atomicio((ssize_t (*)(int, void *, size_t))write, if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, msg, ntohl(msg->op_len)) < 0){ s, msg, ntohl(msg->op_len)) < 0){
@ -368,7 +382,7 @@ clicon_msg_send(int s,
return retval; return retval;
} }
/*! Receive a CLICON message using IPC message struct /*! Receive a Clixon message using IPC message struct
* *
* XXX: timeout? and signals? * XXX: timeout? and signals?
* There is rudimentary code for turning on signals and handling them * There is rudimentary code for turning on signals and handling them
@ -378,9 +392,10 @@ clicon_msg_send(int s,
* behaviour. * behaviour.
* Now, ^C will interrupt the whole process, and this may not be what you want. * 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] 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[in] intr If set, make a ^C cause an error
* @param[out] msg CLICON msg data reply structure. Free with free() * @param[out] msg Clixon msg data reply structure. Free with free()
* @param[out] eof Set if eof encountered * @param[out] eof Set if eof encountered
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
@ -389,6 +404,7 @@ clicon_msg_send(int s,
*/ */
int int
clicon_msg_rcv(int s, clicon_msg_rcv(int s,
const char *descr,
int intr, int intr,
struct clicon_msg **msg, struct clicon_msg **msg,
int *eof) int *eof)
@ -453,6 +469,9 @@ clicon_msg_rcv(int s,
*eof = 1; *eof = 1;
goto ok; goto ok;
} }
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); clicon_debug(CLIXON_DBG_MSG, "Recv: %s", (*msg)->op_body);
ok: ok:
retval = 0; retval = 0;
@ -468,14 +487,18 @@ clicon_msg_rcv(int s,
/*! Receive a message using plain NETCONF /*! Receive a message using plain NETCONF
* *
* @param[in] s socket (unix or inet) to communicate with backend * @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] cb cligen buf struct containing the incoming message
* @param[out] eof Set if eof encountered * @param[out] eof Set if eof encountered
* @retval 0 OK
* @retval -1 Error
* @see netconf_input_cb() * @see netconf_input_cb()
* @see clicon_msg_rcv using IPC message struct * @see clicon_msg_rcv using IPC message struct
* @note only NETCONF version 1.0 EOM framing * @note only NETCONF version 1.0 EOM framing
*/ */
int int
clicon_msg_rcv1(int s, clicon_msg_rcv1(int s,
const char *descr,
cbuf *cb, cbuf *cb,
int *eof) int *eof)
{ {
@ -523,6 +546,9 @@ clicon_msg_rcv1(int s,
break; /* No data to read */ break; /* No data to read */
} /* while */ } /* while */
ok: ok:
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)); clicon_debug(CLIXON_DBG_MSG, "Recv: %s", cbuf_get(cb));
retval = 0; retval = 0;
done: done:
@ -530,19 +556,26 @@ clicon_msg_rcv1(int s,
return retval; 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[in] s socket (unix or inet) to communicate with backend
* @param[out] msg CLICON msg data reply structure. Free with free() * @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 * @see clicon_msg_send using internal IPC header
*/ */
int int
clicon_msg_send1(int s, clicon_msg_send1(int s,
const char *descr,
cbuf *cb) cbuf *cb)
{ {
int retval = -1; int retval = -1;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__); clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
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)); clicon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
if (atomicio((ssize_t (*)(int, void *, size_t))write, if (atomicio((ssize_t (*)(int, void *, size_t))write,
s, cbuf_get(cb), cbuf_len(cb)) < 0){ s, cbuf_get(cb), cbuf_len(cb)) < 0){
@ -558,7 +591,7 @@ clicon_msg_send1(int s,
/*! Connect to server, send a clicon_msg message and wait for result using unix socket /*! Connect to server, send a clicon_msg message and wait for result using unix socket
* *
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] msg CLICON msg data structure. It has fixed header and variable body. * @param[in] msg Internal msg data structure. It has fixed header and variable body.
* @param[in] sockpath Unix domain file path * @param[in] sockpath Unix domain file path
* @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 * @param[out] sock0 Return socket in case of asynchronous notify
@ -653,7 +686,8 @@ clicon_rpc_connect_inet(clicon_handle h,
* due to remote peer disconnecting. The caller may have to do something,... * due to remote peer disconnecting. The caller may have to do something,...
* *
* @param[in] sock Socket / file descriptor * @param[in] sock Socket / file descriptor
* @param[in] msg CLICON msg data structure. It has fixed header and variable body. * @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] xret Returned data as netconf xml tree.
* @param[out] eof Set if eof encountered * @param[out] eof Set if eof encountered
* @retval 0 OK (check eof) * @retval 0 OK (check eof)
@ -662,6 +696,7 @@ clicon_rpc_connect_inet(clicon_handle h,
*/ */
int int
clicon_rpc(int sock, clicon_rpc(int sock,
const char *descr,
struct clicon_msg *msg, struct clicon_msg *msg,
char **ret, char **ret,
int *eof) int *eof)
@ -671,9 +706,9 @@ clicon_rpc(int sock,
char *data = NULL; char *data = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__); clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (clicon_msg_send(sock, msg) < 0) if (clicon_msg_send(sock, descr, msg) < 0)
goto done; goto done;
if (clicon_msg_rcv(sock, 0, &reply, eof) < 0) if (clicon_msg_rcv(sock, descr, 0, &reply, eof) < 0)
goto done; goto done;
if (*eof) if (*eof)
goto ok; goto ok;
@ -695,9 +730,9 @@ clicon_rpc(int sock,
/*! Send a netconf message and recieve result using plain NETCONF /*! Send a netconf message and recieve result using plain NETCONF
* *
* This is mainly used by the client API. * This is mainly used by the client API.
*
* @param[in] sock Socket / file descriptor * @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] msgret Returned data as netconf xml tree.
* @param[out] eof Set if eof encountered * @param[out] eof Set if eof encountered
* @retval 0 OK * @retval 0 OK
@ -706,6 +741,7 @@ clicon_rpc(int sock,
*/ */
int int
clicon_rpc1(int sock, clicon_rpc1(int sock,
const char *descr,
cbuf *msg, cbuf *msg,
cbuf *msgret, cbuf *msgret,
int *eof) int *eof)
@ -717,9 +753,9 @@ clicon_rpc1(int sock,
goto done; goto done;
if (netconf_framing_postamble(NETCONF_SSH_CHUNKED, msg) < 0) if (netconf_framing_postamble(NETCONF_SSH_CHUNKED, msg) < 0)
goto done; goto done;
if (clicon_msg_send1(sock, msg) < 0) if (clicon_msg_send1(sock, descr, msg) < 0)
goto done; goto done;
if (clicon_msg_rcv1(sock, msgret, eof) < 0) if (clicon_msg_rcv1(sock, descr, msgret, eof) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: done:
@ -730,6 +766,7 @@ clicon_rpc1(int sock,
/*! Send a clicon_msg message as reply to a clicon rpc request /*! Send a clicon_msg message as reply to a clicon rpc request
* *
* @param[in] s Socket to communicate with client * @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] data Returned data as byte-string.
* @param[in] datalen Length of returned data XXX may be unecessary if always string? * @param[in] datalen Length of returned data XXX may be unecessary if always string?
* @retval 0 OK * @retval 0 OK
@ -737,6 +774,7 @@ clicon_rpc1(int sock,
*/ */
int int
send_msg_reply(int s, send_msg_reply(int s,
const char *descr,
char *data, char *data,
uint32_t datalen) uint32_t datalen)
{ {
@ -751,7 +789,7 @@ send_msg_reply(int s,
reply->op_len = htonl(len); reply->op_len = htonl(len);
if (datalen > 0) if (datalen > 0)
memcpy(reply->op_body, data, datalen); memcpy(reply->op_body, data, datalen);
if (clicon_msg_send(s, reply) < 0) if (clicon_msg_send(s, descr, reply) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: done:
@ -763,6 +801,7 @@ send_msg_reply(int s,
/*! Send a clicon_msg NOTIFY message asynchronously to client /*! Send a clicon_msg NOTIFY message asynchronously to client
* *
* @param[in] s Socket to communicate with client * @param[in] s Socket to communicate with client
* @param[in] descr Description of peer for logging
* @param[in] level * @param[in] level
* @param[in] event * @param[in] event
* @retval 0 OK * @retval 0 OK
@ -771,6 +810,7 @@ send_msg_reply(int s,
*/ */
static int static int
send_msg_notify(int s, send_msg_notify(int s,
const char *descr,
char *event) char *event)
{ {
int retval = -1; int retval = -1;
@ -778,7 +818,7 @@ send_msg_notify(int s,
if ((msg=clicon_msg_encode(0, "%s", event)) == NULL) if ((msg=clicon_msg_encode(0, "%s", event)) == NULL)
goto done; goto done;
if (clicon_msg_send(s, msg) < 0) if (clicon_msg_send(s, descr, msg) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: done:
@ -791,6 +831,7 @@ send_msg_notify(int s,
* *
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] s Socket to communicate with client * @param[in] s Socket to communicate with client
* @param[in] descr Description of peer for logging
* @param[in] xev Event as XML * @param[in] xev Event as XML
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
@ -799,6 +840,7 @@ send_msg_notify(int s,
int int
send_msg_notify_xml(clicon_handle h, send_msg_notify_xml(clicon_handle h,
int s, int s,
const char *descr,
cxobj *xev) cxobj *xev)
{ {
int retval = -1; 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) if (clixon_xml2cbuf(cb, xev, 0, 0, NULL, -1, 0) < 0)
goto done; goto done;
if (send_msg_notify(s, cbuf_get(cb)) < 0) if (send_msg_notify(s, descr, cbuf_get(cb)) < 0)
goto done; goto done;
retval = 0; retval = 0;
done: 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 /*! Look for a text pattern in an input string, one char at a time
*
* @param[in] tag What to look for * @param[in] tag What to look for
* @param[in] ch New input character * @param[in] ch New input character
* @param[in,out] state A state integer holding how far we have parsed. * @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 1 Yes, we have detected end tag!
* @retval 0 No, we havent detected end tag
* @code * @code
* int state = 0; * int state = 0;
* char ch; * char ch;

View file

@ -168,7 +168,7 @@ clicon_rpc_msg_once(clicon_handle h,
} }
else if (clicon_rpc_connect(h, &s) < 0) else if (clicon_rpc_connect(h, &s) < 0)
goto done; 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 */ /* 2. check socket shutdown AFTER rpc */
close(s); close(s);
s = -1; s = -1;
@ -184,7 +184,7 @@ clicon_rpc_msg_once(clicon_handle h,
/*! Send internal netconf rpc from client to backend /*! 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[in] msg Encoded message. Deallocate with free
* @param[out] xret0 Return value from backend as xml tree. Free w xml_free * @param[out] xret0 Return value from backend as xml tree. Free w xml_free
* @retval 0 OK * @retval 0 OK
@ -263,7 +263,7 @@ clicon_rpc_msg(clicon_handle h,
/*! Send internal netconf rpc from client to backend and return a persistent socket /*! 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[in] msg Encoded message. Deallocate with free
* @param[out] xret0 Return value from backend as xml tree. Free w xml_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 * @param[out] sock0 If pointer exists, do not close socket to backend on success
@ -364,6 +364,7 @@ session_id_check(clicon_handle h,
} }
/*! Generic xml netconf clicon rpc for persistent /*! Generic xml netconf clicon rpc for persistent
*
* Want to go over to use netconf directly between client and server,... * Want to go over to use netconf directly between client and server,...
* @param[in] h clicon handle * @param[in] h clicon handle
* @param[in] xmlstr XML netconf tree as string * @param[in] xmlstr XML netconf tree as string
@ -484,7 +485,7 @@ clicon_rpc_netconf_xml(clicon_handle h,
/*! Get database configuration /*! Get database configuration
* *
* Same as clicon_proto_change just with a cvec instead of lvec * 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] username If NULL, use default
* @param[in] db Name of database * @param[in] db Name of database
* @param[in] xpath XPath (or "") * @param[in] xpath XPath (or "")
@ -619,7 +620,7 @@ clicon_rpc_get_config(clicon_handle h,
/*! Send database entries as XML to backend daemon /*! 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] db Name of database
* @param[in] op Operation on database item: OP_MERGE, OP_REPLACE * @param[in] op Operation on database item: OP_MERGE, OP_REPLACE
* @param[in] xml XML string. Ex: <config><a>..</a><b>...</b></config> * @param[in] xml XML string. Ex: <config><a>..</a><b>...</b></config>
@ -688,7 +689,7 @@ clicon_rpc_edit_config(clicon_handle h,
* *
* Note this assumes the backend can access these files and (usually) assumes * Note this assumes the backend can access these files and (usually) assumes
* clients and servers have the access to the same filesystem. * clients and servers have the access to the same filesystem.
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] db1 src database, eg "running" * @param[in] db1 src database, eg "running"
* @param[in] db2 dst database, eg "startup" * @param[in] db2 dst database, eg "startup"
* @retval 0 OK * @retval 0 OK
@ -748,7 +749,7 @@ clicon_rpc_copy_config(clicon_handle h,
/*! Send a request to backend to delete a config database /*! Send a request to backend to delete a config database
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] db database, eg "running" * @param[in] db database, eg "running"
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog
@ -805,7 +806,8 @@ clicon_rpc_delete_config(clicon_handle h,
} }
/*! Lock a database /*! Lock a database
* @param[in] h CLICON handle *
* @param[in] h Clixon handle
* @param[in] db database, eg "running" * @param[in] db database, eg "running"
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog
@ -858,7 +860,8 @@ clicon_rpc_lock(clicon_handle h,
} }
/*! Unlock a database /*! Unlock a database
* @param[in] h CLICON handle *
* @param[in] h Clixon handle
* @param[in] db database, eg "running" * @param[in] db database, eg "running"
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog
@ -911,6 +914,7 @@ clicon_rpc_unlock(clicon_handle h,
} }
/*! Get database configuration and state data /*! Get database configuration and state data
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] xpath XPath in a filter stmt (or NULL/"" for no filter) * @param[in] xpath XPath in a filter stmt (or NULL/"" for no filter)
* @param[in] namespace Namespace associated w xpath * @param[in] namespace Namespace associated w xpath
@ -1073,8 +1077,8 @@ clicon_rpc_get(clicon_handle h,
* @param[in] content Clixon extension: all, config, noconfig. -1 means all * @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] 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] defaults Value of the with-defaults mode, rfc6243, or NULL
* @param[in] offset uint32, 0 means none * @param[in] offset 0 means none
* @param[in] limit uint32, 0 means unbounded * @param[in] limit 0 means unbounded
* @param[in] direction Collection/clixon extension * @param[in] direction Collection/clixon extension
* @param[in] sort Collection/clixon extension * @param[in] sort Collection/clixon extension
* @param[in] where Collection/clixon extension * @param[in] where Collection/clixon extension
@ -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 /*! 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 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog
* Session is implicitly created in eg clicon_rpc_netconf * Session is implicitly created in eg clicon_rpc_netconf
@ -1291,7 +1295,7 @@ clicon_rpc_close_session(clicon_handle h)
/*! Kill other user sessions /*! Kill other user sessions
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] session_id Session id of other user session * @param[in] session_id Session id of other user session
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog
@ -1345,7 +1349,7 @@ clicon_rpc_kill_session(clicon_handle h,
/*! Send validate request to backend daemon /*! Send validate request to backend daemon
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] db Name of database * @param[in] db Name of database
* @retval 1 OK * @retval 1 OK
* @retval 0 Invalid, netconf error return, and logged to syslog * @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 /*! 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] confirmed If set, send commit/confirmed
* @param[in] cancel If set, send cancel-commit * @param[in] cancel If set, send cancel-commit
* @param[in] timeout For confirmed, a timeout in seconds (default 600s) * @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 /*! Discard all changes in candidate / revert to running
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @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 /*! Send a debug request to backend server
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] level Debug level * @param[in] level Debug level
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @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 /*! 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 * @param[in] level Debug level
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @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 /*! Send a restart plugin request to backend server
* *
* @param[in] h CLICON handle * @param[in] h Clixon handle
* @param[in] level Debug level * @param[in] level Debug level
* @retval 0 OK * @retval 0 OK
* @retval -1 Error and logged to syslog * @retval -1 Error and logged to syslog

View file

@ -91,6 +91,7 @@
#define STREAM_TIMER_TIMEOUT_S 5 #define STREAM_TIMER_TIMEOUT_S 5
/*! Find an event notification stream given name /*! Find an event notification stream given name
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] name Name of stream * @param[in] name Name of stream
* @retval es Event notification stream structure * @retval es Event notification stream structure
@ -114,6 +115,7 @@ stream_find(clicon_handle h,
} }
/*! Add notification event stream /*! Add notification event stream
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] name Name of stream * @param[in] name Name of stream
* @param[in] description Description 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) /*! Delete complete notification event stream list (not just single stream)
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] force Force deletion of * @param[in] force Force deletion of
*/ */
@ -189,6 +192,7 @@ stream_delete_all(clicon_handle h,
} }
/*! Return stream definition state in XML supporting RFC 8040 and RFC5277 /*! Return stream definition state in XML supporting RFC 8040 and RFC5277
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] access If set, include access/location * @param[in] access If set, include access/location
* @param[out] cb Output buffer containing XML on exit * @param[out] cb Output buffer containing XML on exit
@ -231,6 +235,7 @@ stream_get_xml(clicon_handle h,
} }
/*! Check all stream subscription stop timers, set up new timer /*! Check all stream subscription stop timers, set up new timer
*
* @param[in] fd No-op * @param[in] fd No-op
* @param[in] arg Clicon handle * @param[in] arg Clicon handle
* @note format is given by clixon_event_reg_timeout callback function (fd not needed) * @note format is given by clixon_event_reg_timeout callback function (fd not needed)
@ -320,6 +325,7 @@ stream_del()
#endif #endif
/*! Add an event notification callback to a stream given a callback function /*! Add an event notification callback to a stream given a callback function
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] stream Name of stream * @param[in] stream Name of stream
* @param[in] xpath Filter selector - xpath * @param[in] xpath Filter selector - xpath
@ -375,6 +381,7 @@ stream_ss_add(clicon_handle h,
} }
/*! Delete event stream subscription to a stream given a callback and arg /*! Delete event stream subscription to a stream given a callback and arg
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] stream Name of stream or NULL for all streams * @param[in] stream Name of stream or NULL for all streams
* @param[in] fn Callback when event occurs * @param[in] fn Callback when event occurs
@ -404,6 +411,7 @@ stream_ss_rm(clicon_handle h,
} }
/*! Find stream callback given callback function and its (unique) argument /*! Find stream callback given callback function and its (unique) argument
*
* @param[in] es Pointer to event stream * @param[in] es Pointer to event stream
* @param[in] fn Stream callback * @param[in] fn Stream callback
* @param[in] arg Argument - typically unique client handle * @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 /*! Remove stream subscription identified with fn and arg in all streams
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] fn Stream callback * @param[in] fn Stream callback
* @param[in] arg Argument - typically unique client handle * @param[in] arg Argument - typically unique client handle
@ -456,6 +465,7 @@ stream_ss_delete_all(clicon_handle h,
} }
/*! Delete a single stream /*! Delete a single stream
*
* @see stream_ss_delete_all (merge with this?) * @see stream_ss_delete_all (merge with this?)
*/ */
int int
@ -484,6 +494,7 @@ stream_ss_delete(clicon_handle h,
} }
/*! Stream notify event and distribute to all registered callbacks /*! Stream notify event and distribute to all registered callbacks
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] stream Name of event stream. CLICON is predefined as LOG stream * @param[in] stream Name of event stream. CLICON is predefined as LOG stream
* @param[in] tv Timestamp. Dont notify if subscription has stoptime<tv * @param[in] tv Timestamp. Dont notify if subscription has stoptime<tv
@ -530,6 +541,7 @@ stream_notify1(clicon_handle h,
} }
/*! Stream notify event and distribute to all registered callbacks /*! Stream notify event and distribute to all registered callbacks
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] stream Name of event stream. CLICON is predefined as LOG stream * @param[in] stream Name of event stream. CLICON is predefined as LOG stream
* @param[in] event Notification as format string according to printf(3) * @param[in] event Notification as format string according to printf(3)
@ -611,6 +623,7 @@ stream_notify(clicon_handle h,
} }
/*! Backward compatible function /*! Backward compatible function
*
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] stream Name of event stream. CLICON is predefined as LOG stream * @param[in] stream Name of event stream. CLICON is predefined as LOG stream
* @param[in] xml Notification as XML stream. Is copied. * @param[in] xml Notification as XML stream. Is copied.
@ -681,6 +694,7 @@ stream_notify_xml(clicon_handle h,
/*! Replay a stream by sending notification messages /*! Replay a stream by sending notification messages
*
* @see RFC5277 Sec 2.1.1: * @see RFC5277 Sec 2.1.1:
* Start Time: * Start Time:
A parameter, <startTime>, used to trigger the replay feature A parameter, <startTime>, used to trigger the replay feature
@ -745,6 +759,7 @@ stream_replay_notify(clicon_handle h,
} }
/*! Add replay sample to stream with timestamp /*! Add replay sample to stream with timestamp
*
* @param[in] es Stream * @param[in] es Stream
* @param[in] tv Timestamp * @param[in] tv Timestamp
* @param[in] xv XML * @param[in] xv XML
@ -781,6 +796,7 @@ struct replay_arg{
}; };
/*! Timeout callback for replaying stream /*! Timeout callback for replaying stream
*
* @param[in] fd Ignore * @param[in] fd Ignore
* @param[in] arg tmp struct including clicon handle, stream and subscription * @param[in] arg tmp struct including clicon handle, stream and subscription
*/ */
@ -892,9 +908,10 @@ curl_get_cb(void *ptr,
} }
/*! Send a curl POST request /*! 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 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: curl_easy_perform blocks
* Note: New handle is created every time, the handle can be re-used for better TCP performance * 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 * @see same function (url_post) in grideye_curl.c
@ -953,6 +970,7 @@ url_post(char *url,
} }
/*! Stream callback for example stream notification /*! Stream callback for example stream notification
*
* Push via curl_post to publish stream event * Push via curl_post to publish stream event
* @param[in] h Clicon handle * @param[in] h Clicon handle
* @param[in] op Operation: 0 OK, 1 Close * @param[in] op Operation: 0 OK, 1 Close

View file

@ -99,7 +99,7 @@ main(int argc,
if ((ch = clixon_client_connect(h, CLIXON_CLIENT_NETCONF, NULL)) == NULL) if ((ch = clixon_client_connect(h, CLIXON_CLIENT_NETCONF, NULL)) == NULL)
return -1; return -1;
s = clixon_client_socket_get(ch); s = clixon_client_socket_get(ch);
if (clixon_client_hello(s, 0) < 0) if (clixon_client_hello(s, NULL, 0) < 0)
return -1; return -1;
/* Here are read functions depending on an example YANG /* Here are read functions depending on an example YANG
* (Need an example YANG and XML input to confd) * (Need an example YANG and XML input to confd)

View file

@ -178,7 +178,7 @@ main(int argc,
else else
if (clicon_rpc_connect_inet(h, sockpath, 4535, &s) < 0) if (clicon_rpc_connect_inet(h, sockpath, 4535, &s) < 0)
goto done; goto done;
if (clicon_rpc(s, msg, &retdata, &eof) < 0) if (clicon_rpc(s, NULL, msg, &retdata, &eof) < 0)
goto done; goto done;
close(s); close(s);
fprintf(stdout, "%s\n", retdata); fprintf(stdout, "%s\n", retdata);