Formatting, whitespace
This commit is contained in:
parent
f26ea043c7
commit
411f509fd8
19 changed files with 288 additions and 288 deletions
|
|
@ -1587,11 +1587,11 @@ from_client_restart_plugin(clixon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
from_client_process_control(clixon_handle h,
|
from_client_process_control(clixon_handle h,
|
||||||
cxobj *xe,
|
cxobj *xe,
|
||||||
cbuf *cbret,
|
cbuf *cbret,
|
||||||
void *arg,
|
void *arg,
|
||||||
void *regarg)
|
void *regarg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
@ -1631,7 +1631,7 @@ from_client_process_control(clixon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
from_client_hello(clixon_handle h,
|
from_client_hello(clixon_handle h,
|
||||||
cxobj *x,
|
cxobj *x,
|
||||||
struct client_entry *ce,
|
struct client_entry *ce,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
|
|
|
||||||
|
|
@ -408,10 +408,10 @@ startup_common(clixon_handle h,
|
||||||
* @retval -1 Error - or validation failed (but cbret not set)
|
* @retval -1 Error - or validation failed (but cbret not set)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
startup_validate(clixon_handle h,
|
startup_validate(clixon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
cxobj **xtr,
|
cxobj **xtr,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -454,9 +454,9 @@ startup_validate(clixon_handle h,
|
||||||
* Only called from startup_mode_startup
|
* Only called from startup_mode_startup
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
startup_commit(clixon_handle h,
|
startup_commit(clixon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ confirmed_commit_state_get(clixon_handle h)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
confirmed_commit_state_set(clixon_handle h,
|
confirmed_commit_state_set(clixon_handle h,
|
||||||
enum confirmed_commit_state state)
|
enum confirmed_commit_state state)
|
||||||
{
|
{
|
||||||
struct confirmed_commit *cc = NULL;
|
struct confirmed_commit *cc = NULL;
|
||||||
|
|
@ -211,8 +211,8 @@ confirmed_commit_fn_arg_get(clixon_handle h,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
confirmed_commit_fn_arg_set(clixon_handle h,
|
confirmed_commit_fn_arg_set(clixon_handle h,
|
||||||
int (*fn)(int, void*),
|
int (*fn)(int, void*),
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct confirmed_commit *cc = NULL;
|
struct confirmed_commit *cc = NULL;
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ cancel_rollback_event(clixon_handle h)
|
||||||
* @see do_rollback()
|
* @see do_rollback()
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
rollback_fn(int fd,
|
rollback_fn(int fd,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
clixon_handle h = arg;
|
clixon_handle h = arg;
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,13 @@ restconf_client_get_capabilities(clixon_handle h,
|
||||||
* @retval -1 Error (fatal)
|
* @retval -1 Error (fatal)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
client_get_streams(clixon_handle h,
|
client_get_streams(clixon_handle h,
|
||||||
yang_stmt *yspec,
|
yang_stmt *yspec,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cvec *nsc,
|
cvec *nsc,
|
||||||
yang_stmt *ymod,
|
yang_stmt *ymod,
|
||||||
char *top,
|
char *top,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *yns = NULL; /* yang namespace */
|
yang_stmt *yns = NULL; /* yang namespace */
|
||||||
|
|
@ -396,16 +396,16 @@ filter_xpath_again(clixon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
get_nacm_and_reply(clixon_handle h,
|
get_nacm_and_reply(clixon_handle h,
|
||||||
cxobj *xret,
|
cxobj *xret,
|
||||||
cxobj **xvec,
|
cxobj **xvec,
|
||||||
size_t xlen,
|
size_t xlen,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cvec *nsc,
|
cvec *nsc,
|
||||||
char *username,
|
char *username,
|
||||||
int32_t depth,
|
int32_t depth,
|
||||||
withdefaults_type wdef,
|
withdefaults_type wdef,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xnacm = NULL;
|
cxobj *xnacm = NULL;
|
||||||
|
|
@ -447,12 +447,12 @@ get_nacm_and_reply(clixon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
element2value(clixon_handle h,
|
element2value(clixon_handle h,
|
||||||
cxobj *xe,
|
cxobj *xe,
|
||||||
char *name,
|
char *name,
|
||||||
char *defaultstr,
|
char *defaultstr,
|
||||||
cbuf *cbret,
|
cbuf *cbret,
|
||||||
uint32_t *value)
|
uint32_t *value)
|
||||||
{
|
{
|
||||||
char *valstr;
|
char *valstr;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_plugin_reset_one(clixon_plugin_t *cp,
|
clixon_plugin_reset_one(clixon_plugin_t *cp,
|
||||||
clixon_handle h,
|
clixon_handle h,
|
||||||
char *db)
|
char *db)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgreset_t *fn; /* callback */
|
plgreset_t *fn; /* callback */
|
||||||
|
|
@ -137,7 +137,7 @@ clixon_plugin_reset_all(clixon_handle h,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
clixon_plugin_pre_daemon_one(clixon_plugin_t *cp,
|
||||||
clixon_handle h)
|
clixon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||||
|
|
@ -199,7 +199,7 @@ clixon_plugin_pre_daemon_all(clixon_handle h)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
clixon_plugin_daemon_one(clixon_plugin_t *cp,
|
||||||
clixon_handle h)
|
clixon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
plgdaemon_t *fn; /* Daemonize plugin callback function */
|
||||||
|
|
@ -332,11 +332,11 @@ clixon_plugin_statedata_one(clixon_plugin_t *cp,
|
||||||
* @note xret can be replaced in this function
|
* @note xret can be replaced in this function
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_plugin_statedata_all(clixon_handle h,
|
clixon_plugin_statedata_all(clixon_handle h,
|
||||||
yang_stmt *yspec,
|
yang_stmt *yspec,
|
||||||
cvec *nsc,
|
cvec *nsc,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -457,8 +457,7 @@ int
|
||||||
clixon_plugin_lockdb_all(clixon_handle h,
|
clixon_plugin_lockdb_all(clixon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
int lock,
|
int lock,
|
||||||
int id
|
int id)
|
||||||
)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -786,9 +785,9 @@ plugin_transaction_revert_all(clixon_handle h,
|
||||||
* The commit failed is called for only failed plugin before revert all cb.
|
* The commit failed is called for only failed plugin before revert all cb.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
plugin_transaction_commit_failed(clixon_plugin_t *cp,
|
plugin_transaction_commit_failed(clixon_plugin_t *cp,
|
||||||
clixon_handle h,
|
clixon_handle h,
|
||||||
transaction_data_t *td)
|
transaction_data_t *td)
|
||||||
{
|
{
|
||||||
trans_cb_t *fn;
|
trans_cb_t *fn;
|
||||||
|
|
||||||
|
|
@ -806,7 +805,7 @@ plugin_transaction_commit_failed(clixon_plugin_t *cp,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
plugin_transaction_commit_one(clixon_plugin_t *cp,
|
plugin_transaction_commit_one(clixon_plugin_t *cp,
|
||||||
clixon_handle h,
|
clixon_handle h,
|
||||||
transaction_data_t *td)
|
transaction_data_t *td)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,9 @@ startup --+-------------------------------------> BROKEN XML
|
||||||
* @note: if commit fails, copy factory to running
|
* @note: if commit fails, copy factory to running
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
startup_mode_startup(clixon_handle h,
|
startup_mode_startup(clixon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
||||||
|
|
@ -85,15 +85,15 @@
|
||||||
* @see struct clixon_handle, struct cli_handle
|
* @see struct clixon_handle, struct cli_handle
|
||||||
*/
|
*/
|
||||||
struct backend_handle {
|
struct backend_handle {
|
||||||
int bh_magic; /* magic (HDR)*/
|
int bh_magic; /* magic (HDR)*/
|
||||||
clicon_hash_t *bh_copt; /* clicon option list (HDR) */
|
clicon_hash_t *bh_copt; /* clicon option list (HDR) */
|
||||||
clicon_hash_t *bh_data; /* internal clicon data (HDR) */
|
clicon_hash_t *bh_data; /* internal clicon data (HDR) */
|
||||||
clicon_hash_t *ch_db_elmnt; /* xml datastore element cache data */
|
clicon_hash_t *ch_db_elmnt; /* xml datastore element cache data */
|
||||||
event_stream_t *bh_stream; /* notification streams, see clixon_stream.[ch] */
|
event_stream_t *bh_stream; /* notification streams, see clixon_stream.[ch] */
|
||||||
|
|
||||||
/* ------ end of common handle ------ */
|
/* ------ end of common handle ------ */
|
||||||
struct client_entry *bh_ce_list; /* The client list */
|
struct client_entry *bh_ce_list; /* The client list */
|
||||||
int bh_ce_nr; /* Number of clients, just increment */
|
int bh_ce_nr; /* Number of clients, just increment */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Creates and returns a clicon config handle for other CLICON API calls
|
/*! Creates and returns a clicon config handle for other CLICON API calls
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
***** BEGIN LICENSE BLOCK *****
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||||
Copyright (C) 2017-2019 Olof Hagsand
|
Copyright (C) 2017-2019 Olof Hagsand
|
||||||
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC (Netgate)
|
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC (Netgate)
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
in which case the provisions of the GPL are applicable instead
|
in which case the provisions of the GPL are applicable instead
|
||||||
of those above. If you wish to allow use of your version of this file only
|
of those above. If you wish to allow use of your version of this file only
|
||||||
under the terms of the GPL, and not to allow others to
|
under the terms of the GPL, and not to allow others to
|
||||||
use your version of this file under the terms of Apache License version 2,
|
use your version of this file under the terms of Apache License version 2,
|
||||||
indicate your decision by deleting the provisions above and replace them with
|
indicate your decision by deleting the provisions above and replace them with
|
||||||
the notice and other provisions required by the GPL. If you do not delete
|
the notice and other provisions required by the GPL. If you do not delete
|
||||||
the provisions above, a recipient may use your version of this file under
|
the provisions above, a recipient may use your version of this file under
|
||||||
|
|
@ -67,15 +67,15 @@
|
||||||
|
|
||||||
/* xf specifices a filter, and xn is an xml tree.
|
/* xf specifices a filter, and xn is an xml tree.
|
||||||
* Select the part of xn that matches xf and return it.
|
* Select the part of xn that matches xf and return it.
|
||||||
* Change xn destructively by removing the parts of the sub-tree that does
|
* Change xn destructively by removing the parts of the sub-tree that does
|
||||||
* not match.
|
* not match.
|
||||||
* Match according to Section 6 of RFC 4741.
|
* Match according to Section 6 of RFC 4741.
|
||||||
NO_FILTER, select all
|
NO_FILTER, select all
|
||||||
EMPTY_FILTER, select nothing
|
EMPTY_FILTER, select nothing
|
||||||
ATTRIBUTE_MATCH, select if attribute match
|
ATTRIBUTE_MATCH, select if attribute match
|
||||||
SELECTION, select this node
|
SELECTION, select this node
|
||||||
CONTENT_MATCH, select all siblings with matching content
|
CONTENT_MATCH, select all siblings with matching content
|
||||||
CONTAINMENT select
|
CONTAINMENT select
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* return a string containing leafs value, NULL if no leaf or no value */
|
/* return a string containing leafs value, NULL if no leaf or no value */
|
||||||
|
|
@ -192,10 +192,10 @@ xml_filter_recursive(cxobj *xfilter,
|
||||||
|
|
||||||
/*! Remove parts of configuration xml tree that does not match filter xml tree
|
/*! Remove parts of configuration xml tree that does not match filter xml tree
|
||||||
*
|
*
|
||||||
* @param[in] xfilter Filter xml
|
* @param[in] xfilter Filter xml
|
||||||
* @param[out] xconf Configuration xml
|
* @param[out] xconf Configuration xml
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* This is the top-level function, calls a recursive variant.
|
* This is the top-level function, calls a recursive variant.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
***** BEGIN LICENSE BLOCK *****
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||||
Copyright (C) 2017-2019 Olof Hagsand
|
Copyright (C) 2017-2019 Olof Hagsand
|
||||||
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
in which case the provisions of the GPL are applicable instead
|
in which case the provisions of the GPL are applicable instead
|
||||||
of those above. If you wish to allow use of your version of this file only
|
of those above. If you wish to allow use of your version of this file only
|
||||||
under the terms of the GPL, and not to allow others to
|
under the terms of the GPL, and not to allow others to
|
||||||
use your version of this file under the terms of Apache License version 2,
|
use your version of this file under the terms of Apache License version 2,
|
||||||
indicate your decision by deleting the provisions above and replace them with
|
indicate your decision by deleting the provisions above and replace them with
|
||||||
the notice and other provisions required by the GPL. If you do not delete
|
the notice and other provisions required by the GPL. If you do not delete
|
||||||
the provisions above, a recipient may use your version of this file under
|
the provisions above, a recipient may use your version of this file under
|
||||||
|
|
@ -115,7 +115,7 @@ netconf_add_request_attr(cxobj *xrpc,
|
||||||
/* If attribute already exists, dont copy it */
|
/* If attribute already exists, dont copy it */
|
||||||
if (xml_find_type(xrep, NULL, xml_name(xa), CX_ATTR) != NULL)
|
if (xml_find_type(xrep, NULL, xml_name(xa), CX_ATTR) != NULL)
|
||||||
continue; /* Skip already present (dont overwrite) */
|
continue; /* Skip already present (dont overwrite) */
|
||||||
/* Filter all clixon-lib attributes and namespace declaration
|
/* Filter all clixon-lib attributes and namespace declaration
|
||||||
* to avoid leaking internal attributes to external NETCONF
|
* to avoid leaking internal attributes to external NETCONF
|
||||||
* note this is only done on top-level.
|
* note this is only done on top-level.
|
||||||
*/
|
*/
|
||||||
|
|
@ -137,7 +137,7 @@ netconf_add_request_attr(cxobj *xrpc,
|
||||||
/*! Process netconf hello message
|
/*! Process netconf hello message
|
||||||
*
|
*
|
||||||
* A server receiving a <hello> message with a <session-id> element MUST
|
* A server receiving a <hello> message with a <session-id> element MUST
|
||||||
* terminate the NETCONF session.
|
* terminate the NETCONF session.
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] xn
|
* @param[in] xn
|
||||||
* @param[out] eof Request termination
|
* @param[out] eof Request termination
|
||||||
|
|
@ -175,7 +175,7 @@ netconf_hello_msg(clixon_handle h,
|
||||||
continue;
|
continue;
|
||||||
if ((body = xml_body(x)) == NULL)
|
if ((body = xml_body(x)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
/* When comparing protocol version capability URIs, only the base part is used, in the
|
/* When comparing protocol version capability URIs, only the base part is used, in the
|
||||||
* event any parameters are encoded at the end of the URI string. */
|
* event any parameters are encoded at the end of the URI string. */
|
||||||
if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0){ /* RFC 4741 */
|
if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0){ /* RFC 4741 */
|
||||||
foundbase_10++;
|
foundbase_10++;
|
||||||
|
|
@ -201,7 +201,7 @@ netconf_hello_msg(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Process incoming Netconf RPC netconf message
|
/*! Process incoming Netconf RPC netconf message
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] xreq XML tree containing netconf RPC message
|
* @param[in] xreq XML tree containing netconf RPC message
|
||||||
|
|
@ -389,7 +389,7 @@ netconf_input_packet(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Get netconf message: detect end-of-msg
|
/*! Get netconf message: detect end-of-msg
|
||||||
*
|
*
|
||||||
* @param[in] s Socket where input arrived. read from this.
|
* @param[in] s Socket where input arrived. read from this.
|
||||||
* @param[in] arg Clixon handle.
|
* @param[in] arg Clixon handle.
|
||||||
|
|
@ -454,7 +454,7 @@ netconf_input_cb(int s,
|
||||||
frame_size = 0;
|
frame_size = 0;
|
||||||
else
|
else
|
||||||
frame_size = i32;
|
frame_size = i32;
|
||||||
/* Read input data from socket and append to cbbuf */
|
/* Read input data from socket and append to cbuf */
|
||||||
if ((len = netconf_input_read2(s, buf, buflen, &eof)) < 0)
|
if ((len = netconf_input_read2(s, buf, buflen, &eof)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
@ -570,16 +570,16 @@ send_hello(clixon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Clean and close all state of netconf process (but dont exit).
|
/*! Clean and close all state of netconf process (but dont exit).
|
||||||
*
|
*
|
||||||
* Cannot use h after this
|
* Cannot use h after this
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
netconf_terminate(clixon_handle h)
|
netconf_terminate(clixon_handle h)
|
||||||
{
|
{
|
||||||
cvec *nsctx;
|
cvec *nsctx;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
||||||
if (clixon_exit_get() == 0)
|
if (clixon_exit_get() == 0)
|
||||||
clixon_exit_set(1);
|
clixon_exit_set(1);
|
||||||
|
|
@ -602,7 +602,7 @@ netconf_terminate(clixon_handle h)
|
||||||
/*! Setup signal handlers
|
/*! Setup signal handlers
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
netconf_signal_init (clixon_handle h)
|
netconf_signal_init(clixon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
|
|
@ -616,7 +616,7 @@ netconf_signal_init (clixon_handle h)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
timeout_fn(int s,
|
timeout_fn(int s,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
clixon_err(OE_EVENTS, ETIMEDOUT, "User request timeout");
|
clixon_err(OE_EVENTS, ETIMEDOUT, "User request timeout");
|
||||||
|
|
@ -747,7 +747,7 @@ main(int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Logs, error and debug to stderr or syslog, set debug level
|
* Logs, error and debug to stderr or syslog, set debug level
|
||||||
*/
|
*/
|
||||||
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
clixon_log_init(h, __PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
|
|
@ -942,7 +942,7 @@ main(int argc,
|
||||||
goto done;
|
goto done;
|
||||||
clicon_session_id_set(h, id);
|
clicon_session_id_set(h, id);
|
||||||
|
|
||||||
/* Send hello to northbound client
|
/* Send hello to northbound client
|
||||||
* Note that this is a violation of RDFC 6241 Sec 8.1:
|
* Note that this is a violation of RDFC 6241 Sec 8.1:
|
||||||
* When the NETCONF session is opened, each peer(both client and server) MUST send a <hello..
|
* When the NETCONF session is opened, each peer(both client and server) MUST send a <hello..
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
***** BEGIN LICENSE BLOCK *****
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren
|
||||||
Copyright (C) 2017-2019 Olof Hagsand
|
Copyright (C) 2017-2019 Olof Hagsand
|
||||||
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
in which case the provisions of the GPL are applicable instead
|
in which case the provisions of the GPL are applicable instead
|
||||||
of those above. If you wish to allow use of your version of this file only
|
of those above. If you wish to allow use of your version of this file only
|
||||||
under the terms of the GPL, and not to allow others to
|
under the terms of the GPL, and not to allow others to
|
||||||
use your version of this file under the terms of Apache License version 2,
|
use your version of this file under the terms of Apache License version 2,
|
||||||
indicate your decision by deleting the provisions above and replace them with
|
indicate your decision by deleting the provisions above and replace them with
|
||||||
the notice and other provisions required by the GPL. If you do not delete
|
the notice and other provisions required by the GPL. If you do not delete
|
||||||
the provisions above, a recipient may use your version of this file under
|
the provisions above, a recipient may use your version of this file under
|
||||||
|
|
@ -74,10 +74,10 @@
|
||||||
#include "netconf_rpc.h"
|
#include "netconf_rpc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* <rpc [attributes]>
|
* <rpc [attributes]>
|
||||||
<!- - tag elements in a request from a client application - ->
|
<!- - tag elements in a request from a client application - ->
|
||||||
</rpc>
|
</rpc>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
netconf_get_config_subtree(clixon_handle h,
|
netconf_get_config_subtree(clixon_handle h,
|
||||||
|
|
@ -100,7 +100,7 @@ netconf_get_config_subtree(clixon_handle h,
|
||||||
NETCONF_BASE_NAMESPACE
|
NETCONF_BASE_NAMESPACE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
// done:
|
// done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
@ -116,22 +116,22 @@ ok:
|
||||||
* @note filter type subtree and xpath is supported, but xpath is preferred, and
|
* @note filter type subtree and xpath is supported, but xpath is preferred, and
|
||||||
* better performance and tested. Please use xpath.
|
* better performance and tested. Please use xpath.
|
||||||
*
|
*
|
||||||
* <get-config>
|
* <get-config>
|
||||||
* <source>
|
* <source>
|
||||||
* <candidate/> | <running/>
|
* <candidate/> | <running/>
|
||||||
* </source>
|
* </source>
|
||||||
* </get-config>
|
* </get-config>
|
||||||
*
|
*
|
||||||
* <get-config>
|
* <get-config>
|
||||||
* <source>
|
* <source>
|
||||||
* <candidate/> | <running/>
|
* <candidate/> | <running/>
|
||||||
* </source>
|
* </source>
|
||||||
* <filter type="subtree">
|
* <filter type="subtree">
|
||||||
* <configuration>
|
* <configuration>
|
||||||
* <!- - tag elements for each configuration element to return - ->
|
* <!- - tag elements for each configuration element to return - ->
|
||||||
* </configuration>
|
* </configuration>
|
||||||
* </filter>
|
* </filter>
|
||||||
* </get-config>
|
* </get-config>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <rpc><get-config><source><running /></source>
|
* <rpc><get-config><source><running /></source>
|
||||||
|
|
@ -147,36 +147,36 @@ ok:
|
||||||
* -----------------+-----------+---------------+--------------+
|
* -----------------+-----------+---------------+--------------+
|
||||||
* Example requests of each:
|
* Example requests of each:
|
||||||
* no filter + no config
|
* no filter + no config
|
||||||
<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>
|
<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>
|
||||||
* filter subnet + no config:
|
* filter subnet + no config:
|
||||||
<rpc><get-config><source><candidate/></source><filter/></get-config></rpc>]]>]]>
|
<rpc><get-config><source><candidate/></source><filter/></get-config></rpc>]]>]]>
|
||||||
* filter xpath + select all:
|
* filter xpath + select all:
|
||||||
<rpc><get-config><source><candidate/></source><filter type="xpath" select="/"/></get-config></rpc>]]>]]>
|
<rpc><get-config><source><candidate/></source><filter type="xpath" select="/"/></get-config></rpc>]]>]]>
|
||||||
* filter subtree + config:
|
* filter subtree + config:
|
||||||
<rpc><get-config><source><candidate/></source><filter type="subtree"><configuration><interfaces><interface><ipv4><enabled/></ipv4></interface></interfaces></configuration></filter></get-config></rpc>]]>]]>
|
<rpc><get-config><source><candidate/></source><filter type="subtree"><configuration><interfaces><interface><ipv4><enabled/></ipv4></interface></interfaces></configuration></filter></get-config></rpc>]]>]]>
|
||||||
* filter xpath + select:
|
* filter xpath + select:
|
||||||
<rpc><get-config><source><candidate/></source><filter type="xpath" select="/interfaces/interface/ipv4"/></get-config></rpc>]]>]]>
|
<rpc><get-config><source><candidate/></source><filter type="xpath" select="/interfaces/interface/ipv4"/></get-config></rpc>]]>]]>
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
netconf_get_config(clixon_handle h,
|
netconf_get_config(clixon_handle h,
|
||||||
cxobj *xn,
|
cxobj *xn,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xfilter; /* filter */
|
cxobj *xfilter; /* filter */
|
||||||
char *ftype = NULL;
|
char *ftype = NULL;
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
char *prefix = NULL;
|
char *prefix = NULL;
|
||||||
|
|
||||||
if(xml_nsctx_node(xn, &nsc) < 0)
|
if(xml_nsctx_node(xn, &nsc) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Get prefix of netconf base namespace in the incoming message */
|
/* Get prefix of netconf base namespace in the incoming message */
|
||||||
if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){
|
if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ie <filter>...</filter> */
|
/* ie <filter>...</filter> */
|
||||||
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
||||||
ftype = xml_find_value(xfilter, "type");
|
ftype = xml_find_value(xfilter, "type");
|
||||||
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
||||||
|
|
@ -193,12 +193,12 @@ netconf_get_config(clixon_handle h,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
"<error-type>applicatio</error-type>"
|
"<error-type>applicatio</error-type>"
|
||||||
"<error-severity>error</error-severity>"
|
"<error-severity>error</error-severity>"
|
||||||
"<error-message>filter type not supported</error-message>"
|
"<error-message>filter type not supported</error-message>"
|
||||||
"<error-info>type</error-info>"
|
"<error-info>type</error-info>"
|
||||||
"</rpc-error></rpc-reply>",
|
"</rpc-error></rpc-reply>",
|
||||||
NETCONF_BASE_NAMESPACE);
|
NETCONF_BASE_NAMESPACE);
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
@ -220,16 +220,16 @@ netconf_get_config(clixon_handle h,
|
||||||
* @example
|
* @example
|
||||||
* <edit-config>
|
* <edit-config>
|
||||||
* <config>...</config>
|
* <config>...</config>
|
||||||
* <default-operation>(merge | none | replace)</default-operation>
|
* <default-operation>(merge | none | replace)</default-operation>
|
||||||
* <error-option>(stop-on-error | continue-on-error )</error-option>
|
* <error-option>(stop-on-error | continue-on-error )</error-option>
|
||||||
* <test-option>(set | test-then-set | test-only)</test-option>
|
* <test-option>(set | test-then-set | test-only)</test-option>
|
||||||
* </edit-config>
|
* </edit-config>
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
get_edit_opts(cxobj *xn,
|
get_edit_opts(cxobj *xn,
|
||||||
enum test_option *testopt,
|
enum test_option *testopt,
|
||||||
enum error_option *erropt,
|
enum error_option *erropt,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
@ -252,10 +252,10 @@ get_edit_opts(cxobj *xn,
|
||||||
if (strcmp(optstr, "stop-on-error") == 0)
|
if (strcmp(optstr, "stop-on-error") == 0)
|
||||||
*erropt = STOP_ON_ERROR;
|
*erropt = STOP_ON_ERROR;
|
||||||
else
|
else
|
||||||
if (strcmp(optstr, "continue-on-error") == 0)
|
if (strcmp(optstr, "continue-on-error") == 0)
|
||||||
*erropt = CONTINUE_ON_ERROR;
|
*erropt = CONTINUE_ON_ERROR;
|
||||||
else
|
else
|
||||||
goto parerr;
|
goto parerr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retval = 1; /* hunky dory */
|
retval = 1; /* hunky dory */
|
||||||
|
|
@ -272,41 +272,41 @@ get_edit_opts(cxobj *xn,
|
||||||
|
|
||||||
/*! Netconf edit configuration
|
/*! Netconf edit configuration
|
||||||
*
|
*
|
||||||
Write the change on a tmp file, then load that into candidate configuration.
|
Write the change on a tmp file, then load that into candidate configuration.
|
||||||
<edit-config>
|
<edit-config>
|
||||||
<target>
|
<target>
|
||||||
<candidate/>
|
<candidate/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!- - EITHER - ->
|
|
||||||
|
|
||||||
<config>
|
<!- - EITHER - ->
|
||||||
<configuration>
|
|
||||||
<!- - tag elements representing the data to incorporate - ->
|
|
||||||
</configuration>
|
|
||||||
</config>
|
|
||||||
|
|
||||||
<!- - OR - ->
|
<config>
|
||||||
|
<configuration>
|
||||||
<config-text>
|
<!- - tag elements representing the data to incorporate - ->
|
||||||
<configuration-text>
|
</configuration>
|
||||||
<!- - tag elements inline configuration data in text format - ->
|
</config>
|
||||||
</configuration-text>
|
|
||||||
</config-text>
|
|
||||||
|
|
||||||
<!- - OR - ->
|
<!- - OR - ->
|
||||||
|
|
||||||
<url>
|
<config-text>
|
||||||
<!- - location specifier for file containing data - ->
|
<configuration-text>
|
||||||
</url>
|
<!- - tag elements inline configuration data in text format - ->
|
||||||
|
</configuration-text>
|
||||||
<default-operation>(merge | none | replace)</default-operation>
|
</config-text>
|
||||||
<error-option>(stop-on-error | continue-on-error )</error-option>
|
|
||||||
<test-option>(set | test-then-set | test-only)</test-option>
|
|
||||||
<edit-config>
|
|
||||||
|
|
||||||
CLIXON addition:
|
<!- - OR - ->
|
||||||
<filter type="restconf" select="/data/profile=a" />
|
|
||||||
|
<url>
|
||||||
|
<!- - location specifier for file containing data - ->
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<default-operation>(merge | none | replace)</default-operation>
|
||||||
|
<error-option>(stop-on-error | continue-on-error )</error-option>
|
||||||
|
<test-option>(set | test-then-set | test-only)</test-option>
|
||||||
|
<edit-config>
|
||||||
|
|
||||||
|
CLIXON addition:
|
||||||
|
<filter type="restconf" select="/data/profile=a" />
|
||||||
|
|
||||||
*
|
*
|
||||||
* @param[in] h clicon handle
|
* @param[in] h clicon handle
|
||||||
|
|
@ -334,9 +334,9 @@ netconf_edit_config(clixon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
if (optret == 0) /* error in opt parameters */
|
if (optret == 0) /* error in opt parameters */
|
||||||
goto ok;
|
goto ok;
|
||||||
/* These constraints are clixon-specific since :validate should
|
/* These constraints are clixon-specific since :validate should
|
||||||
* support all testopts, and erropts should be supported
|
* support all testopts, and erropts should be supported
|
||||||
* And therefore extends the validation
|
* And therefore extends the validation
|
||||||
* (implement the features before removing these checks)
|
* (implement the features before removing these checks)
|
||||||
*/
|
*/
|
||||||
if (testopt!=TEST_THEN_SET || erropt!=STOP_ON_ERROR){
|
if (testopt!=TEST_THEN_SET || erropt!=STOP_ON_ERROR){
|
||||||
|
|
@ -357,7 +357,7 @@ netconf_edit_config(clixon_handle h,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Get running configuration and device state information
|
/*! Get running configuration and device state information
|
||||||
*
|
*
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
||||||
* @param[out] xret Return XML, error or OK
|
* @param[out] xret Return XML, error or OK
|
||||||
|
|
@ -375,21 +375,21 @@ netconf_get(clixon_handle h,
|
||||||
cxobj *xn,
|
cxobj *xn,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xfilter; /* filter */
|
cxobj *xfilter; /* filter */
|
||||||
char *ftype = NULL;
|
char *ftype = NULL;
|
||||||
cvec *nsc = NULL;
|
cvec *nsc = NULL;
|
||||||
char *prefix = NULL;
|
char *prefix = NULL;
|
||||||
|
|
||||||
if(xml_nsctx_node(xn, &nsc) < 0)
|
if(xml_nsctx_node(xn, &nsc) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Get prefix of netconf base namespace in the incoming message */
|
/* Get prefix of netconf base namespace in the incoming message */
|
||||||
if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){
|
if (xml_nsctx_get_prefix(nsc, NETCONF_BASE_NAMESPACE, &prefix) == 0){
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ie <filter>...</filter> */
|
/* ie <filter>...</filter> */
|
||||||
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
||||||
ftype = xml_find_value(xfilter, "type");
|
ftype = xml_find_value(xfilter, "type");
|
||||||
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
||||||
|
|
@ -405,12 +405,12 @@ netconf_get(clixon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
} else {
|
} else {
|
||||||
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
"<error-type>applicatio</error-type>"
|
"<error-type>applicatio</error-type>"
|
||||||
"<error-severity>error</error-severity>"
|
"<error-severity>error</error-severity>"
|
||||||
"<error-message>filter type not supported</error-message>"
|
"<error-message>filter type not supported</error-message>"
|
||||||
"<error-info>type</error-info>"
|
"<error-info>type</error-info>"
|
||||||
"</rpc-error></rpc-reply>",
|
"</rpc-error></rpc-reply>",
|
||||||
NETCONF_BASE_NAMESPACE);
|
NETCONF_BASE_NAMESPACE);
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
@ -424,16 +424,16 @@ netconf_get(clixon_handle h,
|
||||||
*
|
*
|
||||||
* and this session has registered for that event.
|
* and this session has registered for that event.
|
||||||
* Filter it and forward it.
|
* Filter it and forward it.
|
||||||
<notification>
|
<notification>
|
||||||
<eventTime>2007-07-08T00:01:00Z</eventTime>
|
<eventTime>2007-07-08T00:01:00Z</eventTime>
|
||||||
<event xmlns="http://example.com/event/1.0">
|
<event xmlns="http://example.com/event/1.0">
|
||||||
<eventClass>fault</eventClass>
|
<eventClass>fault</eventClass>
|
||||||
<reportingEntity>
|
<reportingEntity>
|
||||||
<card>Ethernet0</card>
|
<card>Ethernet0</card>
|
||||||
</reportingEntity>
|
</reportingEntity>
|
||||||
<severity>major</severity>
|
<severity>major</severity>
|
||||||
</event>
|
</event>
|
||||||
</notification>
|
</notification>
|
||||||
* @see rfc5277:
|
* @see rfc5277:
|
||||||
* An event notification is sent to the client who initiated a
|
* An event notification is sent to the client who initiated a
|
||||||
* <create-subscription> command asynchronously when an event of
|
* <create-subscription> command asynchronously when an event of
|
||||||
|
|
@ -518,18 +518,18 @@ netconf_notification_cb(int s,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
<create-subscription>
|
<create-subscription>
|
||||||
<stream>RESULT</stream> # If not present, events in the default NETCONF stream will be sent.
|
<stream>RESULT</stream> # If not present, events in the default NETCONF stream will be sent.
|
||||||
<filter type="xpath" select="XPATHEXPR"/>
|
<filter type="xpath" select="XPATHEXPR"/>
|
||||||
<startTime/> # only for replay (NYI)
|
<startTime/> # only for replay (NYI)
|
||||||
<stopTime/> # only for replay (NYI)
|
<stopTime/> # only for replay (NYI)
|
||||||
</create-subscription>
|
</create-subscription>
|
||||||
Dont support replay
|
Dont support replay
|
||||||
* @param[in] h clicon handle
|
* @param[in] h clicon handle
|
||||||
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
||||||
* @param[out] xret Return XML, error or OK
|
* @param[out] xret Return XML, error or OK
|
||||||
* @see netconf_notification_cb for asynchronous stream notifications
|
* @see netconf_notification_cb for asynchronous stream notifications
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
netconf_create_subscription(clixon_handle h,
|
netconf_create_subscription(clixon_handle h,
|
||||||
cxobj *xn,
|
cxobj *xn,
|
||||||
|
|
@ -560,9 +560,9 @@ netconf_create_subscription(clixon_handle h,
|
||||||
if (xpath_first(*xret, NULL, "rpc-reply/rpc-error") != NULL)
|
if (xpath_first(*xret, NULL, "rpc-reply/rpc-error") != NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
if (clixon_event_reg_fd(s,
|
if (clixon_event_reg_fd(s,
|
||||||
netconf_notification_cb,
|
netconf_notification_cb,
|
||||||
h,
|
h,
|
||||||
"notification socket") < 0)
|
"notification socket") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
@ -572,8 +572,8 @@ netconf_create_subscription(clixon_handle h,
|
||||||
|
|
||||||
/*! See if there is any application defined RPC for this tag
|
/*! See if there is any application defined RPC for this tag
|
||||||
*
|
*
|
||||||
* This may either be local client-side or backend. If backend send as netconf
|
* This may either be local client-side or backend. If backend send as netconf
|
||||||
* RPC.
|
* RPC.
|
||||||
* Assume already bound and validated.
|
* Assume already bound and validated.
|
||||||
* @param[in] h clicon handle
|
* @param[in] h clicon handle
|
||||||
* @param[in] xn Sub-tree (under xorig) at child of rpc: <rpc><xn></rpc>.
|
* @param[in] xn Sub-tree (under xorig) at child of rpc: <rpc><xn></rpc>.
|
||||||
|
|
@ -588,17 +588,17 @@ netconf_application_rpc(clixon_handle h,
|
||||||
cxobj *xn,
|
cxobj *xn,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *yspec = NULL; /* application yspec */
|
yang_stmt *yspec = NULL; /* application yspec */
|
||||||
yang_stmt *yrpc = NULL;
|
yang_stmt *yrpc = NULL;
|
||||||
yang_stmt *ymod = NULL;
|
yang_stmt *ymod = NULL;
|
||||||
yang_stmt *youtput;
|
yang_stmt *youtput;
|
||||||
cxobj *xoutput;
|
cxobj *xoutput;
|
||||||
cxobj *xerr = NULL;
|
cxobj *xerr = NULL;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
cbuf *cbret = NULL;
|
cbuf *cbret = NULL;
|
||||||
int ret;
|
int nr = 0;
|
||||||
int nr = 0;
|
int ret;
|
||||||
|
|
||||||
/* First check system / netconf RPC:s */
|
/* First check system / netconf RPC:s */
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
|
|
@ -609,7 +609,7 @@ netconf_application_rpc(clixon_handle h,
|
||||||
clixon_err(OE_UNIX, 0, "cbuf_new");
|
clixon_err(OE_UNIX, 0, "cbuf_new");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Find yang rpc statement, return yang rpc statement if found
|
/* Find yang rpc statement, return yang rpc statement if found
|
||||||
Check application RPC */
|
Check application RPC */
|
||||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||||
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
clixon_err(OE_YANG, ENOENT, "No yang spec");
|
||||||
|
|
@ -647,7 +647,7 @@ netconf_application_rpc(clixon_handle h,
|
||||||
else /* Send to backend */
|
else /* Send to backend */
|
||||||
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Sanity check of outgoing XML
|
/* Sanity check of outgoing XML
|
||||||
* For now, skip outgoing checks.
|
* For now, skip outgoing checks.
|
||||||
* (1) Does not handle <ok/> properly
|
* (1) Does not handle <ok/> properly
|
||||||
* (2) Uncertain how validation errors should be logged/handled
|
* (2) Uncertain how validation errors should be logged/handled
|
||||||
|
|
@ -692,7 +692,7 @@ netconf_application_rpc(clixon_handle h,
|
||||||
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
* @param[in] xn Sub-tree (under xorig) at <rpc>...</rpc> level.
|
||||||
* @param[out] xret Return XML, error or OK
|
* @param[out] xret Return XML, error or OK
|
||||||
* @param[out] eof Set to 1 if pending close socket
|
* @param[out] eof Set to 1 if pending close socket
|
||||||
* @retval 0 OK, can also be netconf error
|
* @retval 0 OK, can also be netconf error
|
||||||
* @retval -1 Error, fatal
|
* @retval -1 Error, fatal
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
|
@ -707,7 +707,7 @@ netconf_rpc_dispatch(clixon_handle h,
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
|
|
||||||
/* Tag username on all incoming requests in case they are forwarded as internal messages
|
/* Tag username on all incoming requests in case they are forwarded as internal messages
|
||||||
* This may be unecesary since not all are forwarded.
|
* This may be unecesary since not all are forwarded.
|
||||||
* It may even be wrong if something else is done with the incoming message?
|
* It may even be wrong if something else is done with the incoming message?
|
||||||
*/
|
*/
|
||||||
if ((username = clicon_username_get(h)) != NULL){
|
if ((username = clicon_username_get(h)) != NULL){
|
||||||
|
|
@ -716,7 +716,7 @@ netconf_rpc_dispatch(clixon_handle h,
|
||||||
}
|
}
|
||||||
/* Many of these calls are now calling generic clicon_rpc_netconf_xml
|
/* Many of these calls are now calling generic clicon_rpc_netconf_xml
|
||||||
* directly, since the validation is generic and done before this place
|
* directly, since the validation is generic and done before this place
|
||||||
* in the call. Some call however need extra validation, such as the
|
* in the call. Some call however need extra validation, such as the
|
||||||
* filter parameter to get/get-config and tes- err-opts of edit-config.
|
* filter parameter to get/get-config and tes- err-opts of edit-config.
|
||||||
*/
|
*/
|
||||||
xe = NULL;
|
xe = NULL;
|
||||||
|
|
@ -782,4 +782,5 @@ netconf_rpc_dispatch(clixon_handle h,
|
||||||
if ((xa = xml_find(xn, "username")) != NULL)
|
if ((xa = xml_find(xn, "username")) != NULL)
|
||||||
xml_purge(xa);
|
xml_purge(xa);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
fcgi_params_set(clixon_handle h,
|
fcgi_params_set(clixon_handle h,
|
||||||
char **envp)
|
char **envp)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -191,10 +191,10 @@ static int session_id_context = 1;
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
restconf_native_handle_set(clixon_handle h,
|
restconf_native_handle_set(clixon_handle h,
|
||||||
restconf_native_handle *rh)
|
restconf_native_handle *rh)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
/* It is the pointer to ys that should be copied by hash,
|
/* It is the pointer to ys that should be copied by hash,
|
||||||
so we send a ptr to the ptr to indicate what to copy.
|
so we send a ptr to the ptr to indicate what to copy.
|
||||||
|
|
@ -204,10 +204,12 @@ restconf_native_handle_set(clixon_handle h,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* util function to append log string
|
/*! util function to append log string
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
print_cb(const char *str, size_t len, void *cb)
|
print_cb(const char *str,
|
||||||
|
size_t len,
|
||||||
|
void *cb)
|
||||||
{
|
{
|
||||||
return cbuf_append_str((cbuf*)cb, (char*)str); /* Assume string */
|
return cbuf_append_str((cbuf*)cb, (char*)str); /* Assume string */
|
||||||
}
|
}
|
||||||
|
|
@ -529,14 +531,14 @@ static int
|
||||||
restconf_accept_client(int fd,
|
restconf_accept_client(int fd,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
restconf_socket *rsock;
|
restconf_socket *rsock;
|
||||||
clixon_handle h;
|
clixon_handle h;
|
||||||
int s = -1;
|
int s = -1;
|
||||||
struct sockaddr from = {0,};
|
struct sockaddr from = {0,};
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
void *addr;
|
void *addr;
|
||||||
|
|
||||||
clixon_debug(CLIXON_DBG_RESTCONF, "%d", fd);
|
clixon_debug(CLIXON_DBG_RESTCONF, "%d", fd);
|
||||||
if ((rsock = (restconf_socket *)arg) == NULL){
|
if ((rsock = (restconf_socket *)arg) == NULL){
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,6 @@ api_data_get2(clixon_handle h,
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Ad-hoc method to determine json pagination request:
|
/* Ad-hoc method to determine json pagination request:
|
||||||
* address list and one of "item/offset/.." is defined
|
* address list and one of "item/offset/.." is defined
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
|
||||||
# Stage 2
|
# Stage 2
|
||||||
# The second step skips the development environment and builds a runtime system
|
# The second step skips the development environment and builds a runtime system
|
||||||
FROM alpine
|
FROM alpine
|
||||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
LABEL maintainer="Olof Hagsand <olof@hagsand.se>"
|
||||||
|
|
||||||
# For clixon and cligen
|
# For clixon and cligen
|
||||||
RUN apk add --update flex bison fcgi-dev
|
RUN apk add --update flex bison fcgi-dev
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
|
||||||
# The second step skips the development environment and builds a runtime system
|
# The second step skips the development environment and builds a runtime system
|
||||||
# 3.20
|
# 3.20
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
LABEL maintainer="Olof Hagsand <olof@hagsand.se>"
|
||||||
|
|
||||||
# For clixon and cligen
|
# For clixon and cligen
|
||||||
RUN apk add --update flex bison openssl
|
RUN apk add --update flex bison openssl
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,8 @@ xml_nsctx_namespace_netconf_default(clixon_handle h)
|
||||||
* @see xml_nsctx_free Free the reutned handle
|
* @see xml_nsctx_free Free the reutned handle
|
||||||
*/
|
*/
|
||||||
cvec *
|
cvec *
|
||||||
xml_nsctx_init(char *prefix,
|
xml_nsctx_init(char *prefix,
|
||||||
char *ns)
|
char *ns)
|
||||||
{
|
{
|
||||||
cvec *cvv = NULL;
|
cvec *cvv = NULL;
|
||||||
|
|
||||||
|
|
@ -194,16 +194,16 @@ xml_nsctx_get_prefix(cvec *cvv,
|
||||||
|
|
||||||
/*! Set or replace namespace in namespace context
|
/*! Set or replace namespace in namespace context
|
||||||
*
|
*
|
||||||
* @param[in] cvv Namespace context
|
* @param[in] cvv Namespace context
|
||||||
* @param[in] prefix Namespace prefix, or NULL for default
|
* @param[in] prefix Namespace prefix, or NULL for default
|
||||||
* @param[in] ns Cached namespace to set (assume non-null?)
|
* @param[in] ns Cached namespace to set (assume non-null?)
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_nsctx_add(cvec *cvv,
|
xml_nsctx_add(cvec *cvv,
|
||||||
char *prefix,
|
char *prefix,
|
||||||
char *ns)
|
char *ns)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cg_var *cv;
|
cg_var *cv;
|
||||||
|
|
@ -219,7 +219,7 @@ xml_nsctx_add(cvec *cvv,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xml_nsctx_node1(cxobj *xn,
|
xml_nsctx_node1(cxobj *xn,
|
||||||
cvec *nsc)
|
cvec *nsc)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xa = NULL;
|
cxobj *xa = NULL;
|
||||||
|
|
@ -546,9 +546,10 @@ xml2ns(cxobj *x,
|
||||||
|
|
||||||
/*! Recursively check prefix / namespaces (and populate ns cache)
|
/*! Recursively check prefix / namespaces (and populate ns cache)
|
||||||
*
|
*
|
||||||
* @retval 1 OK
|
* @param[in] xt XML node
|
||||||
* @retval 0 (Some) prefix not found
|
* @retval 1 OK
|
||||||
* @retval -1 Error
|
* @retval 0 (Some) prefix not found
|
||||||
|
* @retval -1 Error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml2ns_recurse(cxobj *xt)
|
xml2ns_recurse(cxobj *xt)
|
||||||
|
|
|
||||||
|
|
@ -812,7 +812,6 @@ meta_stmt : organization_stmt { _PARSE_DEBUG("meta-stmt -> organization-s
|
||||||
| reference_stmt { _PARSE_DEBUG("meta-stmt -> reference-stmt"); }
|
| reference_stmt { _PARSE_DEBUG("meta-stmt -> reference-stmt"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/* length-stmt */
|
/* length-stmt */
|
||||||
length_stmt : K_LENGTH string ';' /* XXX length-arg-str */
|
length_stmt : K_LENGTH string ';' /* XXX length-arg-str */
|
||||||
{ if (ysp_add(_yy, Y_LENGTH, $2, NULL) == NULL) _YYERROR("length_stmt");
|
{ if (ysp_add(_yy, Y_LENGTH, $2, NULL) == NULL) _YYERROR("length_stmt");
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,8 @@ module clixon-restconf {
|
||||||
leaf debug {
|
leaf debug {
|
||||||
description
|
description
|
||||||
"Set debug level of restconf daemon.
|
"Set debug level of restconf daemon.
|
||||||
0 is no debug, 1 is debugging, more is detailed debug.
|
Debug logs will be directed to log-destination with LOG_DEBUG level (for syslog)
|
||||||
Debug logs will be directed to log-destination with LOG_DEBUG level (for syslog)";
|
Note: must be decimal";
|
||||||
type uint32;
|
type uint32;
|
||||||
default 0;
|
default 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
#
|
#
|
||||||
# Copyright (C) 2017-2019 Olof Hagsand
|
# Copyright (C) 2017-2019 Olof Hagsand
|
||||||
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
# Copyright (C) 2020-2022 Olof Hagsand and Rubicon Communications, LLC(Netgate)
|
||||||
#
|
#
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
# in which case the provisions of the GPL are applicable instead
|
# in which case the provisions of the GPL are applicable instead
|
||||||
# of those above. If you wish to allow use of your version of this file only
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
# under the terms of the GPL, and not to allow others to
|
# under the terms of the GPL, and not to allow others to
|
||||||
# use your version of this file under the terms of Apache License version 2,
|
# use your version of this file under the terms of Apache License version 2,
|
||||||
# indicate your decision by deleting the provisions above and replace them with
|
# indicate your decision by deleting the provisions above and replace them with
|
||||||
# the notice and other provisions required by the GPL. If you do not delete
|
# the notice and other provisions required by the GPL. If you do not delete
|
||||||
# the provisions above, a recipient may use your version of this file under
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
|
@ -67,26 +67,25 @@ YANGSPECS += ietf-origin@2018-02-14.yang
|
||||||
YANGSPECS += ietf-netconf-with-defaults@2011-06-01.yang
|
YANGSPECS += ietf-netconf-with-defaults@2011-06-01.yang
|
||||||
YANGSPECS += ietf-netconf-monitoring@2010-10-04.yang
|
YANGSPECS += ietf-netconf-monitoring@2010-10-04.yang
|
||||||
|
|
||||||
# in draft-ietf-netconf-list-pagination-04.html
|
# IETF list-pagination drafts
|
||||||
YANGSPECS += ietf-list-pagination@2024-07-08.yang
|
YANGSPECS += ietf-list-pagination@2024-10-21.yang
|
||||||
# in draft-ietf-netconf-list-pagination-nc-04
|
YANGSPECS += ietf-list-pagination-nc@2024-10-21.yang
|
||||||
YANGSPECS += ietf-list-pagination-nc@2024-07-08.yang
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f Makefile *~ .depend
|
rm -f Makefile *~ .depend
|
||||||
|
|
||||||
install: $(YANGSPECS)
|
install: $(YANGSPECS)
|
||||||
install -d -m 0755 $(DESTDIR)$(YANG_INSTALLDIR)
|
install -d -m 0755 $(DESTDIR)$(YANG_INSTALLDIR)
|
||||||
install -m 0644 $(YANGSPECS) $(DESTDIR)$(YANG_INSTALLDIR)
|
install -m 0644 $(YANGSPECS) $(DESTDIR)$(YANG_INSTALLDIR)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
(cd $(DESTDIR)$(YANG_INSTALLDIR); rm -rf *.yang)
|
(cd $(DESTDIR)$(YANG_INSTALLDIR); rm -rf *.yang)
|
||||||
|
|
||||||
install-include:
|
install-include:
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue