Initial Net-snmp frontend commit
Added apps/snmp with makefiles, autotools, docker adjustment Minimal snmp_main program
This commit is contained in:
parent
cca8c88ec1
commit
451cbef23d
9 changed files with 609 additions and 11 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -2,9 +2,9 @@ name: Clixon CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, http-data ]
|
branches: [ master, snmp ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master, http-data ]
|
branches: [ master, snmp ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
||||||
25
CHANGELOG.md
25
CHANGELOG.md
|
|
@ -34,14 +34,35 @@
|
||||||
* [3.3.2](#332) Aug 27 2017
|
* [3.3.2](#332) Aug 27 2017
|
||||||
* [3.3.1](#331) June 7 2017
|
* [3.3.1](#331) June 7 2017
|
||||||
|
|
||||||
|
### New features
|
||||||
|
|
||||||
|
* Clixon SNMP frontend
|
||||||
|
* net-snmp and MIB to YANG translation
|
||||||
|
* Experimental work
|
||||||
|
|
||||||
|
* Extended the Restconf implementation with a limited http-data static service
|
||||||
|
* Added two new config options to clixon-config.yang:
|
||||||
|
* `CLICON_HTTP_DATA_PATH`
|
||||||
|
* `CLICON_HTTP_DATA_ROOT`
|
||||||
|
* Added feature http-data to restconf-config.yang and the following option:
|
||||||
|
* `enable-http-data`
|
||||||
|
* The limited implementation is as follows:
|
||||||
|
* path: Local static files within `CLICON_WWW_DATA_ROOT`
|
||||||
|
* operation GET, HEAD, or OPTIONS
|
||||||
|
* query parameters not supported
|
||||||
|
* no indata
|
||||||
|
* media: html, css, js, fonts, image,
|
||||||
|
7. Authentication, TLS, http/2 as restconf
|
||||||
|
Generic changes:
|
||||||
|
* Uniform path selection across fcgi, native http/1 + http/2
|
||||||
|
|
||||||
|
|
||||||
## 5.7.0
|
## 5.7.0
|
||||||
17 May 2022
|
17 May 2022
|
||||||
|
|
||||||
The Clixon 5.7 release introduces (long overdue) NETCONF chunked framing as defined
|
The Clixon 5.7 release introduces (long overdue) NETCONF chunked framing as defined
|
||||||
in RFC 6242. It also introduces a limited http data service and lots of bugfixes.
|
in RFC 6242. It also introduces a limited http data service and lots of bugfixes.
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
* Implementation of "chunked framing" according to RFC6242 for Netconf 1.1.
|
* Implementation of "chunked framing" according to RFC6242 for Netconf 1.1.
|
||||||
* First hello is 1.0 EOM framing, then successing rpc is chunked framing
|
* First hello is 1.0 EOM framing, then successing rpc is chunked framing
|
||||||
* See
|
* See
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ VPATH = @srcdir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
with_restconf = @with_restconf@
|
with_restconf = @with_restconf@
|
||||||
|
enable_netsnmp = @enable_netsnmp@
|
||||||
|
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
|
@ -47,6 +48,11 @@ SUBDIRS += netconf
|
||||||
ifdef with_restconf
|
ifdef with_restconf
|
||||||
SUBDIRS += restconf
|
SUBDIRS += restconf
|
||||||
endif
|
endif
|
||||||
|
ifdef enable_netsnmp
|
||||||
|
ifeq ($(enable_netsnmp),yes)
|
||||||
|
SUBDIRS += snmp
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: all clean depend install $(SUBDIRS)
|
.PHONY: all clean depend install $(SUBDIRS)
|
||||||
|
|
||||||
|
|
|
||||||
131
apps/snmp/Makefile.in
Normal file
131
apps/snmp/Makefile.in
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
#
|
||||||
|
# ***** BEGIN LICENSE BLOCK *****
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 Olof Hagsand and Kristofer Hallin
|
||||||
|
#
|
||||||
|
# This file is part of CLIXON
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# Alternatively, the contents of this file may be used under the terms of
|
||||||
|
# the GNU General Public License Version 3 or later (the "GPL"),
|
||||||
|
# in which case the provisions of the GPL are applicable instead
|
||||||
|
# of those above. If you wish to allow use of your version of this file only
|
||||||
|
# under the terms of the GPL, and not to allow others to
|
||||||
|
# use your version of this file under the terms of Apache License version 2,
|
||||||
|
# indicate your decision by deleting the provisions above and replace them with
|
||||||
|
# the notice and other provisions required by the GPL. If you do not delete
|
||||||
|
# the provisions above, a recipient may use your version of this file under
|
||||||
|
# the terms of any one of the Apache License version 2 or the GPL.
|
||||||
|
#
|
||||||
|
# ***** END LICENSE BLOCK *****
|
||||||
|
#
|
||||||
|
#
|
||||||
|
VPATH = @srcdir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
CC = @CC@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
LINKAGE = @LINKAGE@
|
||||||
|
INSTALLFLAGS = @INSTALLFLAGS@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
bindir = @bindir@
|
||||||
|
libdir = @libdir@
|
||||||
|
sbindir = @sbindir@
|
||||||
|
mandir = @mandir@
|
||||||
|
libexecdir = @libexecdir@
|
||||||
|
localstatedir = @localstatedir@
|
||||||
|
sysconfdir = @sysconfdir@
|
||||||
|
includedir = @includedir@
|
||||||
|
HOST_VENDOR = @host_vendor@
|
||||||
|
|
||||||
|
SH_SUFFIX = @SH_SUFFIX@
|
||||||
|
LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@
|
||||||
|
CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@
|
||||||
|
CLIXON_MINOR = @CLIXON_VERSION_MINOR@
|
||||||
|
|
||||||
|
# Use this clixon lib for linking
|
||||||
|
ifeq ($(LINKAGE),dynamic)
|
||||||
|
CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
|
||||||
|
else
|
||||||
|
CLIXON_LIB = libclixon$(LIBSTATIC_SUFFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# For dependency
|
||||||
|
LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB)
|
||||||
|
|
||||||
|
LIBS = -L$(top_srcdir)/lib/src $(top_srcdir)/lib/src/$(CLIXON_LIB) @LIBS@
|
||||||
|
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
|
||||||
|
ifeq ($(LINKAGE),dynamic)
|
||||||
|
CPPFLAGS += -fPIC
|
||||||
|
endif
|
||||||
|
|
||||||
|
INCLUDES = -I. -I$(top_srcdir)/lib/src -I$(top_srcdir)/lib -I$(top_srcdir)/include -I$(top_srcdir) @INCLUDES@
|
||||||
|
|
||||||
|
# Application
|
||||||
|
APPL = clixon_snmp
|
||||||
|
|
||||||
|
# Common source - not accessible from plugin - independent of restconf package (fcgi|native)
|
||||||
|
APPSRC =
|
||||||
|
APPSRC += snmp_main.c
|
||||||
|
|
||||||
|
APPOBJ = $(APPSRC:.c=.o)
|
||||||
|
|
||||||
|
all: $(APPL)
|
||||||
|
|
||||||
|
# Dependency of clixon library (LIBDEPS)
|
||||||
|
$(top_srcdir)/lib/src/$(CLIXON_LIB):
|
||||||
|
(cd $(top_srcdir)/lib/src && $(MAKE) $(MFLAGS) $(CLIXON_LIB))
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.core $(APPL) $(APPOBJ) *.o
|
||||||
|
rm -f *.gcda *.gcno *.gcov # coverage
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile *~ .depend
|
||||||
|
|
||||||
|
# Put daemon in bin
|
||||||
|
# Put other executables in libexec/
|
||||||
|
install: $(APPL)
|
||||||
|
install -d -m 0755 $(DESTDIR)$(sbindir)
|
||||||
|
install -m 0755 $(INSTALLFLAGS) $(APPL) $(DESTDIR)$(sbindir)
|
||||||
|
|
||||||
|
install-include:
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(DESTDIR)$(sbindir)/$(APPL)
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .c .o
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(INCLUDES) -D__PROGRAM__=\"clixon_snmp\" $(CPPFLAGS) $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
$(APPL) : $(APPOBJ) $(LIBDEPS)
|
||||||
|
echo $(APPOBJ)
|
||||||
|
echo $(LIBDEPS)
|
||||||
|
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||||
|
|
||||||
|
TAGS:
|
||||||
|
find . -name '*.[chyl]' -print | etags -
|
||||||
|
|
||||||
|
depend:
|
||||||
|
$(CC) $(DEPENDFLAGS) @DEFS@ $(INCLUDES) $(CFLAGS) -MM $(APPFCGI) $(APPSRC) > .depend
|
||||||
|
|
||||||
|
#include .depend
|
||||||
327
apps/snmp/snmp_main.c
Normal file
327
apps/snmp/snmp_main.c
Normal file
|
|
@ -0,0 +1,327 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright (C) 2022 Olof Hagsand and Kristofer Hallin
|
||||||
|
|
||||||
|
This file is part of CLIXON.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Alternatively, the contents of this file may be used under the terms of
|
||||||
|
the GNU General Public License Version 3 or later (the "GPL"),
|
||||||
|
in which case the provisions of the GPL are applicable instead
|
||||||
|
of those above. If you wish to allow use of your version of this file only
|
||||||
|
under the terms of the GPL, and not to allow others to
|
||||||
|
use your version of this file under the terms of Apache License version 2,
|
||||||
|
indicate your decision by deleting the provisions above and replace them with
|
||||||
|
the notice and other provisions required by the GPL. If you do not delete
|
||||||
|
the provisions above, a recipient may use your version of this file under
|
||||||
|
the terms of any one of the Apache License version 2 or the GPL.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "clixon_config.h" /* generated by config & autoconf */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <net-snmp/net-snmp-config.h>
|
||||||
|
|
||||||
|
/* cligen */
|
||||||
|
#include <cligen/cligen.h>
|
||||||
|
|
||||||
|
/* clicon */
|
||||||
|
#include <clixon/clixon.h>
|
||||||
|
|
||||||
|
/* Command line options to be passed to getopt(3) */
|
||||||
|
#define SNMP_OPTS "hD:f:l:o:"
|
||||||
|
|
||||||
|
/*! XXX netsnmp API goes here
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
snmp_input_cb(int s,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
retval = 0;
|
||||||
|
// done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Clean and close all state of netconf process (but dont exit).
|
||||||
|
* Cannot use h after this
|
||||||
|
* @param[in] h Clixon handle
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
snmp_terminate(clicon_handle h)
|
||||||
|
{
|
||||||
|
yang_stmt *yspec;
|
||||||
|
cvec *nsctx;
|
||||||
|
cxobj *x;
|
||||||
|
|
||||||
|
clicon_rpc_close_session(h);
|
||||||
|
if ((yspec = clicon_dbspec_yang(h)) != NULL)
|
||||||
|
ys_free(yspec);
|
||||||
|
if ((yspec = clicon_config_yang(h)) != NULL)
|
||||||
|
ys_free(yspec);
|
||||||
|
if ((nsctx = clicon_nsctx_global_get(h)) != NULL)
|
||||||
|
cvec_free(nsctx);
|
||||||
|
if ((x = clicon_conf_xml(h)) != NULL)
|
||||||
|
xml_free(x);
|
||||||
|
xpath_optimize_exit();
|
||||||
|
clixon_event_exit();
|
||||||
|
clicon_handle_exit(h);
|
||||||
|
clixon_err_exit();
|
||||||
|
clicon_log_exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Setup signal handlers
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
snmp_signal_init (clicon_handle h)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
if (set_signal(SIGPIPE, SIG_IGN, NULL) < 0){
|
||||||
|
clicon_err(OE_UNIX, errno, "Setting DIGPIPE signal");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Usage help routine
|
||||||
|
* @param[in] h Clixon handle
|
||||||
|
* @param[in] argv0 command line
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
usage(clicon_handle h,
|
||||||
|
char *argv0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage:%s\n"
|
||||||
|
"where options are\n"
|
||||||
|
"\t-h\t\tHelp\n"
|
||||||
|
"\t-D <level>\tDebug level\n"
|
||||||
|
"\t-f <file>\tConfiguration file (mandatory)\n"
|
||||||
|
"\t-l (e|o|s|f<file>) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n"
|
||||||
|
"\t-o \"<option>=<value>\"\tGive configuration option overriding config file (see clixon-config.yang)\n",
|
||||||
|
argv0
|
||||||
|
);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc,
|
||||||
|
char **argv)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
int c;
|
||||||
|
char *argv0 = argv[0];
|
||||||
|
clicon_handle h;
|
||||||
|
int logdst = CLICON_LOG_STDERR;
|
||||||
|
struct passwd *pw;
|
||||||
|
yang_stmt *yspec = NULL;
|
||||||
|
char *str;
|
||||||
|
uint32_t id;
|
||||||
|
cvec *nsctx_global = NULL; /* Global namespace context */
|
||||||
|
size_t cligen_buflen;
|
||||||
|
size_t cligen_bufthreshold;
|
||||||
|
int dbg = 0;
|
||||||
|
size_t sz;
|
||||||
|
|
||||||
|
/* Create handle */
|
||||||
|
if ((h = clicon_handle_init()) == NULL)
|
||||||
|
return -1;
|
||||||
|
/* In the startup, logs to stderr & debug flag set later */
|
||||||
|
clicon_log_init(__PROGRAM__, LOG_INFO, logdst);
|
||||||
|
|
||||||
|
/* Set username to clixon handle. Use in all communication to backend */
|
||||||
|
if ((pw = getpwuid(getuid())) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "getpwuid");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (clicon_username_set(h, pw->pw_name) < 0)
|
||||||
|
goto done;
|
||||||
|
while ((c = getopt(argc, argv, SNMP_OPTS)) != -1)
|
||||||
|
switch (c) {
|
||||||
|
case 'h' : /* help */
|
||||||
|
usage(h, argv[0]);
|
||||||
|
break;
|
||||||
|
case 'D' : /* debug */
|
||||||
|
if (sscanf(optarg, "%d", &dbg) != 1)
|
||||||
|
usage(h, argv[0]);
|
||||||
|
break;
|
||||||
|
case 'f': /* override config file */
|
||||||
|
if (!strlen(optarg))
|
||||||
|
usage(h, argv[0]);
|
||||||
|
clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg);
|
||||||
|
break;
|
||||||
|
case 'l': /* Log destination: s|e|o */
|
||||||
|
if ((logdst = clicon_log_opt(optarg[0])) < 0)
|
||||||
|
usage(h, argv[0]);
|
||||||
|
if (logdst == CLICON_LOG_FILE &&
|
||||||
|
strlen(optarg)>1 &&
|
||||||
|
clicon_log_file(optarg+1) < 0)
|
||||||
|
goto done;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Logs, error and debug to stderr or syslog, set debug level
|
||||||
|
*/
|
||||||
|
clicon_log_init(__PROGRAM__, dbg?LOG_DEBUG:LOG_INFO, logdst);
|
||||||
|
clicon_debug_init(dbg, NULL);
|
||||||
|
yang_init(h);
|
||||||
|
|
||||||
|
/* Find, read and parse configfile */
|
||||||
|
if (clicon_options_main(h) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Now rest of options */
|
||||||
|
optind = 1;
|
||||||
|
opterr = 0;
|
||||||
|
while ((c = getopt(argc, argv, SNMP_OPTS)) != -1)
|
||||||
|
switch (c) {
|
||||||
|
case 'h' : /* help */
|
||||||
|
case 'D' : /* debug */
|
||||||
|
case 'f': /* config file */
|
||||||
|
case 'l': /* log */
|
||||||
|
break; /* see above */
|
||||||
|
case 'o':{ /* Configuration option */
|
||||||
|
char *val;
|
||||||
|
if ((val = index(optarg, '=')) == NULL)
|
||||||
|
usage(h, argv0);
|
||||||
|
*val++ = '\0';
|
||||||
|
if (clicon_option_add(h, optarg, val) < 0)
|
||||||
|
goto done;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
usage(h, argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
/* Access the remaining argv/argc options (after --) w clicon-argv_get() */
|
||||||
|
clicon_argv_set(h, argv0, argc, argv);
|
||||||
|
|
||||||
|
/* Init cligen buffers */
|
||||||
|
cligen_buflen = clicon_option_int(h, "CLICON_CLI_BUF_START");
|
||||||
|
cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD");
|
||||||
|
cbuf_alloc_set(cligen_buflen, cligen_bufthreshold);
|
||||||
|
|
||||||
|
if ((sz = clicon_option_int(h, "CLICON_LOG_STRING_LIMIT")) != 0)
|
||||||
|
clicon_log_string_limit_set(sz);
|
||||||
|
|
||||||
|
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
|
||||||
|
xml_nsctx_namespace_netconf_default(h);
|
||||||
|
|
||||||
|
/* Add (hardcoded) netconf features in case ietf-netconf loaded here
|
||||||
|
* Otherwise it is loaded in netconf_module_load below
|
||||||
|
*/
|
||||||
|
if (netconf_module_features(h) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Setup signal handlers, int particular PIPE that occurs if backend closes / restarts */
|
||||||
|
if (snmp_signal_init(h) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* In case ietf-yang-metadata is loaded by application, handle annotation extension */
|
||||||
|
if (0 && yang_metadata_init(h) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Create top-level yang spec and store as option */
|
||||||
|
if ((yspec = yspec_new()) == NULL)
|
||||||
|
goto done;
|
||||||
|
clicon_dbspec_yang_set(h, yspec);
|
||||||
|
|
||||||
|
/* Load Yang modules
|
||||||
|
* 1. Load a yang module as a specific absolute filename */
|
||||||
|
if ((str = clicon_yang_main_file(h)) != NULL){
|
||||||
|
if (yang_spec_parse_file(h, str, yspec) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* 2. Load a (single) main module */
|
||||||
|
if ((str = clicon_yang_module_main(h)) != NULL){
|
||||||
|
if (yang_spec_parse_module(h, str, clicon_yang_module_revision(h),
|
||||||
|
yspec) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* 3. Load all modules in a directory */
|
||||||
|
if ((str = clicon_yang_main_dir(h)) != NULL){
|
||||||
|
if (yang_spec_load_dir(h, str, yspec) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* Load clixon lib yang module */
|
||||||
|
if (yang_spec_parse_module(h, "clixon-lib", NULL, yspec) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Load yang module library, RFC7895 */
|
||||||
|
if (yang_modules_init(h) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Add netconf yang spec, used by netconf client and as internal protocol */
|
||||||
|
if (netconf_module_load(h) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Here all modules are loaded
|
||||||
|
* Compute and set canonical namespace context
|
||||||
|
*/
|
||||||
|
if (xml_nsctx_yangspec(yspec, &nsctx_global) < 0)
|
||||||
|
goto done;
|
||||||
|
if (clicon_nsctx_global_set(h, nsctx_global) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Call start function is all plugins before we go interactive */
|
||||||
|
if (clixon_plugin_start_all(h) < 0)
|
||||||
|
goto done;
|
||||||
|
#if 1
|
||||||
|
/* XXX get session id from backend hello */
|
||||||
|
clicon_session_id_set(h, getpid());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Send hello request to backend to get session-id back
|
||||||
|
* This is done once at the beginning of the session and then this is
|
||||||
|
* used by the client, even though new TCP sessions are created for
|
||||||
|
* each message sent to the backend.
|
||||||
|
*/
|
||||||
|
if (clicon_hello_req(h, &id) < 0)
|
||||||
|
goto done;
|
||||||
|
clicon_session_id_set(h, id);
|
||||||
|
|
||||||
|
/* XXX Here should register an net-snmp interface socket
|
||||||
|
* But it registers stdin which is wrong
|
||||||
|
*/
|
||||||
|
if (clixon_event_reg_fd(0, snmp_input_cb, h, "snmp socket") < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (dbg)
|
||||||
|
clicon_option_dump(h, dbg);
|
||||||
|
if (clixon_event_loop(h) < 0)
|
||||||
|
goto done;
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
snmp_terminate(h);
|
||||||
|
clicon_log_init(__PROGRAM__, LOG_INFO, 0); /* Log on syslog no stderr */
|
||||||
|
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
91
configure
vendored
91
configure
vendored
|
|
@ -638,6 +638,7 @@ CLIXON_YANG_PATCH
|
||||||
with_libxml2
|
with_libxml2
|
||||||
HAVE_HTTP1
|
HAVE_HTTP1
|
||||||
HAVE_LIBNGHTTP2
|
HAVE_LIBNGHTTP2
|
||||||
|
enable_netsnmp
|
||||||
with_restconf
|
with_restconf
|
||||||
LINKAGE
|
LINKAGE
|
||||||
LIBSTATIC_SUFFIX
|
LIBSTATIC_SUFFIX
|
||||||
|
|
@ -722,6 +723,7 @@ enable_publish
|
||||||
with_restconf
|
with_restconf
|
||||||
enable_http1
|
enable_http1
|
||||||
enable_nghttp2
|
enable_nghttp2
|
||||||
|
enable_netsnmp
|
||||||
with_configfile
|
with_configfile
|
||||||
with_libxml2
|
with_libxml2
|
||||||
with_sigaction
|
with_sigaction
|
||||||
|
|
@ -1374,6 +1376,7 @@ Optional Features:
|
||||||
only
|
only
|
||||||
--disable-nghttp2 Disable nghttp2 for native restconf http/2, ie
|
--disable-nghttp2 Disable nghttp2 for native restconf http/2, ie
|
||||||
http/1 only
|
http/1 only
|
||||||
|
--enable-netsnmp Enable net-snmp Clixon YANG mapping
|
||||||
|
|
||||||
|
|
||||||
Optional Packages:
|
Optional Packages:
|
||||||
|
|
@ -3385,7 +3388,8 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set to native or fcgi -> compile apps/restconf
|
# Set to native or fcgi -> compile apps/restconf
|
||||||
|
# Enable build of apps/snmp
|
||||||
HAVE_LIBNGHTTP2=false
|
HAVE_LIBNGHTTP2=false
|
||||||
# consider using neutral constant such as with-http2
|
# consider using neutral constant such as with-http2
|
||||||
HAVE_HTTP1=false
|
HAVE_HTTP1=false
|
||||||
|
|
@ -5301,6 +5305,87 @@ if test "${with_restconf+set}" = set; then :
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# This is for net-snmp
|
||||||
|
# Check whether --enable-netsnmp was given.
|
||||||
|
if test "${enable_netsnmp+set}" = set; then :
|
||||||
|
enableval=$enable_netsnmp;
|
||||||
|
if test "$enableval" = no; then
|
||||||
|
enable_netsnmp=no
|
||||||
|
else
|
||||||
|
enable_netsnmp=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
enable_netsnmp=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking netsnmp is enabled: $enable_netsnmp" >&5
|
||||||
|
$as_echo "checking netsnmp is enabled: $enable_netsnmp" >&6; }
|
||||||
|
|
||||||
|
if test "$enable_netsnmp" = "yes"; then
|
||||||
|
# All libs are:
|
||||||
|
# libnetsnmp, libnetsnmpmibs, libnetsnmpagent, libnetsnmptrapd, libnetsnmphelpers
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for snmp_open in -lnetsnmp" >&5
|
||||||
|
$as_echo_n "checking for snmp_open in -lnetsnmp... " >&6; }
|
||||||
|
if ${ac_cv_lib_netsnmp_snmp_open+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_check_lib_save_LIBS=$LIBS
|
||||||
|
LIBS="-lnetsnmp $LIBS"
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
/* Override any GCC internal prototype to avoid an error.
|
||||||
|
Use char because int might match the return type of a GCC
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
#endif
|
||||||
|
char snmp_open ();
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return snmp_open ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_link "$LINENO"; then :
|
||||||
|
ac_cv_lib_netsnmp_snmp_open=yes
|
||||||
|
else
|
||||||
|
ac_cv_lib_netsnmp_snmp_open=no
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
LIBS=$ac_check_lib_save_LIBS
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netsnmp_snmp_open" >&5
|
||||||
|
$as_echo "$ac_cv_lib_netsnmp_snmp_open" >&6; }
|
||||||
|
if test "x$ac_cv_lib_netsnmp_snmp_open" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_LIBNETSNMP 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
LIBS="-lnetsnmp $LIBS"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
for ac_header in net-snmp/net-snmp-config.h
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_header_mongrel "$LINENO" "net-snmp/net-snmp-config.h" "ac_cv_header_net_snmp_net_snmp_config_h" "$ac_includes_default"
|
||||||
|
if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_NET_SNMP_NET_SNMP_CONFIG_H 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
else
|
||||||
|
as_fn_error $? "snmp is missing" "$LINENO" 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Set default config file location
|
# Set default config file location
|
||||||
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
||||||
|
|
||||||
|
|
@ -5569,7 +5654,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/main/Makefile example/main/example.xml extras/rpm/Makefile docker/Makefile docker/base/Makefile docker/clixon-dev/Makefile docker/main/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/mandatory/Makefile doc/Makefile test/Makefile test/config.sh test/cicd/Makefile test/vagrant/Makefile"
|
ac_config_files="$ac_config_files Makefile lib/Makefile lib/src/Makefile lib/clixon/Makefile apps/Makefile apps/cli/Makefile apps/backend/Makefile apps/netconf/Makefile apps/restconf/Makefile apps/snmp/Makefile include/Makefile etc/Makefile etc/clixonrc example/Makefile example/main/Makefile example/main/example.xml extras/rpm/Makefile docker/Makefile docker/base/Makefile docker/clixon-dev/Makefile docker/main/Makefile util/Makefile yang/Makefile yang/clixon/Makefile yang/mandatory/Makefile doc/Makefile test/Makefile test/config.sh test/cicd/Makefile test/vagrant/Makefile"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# This file is a shell script that caches the results of configure
|
||||||
|
|
@ -6272,6 +6357,7 @@ do
|
||||||
"apps/backend/Makefile") CONFIG_FILES="$CONFIG_FILES apps/backend/Makefile" ;;
|
"apps/backend/Makefile") CONFIG_FILES="$CONFIG_FILES apps/backend/Makefile" ;;
|
||||||
"apps/netconf/Makefile") CONFIG_FILES="$CONFIG_FILES apps/netconf/Makefile" ;;
|
"apps/netconf/Makefile") CONFIG_FILES="$CONFIG_FILES apps/netconf/Makefile" ;;
|
||||||
"apps/restconf/Makefile") CONFIG_FILES="$CONFIG_FILES apps/restconf/Makefile" ;;
|
"apps/restconf/Makefile") CONFIG_FILES="$CONFIG_FILES apps/restconf/Makefile" ;;
|
||||||
|
"apps/snmp/Makefile") CONFIG_FILES="$CONFIG_FILES apps/snmp/Makefile" ;;
|
||||||
"include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
|
"include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
|
||||||
"etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
|
"etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
|
||||||
"etc/clixonrc") CONFIG_FILES="$CONFIG_FILES etc/clixonrc" ;;
|
"etc/clixonrc") CONFIG_FILES="$CONFIG_FILES etc/clixonrc" ;;
|
||||||
|
|
@ -6878,4 +6964,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
|
||||||
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
|
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
23
configure.ac
23
configure.ac
|
|
@ -114,7 +114,8 @@ AC_SUBST(LIBS)
|
||||||
AC_SUBST(SH_SUFFIX)
|
AC_SUBST(SH_SUFFIX)
|
||||||
AC_SUBST(LIBSTATIC_SUFFIX)
|
AC_SUBST(LIBSTATIC_SUFFIX)
|
||||||
AC_SUBST(LINKAGE)
|
AC_SUBST(LINKAGE)
|
||||||
AC_SUBST(with_restconf) # Set to native or fcgi -> compile apps/restconf
|
AC_SUBST(with_restconf) # Set to native or fcgi -> compile apps/restconf
|
||||||
|
AC_SUBST(enable_netsnmp) # Enable build of apps/snmp
|
||||||
AC_SUBST(HAVE_LIBNGHTTP2,false) # consider using neutral constant such as with-http2
|
AC_SUBST(HAVE_LIBNGHTTP2,false) # consider using neutral constant such as with-http2
|
||||||
AC_SUBST(HAVE_HTTP1,false)
|
AC_SUBST(HAVE_HTTP1,false)
|
||||||
AC_SUBST(with_libxml2)
|
AC_SUBST(with_libxml2)
|
||||||
|
|
@ -275,6 +276,24 @@ AC_ARG_WITH([restconf],
|
||||||
AC_ARG_WITH([restconf],
|
AC_ARG_WITH([restconf],
|
||||||
AS_HELP_STRING([--without-restconf],[Disable restconf altogether]))
|
AS_HELP_STRING([--without-restconf],[Disable restconf altogether]))
|
||||||
|
|
||||||
|
# This is for net-snmp
|
||||||
|
AC_ARG_ENABLE(netsnmp, AS_HELP_STRING([--enable-netsnmp],[Enable net-snmp Clixon YANG mapping]),[
|
||||||
|
if test "$enableval" = no; then
|
||||||
|
enable_netsnmp=no
|
||||||
|
else
|
||||||
|
enable_netsnmp=yes
|
||||||
|
fi
|
||||||
|
],
|
||||||
|
[ enable_netsnmp=no])
|
||||||
|
AC_MSG_RESULT(checking netsnmp is enabled: $enable_netsnmp)
|
||||||
|
|
||||||
|
if test "$enable_netsnmp" = "yes"; then
|
||||||
|
# All libs are:
|
||||||
|
# libnetsnmp, libnetsnmpmibs, libnetsnmpagent, libnetsnmptrapd, libnetsnmphelpers
|
||||||
|
AC_CHECK_LIB(netsnmp, snmp_open)
|
||||||
|
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h,[], AC_MSG_ERROR([snmp is missing]))
|
||||||
|
fi
|
||||||
|
|
||||||
# Set default config file location
|
# Set default config file location
|
||||||
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
CLIXON_DEFAULT_CONFIG=/usr/local/etc/clixon.xml
|
||||||
AC_ARG_WITH([configfile],
|
AC_ARG_WITH([configfile],
|
||||||
|
|
@ -352,6 +371,7 @@ AC_OUTPUT(Makefile
|
||||||
apps/backend/Makefile
|
apps/backend/Makefile
|
||||||
apps/netconf/Makefile
|
apps/netconf/Makefile
|
||||||
apps/restconf/Makefile
|
apps/restconf/Makefile
|
||||||
|
apps/snmp/Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
etc/Makefile
|
etc/Makefile
|
||||||
etc/clixonrc
|
etc/clixonrc
|
||||||
|
|
@ -373,4 +393,3 @@ AC_OUTPUT(Makefile
|
||||||
test/cicd/Makefile
|
test/cicd/Makefile
|
||||||
test/vagrant/Makefile
|
test/vagrant/Makefile
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ RUN apk add --update git make build-base gcc flex bison curl-dev
|
||||||
# nghttp2 dependencies
|
# nghttp2 dependencies
|
||||||
RUN apk add --update nghttp2
|
RUN apk add --update nghttp2
|
||||||
|
|
||||||
|
# For netsnmp
|
||||||
|
RUN apk add --update net-snmp
|
||||||
|
|
||||||
# Checkut models
|
# Checkut models
|
||||||
WORKDIR /usr/local/share/
|
WORKDIR /usr/local/share/
|
||||||
|
|
||||||
|
|
@ -88,7 +91,7 @@ WORKDIR /clixon/clixon
|
||||||
COPY clixon .
|
COPY clixon .
|
||||||
|
|
||||||
# Configure, build and install clixon
|
# Configure, build and install clixon
|
||||||
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=native --enable-nghttp2 --enable-http1 --with-yang-standard-dir=/usr/local/share/yang/standard
|
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=native --enable-nghttp2 --enable-http1 --with-yang-standard-dir=/usr/local/share/yang/standard # --enable-netsnmp
|
||||||
|
|
||||||
RUN make
|
RUN make
|
||||||
RUN make install
|
RUN make install
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
/* Define to 1 if you have the `getresuid' function. */
|
/* Define to 1 if you have the `getresuid' function. */
|
||||||
#undef HAVE_GETRESUID
|
#undef HAVE_GETRESUID
|
||||||
|
|
||||||
/* Enable HTTP/1 (default true) */
|
/* Set to true to enable Native HTTP/1 */
|
||||||
#undef HAVE_HTTP1
|
#undef HAVE_HTTP1
|
||||||
|
|
||||||
/* Define to 1 if you have the `inet_aton' function. */
|
/* Define to 1 if you have the `inet_aton' function. */
|
||||||
|
|
@ -60,6 +60,9 @@
|
||||||
/* Define to 1 if you have the `m' library (-lm). */
|
/* Define to 1 if you have the `m' library (-lm). */
|
||||||
#undef HAVE_LIBM
|
#undef HAVE_LIBM
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `netsnmp' library (-lnetsnmp). */
|
||||||
|
#undef HAVE_LIBNETSNMP
|
||||||
|
|
||||||
/* Define to 1 if you have the `nghttp2' library (-lnghttp2). */
|
/* Define to 1 if you have the `nghttp2' library (-lnghttp2). */
|
||||||
#undef HAVE_LIBNGHTTP2
|
#undef HAVE_LIBNGHTTP2
|
||||||
|
|
||||||
|
|
@ -75,6 +78,9 @@
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <net-snmp/net-snmp-config.h> header file. */
|
||||||
|
#undef HAVE_NET_SNMP_NET_SNMP_CONFIG_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <nghttp2/nghttp2.h> header file. */
|
/* Define to 1 if you have the <nghttp2/nghttp2.h> header file. */
|
||||||
#undef HAVE_NGHTTP2_NGHTTP2_H
|
#undef HAVE_NGHTTP2_NGHTTP2_H
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue