Browse Source

Merge branch 'trac1283'

Conflicts:
	src/lib/dhcp/iface_mgr.cc
Mukund Sivaraman 11 years ago
parent
commit
312e27c041
38 changed files with 167 additions and 141 deletions
  1. 2 3
      src/bin/d2/d2_cfg_mgr.cc
  2. 1 1
      src/bin/dhcp4/config_parser.cc
  3. 20 20
      src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
  4. 4 4
      src/bin/dhcp4/tests/dhcp4_test_utils.cc
  5. 2 2
      src/bin/dhcp6/config_parser.cc
  6. 1 1
      src/bin/dhcp6/dhcp6_srv.cc
  7. 2 4
      src/bin/dhcp6/tests/config_parser_unittest.cc
  8. 12 12
      src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
  9. 4 4
      src/bin/dhcp6/tests/dhcp6_test_utils.cc
  10. 6 0
      src/lib/asiolink/io_address.cc
  11. 16 0
      src/lib/asiolink/io_address.h
  12. 2 2
      src/lib/asiolink/io_endpoint.cc
  13. 11 1
      src/lib/asiolink/tests/io_address_unittest.cc
  14. 3 5
      src/lib/dhcp/iface_mgr.cc
  15. 3 3
      src/lib/dhcp/option6_addrlst.cc
  16. 3 4
      src/lib/dhcp/option6_iaaddr.cc
  17. 2 2
      src/lib/dhcp/option6_iaprefix.cc
  18. 3 3
      src/lib/dhcp/option_custom.cc
  19. 1 1
      src/lib/dhcp/option_definition.cc
  20. 2 2
      src/lib/dhcp/pkt4.cc
  21. 2 2
      src/lib/dhcp/pkt6.cc
  22. 3 3
      src/lib/dhcp/pkt_filter.cc
  23. 2 1
      src/lib/dhcp/pkt_filter_inet.cc
  24. 5 5
      src/lib/dhcp/tests/iface_mgr_unittest.cc
  25. 6 6
      src/lib/dhcp/tests/option_custom_unittest.cc
  26. 2 2
      src/lib/dhcp/tests/option_data_types_unittest.cc
  27. 8 8
      src/lib/dhcp/tests/pkt4_unittest.cc
  28. 2 2
      src/lib/dhcp/tests/protocol_util_unittest.cc
  29. 1 1
      src/lib/dhcp_ddns/ncr_msg.cc
  30. 1 1
      src/lib/dhcpsrv/alloc_engine.cc
  31. 2 2
      src/lib/dhcpsrv/lease.cc
  32. 2 2
      src/lib/dhcpsrv/memfile_lease_mgr.cc
  33. 2 2
      src/lib/dhcpsrv/mysql_lease_mgr.cc
  34. 4 4
      src/lib/dhcpsrv/pool.cc
  35. 5 6
      src/lib/dhcpsrv/subnet.cc
  36. 16 16
      src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
  37. 2 2
      src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
  38. 2 2
      src/lib/dhcpsrv/tests/test_utils.cc

+ 2 - 3
src/bin/d2/d2_cfg_mgr.cc

@@ -119,7 +119,7 @@ std::string
 D2CfgMgr::reverseV4Address(const isc::asiolink::IOAddress& ioaddr) {
     if (!ioaddr.isV4()) {
         isc_throw(D2CfgError, "D2CfgMgr address is not IPv4 address :"
-                              << ioaddr.toText());
+                  << ioaddr);
     }
 
     // Get the address in byte vector form.
@@ -148,8 +148,7 @@ D2CfgMgr::reverseV4Address(const isc::asiolink::IOAddress& ioaddr) {
 std::string
 D2CfgMgr::reverseV6Address(const isc::asiolink::IOAddress& ioaddr) {
     if (!ioaddr.isV6()) {
-        isc_throw(D2CfgError, "D2Cfg address is not IPv6 address: "
-                              << ioaddr.toText());
+        isc_throw(D2CfgError, "D2Cfg address is not IPv6 address: " << ioaddr);
     }
 
     // Turn the address into a string of digits.

+ 1 - 1
src/bin/dhcp4/config_parser.cc

@@ -265,7 +265,7 @@ protected:
         Triplet<uint32_t> valid = getParam("valid-lifetime");
 
         stringstream tmp;
-        tmp << addr.toText() << "/" << (int)len
+        tmp << addr << "/" << (int)len
             << " with params t1=" << t1 << ", t2=" << t2 << ", valid=" << valid;
 
         LOG_INFO(dhcp4_logger, DHCP4_CONFIG_NEW_SUBNET).arg(tmp.str());

+ 20 - 20
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc

@@ -584,7 +584,7 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, DiscoverHint) {
     // lifetime is correct, that T1 and T2 are returned properly
     checkAddressParams(offer, subnet_);
 
-    EXPECT_EQ(offer->getYiaddr().toText(), hint.toText());
+    EXPECT_EQ(offer->getYiaddr(), hint);
 
     // Check identifiers
     checkServerId(offer, srv->getServerID());
@@ -624,7 +624,7 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, DiscoverNoClientId) {
     // lifetime is correct, that T1 and T2 are returned properly
     checkAddressParams(offer, subnet_);
 
-    EXPECT_EQ(offer->getYiaddr().toText(), hint.toText());
+    EXPECT_EQ(offer->getYiaddr(), hint);
 
     // Check identifiers
     checkServerId(offer, srv->getServerID());
@@ -664,7 +664,7 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, DiscoverInvalidHint) {
     // lifetime is correct, that T1 and T2 are returned properly
     checkAddressParams(offer, subnet_);
 
-    EXPECT_NE(offer->getYiaddr().toText(), hint.toText());
+    EXPECT_NE(offer->getYiaddr(), hint);
 
     // Check identifiers
     checkServerId(offer, srv->getServerID());
@@ -735,12 +735,12 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, ManyDiscovers) {
     checkClientId(offer3, clientid3);
 
     // Finally check that the addresses offered are different
-    EXPECT_NE(addr1.toText(), addr2.toText());
-    EXPECT_NE(addr2.toText(), addr3.toText());
-    EXPECT_NE(addr3.toText(), addr1.toText());
-    cout << "Offered address to client1=" << addr1.toText() << endl;
-    cout << "Offered address to client2=" << addr2.toText() << endl;
-    cout << "Offered address to client3=" << addr3.toText() << endl;
+    EXPECT_NE(addr1, addr2);
+    EXPECT_NE(addr2, addr3);
+    EXPECT_NE(addr3, addr1);
+    cout << "Offered address to client1=" << addr1 << endl;
+    cout << "Offered address to client2=" << addr2 << endl;
+    cout << "Offered address to client3=" << addr3 << endl;
 }
 
 // Checks whether echoing back client-id is controllable, i.e.
@@ -802,7 +802,7 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, RequestBasic) {
 
     // Check if we get response at all
     checkResponse(ack, DHCPACK, 1234);
-    EXPECT_EQ(hint.toText(), ack->getYiaddr().toText());
+    EXPECT_EQ(hint, ack->getYiaddr());
 
     // Check that address was returned from proper range, that its lease
     // lifetime is correct, that T1 and T2 are returned properly
@@ -886,9 +886,9 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, ManyRequests) {
     IOAddress addr3 = ack3->getYiaddr();
 
     // Check that every client received the address it requested
-    EXPECT_EQ(req_addr1.toText(), addr1.toText());
-    EXPECT_EQ(req_addr2.toText(), addr2.toText());
-    EXPECT_EQ(req_addr3.toText(), addr3.toText());
+    EXPECT_EQ(req_addr1, addr1);
+    EXPECT_EQ(req_addr2, addr2);
+    EXPECT_EQ(req_addr3, addr3);
 
     // Check that the assigned address is indeed from the configured pool
     checkAddressParams(ack1, subnet_);
@@ -910,12 +910,12 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, ManyRequests) {
     l = checkLease(ack3, clientid3, req3->getHWAddr(), addr3);
 
     // Finally check that the addresses offered are different
-    EXPECT_NE(addr1.toText(), addr2.toText());
-    EXPECT_NE(addr2.toText(), addr3.toText());
-    EXPECT_NE(addr3.toText(), addr1.toText());
-    cout << "Offered address to client1=" << addr1.toText() << endl;
-    cout << "Offered address to client2=" << addr2.toText() << endl;
-    cout << "Offered address to client3=" << addr3.toText() << endl;
+    EXPECT_NE(addr1, addr2);
+    EXPECT_NE(addr2, addr3);
+    EXPECT_NE(addr3, addr1);
+    cout << "Offered address to client1=" << addr1 << endl;
+    cout << "Offered address to client2=" << addr2 << endl;
+    cout << "Offered address to client3=" << addr3 << endl;
 }
 
 // Checks whether echoing back client-id is controllable
