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