summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2018-12-04 09:48:28 +0100
committerMarcin Siodelski <marcin@isc.org>2018-12-04 09:48:28 +0100
commit0a42706dce3464b8915fcf1386105b53f1a616c7 (patch)
treed45ee3322fa560a803b292854bc4b7d25b219b34 /src
parent[#86,!152] Client FQDN option converts all names to lower case. (diff)
downloadkea-0a42706dce3464b8915fcf1386105b53f1a616c7.tar.xz
kea-0a42706dce3464b8915fcf1386105b53f1a616c7.zip
[#86,!152] DHCPv4 server performs case insensitive comparison of FQDN.
Diffstat (limited to 'src')
-rw-r--r--src/bin/dhcp4/tests/fqdn_unittest.cc5
-rw-r--r--src/lib/dhcpsrv/lease.cc3
-rw-r--r--src/lib/dhcpsrv/lease.h2
-rw-r--r--src/lib/dhcpsrv/tests/lease_unittest.cc6
4 files changed, 14 insertions, 2 deletions
diff --git a/src/bin/dhcp4/tests/fqdn_unittest.cc b/src/bin/dhcp4/tests/fqdn_unittest.cc
index 8246987db2..f5c0c510ce 100644
--- a/src/bin/dhcp4/tests/fqdn_unittest.cc
+++ b/src/bin/dhcp4/tests/fqdn_unittest.cc
@@ -883,8 +883,11 @@ TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsNewLease) {
TEST_F(NameDhcpv4SrvTest, createNameChangeRequestsRenewNoChange) {
Lease4Ptr lease = createLease(IOAddress("192.0.2.3"), "myhost.example.com.",
true, true);
+ // Comparison should be case insensitive, so turning some of the
+ // characters of the old lease hostname to upper case should not
+ // trigger NCRs.
Lease4Ptr old_lease = createLease(IOAddress("192.0.2.3"),
- "myhost.example.com.", true, true);
+ "Myhost.Example.Com.", true, true);
old_lease->valid_lft_ += 100;
ASSERT_NO_THROW(srv_->createNameChangeRequests(lease, old_lease));
diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc
index 6b50a3858f..b6a05b2330 100644
--- a/src/lib/dhcpsrv/lease.cc
+++ b/src/lib/dhcpsrv/lease.cc
@@ -8,6 +8,7 @@
#include <dhcpsrv/lease.h>
#include <util/pointer_util.h>
+#include <boost/algorithm/string.hpp>
#include <boost/scoped_ptr.hpp>
#include <sstream>
#include <iostream>
@@ -112,7 +113,7 @@ Lease::getExpirationTime() const {
bool
Lease::hasIdenticalFqdn(const Lease& other) const {
- return (hostname_ == other.hostname_ &&
+ return (boost::algorithm::iequals(hostname_, other.hostname_) &&
fqdn_fwd_ == other.fqdn_fwd_ &&
fqdn_rev_ == other.fqdn_rev_);
}
diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h
index c42cfc9a9e..fbac2cf35c 100644
--- a/src/lib/dhcpsrv/lease.h
+++ b/src/lib/dhcpsrv/lease.h
@@ -188,6 +188,8 @@ struct Lease : public isc::data::UserContext, public isc::data::CfgToElement {
/// @brief Returns true if the other lease has equal FQDN data.
///
+ /// The comparison of the hostname is case insensitive.
+ ///
/// @param other Lease which FQDN data is to be compared with our lease.
///
/// @return Boolean value which indicates whether FQDN data of the other
diff --git a/src/lib/dhcpsrv/tests/lease_unittest.cc b/src/lib/dhcpsrv/tests/lease_unittest.cc
index 8b3bac04f2..39858e23e2 100644
--- a/src/lib/dhcpsrv/tests/lease_unittest.cc
+++ b/src/lib/dhcpsrv/tests/lease_unittest.cc
@@ -453,6 +453,9 @@ TEST_F(Lease4Test, hasIdenticalFqdn) {
Lease4 lease = createLease4("myhost.example.com.", true, true);
EXPECT_TRUE(lease.hasIdenticalFqdn(createLease4("myhost.example.com.",
true, true)));
+ // Case insensitive comparison.
+ EXPECT_TRUE(lease.hasIdenticalFqdn(createLease4("myHOst.ExamplE.coM.",
+ true, true)));
EXPECT_FALSE(lease.hasIdenticalFqdn(createLease4("other.example.com.",
true, true)));
EXPECT_FALSE(lease.hasIdenticalFqdn(createLease4("myhost.example.com.",
@@ -1032,6 +1035,9 @@ TEST(Lease6Test, hasIdenticalFqdn) {
Lease6 lease = createLease6("myhost.example.com.", true, true);
EXPECT_TRUE(lease.hasIdenticalFqdn(createLease6("myhost.example.com.",
true, true)));
+ // Case insensitive comparison.
+ EXPECT_TRUE(lease.hasIdenticalFqdn(createLease6("myHOst.ExamplE.coM.",
+ true, true)));
EXPECT_FALSE(lease.hasIdenticalFqdn(createLease6("other.example.com.",
true, true)));
EXPECT_FALSE(lease.hasIdenticalFqdn(createLease6("myhost.example.com.",