Commit df38cef2 authored by Kazunori Fujiwara's avatar Kazunori Fujiwara
Browse files

[2138] Merge branch 'master' into trac2138

parents b34e3313 86f34c57
......@@ -35,3 +35,4 @@ TAGS
/coverage-cpp-html
/dns++.pc
/report.info
/logger_lockfile
nnn. [func]* naokikambe, fujiwara
469. [bug] jelte
libdatasrc: the data source client list class now ignores zone
content problems (such as out-of-zone data) in MasterFiles type
zones, instead of aborting the entire configuration. It only logs
an error, and all other zones and datasources are still loaded. The
error log message has been improved to include the zone origin and
source file name. As a result of this change, b10-auth no longer
exits upon encountering such errors during startup.
(Trac #2178, git a75ed413e8a1c8e3702beea4811a46a1bf519bbd)
468. [func]* naokikambe, fujiwara
b10-stats polls the bind10 and b10-auth with new 'getstats' command
to retrieve statistics data. The polling interval can be configured
by bindctl command. The 'sendstats' command was removed from bind10
and b10-auth. The 'statistics-interval' config item was removed from
b10-auth.
(Trac #2136, #2137 and #2138, git TBD)
to retrieve statistics data. The "poll-interval" parameter in
b10-stats is for configuring the polling interval. All statistics
data collected once are preserved while b10-stats is running.
The "sendstats" command was removed from bind10 and b10-auth. The
"statistics-interval" configuration item was removed from b10-auth.
(Trac #2136, git dcb5ce50b4b4e50d28247d5f8b5cb8d90bda942a)
(Trac #2137, git d53bb65a43f6027b15a6edc08c137951e3ce5e0e)
(Trac #2138, git b34e3313460eebc9c272ca8c1beb27297c195150)
bind10-devel-20120816 released on August 16, 2012
467. [bug] jelte
For configurations, allow named sets to contain lists of items.
(Trac #2114, git 712637513505f7afb8434292ca2a98c3517dffd3)
466. [func] jelte
Allow bindctl to add and remove items to and from lists
and dicts for items of type "any". This is for easier
configurations.
(Trac #2184, git ad2d728d1496a9ff59d622077850eed0638b54eb)
465. [doc] vorner
Improved documentation about ACLs in the Guide.
(Trac #2066, git 76f733925b3f3560cfc2ee96d2a19905b623bfc3)
464. [func] jelte, muks
libdns++: The LabelSequence class has been extended with some new
methods. These are mainly intended for internal development, but
the class is public, so interested users may want to look into the
extensions.
(Trac #2052, git 57c61f2^..dbef0e2)
(Trac #2053, git 1fc2b06b57a008ec602daa2dac79939b3cc6b65d)
(Trac #2086, git 3fac7d5579c5f51b8e952b50db510b45bfa986f3)
(Trac #2087, git 49ad6346f574d00cfbd1d12905915fd0dd6a0bac)
(Trac #2148, git 285c2845ca96e7ef89f9158f1dea8cda147b6566)
463. [func] jinmei
Python isc.dns: the Name, RRType and RRClass classes are now
hashable. So, for example, objects of these classes can be used
as a dictionary key.
(Trac #1883, git 93ec40dd0a1df963c676037cc60c066c748b3030)
462. [build] jreed
BIND 10 now compiles against googletest-1.6.0 versions that are
installed on the system as source code. For such versions, use the
--with-gtest-source configure switch.
(Trac #1999, git 6a26d459a40d7eed8ebcff01835377b3394a78de)
461. [bug] muks
We now set g+w and g+s permissions (mode 02770) during
installation for the BIND 10 local state directory
($prefix/var/bind10-devel/) so that permissions to files
and sub-directories created in that directory are inherited.
(Trac #2171, git ab4d20907abdb3ce972172463dcc73405b3dee79)
460. [bug] muks
SSHFP's algorithm and fingerprint type checks have been relaxed
such that they will accept any values in [0,255]. This is so that
future algorithm and fingerprint types are accomodated.
(Trac #2124, git 49e6644811a7ad09e1326f20dd73ab43116dfd21)
459. [func] tomek
b10-dhcp6: DHCPv6 server component is now integrated into
BIND 10 framework. It can be started from BIND 10 (using bindctl)
and can receive commands. The only supported command for now
is 'Dhcp6 shutdown'.
b10-dhcp4: Command line-switch '-s' to disable msgq was added.
b10-dhcp6: Command line-switch '-s' to disable msgq was added.
(Trac #1708, git e0d7c52a71414f4de1361b09d3c70431c96daa3f)
458. [build]* jinmei
458. [build]* jinmei
>>>>>>> master
BIND 10 now relies on Boost offset_ptr, which caused some new
portability issues. Such issues are detected at ./configure time.
If ./configure stops due to this, try the following workaround:
......@@ -19,12 +94,12 @@ nnn. [func]* naokikambe, fujiwara
(which would be the case if Boost is installed via pkgsrc)
(Trac #2147, git 30061d1139aad8716e97d6b620c259752fd0a3cd)
457. [build]* muks
457. [build]* muks
BIND 10 library names now have a "b10-" prefix. This is to avoid
clashes with other similarly named libraries on the system.
(Trac #2071, git ac20a00c28069804edc0a36050995df52f601efb)
456. [build]* muks
456. [build] muks
BIND 10 now compiles against log4cplus-1.1.0 (RC releases)
also. Note: some older versions of log4cplus don't work any more;
known oldest workable version is 1.0.4. Thanks to John Lumby for
......@@ -35,7 +110,8 @@ nnn. [func]* naokikambe, fujiwara
The server now uses newer API for data sources. This would be an
internal change, however, the data sources are now configured
differently. Please, migrate your configuration to the top-level
"data_sources" module.
"data_sources" module. Also the bind10 -n and --no-cache
and b10-auth -n options are removed.
(Trac #1976, git 0d4685b3e7603585afde1b587cbfefdfaf6a1bb3)
454. [bug] jelte
......@@ -52,11 +128,14 @@ nnn. [func]* naokikambe, fujiwara
NOTIMP instead of SERVFAIL.
(Trac #1986, git bd6b0a5ed3481f78fb4e5cb0b18c7b6e5920f9f8)
452. [func]* muks
isc-sysinfo: An initial implementation of the isc-sysinfo tool
is now available. It gathers and outputs system information which
can be used by future tech support staff.
(Trac #2062, git 144e80212746f8d55e6a59edcf689fec9f32ae95)
452. [func] muks, jelte
isc-sysinfo: An initial implementation of the isc-sysinfo
tool is now available for Linux, OpenBSD, FreeBSD, and Mac
OS X. It gathers and outputs system information which can
be used by future tech support staff. This includes a
generic Python "sysinfo" module.
(Trac #2062, #2121, #2122, #2172,
git 144e80212746f8d55e6a59edcf689fec9f32ae95)
451. [bug] muks, jinmei
libdatasrc: the database-based data source now correctly returns
......@@ -66,14 +145,14 @@ nnn. [func]* naokikambe, fujiwara
"glue"; it's the caller's responsibility.)
(Trac #1771, git 483f1075942965f0340291e7ff7dae7806df22af)
450. [func]* tomek
450. [func] tomek
b10-dhcp4: DHCPv4 server component is now integrated into
BIND10 framework. It can be started from BIND10 (using bindctl)
BIND 10 framework. It can be started from BIND 10 (using bindctl)
and can receive commands. The only supported command for now
is 'Dhcp4 shutdown'.
(Trac #1651, git 7e16a5a50d3311e63d10a224ec6ebcab5f25f62c)
bind10-devel-20120621 released on June 21. 2012
bind10-devel-20120621 released on June 21, 2012
449. [bug] muks
b10-xfin: fixed a bug where xfrin sent the wrong notification
......@@ -134,7 +213,7 @@ bind10-devel-20120621 released on June 21. 2012
file) was removed.
(Trac #1281, git 900fc8b420789a8c636bcf20fdaffc60bc1041e0)
bind10-devel-20120517 released on May 17. 2012
bind10-devel-20120517 released on May 17, 2012
440. [func] muks
bindctl: improved some error messages so they will be more
......@@ -713,7 +792,7 @@ bind10-devel-20120119 released on January 19, 2012
(Trac #1430, git b35797ba1a49c78246abc8f2387901f9690b328d)
356. [doc] tomek
BIND10 Guide updated. It now describes DHCPv4 and DHCPv6
BIND 10 Guide updated. It now describes DHCPv4 and DHCPv6
components, including their overview, usage, supported standard
and limitations. libdhcp++ is also described.
(Trac #1367, git 3758ab360efe1cdf616636b76f2e0fb41f2a62a0)
......@@ -1529,7 +1608,7 @@ bind10-devel-20110519 released on May 19, 2011
(Trac #719, git a234b20dc6617392deb8a1e00eb0eed0ff353c0a)
236. [func] jelte
C++ client side of configuration now uses BIND10 logging system.
C++ client side of configuration now uses BIND 10 logging system.
It also has improved error handling when communicating with the
rest of the system.
(Trac #743, git 86632c12308c3ed099d75eb828f740c526dd7ec0)
......@@ -2479,8 +2558,8 @@ bind10-devel-20100917 released on September 17, 2010
86. [func] jerry
bin/zonemgr: Added zone manager module. The zone manager is one
of the co-operating processes of BIND10, which keeps track of
timers and other information necessary for BIND10 to act as a
of the co-operating processes of BIND 10, which keeps track of
timers and other information necessary for BIND 10 to act as a
slave. (Trac #215, svn r2737)
85. [build]* jinmei
......
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT(bind10-devel, 20120712, bind10-dev@isc.org)
AC_INIT(bind10-devel, 20120817, bind10-dev@isc.org)
AC_CONFIG_SRCDIR(README)
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])dnl be backward compatible
......@@ -1101,6 +1101,7 @@ AC_CONFIG_FILES([Makefile
src/bin/zonemgr/tests/Makefile
src/bin/stats/Makefile
src/bin/stats/tests/Makefile
src/bin/stats/tests/testdata/Makefile
src/bin/usermgr/Makefile
src/bin/tests/Makefile
src/lib/Makefile
......
......@@ -72,11 +72,13 @@
* DHCPv6 server component does not support relayed traffic yet, as
* support for relay decapsulation is not implemented yet.
*
* DHCPv6 server component does not listen to BIND10 message queue.
*
* DHCPv6 server component does not use BIND10 logging yet.
*
* DHCPv6 server component is not integrated with boss yet.
* @section dhcpv6Session BIND10 message queue integration
*
* DHCPv4 server component is now integrated with BIND10 message queue.
* It follows the same principle as DHCPv4. See \ref dhcpv4Session for
* details.
*
* @page libdhcp libdhcp++
*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>BIND 10 Messages Manual</title><link rel="stylesheet" href="./bind10-guide.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><meta name="description" content="BIND 10 is a Domain Name System (DNS) suite managed by Internet Systems Consortium (ISC). It includes DNS libraries and modular components for controlling authoritative and recursive DNS servers. This is the messages manual for BIND 10 version 20120712. The most up-to-date version of this document, along with other documents for BIND 10, can be found at ."></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="BIND 10 Messages Manual"><div class="titlepage"><div><div><h1 class="title"><a name="idp98160"></a>BIND 10 Messages Manual</h1></div><div><p class="releaseinfo">This is the messages manual for BIND 10 version
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>BIND 10 Messages Manual</title><link rel="stylesheet" href="./bind10-guide.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><meta name="description" content="BIND 10 is a Domain Name System (DNS) suite managed by Internet Systems Consortium (ISC). It includes DNS libraries and modular components for controlling authoritative and recursive DNS servers. This is the messages manual for BIND 10 version 20120712. The most up-to-date version of this document, along with other documents for BIND 10, can be found at ."></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" title="BIND 10 Messages Manual"><div class="titlepage"><div><div><h1 class="title"><a name="id1168229451102"></a>BIND 10 Messages Manual</h1></div><div><p class="releaseinfo">This is the messages manual for BIND 10 version
20120712.</p></div><div><p class="copyright">Copyright © 2011-2012 Internet Systems Consortium, Inc.</p></div><div><div class="abstract" title="Abstract"><p class="title"><b>Abstract</b></p><p>BIND 10 is a Domain Name System (DNS) suite managed by
Internet Systems Consortium (ISC). It includes DNS libraries
and modular components for controlling authoritative and
......
......@@ -420,16 +420,6 @@ This is a debug message reporting that an incoming NOTIFY was received.
</para></listitem>
</varlistentry>
<varlistentry id="AUTH_RECEIVED_SENDSTATS">
<term>AUTH_RECEIVED_SENDSTATS command 'sendstats' received</term>
<listitem><para>
This is a debug message issued when the authoritative server has received
a command from the statistics module to send it data. The 'sendstats'
command is handled differently to other commands, which is why the debug
message associated with it has its own code.
</para></listitem>
</varlistentry>
<varlistentry id="AUTH_RESPONSE_FAILURE">
<term>AUTH_RESPONSE_FAILURE exception while building response to query: %1</term>
<listitem><para>
......
'\" t
.\" Title: bind10
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
.\" Date: April 12, 2012
.\" Manual: BIND10
.\" Source: BIND10
......@@ -9,6 +9,15 @@
.\"
.TH "BIND10" "8" "April 12, 2012" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
......@@ -166,7 +175,7 @@ This defines how required a component is\&. The possible settings for
\fIkind\fR
are:
\fIcore\fR
(system won\'t start if it won\'t start and
(system won\*(Aqt start if it won\*(Aqt start and
\fBbind10\fR
will shutdown if a
\(lqcore\(rq
......@@ -176,7 +185,7 @@ component crashes),
will restart failing component), and
\fIneeded\fR
(\fBbind10\fR
will shutdown if component won\'t initially start, but if crashes later, it will attempt to restart)\&. This setting is required\&.
will shutdown if component won\*(Aqt initially start, but if crashes later, it will attempt to restart)\&. This setting is required\&.
.RE
.PP
\fIpriority\fR
......@@ -209,7 +218,6 @@ tells
to send its statistics data to the
\fBb10\-stats\fR
daemon\&. This is an internal command and not exposed to the administrator\&.
.PP
\fBping\fR
......@@ -219,17 +227,9 @@ daemon\&. It returns the text
\(lqpong\(rq\&.
.PP
\fBsendstats\fR
tells
\fBbind10\fR
to send its statistics data to the
\fBb10\-stats\fR
daemon immediately\&.
.PP
\fBshow_processes\fR
lists the current processes managed by
\fBbind10\fR\&. The output is an array in JSON format containing the process ID and the name for each\&.
\fBbind10\fR\&. The output is an array in JSON format containing the process ID, the name for each and the address name used on each message bus\&.
.PP
......
......@@ -394,7 +394,6 @@ xfrin
daemon.
This is an internal command and not exposed to the administrator.
<!-- not defined in spec -->
<!-- TODO: explain difference with sendstat -->
</para>
<para>
......@@ -403,18 +402,11 @@ xfrin
It returns the text <quote>pong</quote>.
</para>
<para>
<command>sendstats</command> tells <command>bind10</command>
to send its statistics data to the <command>b10-stats</command>
daemon immediately.
<!-- TODO: compare with internal command getstats? -->
</para>
<para>
<command>show_processes</command> lists the current processes
managed by <command>bind10</command>.
The output is an array in JSON format containing the process
ID and the name for each.
ID, the name for each and the address name used on each message bus.
<!-- TODO: what is name? -->
<!-- TODO: change to JSON object format? -->
<!-- TODO: ticket #1406 -->
......@@ -490,6 +482,9 @@ xfrin
<citerefentry>
<refentrytitle>b10-zonemgr</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-stats</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citetitle>BIND 10 Guide</citetitle>.
</para>
</refsect1>
......
......@@ -281,14 +281,13 @@ class BoB:
pids.sort()
process_list = [ ]
for pid in pids:
process_list.append([pid, self.components[pid].name()])
process_list.append([pid, self.components[pid].name(),
self.components[pid].address()])
return process_list
def _get_stats_data(self):
return { "owner": "Boss",
"data": { 'boot_time':
time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}
return { 'boot_time':
time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}
def command_handler(self, command, args):
......@@ -301,25 +300,8 @@ class BoB:
self.runnable = False
answer = isc.config.ccsession.create_answer(0)
elif command == "getstats":
answer = isc.config.ccsession.create_answer(0, self._get_stats_data())
elif command == "sendstats":
# send statistics data to the stats daemon immediately
stats_data = self._get_stats_data()
valid = self.ccs.get_module_spec().validate_statistics(
True, stats_data["data"])
if valid:
cmd = isc.config.ccsession.create_command('set', stats_data)
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
# Consume the answer, in case it becomes a orphan message.
try:
self.cc_session.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
pass
answer = isc.config.ccsession.create_answer(0)
else:
logger.fatal(BIND10_INVALID_STATISTICS_DATA);
answer = isc.config.ccsession.create_answer(
1, "specified statistics data is invalid")
answer = isc.config.ccsession.create_answer(
0, self._get_stats_data())
elif command == "ping":
answer = isc.config.ccsession.create_answer(0, "pong")
elif command == "show_processes":
......
......@@ -64,11 +64,6 @@
"command_description": "Shut down BIND 10",
"command_args": []
},
{
"command_name": "sendstats",
"command_description": "Send data to a statistics module at once",
"command_args": []
},
{
"command_name": "ping",
"command_description": "Ping the boss process",
......
......@@ -413,20 +413,7 @@ class TestBoB(unittest.TestCase):
# "getstats" command
self.assertEqual(bob.command_handler("getstats", None),
isc.config.ccsession.create_answer(0,
{ "owner": "Boss",
"data": {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}}))
# "sendstats" command
self.assertEqual(bob.command_handler("sendstats", None),
isc.config.ccsession.create_answer(0))
self.assertEqual(bob.cc_session.group, "Stats")
self.assertEqual(bob.cc_session.msg,
isc.config.ccsession.create_command(
"set", { "owner": "Boss",
"data": {
"boot_time": time.strftime("%Y-%m-%dT%H:%M:%SZ", _BASETIME)
}}))
{ 'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME) }))
# "ping" command
self.assertEqual(bob.command_handler("ping", None),
isc.config.ccsession.create_answer(0, "pong"))
......@@ -938,9 +925,10 @@ class TestStartStopProcessesBob(unittest.TestCase):
#self.check_started_dhcp(bob, True, True)
class MockComponent:
def __init__(self, name, pid):
def __init__(self, name, pid, address=None):
self.name = lambda: name
self.pid = lambda: pid
self.address = lambda: address
class TestBossCmd(unittest.TestCase):
......@@ -966,10 +954,10 @@ class TestBossCmd(unittest.TestCase):
"""
bob = MockBob()
bob.register_process(1, MockComponent('first', 1))
bob.register_process(2, MockComponent('second', 2))
bob.register_process(2, MockComponent('second', 2, 'Second'))
answer = bob.command_handler("show_processes", None)
processes = [[1, 'first'],
[2, 'second']]
processes = [[1, 'first', None],
[2, 'second', 'Second']]
self.assertEqual(answer, {'result': [0, processes]})
class TestParseArgs(unittest.TestCase):
......
......@@ -26,8 +26,9 @@ b10-cfgmgr: b10-cfgmgr.py
install-data-local:
$(mkinstalldirs) $(DESTDIR)/@localstatedir@/@PACKAGE@
# TODO: permissions handled later
install-data-hook:
-chmod 2770 $(DESTDIR)/@localstatedir@/@PACKAGE@
CLEANDIRS = __pycache__
......
......@@ -12,8 +12,8 @@
"item_type": "map",
"item_optional": true,
"item_default": {
"origin": "",
"class": "IN",
"origin": "",
"class": "IN",
"update_acl": []
},
"map_item_spec": [
......@@ -33,11 +33,12 @@
"item_name": "update_acl",
"item_type": "list",
"item_optional": false,
"item_default": [],
"item_default": [],
"list_item_spec": {
"item_name": "acl_element",
"item_type": "any",
"item_optional": true
"item_optional": true,
"item_default": {"action": "REJECT"}
}
}
]
......
......@@ -86,7 +86,7 @@ void ControlledDhcpv4Srv::establishSession() {
string specfile;
if (getenv("B10_FROM_BUILD")) {
specfile = string(getenv("B10_FROM_BUILD")) +
"/src/bin/auth/dhcp4.spec";
"/src/bin/dhcp4/dhcp4.spec";
} else {
specfile = string(DHCP4_SPECFILE_LOCATION);
}
......
......@@ -37,16 +37,21 @@ const std::string HARDCODED_SERVER_ID = "192.0.2.1";
Dhcpv4Srv::Dhcpv4Srv(uint16_t port) {
cout << "Initialization: opening sockets on port " << port << endl;
// first call to instance() will create IfaceMgr (it's a singleton)
// it may throw something if things go wrong
IfaceMgr::instance();
try {
// first call to instance() will create IfaceMgr (it's a singleton)
// it may throw something if things go wrong
IfaceMgr::instance();
/// @todo: instantiate LeaseMgr here once it is imlpemented.
IfaceMgr::instance().printIfaces();
/// @todo: instantiate LeaseMgr here once it is imlpemented.
IfaceMgr::instance().openSockets4(port);
IfaceMgr::instance().openSockets4(port);
setServerID();
setServerID();
} catch (const std::exception &e) {
cerr << "Error during DHCPv4 server startup: " << e.what() << endl;
shutdown_ = true;
return;
}
shutdown_ = false;
}
......
......@@ -14,18 +14,14 @@
#include <config.h>
#include <iostream>
#include <exceptions/exceptions.h>
#include <log/dummylog.h>
#include <log/logger_support.h>
#include <dhcp4/ctrl_dhcp4_srv.h>
#include <dhcp4/dhcp4_srv.h>
#include <dhcp/dhcp4.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using namespace isc::dhcp;
/// This file contains entry point (main() function) for standard DHCPv4 server
/// component for BIND10 framework. It parses command-line arguments and
/// instantiates ControlledDhcpv4Srv class that is responsible for establishing
......@@ -44,7 +40,9 @@ usage() {
cerr << "Usage: b10-dhcp4 [-v]"
<< endl;
cerr << "\t-v: verbose output" << endl;
cerr << "\t-p number: specify non-standard port number 1-65535 (useful for testing only)" << endl;
cerr << "\t-s: stand-alone mode (don't connect to BIND10)" << endl;
cerr << "\t-p number: specify non-standard port number 1-65535 "
<< "(useful for testing only)" << endl;
exit(EXIT_FAILURE);
}
} // end of anonymous namespace
......@@ -55,16 +53,26 @@ main(int argc, char* argv[]) {
bool verbose_mode = false; // should server be verbose?
int port_number = DHCP4_SERVER_PORT; // The default. any other values are
// useful for testing only.
bool stand_alone = false; // should be connect to BIND10 msgq?
while ((ch = getopt(argc, argv, "vp:")) != -1) {
while ((ch = getopt(argc, argv, "vsp:")) != -1) {
switch (ch) {
case 'v':
verbose_mode = true;
isc::log::denabled = true;
break;
case 's':
stand_alone = true;
break;
case 'p':
port_number = strtol(optarg, NULL, 10);
if (port_number == 0) {
try {
port_number = boost::lexical_cast<int>(optarg);
} catch (const boost::bad_lexical_cast &) {
cerr << "Failed to parse port number: [" << optarg
<< "], 1-65535 allowed." << endl;
usage();
}
if (port_number <= 0 || port_number > 65535) {
cerr << "Failed to parse port number: [" << optarg
<< "], 1-65535 allowed." << endl;
usage();
......@@ -82,7 +90,8 @@ main(int argc, char* argv[]) {
isc::log::MAX_DEBUG_LEVEL, NULL);
cout << "b10-dhcp4: My pid=" << getpid() << ", binding to port "
<< port_number << ", verbose " << (verbose_mode?"yes":"no") << endl;
<< port_number << ", verbose " << (verbose_mode?"yes":"no")
<< ", stand-alone=" << (stand_alone?"yes":"no") << endl;
if (argc - optind > 0) {
usage();
......@@ -94,11 +103,23 @@ main(int argc, char* argv[]) {
cout << "[b10-dhcp4] Initiating DHCPv4 server operation." << endl;
ControlledDhcpv4Srv* server = new ControlledDhcpv4Srv(port_number);
server->run();
delete server;
server = NULL;
/// @todo: pass verbose to the actul server once logging is implemented
ControlledDhcpv4Srv server(port_number);
if (!stand_alone) {
try {
server.establishSession();
} catch (const std::exception& ex) {
cerr << "Failed to establish BIND10 session. "
"Running in stand-alone mode:" << ex.what() << endl;
// Let's continue. It is useful to have the ability to run
// DHCP server in stand-alone mode, e.g. for testing
}
} else {