@@ -1003,7 +1003,7 @@ TEST_F(Dhcpv4SrvFakeIfaceTest, RenewBasic) {
 
     // Check if we get response at all
     checkResponse(ack, DHCPACK, 1234);
-    EXPECT_EQ(addr.toText(), ack->getYiaddr().toText());
+    EXPECT_EQ(addr, ack->getYiaddr());
 
     // Check that address was returned from proper range, that its lease
     // lifetime is correct, that T1 and T2 are returned properly

+ 4 - 4
src/bin/dhcp4/tests/dhcp4_test_utils.cc

@@ -126,7 +126,7 @@ void Dhcpv4SrvTest::messageCheck(const Pkt4Ptr& q, const Pkt4Ptr& a) {
     EXPECT_TRUE(a->getOption(DHO_DHCP_SERVER_IDENTIFIER));
 
     // Check that something is offered
-    EXPECT_TRUE(a->getYiaddr().toText() != "0.0.0.0");
+    EXPECT_NE("0.0.0.0", a->getYiaddr().toText());
 }
 
 ::testing::AssertionResult
@@ -299,14 +299,14 @@ Lease4Ptr Dhcpv4SrvTest::checkLease(const Pkt4Ptr& rsp,
 
     Lease4Ptr lease = LeaseMgrFactory::instance().getLease4(expected_addr);
     if (!lease) {
-        cout << "Lease for " << expected_addr.toText()
+        cout << "Lease for " << expected_addr
              << " not found in the database backend.";
         return (Lease4Ptr());
     }
 
-    EXPECT_EQ(rsp->getYiaddr().toText(), expected_addr.toText());
+    EXPECT_EQ(rsp->getYiaddr(), expected_addr);
 
-    EXPECT_EQ(expected_addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(expected_addr, lease->addr_);
     if (client_id) {
         EXPECT_TRUE(*lease->client_id_ == *id);
     }

+ 2 - 2
src/bin/dhcp6/config_parser.cc

@@ -497,12 +497,12 @@ protected:
                       "parser error: interface (defined for locally reachable "
                       "subnets) and interface-id (defined for subnets reachable"
                       " via relays) cannot be defined at the same time for "
-                      "subnet " << addr.toText() << "/" << (int)len);
+                      "subnet " << addr << "/" << (int)len);
             }
         }
 
         stringstream tmp;
-        tmp << addr.toText() << "/" << static_cast<int>(len)
+        tmp << addr << "/" << static_cast<int>(len)
             << " with params t1=" << t1 << ", t2=" << t2 << ", pref="
             << pref << ", valid=" << valid;
 

+ 1 - 1
src/bin/dhcp6/dhcp6_srv.cc

@@ -1199,7 +1199,7 @@ Dhcpv6Srv::createRemovalNameChangeRequest(const Lease6Ptr& lease) {
     if (!lease->duid_) {
         isc_throw(isc::Unexpected, "DUID must be set when creating"
                   << " NameChangeRequest for DNS records removal for "
-                  << lease->addr_.toText());
+                  << lease->addr_);
 
     }
     isc::dhcp_ddns::D2Dhcid dhcid(*lease->duid_, hostname_wire);

+ 2 - 4
src/bin/dhcp6/tests/config_parser_unittest.cc

@@ -965,8 +965,7 @@ TEST_F(Dhcp6ParserTest, pdPoolBasics) {
     // verify that it was interpreted correctly by checking the last address
     // value.
     isc::asiolink::IOAddress prefixAddress("2001:db8:1::");
-    EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64).toText(),
-              p6->getLastAddress().toText());
+    EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64), p6->getLastAddress());
 }
 
 // Goal of this test is verify that a list of PD pools can be configured.
@@ -1099,8 +1098,7 @@ TEST_F(Dhcp6ParserTest, subnetAndPrefixDelegated) {
     // verify that it was interpreted correctly by checking the last address
     // value.
     isc::asiolink::IOAddress prefixAddress("2001:db8:1::");
-    EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64).toText(),
-              p6->getLastAddress().toText());
+    EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64), p6->getLastAddress());
 }
 
 

+ 12 - 12
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc

