Structural C-code change: Merged yang_spec and yang_node types into yang_stmt
This commit is contained in:
parent
4f9e942103
commit
b5f1f7346e
52 changed files with 492 additions and 496 deletions
|
|
@ -35,6 +35,9 @@
|
||||||
|
|
||||||
|
|
||||||
### API changes on existing features (you may need to change your code)
|
### API changes on existing features (you may need to change your code)
|
||||||
|
* Structural C-code change: Merged yang_spec and yang_node types into yang_stmt
|
||||||
|
* Change all yn_* and yp_ to ys_*
|
||||||
|
* Change all references to yang_node/yang_spec to yang_stmt
|
||||||
* Structural change: removed datastore plugin and directory, and merged into regulat clixon lib code.
|
* Structural change: removed datastore plugin and directory, and merged into regulat clixon lib code.
|
||||||
* The CLICON_XMLDB_PLUGIN config option is obsolete, you should remove it from your config file
|
* The CLICON_XMLDB_PLUGIN config option is obsolete, you should remove it from your config file
|
||||||
* The datastore directory is removed, code is moved to lib/src/clixon_datastore*.c
|
* The datastore directory is removed, code is moved to lib/src/clixon_datastore*.c
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ backend_client_rm(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
client_get_streams(clicon_handle h,
|
client_get_streams(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
char *module,
|
char *module,
|
||||||
char *top,
|
char *top,
|
||||||
|
|
@ -175,11 +175,11 @@ client_get_streams(clicon_handle h,
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
|
|
||||||
if ((ystream = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL){
|
if ((ystream = yang_find(yspec, Y_MODULE, module)) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "%s yang module not found", module);
|
clicon_err(OE_YANG, 0, "%s yang module not found", module);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((yns = yang_find((yang_node*)ystream, Y_NAMESPACE, NULL)) == NULL){
|
if ((yns = yang_find(ystream, Y_NAMESPACE, NULL)) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
|
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ client_statedata(clicon_handle h,
|
||||||
cxobj **xvec = NULL;
|
cxobj **xvec = NULL;
|
||||||
size_t xlen;
|
size_t xlen;
|
||||||
int i;
|
int i;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||||
|
|
@ -379,7 +379,7 @@ from_client_edit_config(clicon_handle h,
|
||||||
enum operation_type operation = OP_MERGE;
|
enum operation_type operation = OP_MERGE;
|
||||||
int piddb;
|
int piddb;
|
||||||
int non_config = 0;
|
int non_config = 0;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cbuf *cbx = NULL; /* Assist cbuf */
|
cbuf *cbx = NULL; /* Assist cbuf */
|
||||||
int ret;
|
int ret;
|
||||||
char *username;
|
char *username;
|
||||||
|
|
@ -1061,7 +1061,7 @@ from_client_msg(clicon_handle h,
|
||||||
cbuf *cbret = NULL; /* return message */
|
cbuf *cbret = NULL; /* return message */
|
||||||
int ret;
|
int ret;
|
||||||
char *username;
|
char *username;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ye;
|
yang_stmt *ye;
|
||||||
yang_stmt *ymod;
|
yang_stmt *ymod;
|
||||||
cxobj *xnacm = NULL;
|
cxobj *xnacm = NULL;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
generic_validate(yang_spec *yspec,
|
generic_validate(yang_stmt *yspec,
|
||||||
transaction_data_t *td,
|
transaction_data_t *td,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
|
|
@ -168,7 +168,7 @@ startup_common(clicon_handle h,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
int ret;
|
int ret;
|
||||||
modstate_diff_t *msd = NULL;
|
modstate_diff_t *msd = NULL;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
|
|
@ -341,7 +341,7 @@ from_validate_common(clicon_handle h,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
int i;
|
int i;
|
||||||
cxobj *xn;
|
cxobj *xn;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
static int
|
static int
|
||||||
backend_terminate(clicon_handle h)
|
backend_terminate(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
char *pidfile = clicon_backend_pidfile(h);
|
char *pidfile = clicon_backend_pidfile(h);
|
||||||
int sockfamily = clicon_sock_family(h);
|
int sockfamily = clicon_sock_family(h);
|
||||||
char *sockpath = clicon_sock(h);
|
char *sockpath = clicon_sock(h);
|
||||||
|
|
@ -174,7 +174,7 @@ nacm_load_external(clicon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *filename; /* NACM config file */
|
char *filename; /* NACM config file */
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
|
@ -325,8 +325,8 @@ main(int argc,
|
||||||
int sockfamily;
|
int sockfamily;
|
||||||
char *nacm_mode;
|
char *nacm_mode;
|
||||||
int logdst = CLICON_LOG_SYSLOG|CLICON_LOG_STDERR;
|
int logdst = CLICON_LOG_SYSLOG|CLICON_LOG_STDERR;
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
|
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
|
||||||
char *str;
|
char *str;
|
||||||
int ss = -1; /* server socket */
|
int ss = -1; /* server socket */
|
||||||
cbuf *cbret = NULL; /* startup cbuf if invalid */
|
cbuf *cbret = NULL; /* startup cbuf if invalid */
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ clixon_plugin_reset(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_plugin_statedata(clicon_handle h,
|
clixon_plugin_statedata(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ int backend_plugin_initiate(clicon_handle h);
|
||||||
|
|
||||||
int clixon_plugin_reset(clicon_handle h, char *db);
|
int clixon_plugin_reset(clicon_handle h, char *db);
|
||||||
|
|
||||||
int clixon_plugin_statedata(clicon_handle h, yang_spec *yspec, char *xpath, cxobj **xtop);
|
int clixon_plugin_statedata(clicon_handle h, yang_stmt *yspec, char *xpath, cxobj **xtop);
|
||||||
transaction_data_t * transaction_new(void);
|
transaction_data_t * transaction_new(void);
|
||||||
int transaction_free(transaction_data_t *);
|
int transaction_free(transaction_data_t *);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ startup_failsafe(clicon_handle h)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
startup_module_state(clicon_handle h,
|
startup_module_state(clicon_handle h,
|
||||||
yang_spec *yspec)
|
yang_stmt *yspec)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,6 @@ int startup_db_reset(clicon_handle h, char *db);
|
||||||
int startup_mode_startup(clicon_handle h, char *db, cbuf *cbret);
|
int startup_mode_startup(clicon_handle h, char *db, cbuf *cbret);
|
||||||
int startup_extraxml(clicon_handle h, char *file, cbuf *cbret);
|
int startup_extraxml(clicon_handle h, char *file, cbuf *cbret);
|
||||||
int startup_failsafe(clicon_handle h);
|
int startup_failsafe(clicon_handle h);
|
||||||
int startup_module_state(clicon_handle h, yang_spec *yspec);
|
int startup_module_state(clicon_handle h, yang_stmt *yspec);
|
||||||
|
|
||||||
#endif /* _BACKEND_STARTUP_H_ */
|
#endif /* _BACKEND_STARTUP_H_ */
|
||||||
|
|
|
||||||
|
|
@ -213,9 +213,9 @@ cli_dbxml(clicon_handle h,
|
||||||
int len;
|
int len;
|
||||||
cg_var *arg;
|
cg_var *arg;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
||||||
yang_node *y = NULL; /* yang spec of xpath */
|
yang_stmt *y = NULL; /* yang spec of xpath */
|
||||||
cxobj *xtop = NULL; /* xpath root */
|
cxobj *xtop = NULL; /* xpath root */
|
||||||
cxobj *xa; /* attribute */
|
cxobj *xa; /* attribute */
|
||||||
cxobj *xb; /* body */
|
cxobj *xb; /* body */
|
||||||
|
|
@ -243,7 +243,7 @@ cli_dbxml(clicon_handle h,
|
||||||
xml_type_set(xa, CX_ATTR);
|
xml_type_set(xa, CX_ATTR);
|
||||||
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
if (xml_value_set(xa, xml_operation2str(op)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (y->yn_keyword != Y_LIST && y->yn_keyword != Y_LEAF_LIST){
|
if (y->ys_keyword != Y_LIST && y->ys_keyword != Y_LEAF_LIST){
|
||||||
len = cvec_len(cvv);
|
len = cvec_len(cvv);
|
||||||
if (len > 1){
|
if (len > 1){
|
||||||
cval = cvec_i(cvv, len-1);
|
cval = cvec_i(cvv, len-1);
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ yang2cli_var_identityref(yang_stmt *ys,
|
||||||
cprintf(cb, ">");
|
cprintf(cb, ">");
|
||||||
if (helptext)
|
if (helptext)
|
||||||
cprintf(cb, "(\"%s\")", helptext);
|
cprintf(cb, "(\"%s\")", helptext);
|
||||||
if ((ybaseref = yang_find((yang_node*)ytype, Y_BASE, NULL)) != NULL &&
|
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) != NULL &&
|
||||||
(ybaseid = yang_find_identity(ys, ybaseref->ys_argument)) != NULL){
|
(ybaseid = yang_find_identity(ys, ybaseref->ys_argument)) != NULL){
|
||||||
if (cvec_len(ybaseid->ys_cvec) > 0){
|
if (cvec_len(ybaseid->ys_cvec) > 0){
|
||||||
cprintf(cb, "|<%s:%s choice:", ys->ys_argument, cvtypestr);
|
cprintf(cb, "|<%s:%s choice:", ys->ys_argument, cvtypestr);
|
||||||
|
|
@ -329,7 +329,7 @@ yang2cli_var_sub(clicon_handle h,
|
||||||
cprintf(cb, " choice:");
|
cprintf(cb, " choice:");
|
||||||
i = 0;
|
i = 0;
|
||||||
yi = NULL;
|
yi = NULL;
|
||||||
while ((yi = yn_each((yang_node*)ytype, yi)) != NULL){
|
while ((yi = yn_each(ytype, yi)) != NULL){
|
||||||
if (yi->ys_keyword != Y_ENUM && yi->ys_keyword != Y_BIT)
|
if (yi->ys_keyword != Y_ENUM && yi->ys_keyword != Y_BIT)
|
||||||
continue;
|
continue;
|
||||||
if (i)
|
if (i)
|
||||||
|
|
@ -443,7 +443,7 @@ yang2cli_var_union(clicon_handle h,
|
||||||
* not resolved types (unless they are built-in, but the resolve call is
|
* not resolved types (unless they are built-in, but the resolve call is
|
||||||
* made in the union_one call.
|
* made in the union_one call.
|
||||||
*/
|
*/
|
||||||
while ((ytsub = yn_each((yang_node*)ytype, ytsub)) != NULL){
|
while ((ytsub = yn_each(ytype, ytsub)) != NULL){
|
||||||
if (ytsub->ys_keyword != Y_TYPE)
|
if (ytsub->ys_keyword != Y_TYPE)
|
||||||
continue;
|
continue;
|
||||||
if (i++)
|
if (i++)
|
||||||
|
|
@ -563,7 +563,7 @@ yang2cli_leaf(clicon_handle h,
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
/* description */
|
/* description */
|
||||||
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
|
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
|
||||||
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "strdup");
|
clicon_err(OE_UNIX, errno, "strdup");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -618,7 +618,7 @@ yang2cli_container(clicon_handle h,
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
|
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
|
||||||
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
|
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
|
||||||
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "strdup");
|
clicon_err(OE_UNIX, errno, "strdup");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -668,7 +668,7 @@ yang2cli_list(clicon_handle h,
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
|
cprintf(cb, "%*s%s", level*3, "", ys->ys_argument);
|
||||||
if ((yd = yang_find((yang_node*)ys, Y_DESCRIPTION, NULL)) != NULL){
|
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
|
||||||
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
if ((helptext = strdup(yd->ys_argument)) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "strdup");
|
clicon_err(OE_UNIX, errno, "strdup");
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -683,7 +683,7 @@ yang2cli_list(clicon_handle h,
|
||||||
/* Iterate over individual keys */
|
/* Iterate over individual keys */
|
||||||
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
|
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
|
||||||
keyname = cv_string_get(cvi);
|
keyname = cv_string_get(cvi);
|
||||||
if ((yleaf = yang_find((yang_node*)ys, Y_LEAF, keyname)) == NULL){
|
if ((yleaf = yang_find(ys, Y_LEAF, keyname)) == NULL){
|
||||||
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
|
clicon_err(OE_XML, 0, "List statement \"%s\" has no key leaf \"%s\"",
|
||||||
ys->ys_argument, keyname);
|
ys->ys_argument, keyname);
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -836,7 +836,7 @@ yang2cli_stmt(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
yang2cli(clicon_handle h,
|
yang2cli(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
parse_tree *ptnew,
|
parse_tree *ptnew,
|
||||||
enum genmodel_type gt)
|
enum genmodel_type gt)
|
||||||
{
|
{
|
||||||
|
|
@ -851,8 +851,8 @@ yang2cli(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Traverse YANG, loop through all modules and generate CLI */
|
/* Traverse YANG, loop through all modules and generate CLI */
|
||||||
for (i=0; i<yspec->yp_len; i++)
|
for (i=0; i<yspec->ys_len; i++)
|
||||||
if ((ymod = yspec->yp_stmt[i]) != NULL){
|
if ((ymod = yspec->ys_stmt[i]) != NULL){
|
||||||
if (yang2cli_stmt(h, ymod, gt, 0, cb) < 0)
|
if (yang2cli_stmt(h, ymod, gt, 0, cb) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
int yang2cli(clicon_handle h, yang_spec *yspec, parse_tree *ptnew,
|
int yang2cli(clicon_handle h, yang_stmt *yspec, parse_tree *ptnew,
|
||||||
enum genmodel_type gt);
|
enum genmodel_type gt);
|
||||||
|
|
||||||
#endif /* _CLI_GENERATE_H_ */
|
#endif /* _CLI_GENERATE_H_ */
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ cli_history_save(clicon_handle h)
|
||||||
static int
|
static int
|
||||||
cli_terminate(clicon_handle h)
|
cli_terminate(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
||||||
clicon_rpc_close_session(h);
|
clicon_rpc_close_session(h);
|
||||||
|
|
@ -279,8 +279,8 @@ main(int argc, char **argv)
|
||||||
int help = 0;
|
int help = 0;
|
||||||
int logdst = CLICON_LOG_STDERR;
|
int logdst = CLICON_LOG_STDERR;
|
||||||
char *restarg = NULL; /* what remains after options */
|
char *restarg = NULL; /* what remains after options */
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
|
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,10 +112,10 @@ expand_dbvar(void *h,
|
||||||
int j;
|
int j;
|
||||||
int k;
|
int k;
|
||||||
cg_var *cv;
|
cg_var *cv;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xtop = NULL; /* xpath root */
|
cxobj *xtop = NULL; /* xpath root */
|
||||||
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
cxobj *xbot = NULL; /* xpath, NULL if datastore */
|
||||||
yang_node *y = NULL; /* yang spec of xpath */
|
yang_stmt *y = NULL; /* yang spec of xpath */
|
||||||
yang_stmt *ytype;
|
yang_stmt *ytype;
|
||||||
yang_stmt *ypath;
|
yang_stmt *ypath;
|
||||||
cxobj *xcur;
|
cxobj *xcur;
|
||||||
|
|
@ -183,9 +183,9 @@ expand_dbvar(void *h,
|
||||||
* Here the whole syntax tree is loaded, and it would be better to offload
|
* Here the whole syntax tree is loaded, and it would be better to offload
|
||||||
* such operations to the datastore by a generic xpath function.
|
* such operations to the datastore by a generic xpath function.
|
||||||
*/
|
*/
|
||||||
if ((ytype = yang_find((yang_node*)y, Y_TYPE, NULL)) != NULL)
|
if ((ytype = yang_find(y, Y_TYPE, NULL)) != NULL)
|
||||||
if (strcmp(ytype->ys_argument, "leafref")==0){
|
if (strcmp(ytype->ys_argument, "leafref")==0){
|
||||||
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
|
if ((ypath = yang_find(ytype, Y_PATH, NULL)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "Leafref %s requires path statement", ytype->ys_argument);
|
clicon_err(OE_DB, 0, "Leafref %s requires path statement", ytype->ys_argument);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -394,17 +394,17 @@ show_yang(clicon_handle h,
|
||||||
cvec *cvv,
|
cvec *cvv,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
yang_node *yn;
|
yang_stmt *yn;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if (cvec_len(argv) > 0){
|
if (cvec_len(argv) > 0){
|
||||||
str = cv_string_get(cvec_i(argv, 0));
|
str = cv_string_get(cvec_i(argv, 0));
|
||||||
yn = (yang_node*)yang_find((yang_node*)yspec, 0, str);
|
yn = yang_find(yspec, 0, str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yn = (yang_node*)yspec;
|
yn = yspec;
|
||||||
yang_print(stdout, yn);
|
yang_print(stdout, yn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -443,7 +443,7 @@ cli_show_config(clicon_handle h,
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
cxobj *xerr;
|
cxobj *xerr;
|
||||||
enum genmodel_type gt;
|
enum genmodel_type gt;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
if (cvec_len(argv) != 3 && cvec_len(argv) != 4){
|
if (cvec_len(argv) != 3 && cvec_len(argv) != 4){
|
||||||
clicon_err(OE_PLUGIN, 0, "Got %d arguments. Expected: <dbname>,<format>,<xpath>[,<attr>]", cvec_len(argv));
|
clicon_err(OE_PLUGIN, 0, "Got %d arguments. Expected: <dbname>,<format>,<xpath>[,<attr>]", cvec_len(argv));
|
||||||
|
|
@ -622,7 +622,7 @@ cli_show_auto(clicon_handle h,
|
||||||
cvec *argv)
|
cvec *argv)
|
||||||
{
|
{
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
char *api_path_fmt; /* xml key format */
|
char *api_path_fmt; /* xml key format */
|
||||||
// char *api_path = NULL; /* xml key */
|
// char *api_path = NULL; /* xml key */
|
||||||
char *db;
|
char *db;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ netconf_input_packet(clicon_handle h,
|
||||||
cxobj *xret = NULL; /* Return (out) */
|
cxobj *xret = NULL; /* Return (out) */
|
||||||
cxobj *xrpc;
|
cxobj *xrpc;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
int ret;
|
int ret;
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
cxobj *xa2;
|
cxobj *xa2;
|
||||||
|
|
@ -290,7 +290,7 @@ send_hello(clicon_handle h,
|
||||||
static int
|
static int
|
||||||
netconf_terminate(clicon_handle h)
|
netconf_terminate(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
|
|
||||||
clixon_plugin_exit(h);
|
clixon_plugin_exit(h);
|
||||||
|
|
@ -357,8 +357,8 @@ main(int argc,
|
||||||
int logdst = CLICON_LOG_STDERR;
|
int logdst = CLICON_LOG_STDERR;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct timeval tv = {0,}; /* timeout */
|
struct timeval tv = {0,}; /* timeout */
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
|
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
/* Create handle */
|
/* Create handle */
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ netconf_notification_cb(int s,
|
||||||
cxobj *xn = NULL; /* event xml */
|
cxobj *xn = NULL; /* event xml */
|
||||||
cxobj *xt = NULL; /* top xml */
|
cxobj *xt = NULL; /* top xml */
|
||||||
clicon_handle h = (clicon_handle)arg;
|
clicon_handle h = (clicon_handle)arg;
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
|
|
||||||
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) */
|
||||||
|
|
@ -541,7 +541,7 @@ netconf_application_rpc(clicon_handle h,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *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 *yinput;
|
yang_stmt *yinput;
|
||||||
|
|
@ -579,11 +579,11 @@ netconf_application_rpc(clicon_handle h,
|
||||||
"</rpc-error></rpc-reply>", xml_name(xn));
|
"</rpc-error></rpc-reply>", xml_name(xn));
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(xn));
|
yrpc = yang_find(ymod, Y_RPC, xml_name(xn));
|
||||||
/* Check if found */
|
/* Check if found */
|
||||||
if (yrpc != NULL){
|
if (yrpc != NULL){
|
||||||
/* 1. Check xn arguments with input statement. */
|
/* 1. Check xn arguments with input statement. */
|
||||||
if ((yinput = yang_find((yang_node*)yrpc, Y_INPUT, NULL)) != NULL){
|
if ((yinput = yang_find(yrpc, Y_INPUT, NULL)) != NULL){
|
||||||
xml_spec_set(xn, yinput); /* needed for xml_spec_populate */
|
xml_spec_set(xn, yinput); /* needed for xml_spec_populate */
|
||||||
if (xml_apply(xn, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
if (xml_apply(xn, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -616,7 +616,7 @@ netconf_application_rpc(clicon_handle h,
|
||||||
* (2) Uncertain how validation errors should be logged/handled
|
* (2) Uncertain how validation errors should be logged/handled
|
||||||
*/
|
*/
|
||||||
if (0)
|
if (0)
|
||||||
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL){
|
if ((youtput = yang_find(yrpc, Y_OUTPUT, NULL)) != NULL){
|
||||||
xoutput=xpath_first(*xret, "/");
|
xoutput=xpath_first(*xret, "/");
|
||||||
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
|
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
|
||||||
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
||||||
|
|
|
||||||
|
|
@ -478,7 +478,7 @@ api_return_err(clicon_handle h,
|
||||||
int
|
int
|
||||||
restconf_terminate(clicon_handle h)
|
restconf_terminate(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
int fs; /* fgcx socket */
|
int fs; /* fgcx socket */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -521,8 +521,8 @@ main(int argc,
|
||||||
clicon_handle h;
|
clicon_handle h;
|
||||||
char *dir;
|
char *dir;
|
||||||
int logdst = CLICON_LOG_SYSLOG;
|
int logdst = CLICON_LOG_SYSLOG;
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
yang_spec *yspecfg = NULL; /* For config XXX clixon bug */
|
yang_stmt *yspecfg = NULL; /* For config XXX clixon bug */
|
||||||
char *stream_path;
|
char *stream_path;
|
||||||
int finish;
|
int finish;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ api_data_get2(clicon_handle h,
|
||||||
cbuf *cbpath = NULL;
|
cbuf *cbpath = NULL;
|
||||||
char *path;
|
char *path;
|
||||||
cbuf *cbx = NULL;
|
cbuf *cbx = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
cxobj *xerr = NULL; /* malloced */
|
cxobj *xerr = NULL; /* malloced */
|
||||||
cxobj *xe = NULL;
|
cxobj *xe = NULL;
|
||||||
|
|
@ -443,8 +443,8 @@ api_data_post(clicon_handle h,
|
||||||
cxobj *xtop = NULL; /* xpath root */
|
cxobj *xtop = NULL; /* xpath root */
|
||||||
cxobj *xbot = NULL;
|
cxobj *xbot = NULL;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
yang_node *y = NULL;
|
yang_stmt *y = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
cxobj *xretcom = NULL; /* return from commit */
|
cxobj *xretcom = NULL; /* return from commit */
|
||||||
|
|
@ -710,8 +710,8 @@ api_data_put(clicon_handle h,
|
||||||
cxobj *xbot = NULL;
|
cxobj *xbot = NULL;
|
||||||
cxobj *xparent;
|
cxobj *xparent;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
yang_node *y = NULL;
|
yang_stmt *y = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
char *api_path;
|
char *api_path;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
|
|
@ -847,7 +847,7 @@ api_data_put(clicon_handle h,
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
/* If list or leaf-list, api-path keys must match data keys */
|
/* If list or leaf-list, api-path keys must match data keys */
|
||||||
if (y && (y->yn_keyword == Y_LIST ||y->yn_keyword == Y_LEAF_LIST)){
|
if (y && (y->ys_keyword == Y_LIST ||y->ys_keyword == Y_LEAF_LIST)){
|
||||||
if (match_list_keys((yang_stmt*)y, x, xbot) < 0){
|
if (match_list_keys((yang_stmt*)y, x, xbot) < 0){
|
||||||
if (netconf_operation_failed_xml(&xerr, "protocol", "api-path keys do not match data keys") < 0)
|
if (netconf_operation_failed_xml(&xerr, "protocol", "api-path keys do not match data keys") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -988,8 +988,8 @@ api_data_delete(clicon_handle h,
|
||||||
cxobj *xbot = NULL;
|
cxobj *xbot = NULL;
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
cbuf *cbx = NULL;
|
cbuf *cbx = NULL;
|
||||||
yang_node *y = NULL;
|
yang_stmt *y = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
enum operation_type op = OP_DELETE;
|
enum operation_type op = OP_DELETE;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
cxobj *xretcom = NULL; /* return from commmit */
|
cxobj *xretcom = NULL; /* return from commmit */
|
||||||
|
|
@ -1128,7 +1128,7 @@ api_operations_get(clicon_handle h,
|
||||||
int use_xml)
|
int use_xml)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ymod; /* yang module */
|
yang_stmt *ymod; /* yang module */
|
||||||
yang_stmt *yc;
|
yang_stmt *yc;
|
||||||
char *namespace;
|
char *namespace;
|
||||||
|
|
@ -1146,10 +1146,10 @@ api_operations_get(clicon_handle h,
|
||||||
cprintf(cbx, "{\"operations\": {");
|
cprintf(cbx, "{\"operations\": {");
|
||||||
ymod = NULL;
|
ymod = NULL;
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((ymod = yn_each((yang_node*)yspec, ymod)) != NULL) {
|
while ((ymod = yn_each(yspec, ymod)) != NULL) {
|
||||||
namespace = yang_find_mynamespace(ymod);
|
namespace = yang_find_mynamespace(ymod);
|
||||||
yc = NULL;
|
yc = NULL;
|
||||||
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
|
while ((yc = yn_each(ymod, yc)) != NULL) {
|
||||||
if (yc->ys_keyword != Y_RPC)
|
if (yc->ys_keyword != Y_RPC)
|
||||||
continue;
|
continue;
|
||||||
if (use_xml)
|
if (use_xml)
|
||||||
|
|
@ -1207,7 +1207,7 @@ static int
|
||||||
api_operations_post_input(clicon_handle h,
|
api_operations_post_input(clicon_handle h,
|
||||||
FCGX_Request *r,
|
FCGX_Request *r,
|
||||||
char *data,
|
char *data,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
yang_stmt *yrpc,
|
yang_stmt *yrpc,
|
||||||
cxobj *xrpc,
|
cxobj *xrpc,
|
||||||
int pretty,
|
int pretty,
|
||||||
|
|
@ -1342,7 +1342,7 @@ static int
|
||||||
api_operations_post_output(clicon_handle h,
|
api_operations_post_output(clicon_handle h,
|
||||||
FCGX_Request *r,
|
FCGX_Request *r,
|
||||||
cxobj *xret,
|
cxobj *xret,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
yang_stmt *youtput,
|
yang_stmt *youtput,
|
||||||
char *namespace,
|
char *namespace,
|
||||||
int pretty,
|
int pretty,
|
||||||
|
|
@ -1511,14 +1511,14 @@ api_operations_post(clicon_handle h,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int i;
|
int i;
|
||||||
char *oppath = path;
|
char *oppath = path;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *youtput = NULL;
|
yang_stmt *youtput = NULL;
|
||||||
yang_stmt *yrpc = NULL;
|
yang_stmt *yrpc = NULL;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
cxobj *xerr = NULL; /* malloced must be freed */
|
cxobj *xerr = NULL; /* malloced must be freed */
|
||||||
cxobj *xtop = NULL; /* xpath root */
|
cxobj *xtop = NULL; /* xpath root */
|
||||||
cxobj *xbot = NULL;
|
cxobj *xbot = NULL;
|
||||||
yang_node *y = NULL;
|
yang_stmt *y = NULL;
|
||||||
cxobj *xoutput = NULL;
|
cxobj *xoutput = NULL;
|
||||||
cxobj *xa;
|
cxobj *xa;
|
||||||
cxobj *xe;
|
cxobj *xe;
|
||||||
|
|
@ -1561,7 +1561,7 @@ api_operations_post(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
if (nodeid_split(oppath+1, &prefix, &id) < 0) /* +1 skip / */
|
if (nodeid_split(oppath+1, &prefix, &id) < 0) /* +1 skip / */
|
||||||
goto done;
|
goto done;
|
||||||
if ((ys = yang_find((yang_node*)yspec, Y_MODULE, prefix)) == NULL){
|
if ((ys = yang_find(yspec, Y_MODULE, prefix)) == NULL){
|
||||||
if (netconf_operation_failed_xml(&xerr, "protocol", "yang module not found") < 0)
|
if (netconf_operation_failed_xml(&xerr, "protocol", "yang module not found") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
|
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
|
||||||
|
|
@ -1572,7 +1572,7 @@ api_operations_post(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
if ((yrpc = yang_find((yang_node*)ys, Y_RPC, id)) == NULL){
|
if ((yrpc = yang_find(ys, Y_RPC, id)) == NULL){
|
||||||
if (netconf_missing_element_xml(&xerr, "application", id, "RPC not defined") < 0)
|
if (netconf_missing_element_xml(&xerr, "application", id, "RPC not defined") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
|
if ((xe = xpath_first(xerr, "rpc-error")) == NULL){
|
||||||
|
|
@ -1704,7 +1704,7 @@ api_operations_post(clicon_handle h,
|
||||||
clicon_debug(1, "%s 8. Receive reply:%s", __FUNCTION__, cbuf_get(ccc));
|
clicon_debug(1, "%s 8. Receive reply:%s", __FUNCTION__, cbuf_get(ccc));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL);
|
youtput = yang_find(yrpc, Y_OUTPUT, NULL);
|
||||||
if ((ret = api_operations_post_output(h, r, xret, yspec, youtput, namespace,
|
if ((ret = api_operations_post_output(h, r, xret, yspec, youtput, namespace,
|
||||||
pretty, use_xml, &xoutput)) < 0)
|
pretty, use_xml, &xoutput)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ upgrade_2016(clicon_handle h,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ym;
|
yang_stmt *ym;
|
||||||
cxobj **vec = NULL;
|
cxobj **vec = NULL;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
|
|
@ -384,7 +384,7 @@ upgrade_2018(clicon_handle h,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ym;
|
yang_stmt *ym;
|
||||||
cxobj **vec = NULL;
|
cxobj **vec = NULL;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
|
|
|
||||||
|
|
@ -58,14 +58,14 @@ typedef struct {
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
yang_spec * clicon_dbspec_yang(clicon_handle h);
|
yang_stmt * clicon_dbspec_yang(clicon_handle h);
|
||||||
int clicon_dbspec_yang_set(clicon_handle h, struct yang_spec *ys);
|
int clicon_dbspec_yang_set(clicon_handle h, yang_stmt *ys);
|
||||||
|
|
||||||
cxobj * clicon_nacm_ext(clicon_handle h);
|
cxobj * clicon_nacm_ext(clicon_handle h);
|
||||||
int clicon_nacm_ext_set(clicon_handle h, cxobj *xn);
|
int clicon_nacm_ext_set(clicon_handle h, cxobj *xn);
|
||||||
|
|
||||||
yang_spec * clicon_config_yang(clicon_handle h);
|
yang_stmt * clicon_config_yang(clicon_handle h);
|
||||||
int clicon_config_yang_set(clicon_handle h, struct yang_spec *ys);
|
int clicon_config_yang_set(clicon_handle h, yang_stmt *ys);
|
||||||
|
|
||||||
cxobj *clicon_conf_xml(clicon_handle h);
|
cxobj *clicon_conf_xml(clicon_handle h);
|
||||||
int clicon_conf_xml_set(clicon_handle h, cxobj *x);
|
int clicon_conf_xml_set(clicon_handle h, cxobj *x);
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ int xml2json_cbuf(cbuf *cb, cxobj *x, int pretty);
|
||||||
int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty);
|
int xml2json_cbuf_vec(cbuf *cb, cxobj **vec, size_t veclen, int pretty);
|
||||||
int xml2json(FILE *f, cxobj *x, int pretty);
|
int xml2json(FILE *f, cxobj *x, int pretty);
|
||||||
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty);
|
int xml2json_vec(FILE *f, cxobj **vec, size_t veclen, int pretty);
|
||||||
int json2xml_ns(yang_spec *yspec, cxobj *x, cxobj **xerr);
|
int json2xml_ns(yang_stmt *yspec, cxobj *x, cxobj **xerr);
|
||||||
int json_parse_str(char *str, cxobj **xt);
|
int json_parse_str(char *str, cxobj **xt);
|
||||||
int json_parse_file(int fd, yang_spec *yspec, cxobj **xt);
|
int json_parse_file(int fd, yang_stmt *yspec, cxobj **xt);
|
||||||
|
|
||||||
#endif /* _CLIXON_JSON_H */
|
#endif /* _CLIXON_JSON_H */
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ int netconf_operation_failed(cbuf *cb, char *type, char *message);
|
||||||
int netconf_operation_failed_xml(cxobj **xret, char *type, char *message);
|
int netconf_operation_failed_xml(cxobj **xret, char *type, char *message);
|
||||||
int netconf_malformed_message(cbuf *cb, char *message);
|
int netconf_malformed_message(cbuf *cb, char *message);
|
||||||
int netconf_malformed_message_xml(cxobj **xret, char *message);
|
int netconf_malformed_message_xml(cxobj **xret, char *message);
|
||||||
int netconf_trymerge(cxobj *x, yang_spec *yspec, cxobj **xret);
|
int netconf_trymerge(cxobj *x, yang_stmt *yspec, cxobj **xret);
|
||||||
int netconf_module_load(clicon_handle h);
|
int netconf_module_load(clicon_handle h);
|
||||||
char *netconf_db_find(cxobj *xn, char *name);
|
char *netconf_db_find(cxobj *xn, char *name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ int clicon_option_dump(clicon_handle h, int dblevel);
|
||||||
int clicon_option_add(clicon_handle h, char *name, char *value);
|
int clicon_option_add(clicon_handle h, char *name, char *value);
|
||||||
|
|
||||||
/* Initialize options: set defaults, read config-file, etc */
|
/* Initialize options: set defaults, read config-file, etc */
|
||||||
int clicon_options_main(clicon_handle h, yang_spec *yspec);
|
int clicon_options_main(clicon_handle h, yang_stmt *yspec);
|
||||||
|
|
||||||
/*! Check if a clicon option has a value */
|
/*! Check if a clicon option has a value */
|
||||||
int clicon_option_exists(clicon_handle h, const char *name);
|
int clicon_option_exists(clicon_handle h, const char *name);
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct clicon_msg *clicon_msg_encode(char *format, ...) __attribute__ ((format (
|
||||||
#else
|
#else
|
||||||
struct clicon_msg *clicon_msg_encode(char *format, ...);
|
struct clicon_msg *clicon_msg_encode(char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
int clicon_msg_decode(struct clicon_msg *msg, yang_spec *yspec, cxobj **xml);
|
int clicon_msg_decode(struct clicon_msg *msg, yang_stmt *yspec, cxobj **xml);
|
||||||
|
|
||||||
int clicon_connect_unix(char *sockpath);
|
int clicon_connect_unix(char *sockpath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,12 @@ int xml_free(cxobj *xn);
|
||||||
int xml_print(FILE *f, cxobj *xn);
|
int xml_print(FILE *f, cxobj *xn);
|
||||||
int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint);
|
int clicon_xml2file(FILE *f, cxobj *xn, int level, int prettyprint);
|
||||||
int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint);
|
int clicon_xml2cbuf(cbuf *xf, cxobj *xn, int level, int prettyprint);
|
||||||
int xml_parse_file(int fd, char *endtag, yang_spec *yspec, cxobj **xt);
|
int xml_parse_file(int fd, char *endtag, yang_stmt *yspec, cxobj **xt);
|
||||||
int xml_parse_string(const char *str, yang_spec *yspec, cxobj **xml_top);
|
int xml_parse_string(const char *str, yang_stmt *yspec, cxobj **xml_top);
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||||
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
|
||||||
#else
|
#else
|
||||||
int xml_parse_va(cxobj **xt, yang_spec *yspec, const char *format, ...);
|
int xml_parse_va(cxobj **xt, yang_stmt *yspec, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
|
int xmltree2cbuf(cbuf *cb, cxobj *x, int level);
|
||||||
int xml_copy_one(cxobj *xn0, cxobj *xn1);
|
int xml_copy_one(cxobj *xn0, cxobj *xn1);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ int xml_yang_validate_all(cxobj *xt, cbuf *cbret);
|
||||||
int xml_yang_validate_all_top(cxobj *xt, cbuf *cbret);
|
int xml_yang_validate_all_top(cxobj *xt, cbuf *cbret);
|
||||||
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);
|
int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0);
|
||||||
int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0);
|
int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0);
|
||||||
int xml_diff(yang_spec *yspec, cxobj *xt1, cxobj *xt2,
|
int xml_diff(yang_stmt *yspec, cxobj *xt1, cxobj *xt2,
|
||||||
cxobj ***first, size_t *firstlen,
|
cxobj ***first, size_t *firstlen,
|
||||||
cxobj ***second, size_t *secondlen,
|
cxobj ***second, size_t *secondlen,
|
||||||
cxobj ***changed1, cxobj ***changed2, size_t *changedlen);
|
cxobj ***changed1, cxobj ***changed2, size_t *changedlen);
|
||||||
|
|
@ -63,12 +63,12 @@ int xml_tree_prune_flagged(cxobj *xt, int flag, int test);
|
||||||
int xml_default(cxobj *x, void *arg);
|
int xml_default(cxobj *x, void *arg);
|
||||||
int xml_sanity(cxobj *x, void *arg);
|
int xml_sanity(cxobj *x, void *arg);
|
||||||
int xml_non_config_data(cxobj *xt, void *arg);
|
int xml_non_config_data(cxobj *xt, void *arg);
|
||||||
int xml_spec_populate_rpc(clicon_handle h, cxobj *x, yang_spec *yspec);
|
int xml_spec_populate_rpc(clicon_handle h, cxobj *x, yang_stmt *yspec);
|
||||||
int xml_spec_populate(cxobj *x, void *arg);
|
int xml_spec_populate(cxobj *x, void *arg);
|
||||||
int api_path2xpath(yang_spec *yspec, cvec *cvv, int offset, cbuf *xpath);
|
int api_path2xpath(yang_stmt *yspec, cvec *cvv, int offset, cbuf *xpath);
|
||||||
int api_path2xml(char *api_path, yang_spec *yspec, cxobj *xtop,
|
int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop,
|
||||||
yang_class nodeclass, cxobj **xpathp, yang_node **ypathp);
|
yang_class nodeclass, cxobj **xpathp, yang_stmt **ypathp);
|
||||||
int xml_merge(cxobj *x0, cxobj *x1, yang_spec *yspec, char **reason);
|
int xml_merge(cxobj *x0, cxobj *x1, yang_stmt *yspec, char **reason);
|
||||||
int yang_enum_int_value(cxobj *node, int32_t *val);
|
int yang_enum_int_value(cxobj *node, int32_t *val);
|
||||||
|
|
||||||
#endif /* _CLIXON_XML_MAP_H_ */
|
#endif /* _CLIXON_XML_MAP_H_ */
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
int xml_child_spec(cxobj *x, cxobj *xp, yang_spec *yspec, yang_stmt **yp);
|
int xml_child_spec(cxobj *x, cxobj *xp, yang_stmt *yspec, yang_stmt **yp);
|
||||||
int xml_sort(cxobj *x0, void *arg);
|
int xml_sort(cxobj *x0, void *arg);
|
||||||
cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval);
|
cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval);
|
||||||
int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword,
|
int xml_insert_pos(cxobj *x0, char *name, int yangi, enum rfc_6020 keyword,
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ typedef struct yang_type_cache yang_type_cache;
|
||||||
struct yang_stmt{
|
struct yang_stmt{
|
||||||
int ys_len; /* Number of children */
|
int ys_len; /* Number of children */
|
||||||
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
|
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
|
||||||
struct yang_node *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
||||||
enum rfc_6020 ys_keyword; /* See clicon_yang_parse.tab.h */
|
enum rfc_6020 ys_keyword; /* See clicon_yang_parse.tab.h */
|
||||||
|
|
||||||
char *ys_argument; /* String / argument depending on keyword */
|
char *ys_argument; /* String / argument depending on keyword */
|
||||||
|
|
@ -220,68 +220,64 @@ struct yang_stmt{
|
||||||
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
|
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! top-level yang parse-tree */
|
#if 0 /* Backward compatible */
|
||||||
struct yang_spec{
|
typedef struct yang_stmt yang_node;
|
||||||
int yp_len; /* Number of children */
|
typedef struct yang_stmt yang_spec;
|
||||||
struct yang_stmt **yp_stmt; /* Vector of children statement pointers */
|
|
||||||
struct yang_node *yp_parent; /* Backpointer to parent: always NULL. See yang_stmt */
|
|
||||||
enum rfc_6020 yp_keyword; /* SHOULD BE Y_SPEC */
|
|
||||||
char *yp_argument; /* XXX String / argument depending on keyword */
|
|
||||||
int yp_flags; /* Flags according to YANG_FLAG_* above */
|
|
||||||
};
|
|
||||||
typedef struct yang_spec yang_spec;
|
|
||||||
|
|
||||||
/*! super-class of yang_stmt and yang_spec: it must start exactly as those two classes */
|
#define yn_len ys_len
|
||||||
struct yang_node{
|
#define yn_stmt ys_stmt
|
||||||
int yn_len; /* Number of children */
|
#define yn_parent ys_parent
|
||||||
struct yang_stmt **yn_stmt; /* Vector of children statement pointers */
|
#define yn_keyword ys_keyword
|
||||||
struct yang_node *yn_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
#define yn_argument ys_argument
|
||||||
enum rfc_6020 yn_keyword; /* See clicon_yang_parse.tab.h */
|
#define yn_flags ys_flags
|
||||||
char *yn_argument; /* XXX String / argument depending on keyword */
|
#define yp_len ys_len
|
||||||
int yn_flags; /* Flags according to YANG_FLAG_* above */
|
#define yp_stmt ys_stmt
|
||||||
};
|
#define yp_parent ys_parent
|
||||||
typedef struct yang_node yang_node;
|
#define yp_keyword ys_keyword
|
||||||
|
#define yp_argument ys_argument
|
||||||
|
#define yp_flags ys_flags
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
|
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*/
|
*/
|
||||||
yang_spec *yspec_new(void);
|
yang_stmt *yspec_new(void);
|
||||||
yang_stmt *ys_new(enum rfc_6020 keyw);
|
yang_stmt *ys_new(enum rfc_6020 keyw);
|
||||||
int ys_free(yang_stmt *ys);
|
int ys_free(yang_stmt *ys);
|
||||||
int yspec_free(yang_spec *yspec);
|
int yspec_free(yang_stmt *yspec);
|
||||||
int ys_cp(yang_stmt *new, yang_stmt *old);
|
int ys_cp(yang_stmt *new, yang_stmt *old);
|
||||||
yang_stmt *ys_dup(yang_stmt *old);
|
yang_stmt *ys_dup(yang_stmt *old);
|
||||||
int yn_insert(yang_node *yn_parent, yang_stmt *ys_child);
|
int yn_insert(yang_stmt *ys_parent, yang_stmt *ys_child);
|
||||||
yang_stmt *yn_each(yang_node *yn, yang_stmt *ys);
|
yang_stmt *yn_each(yang_stmt *yn, yang_stmt *ys);
|
||||||
char *yang_key2str(int keyword);
|
char *yang_key2str(int keyword);
|
||||||
char *yarg_prefix(yang_stmt *ys);
|
char *yarg_prefix(yang_stmt *ys);
|
||||||
char *yarg_id(yang_stmt *ys);
|
char *yarg_id(yang_stmt *ys);
|
||||||
int ys_module_by_xml(yang_spec *ysp, struct xml *xt, yang_stmt **ymodp);
|
int ys_module_by_xml(yang_stmt *ysp, struct xml *xt, yang_stmt **ymodp);
|
||||||
yang_stmt *ys_module(yang_stmt *ys);
|
yang_stmt *ys_module(yang_stmt *ys);
|
||||||
yang_spec *ys_spec(yang_stmt *ys);
|
yang_stmt *ys_spec(yang_stmt *ys);
|
||||||
yang_stmt *yang_find_module_by_prefix(yang_stmt *ys, char *prefix);
|
yang_stmt *yang_find_module_by_prefix(yang_stmt *ys, char *prefix);
|
||||||
yang_stmt *yang_find_module_by_namespace(yang_spec *yspec, char *namespace);
|
yang_stmt *yang_find_module_by_namespace(yang_stmt *yspec, char *namespace);
|
||||||
yang_stmt *yang_find_module_by_name(yang_spec *yspec, char *name);
|
yang_stmt *yang_find_module_by_name(yang_stmt *yspec, char *name);
|
||||||
yang_stmt *yang_find(yang_node *yn, int keyword, const char *argument);
|
yang_stmt *yang_find(yang_stmt *yn, int keyword, const char *argument);
|
||||||
int yang_match(yang_node *yn, int keyword, char *argument);
|
int yang_match(yang_stmt *yn, int keyword, char *argument);
|
||||||
yang_stmt *yang_find_datanode(yang_node *yn, char *argument);
|
yang_stmt *yang_find_datanode(yang_stmt *yn, char *argument);
|
||||||
yang_stmt *yang_find_schemanode(yang_node *yn, char *argument);
|
yang_stmt *yang_find_schemanode(yang_stmt *yn, char *argument);
|
||||||
char *yang_find_myprefix(yang_stmt *ys);
|
char *yang_find_myprefix(yang_stmt *ys);
|
||||||
char *yang_find_mynamespace(yang_stmt *ys);
|
char *yang_find_mynamespace(yang_stmt *ys);
|
||||||
yang_node *yang_choice(yang_stmt *y);
|
yang_stmt *yang_choice(yang_stmt *y);
|
||||||
int yang_order(yang_stmt *y);
|
int yang_order(yang_stmt *y);
|
||||||
int yang_print(FILE *f, yang_node *yn);
|
int yang_print(FILE *f, yang_stmt *yn);
|
||||||
int yang_print_cbuf(cbuf *cb, yang_node *yn, int marginal);
|
int yang_print_cbuf(cbuf *cb, yang_stmt *yn, int marginal);
|
||||||
int ys_populate(yang_stmt *ys, void *arg);
|
int ys_populate(yang_stmt *ys, void *arg);
|
||||||
yang_stmt *yang_parse_file(int fd, const char *name, yang_spec *ysp);
|
yang_stmt *yang_parse_file(int fd, const char *name, yang_stmt *ysp);
|
||||||
int yang_apply(yang_node *yn, enum rfc_6020 key, yang_applyfn_t fn,
|
int yang_apply(yang_stmt *yn, enum rfc_6020 key, yang_applyfn_t fn,
|
||||||
void *arg);
|
void *arg);
|
||||||
int yang_abs_schema_nodeid(yang_spec *yspec, yang_stmt *ys,
|
int yang_abs_schema_nodeid(yang_stmt *yspec, yang_stmt *ys,
|
||||||
char *schema_nodeid,
|
char *schema_nodeid,
|
||||||
enum rfc_6020 keyword, yang_stmt **yres);
|
enum rfc_6020 keyword, yang_stmt **yres);
|
||||||
int yang_desc_schema_nodeid(yang_node *yn, char *schema_nodeid,
|
int yang_desc_schema_nodeid(yang_stmt *yn, char *schema_nodeid,
|
||||||
enum rfc_6020 keyword, yang_stmt **yres);
|
enum rfc_6020 keyword, yang_stmt **yres);
|
||||||
int ys_parse_date_arg(char *datearg, uint32_t *dateint);
|
int ys_parse_date_arg(char *datearg, uint32_t *dateint);
|
||||||
|
|
||||||
|
|
@ -290,10 +286,10 @@ int ys_parse_sub(yang_stmt *ys, char *extra);
|
||||||
int yang_mandatory(yang_stmt *ys);
|
int yang_mandatory(yang_stmt *ys);
|
||||||
int yang_config(yang_stmt *ys);
|
int yang_config(yang_stmt *ys);
|
||||||
int yang_spec_parse_module(clicon_handle h, const char *module,
|
int yang_spec_parse_module(clicon_handle h, const char *module,
|
||||||
const char *revision, yang_spec *yspec);
|
const char *revision, yang_stmt *yspec);
|
||||||
int yang_spec_parse_file(clicon_handle h, char *filename, yang_spec *yspec);
|
int yang_spec_parse_file(clicon_handle h, char *filename, yang_stmt *yspec);
|
||||||
int yang_spec_load_dir(clicon_handle h, char *dir, yang_spec *yspec);
|
int yang_spec_load_dir(clicon_handle h, char *dir, yang_stmt *yspec);
|
||||||
cvec *yang_arg2cvec(yang_stmt *ys, char *delimi);
|
cvec *yang_arg2cvec(yang_stmt *ys, char *delimi);
|
||||||
int yang_key_match(yang_node *yn, char *name);
|
int yang_key_match(yang_stmt *yn, char *name);
|
||||||
|
|
||||||
#endif /* _CLIXON_YANG_H_ */
|
#endif /* _CLIXON_YANG_H_ */
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ int modstate_diff_free(modstate_diff_t *);
|
||||||
int yang_modules_init(clicon_handle h);
|
int yang_modules_init(clicon_handle h);
|
||||||
char *yang_modules_revision(clicon_handle h);
|
char *yang_modules_revision(clicon_handle h);
|
||||||
|
|
||||||
int yang_modules_state_get(clicon_handle h, yang_spec *yspec, char *xpath,
|
int yang_modules_state_get(clicon_handle h, yang_stmt *yspec, char *xpath,
|
||||||
int brief, cxobj **xret);
|
int brief, cxobj **xret);
|
||||||
|
|
||||||
int clixon_module_upgrade(clicon_handle h, cxobj *xt, modstate_diff_t *msd, cbuf *cb);
|
int clixon_module_upgrade(clicon_handle h, cxobj *xt, modstate_diff_t *msd, cbuf *cb);
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
/*! Get YANG specification for application
|
/*! Get YANG specification for application
|
||||||
* Must use hash functions directly since they are not strings.
|
* Must use hash functions directly since they are not strings.
|
||||||
*/
|
*/
|
||||||
yang_spec *
|
yang_stmt *
|
||||||
clicon_dbspec_yang(clicon_handle h)
|
clicon_dbspec_yang(clicon_handle h)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
@ -84,7 +84,7 @@ clicon_dbspec_yang(clicon_handle h)
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if ((p = hash_value(cdat, "dbspec_yang", &len)) != NULL)
|
if ((p = hash_value(cdat, "dbspec_yang", &len)) != NULL)
|
||||||
return *(yang_spec **)p;
|
return *(yang_stmt **)p;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,8 +92,8 @@ clicon_dbspec_yang(clicon_handle h)
|
||||||
* ys must be a malloced pointer
|
* ys must be a malloced pointer
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_dbspec_yang_set(clicon_handle h,
|
clicon_dbspec_yang_set(clicon_handle h,
|
||||||
struct yang_spec *ys)
|
yang_stmt *ys)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ clicon_nacm_ext_set(clicon_handle h,
|
||||||
/*! Get YANG specification for clixon config
|
/*! Get YANG specification for clixon config
|
||||||
* Must use hash functions directly since they are not strings.
|
* Must use hash functions directly since they are not strings.
|
||||||
*/
|
*/
|
||||||
yang_spec *
|
yang_stmt *
|
||||||
clicon_config_yang(clicon_handle h)
|
clicon_config_yang(clicon_handle h)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
@ -159,7 +159,7 @@ clicon_config_yang(clicon_handle h)
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if ((p = hash_value(cdat, "control_yang", &len)) != NULL)
|
if ((p = hash_value(cdat, "control_yang", &len)) != NULL)
|
||||||
return *(yang_spec **)p;
|
return *(yang_stmt **)p;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,8 +167,8 @@ clicon_config_yang(clicon_handle h)
|
||||||
* ys must be a malloced pointer
|
* ys must be a malloced pointer
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_config_yang_set(clicon_handle h,
|
clicon_config_yang_set(clicon_handle h,
|
||||||
struct yang_spec *ys)
|
yang_stmt *ys)
|
||||||
{
|
{
|
||||||
clicon_hash_t *cdat = clicon_data(h);
|
clicon_hash_t *cdat = clicon_data(h);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ xml_copy_marked(cxobj *x0,
|
||||||
* node in list is marked */
|
* node in list is marked */
|
||||||
if (mark && yt && yt->ys_keyword == Y_LIST){
|
if (mark && yt && yt->ys_keyword == Y_LIST){
|
||||||
/* XXX: I think yang_key_match is suboptimal here */
|
/* XXX: I think yang_key_match is suboptimal here */
|
||||||
if ((iskey = yang_key_match((yang_node*)yt, name)) < 0)
|
if ((iskey = yang_key_match(yt, name)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (iskey){
|
if (iskey){
|
||||||
if ((xcopy = xml_new(name, x1, xml_spec(x))) == NULL)
|
if ((xcopy = xml_new(name, x1, xml_spec(x))) == NULL)
|
||||||
|
|
@ -220,7 +220,7 @@ xml_copy_marked(cxobj *x0,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
text_read_modstate(clicon_handle h,
|
text_read_modstate(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj *xt,
|
cxobj *xt,
|
||||||
modstate_diff_t *msd)
|
modstate_diff_t *msd)
|
||||||
{
|
{
|
||||||
|
|
@ -306,7 +306,7 @@ text_read_modstate(clicon_handle h,
|
||||||
int
|
int
|
||||||
xmldb_readfile(clicon_handle h,
|
xmldb_readfile(clicon_handle h,
|
||||||
const char *db,
|
const char *db,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xp,
|
cxobj **xp,
|
||||||
modstate_diff_t *msd)
|
modstate_diff_t *msd)
|
||||||
{
|
{
|
||||||
|
|
@ -391,7 +391,7 @@ xmldb_get_nocache(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *dbfile = NULL;
|
char *dbfile = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
@ -513,7 +513,7 @@ xmldb_get_cache(clicon_handle h,
|
||||||
modstate_diff_t *msd)
|
modstate_diff_t *msd)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *x0t = NULL; /* (cached) top of tree */
|
cxobj *x0t = NULL; /* (cached) top of tree */
|
||||||
cxobj *x0;
|
cxobj *x0;
|
||||||
cxobj **xvec = NULL;
|
cxobj **xvec = NULL;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,6 @@
|
||||||
*/
|
*/
|
||||||
int xmldb_get_cache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
|
int xmldb_get_cache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
|
||||||
int xmldb_get_nocache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
|
int xmldb_get_nocache(clicon_handle h, const char *db, char *xpath, int config, cxobj **xret, modstate_diff_t *msd);
|
||||||
int xmldb_readfile(clicon_handle h, const char *db, yang_spec *yspec, cxobj **xp, modstate_diff_t *msd);
|
int xmldb_readfile(clicon_handle h, const char *db, yang_stmt *yspec, cxobj **xp, modstate_diff_t *msd);
|
||||||
|
|
||||||
#endif /* _CLIXON_DATASTORE_READ_H */
|
#endif /* _CLIXON_DATASTORE_READ_H */
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ valgrind --tool=callgrind datastore_client -d candidate -b /tmp/text -p ../datas
|
||||||
static int
|
static int
|
||||||
text_modify(clicon_handle h,
|
text_modify(clicon_handle h,
|
||||||
cxobj *x0,
|
cxobj *x0,
|
||||||
yang_node *y0,
|
yang_stmt *y0,
|
||||||
cxobj *x0p,
|
cxobj *x0p,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
enum operation_type op,
|
enum operation_type op,
|
||||||
|
|
@ -144,7 +144,7 @@ text_modify(clicon_handle h,
|
||||||
if (xml_operation(opstr, &op) < 0)
|
if (xml_operation(opstr, &op) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
x1name = xml_name(x1);
|
x1name = xml_name(x1);
|
||||||
if (y0->yn_keyword == Y_LEAF_LIST || y0->yn_keyword == Y_LEAF){
|
if (y0->ys_keyword == Y_LEAF_LIST || y0->ys_keyword == Y_LEAF){
|
||||||
x1bstr = xml_body(x1);
|
x1bstr = xml_body(x1);
|
||||||
switch(op){
|
switch(op){
|
||||||
case OP_CREATE:
|
case OP_CREATE:
|
||||||
|
|
@ -181,7 +181,7 @@ text_modify(clicon_handle h,
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* If it is key I dont want to mark it */
|
/* If it is key I dont want to mark it */
|
||||||
if ((iamkey=yang_key_match(y0->yn_parent, x1name)) < 0)
|
if ((iamkey=yang_key_match(y0->ys_parent, x1name)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (!iamkey && op==OP_NONE)
|
if (!iamkey && op==OP_NONE)
|
||||||
#else
|
#else
|
||||||
|
|
@ -262,7 +262,7 @@ text_modify(clicon_handle h,
|
||||||
can be modified in its entirety only.
|
can be modified in its entirety only.
|
||||||
Any "operation" attributes present on subelements of an anyxml
|
Any "operation" attributes present on subelements of an anyxml
|
||||||
node are ignored by the NETCONF server.*/
|
node are ignored by the NETCONF server.*/
|
||||||
if (y0->yn_keyword == Y_ANYXML || y0->yn_keyword == Y_ANYDATA){
|
if (y0->ys_keyword == Y_ANYXML || y0->ys_keyword == Y_ANYDATA){
|
||||||
if (op == OP_NONE)
|
if (op == OP_NONE)
|
||||||
break;
|
break;
|
||||||
if (op==OP_MERGE && !permit && xnacm){
|
if (op==OP_MERGE && !permit && xnacm){
|
||||||
|
|
@ -344,7 +344,7 @@ text_modify(clicon_handle h,
|
||||||
x1cname = xml_name(x1c);
|
x1cname = xml_name(x1c);
|
||||||
x0c = x0vec[i++];
|
x0c = x0vec[i++];
|
||||||
yc = yang_find_datanode(y0, x1cname);
|
yc = yang_find_datanode(y0, x1cname);
|
||||||
if ((ret = text_modify(h, x0c, (yang_node*)yc, x0, x1c, op,
|
if ((ret = text_modify(h, x0c, yc, x0, x1c, op,
|
||||||
username, xnacm, permit, cbret)) < 0)
|
username, xnacm, permit, cbret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||||
|
|
@ -404,7 +404,7 @@ static int
|
||||||
text_modify_top(clicon_handle h,
|
text_modify_top(clicon_handle h,
|
||||||
cxobj *x0,
|
cxobj *x0,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
enum operation_type op,
|
enum operation_type op,
|
||||||
char *username,
|
char *username,
|
||||||
cxobj *xnacm,
|
cxobj *xnacm,
|
||||||
|
|
@ -489,7 +489,7 @@ text_modify_top(clicon_handle h,
|
||||||
if (ys_module_by_xml(yspec, x1c, &ymod) <0)
|
if (ys_module_by_xml(yspec, x1c, &ymod) <0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ymod != NULL)
|
if (ymod != NULL)
|
||||||
yc = yang_find_datanode((yang_node*)ymod, x1cname);
|
yc = yang_find_datanode(ymod, x1cname);
|
||||||
if (yc == NULL){
|
if (yc == NULL){
|
||||||
if (netconf_unknown_element(cbret, "application", x1cname, "Unassigned yang spec") < 0)
|
if (netconf_unknown_element(cbret, "application", x1cname, "Unassigned yang spec") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -506,7 +506,7 @@ text_modify_top(clicon_handle h,
|
||||||
x0c = NULL;
|
x0c = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((ret = text_modify(h, x0c, (yang_node*)yc, x0, x1c, op,
|
if ((ret = text_modify(h, x0c, yc, x0, x1c, op,
|
||||||
username, xnacm, permit, cbret)) < 0)
|
username, xnacm, permit, cbret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
/* If xml return - ie netconf error xml tree, then stop and return OK */
|
||||||
|
|
@ -552,7 +552,7 @@ xml_container_presence(cxobj *x,
|
||||||
/* Mark node that is: container, have no children, dont have presence */
|
/* Mark node that is: container, have no children, dont have presence */
|
||||||
if (y->ys_keyword == Y_CONTAINER &&
|
if (y->ys_keyword == Y_CONTAINER &&
|
||||||
xml_child_nr_notype(x, CX_ATTR)==0 &&
|
xml_child_nr_notype(x, CX_ATTR)==0 &&
|
||||||
yang_find((yang_node*)y, Y_PRESENCE, NULL) == NULL)
|
yang_find(y, Y_PRESENCE, NULL) == NULL)
|
||||||
xml_flag_set(x, XML_FLAG_MARK); /* Mark, remove later */
|
xml_flag_set(x, XML_FLAG_MARK); /* Mark, remove later */
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -597,7 +597,7 @@ xmldb_put(clicon_handle h,
|
||||||
char *dbfile = NULL;
|
char *dbfile = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cxobj *x0 = NULL;
|
cxobj *x0 = NULL;
|
||||||
db_elmnt *de = NULL;
|
db_elmnt *de = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ xml2json1_cbuf(cbuf *cb,
|
||||||
enum array_element_type xc_arraytype;
|
enum array_element_type xc_arraytype;
|
||||||
yang_stmt *ys;
|
yang_stmt *ys;
|
||||||
yang_stmt *ymod; /* yang module */
|
yang_stmt *ymod; /* yang module */
|
||||||
yang_spec *yspec = NULL; /* yang spec */
|
yang_stmt *yspec = NULL; /* yang spec */
|
||||||
int bodystr0=1;
|
int bodystr0=1;
|
||||||
char *prefix=NULL; /* prefix / local namespace name */
|
char *prefix=NULL; /* prefix / local namespace name */
|
||||||
char *namespace=NULL; /* namespace uri */
|
char *namespace=NULL; /* namespace uri */
|
||||||
|
|
@ -728,7 +728,7 @@ xml2json_vec(FILE *f,
|
||||||
* @note the opposite - xml2ns is made inline in xml2json1_cbuf
|
* @note the opposite - xml2ns is made inline in xml2json1_cbuf
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
json2xml_ns(yang_spec *yspec,
|
json2xml_ns(yang_stmt *yspec,
|
||||||
cxobj *x,
|
cxobj *x,
|
||||||
cxobj **xerr)
|
cxobj **xerr)
|
||||||
{
|
{
|
||||||
|
|
@ -860,7 +860,7 @@ json_parse_str(char *str,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
json_parse_file(int fd,
|
json_parse_file(int fd,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xt)
|
cxobj **xt)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
|
||||||
|
|
@ -976,7 +976,7 @@ netconf_malformed_message_xml(cxobj **xret,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
netconf_trymerge(cxobj *x,
|
netconf_trymerge(cxobj *x,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -1018,7 +1018,7 @@ netconf_module_load(clicon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if ((xc = clicon_conf_xml(h)) == NULL){
|
if ((xc = clicon_conf_xml(h)) == NULL){
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ clicon_option_dump(clicon_handle h,
|
||||||
static int
|
static int
|
||||||
parse_configfile(clicon_handle h,
|
parse_configfile(clicon_handle h,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xconfig)
|
cxobj **xconfig)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
@ -290,7 +290,7 @@ clicon_option_add(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_options_main(clicon_handle h,
|
clicon_options_main(clicon_handle h,
|
||||||
yang_spec *yspec)
|
yang_stmt *yspec)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char *configfile;
|
char *configfile;
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ clicon_msg_encode(char *format, ...)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_msg_decode(struct clicon_msg *msg,
|
clicon_msg_decode(struct clicon_msg *msg,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xml)
|
cxobj **xml)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ clicon_rpc_msg(clicon_handle h,
|
||||||
int port;
|
int port;
|
||||||
char *retdata = NULL;
|
char *retdata = NULL;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
#ifdef RPC_USERNAME_ASSERT
|
#ifdef RPC_USERNAME_ASSERT
|
||||||
assert(strstr(msg->op_body, "username")!=NULL); /* XXX */
|
assert(strstr(msg->op_body, "username")!=NULL); /* XXX */
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@ stream_notify(clicon_handle h,
|
||||||
va_list args;
|
va_list args;
|
||||||
int len;
|
int len;
|
||||||
cxobj *xev = NULL;
|
cxobj *xev = NULL;
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
char timestr[28];
|
char timestr[28];
|
||||||
|
|
@ -621,7 +621,7 @@ stream_notify_xml(clicon_handle h,
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xev = NULL;
|
cxobj *xev = NULL;
|
||||||
cxobj *xml2; /* copy */
|
cxobj *xml2; /* copy */
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
char timestr[28];
|
char timestr[28];
|
||||||
|
|
|
||||||
|
|
@ -1605,7 +1605,7 @@ xmltree2cbuf(cbuf *cb,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_xml_parse(const char *str,
|
_xml_parse(const char *str,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj *xt)
|
cxobj *xt)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -1685,7 +1685,7 @@ FSM(char *tag,
|
||||||
int
|
int
|
||||||
xml_parse_file(int fd,
|
xml_parse_file(int fd,
|
||||||
char *endtag,
|
char *endtag,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xt)
|
cxobj **xt)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -1772,7 +1772,7 @@ xml_parse_file(int fd,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_parse_string(const char *str,
|
xml_parse_string(const char *str,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj **xtop)
|
cxobj **xtop)
|
||||||
{
|
{
|
||||||
if (*xtop == NULL)
|
if (*xtop == NULL)
|
||||||
|
|
@ -1804,7 +1804,7 @@ xml_parse_string(const char *str,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_parse_va(cxobj **xtop,
|
xml_parse_va(cxobj **xtop,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ clixon_xml_changelog_init(clicon_handle h)
|
||||||
char *filename;
|
char *filename;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
cbuf *cbret = NULL;
|
cbuf *cbret = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ xml2cli(FILE *f,
|
||||||
/* If list then first loop through keys */
|
/* If list then first loop through keys */
|
||||||
xe = NULL;
|
xe = NULL;
|
||||||
while ((xe = xml_child_each(x, xe, -1)) != NULL){
|
while ((xe = xml_child_each(x, xe, -1)) != NULL){
|
||||||
if ((match = yang_key_match((yang_node*)ys, xml_name(xe))) < 0)
|
if ((match = yang_key_match(ys, xml_name(xe))) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (!match)
|
if (!match)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -226,7 +226,7 @@ xml2cli(FILE *f,
|
||||||
xe = NULL;
|
xe = NULL;
|
||||||
while ((xe = xml_child_each(x, xe, -1)) != NULL){
|
while ((xe = xml_child_each(x, xe, -1)) != NULL){
|
||||||
if (ys->ys_keyword == Y_LIST){
|
if (ys->ys_keyword == Y_LIST){
|
||||||
if ((match = yang_key_match((yang_node*)ys, xml_name(xe))) < 0)
|
if ((match = yang_key_match(ys, xml_name(xe))) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (match){
|
if (match){
|
||||||
fprintf(f, "%s\n", cbuf_get(cbpre));
|
fprintf(f, "%s\n", cbuf_get(cbpre));
|
||||||
|
|
@ -268,7 +268,7 @@ validate_leafref(cxobj *xt,
|
||||||
|
|
||||||
if ((leafrefbody = xml_body(xt)) == NULL)
|
if ((leafrefbody = xml_body(xt)) == NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
|
if ((ypath = yang_find(ytype, Y_PATH, NULL)) == NULL){
|
||||||
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Leafref requires path statement") < 0)
|
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Leafref requires path statement") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -348,7 +348,7 @@ validate_identityref(cxobj *xt,
|
||||||
node = cbuf_get(cb);
|
node = cbuf_get(cb);
|
||||||
}
|
}
|
||||||
/* This is the type's base reference */
|
/* This is the type's base reference */
|
||||||
if ((ybaseref = yang_find((yang_node*)ytype, Y_BASE, NULL)) == NULL){
|
if ((ybaseref = yang_find(ytype, Y_BASE, NULL)) == NULL){
|
||||||
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Identityref validation failed, no base") < 0)
|
if (netconf_missing_element(cbret, "application", ytype->ys_argument, "Identityref validation failed, no base") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -501,9 +501,9 @@ check_choice(cxobj *xt,
|
||||||
cbuf *cbret)
|
cbuf *cbret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_node *yc;
|
yang_stmt *yc;
|
||||||
yang_stmt *y;
|
yang_stmt *y;
|
||||||
yang_node *yp;
|
yang_stmt *yp;
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
cxobj *xp;
|
cxobj *xp;
|
||||||
|
|
||||||
|
|
@ -516,7 +516,7 @@ check_choice(cxobj *xt,
|
||||||
if ((x != xt) &&
|
if ((x != xt) &&
|
||||||
(y = xml_spec(x)) != NULL &&
|
(y = xml_spec(x)) != NULL &&
|
||||||
(yp = yang_choice(y)) != NULL &&
|
(yp = yang_choice(y)) != NULL &&
|
||||||
yp == (yang_node*)yc){
|
yp == yc){
|
||||||
if (netconf_bad_element(cbret, "application", xml_name(x), "Element in choice statement already exists") < 0)
|
if (netconf_bad_element(cbret, "application", xml_name(x), "Element in choice statement already exists") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -549,7 +549,7 @@ check_mandatory(cxobj *xt,
|
||||||
cxobj *x;
|
cxobj *x;
|
||||||
yang_stmt *y;
|
yang_stmt *y;
|
||||||
yang_stmt *yc;
|
yang_stmt *yc;
|
||||||
yang_node *yp;
|
yang_stmt *yp;
|
||||||
cvec *cvk = NULL; /* vector of index keys */
|
cvec *cvk = NULL; /* vector of index keys */
|
||||||
cg_var *cvi;
|
cg_var *cvi;
|
||||||
char *keyname;
|
char *keyname;
|
||||||
|
|
@ -598,7 +598,7 @@ check_mandatory(cxobj *xt,
|
||||||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
||||||
if ((y = xml_spec(x)) != NULL &&
|
if ((y = xml_spec(x)) != NULL &&
|
||||||
(yp = yang_choice(y)) != NULL &&
|
(yp = yang_choice(y)) != NULL &&
|
||||||
yp == (yang_node*)yc){
|
yp == yc){
|
||||||
break; /* leave loop with x set */
|
break; /* leave loop with x set */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -777,7 +777,7 @@ xml_yang_validate_all(cxobj *xt,
|
||||||
/* Special case if leaf is leafref, then first check against
|
/* Special case if leaf is leafref, then first check against
|
||||||
current xml tree
|
current xml tree
|
||||||
*/
|
*/
|
||||||
if ((yc = yang_find((yang_node*)ys, Y_TYPE, NULL)) != NULL){
|
if ((yc = yang_find(ys, Y_TYPE, NULL)) != NULL){
|
||||||
if (strcmp(yc->ys_argument, "leafref") == 0){
|
if (strcmp(yc->ys_argument, "leafref") == 0){
|
||||||
if (validate_leafref(xt, yc, cbret) < 0)
|
if (validate_leafref(xt, yc, cbret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -787,7 +787,7 @@ xml_yang_validate_all(cxobj *xt,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((yc = yang_find((yang_node*)ys, Y_MIN_ELEMENTS, NULL)) != NULL){
|
if ((yc = yang_find(ys, Y_MIN_ELEMENTS, NULL)) != NULL){
|
||||||
/* The behavior of the constraint depends on the type of the
|
/* The behavior of the constraint depends on the type of the
|
||||||
* leaf-list's or list's closest ancestor node in the schema tree
|
* leaf-list's or list's closest ancestor node in the schema tree
|
||||||
* that is not a non-presence container (see Section 7.5.1):
|
* that is not a non-presence container (see Section 7.5.1):
|
||||||
|
|
@ -811,7 +811,7 @@ xml_yang_validate_all(cxobj *xt,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if ((yc = yang_find((yang_node*)ys, Y_MAX_ELEMENTS, NULL)) != NULL){
|
if ((yc = yang_find(ys, Y_MAX_ELEMENTS, NULL)) != NULL){
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -821,14 +821,14 @@ xml_yang_validate_all(cxobj *xt,
|
||||||
/* must sub-node RFC 7950 Sec 7.5.3. Can be several.
|
/* must sub-node RFC 7950 Sec 7.5.3. Can be several.
|
||||||
* XXX. use yang path instead? */
|
* XXX. use yang path instead? */
|
||||||
yc = NULL;
|
yc = NULL;
|
||||||
while ((yc = yn_each((yang_node*)ys, yc)) != NULL) {
|
while ((yc = yn_each(ys, yc)) != NULL) {
|
||||||
if (yc->ys_keyword != Y_MUST)
|
if (yc->ys_keyword != Y_MUST)
|
||||||
continue;
|
continue;
|
||||||
xpath = yc->ys_argument; /* "must" has xpath argument */
|
xpath = yc->ys_argument; /* "must" has xpath argument */
|
||||||
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
|
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (!nr){
|
if (!nr){
|
||||||
ye = yang_find((yang_node*)yc, Y_ERROR_MESSAGE, NULL);
|
ye = yang_find(yc, Y_ERROR_MESSAGE, NULL);
|
||||||
if (netconf_operation_failed(cbret, "application",
|
if (netconf_operation_failed(cbret, "application",
|
||||||
ye?ye->ys_argument:"must xpath validation failed") < 0)
|
ye?ye->ys_argument:"must xpath validation failed") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -836,7 +836,7 @@ xml_yang_validate_all(cxobj *xt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */
|
/* "when" sub-node RFC 7950 Sec 7.21.5. Can only be one. */
|
||||||
if ((yc = yang_find((yang_node*)ys, Y_WHEN, NULL)) != NULL){
|
if ((yc = yang_find(ys, Y_WHEN, NULL)) != NULL){
|
||||||
xpath = yc->ys_argument; /* "when" has xpath argument */
|
xpath = yc->ys_argument; /* "when" has xpath argument */
|
||||||
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
|
if ((nr = xpath_vec_bool(xt, "%s", xpath)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -932,7 +932,7 @@ xml2cvec(cxobj *xt,
|
||||||
/* Go through all children of the xml tree */
|
/* Go through all children of the xml tree */
|
||||||
while ((xc = xml_child_each(xt, xc, CX_ELMNT)) != NULL){
|
while ((xc = xml_child_each(xt, xc, CX_ELMNT)) != NULL){
|
||||||
name = xml_name(xc);
|
name = xml_name(xc);
|
||||||
if ((ys = yang_find_datanode((yang_node*)yt, name)) == NULL){
|
if ((ys = yang_find_datanode(yt, name)) == NULL){
|
||||||
clicon_debug(0, "%s: yang sanity problem: %s in xml but not present in yang under %s",
|
clicon_debug(0, "%s: yang sanity problem: %s in xml but not present in yang under %s",
|
||||||
__FUNCTION__, name, yt->ys_argument);
|
__FUNCTION__, name, yt->ys_argument);
|
||||||
if ((body = xml_body(xc)) != NULL){
|
if ((body = xml_body(xc)) != NULL){
|
||||||
|
|
@ -1161,7 +1161,7 @@ xml_diff1(yang_stmt *ys,
|
||||||
* Bot xml trees should be freed with xml_free()
|
* Bot xml trees should be freed with xml_free()
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xml_diff(yang_spec *yspec,
|
xml_diff(yang_stmt *yspec,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
cxobj *x2,
|
cxobj *x2,
|
||||||
cxobj ***first,
|
cxobj ***first,
|
||||||
|
|
@ -1215,7 +1215,7 @@ yang2api_path_fmt_1(yang_stmt *ys,
|
||||||
int inclkey,
|
int inclkey,
|
||||||
cbuf *cb)
|
cbuf *cb)
|
||||||
{
|
{
|
||||||
yang_node *yp; /* parent */
|
yang_stmt *yp; /* parent */
|
||||||
int i;
|
int i;
|
||||||
cvec *cvk = NULL; /* vector of index keys */
|
cvec *cvk = NULL; /* vector of index keys */
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -1225,15 +1225,15 @@ yang2api_path_fmt_1(yang_stmt *ys,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (yp != NULL && /* XXX rm */
|
if (yp != NULL && /* XXX rm */
|
||||||
yp->yn_keyword != Y_MODULE &&
|
yp->ys_keyword != Y_MODULE &&
|
||||||
yp->yn_keyword != Y_SUBMODULE){
|
yp->ys_keyword != Y_SUBMODULE){
|
||||||
if (yang2api_path_fmt_1((yang_stmt *)yp, 1, cb) < 0) /* recursive call */
|
if (yang2api_path_fmt_1((yang_stmt *)yp, 1, cb) < 0) /* recursive call */
|
||||||
goto done;
|
goto done;
|
||||||
if (yp->yn_keyword != Y_CHOICE && yp->yn_keyword != Y_CASE)
|
if (yp->ys_keyword != Y_CHOICE && yp->ys_keyword != Y_CASE)
|
||||||
cprintf(cb, "/");
|
cprintf(cb, "/");
|
||||||
}
|
}
|
||||||
else /* top symbol - mark with name prefix */
|
else /* top symbol - mark with name prefix */
|
||||||
cprintf(cb, "/%s:", yp->yn_argument);
|
cprintf(cb, "/%s:", yp->ys_argument);
|
||||||
|
|
||||||
if (inclkey){
|
if (inclkey){
|
||||||
if (ys->ys_keyword != Y_CHOICE && ys->ys_keyword != Y_CASE)
|
if (ys->ys_keyword != Y_CHOICE && ys->ys_keyword != Y_CASE)
|
||||||
|
|
@ -1241,7 +1241,7 @@ yang2api_path_fmt_1(yang_stmt *ys,
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (ys->ys_keyword == Y_LEAF && yp &&
|
if (ys->ys_keyword == Y_LEAF && yp &&
|
||||||
yp->yn_keyword == Y_LIST){
|
yp->ys_keyword == Y_LIST){
|
||||||
if (yang_key_match(yp, ys->ys_argument) == 0)
|
if (yang_key_match(yp, ys->ys_argument) == 0)
|
||||||
cprintf(cb, "%s", ys->ys_argument); /* Not if leaf and key */
|
cprintf(cb, "%s", ys->ys_argument); /* Not if leaf and key */
|
||||||
}
|
}
|
||||||
|
|
@ -1521,7 +1521,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
|
||||||
}
|
}
|
||||||
/* If it is key dont remove it yet (see second round) */
|
/* If it is key dont remove it yet (see second round) */
|
||||||
if (yt){
|
if (yt){
|
||||||
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
|
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (iskey){
|
if (iskey){
|
||||||
anykey++;
|
anykey++;
|
||||||
|
|
@ -1549,7 +1549,7 @@ xml_tree_prune_flagged_sub(cxobj *xt,
|
||||||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
||||||
/* If it is key remove it here */
|
/* If it is key remove it here */
|
||||||
if (yt){
|
if (yt){
|
||||||
if ((iskey = yang_key_match((yang_node*)yt, xml_name(x))) < 0)
|
if ((iskey = yang_key_match(yt, xml_name(x))) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (iskey && xml_purge(x) < 0)
|
if (iskey && xml_purge(x) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -1726,7 +1726,7 @@ xml_non_config_data(cxobj *xt,
|
||||||
int
|
int
|
||||||
xml_spec_populate_rpc(clicon_handle h,
|
xml_spec_populate_rpc(clicon_handle h,
|
||||||
cxobj *xrpc,
|
cxobj *xrpc,
|
||||||
yang_spec *yspec)
|
yang_stmt *yspec)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_stmt *yrpc = NULL; /* yang node */
|
yang_stmt *yrpc = NULL; /* yang node */
|
||||||
|
|
@ -1743,12 +1743,12 @@ xml_spec_populate_rpc(clicon_handle h,
|
||||||
if (ys_module_by_xml(yspec, x, &ymod) < 0)
|
if (ys_module_by_xml(yspec, x, &ymod) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ymod != NULL)
|
if (ymod != NULL)
|
||||||
yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(x));
|
yrpc = yang_find(ymod, Y_RPC, xml_name(x));
|
||||||
/* Non-strict semantics: loop through all modules to find the node
|
/* Non-strict semantics: loop through all modules to find the node
|
||||||
*/
|
*/
|
||||||
if (yrpc){
|
if (yrpc){
|
||||||
xml_spec_set(x, yrpc);
|
xml_spec_set(x, yrpc);
|
||||||
if ((yi = yang_find((yang_node*)yrpc, Y_INPUT, NULL)) != NULL){
|
if ((yi = yang_find(yrpc, Y_INPUT, NULL)) != NULL){
|
||||||
/* kludge rpc -> input XXX THIS HIDES AN ERROR IN xml_spec_populate */
|
/* kludge rpc -> input XXX THIS HIDES AN ERROR IN xml_spec_populate */
|
||||||
xml_spec_set(x, yi);
|
xml_spec_set(x, yi);
|
||||||
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
if (xml_apply(x, CX_ELMNT, xml_spec_populate, yspec) < 0)
|
||||||
|
|
@ -1777,25 +1777,25 @@ xml_spec_populate(cxobj *x,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
// clicon_handle h = (clicon_handle)arg;
|
// clicon_handle h = (clicon_handle)arg;
|
||||||
yang_spec *yspec = NULL; /* yang spec */
|
yang_stmt *yspec = NULL; /* yang spec */
|
||||||
yang_stmt *y = NULL; /* yang node */
|
yang_stmt *y = NULL; /* yang node */
|
||||||
yang_stmt *yparent; /* yang parent */
|
yang_stmt *yparent; /* yang parent */
|
||||||
yang_stmt *ymod; /* yang module */
|
yang_stmt *ymod; /* yang module */
|
||||||
cxobj *xp = NULL; /* xml parent */
|
cxobj *xp = NULL; /* xml parent */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
yspec = (yang_spec*)arg;
|
yspec = (yang_stmt*)arg;
|
||||||
if (xml_spec(x))
|
if (xml_spec(x))
|
||||||
; // goto ok;
|
; // goto ok;
|
||||||
xp = xml_parent(x);
|
xp = xml_parent(x);
|
||||||
name = xml_name(x);
|
name = xml_name(x);
|
||||||
if (xp && (yparent = xml_spec(xp)) != NULL)
|
if (xp && (yparent = xml_spec(xp)) != NULL)
|
||||||
y = yang_find_datanode((yang_node*)yparent, name);
|
y = yang_find_datanode(yparent, name);
|
||||||
else if (yspec){
|
else if (yspec){
|
||||||
if (ys_module_by_xml(yspec, x, &ymod) < 0)
|
if (ys_module_by_xml(yspec, x, &ymod) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ymod != NULL)
|
if (ymod != NULL)
|
||||||
y = yang_find_schemanode((yang_node*)ymod, name);
|
y = yang_find_schemanode(ymod, name);
|
||||||
}
|
}
|
||||||
if (y)
|
if (y)
|
||||||
xml_spec_set(x, y);
|
xml_spec_set(x, y);
|
||||||
|
|
@ -1848,7 +1848,7 @@ xml_spec_populate(cxobj *x,
|
||||||
* @see api_path2xml For api-path to xml tree
|
* @see api_path2xml For api-path to xml tree
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
api_path2xpath(yang_spec *yspec,
|
api_path2xpath(yang_stmt *yspec,
|
||||||
cvec *cvv,
|
cvec *cvv,
|
||||||
int offset,
|
int offset,
|
||||||
cbuf *xpath)
|
cbuf *xpath)
|
||||||
|
|
@ -1881,10 +1881,10 @@ api_path2xpath(yang_spec *yspec,
|
||||||
clicon_err(OE_YANG, ENOENT, "No such yang module: %s", prefix);
|
clicon_err(OE_YANG, ENOENT, "No such yang module: %s", prefix);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
y = yang_find_datanode((yang_node*)ymod, name);
|
y = yang_find_datanode(ymod, name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
y = yang_find_datanode((yang_node*)y, name);
|
y = yang_find_datanode(y, name);
|
||||||
if (y == NULL){
|
if (y == NULL){
|
||||||
clicon_err(OE_YANG, errno, "Unknown element: '%s'", name);
|
clicon_err(OE_YANG, errno, "Unknown element: '%s'", name);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -1955,10 +1955,10 @@ static int
|
||||||
api_path2xml_vec(char **vec,
|
api_path2xml_vec(char **vec,
|
||||||
int nvec,
|
int nvec,
|
||||||
cxobj *x0,
|
cxobj *x0,
|
||||||
yang_node *y0,
|
yang_stmt *y0,
|
||||||
yang_class nodeclass,
|
yang_class nodeclass,
|
||||||
cxobj **xpathp,
|
cxobj **xpathp,
|
||||||
yang_node **ypathp)
|
yang_stmt **ypathp)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int j;
|
int j;
|
||||||
|
|
@ -1997,22 +1997,22 @@ api_path2xml_vec(char **vec,
|
||||||
/* Split into prefix and localname */
|
/* Split into prefix and localname */
|
||||||
if (nodeid_split(nodeid, &prefix, &name) < 0)
|
if (nodeid_split(nodeid, &prefix, &name) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (y0->yn_keyword == Y_SPEC){ /* top-node */
|
if (y0->ys_keyword == Y_SPEC){ /* top-node */
|
||||||
if (prefix == NULL){
|
if (prefix == NULL){
|
||||||
clicon_err(OE_XML, EINVAL, "api-path element '%s', expected prefix:name", nodeid);
|
clicon_err(OE_XML, EINVAL, "api-path element '%s', expected prefix:name", nodeid);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if ((ymod = yang_find_module_by_name((yang_spec*)y0, prefix)) == NULL){
|
if ((ymod = yang_find_module_by_name(y0, prefix)) == NULL){
|
||||||
clicon_err(OE_YANG, EINVAL, "api-path element prefix: '%s', no such yang module", prefix);
|
clicon_err(OE_YANG, EINVAL, "api-path element prefix: '%s', no such yang module", prefix);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
namespace = yang_find_mynamespace(ymod);
|
namespace = yang_find_mynamespace(ymod);
|
||||||
y0 = (yang_node*)ymod;
|
y0 = ymod;
|
||||||
|
|
||||||
}
|
}
|
||||||
y = (nodeclass==YC_SCHEMANODE)?
|
y = (nodeclass==YC_SCHEMANODE)?
|
||||||
yang_find_schemanode((yang_node*)y0, name):
|
yang_find_schemanode(y0, name):
|
||||||
yang_find_datanode((yang_node*)y0, name);
|
yang_find_datanode(y0, name);
|
||||||
if (y == NULL){
|
if (y == NULL){
|
||||||
clicon_err(OE_YANG, EINVAL, "api-path name: '%s', no such yang element", name);
|
clicon_err(OE_YANG, EINVAL, "api-path name: '%s', no such yang element", name);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
@ -2082,7 +2082,7 @@ api_path2xml_vec(char **vec,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((retval = api_path2xml_vec(vec+1, nvec-1,
|
if ((retval = api_path2xml_vec(vec+1, nvec-1,
|
||||||
x, (yang_node*)y,
|
x, y,
|
||||||
nodeclass,
|
nodeclass,
|
||||||
xpathp, ypathp)) < 1)
|
xpathp, ypathp)) < 1)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -2127,11 +2127,11 @@ api_path2xml_vec(char **vec,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
api_path2xml(char *api_path,
|
api_path2xml(char *api_path,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
cxobj *xtop,
|
cxobj *xtop,
|
||||||
yang_class nodeclass,
|
yang_class nodeclass,
|
||||||
cxobj **xbotp,
|
cxobj **xbotp,
|
||||||
yang_node **ybotp)
|
yang_stmt **ybotp)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
char **vec = NULL;
|
char **vec = NULL;
|
||||||
|
|
@ -2155,7 +2155,7 @@ api_path2xml(char *api_path,
|
||||||
}
|
}
|
||||||
nvec--; /* NULL-terminated */
|
nvec--; /* NULL-terminated */
|
||||||
if ((retval = api_path2xml_vec(vec+1, nvec,
|
if ((retval = api_path2xml_vec(vec+1, nvec,
|
||||||
xtop, (yang_node*)yspec, nodeclass,
|
xtop, yspec, nodeclass,
|
||||||
xbotp, ybotp)) < 1)
|
xbotp, ybotp)) < 1)
|
||||||
goto done;
|
goto done;
|
||||||
xml_yang_root(*xbotp, &xroot);
|
xml_yang_root(*xbotp, &xroot);
|
||||||
|
|
@ -2229,7 +2229,7 @@ xmlns_assign(cxobj *x)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xml_merge1(cxobj *x0,
|
xml_merge1(cxobj *x0,
|
||||||
yang_node *y0,
|
yang_stmt *y0,
|
||||||
cxobj *x0p,
|
cxobj *x0p,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
char **reason)
|
char **reason)
|
||||||
|
|
@ -2250,7 +2250,7 @@ xml_merge1(cxobj *x0,
|
||||||
assert(y0);
|
assert(y0);
|
||||||
|
|
||||||
x1name = xml_name(x1);
|
x1name = xml_name(x1);
|
||||||
if (y0->yn_keyword == Y_LEAF_LIST || y0->yn_keyword == Y_LEAF){
|
if (y0->ys_keyword == Y_LEAF_LIST || y0->ys_keyword == Y_LEAF){
|
||||||
x1bstr = xml_body(x1);
|
x1bstr = xml_body(x1);
|
||||||
if (x0==NULL){
|
if (x0==NULL){
|
||||||
if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL)
|
if ((x0 = xml_new(x1name, x0p, (yang_stmt*)y0)) == NULL)
|
||||||
|
|
@ -2300,7 +2300,7 @@ xml_merge1(cxobj *x0,
|
||||||
x0c = NULL;
|
x0c = NULL;
|
||||||
if (yc && match_base_child(x0, x1c, yc, &x0c) < 0)
|
if (yc && match_base_child(x0, x1c, yc, &x0c) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
|
if (xml_merge1(x0c, yc, x0, x1c, reason) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (*reason != NULL)
|
if (*reason != NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
@ -2339,7 +2339,7 @@ xml_merge1(cxobj *x0,
|
||||||
int
|
int
|
||||||
xml_merge(cxobj *x0,
|
xml_merge(cxobj *x0,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
char **reason)
|
char **reason)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -2370,7 +2370,7 @@ xml_merge(cxobj *x0,
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
/* Get yang spec of the child */
|
/* Get yang spec of the child */
|
||||||
if ((yc = yang_find_datanode((yang_node*)ymod, x1cname)) == NULL){
|
if ((yc = yang_find_datanode(ymod, x1cname)) == NULL){
|
||||||
if (reason){
|
if (reason){
|
||||||
if ((cbr = cbuf_new()) == NULL){
|
if ((cbr = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_XML, errno, "cbuf_new");
|
clicon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
|
@ -2391,7 +2391,7 @@ xml_merge(cxobj *x0,
|
||||||
* it is treated as a match, and x0c will remain
|
* it is treated as a match, and x0c will remain
|
||||||
* If it is overwritten, then x0c should be removed here.
|
* If it is overwritten, then x0c should be removed here.
|
||||||
*/
|
*/
|
||||||
if (xml_merge1(x0c, (yang_node*)yc, x0, x1c, reason) < 0)
|
if (xml_merge1(x0c, yc, x0, x1c, reason) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (*reason != NULL)
|
if (*reason != NULL)
|
||||||
break;
|
break;
|
||||||
|
|
@ -2422,7 +2422,7 @@ yang_enum_int_value(cxobj *node,
|
||||||
int32_t *val)
|
int32_t *val)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ys;
|
yang_stmt *ys;
|
||||||
yang_stmt *ytype;
|
yang_stmt *ytype;
|
||||||
yang_stmt *yrestype; /* resolved type */
|
yang_stmt *yrestype; /* resolved type */
|
||||||
|
|
@ -2436,17 +2436,17 @@ yang_enum_int_value(cxobj *node,
|
||||||
goto done;
|
goto done;
|
||||||
if ((yspec = ys_spec(ys)) == NULL)
|
if ((yspec = ys_spec(ys)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if ((ytype = yang_find((yang_node *)ys, Y_TYPE, NULL)) == NULL)
|
if ((ytype = yang_find(ys, Y_TYPE, NULL)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (yang_type_resolve(ys, ys, ytype, &yrestype,
|
if (yang_type_resolve(ys, ys, ytype, &yrestype,
|
||||||
NULL, NULL, NULL, NULL) < 0)
|
NULL, NULL, NULL, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (yrestype==NULL || strcmp(yrestype->ys_argument, "enumeration"))
|
if (yrestype==NULL || strcmp(yrestype->ys_argument, "enumeration"))
|
||||||
goto done;
|
goto done;
|
||||||
if ((yenum = yang_find((yang_node *)yrestype, Y_ENUM, xml_body(node))) == NULL)
|
if ((yenum = yang_find(yrestype, Y_ENUM, xml_body(node))) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Should assign value if yval not found */
|
/* Should assign value if yval not found */
|
||||||
if ((yval = yang_find((yang_node *)yenum, Y_VALUE, NULL)) == NULL)
|
if ((yval = yang_find(yenum, Y_VALUE, NULL)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* reason is string containing why int could not be parsed */
|
/* reason is string containing why int could not be parsed */
|
||||||
if (parse_int32(yval->ys_argument, val, &reason) < 0)
|
if (parse_int32(yval->ys_argument, val, &reason) < 0)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct xml_parse_yacc_arg{
|
||||||
cxobj *ya_xelement; /* xml active element */
|
cxobj *ya_xelement; /* xml active element */
|
||||||
cxobj *ya_xparent; /* xml parent element*/
|
cxobj *ya_xparent; /* xml parent element*/
|
||||||
int ya_skipspace; /* If set, remove all non-terminal bodies (strip pretty-print) */
|
int ya_skipspace; /* If set, remove all non-terminal bodies (strip pretty-print) */
|
||||||
yang_spec *ya_yspec; /* If set, top-level yang-spec */
|
yang_stmt *ya_yspec; /* If set, top-level yang-spec */
|
||||||
int ya_lex_state; /* lex start condition (AMPERSAND) */
|
int ya_lex_state; /* lex start condition (AMPERSAND) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ xml_cv_cache(cxobj *x,
|
||||||
int
|
int
|
||||||
xml_child_spec(cxobj *x,
|
xml_child_spec(cxobj *x,
|
||||||
cxobj *xp,
|
cxobj *xp,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
yang_stmt **yresult)
|
yang_stmt **yresult)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -161,11 +161,11 @@ xml_child_spec(cxobj *x,
|
||||||
/* First case: parent already has an associated yang statement,
|
/* First case: parent already has an associated yang statement,
|
||||||
* then find matching child of that */
|
* then find matching child of that */
|
||||||
if (yparent->ys_keyword == Y_RPC){
|
if (yparent->ys_keyword == Y_RPC){
|
||||||
if ((yi = yang_find((yang_node*)yparent, Y_INPUT, NULL)) != NULL)
|
if ((yi = yang_find(yparent, Y_INPUT, NULL)) != NULL)
|
||||||
y = yang_find_datanode((yang_node*)yi, name);
|
y = yang_find_datanode(yi, name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
y = yang_find_datanode((yang_node*)yparent, name);
|
y = yang_find_datanode(yparent, name);
|
||||||
}
|
}
|
||||||
else if (yspec){
|
else if (yspec){
|
||||||
/* Second case, this is a "root", need to find yang stmt from spec
|
/* Second case, this is a "root", need to find yang stmt from spec
|
||||||
|
|
@ -173,13 +173,13 @@ xml_child_spec(cxobj *x,
|
||||||
if (ys_module_by_xml(yspec, xp, &ymod) < 0)
|
if (ys_module_by_xml(yspec, xp, &ymod) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ymod != NULL)
|
if (ymod != NULL)
|
||||||
y = yang_find_schemanode((yang_node*)ymod, name);
|
y = yang_find_schemanode(ymod, name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
y = NULL;
|
y = NULL;
|
||||||
/* kludge rpc -> input */
|
/* kludge rpc -> input */
|
||||||
if (y && y->ys_keyword == Y_RPC && yang_find((yang_node*)y, Y_INPUT, NULL))
|
if (y && y->ys_keyword == Y_RPC && yang_find(y, Y_INPUT, NULL))
|
||||||
y = yang_find((yang_node*)y, Y_INPUT, NULL);
|
y = yang_find(y, Y_INPUT, NULL);
|
||||||
*yresult = y;
|
*yresult = y;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -256,7 +256,7 @@ xml_cmp(const void* arg1,
|
||||||
* otherwise sort according to key
|
* otherwise sort according to key
|
||||||
*/
|
*/
|
||||||
if (yang_config(y1)==0 ||
|
if (yang_config(y1)==0 ||
|
||||||
yang_find((yang_node*)y1, Y_ORDERED_BY, "user") != NULL){
|
yang_find(y1, Y_ORDERED_BY, "user") != NULL){
|
||||||
equal = nr1-nr2;
|
equal = nr1-nr2;
|
||||||
goto done; /* Ordered by user or state data : maintain existing order */
|
goto done; /* Ordered by user or state data : maintain existing order */
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +349,7 @@ xml_cmp1(cxobj *x,
|
||||||
match = strcmp(name, xml_name(x));
|
match = strcmp(name, xml_name(x));
|
||||||
break;
|
break;
|
||||||
case Y_LEAF_LIST: /* Match with name and value */
|
case Y_LEAF_LIST: /* Match with name and value */
|
||||||
if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL)
|
if (userorder && yang_find(y, Y_ORDERED_BY, "user") != NULL)
|
||||||
*userorder=1;
|
*userorder=1;
|
||||||
if ((b=xml_body(x)) == NULL)
|
if ((b=xml_body(x)) == NULL)
|
||||||
match = 1;
|
match = 1;
|
||||||
|
|
@ -357,7 +357,7 @@ xml_cmp1(cxobj *x,
|
||||||
match = strcmp(keyval[0], b);
|
match = strcmp(keyval[0], b);
|
||||||
break;
|
break;
|
||||||
case Y_LIST: /* Match with array of key values */
|
case Y_LIST: /* Match with array of key values */
|
||||||
if (userorder && yang_find((yang_node*)y, Y_ORDERED_BY, "user") != NULL)
|
if (userorder && yang_find(y, Y_ORDERED_BY, "user") != NULL)
|
||||||
*userorder=1;
|
*userorder=1;
|
||||||
/* All must match */
|
/* All must match */
|
||||||
for (i=0; i<keynr; i++){
|
for (i=0; i<keynr; i++){
|
||||||
|
|
@ -719,8 +719,8 @@ match_base_child(cxobj *x0,
|
||||||
int yorder;
|
int yorder;
|
||||||
cxobj *x0c = NULL;
|
cxobj *x0c = NULL;
|
||||||
yang_stmt *y0c;
|
yang_stmt *y0c;
|
||||||
yang_node *y0p;
|
yang_stmt *y0p;
|
||||||
yang_node *yp; /* yang parent */
|
yang_stmt *yp; /* yang parent */
|
||||||
|
|
||||||
*x0cp = NULL; /* init return value */
|
*x0cp = NULL; /* init return value */
|
||||||
/* Special case is if yc parent (yp) is choice/case
|
/* Special case is if yc parent (yp) is choice/case
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -524,7 +524,7 @@ yang_cardinality(clicon_handle h,
|
||||||
/* 2) For all in 1 and 1..n list, if 0 such children ->ERROR */
|
/* 2) For all in 1 and 1..n list, if 0 such children ->ERROR */
|
||||||
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
|
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
|
||||||
if (yc->yc_min &&
|
if (yc->yc_min &&
|
||||||
yang_find((yang_node*)yt, yc->yc_child, NULL) == NULL){
|
yang_find(yt, yc->yc_child, NULL) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "%s: \"%s\" is missing but is mandatory child of \"%s\"",
|
clicon_err(OE_YANG, 0, "%s: \"%s\" is missing but is mandatory child of \"%s\"",
|
||||||
modname, yang_key2str(yc->yc_child), yang_key2str(pk));
|
modname, yang_key2str(yc->yc_child), yang_key2str(pk));
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -533,7 +533,7 @@ yang_cardinality(clicon_handle h,
|
||||||
/* 3) For all in 0..1 and 1 list, if >1 such children ->ERROR */
|
/* 3) For all in 0..1 and 1 list, if >1 such children ->ERROR */
|
||||||
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
|
for (yc = &ycplist[0]; (int)yc->yc_parent == pk; yc++){
|
||||||
if (yc->yc_max<NMAX &&
|
if (yc->yc_max<NMAX &&
|
||||||
(nr = yang_match((yang_node*)yt, yc->yc_child, NULL)) > yc->yc_max){
|
(nr = yang_match(yt, yc->yc_child, NULL)) > yc->yc_max){
|
||||||
clicon_err(OE_YANG, 0, "%s: \"%s\" has %d children of type \"%s\", but only %d allowed",
|
clicon_err(OE_YANG, 0, "%s: \"%s\" has %d children of type \"%s\", but only %d allowed",
|
||||||
modname,
|
modname,
|
||||||
yang_key2str(pk),
|
yang_key2str(pk),
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ int
|
||||||
yang_modules_init(clicon_handle h)
|
yang_modules_init(clicon_handle h)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if (!clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895"))
|
if (!clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895"))
|
||||||
|
|
@ -143,15 +143,15 @@ yang_modules_init(clicon_handle h)
|
||||||
char *
|
char *
|
||||||
yang_modules_revision(clicon_handle h)
|
yang_modules_revision(clicon_handle h)
|
||||||
{
|
{
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
yang_stmt *ymod;
|
yang_stmt *ymod;
|
||||||
yang_stmt *yrev;
|
yang_stmt *yrev;
|
||||||
char *revision = NULL;
|
char *revision = NULL;
|
||||||
|
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if ((ymod = yang_find((yang_node*)yspec, Y_MODULE, "ietf-yang-library")) != NULL ||
|
if ((ymod = yang_find(yspec, Y_MODULE, "ietf-yang-library")) != NULL ||
|
||||||
(ymod = yang_find((yang_node*)yspec, Y_SUBMODULE, "ietf-yang-library")) != NULL){
|
(ymod = yang_find(yspec, Y_SUBMODULE, "ietf-yang-library")) != NULL){
|
||||||
if ((yrev = yang_find((yang_node*)ymod, Y_REVISION, NULL)) != NULL){
|
if ((yrev = yang_find(ymod, Y_REVISION, NULL)) != NULL){
|
||||||
revision = yrev->ys_argument;
|
revision = yrev->ys_argument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ yang_modules_revision(clicon_handle h)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
yms_build(clicon_handle h,
|
yms_build(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
char *msid,
|
char *msid,
|
||||||
int brief,
|
int brief,
|
||||||
cbuf *cb)
|
cbuf *cb)
|
||||||
|
|
@ -175,12 +175,12 @@ yms_build(clicon_handle h,
|
||||||
yang_stmt *ymod; /* generic module */
|
yang_stmt *ymod; /* generic module */
|
||||||
yang_stmt *yns = NULL; /* namespace */
|
yang_stmt *yns = NULL; /* namespace */
|
||||||
|
|
||||||
if ((ylib = yang_find((yang_node*)yspec, Y_MODULE, module)) == NULL &&
|
if ((ylib = yang_find(yspec, Y_MODULE, module)) == NULL &&
|
||||||
(ylib = yang_find((yang_node*)yspec, Y_SUBMODULE, module)) == NULL){
|
(ylib = yang_find(yspec, Y_SUBMODULE, module)) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "%s not found", module);
|
clicon_err(OE_YANG, 0, "%s not found", module);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((yns = yang_find((yang_node*)ylib, Y_NAMESPACE, NULL)) == NULL){
|
if ((yns = yang_find(ylib, Y_NAMESPACE, NULL)) == NULL){
|
||||||
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
|
clicon_err(OE_YANG, 0, "%s yang namespace not found", module);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -189,17 +189,17 @@ yms_build(clicon_handle h,
|
||||||
cprintf(cb,"<module-set-id>%s</module-set-id>", msid);
|
cprintf(cb,"<module-set-id>%s</module-set-id>", msid);
|
||||||
|
|
||||||
ymod = NULL;
|
ymod = NULL;
|
||||||
while ((ymod = yn_each((yang_node*)yspec, ymod)) != NULL) {
|
while ((ymod = yn_each(yspec, ymod)) != NULL) {
|
||||||
if (ymod->ys_keyword != Y_MODULE &&
|
if (ymod->ys_keyword != Y_MODULE &&
|
||||||
ymod->ys_keyword != Y_SUBMODULE)
|
ymod->ys_keyword != Y_SUBMODULE)
|
||||||
continue;
|
continue;
|
||||||
cprintf(cb,"<module>");
|
cprintf(cb,"<module>");
|
||||||
cprintf(cb,"<name>%s</name>", ymod->ys_argument);
|
cprintf(cb,"<name>%s</name>", ymod->ys_argument);
|
||||||
if ((ys = yang_find((yang_node*)ymod, Y_REVISION, NULL)) != NULL)
|
if ((ys = yang_find(ymod, Y_REVISION, NULL)) != NULL)
|
||||||
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
|
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
|
||||||
else
|
else
|
||||||
cprintf(cb,"<revision></revision>");
|
cprintf(cb,"<revision></revision>");
|
||||||
if ((ys = yang_find((yang_node*)ymod, Y_NAMESPACE, NULL)) != NULL)
|
if ((ys = yang_find(ymod, Y_NAMESPACE, NULL)) != NULL)
|
||||||
cprintf(cb,"<namespace>%s</namespace>", ys->ys_argument);
|
cprintf(cb,"<namespace>%s</namespace>", ys->ys_argument);
|
||||||
else
|
else
|
||||||
cprintf(cb,"<namespace></namespace>");
|
cprintf(cb,"<namespace></namespace>");
|
||||||
|
|
@ -207,7 +207,7 @@ yms_build(clicon_handle h,
|
||||||
submodules */
|
submodules */
|
||||||
if (!brief){
|
if (!brief){
|
||||||
yc = NULL;
|
yc = NULL;
|
||||||
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
|
while ((yc = yn_each(ymod, yc)) != NULL) {
|
||||||
switch(yc->ys_keyword){
|
switch(yc->ys_keyword){
|
||||||
case Y_FEATURE:
|
case Y_FEATURE:
|
||||||
if (yc->ys_cv && cv_bool_get(yc->ys_cv))
|
if (yc->ys_cv && cv_bool_get(yc->ys_cv))
|
||||||
|
|
@ -220,12 +220,12 @@ yms_build(clicon_handle h,
|
||||||
cprintf(cb, "<conformance-type>implement</conformance-type>");
|
cprintf(cb, "<conformance-type>implement</conformance-type>");
|
||||||
}
|
}
|
||||||
yc = NULL;
|
yc = NULL;
|
||||||
while ((yc = yn_each((yang_node*)ymod, yc)) != NULL) {
|
while ((yc = yn_each(ymod, yc)) != NULL) {
|
||||||
switch(yc->ys_keyword){
|
switch(yc->ys_keyword){
|
||||||
case Y_SUBMODULE:
|
case Y_SUBMODULE:
|
||||||
cprintf(cb,"<submodule>");
|
cprintf(cb,"<submodule>");
|
||||||
cprintf(cb,"<name>%s</name>", yc->ys_argument);
|
cprintf(cb,"<name>%s</name>", yc->ys_argument);
|
||||||
if ((ys = yang_find((yang_node*)yc, Y_REVISION, NULL)) != NULL)
|
if ((ys = yang_find(yc, Y_REVISION, NULL)) != NULL)
|
||||||
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
|
cprintf(cb,"<revision>%s</revision>", ys->ys_argument);
|
||||||
else
|
else
|
||||||
cprintf(cb,"<revision></revision>");
|
cprintf(cb,"<revision></revision>");
|
||||||
|
|
@ -273,7 +273,7 @@ x +--ro namespace inet:uri
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
yang_modules_state_get(clicon_handle h,
|
yang_modules_state_get(clicon_handle h,
|
||||||
yang_spec *yspec,
|
yang_stmt *yspec,
|
||||||
char *xpath,
|
char *xpath,
|
||||||
int brief,
|
int brief,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
|
|
@ -362,7 +362,7 @@ mod_ns_upgrade(clicon_handle h,
|
||||||
uint32_t from = 0;
|
uint32_t from = 0;
|
||||||
uint32_t to = 0;
|
uint32_t to = 0;
|
||||||
int ret;
|
int ret;
|
||||||
yang_spec *yspec;
|
yang_stmt *yspec;
|
||||||
|
|
||||||
/* Make upgrade callback for this XML, specifying the module
|
/* Make upgrade callback for this XML, specifying the module
|
||||||
* namespace, from and to revision.
|
* namespace, from and to revision.
|
||||||
|
|
@ -376,7 +376,7 @@ mod_ns_upgrade(clicon_handle h,
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if ((ymod = yang_find_module_by_namespace(yspec, ns)) == NULL)
|
if ((ymod = yang_find_module_by_namespace(yspec, ns)) == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
if ((yrev = yang_find((yang_node*)ymod, Y_REVISION, NULL)) == NULL)
|
if ((yrev = yang_find(ymod, Y_REVISION, NULL)) == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (ys_parse_date_arg(yrev->ys_argument, &to) < 0)
|
if (ys_parse_date_arg(yrev->ys_argument, &to) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct ys_stack{
|
struct ys_stack{
|
||||||
struct ys_stack *ys_next;
|
struct ys_stack *ys_next;
|
||||||
struct yang_node *ys_node;
|
yang_stmt *ys_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clicon_yang_yacc_arg{ /* XXX: mostly unrelevant */
|
struct clicon_yang_yacc_arg{ /* XXX: mostly unrelevant */
|
||||||
|
|
@ -88,7 +88,7 @@ extern char *clixon_yang_parsetext;
|
||||||
int yang_scan_init(struct clicon_yang_yacc_arg *ya);
|
int yang_scan_init(struct clicon_yang_yacc_arg *ya);
|
||||||
int yang_scan_exit(struct clicon_yang_yacc_arg *ya);
|
int yang_scan_exit(struct clicon_yang_yacc_arg *ya);
|
||||||
|
|
||||||
int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_spec *ysp);
|
int yang_parse_init(struct clicon_yang_yacc_arg *ya, yang_stmt *ysp);
|
||||||
int yang_parse_exit(struct clicon_yang_yacc_arg *ya);
|
int yang_parse_exit(struct clicon_yang_yacc_arg *ya);
|
||||||
|
|
||||||
int clixon_yang_parselex(void *_ya);
|
int clixon_yang_parselex(void *_ya);
|
||||||
|
|
@ -96,6 +96,6 @@ int clixon_yang_parseparse(void *);
|
||||||
void clixon_yang_parseerror(void *_ya, char*);
|
void clixon_yang_parseerror(void *_ya, char*);
|
||||||
|
|
||||||
int ystack_pop(struct clicon_yang_yacc_arg *ya);
|
int ystack_pop(struct clicon_yang_yacc_arg *ya);
|
||||||
struct ys_stack *ystack_push(struct clicon_yang_yacc_arg *ya, yang_node *yn);
|
struct ys_stack *ystack_push(struct clicon_yang_yacc_arg *ya, yang_stmt *yn);
|
||||||
|
|
||||||
#endif /* _CLIXON_YANG_PARSE_H_ */
|
#endif /* _CLIXON_YANG_PARSE_H_ */
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ clixon_yang_parseerror(void *_yy,
|
||||||
|
|
||||||
int
|
int
|
||||||
yang_parse_init(struct clicon_yang_yacc_arg *yy,
|
yang_parse_init(struct clicon_yang_yacc_arg *yy,
|
||||||
yang_spec *ysp)
|
yang_stmt *ysp)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +246,7 @@ ystack_pop(struct clicon_yang_yacc_arg *yy)
|
||||||
|
|
||||||
struct ys_stack *
|
struct ys_stack *
|
||||||
ystack_push(struct clicon_yang_yacc_arg *yy,
|
ystack_push(struct clicon_yang_yacc_arg *yy,
|
||||||
yang_node *yn)
|
yang_stmt *yn)
|
||||||
{
|
{
|
||||||
struct ys_stack *ystack;
|
struct ys_stack *ystack;
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ ysp_add(struct clicon_yang_yacc_arg *yy,
|
||||||
{
|
{
|
||||||
struct ys_stack *ystack = yy->yy_stack;
|
struct ys_stack *ystack = yy->yy_stack;
|
||||||
yang_stmt *ys = NULL;
|
yang_stmt *ys = NULL;
|
||||||
yang_node *yn;
|
yang_stmt *yn;
|
||||||
|
|
||||||
ystack = yy->yy_stack;
|
ystack = yy->yy_stack;
|
||||||
if (ystack == NULL){
|
if (ystack == NULL){
|
||||||
|
|
@ -317,7 +317,7 @@ ysp_add_push(struct clicon_yang_yacc_arg *yy,
|
||||||
|
|
||||||
if ((ys = ysp_add(yy, keyword, argument, extra)) == NULL)
|
if ((ys = ysp_add(yy, keyword, argument, extra)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (ystack_push(yy, (yang_node*)ys) == NULL)
|
if (ystack_push(yy, ys) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return ys;
|
return ys;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -474,7 +474,7 @@ cv_validate1(cg_var *cv,
|
||||||
if (strcmp(restype, "enumeration") == 0){
|
if (strcmp(restype, "enumeration") == 0){
|
||||||
found = 0;
|
found = 0;
|
||||||
yi = NULL;
|
yi = NULL;
|
||||||
while ((yi = yn_each((yang_node*)yrestype, yi)) != NULL){
|
while ((yi = yn_each(yrestype, yi)) != NULL){
|
||||||
if (yi->ys_keyword != Y_ENUM)
|
if (yi->ys_keyword != Y_ENUM)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(yi->ys_argument, str) == 0){
|
if (strcmp(yi->ys_argument, str) == 0){
|
||||||
|
|
@ -500,7 +500,7 @@ cv_validate1(cg_var *cv,
|
||||||
continue;
|
continue;
|
||||||
found = 0;
|
found = 0;
|
||||||
yi = NULL;
|
yi = NULL;
|
||||||
while ((yi = yn_each((yang_node*)yrestype, yi)) != NULL){
|
while ((yi = yn_each(yrestype, yi)) != NULL){
|
||||||
if (yi->ys_keyword != Y_BIT)
|
if (yi->ys_keyword != Y_BIT)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(yi->ys_argument, v) == 0){
|
if (strcmp(yi->ys_argument, v) == 0){
|
||||||
|
|
@ -630,7 +630,7 @@ ys_cv_validate_union(yang_stmt *ys,
|
||||||
yang_stmt *yt = NULL;
|
yang_stmt *yt = NULL;
|
||||||
char *reason1 = NULL; /* saved reason */
|
char *reason1 = NULL; /* saved reason */
|
||||||
|
|
||||||
while ((yt = yn_each((yang_node*)yrestype, yt)) != NULL){
|
while ((yt = yn_each(yrestype, yt)) != NULL){
|
||||||
if (yt->ys_keyword != Y_TYPE)
|
if (yt->ys_keyword != Y_TYPE)
|
||||||
continue;
|
continue;
|
||||||
if ((retval = ys_cv_validate_union_one(ys, reason, yt, type, val)) < 0)
|
if ((retval = ys_cv_validate_union_one(ys, reason, yt, type, val)) < 0)
|
||||||
|
|
@ -744,12 +744,12 @@ ys_typedef(yang_stmt *ys)
|
||||||
static yang_stmt *
|
static yang_stmt *
|
||||||
ys_typedef_up(yang_stmt *ys)
|
ys_typedef_up(yang_stmt *ys)
|
||||||
{
|
{
|
||||||
yang_node *yn;
|
yang_stmt *yn;
|
||||||
|
|
||||||
while (ys != NULL && !ys_typedef(ys)){
|
while (ys != NULL && !ys_typedef(ys)){
|
||||||
yn = ys->ys_parent;
|
yn = ys->ys_parent;
|
||||||
/* Some extra stuff to ensure ys is a stmt */
|
/* Some extra stuff to ensure ys is a stmt */
|
||||||
if (yn && yn->yn_keyword == Y_SPEC)
|
if (yn && yn->ys_keyword == Y_SPEC)
|
||||||
yn = NULL;
|
yn = NULL;
|
||||||
ys = (yang_stmt*)yn;
|
ys = (yang_stmt*)yn;
|
||||||
}
|
}
|
||||||
|
|
@ -791,7 +791,7 @@ yang_find_identity(yang_stmt *ys,
|
||||||
char *prefix = NULL;
|
char *prefix = NULL;
|
||||||
yang_stmt *ymodule;
|
yang_stmt *ymodule;
|
||||||
yang_stmt *yid = NULL;
|
yang_stmt *yid = NULL;
|
||||||
yang_node *yn;
|
yang_stmt *yn;
|
||||||
|
|
||||||
if ((id = strchr(identity, ':')) == NULL)
|
if ((id = strchr(identity, ':')) == NULL)
|
||||||
id = identity;
|
id = identity;
|
||||||
|
|
@ -804,7 +804,7 @@ yang_find_identity(yang_stmt *ys,
|
||||||
if (prefix){ /* Go to top and find import that matches */
|
if (prefix){ /* Go to top and find import that matches */
|
||||||
if ((ymodule = yang_find_module_by_prefix(ys, prefix)) == NULL)
|
if ((ymodule = yang_find_module_by_prefix(ys, prefix)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
yid = yang_find((yang_node*)ymodule, Y_IDENTITY, id);
|
yid = yang_find(ymodule, Y_IDENTITY, id);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
while (1){
|
while (1){
|
||||||
|
|
@ -812,11 +812,11 @@ yang_find_identity(yang_stmt *ys,
|
||||||
if ((ys = ys_typedef_up(ys)) == NULL) /* If reach top */
|
if ((ys = ys_typedef_up(ys)) == NULL) /* If reach top */
|
||||||
break;
|
break;
|
||||||
/* Here find identity */
|
/* Here find identity */
|
||||||
if ((yid = yang_find((yang_node*)ys, Y_IDENTITY, id)) != NULL)
|
if ((yid = yang_find(ys, Y_IDENTITY, id)) != NULL)
|
||||||
break;
|
break;
|
||||||
/* Did not find a matching typedef there, proceed to next level */
|
/* Did not find a matching typedef there, proceed to next level */
|
||||||
yn = ys->ys_parent;
|
yn = ys->ys_parent;
|
||||||
if (yn && yn->yn_keyword == Y_SPEC)
|
if (yn && yn->ys_keyword == Y_SPEC)
|
||||||
yn = NULL;
|
yn = NULL;
|
||||||
ys = (yang_stmt*)yn;
|
ys = (yang_stmt*)yn;
|
||||||
}
|
}
|
||||||
|
|
@ -910,7 +910,7 @@ yang_type_resolve(yang_stmt *yorig,
|
||||||
char *type;
|
char *type;
|
||||||
char *prefix = NULL;
|
char *prefix = NULL;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
yang_node *yn;
|
yang_stmt *yn;
|
||||||
yang_stmt *yrmod; /* module where resolved type is looked for */
|
yang_stmt *yrmod; /* module where resolved type is looked for */
|
||||||
|
|
||||||
if (options)
|
if (options)
|
||||||
|
|
@ -926,10 +926,10 @@ yang_type_resolve(yang_stmt *yorig,
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
/* Resolving type restrictions */
|
/* Resolving type restrictions */
|
||||||
yrange = yang_find((yang_node*)ytype, Y_RANGE, NULL);
|
yrange = yang_find(ytype, Y_RANGE, NULL);
|
||||||
ylength = yang_find((yang_node*)ytype, Y_LENGTH, NULL);
|
ylength = yang_find(ytype, Y_LENGTH, NULL);
|
||||||
ypattern = yang_find((yang_node*)ytype, Y_PATTERN, NULL);
|
ypattern = yang_find(ytype, Y_PATTERN, NULL);
|
||||||
yfraction = yang_find((yang_node*)ytype, Y_FRACTION_DIGITS, NULL);
|
yfraction = yang_find(ytype, Y_FRACTION_DIGITS, NULL);
|
||||||
|
|
||||||
/* Check if type is basic type. If so, return that */
|
/* Check if type is basic type. If so, return that */
|
||||||
if (prefix == NULL && yang_builtin(type)){
|
if (prefix == NULL && yang_builtin(type)){
|
||||||
|
|
@ -946,7 +946,7 @@ yang_type_resolve(yang_stmt *yorig,
|
||||||
prefix, type, ys_module(yorig)->ys_argument);
|
prefix, type, ys_module(yorig)->ys_argument);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((rytypedef = yang_find((yang_node*)yrmod, Y_TYPEDEF, type)) == NULL)
|
if ((rytypedef = yang_find(yrmod, Y_TYPEDEF, type)) == NULL)
|
||||||
goto ok; /* unresolved */
|
goto ok; /* unresolved */
|
||||||
ys = rytypedef;
|
ys = rytypedef;
|
||||||
}
|
}
|
||||||
|
|
@ -958,17 +958,17 @@ yang_type_resolve(yang_stmt *yorig,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Here find typedef */
|
/* Here find typedef */
|
||||||
if ((rytypedef = yang_find((yang_node*)ys, Y_TYPEDEF, type)) != NULL)
|
if ((rytypedef = yang_find(ys, Y_TYPEDEF, type)) != NULL)
|
||||||
break;
|
break;
|
||||||
/* Did not find a matching typedef there, proceed to next level */
|
/* Did not find a matching typedef there, proceed to next level */
|
||||||
yn = ys->ys_parent;
|
yn = ys->ys_parent;
|
||||||
if (yn && (yn->yn_keyword == Y_SPEC))
|
if (yn && (yn->ys_keyword == Y_SPEC))
|
||||||
yn = NULL;
|
yn = NULL;
|
||||||
ys = (yang_stmt*)yn;
|
ys = (yang_stmt*)yn;
|
||||||
}
|
}
|
||||||
if (rytypedef != NULL){ /* We have found a typedef */
|
if (rytypedef != NULL){ /* We have found a typedef */
|
||||||
/* Find associated type statement */
|
/* Find associated type statement */
|
||||||
if ((rytype = yang_find((yang_node*)rytypedef, Y_TYPE, NULL)) == NULL){
|
if ((rytype = yang_find(rytypedef, Y_TYPE, NULL)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "mandatory type object is not found");
|
clicon_err(OE_DB, 0, "mandatory type object is not found");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -1045,7 +1045,7 @@ yang_type_get(yang_stmt *ys,
|
||||||
if (options)
|
if (options)
|
||||||
*options = 0x0;
|
*options = 0x0;
|
||||||
/* Find mandatory type */
|
/* Find mandatory type */
|
||||||
if ((ytype = yang_find((yang_node*)ys, Y_TYPE, NULL)) == NULL){
|
if ((ytype = yang_find(ys, Y_TYPE, NULL)) == NULL){
|
||||||
clicon_err(OE_DB, 0, "mandatory type object is not found");
|
clicon_err(OE_DB, 0, "mandatory type object is not found");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ main(int argc, char **argv)
|
||||||
char *argv0;
|
char *argv0;
|
||||||
char *db = "running";
|
char *db = "running";
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
char *yangfilename = NULL;
|
char *yangfilename = NULL;
|
||||||
char *dbdir = NULL;
|
char *dbdir = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ usage(char *argv0)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
yang_spec *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
int c;
|
int c;
|
||||||
int logdst = CLICON_LOG_STDERR;
|
int logdst = CLICON_LOG_STDERR;
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ main(int argc, char **argv)
|
||||||
fprintf(stderr, "yang parse error %s\n", clicon_err_reason);
|
fprintf(stderr, "yang parse error %s\n", clicon_err_reason);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
yang_print(stdout, (yang_node*)yspec);
|
yang_print(stdout, yspec);
|
||||||
done:
|
done:
|
||||||
if (yspec)
|
if (yspec)
|
||||||
yspec_free(yspec);
|
yspec_free(yspec);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue