summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_hosts.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2014-12-10 20:41:19 +0100
committerMarcin Siodelski <marcin@isc.org>2014-12-10 20:41:19 +0100
commit00b49298ec5e5e5c722e5938547c86c954fc76e1 (patch)
tree72b5a656b1412cc100c27fc6f143a01a5f5844ef /src/lib/dhcpsrv/cfg_hosts.cc
parent[master] ChangeLog updated after #3556 merge. (diff)
parent[3628] Addressed review comments. (diff)
downloadkea-00b49298ec5e5e5c722e5938547c86c954fc76e1.tar.xz
kea-00b49298ec5e5e5c722e5938547c86c954fc76e1.zip
[master] Merge branch 'trac3628'
Conflicts: src/lib/dhcpsrv/Makefile.am src/lib/dhcpsrv/cfg_hosts.cc src/lib/dhcpsrv/tests/cfg_hosts_unittest.cc
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index f786950926..8bb17f3cc3 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -14,6 +14,7 @@
#include <dhcpsrv/cfg_hosts.h>
#include <exceptions/exceptions.h>
+#include <ostream>
using namespace isc::asiolink;
@@ -173,6 +174,23 @@ CfgHosts::add(const HostPtr& host) {
/// @todo This may need further sanity checks.
HWAddrPtr hwaddr = host->getHWAddress();
DuidPtr duid = host->getDuid();
+
+ // There should be at least one resource reserved: hostname, IPv4
+ // address, IPv6 address or prefix.
+ if (host->getHostname().empty() &&
+ (host->getIPv4Reservation() == IOAddress("0.0.0.0")) &&
+ (!host->hasIPv6Reservation())) {
+ std::ostringstream s;
+ if (hwaddr) {
+ s << "for DUID: " << hwaddr->toText();
+ } else if (duid) {
+ s << "for HW address: " << duid->toText();
+ }
+ isc_throw(BadValue, "specified reservation " << s
+ << " must include at least one resource, i.e. "
+ "hostname, IPv4 address or IPv6 address/prefix");
+ }
+
// Check for duplicates for the specified IPv4 subnet.
if ((host->getIPv4SubnetID() > 0) &&
get4(host->getIPv4SubnetID(), hwaddr, duid)) {
@@ -182,7 +200,7 @@ CfgHosts::add(const HostPtr& host) {
<< "' to the IPv4 subnet id '" << host->getIPv4SubnetID()
<< "' as this host has already been added");
- // Checek for duplicates for the specified IPv6 subnet.
+ // Check for duplicates for the specified IPv6 subnet.
} else if (host->getIPv6SubnetID() &&
get6(host->getIPv6SubnetID(), duid, hwaddr)) {
isc_throw(DuplicateHost, "failed to add new host using the HW"
@@ -192,6 +210,8 @@ CfgHosts::add(const HostPtr& host) {
<< "' as this host has already been added");
}
+ /// @todo This may need further sanity checks.
+
// This is a new instance - add it.
hosts_.insert(host);
}