- Pagination: enabled LIST_PAGINATION and remobved constant
- Changed logic on how to find clixon_restconf in pseudo plugin - Removed ==== in constants to avoid conflict with git merge - Remove assert - Added fuzzing for netconf
This commit is contained in:
parent
47141089c2
commit
b70e22096e
28 changed files with 114 additions and 155 deletions
|
|
@ -57,7 +57,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <assert.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/* cligen */
|
||||
|
|
@ -394,7 +393,10 @@ from_client_edit_config(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
}
|
||||
assert(cbuf_len(cbret) == 0);
|
||||
if (cbuf_len(cbret) != 0){
|
||||
clicon_err(OE_NETCONF, EINVAL, "Internal error: cbret is not empty");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cbret, "<rpc-reply xmlns=\"%s\"><ok", NETCONF_BASE_NAMESPACE);
|
||||
if (clicon_data_get(h, "objectexisted", &val) == 0)
|
||||
cprintf(cbret, " objectexisted=\"%s\"", val);
|
||||
|
|
@ -1367,7 +1369,10 @@ from_client(int s,
|
|||
int eof = 0;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
// assert(s == ce->ce_s);
|
||||
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, &msg, &eof) < 0)
|
||||
goto done;
|
||||
if (eof)
|
||||
|
|
|
|||
|
|
@ -389,8 +389,6 @@ get_nacm_and_reply(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
#ifdef LIST_PAGINATION
|
||||
|
||||
/*! Help function for parsing restconf query parameter and setting netconf attribute
|
||||
*
|
||||
* If not "unbounded", parse and set a numeric value
|
||||
|
|
@ -652,7 +650,6 @@ get_list_pagination(clicon_handle h,
|
|||
xml_free(xret);
|
||||
return retval;
|
||||
}
|
||||
#endif /* LIST_PAGINATION */
|
||||
|
||||
/*! Common get/get-config code for retrieving configuration and state information.
|
||||
*
|
||||
|
|
@ -692,11 +689,9 @@ get_common(clicon_handle h,
|
|||
cbuf *cbmsg = NULL; /* For error msg */
|
||||
char *xpath0;
|
||||
cbuf *cbreason = NULL;
|
||||
#ifdef LIST_PAGINATION
|
||||
int list_pagination = 0;
|
||||
char *valstr;
|
||||
cxobj *x;
|
||||
#endif /* LIST_PAGINATION */
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
username = clicon_username_get(h);
|
||||
|
|
@ -736,7 +731,6 @@ get_common(clicon_handle h,
|
|||
goto ok;
|
||||
}
|
||||
}
|
||||
#ifdef LIST_PAGINATION
|
||||
/* Check if list pagination */
|
||||
if ((x = xml_find_type(xe, NULL, "list-pagination", CX_ELMNT)) != NULL &&
|
||||
(valstr = xml_body(x)) != NULL &&
|
||||
|
|
@ -752,7 +746,6 @@ get_common(clicon_handle h,
|
|||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
#endif /* LIST_PAGINATION */
|
||||
/* Read configuration */
|
||||
switch (content){
|
||||
case CONTENT_CONFIG: /* config data only */
|
||||
|
|
|
|||
|
|
@ -246,9 +246,11 @@ restconf_pseudo_process_control(clicon_handle h)
|
|||
int i;
|
||||
int nr;
|
||||
cbuf *cb = NULL;
|
||||
char *dir = NULL;
|
||||
char *dir0 = NULL;
|
||||
char *dir1 = NULL;
|
||||
char *pgm;
|
||||
struct stat fstat;
|
||||
int found = 0;
|
||||
|
||||
nr = 10;
|
||||
if ((argv = calloc(nr, sizeof(char *))) == NULL){
|
||||
|
|
@ -265,19 +267,32 @@ restconf_pseudo_process_control(clicon_handle h)
|
|||
* If not, use the Makefile
|
||||
* Use PATH?
|
||||
*/
|
||||
if ((dir = clicon_option_str(h, "CLICON_RESTCONF_INSTALLDIR")) == NULL){
|
||||
if ((dir = CLIXON_CONFIG_SBINDIR) == NULL){
|
||||
clicon_err(OE_RESTCONF, EINVAL, "Both option CLICON_RESTCONF_INSTALLDIR and makefile constant CLIXON_CONFIG_SBINDIR are NULL which make sit not possible to know where clixon_restconf is installed(shouldnt happen)");
|
||||
goto done;
|
||||
if ((dir0 = clicon_option_str(h, "CLICON_RESTCONF_INSTALLDIR")) != NULL){
|
||||
cprintf(cb, "%s/clixon_restconf", dir0);
|
||||
pgm = cbuf_get(cb);
|
||||
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
|
||||
clicon_debug(1, "Found %s", pgm);
|
||||
found++;
|
||||
}
|
||||
else
|
||||
clicon_debug(1, "Not found: %s", pgm);
|
||||
}
|
||||
cprintf(cb, "%s/clixon_restconf", dir);
|
||||
pgm = cbuf_get(cb);
|
||||
/* Sanity check: program exists */
|
||||
if (stat(pgm, &fstat) < 0) {
|
||||
clicon_err(OE_FATAL, errno, "%s, you may have set CLICON_BACKEND_RESTCONF_PROCESS but clixon_restconf is not found in %s. Try overriding with CLICON_RESTCONF_INSTALLDIR",
|
||||
pgm,
|
||||
CLIXON_CONFIG_SBINDIR);
|
||||
if (!found &&
|
||||
(dir1 = CLIXON_CONFIG_SBINDIR) != NULL){
|
||||
cbuf_reset(cb);
|
||||
cprintf(cb, "%s/clixon_restconf", dir1);
|
||||
pgm = cbuf_get(cb);
|
||||
clicon_debug(1, "Looking for %s", pgm);
|
||||
if (stat(pgm, &fstat) == 0){ /* Sanity check: program exists */
|
||||
clicon_debug(1, "Found %s", pgm);
|
||||
found++;
|
||||
}
|
||||
else
|
||||
clicon_debug(1, "Not found: %s", pgm);
|
||||
}
|
||||
if (!found){
|
||||
clicon_err(OE_RESTCONF, 0, "clixon_restconf not found in neither CLICON_RESTCONF_INSTALLDIR(%s) nor CLIXON_CONFIG_SBINDIR(%s). Try overriding with CLICON_RESTCONF_INSTALLDIR",
|
||||
dir0, dir1);
|
||||
goto done;
|
||||
}
|
||||
argv[i++] = pgm;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,33 @@
|
|||
* | | ------------> | cli |
|
||||
* | list{key A;}| | syntax |
|
||||
* +-------------+ +-------------+
|
||||
|
||||
* YANG generate CLI
|
||||
|
||||
This is an example yang module:
|
||||
module m {
|
||||
container x {
|
||||
namespace "urn:example:m";
|
||||
prefix m;
|
||||
list m1 {
|
||||
key "a";
|
||||
leaf a {
|
||||
type string;
|
||||
}
|
||||
leaf b {
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
You can see which CLISPEC it generates via clixon_cli -D 2:
|
||||
x,cli_set("/example:x");{
|
||||
m1 a (<a:string>|<a:string expand_dbvar("candidate","/example:x/m1=%s/a")>),overwrite_me("/example:x/m1=%s/");
|
||||
{
|
||||
b (<b:string>|<b:string expand_dbvar("candidate","/example:x/m1=%s/b")>),overwrite_me("/example:x/m1=%s/b");
|
||||
}
|
||||
}
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "clixon_config.h" /* generated by config & autoconf */
|
||||
|
|
@ -69,36 +96,6 @@
|
|||
/* variable expand function */
|
||||
#define GENERATE_EXPAND_XMLDB "expand_dbvar"
|
||||
|
||||
/*=====================================================================
|
||||
* YANG generate CLI
|
||||
*=====================================================================*/
|
||||
/*
|
||||
This is an example yang module:
|
||||
module m {
|
||||
container x {
|
||||
namespace "urn:example:m";
|
||||
prefix m;
|
||||
list m1 {
|
||||
key "a";
|
||||
leaf a {
|
||||
type string;
|
||||
}
|
||||
leaf b {
|
||||
type string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
You can see which CLISPEC it generates via clixon_cli -D 2:
|
||||
x,cli_set("/example:x");{
|
||||
m1 a (<a:string>|<a:string expand_dbvar("candidate","/example:x/m1=%s/a")>),overwrite_me("/example:x/m1=%s/");
|
||||
{
|
||||
b (<b:string>|<b:string expand_dbvar("candidate","/example:x/m1=%s/b")>),overwrite_me("/example:x/m1=%s/b");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*! Create cligen variable expand entry with xmlkey format string as argument
|
||||
* @param[in] h clicon handle
|
||||
* @param[in] ys yang_stmt of the node at hand
|
||||
|
|
|
|||
|
|
@ -891,8 +891,6 @@ cli_show_options(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
#ifdef LIST_PAGINATION
|
||||
|
||||
/*! Show pagination
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] cvv Vector of cli string and instantiated variables
|
||||
|
|
@ -1016,11 +1014,3 @@ cli_pagination(clicon_handle h,
|
|||
cbuf_free(cb);
|
||||
return retval;
|
||||
}
|
||||
#else
|
||||
int
|
||||
cli_pagination(clicon_handle h, cvec *cvv, cvec *argv)
|
||||
{
|
||||
fprintf(stderr, "Not yet implemented\n");
|
||||
return 0;
|
||||
}
|
||||
#endif /* LIST_PAGINATION */
|
||||
|
|
|
|||
|
|
@ -300,7 +300,6 @@ api_data_get2(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
#ifdef LIST_PAGINATION
|
||||
/*! GET Collection
|
||||
* According to restconf collection draft. Lists, work in progress
|
||||
* @param[in] h Clixon handle
|
||||
|
|
@ -566,7 +565,6 @@ api_data_collection(clicon_handle h,
|
|||
free(xvec);
|
||||
return retval;
|
||||
}
|
||||
#endif /* LIST_PAGINATION */
|
||||
|
||||
/*! REST HEAD method
|
||||
* @param[in] h Clixon handle
|
||||
|
|
@ -644,13 +642,8 @@ api_data_get(clicon_handle h,
|
|||
break;
|
||||
case YANG_COLLECTION_XML:
|
||||
case YANG_COLLECTION_JSON:
|
||||
#ifdef LIST_PAGINATION
|
||||
if (api_data_collection(h, req, api_path, pcvec, pi, qvec, pretty, media_out) < 0)
|
||||
goto done;
|
||||
#else
|
||||
if (restconf_notimplemented(h, req, pretty, media_out) < 0)
|
||||
goto done;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ restconf_connection_sanity(clicon_handle h,
|
|||
if (rc->rc_ssl == NULL &&
|
||||
rc->rc_proto == HTTP_2 &&
|
||||
clicon_option_bool(h, "CLICON_RESTCONF_HTTP2_PLAIN") == 0){
|
||||
if (netconf_invalid_value_xml(&xerr, "protocol", "Plain HTTP/2 is disabled") < 0)
|
||||
if (netconf_invalid_value_xml(&xerr, "protocol", "Only HTTP/2 with TLS is enabled, plain http/2 is disabled") < 0)
|
||||
goto done;
|
||||
if ((media_str = restconf_param_get(h, "HTTP_ACCEPT")) == NULL){
|
||||
media_out = YANG_DATA_JSON;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue