]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3695] Addressed review comments.
authorMarcin Siodelski <marcin@isc.org>
Mon, 16 Feb 2015 17:19:17 +0000 (18:19 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 16 Feb 2015 17:19:17 +0000 (18:19 +0100)
src/lib/asiolink/io_address.h
src/lib/asiolink/tests/io_address_unittest.cc
src/lib/dhcp/iface_mgr.cc
src/lib/dhcp/iface_mgr.h
src/lib/dhcp/tests/iface_mgr_unittest.cc
src/lib/dhcpsrv/cfg_iface.cc
src/lib/dhcpsrv/cfg_iface.h

index 417126eec804c1b382b66b6a3aaab48262b578af..f210242ecbbb281f733f42b183aceb5d8250060e 100644 (file)
@@ -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:
index 221ed5e4715f6b99544b7f682a9ff1e5edf92c2d..b7af7260b074f19e75e4f42d51fe3c7624099072 100644 (file)
@@ -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());
+}
index 1a6228056c0c597a8978f3d55ace6fe116a80b98..620b0ceaf7987100e50c0a232c455f6970452791 100644 (file)
@@ -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) {
index ccb3acfce6392f083ad4ae689cb23b300b8bf112..f993ba6702cc0fdbaa2cf27c6131b68c0ecc0d4a 100644 (file)
@@ -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.
     ///
index a0564f37f2991cd7a63766d21819a17c9ee50136..a6f0597930c8d1c12dfcb027be6310e00a00198e 100644 (file)
@@ -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
index 0e043443afb4caf94a8b94342b277b6ab8a2bbf9..a12a431adfa2eafdcf49bcd779ffb92571700c29 100644 (file)
@@ -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);
         }
     }
index 4edad85f06fb8011c90a7b82b7204b36edffb72a..5803c939d41f27b5ef09864a814bb250961ec91b 100644 (file)
@@ -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.