diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c300aa3..9d613f22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Expected: September, 2021 * ietf-restconf-list-pagination@2015-01-30.yang * clixon-netconf-list-pagination@2021-08-27.yang * ietf-yang-metadata@2016-08-05.yang + * New http media: application/yang-collection+xml/json * Updated state callback signature containing parameters for pagination * See API changes below * YANG Leafref feature update @@ -63,8 +64,7 @@ Expected: September, 2021 * Thanks to Alan Yaniger for providing this patch * List pagination * This is prototype work for ietf netconf work - * See draft-wwlh-netconf-list-pagination-00.txt - * New http media: application/yang-collection+xml/json + * New state callback signature (ca_statedata2) * The new callback contains parameters for pagination diff --git a/apps/backend/Makefile.in b/apps/backend/Makefile.in index 773a7d48..2ee7056e 100644 --- a/apps/backend/Makefile.in +++ b/apps/backend/Makefile.in @@ -47,7 +47,7 @@ endif SH_SUFFIX = @SH_SUFFIX@ INSTALLFLAGS = @INSTALLFLAGS@ LDFLAGS = @LDFLAGS@ -ifeq ($(LINKAGE),static) +ifneq ($(LINKAGE),dynamic) LDFLAGS += -rdynamic -L. endif prefix = @prefix@ @@ -65,10 +65,10 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ # Use this clixon lib for linking -ifeq ($(LINKAGE),static) - CLIXON_LIB = libclixon.a -else +ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) +else + CLIXON_LIB = libclixon.a endif # For dependency. A little strange that we rely on it being built in the src dir @@ -104,10 +104,10 @@ MYLIBSO = lib$(MYNAME)$(SH_SUFFIX).$(CLIXON_MAJOR) MYLIBLINK = lib$(MYNAME)$(SH_SUFFIX) MYLIBSTATIC = lib$(MYNAME).a -ifeq ($(LINKAGE),static) - MYLIB = $(MYLIBSTATIC) -else +ifeq ($(LINKAGE),dynamic) MYLIB = $(MYLIBDYNAMIC) +else + MYLIB = $(MYLIBSTATIC) endif all: $(MYLIB) $(APPL) test diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index 17f1c779..a91a679e 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -607,6 +607,7 @@ get_list_pagination(clicon_handle h, offset, limit, &remaining, &xret)) < 0) goto done; } + /* Help function to filter out anything that is outside of xpath */ if (filter_xpath_again(h, yspec, xret, xpath, nsc, &x1) < 0) goto done; #ifdef LIST_PAGINATION_REMAINING diff --git a/apps/cli/Makefile.in b/apps/cli/Makefile.in index 91bcd795..85a6a76b 100644 --- a/apps/cli/Makefile.in +++ b/apps/cli/Makefile.in @@ -46,7 +46,7 @@ endif SH_SUFFIX = @SH_SUFFIX@ INSTALLFLAGS = @INSTALLFLAGS@ LDFLAGS = @LDFLAGS@ -ifeq ($(LINKAGE),static) +ifneq ($(LINKAGE),dynamic) LDFLAGS += -rdynamic -L. endif @@ -66,10 +66,10 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@ # Use this clixon lib for linking -ifeq ($(LINKAGE),static) - CLIXON_LIB = libclixon.a -else +ifeq ($(LINKAGE),dynamic) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR) +else + CLIXON_LIB = libclixon.a endif # For dependency. A little strange that we rely on it being built in the src dir @@ -87,6 +87,10 @@ APPL = clixon_cli APPSRC = cli_main.c APPOBJ = $(APPSRC:.c=.o) +# HACK +#EXTRAS += $(top_srcdir)/example/main/example_cli.o +#EXTRAS += $(top_srcdir)/example/main/test_cli.o + # Accessible from plugin LIBSRC = cli_common.c LIBSRC += cli_show.c @@ -165,7 +169,7 @@ $(APPL): $(APPOBJ) $(MYLIB) $(LIBDEPS) ifeq ($(LINKAGE),dynamic) $(CC) $(LDFLAGS) $(APPOBJ) -L. $(MYLIB) $(LIBS) -o $@ else - $(CC) $(LDFLAGS) $(APPOBJ) -L. $(LIBOBJ) $(LIBS) -o $@ + $(CC) $(LDFLAGS) $(APPOBJ) $(EXTRAS) -L. $(LIBOBJ) $(LIBS) -o $@ endif $(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS) diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 498e6ac9..756658c4 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -412,7 +412,6 @@ main(int argc, struct passwd *pw; char *str; int tabmode; - char *dir; cvec *nsctx_global = NULL; /* Global namespace context */ size_t cligen_buflen; size_t cligen_bufthreshold; @@ -623,11 +622,17 @@ main(int argc, if (clixon_plugin_module_init(h) < 0) goto done; - /* Load cli plugins before yangs are loaded (eg extension callbacks) */ - if ((dir = clicon_cli_dir(h)) != NULL && - clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir, NULL) < 0) - goto done; - +#ifndef CLIXON_STATIC_PLUGINS + { + char *dir; + /* Load cli .so plugins before yangs are loaded (eg extension callbacks) and + * before CLI is loaded by cli_syntax_load below */ + if ((dir = clicon_cli_dir(h)) != NULL && + clixon_plugins_load(h, CLIXON_PLUGIN_INIT, dir, NULL) < 0) + goto done; + } +#endif + /* Add (hardcoded) netconf features in case ietf-netconf loaded here * Otherwise it is loaded in netconf_module_load below */ @@ -685,7 +690,8 @@ main(int argc, if (autocli_start(h, printgen) < 0) goto done; - /* Initialize cli syntax */ + /* Initialize cli syntax. + * Plugins have already been loaded by clixon_plugins_load above */ if (cli_syntax_load(h) < 0) goto done; diff --git a/apps/cli/cli_plugin.c b/apps/cli/cli_plugin.c index 255866d2..0930438b 100644 --- a/apps/cli/cli_plugin.c +++ b/apps/cli/cli_plugin.c @@ -249,10 +249,16 @@ clixon_str2fn(char *name, } /*! Load a file containing syntax and append to specified modes, also load C plugin + * + * First load CLIgen file, + * Then find which .so to load by looking in the "CLICON_PLUGIN" variable in that file. + * Make a lookup of plugins already loaded and resolve callbacks from cligen trees to + * dl symbols in the plugin. * @param[in] h Clixon handle * @param[in] filename Name of file where syntax is specified (in syntax-group dir) * @param[in] dir Name of dir, or NULL * @param[out] ptall Universal CLIgen parse tree: apply to all modes + * @see clixon_plugins_load Where .so plugin code has been loaded prior to this */ static int cli_load_syntax_file(clicon_handle h, @@ -271,7 +277,9 @@ cli_load_syntax_file(clicon_handle h, char **vec = NULL; int i, nvec; char *plgnam; +#ifndef CLIXON_STATIC_PLUGINS clixon_plugin_t *cp; +#endif if ((pt = pt_new()) == NULL){ clicon_err(OE_UNIX, errno, "pt_new"); @@ -311,6 +319,7 @@ cli_load_syntax_file(clicon_handle h, prompt = cvec_find_str(cvv, "CLICON_PROMPT"); plgnam = cvec_find_str(cvv, "CLICON_PLUGIN"); +#ifndef CLIXON_STATIC_PLUGINS if (plgnam != NULL) { /* Find plugin for callback resolving */ if ((cp = clixon_plugin_find(h, plgnam)) != NULL) handle = clixon_plugin_handle_get(cp); @@ -321,6 +330,7 @@ cli_load_syntax_file(clicon_handle h, goto done; } } +#endif /* Resolve callback names to function pointers. */ if (cligen_callbackv_str2fn(pt, (cgv_str2fn_t*)clixon_str2fn, handle) < 0){ clicon_err(OE_PLUGIN, 0, "Mismatch between CLIgen file '%s' and CLI plugin file '%s'. Some possible errors:\n\t1. A function given in the CLIgen file does not exist in the plugin (ie link error)\n\t2. The CLIgen spec does not point to the correct plugin .so file (CLICON_PLUGIN=\"%s\" is wrong)", @@ -346,7 +356,7 @@ cli_load_syntax_file(clicon_handle h, goto done; if (nvec == 1 && strcmp(vec[0], "*") == 0){ - /* Special case: Add this to all modes. Add to special "universal" syntax + /* Special case: Add this to all modes. Add to special "universal" syntax * and add to all syntaxes after all files have been loaded. At this point * all modes may not be known (not yet loaded) */ @@ -377,7 +387,10 @@ done: return retval; } -/*! Load a syntax group. Includes both CLI plugin and CLIgen spec syntax files. +/*! CLIgen spec syntax files and create CLIgen trees to drive the CLI syntax generator + * + * CLI .so plugins have been loaded: syntax table in place. + * Now load cligen syntax files and create cligen pt trees. * @param[in] h Clicon handle */ int diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index ca49f26a..4a574529 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -71,7 +71,7 @@ #include "netconf_rpc.h" /* Command line options to be passed to getopt(3) */ -#define NETCONF_OPTS "hD:f:E:l:qa:u:d:p:y:U:t:eo:" +#define NETCONF_OPTS "hD:f:E:l:qa:u:d:p:y:U:t:eHo:" #define NETCONF_LOGFILE "/tmp/clixon_netconf.log" @@ -636,6 +636,7 @@ usage(clicon_handle h, "\t-U \tOver-ride unix user with a pseudo user for NACM.\n" "\t-t \tTimeout in seconds. Quit after this time.\n" "\t-e \t\tDont ignore errors on packet input.\n" + "\t-H \t\tHello messages are optional.\n" "\t-o \"