Commit 6abb5e17 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

initial makefiles and some skeleton code for kea-netconf

parent e57a0119
......@@ -1414,6 +1414,8 @@ AC_CONFIG_FILES([Makefile
src/bin/keactrl/tests/keactrl_tests.sh
src/bin/lfc/Makefile
src/bin/lfc/tests/Makefile
src/bin/netconf/Makefile
src/bin/netconf/tests/Makefile
src/bin/perfdhcp/Makefile
src/bin/perfdhcp/tests/Makefile
src/bin/perfdhcp/tests/testdata/Makefile
......
# The following build order must be maintained.
SUBDIRS = dhcp4 dhcp6 d2 agent perfdhcp admin lfc keactrl
SUBDIRS = dhcp4 dhcp6 netconf d2 agent perfdhcp admin lfc keactrl
if KEA_SHELL
SUBDIRS += shell
......
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
AM_CPPFLAGS += $(BOOST_INCLUDES) $(NETCONF_INCLUDES)
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS = -static
endif
CLEANFILES = *.gcno *.gcda netconf_messages.h netconf_messages.cc s-messages
man_MANS = kea-netconf.8
DISTCLEANFILES = $(man_MANS)
EXTRA_DIST = $(man_MANS) kea-netconf.xml
#EXTRA_DIST += netconf.dox netconf_hooks.dox netconfo6.dox
#EXTRA_DIST += netconf_parser.yy
if GENERATE_DOCS
kea-netconf.8: kea-netconf.xml
@XSLTPROC@ --novalid --xinclude --nonet -o $@ \
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \
$(srcdir)/kea-netconf.xml
else
$(man_MANS):
@echo Man generation disabled. Creating dummy $@. Configure with --enable-generate-docs to enable it.
@echo Man generation disabled. Remove this file, configure with --enable-generate-docs, and rebuild Kea > $@
endif
netconf_messages.h netconf_messages.cc: s-messages
s-messages: netconf_messages.mes
$(top_builddir)/src/lib/log/compiler/kea-msg-compiler $(top_srcdir)/src/bin/netconf/netconf_messages.mes
touch $@
BUILT_SOURCES = netconf_messages.h netconf_messages.cc
# convenience archive
noinst_LTLIBRARIES = libnetconf.la
libnetconf_la_SOURCES =
libnetconf_la_SOURCES += agent.cc agent.h
libnetconf_la_SOURCES += translator.cc translator.h
libnetconf_la_SOURCES += netconf_log.cc netconf_log.h
nodist_libnetconf_la_SOURCES = netconf_messages.h netconf_messages.cc
EXTRA_DIST += netconf_messages.mes
sbin_PROGRAMS = kea-netconf
kea_netconf_SOURCES = main.cc
kea_netconf_LDADD = libnetconf.la
kea_netconf_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
kea_netconf_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
kea_netconf_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
kea_netconf_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
kea_netconf_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
kea_netconf_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
kea_netconf_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
kea_netconf_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
kea_netconf_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
kea_netconf_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
kea_netconf_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
kea_netconf_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
kea_netconf_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
kea_netconf_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
kea_netconf_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
kea_netconf_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
kea_netconf_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) $(BOOST_LIBS)
kea_netconfdir = $(pkgdatadir)
if GENERATE_PARSER
#parser: netconf_lexer.cc location.hh position.hh stack.hh netconf_parser.cc netconf_parser.h
# @echo "Flex/bison files regenerated"
# --- Flex/Bison stuff below --------------------------------------------------
# When debugging grammar issues, it's useful to add -v to bison parameters.
# bison will generate parser.output file that explains the whole grammar.
# It can be used to manually follow what's going on in the parser.
# This is especially useful if yydebug_ is set to 1 as that variable
# will cause parser to print out its internal state.
# Call flex with -s to check that the default rule can be suppressed
# Call bison with -W to get warnings like unmarked empty rules
# Note C++11 deprecated register still used by flex < 2.6.0
location.hh position.hh stack.hh netconf_parser.cc netconf_parser.h: netconf_parser.yy
$(YACC) --defines=netconf_parser.h --report=all --report-file=netconf_parser.report -o netconf_parser.cc netconf_parser.yy
netconf_lexer.cc: netconf_lexer.ll
$(LEX) --prefix netconf_ -o netconf_lexer.cc netconf_lexer.ll
else
parser location.hh position.hh stack.hh netconf_parser.cc netconf_parser.h netconf_lexer.cc:
@echo Parser generation disabled. Configure with --enable-generate-parser to enable it.
endif
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <netconf/agent.h>
namespace isc {
namespace netconf {
bool NetconfAgent::run() {
// We need to establish connection to the sysrepo first.
if (!connectSysrepo()) {
return (false);
}
// Second, we need to establish connection to Kea control socket.
if (!connectControlSocket()) {
return (false);
}
while (!shutdown_) {
try {
run_one();
io_service_->poll();
} catch (const std::exception& e) {
// General catch-all exception that are not caught by more specific
// catches. This one is for exceptions derived from std::exception.
LOG_ERROR(netconf_logger, NETCONF_EXCEPTION)
.arg(e.what());
}
}
return (true);
}
bool NetconfAgent::connectSysrepo() {
// Connect to sysrepo
// Establish session
// Register callbacks for event changes.
// Once implemented, change this to true.
return (false);
}
bool NetconfAgent::connectControlSocket() {
// Establish connection to Kea control socket.
// Once implemented, change this to true.
return (false);
}
};
};
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef NETCONF_AGENT_H
#define NETCONF_AGENT_H
#include <dhcpsrv/daemon.h>
#include <asiolink/asio_wrapper.h>
#include <asiolink/asiolink.h>
namespace isc {
namespace netconf {
class NetconfAgent : public isc::dhcp::Daemon {
public:
NetconfAgent()
:verbose_(false) {
};
bool run();
void setVerbose(bool verbose) {
verbose_ = verbose;
}
private:
bool connectSysrepo();
bool connectControlSocket();
/// @brief IOService object, used for all ASIO operations.
isc::asiolink::IOService io_service_;
};
};
};
#endif
<!--
- Copyright (C) 2011-2018 Internet Systems Consortium, Inc. ("ISC")
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<!-- Converted by db4-upgrade version 1.1 -->
<refentry>
<info>
<productname>ISC Kea</productname>
<date>Oct. 27, 2017</date>
<edition>1.3.0</edition>
<author>
<contrib>The Kea software has been written by a number of
engineers working for ISC: Tomek Mrugalski, Stephen Morris, Marcin
Siodelski, Thomas Markwalder, Francis Dupont, Jeremy C. Reed,
Wlodek Wencel and Shawn Routhier. That list is roughly in the
chronological order in which the authors made their first
contribution. For a complete list of authors and
contributors, see AUTHORS file.</contrib><orgname>Internet Systems Consortium, Inc.</orgname></author>
</info>
<refmeta>
<refentrytitle>kea-netconf</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo class="manual">Kea</refmiscinfo>
</refmeta>
<refnamediv>
<refname>kea-dhcp4</refname>
<refpurpose>DHCPv4 server in Kea</refpurpose>
</refnamediv>
<docinfo>
<copyright>
<year>2011-2017</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refsynopsisdiv>
<cmdsynopsis sepchar=" ">
<command>kea-dhcp4</command>
<arg choice="opt" rep="norepeat"><option>-v</option></arg>
<arg choice="opt" rep="norepeat"><option>-V</option></arg>
<arg choice="opt" rep="norepeat"><option>-W</option></arg>
<arg choice="opt" rep="norepeat"><option>-d</option></arg>
<arg choice="opt" rep="norepeat"><option>-c <replaceable class="parameter">config-file</replaceable></option></arg>
<arg choice="opt" rep="norepeat"><option>-t <replaceable class="parameter">config-file</replaceable></option></arg>
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">port-number</replaceable></option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
The <command>kea-dhcp4</command> daemon provides the
DHCPv4 server implementation.
</para>
</refsect1>
<refsect1>
<title>ARGUMENTS</title>
<para>The arguments are as follows:</para>
<variablelist>
<varlistentry>
<term><option>-v</option></term>
<listitem><para>
Display the version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<listitem><para>
Display the extended version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-W</option></term>
<listitem><para>
Display the configuration report.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-d</option></term>
<listitem><para>
Enable the debug mode with extra verbosity.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-c</option></term>
<listitem><para>
Configuration file including the configuration for DHCPv4 server.
It may also contain configuration entries for other Kea services.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-t</option></term>
<listitem><para> Check the configuration file
and report the first error if any. Note
that not all parameters are completely checked, in
particular, service and control channel sockets
are not opened, and hook libraries are not loaded.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-p</option></term>
<listitem><para>
Port number (1-65535) on which the server listens. This is useful
for testing purposes only.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>DOCUMENTATION</title>
<para>Kea comes with an extensive Kea User's Guide documentation
that covers all aspects of running the Kea software -
compilation, installation, configuration, configuration examples
and many more. Kea also features a Kea Messages Manual, which
lists all possible messages Kea can print with a brief
description for each of them. Both documents are typically
available in various formats (txt, html, pdf) with your Kea
distribution. The on-line version is available at
http://kea.isc.org/docs/.</para>
<para>
Kea source code is documented in the Kea Developer's Guide. It's
on-line version is available at http://kea.isc.org. Please
follow Developer's Guide link.
</para>
<para>
Kea project website is available at: http://kea.isc.org.
</para>
</refsect1>
<refsect1>
<title>MAILING LISTS AND SUPPORT</title>
<para>
There are two mailing lists available for Kea project. kea-users
(kea-users at lists.isc.org) is intended for Kea users, while kea-dev
(kea-dev at lists.isc.org) is intended for Kea developers, prospective
contributors and other advanced users. Both lists are available at
http://lists.isc.org. The community provides best effort type of support
on both of those lists.
</para>
<para>
ISC provides professional support for Kea services. See
https://www.isc.org/kea/ for details.
</para>
</refsect1>
<refsect1>
<title>HISTORY</title>
<para>
The <command>b10-dhcp4</command> daemon was first coded in
November 2011 by Tomek Mrugalski.
</para>
<para>
In the mid 2014 Kea was decoupled from the BIND10 framework and became a
standalone DHCP server. The DHCPv4 server binary was renamed to
kea-dhcp4. Kea 1.0.0 was released in December 2015.
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>kea-dhcp6</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-dhcp-ddns</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-ctrl-agent</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-admin</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>keactrl</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>perfdhcp</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>kea-lfc</refentrytitle>
<manvolnum>8</manvolnum>
</citerefentry>,
<citetitle>Kea Administrator's Guide</citetitle>.
</para>
</refsect1>
</refentry>
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <netconf/agent.h>
int main(
/// @brief Prints Kea Usage and exits
///
/// Note: This function never returns. It terminates the process.
void
usage() {
cerr << "Kea netconf daemon, version " << VERSION << endl;
cerr << endl;
cerr << "Usage: " <<
<< " -c: config-file" << endl;
cerr << " -v: print version number and exit" << endl;
cerr << " -V: print extended version and exit" << endl;
exit(EXIT_FAILURE);
}
} // end of anonymous namespace
int
main(int argc, char* argv[]) {
// The standard config file
std::string config_file("");
while ((ch = getopt(argc, argv, "vVc:")) != -1) {
switch (ch) {
case 'v':
cout << Dhcpv4Srv::getVersion(false) << endl;
return (EXIT_SUCCESS);
case 'V':
cout << Dhcpv4Srv::getVersion(true) << endl;
return (EXIT_SUCCESS);
case 'c': // config file
config_file = optarg;
break;
default:
usage();
}
}
// Check for extraneous parameters.
if (argc > optind) {
usage();
}
// Configuration file is required.
if (config_file.empty()) {
cerr << "Configuration file not specified." << endl;
usage();
}
//CfgMgr::instance().setFamily(AF_INET);
int ret = EXIT_SUCCESS;
try {
// It is important that we set a default logger name because this name
// will be used when the user doesn't provide the logging configuration
// in the Kea configuration file.
CfgMgr::instance().setDefaultLoggerName(KEA_NETCONF_LOGGER_NAME);
// Initialize logging. If verbose, we'll use maximum verbosity.
bool verbose_mode = true;
Daemon::loggerInit(KEA_NETCONF_LOGGER_NAME, verbose_mode);
LOG_INFO(netconf_logger, NETCONF_AGENT_STARTING).arg(VERSION).arg(getpid());
// Create the server instance.
NetconfAgent agent;
// Remember verbose-mode
agent.setVerbose(verbose_mode);
// Create our PID file.
//server.setProcName(DHCP4_NAME);
//server.setConfigFile(config_file);
//server.createPIDFile();
try {
// Initialize the server.
server.init(config_file);
} catch (const std::exception& ex) {
cerr << "Failed to initialize server: " << ex.what() << endl;
return (EXIT_FAILURE);
}
// Tell the admin we are ready to process packets
LOG_INFO(netconf_logger, NETCONF_AGENT_STATED).arg(VERSION);
// And run the main loop of the server.
agent.run();
LOG_INFO(netconf_logger, NETCONF_SHUTDOWN);
} catch (const isc::exception& ex) {
// First, we parint the error on stderr (that should always work)
cerr "ERROR:" << ex.what() << endl;
}
return (ret);
}
SHTESTS =
# test using command-line arguments, so use check-local target instead of TESTS
check-local:
for shtest in $(SHTESTS) ; do \
echo Running test: $$shtest ; \
export KEA_LOCKFILE_DIR=$(abs_top_builddir); \
export KEA_PIDFILE_DIR=$(abs_top_builddir); \
${SHELL} $(abs_builddir)/$$shtest || exit ; \
done
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_builddir)/src
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CPPFLAGS += $(BOOST_INCLUDES)
CLEANFILES += *.json *.log
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS = -static
endif
TESTS_ENVIRONMENT = \
$(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
TESTS =
if HAVE_GTEST
TESTS += netconf_unittests
netconf_unittests_SOURCES = netconf_unittest.cc
netconf_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
netconf_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS)
netconf_unittests_LDADD = $(top_builddir)/src/bin/netconf/libnetconf.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/cfgrpt/libcfgrpt.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
#netconf_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
netconf_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
netconf_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
netconf_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
netconf_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
netconf_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
netconf_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
endif
noinst_EXTRA_DIST = configs-list.txt
noinst_PROGRAMS = $(TESTS)
// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <log/logger_support.h>
#include <dhcp4/dhcp4_log.h>
#include <gtest/gtest.h>
int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
// See the documentation of the KEA_* environment variables in
// src/lib/log/README for info on how to tweak logging
isc::log::initLogger();
setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1);
int result = RUN_ALL_TESTS();
return (result);