* Yang "min-element" and "max-element" feature supported
* New Clixon Yang RPC: ping. To check if backup is running. * Fixed support for multiple datanodes in a choice/case statement.
This commit is contained in:
parent
2fc37d2470
commit
c529847790
20 changed files with 776 additions and 286 deletions
|
|
@ -1039,6 +1039,26 @@ from_client_debug(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Check liveness of backend daemon, just send a reply
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] xe Request: <rpc><xn></rpc>
|
||||
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
|
||||
* @param[in] arg client-entry
|
||||
* @param[in] regarg User argument given at rpc_callback_register()
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
static int
|
||||
from_client_ping(clicon_handle h,
|
||||
cxobj *xe,
|
||||
cbuf *cbret,
|
||||
void *arg,
|
||||
void *regarg)
|
||||
{
|
||||
cprintf(cbret, "<rpc-reply><ok/></rpc-reply>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! An internal clicon message has arrived from a client. Receive and dispatch.
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] s Socket where message arrived. read from this.
|
||||
|
|
@ -1271,10 +1291,13 @@ backend_rpc_init(clicon_handle h)
|
|||
if (rpc_callback_register(h, from_client_create_subscription, NULL,
|
||||
"urn:ietf:params:xml:ns:netmod:notification", "create-subscription") < 0)
|
||||
goto done;
|
||||
/* In backend_client.? Clixon RPC */
|
||||
/* Clixon RPC */
|
||||
if (rpc_callback_register(h, from_client_debug, NULL,
|
||||
"http://clicon.org/lib", "debug") < 0)
|
||||
goto done;
|
||||
if (rpc_callback_register(h, from_client_ping, NULL,
|
||||
"http://clicon.org/lib", "ping") < 0)
|
||||
goto done;
|
||||
retval =0;
|
||||
done:
|
||||
return retval;
|
||||
|
|
|
|||
|
|
@ -71,10 +71,13 @@
|
|||
#include "netconf_rpc.h"
|
||||
|
||||
/* Command line options to be passed to getopt(3) */
|
||||
#define NETCONF_OPTS "hD:f:l:qa:u:d:p:y:U:t:o:"
|
||||
#define NETCONF_OPTS "hD:f:l:qa:u:d:p:y:U:t:eo:"
|
||||
|
||||
#define NETCONF_LOGFILE "/tmp/clixon_netconf.log"
|
||||
|
||||
/*! Ignore errors on packet errors: continue */
|
||||
static int ignore_packet_errors = 1;
|
||||
|
||||
/*! Process incoming packet
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] cb Packet buffer
|
||||
|
|
@ -235,8 +238,9 @@ netconf_input_cb(int s,
|
|||
/* OK, we have an xml string from a client */
|
||||
/* Remove trailer */
|
||||
*(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0';
|
||||
if (netconf_input_packet(h, cb) < 0)
|
||||
; //goto done; // ignore errors
|
||||
if (netconf_input_packet(h, cb) < 0 &&
|
||||
!ignore_packet_errors) // default is to ignore errors
|
||||
goto done;
|
||||
if (cc_closed)
|
||||
break;
|
||||
cbuf_reset(cb);
|
||||
|
|
@ -338,6 +342,7 @@ usage(clicon_handle h,
|
|||
"\t-y <file>\tLoad yang spec file (override yang main module)\n"
|
||||
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n"
|
||||
"\t-t <sec>\tTimeout in seconds. Quit after this time.\n"
|
||||
"\t-e \tDont ignore errors on packet input.\n"
|
||||
"\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
|
||||
argv0,
|
||||
clicon_netconf_dir(h)
|
||||
|
|
@ -349,6 +354,7 @@ int
|
|||
main(int argc,
|
||||
char **argv)
|
||||
{
|
||||
int retval = -1;
|
||||
int c;
|
||||
char *argv0 = argv[0];
|
||||
int quiet = 0;
|
||||
|
|
@ -455,6 +461,9 @@ main(int argc,
|
|||
case 't': /* timeout in seconds */
|
||||
tv.tv_sec = atoi(optarg);
|
||||
break;
|
||||
case 'e': /* dont ignore packet errors */
|
||||
ignore_packet_errors = 0;
|
||||
break;
|
||||
case 'o':{ /* Configuration option */
|
||||
char *val;
|
||||
if ((val = index(optarg, '=')) == NULL)
|
||||
|
|
@ -528,9 +537,12 @@ main(int argc,
|
|||
}
|
||||
if (event_loop() < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
if (ignore_packet_errors)
|
||||
retval = 0;
|
||||
netconf_terminate(h);
|
||||
clicon_log_init(__PROGRAM__, LOG_INFO, 0); /* Log on syslog no stderr */
|
||||
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -588,6 +588,10 @@ api_data_post(clicon_handle h,
|
|||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (xretcom){ /* Clear: can be reused again below */
|
||||
xml_free(xretcom);
|
||||
xretcom = NULL;
|
||||
}
|
||||
if (if_feature(yspec, "ietf-netconf", "startup")){
|
||||
/* RFC8040 Sec 1.4:
|
||||
* If the NETCONF server supports :startup, the RESTCONF server MUST
|
||||
|
|
@ -933,6 +937,10 @@ api_data_put(clicon_handle h,
|
|||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (xretcom){ /* Clear: can be reused again below */
|
||||
xml_free(xretcom);
|
||||
xretcom = NULL;
|
||||
}
|
||||
if (if_feature(yspec, "ietf-netconf", "startup")){
|
||||
/* RFC8040 Sec 1.4:
|
||||
* If the NETCONF server supports :startup, the RESTCONF server MUST
|
||||
|
|
@ -1108,6 +1116,10 @@ api_data_delete(clicon_handle h,
|
|||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
if (xretcom){ /* Clear: can be reused again below */
|
||||
xml_free(xretcom);
|
||||
xretcom = NULL;
|
||||
}
|
||||
if (if_feature(yspec, "ietf-netconf", "startup")){
|
||||
/* RFC8040 Sec 1.4:
|
||||
* If the NETCONF server supports :startup, the RESTCONF server MUST
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue