diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index c6263576..eb915210 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -111,8 +111,6 @@ backend_terminate(clicon_handle h) yspec_free(yspec); if ((nsctx = clicon_nsctx_global_get(h)) != NULL) cvec_free(nsctx); - if ((yspec = clicon_config_yang(h)) != NULL) - yspec_free(yspec); if ((x = clicon_nacm_ext(h)) != NULL) xml_free(x); if ((x = clicon_conf_xml(h)) != NULL) @@ -519,7 +517,6 @@ main(int argc, usage(h, argv[0]); return -1; } - clicon_config_yang_set(h, yspecfg); /* External NACM file? */ nacm_mode = clicon_option_str(h, "CLICON_NACM_MODE"); if (nacm_mode && strcmp(nacm_mode, "external") == 0) diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index c0981710..83c38625 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -169,8 +169,6 @@ cli_terminate(clicon_handle h) clicon_rpc_close_session(h); if ((yspec = clicon_dbspec_yang(h)) != NULL) yspec_free(yspec); - if ((yspec = clicon_config_yang(h)) != NULL) - yspec_free(yspec); if ((nsctx = clicon_nsctx_global_get(h)) != NULL) cvec_free(nsctx); if ((x = clicon_conf_xml(h)) != NULL) @@ -361,7 +359,6 @@ main(int argc, char **argv) usage(h, argv[0]); return -1; } - clicon_config_yang_set(h, yspecfg); /* Now rest of options */ opterr = 0; optind = 1; diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index ec527cb8..153ec13f 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -331,8 +331,6 @@ netconf_terminate(clicon_handle h) clicon_rpc_close_session(h); if ((yspec = clicon_dbspec_yang(h)) != NULL) yspec_free(yspec); - if ((yspec = clicon_config_yang(h)) != NULL) - yspec_free(yspec); if ((nsctx = clicon_nsctx_global_get(h)) != NULL) cvec_free(nsctx); if ((x = clicon_conf_xml(h)) != NULL) @@ -449,7 +447,6 @@ main(int argc, /* Find and read configfile */ if (clicon_options_main(h, yspecfg) < 0) return -1; - clicon_config_yang_set(h, yspecfg); /* Now rest of options */ optind = 1; opterr = 0; diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index 22d474cb..b79de44f 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -605,8 +605,6 @@ restconf_terminate(clicon_handle h) clicon_rpc_close_session(h); if ((yspec = clicon_dbspec_yang(h)) != NULL) yspec_free(yspec); - if ((yspec = clicon_config_yang(h)) != NULL) - yspec_free(yspec); if ((nsctx = clicon_nsctx_global_get(h)) != NULL) cvec_free(nsctx); if ((x = clicon_conf_xml(h)) != NULL) diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index d7c6dc48..f188f7da 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -648,7 +648,6 @@ main(int argc, /* Find and read configfile */ if (clicon_options_main(h, yspecfg) < 0) goto done; - clicon_config_yang_set(h, yspecfg); stream_path = clicon_option_str(h, "CLICON_STREAM_PATH"); /* Now rest of options, some overwrite option file */ optind = 1; diff --git a/lib/clixon/clixon_data.h b/lib/clixon/clixon_data.h index b1b61926..3f173e04 100644 --- a/lib/clixon/clixon_data.h +++ b/lib/clixon/clixon_data.h @@ -67,9 +67,6 @@ int clicon_nsctx_global_set(clicon_handle h, cvec *nsctx); cxobj * clicon_nacm_ext(clicon_handle h); int clicon_nacm_ext_set(clicon_handle h, cxobj *xn); -yang_stmt * clicon_config_yang(clicon_handle h); -int clicon_config_yang_set(clicon_handle h, yang_stmt *ys); - cxobj *clicon_conf_xml(clicon_handle h); int clicon_conf_xml_set(clicon_handle h, cxobj *x); diff --git a/lib/src/clixon_data.c b/lib/src/clixon_data.c index 3e6a6298..595e5db3 100644 --- a/lib/src/clixon_data.c +++ b/lib/src/clixon_data.c @@ -113,6 +113,10 @@ clicon_dbspec_yang_set(clicon_handle h, * Canonical: use prefix and namespace specified in the yang modules. * @param[in] h Clicon handle * @retval nsctx Namespace context (malloced) + * @code + * cvec *nsctx; + * nsctx = clicon_nsctx_global_get(h); + * @endcode */ cvec * clicon_nsctx_global_get(clicon_handle h) @@ -186,41 +190,6 @@ clicon_nacm_ext_set(clicon_handle h, return 0; } - -#if 1 /* Temporary function until "Top-level Yang symbol cannot be called "config"" is fixed */ -/*! Get YANG specification for clixon config - * Must use hash functions directly since they are not strings. - */ -yang_stmt * -clicon_config_yang(clicon_handle h) -{ - clicon_hash_t *cdat = clicon_data(h); - size_t len; - void *p; - - if ((p = clicon_hash_value(cdat, "control_yang", &len)) != NULL) - return *(yang_stmt **)p; - return NULL; -} - -/*! Set yang specification for control - * ys must be a malloced pointer - */ -int -clicon_config_yang_set(clicon_handle h, - yang_stmt *ys) -{ - clicon_hash_t *cdat = clicon_data(h); - - /* It is the pointer to ys that should be copied by hash, - so we send a ptr to the ptr to indicate what to copy. - */ - if (clicon_hash_add(cdat, "control_yang", &ys, sizeof(ys)) == NULL) - return -1; - return 0; -} -#endif - /*! Get YANG specification for Clixon system options and features * Must use hash functions directly since they are not strings. * Example: features are typically accessed directly in the config tree. diff --git a/lib/src/clixon_xml_nsctx.c b/lib/src/clixon_xml_nsctx.c index 1134d000..6cabf39a 100644 --- a/lib/src/clixon_xml_nsctx.c +++ b/lib/src/clixon_xml_nsctx.c @@ -387,6 +387,9 @@ xml_nsctx_yangspec(yang_stmt *yspec, if (xml_nsctx_add(nc, yang_argument_get(yprefix), yang_argument_get(ynamespace)) < 0) goto done; } + /* Add base netconf namespace as default and "nc" prefix */ + if (xml_nsctx_add(nc, NULL, NETCONF_BASE_NAMESPACE) < 0) + goto done; if (xml_nsctx_add(nc, NETCONF_BASE_PREFIX, NETCONF_BASE_NAMESPACE) < 0) goto done; *ncp = nc;