Browse Source

[3695] Addressed review comments.

Marcin Siodelski 10 years ago
parent
commit
c809fbc454

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

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

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

@@ -1,4 +1,4 @@
-// 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());
+}

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

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

+ 2 - 2
src/lib/dhcp/iface_mgr.h

@@ -1,4 +1,4 @@
-// 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.
     ///

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

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

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

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

+ 2 - 2
src/lib/dhcpsrv/cfg_iface.h

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