Commit c809fbc4 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3695] Addressed review comments.

parent 4a622997
......@@ -245,6 +245,12 @@ public:
return (address);
}
/// @brief Returns an IPv6 zero address.
static const IOAddress& IPV6_ZERO_ADDRESS() {
static IOAddress address("::");
return (address);
}
//@}
private:
......
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011, 2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -217,3 +217,9 @@ TEST(IOAddressTest, accessClassificationMethods) {
EXPECT_FALSE(addr5.isV6LinkLocal());
EXPECT_TRUE (addr5.isV6Multicast());
}
TEST(IOAddressTest, staticAddresses) {
EXPECT_EQ(IOAddress("0.0.0.0"), IOAddress::IPV4_ZERO_ADDRESS());
EXPECT_EQ(IOAddress("255.255.255.255"), IOAddress::IPV4_BCAST_ADDRESS());
EXPECT_EQ(IOAddress("::"), IOAddress::IPV6_ZERO_ADDRESS());
}
......@@ -282,8 +282,8 @@ Iface::setActive(const bool active) {
}
}
uint16_t
Iface::countActive() const {
unsigned int
Iface::countActive4() const {
uint16_t count = 0;
for (AddressCollection::const_iterator addr_it = addrs_.begin();
addr_it != addrs_.end(); ++addr_it) {
......
// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -341,7 +341,7 @@ public:
void setActive(const bool active);
/// @brief Returns a number of activated IPv4 addresses on the interface.
uint16_t countActive() const;
unsigned int countActive4() const;
/// @brief Deletes an address from an interface.
///
......
......@@ -92,24 +92,24 @@ TEST(IfaceTest, readBuffer) {
// Check that counting the number of active addresses on the interface
// works as expected.
TEST(IfaceTest, countActive) {
TEST(IfaceTest, countActive4) {
Iface iface("eth0", 0);
ASSERT_EQ(0, iface.countActive());
ASSERT_EQ(0, iface.countActive4());
iface.addAddress(IOAddress("192.168.0.2"));
ASSERT_EQ(1, iface.countActive());
ASSERT_EQ(1, iface.countActive4());
iface.addAddress(IOAddress("2001:db8:1::1"));
ASSERT_EQ(1, iface.countActive());
ASSERT_EQ(1, iface.countActive4());
iface.addAddress(IOAddress("192.168.0.3"));
ASSERT_EQ(2, iface.countActive());
ASSERT_EQ(2, iface.countActive4());
ASSERT_NO_THROW(iface.setActive(IOAddress("192.168.0.2"), false));
ASSERT_EQ(1, iface.countActive());
ASSERT_EQ(1, iface.countActive4());
ASSERT_NO_THROW(iface.setActive(IOAddress("192.168.0.3"), false));
ASSERT_EQ(0, iface.countActive());
ASSERT_EQ(0, iface.countActive4());
}
/// Mock object implementing PktFilter class. It is used by
......
......@@ -48,7 +48,7 @@ CfgIface::multipleAddressesPerInterfaceActive() const {
const IfaceMgr::IfaceCollection& ifaces = IfaceMgr::instance().getIfaces();
for (IfaceMgr::IfaceCollection::const_iterator iface = ifaces.begin();
iface != ifaces.end(); ++iface) {
if (iface->countActive() > 1) {
if (iface->countActive4() > 1) {
return (true);
}
}
......
......@@ -258,7 +258,7 @@ public:
private:
/// @brief Checks if multiple IPv4 addresses has been activate on any
/// @brief Checks if multiple IPv4 addresses has been activated on any
/// interface.
///
/// This method is useful to check if the current configuration uses
......@@ -296,7 +296,7 @@ private:
/// @param active A boolean value which indicates if all addresses should
/// be active (if true), or inactive (if false).
/// @param iface An interface on which addresses are selected/deselected.
void setIfaceAddrsState(const uint16_t family, const bool inactive,
void setIfaceAddrsState(const uint16_t family, const bool active,
Iface& iface) const;
/// @brief Error handler for executed when opening a socket fail.
......
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