2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-02 06:55:16 +00:00

[1283] Remove toText() calls where IOAddress should be used directly

This commit is contained in:
Mukund Sivaraman
2014-01-07 10:49:14 +05:30
parent df980e49b8
commit 7607200420
33 changed files with 124 additions and 126 deletions

View File

@@ -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());

View File

@@ -456,7 +456,7 @@ TEST_F(Dhcpv4SrvTest, 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());
@@ -495,7 +495,7 @@ TEST_F(Dhcpv4SrvTest, 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());
@@ -534,7 +534,7 @@ TEST_F(Dhcpv4SrvTest, 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());
@@ -600,12 +600,12 @@ TEST_F(Dhcpv4SrvTest, 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.
@@ -665,7 +665,7 @@ TEST_F(Dhcpv4SrvTest, 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
@@ -744,9 +744,9 @@ TEST_F(Dhcpv4SrvTest, 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_);
@@ -768,12 +768,12 @@ TEST_F(Dhcpv4SrvTest, 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
@@ -859,7 +859,7 @@ TEST_F(Dhcpv4SrvTest, 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

View File

@@ -136,7 +136,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
@@ -309,14 +309,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);
}

View File

@@ -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;

View File

@@ -1193,7 +1193,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);

View File

@@ -783,8 +783,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.
@@ -917,8 +916,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());
}

View File

@@ -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

View File

@@ -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_);

View File

@@ -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);

View File

@@ -84,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) {

View File

@@ -190,7 +190,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.");
}
}
@@ -569,7 +569,7 @@ int IfaceMgr::openSocket(const std::string& ifname, const IOAddress& addr,
} else {
isc_throw(BadValue, "Failed to detect family of address: "
<< addr.toText());
<< addr);
}
}
@@ -644,7 +644,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,
@@ -751,7 +751,8 @@ int IfaceMgr::openSocket6(Iface& iface, const IOAddress& addr, uint16_t port) {
if (bind(sock, (struct sockaddr *)&addr6, sizeof(addr6)) < 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);
}
#ifdef IPV6_RECVPKTINFO

View File

@@ -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;

View File

@@ -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_);

View File

@@ -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.");
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -346,10 +346,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;
@@ -914,7 +914,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

View File

@@ -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);
}
}

View File

@@ -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.

View File

@@ -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));

View File

@@ -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.

View File

@@ -590,7 +590,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;

View File

@@ -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"

View File

@@ -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;
}

View File

@@ -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_);
}
}

View File

@@ -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());
}

View File

@@ -263,8 +263,7 @@ 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()
isc_throw(BadValue, "Pool (" << first_addr << "-" << last_addr
<< " does not belong in this (" << prefix_.toText() << "/"
<< static_cast<int>(prefix_len_) << ") subnet");
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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_);