@@ -642,12 +642,12 @@ TEST_F(Dhcpv6SrvTest, ManySolicits) {
     checkClientId(reply3, clientid3);
 
     // Finally check that the addresses offered are different
-    EXPECT_NE(addr1->getAddress().toText(), addr2->getAddress().toText());
-    EXPECT_NE(addr2->getAddress().toText(), addr3->getAddress().toText());
-    EXPECT_NE(addr3->getAddress().toText(), addr1->getAddress().toText());
-    cout << "Offered address to client1=" << addr1->getAddress().toText() << endl;
-    cout << "Offered address to client2=" << addr2->getAddress().toText() << endl;
-    cout << "Offered address to client3=" << addr3->getAddress().toText() << endl;
+    EXPECT_NE(addr1->getAddress(), addr2->getAddress());
+    EXPECT_NE(addr2->getAddress(), addr3->getAddress());
+    EXPECT_NE(addr3->getAddress(), addr1->getAddress());
+    cout << "Offered address to client1=" << addr1->getAddress() << endl;
+    cout << "Offered address to client2=" << addr2->getAddress() << endl;
+    cout << "Offered address to client3=" << addr3->getAddress() << endl;
 }
 
 // This test verifies that incoming REQUEST can be handled properly, that a
@@ -852,12 +852,12 @@ TEST_F(Dhcpv6SrvTest, ManyRequests) {
     checkClientId(reply3, clientid3);
 
     // Finally check that the addresses offered are different
-    EXPECT_NE(addr1->getAddress().toText(), addr2->getAddress().toText());
-    EXPECT_NE(addr2->getAddress().toText(), addr3->getAddress().toText());
-    EXPECT_NE(addr3->getAddress().toText(), addr1->getAddress().toText());
-    cout << "Assigned address to client1=" << addr1->getAddress().toText() << endl;
-    cout << "Assigned address to client2=" << addr2->getAddress().toText() << endl;
-    cout << "Assigned address to client3=" << addr3->getAddress().toText() << endl;
+    EXPECT_NE(addr1->getAddress(), addr2->getAddress());
+    EXPECT_NE(addr2->getAddress(), addr3->getAddress());
+    EXPECT_NE(addr3->getAddress(), addr1->getAddress());
+    cout << "Assigned address to client1=" << addr1->getAddress() << endl;
+    cout << "Assigned address to client2=" << addr2->getAddress() << endl;
+    cout << "Assigned address to client3=" << addr3->getAddress() << endl;
 }
 
 // This test verifies that incoming (positive) RENEW can be handled properly, that a

+ 4 - 4
src/bin/dhcp6/tests/dhcp6_test_utils.cc

@@ -80,12 +80,12 @@ Dhcpv6SrvTest::checkLease(const DuidPtr& duid, const OptionPtr& ia_na,
     Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
                                                             addr->getAddress());
     if (!lease) {
-        std::cout << "Lease for " << addr->getAddress().toText()
+        std::cout << "Lease for " << addr->getAddress()
                   << " not found in the database backend.";
         return (Lease6Ptr());
     }
 
-    EXPECT_EQ(addr->getAddress().toText(), lease->addr_.toText());
+    EXPECT_EQ(addr->getAddress(), lease->addr_);
     EXPECT_TRUE(*lease->duid_ == *duid);
     EXPECT_EQ(ia->getIAID(), lease->iaid_);
     EXPECT_EQ(subnet_->getID(), lease->subnet_id_);
@@ -101,12 +101,12 @@ Dhcpv6SrvTest::checkPdLease(const DuidPtr& duid, const OptionPtr& ia_pd,
     Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD,
                                                             prefix->getAddress());
     if (!lease) {
-        std::cout << "PD lease for " << prefix->getAddress().toText()
+        std::cout << "PD lease for " << prefix->getAddress()
                   << " not found in the database backend.";
         return (Lease6Ptr());
     }
 
-    EXPECT_EQ(prefix->getAddress().toText(), lease->addr_.toText());
+    EXPECT_EQ(prefix->getAddress(), lease->addr_);
     EXPECT_TRUE(*lease->duid_ == *duid);
     EXPECT_EQ(ia->getIAID(), lease->iaid_);
     EXPECT_EQ(subnet_->getID(), lease->subnet_id_);

+ 6 - 0
src/lib/asiolink/io_address.cc

@@ -114,5 +114,11 @@ IOAddress::operator uint32_t() const {
     }
 }
 
+std::ostream&
+operator<<(std::ostream& os, const IOAddress& address) {
+    os << address.toText();
+    return (os);
+}
+
 } // namespace asiolink
 } // namespace isc

+ 16 - 0
src/lib/asiolink/io_address.h

@@ -232,6 +232,22 @@ private:
     asio::ip::address asio_address_;
 };
 
+/// \brief Insert the IOAddress as a string into stream.
+///
+/// This method converts the \c address into a string and inserts it
+/// into the output stream \c os.
+///
+/// This function overloads the global operator<< to behave as described
+/// in ostream::operator<< but applied to \c IOAddress objects.
+///
+/// \param os A \c std::ostream object on which the insertion operation is
+/// performed.
+/// \param address The \c IOAddress object output by the operation.
+/// \return A reference to the same \c std::ostream object referenced by
+/// parameter \c os after the insertion operation.
+std::ostream&
+operator<<(std::ostream& os, const IOAddress& address);
+
 } // namespace asiolink
 } // namespace isc
 #endif // IO_ADDRESS_H

+ 2 - 2
src/lib/asiolink/io_endpoint.cc

