Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
445
Issues
445
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
3aae164d
Commit
3aae164d
authored
Aug 10, 2018
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gitlab3] Implemented bare skeleton for kea-netconf
parent
f3f2c8be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
120 deletions
+117
-120
src/bin/netconf/Makefile.am
src/bin/netconf/Makefile.am
+14
-16
src/bin/netconf/agent.cc
src/bin/netconf/agent.cc
+0
-62
src/bin/netconf/main.cc
src/bin/netconf/main.cc
+32
-42
src/bin/netconf/netconf_log.cc
src/bin/netconf/netconf_log.cc
+23
-0
src/bin/netconf/netconf_log.h
src/bin/netconf/netconf_log.h
+29
-0
src/bin/netconf/netconf_messages.mes
src/bin/netconf/netconf_messages.mes
+19
-0
No files found.
src/bin/netconf/Makefile.am
View file @
3aae164d
...
...
@@ -46,9 +46,7 @@ BUILT_SOURCES = netconf_messages.h netconf_messages.cc
noinst_LTLIBRARIES
=
libnetconf.la
libnetconf_la_SOURCES
=
agent.cc agent.h
libnetconf_la_SOURCES
+=
translator.cc translator.h
libnetconf_la_SOURCES
+=
netconf_log.cc netconf_log.h
libnetconf_la_SOURCES
=
netconf_log.cc netconf_log.h
nodist_libnetconf_la_SOURCES
=
netconf_messages.h netconf_messages.cc
...
...
@@ -59,21 +57,21 @@ 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/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/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/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)
$(SYSREPO_LIBS)
...
...
src/bin/netconf/agent.cc
deleted
100644 → 0
View file @
f3f2c8be
// 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
);
}
};
};
src/bin/netconf/main.cc
View file @
3aae164d
...
...
@@ -6,42 +6,47 @@
#include <config.h>
#include <netconf/agent.h>
#include <netconf/netconf_log.h>
#include <dhcpsrv/cfgmgr.h>
#include <exceptions/exceptions.h>
#include <dhcpsrv/daemon.h>
#include <iostream>
int
main
(
#include <sysrepo-cpp/Session.h>
/// @brief Prints Kea Usage and exits
using
namespace
std
;
using
namespace
isc
;
using
namespace
isc
::
netconf
;
/// @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
;
cerr
<<
"Kea netconf daemon, version "
<<
VERSION
<<
endl
<<
endl
<<
"Usage: "
<<
endl
<<
" -c: config-file"
<<
endl
<<
" -d: debug mode (maximum verbosity)"
<<
endl
<<
" -v: print version number and exit"
<<
endl
<<
" -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
(
""
);
int
ch
;
while
((
ch
=
getopt
(
argc
,
argv
,
"vVc:"
))
!=
-
1
)
{
switch
(
ch
)
{
case
'v'
:
cout
<<
Dhcpv4Srv
::
getVersion
(
false
)
<<
endl
;
cout
<<
string
(
PACKAGE_VERSION
)
<<
endl
;
return
(
EXIT_SUCCESS
);
case
'V'
:
cout
<<
Dhcpv4Srv
::
getVersion
(
true
)
<<
endl
;
cout
<<
string
(
PACKAGE_VERSION
)
<<
endl
;
cout
<<
"git "
<<
EXTENDED_VERSION
<<
endl
;
return
(
EXIT_SUCCESS
);
case
'c'
:
// config file
...
...
@@ -63,51 +68,36 @@ main(int argc, char* argv[]) {
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
);
//
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
);
}
isc
::
dhcp
::
Daemon
::
loggerInit
(
NETCONF_LOGGER_NAME
,
verbose_mode
);
LOG_INFO
(
netconf_logger
,
NETCONF_STARTING
).
arg
(
VERSION
).
arg
(
getpid
());
Connection
conn
(
"kea-netconf"
);
// Tell the admin we are ready to process packets
LOG_INFO
(
netconf_logger
,
NETCONF_
AGENT_
STATED
).
arg
(
VERSION
);
LOG_INFO
(
netconf_logger
,
NETCONF_STATED
).
arg
(
VERSION
);
// And run the main loop of the server.
agent
.
run
();
while
(
true
)
{
cout
<<
"Dummy kea-netconf running. Press ctrl-c to terminate."
<<
endl
;
sleep
(
1
);
}
LOG_INFO
(
netconf_logger
,
NETCONF_SHUTDOWN
);
}
catch
(
const
isc
::
e
xception
&
ex
)
{
}
catch
(
const
isc
::
E
xception
&
ex
)
{
// First, we parint the error on stderr (that should always work)
cerr
"ERROR:"
<<
ex
.
what
()
<<
endl
;
cerr
<<
"ERROR:"
<<
ex
.
what
()
<<
endl
;
ret
=
EXIT_FAILURE
;
}
return
(
ret
);
...
...
src/bin/netconf/
agent.h
→
src/bin/netconf/
netconf_log.cc
View file @
3aae164d
...
...
@@ -4,44 +4,20 @@
// 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
/// @file netconf_log.cc
/// Contains the loggers used by the netconf agent.
#include <
dhcpsrv/daemon
.h>
#include <asiolink/asio_wrapper.h>
#include <
asiolink/asiolink
.h>
#include <
config
.h>
#include <
netconf/netconf_log
.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_
;
};
};
};
const
char
*
NETCONF_LOGGER_NAME
=
"netconf"
;
isc
::
log
::
Logger
netconf_logger
(
NETCONF_LOGGER_NAME
);
#endif
}
// namespace netconf
}
// namespace isc
src/bin/netconf/netconf_log.h
0 → 100644
View file @
3aae164d
// 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/.
/// @file netconf_log.h
/// Contains declarations for loggers used by the Kea netconf agent.
#ifndef NETCONF_LOG_H
#define NETCONF_LOG_H
#include <log/logger_support.h>
#include <log/macros.h>
#include <netconf/netconf_messages.h>
namespace
isc
{
namespace
netconf
{
/// @brief Defines the name of the root level (default) logger.
extern
const
char
*
NETCONF_LOGGER_NAME
;
/// @brief Base logger for the netconf agent
extern
isc
::
log
::
Logger
netconf_logger
;
}
// namespace netconf
}
// namespace isc
#endif // NETCONF_LOG_H
src/bin/netconf/netconf_messages.mes
0 → 100644
View file @
3aae164d
# Copyright (C) 2012-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/.
$NAMESPACE isc::netconf
% NETCONF_STARTING Kea-netconf agent (version %1) is starting with process-id %2
Describe it later.
% NETCONF_STATED Kea-netconf agent (version %1) started
Describe it later.
% NETCONF_SHUTDOWN Kea-netconf agent shutting down.
Describe it later.
% NETCONF_EXCEPTION Exception encountered: %1
Oops.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment