diff options
author | Marcin Siodelski <marcin@isc.org> | 2014-11-04 18:43:58 +0100 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2014-11-04 18:43:58 +0100 |
commit | 58f5cf41194c41ddb2e94787c8b9944f9f46ff8c (patch) | |
tree | 047771f0ca915b158cec26b75d87d61c2ebc8626 /src/lib/dhcpsrv/cfg_hosts.cc | |
parent | [3562] Added negative test scenarios for ipv6 host reservations. (diff) | |
download | kea-58f5cf41194c41ddb2e94787c8b9944f9f46ff8c.tar.xz kea-58f5cf41194c41ddb2e94787c8b9944f9f46ff8c.zip |
[3562] Addressed review comments.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r-- | src/lib/dhcpsrv/cfg_hosts.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 68fb00bd4e..7e8bcbc405 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -160,12 +160,17 @@ CfgHosts::getHostInternal(const SubnetID& subnet_id, const bool subnet6, void CfgHosts::add(const HostPtr& host) { - /// @todo This may need to be sanity-checked. For example, a duplicate + // Sanity check that the host is non-null. + if (!host) { + isc_throw(BadValue, "specified host object must not be NULL when it" + " is added to the configuration"); + } + /// @todo This may need further sanity checks. For example, a duplicate /// should be rejected. HWAddrPtr hwaddr = host->getHWAddress(); DuidPtr duid = host->getDuid(); // Check for duplicates for the specified IPv4 subnet. - if (get4(host->getIPv4SubnetID(), host->getHWAddress(), host->getDuid())) { + if (get4(host->getIPv4SubnetID(), hwaddr, duid)) { isc_throw(DuplicateHost, "failed to add new host using the HW" " address '" << (hwaddr ? hwaddr->toText(false) : "(null)") << " and DUID '" << (duid ? duid->toText() : "(null)") @@ -173,8 +178,7 @@ CfgHosts::add(const HostPtr& host) { << "' as this host has already been added"); // Checek for duplicates for the specified IPv6 subnet. - } else if (get6(host->getIPv6SubnetID(), host->getDuid(), - host->getHWAddress())) { + } else if (get6(host->getIPv6SubnetID(), duid, hwaddr)) { isc_throw(DuplicateHost, "failed to add new host using the HW" " address '" << (hwaddr ? hwaddr->toText(false) : "(null)") << " and DUID '" << (duid ? duid->toText() : "(null)") |