@@ -64,12 +64,12 @@ IOEndpoint::operator!=(const IOEndpoint& other) const {
 ostream&
 operator<<(ostream& os, const IOEndpoint& endpoint) {
     if (endpoint.getFamily() == AF_INET6) {
-        os << "[" << endpoint.getAddress().toText() << "]";
+        os << "[" << endpoint.getAddress() << "]";
     } else {
         // In practice this should be AF_INET, but it's not guaranteed by
         // the interface.  We'll use the result of textual address
         // representation opaquely.
-        os << endpoint.getAddress().toText();
+        os << endpoint.getAddress();
     }
     os << ":" << boost::lexical_cast<string>(endpoint.getPort());
     return (os);

+ 11 - 1
src/lib/asiolink/tests/io_address_unittest.cc

@@ -21,6 +21,7 @@
 #include <algorithm>
 #include <cstring>
 #include <vector>
+#include <sstream>
 
 using namespace isc::asiolink;
 
@@ -83,7 +84,7 @@ TEST(IOAddressTest, fromBytes) {
     EXPECT_NO_THROW({
         addr = IOAddress::fromBytes(AF_INET, v4);
     });
-    EXPECT_EQ(addr.toText(), IOAddress("192.0.2.3").toText());
+    EXPECT_EQ(addr, IOAddress("192.0.2.3"));
 }
 
 TEST(IOAddressTest, toBytesV4) {
@@ -172,3 +173,12 @@ TEST(IOAddressTest, lessThanEqual) {
 
     EXPECT_TRUE(addr6 <= addr7);
 }
+
+// test operator<<.  We simply confirm it appends the result of toText().
+TEST(IOAddressTest, LeftShiftOperator) {
+    const IOAddress addr("192.0.2.5");
+
+    std::ostringstream oss;
+    oss << addr;
+    EXPECT_EQ(addr.toText(), oss.str());
+}

+ 3 - 5
src/lib/dhcp/iface_mgr.cc

@@ -226,7 +226,7 @@ void Iface::addUnicast(const isc::asiolink::IOAddress& addr) {
     for (Iface::AddressCollection::const_iterator i = unicasts_.begin();
          i != unicasts_.end(); ++i) {
         if (*i == addr) {
-            isc_throw(BadValue, "Address " << addr.toText()
+            isc_throw(BadValue, "Address " << addr
                       << " already defined on the " << name_ << " interface.");
         }
     }
@@ -499,7 +499,6 @@ IfaceMgr::openSockets6(const uint16_t port,
 
             try {
                 openSocket(iface->getName(), *addr, port);
-
             } catch (const Exception& ex) {
                 IFACEMGR_ERROR(SocketConfigError, error_handler,
                                "Failed to open unicast socket on  interface "
@@ -560,7 +559,6 @@ IfaceMgr::openSockets6(const uint16_t port,
                                " interface " << iface->getName() << ": "
                                << ex.what());
                 continue;
-
             }
 
             count++;
@@ -662,7 +660,7 @@ int IfaceMgr::openSocket(const std::string& ifname, const IOAddress& addr,
 
     } else {
         isc_throw(BadValue, "Failed to detect family of address: "
-                  << addr.toText());
+                  << addr);
     }
 }
 
@@ -737,7 +735,7 @@ int IfaceMgr::openSocketFromAddress(const IOAddress& addr,
     }
     // If we got here it means that we did not find specified address
     // on any available interface.
-    isc_throw(BadValue, "There is no such address " << addr.toText());
+    isc_throw(BadValue, "There is no such address " << addr);
 }
 
 int IfaceMgr::openSocketFromRemoteAddress(const IOAddress& remote_addr,

+ 3 - 3
src/lib/dhcp/option6_addrlst.cc

@@ -102,9 +102,9 @@ std::string Option6AddrLst::toText(int indent /* =0 */) {
 
     tmp << "type=" << type_ << " " << addrs_.size() << "addr(s): ";
 
-    for (AddressContainer::const_iterator addr=addrs_.begin();
-         addr!=addrs_.end(); ++addr) {
-        tmp << addr->toText() << " ";
+    for (AddressContainer::const_iterator addr = addrs_.begin();
+         addr != addrs_.end(); ++addr) {
+        tmp << *addr << " ";
     }
     return tmp.str();
 }

+ 3 - 4
src/lib/dhcp/option6_iaaddr.cc

@@ -37,7 +37,7 @@ Option6IAAddr::Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress& addr
      valid_(valid) {
     setEncapsulatedSpace("dhcp6");
     if (!addr.isV6()) {
-        isc_throw(isc::BadValue, addr_.toText() << " is not an IPv6 address");
+        isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
     }
 }
 
@@ -57,8 +57,7 @@ void Option6IAAddr::pack(isc::util::OutputBuffer& buf) {
     buf.writeUint16(len() - getHeaderLen());
 
     if (!addr_.isV6()) {
-        isc_throw(isc::BadValue, addr_.toText()
-                  << " is not an IPv6 address");
+        isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
     }
     buf.writeData(&addr_.toBytes()[0], isc::asiolink::V6ADDRESS_LEN);
 
@@ -93,7 +92,7 @@ std::string Option6IAAddr::toText(int indent /* =0 */) {
     for (int i=0; i<indent; i++)
         tmp << " ";
 
-    tmp << "type=" << type_ << "(IAADDR) addr=" << addr_.toText()
+    tmp << "type=" << type_ << "(IAADDR) addr=" << addr_
         << ", preferred-lft=" << preferred_  << ", valid-lft="
         << valid_ << endl;
 

+ 2 - 2
src/lib/dhcp/option6_iaprefix.cc

@@ -51,7 +51,7 @@ Option6IAPrefix::Option6IAPrefix(uint32_t type, OptionBuffer::const_iterator beg
 
 void Option6IAPrefix::pack(isc::util::OutputBuffer& buf) {
     if (!addr_.isV6()) {
-        isc_throw(isc::BadValue, addr_.toText() << " is not an IPv6 address");
+        isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
     }
 
     buf.writeUint16(type_);
@@ -98,7 +98,7 @@ std::string Option6IAPrefix::toText(int indent /* =0 */) {
     for (int i=0; i<indent; i++)
         tmp << " ";
 
-    tmp << "type=" << type_ << "(IAPREFIX) prefix=" << addr_.toText() << "/"
+    tmp << "type=" << type_ << "(IAPREFIX) prefix=" << addr_ << "/"
         << prefix_len_ << ", preferred-lft=" << preferred_ << ", valid-lft="
         << valid_ << endl;
 

+ 3 - 3
src/lib/dhcp/option_custom.cc

@@ -54,7 +54,7 @@ OptionCustom::addArrayDataField(const asiolink::IOAddress& address) {
     if ((address.isV4() && definition_.getType() != OPT_IPV4_ADDRESS_TYPE) ||
         (address.isV6() && definition_.getType() != OPT_IPV6_ADDRESS_TYPE)) {
         isc_throw(BadDataTypeCast, "invalid address specified "
-                  << address.toText() << ". Expected a valid IPv"
+                  << address << ". Expected a valid IPv"
                   << (definition_.getType() == OPT_IPV4_ADDRESS_TYPE ?
                       "4" : "6") << " address.");
     }
@@ -375,7 +375,7 @@ OptionCustom::dataFieldToText(const OptionDataType data_type,
         break;
     case OPT_IPV4_ADDRESS_TYPE:
     case OPT_IPV6_ADDRESS_TYPE:
-        text << readAddress(index).toText();
+        text << readAddress(index);
         break;
     case OPT_FQDN_TYPE:
         text << readFqdn(index);
@@ -443,7 +443,7 @@ OptionCustom::writeAddress(const asiolink::IOAddress& address,
     if ((address.isV4() && buffers_[index].size() != V4ADDRESS_LEN) ||
         (address.isV6() && buffers_[index].size() != V6ADDRESS_LEN)) {
         isc_throw(BadDataTypeCast, "invalid address specified "
-                  << address.toText() << ". Expected a valid IPv"
+                  << address << ". Expected a valid IPv"
                   << (buffers_[index].size() == V4ADDRESS_LEN ? "4" : "6")
                   << " address.");
     }

+ 1 - 1
src/lib/dhcp/option_definition.cc

@@ -497,7 +497,7 @@ OptionDefinition::writeToBuffer(const std::string& value,
             asiolink::IOAddress address(value);
             if (!address.isV4() && !address.isV6()) {
                 isc_throw(BadDataTypeCast, "provided address "
-                          << address.toText()
+                          << address
                           << " is not a valid IPv4 or IPv6 address.");
             }
             OptionDataTypeUtil::writeAddress(address, buf);

+ 2 - 2
src/lib/dhcp/pkt4.cc

@@ -278,8 +278,8 @@ void Pkt4::repack() {
 std::string
 Pkt4::toText() {
     stringstream tmp;
-    tmp << "localAddr=" << local_addr_.toText() << ":" << local_port_
-        << " remoteAddr=" << remote_addr_.toText()
+    tmp << "localAddr=" << local_addr_ << ":" << local_port_
+        << " remoteAddr=" << remote_addr_
         << ":" << remote_port_ << ", msgtype=" << static_cast<int>(getType())
         << ", transid=0x" << hex << transid_ << dec << endl;
 

+ 2 - 2
src/lib/dhcp/pkt6.cc

@@ -453,8 +453,8 @@ Pkt6::unpackTCP() {
 std::string
 Pkt6::toText() {
     stringstream tmp;
-    tmp << "localAddr=[" << local_addr_.toText() << "]:" << local_port_
-        << " remoteAddr=[" << remote_addr_.toText()
+    tmp << "localAddr=[" << local_addr_ << "]:" << local_port_
+        << " remoteAddr=[" << remote_addr_
         << "]:" << remote_port_ << endl;
     tmp << "msgtype=" << static_cast<int>(msg_type_) << ", transid=0x" <<
         hex << transid_ << dec << endl;

+ 3 - 3
src/lib/dhcp/pkt_filter.cc

@@ -29,7 +29,7 @@ PktFilter::openFallbackSocket(const isc::asiolink::IOAddress& addr,
     int sock = socket(AF_INET, SOCK_DGRAM, 0);
     if (sock < 0) {
         isc_throw(SocketConfigError, "failed to create fallback socket for"
-                  " address " << addr.toText() << ", port " << port
+                  " address " << addr << ", port " << port
                   << ", reason: " << strerror(errno));
     }
     // Bind the socket to a specified address and port.
@@ -44,7 +44,7 @@ PktFilter::openFallbackSocket(const isc::asiolink::IOAddress& addr,
         // Remember to close the socket if we failed to bind it.
         close(sock);
         isc_throw(SocketConfigError, "failed to bind fallback socket to"
-                  " address " << addr.toText() << ", port " << port
+                  " address " << addr << ", port " << port
                   << ", reason: " << strerror(errno)
                   << " - is another DHCP server running?");
     }
@@ -54,7 +54,7 @@ PktFilter::openFallbackSocket(const isc::asiolink::IOAddress& addr,
     if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) {
         close(sock);
         isc_throw(SocketConfigError, "failed to set SO_NONBLOCK option on the"
-                  " fallback socket, bound to " << addr.toText() << ", port "
+                  " fallback socket, bound to " << addr << ", port "
                   << port << ", reason: " << strerror(errno));
     }
     // Successfully created and bound a fallback socket. Return a descriptor.

+ 2 - 1
src/lib/dhcp/pkt_filter_inet.cc

@@ -79,7 +79,8 @@ PktFilterInet::openSocket(const Iface& iface,
 
     if (bind(sock, (struct sockaddr *)&addr4, sizeof(addr4)) < 0) {
         close(sock);
-        isc_throw(SocketConfigError, "Failed to bind socket " << sock << " to " << addr.toText()
+        isc_throw(SocketConfigError, "Failed to bind socket " << sock
+                  << " to " << addr
                   << "/port=" << port);
     }
 

+ 5 - 5
src/lib/dhcp/tests/iface_mgr_unittest.cc

@@ -428,10 +428,10 @@ TEST_F(IfaceMgrTest, dhcp6Sniffer) {
         cout << "    pkt = new Pkt6(" << pkt->data_len_ << ");" << endl;
         cout << "    pkt->remote_port_ = " << pkt-> remote_port_ << ";" << endl;
         cout << "    pkt->remote_addr_ = IOAddress(\""
-             << pkt->remote_addr_.toText() << "\");" << endl;
+             << pkt->remote_addr_ << "\");" << endl;
         cout << "    pkt->local_port_ = " << pkt-> local_port_ << ";" << endl;
         cout << "    pkt->local_addr_ = IOAddress(\""
-             << pkt->local_addr_.toText() << "\");" << endl;
+             << pkt->local_addr_ << "\");" << endl;
         cout << "    pkt->ifindex_ = " << pkt->ifindex_ << ";" << endl;
         cout << "    pkt->iface_ = \"" << pkt->iface_ << "\";" << endl;
 
@@ -1015,7 +1015,7 @@ TEST_F(IfaceMgrTest, sendReceive6) {
     EXPECT_EQ(0, memcmp(&sendPkt->data_[0], &rcvPkt->data_[0],
                         rcvPkt->data_.size()));
 
-    EXPECT_EQ(sendPkt->getRemoteAddr().toText(), rcvPkt->getRemoteAddr().toText());
+    EXPECT_EQ(sendPkt->getRemoteAddr(), rcvPkt->getRemoteAddr());
 
     // since we opened 2 sockets on the same interface and none of them is multicast,
     // none is preferred over the other for sending data, so we really should not
@@ -2336,7 +2336,7 @@ TEST_F(IfaceMgrTest, DISABLED_detectIfaces_linux) {
         const Iface::AddressCollection& addrs = i->getAddresses();
         for (Iface::AddressCollection::const_iterator a= addrs.begin();
              a != addrs.end(); ++a) {
-            cout << a->toText() << " ";
+            cout << *a << " ";
         }
         cout << endl;
     }
@@ -2394,7 +2394,7 @@ TEST_F(IfaceMgrTest, DISABLED_detectIfaces_linux) {
                          << " address on " << detected->getFullName() << " interface." << endl;
                     FAIL();
                 }
-                cout << "Address " << addr->toText() << " on interface " << detected->getFullName()
+                cout << "Address " << *addr << " on interface " << detected->getFullName()
                      << " matched with 'ifconfig -a' output." << endl;
             }
         }

+ 6 - 6
src/lib/dhcp/tests/option_custom_unittest.cc

@@ -667,7 +667,7 @@ TEST_F(OptionCustomTest, ipv4AddressDataArray) {
     for (int i = 0; i < 3; ++i) {
         IOAddress address("10.10.10.10");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 
     // Check that it is ok if buffer length is not a multiple of IPv4
@@ -717,7 +717,7 @@ TEST_F(OptionCustomTest, ipv6AddressDataArray) {
     for (int i = 0; i < 3; ++i) {
         IOAddress address("fe80::4");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 
     // Check that it is ok if buffer length is not a multiple of IPv6
@@ -1451,7 +1451,7 @@ TEST_F(OptionCustomTest, unpack) {
     for (int i = 0; i < 3; ++i) {
         IOAddress address("10.10.10.10");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 
     // Remove all addresses we had added. We are going to replace
@@ -1478,7 +1478,7 @@ TEST_F(OptionCustomTest, unpack) {
     for (int i = 0; i < 2; ++i) {
         IOAddress address("10.10.10.10");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 }
 
@@ -1513,7 +1513,7 @@ TEST_F(OptionCustomTest, initialize) {
     for (int i = 0; i < 3; ++i) {
         IOAddress address("fe80::4");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 
     // Clear addresses we had previously added.
@@ -1539,7 +1539,7 @@ TEST_F(OptionCustomTest, initialize) {
     for (int i = 0; i < 2; ++i) {
         IOAddress address("10.10.10.10");
         ASSERT_NO_THROW(address = option->readAddress(i));
-        EXPECT_EQ(addresses[i].toText(), address.toText());
+        EXPECT_EQ(addresses[i], address);
     }
 }
 

+ 2 - 2
src/lib/dhcp/tests/option_data_types_unittest.cc

@@ -93,7 +93,7 @@ TEST_F(OptionDataTypesTest, readAddress) {
 
     // Check that the read address matches address that
     // we used as input.
-    EXPECT_EQ(address.toText(), address_out.toText());
+    EXPECT_EQ(address, address_out);
 
     // Check that an attempt to read the buffer as IPv6 address
     // causes an error as the IPv6 address needs at least 16 bytes
@@ -109,7 +109,7 @@ TEST_F(OptionDataTypesTest, readAddress) {
     address = asiolink::IOAddress("2001:db8:1:0::1");
     writeAddress(address, buf);
     EXPECT_NO_THROW(address_out = OptionDataTypeUtil::readAddress(buf, AF_INET6));
-    EXPECT_EQ(address.toText(), address_out.toText());
+    EXPECT_EQ(address, address_out);
 
     // Truncate the buffer and expect an error to be reported when
     // trying to read it.

+ 8 - 8
src/lib/dhcp/tests/pkt4_unittest.cc

@@ -316,10 +316,10 @@ TEST_F(Pkt4Test, fixedFields) {
     EXPECT_EQ(dummySecs, pkt->getSecs());
     EXPECT_EQ(dummyFlags, pkt->getFlags());
 
-    EXPECT_EQ(dummyCiaddr.toText(), pkt->getCiaddr().toText());
-    EXPECT_EQ(dummyYiaddr.toText(), pkt->getYiaddr().toText());
-    EXPECT_EQ(dummySiaddr.toText(), pkt->getSiaddr().toText());
-    EXPECT_EQ(dummyGiaddr.toText(), pkt->getGiaddr().toText());
+    EXPECT_EQ(dummyCiaddr, pkt->getCiaddr());
+    EXPECT_EQ(dummyYiaddr, pkt->getYiaddr());
+    EXPECT_EQ(dummySiaddr, pkt->getSiaddr());
+    EXPECT_EQ(dummyGiaddr, pkt->getGiaddr());
 
     // Chaddr contains link-layer addr (MAC). It is no longer always 16 bytes
     // long and its length depends on hlen value (it is up to 16 bytes now).
@@ -382,10 +382,10 @@ TEST_F(Pkt4Test, fixedFieldsUnpack) {
     EXPECT_EQ(dummySecs, pkt->getSecs());
     EXPECT_EQ(dummyFlags, pkt->getFlags());
 
-    EXPECT_EQ(dummyCiaddr.toText(), pkt->getCiaddr().toText());
-    EXPECT_EQ(string("1.2.3.4"), pkt->getYiaddr().toText());
-    EXPECT_EQ(string("192.0.2.255"), pkt->getSiaddr().toText());
-    EXPECT_EQ(string("255.255.255.255"), pkt->getGiaddr().toText());
+    EXPECT_EQ(dummyCiaddr, pkt->getCiaddr());
+    EXPECT_EQ("1.2.3.4", pkt->getYiaddr().toText());
+    EXPECT_EQ("192.0.2.255", pkt->getSiaddr().toText());
+    EXPECT_EQ("255.255.255.255", pkt->getGiaddr().toText());
 
     // chaddr is always 16 bytes long and contains link-layer addr (MAC)
     EXPECT_EQ(0, memcmp(dummyChaddr, &pkt->getHWAddr()->hwaddr_[0], dummyHlen));

+ 2 - 2
src/lib/dhcp/tests/protocol_util_unittest.cc

@@ -359,7 +359,7 @@ TEST(ProtocolUtilTest, writeIpUdpHeader) {
         in_buf.readData(src_addr_data, 4);
         src_addr = IOAddress::fromBytes(AF_INET, src_addr_data);
     );
-    EXPECT_EQ(IOAddress("192.0.2.1").toText(), src_addr.toText());
+    EXPECT_EQ(IOAddress("192.0.2.1"), src_addr);
 
     // Validate destination address.
     IOAddress dest_addr("::1");
@@ -368,7 +368,7 @@ TEST(ProtocolUtilTest, writeIpUdpHeader) {
         in_buf.readData(dest_addr_data, 4);
         dest_addr = IOAddress::fromBytes(AF_INET, dest_addr_data);
     );
-    EXPECT_EQ(IOAddress("192.0.2.111").toText(), dest_addr.toText());
+    EXPECT_EQ(IOAddress("192.0.2.111"), dest_addr);
 
     // UDP header starts here.
 

+ 1 - 1
src/lib/dhcp_ddns/ncr_msg.cc

@@ -611,7 +611,7 @@ NameChangeRequest::toText() const {
            << "Reverse Change: " << (reverse_change_ ? "yes" : "no")
            << std::endl
            << "FQDN: [" << fqdn_ << "]" << std::endl
-           << "IP Address: [" << ip_io_address_.toText()  << "]" << std::endl
+           << "IP Address: [" << ip_io_address_ << "]" << std::endl
            << "DHCID: [" << dhcid_.toStr() << "]" << std::endl
            << "Lease Expires On: " << getLeaseExpiresOnStr() << std::endl
            << "Lease Length: " << lease_length_ << std::endl;

+ 1 - 1
src/lib/dhcpsrv/alloc_engine.cc

@@ -90,7 +90,7 @@ AllocEngine::IterativeAllocator::increasePrefix(const isc::asiolink::IOAddress&
                                                 const uint8_t prefix_len) {
     if (!prefix.isV6()) {
         isc_throw(BadValue, "Prefix operations are for IPv6 only (attempted to "
-                  "increase prefix " << prefix.toText() << ")");
+                  "increase prefix " << prefix << ")");
     }
 
     // Get a buffer holding an address.

+ 2 - 2
src/lib/dhcpsrv/lease.cc

@@ -175,7 +175,7 @@ Lease6::toText() const {
 
     stream << "Type:          " << typeToText(type_) << "(" 
            << static_cast<int>(type_) << ") ";
-    stream << "Address:       " << addr_.toText() << "\n"
+    stream << "Address:       " << addr_ << "\n"
            << "Prefix length: " << static_cast<int>(prefixlen_) << "\n"
            << "IAID:          " << iaid_ << "\n"
            << "Pref life:     " << preferred_lft_ << "\n"
@@ -190,7 +190,7 @@ std::string
 Lease4::toText() const {
     ostringstream stream;
 
-    stream << "Address:       " << addr_.toText() << "\n"
+    stream << "Address:       " << addr_ << "\n"
            << "Valid life:    " << valid_lft_ << "\n"
            << "T1:            " << t1_ << "\n"
            << "T2:            " << t2_ << "\n"

+ 2 - 2
src/lib/dhcpsrv/memfile_lease_mgr.cc

@@ -247,7 +247,7 @@ Memfile_LeaseMgr::updateLease4(const Lease4Ptr& lease) {
     Lease4Storage::iterator lease_it = storage4_.find(lease->addr_);
     if (lease_it == storage4_.end()) {
         isc_throw(NoSuchLease, "failed to update the lease with address "
-                  << lease->addr_.toText() << " - no such lease");
+                  << lease->addr_ << " - no such lease");
     }
     **lease_it = *lease;
 }
@@ -260,7 +260,7 @@ Memfile_LeaseMgr::updateLease6(const Lease6Ptr& lease) {
     Lease6Storage::iterator lease_it = storage6_.find(lease->addr_);
     if (lease_it == storage6_.end()) {
         isc_throw(NoSuchLease, "failed to update the lease with address "
-                  << lease->addr_.toText() << " - no such lease");
+                  << lease->addr_ << " - no such lease");
     }
     **lease_it = *lease;
 }

+ 2 - 2
src/lib/dhcpsrv/mysql_lease_mgr.cc

@@ -1809,12 +1809,12 @@ MySqlLeaseMgr::updateLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind,
     int affected_rows = mysql_stmt_affected_rows(statements_[stindex]);
     if (affected_rows == 0) {
         isc_throw(NoSuchLease, "unable to update lease for address " <<
-                  lease->addr_.toText() << " as it does not exist");
+                  lease->addr_ << " as it does not exist");
     } else if (affected_rows > 1) {
         // Should not happen - primary key constraint should only have selected
         // one row.
         isc_throw(DbOperationError, "apparently updated more than one lease "
-                  "that had the address " << lease->addr_.toText());
+                  "that had the address " << lease->addr_);
     }
 }
 

+ 4 - 4
src/lib/dhcpsrv/pool.cc

@@ -34,8 +34,8 @@ bool Pool::inRange(const isc::asiolink::IOAddress& addr) const {
 std::string
 Pool::toText() const {
     std::stringstream tmp;
-    tmp << "type=" << Lease::typeToText(type_) << ", " << first_.toText()
-        << "-" << last_.toText();
+    tmp << "type=" << Lease::typeToText(type_) << ", " << first_
+        << "-" << last_;
     return (tmp.str());
 }
 
@@ -143,8 +143,8 @@ Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
 std::string
 Pool6::toText() const {
     std::stringstream tmp;
-    tmp << "type=" << Lease::typeToText(type_) << ", " << first_.toText()
-        << "-" << last_.toText() << ", delegated_len="
+    tmp << "type=" << Lease::typeToText(type_) << ", " << first_
+        << "-" << last_ << ", delegated_len="
         << static_cast<int>(prefix_len_);
     return (tmp.str());
 }

+ 5 - 6
src/lib/dhcpsrv/subnet.cc

@@ -165,7 +165,7 @@ void Subnet::setLastAllocated(Lease::Type type,
 std::string
 Subnet::toText() const {
     std::stringstream tmp;
-    tmp << prefix_.toText() << "/" << static_cast<unsigned int>(prefix_len_);
+    tmp << prefix_ << "/" << static_cast<unsigned int>(prefix_len_);
     return (tmp.str());
 }
 
@@ -190,7 +190,7 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
 void Subnet4::setSiaddr(const isc::asiolink::IOAddress& siaddr) {
     if (!siaddr.isV4()) {
         isc_throw(BadValue, "Can't set siaddr to non-IPv4 address "
-                  << siaddr.toText());
+                  << siaddr);
     }
     siaddr_ = siaddr;
 }
@@ -266,9 +266,8 @@ Subnet::addPool(const PoolPtr& pool) {
     IOAddress last_addr = pool->getLastAddress();
 
     if (!inRange(first_addr) || !inRange(last_addr)) {
-        isc_throw(BadValue, "Pool (" << first_addr.toText() << "-"
-                  << last_addr.toText()
-                  << " does not belong in this (" << prefix_.toText() << "/"
+        isc_throw(BadValue, "Pool (" << first_addr << "-" << last_addr
+                  << " does not belong in this (" << prefix_ << "/"
                   << static_cast<int>(prefix_len_) << ") subnet");
     }
 
@@ -335,7 +334,7 @@ Subnet6::Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
     :Subnet(prefix, length, t1, t2, valid_lifetime),
      preferred_(preferred_lifetime){
     if (!prefix.isV6()) {
-        isc_throw(BadValue, "Non IPv6 prefix " << prefix.toText()
+        isc_throw(BadValue, "Non IPv6 prefix " << prefix
                   << " specified in subnet6");
     }
 }

+ 16 - 16
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc

@@ -281,10 +281,10 @@ public:
         ASSERT_TRUE(lease);
 
         // Allocated address must be different
-        EXPECT_NE(used_addr.toText(), lease->addr_.toText());
+        EXPECT_NE(used_addr, lease->addr_);
 
         // We should NOT get what we asked for, because it is used already
-        EXPECT_NE(requested.toText(), lease->addr_.toText());
+        EXPECT_NE(requested, lease->addr_);
 
         // Do all checks on the lease
         checkLease6(lease, type, expected_pd_len);
@@ -325,7 +325,7 @@ public:
         ASSERT_TRUE(lease);
 
         // We should NOT get what we asked for, because it is used already
-        EXPECT_NE(hint.toText(), lease->addr_.toText());
+        EXPECT_NE(hint, lease->addr_);
 
         // Do all checks on the lease
         checkLease6(lease, type, expected_pd_len);
@@ -476,7 +476,7 @@ TEST_F(AllocEngine6Test, allocWithValidHint6) {
                                        false);
 
     // We should get what we asked for
-    EXPECT_EQ(lease->addr_.toText(), "2001:db8:1::15");
+    EXPECT_EQ("2001:db8:1::15", lease->addr_.toText());
 }
 
 // This test checks if the address allocation with a hint that is in range,
@@ -864,7 +864,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
                     CalloutHandlePtr())));
     // Check that we got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // Do all checks on the lease (if subnet-id, preferred/valid times are ok etc.)
     checkLease6(lease, Lease::TYPE_NA, 128);
@@ -876,7 +876,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
 
     // Check that we got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 }
 
 // This test checks if an expired lease can be reused in REQUEST (actual allocation)
@@ -912,7 +912,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
 
     // Check that he got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // Check that the lease is indeed updated in LeaseMgr
     Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
@@ -1075,10 +1075,10 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) {
     ASSERT_TRUE(lease);
 
     // Allocated address must be different
-    EXPECT_TRUE(used->addr_.toText() != lease->addr_.toText());
+    EXPECT_NE(used->addr_, lease->addr_);
 
     // We should NOT get what we asked for, because it is used already
-    EXPECT_TRUE(lease->addr_.toText() != "192.0.2.106");
+    EXPECT_NE("192.0.2.106", lease->addr_.toText());
 
     // Do all checks on the lease
     checkLease4(lease);
@@ -1115,7 +1115,7 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
     EXPECT_FALSE(old_lease_);
 
     // We should NOT get what we asked for, because it is used already
-    EXPECT_TRUE(lease->addr_.toText() != "10.1.1.1");
+    EXPECT_NE("10.1.1.1", lease->addr_.toText());
 
     // Do all checks on the lease
     checkLease4(lease);
@@ -1371,7 +1371,7 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
                                      old_lease_);
     // Check that we got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // We are reusing expired lease, the old (expired) instance should be
     // returned. The returned instance should be the same as the original
@@ -1384,13 +1384,13 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
 
     // CASE 2: Asking specifically for this address
     lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
-                                     IOAddress(addr.toText()),
+                                     IOAddress(addr),
                                      false, false, "",
                                      true, CalloutHandlePtr(),
                                      old_lease_);
     // Check that we got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // We are updating expired lease. The copy of the old lease should be
     // returned and it should be equal to the original lease.
@@ -1425,14 +1425,14 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
 
     // A client comes along, asking specifically for this address
     lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
-                                     IOAddress(addr.toText()),
+                                     IOAddress(addr),
                                      false, true, "host.example.com.",
                                      false, CalloutHandlePtr(),
                                      old_lease_);
 
     // Check that he got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // Check that the lease is indeed updated in LeaseMgr
     Lease4Ptr from_mgr = LeaseMgrFactory::instance().getLease4(addr);
@@ -1481,7 +1481,7 @@ TEST_F(AllocEngine4Test, renewLease4) {
                                 callout_handle, false);
     // Check that he got that single lease
     ASSERT_TRUE(lease);
-    EXPECT_EQ(addr.toText(), lease->addr_.toText());
+    EXPECT_EQ(addr, lease->addr_);
 
     // Check that the lease matches subnet_, hwaddr_,clientid_ parameters
     checkLease4(lease);

+ 2 - 2
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc

@@ -95,7 +95,7 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
                              IOAddress("2001:db8:1::456"));
     ASSERT_TRUE(x);
 
-    EXPECT_EQ(x->addr_.toText(), addr.toText());
+    EXPECT_EQ(x->addr_, addr);
     EXPECT_TRUE(*x->duid_ == *duid);
     EXPECT_EQ(x->iaid_, iaid);
     EXPECT_EQ(x->subnet_id_, subnet_id);
@@ -114,7 +114,7 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
     ASSERT_TRUE(y);
     EXPECT_TRUE(*y->duid_ == *duid);
     EXPECT_EQ(y->iaid_, iaid);
-    EXPECT_EQ(y->addr_.toText(), addr.toText());
+    EXPECT_EQ(y->addr_, addr);
 
     // Test getLease6(duid, iaid, subnet_id) - wrong iaid
     uint32_t invalid_iaid = 9; // no such iaid

+ 2 - 2
src/lib/dhcpsrv/tests/test_utils.cc

@@ -48,7 +48,7 @@ detailCompareLease(const Lease4Ptr& first, const Lease4Ptr& second) {
     // odd things happen when they are different: the EXPECT_EQ macro appears to
     // call the operator uint32_t() function, which causes an exception to be
     // thrown for IPv6 addresses.
-    EXPECT_EQ(first->addr_.toText(), second->addr_.toText());
+    EXPECT_EQ(first->addr_, second->addr_);
     EXPECT_TRUE(first->hwaddr_ == second->hwaddr_);
     if (first->client_id_ && second->client_id_) {
         EXPECT_TRUE(*first->client_id_ == *second->client_id_);
@@ -83,7 +83,7 @@ detailCompareLease(const Lease6Ptr& first, const Lease6Ptr& second) {
     // odd things happen when they are different: the EXPECT_EQ macro appears to
     // call the operator uint32_t() function, which causes an exception to be
     // thrown for IPv6 addresses.
-    EXPECT_EQ(first->addr_.toText(), second->addr_.toText());
+    EXPECT_EQ(first->addr_, second->addr_);
     EXPECT_EQ(first->prefixlen_, second->prefixlen_);
     EXPECT_EQ(first->iaid_, second->iaid_);
     ASSERT_TRUE(first->duid_);