Commit 0a42706d authored by Marcin Siodelski's avatar Marcin Siodelski

[#86,!152] DHCPv4 server performs case insensitive comparison of FQDN.

parent abb9982a
......@@ -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));
......
......@@ -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_);
}
......
......@@ -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
......
......@@ -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.",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment