- Modified linkage constant in makefile to test for dynamic only
- CLIXON_STATIC_PLUGIN to support statically linked plugins - Added -H option to clixon_netconf: Do not require hello before request
This commit is contained in:
parent
b70e22096e
commit
c00162aec1
16 changed files with 121 additions and 61 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <user>\tOver-ride unix user with a pseudo user for NACM.\n"
|
||||
"\t-t <sec>\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 \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
|
||||
argv0,
|
||||
clicon_netconf_dir(h)
|
||||
|
|
@ -764,6 +765,9 @@ main(int argc,
|
|||
case 'e': /* dont ignore packet errors */
|
||||
ignore_packet_errors = 0;
|
||||
break;
|
||||
case 'H': /* Hello messages are optional */
|
||||
clicon_option_bool_set(h, "CLICON_NETCONF_HELLO_OPTIONAL", 1);
|
||||
break;
|
||||
case 'o':{ /* Configuration option */
|
||||
char *val;
|
||||
if ((val = index(optarg, '=')) == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue