BIND 10 trac2238, updated. b8f538b9fcf70394e5737269d4bed660721c245d [2238] Circular dependency (asiolink->log->util->asiolink) fixed.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Sep 19 13:57:38 UTC 2012


The branch, trac2238 has been updated
       via  b8f538b9fcf70394e5737269d4bed660721c245d (commit)
      from  68621232d6840227c4309c1fd1ee9e1a8b26120f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b8f538b9fcf70394e5737269d4bed660721c245d
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Sep 19 15:57:17 2012 +0200

    [2238] Circular dependency (asiolink->log->util->asiolink) fixed.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcp/Makefile.am                           |    1 +
 src/lib/{util => dhcp}/addr_utilities.cc           |    4 ++--
 src/lib/{util => dhcp}/addr_utilities.h            |    2 +-
 src/lib/dhcp/cfgmgr.cc                             |    2 +-
 src/lib/dhcp/tests/Makefile.am                     |    4 +++-
 .../tests/addr_utilities_unittest.cc               |    4 ++--
 src/lib/util/Makefile.am                           |    1 -
 src/lib/util/tests/Makefile.am                     |    2 --
 8 files changed, 10 insertions(+), 10 deletions(-)
 rename src/lib/{util => dhcp}/addr_utilities.cc (97%)
 rename src/lib/{util => dhcp}/addr_utilities.h (99%)
 rename src/lib/{util => dhcp}/tests/addr_utilities_unittest.cc (98%)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/Makefile.am b/src/lib/dhcp/Makefile.am
index 3bcb398..a458848 100644
--- a/src/lib/dhcp/Makefile.am
+++ b/src/lib/dhcp/Makefile.am
@@ -30,6 +30,7 @@ libb10_dhcp___la_SOURCES += pkt6.cc pkt6.h
 libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h
 
 libb10_dhcpsrv_la_SOURCES  = cfgmgr.cc cfgmgr.h
+libb10_dhcpsrv_la_SOURCES += addr_utilities.cc addr_utilities.h
 libb10_dhcpsrv_la_CXXFLAGS = $(AM_CXXFLAGS)
 libb10_dhcpsrv_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES)
 libb10_dhcpsrv_la_LIBADD   = $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
diff --git a/src/lib/dhcp/addr_utilities.cc b/src/lib/dhcp/addr_utilities.cc
new file mode 100644
index 0000000..ddd761a
--- /dev/null
+++ b/src/lib/dhcp/addr_utilities.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2012 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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <dhcp/addr_utilities.h>
+
+namespace isc {
+namespace dhcp {
+
+isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
+                                           uint8_t len) {
+
+    static char bitMask[]= { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
+    uint8_t packed[16];
+
+    memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
+
+    if (len % 8 != 0) {
+        uint8_t mask = bitMask[len % 8];
+        packed[len / 8] = packed[len / 8] & mask;
+        len = (len/8 + 1) * 8;
+    }
+    for (int i = len / 8; i < 16; ++i) {
+        packed[i] = 0x0;
+    }
+
+    return (isc::asiolink::IOAddress::from_bytes(AF_INET6, packed));
+}
+
+isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
+                                          uint8_t len) {
+
+    static char bitMask[]= { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
+    uint8_t packed[16];
+
+    memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
+
+    if (len % 8 != 0) {
+        uint8_t mask = bitMask[len % 8];
+        packed[len / 8] = packed[len / 8] | ~mask;
+        len = (len/8 + 1) * 8;
+    }
+    for (int i = len / 8; i < 16; ++i) {
+        packed[i] = 0xff;
+    }
+
+    return (isc::asiolink::IOAddress::from_bytes(AF_INET6, packed));
+}
+
+};
+};
diff --git a/src/lib/dhcp/addr_utilities.h b/src/lib/dhcp/addr_utilities.h
new file mode 100644
index 0000000..d82a8a6
--- /dev/null
+++ b/src/lib/dhcp/addr_utilities.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2012 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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <asiolink/io_address.h>
+
+namespace isc {
+namespace dhcp {
+
+/// This code is based on similar code from the Dibbler project. I, Tomasz Mrugalski,
+/// as a sole creater of that code hereby release it under BSD license for the benefit
+/// of the BIND10 project.
+
+/// @brief returns a first address in a given prefix
+///
+/// Example: For 2001:db8:1::deaf:beef and length /120 the function will return
+/// 2001:db8:1::dead:bee0. See also @ref lastAddrInPrefix.
+///
+/// @param prefix and address that belongs to a prefix
+/// @param len prefix length
+///
+/// @return first address from a prefix
+isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
+                                           uint8_t len);
+
+/// @brief returns a last address in a given prefix
+///
+/// Example: For 2001:db8:1::deaf:beef and length /112 the function will return
+/// 2001:db8:1::dead:ffff. See also @ref firstAddrInPrefix.
+///
+/// @param prefix and address that belongs to a prefix
+/// @param len prefix length
+///
+/// @return first address from a prefix
+isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
+                                          uint8_t len);
+
+};
+};
diff --git a/src/lib/dhcp/cfgmgr.cc b/src/lib/dhcp/cfgmgr.cc
index 22b99de..1bb76c8 100644
--- a/src/lib/dhcp/cfgmgr.cc
+++ b/src/lib/dhcp/cfgmgr.cc
@@ -12,7 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include <util/addr_utilities.h>
+#include <dhcp/addr_utilities.h>
 #include <asiolink/io_address.h>
 #include <dhcp/cfgmgr.h>
 
diff --git a/src/lib/dhcp/tests/Makefile.am b/src/lib/dhcp/tests/Makefile.am
index d061d0d..4eb7e3c 100644
--- a/src/lib/dhcp/tests/Makefile.am
+++ b/src/lib/dhcp/tests/Makefile.am
@@ -45,7 +45,8 @@ libdhcp___unittests_LDFLAGS  = $(AM_LDFLAGS)  $(GTEST_LDFLAGS)
 libdhcp___unittests_CXXFLAGS = $(AM_CXXFLAGS)
 
 libdhcpsrv_unittests_SOURCES  = run_unittests.cc
-libdhcpsrv_unittests_SOURCES  += ../cfgmgr.cc ../cfgmgr.h cfgmgr_unittest.cc
+libdhcpsrv_unittests_SOURCES += ../cfgmgr.cc ../cfgmgr.h cfgmgr_unittest.cc
+libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc
 
 libdhcpsrv_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
 libdhcpsrv_unittests_LDFLAGS  = $(AM_LDFLAGS)  $(GTEST_LDFLAGS)
@@ -53,6 +54,7 @@ libdhcpsrv_unittests_CXXFLAGS = $(AM_CXXFLAGS)
 libdhcpsrv_unittests_LDADD  = $(GTEST_LDADD)
 libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
 libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
+libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libb10-dhcpsrv.la
 
 
 if USE_CLANGPP
diff --git a/src/lib/dhcp/tests/addr_utilities_unittest.cc b/src/lib/dhcp/tests/addr_utilities_unittest.cc
new file mode 100644
index 0000000..c9daa9b
--- /dev/null
+++ b/src/lib/dhcp/tests/addr_utilities_unittest.cc
@@ -0,0 +1,85 @@
+
+// Copyright (C) 2010  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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <config.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <gtest/gtest.h>
+#include <vector>
+
+#include <dhcp/addr_utilities.h>
+
+using namespace std;
+using namespace isc::dhcp;
+using namespace isc::asiolink;
+
+TEST(Pool6Test, lastAddrInPrefix) {
+    IOAddress addr1("2001:db8:1:1234:5678:abcd:1234:beef");
+
+    // Prefixes rounded to nibbles are easy...
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1234:ffff",
+              lastAddrInPrefix(addr1, 112).toText());
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:123f:ffff",
+              lastAddrInPrefix(addr1, 108).toText());
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:12ff:ffff",
+              lastAddrInPrefix(addr1, 104).toText());
+    EXPECT_EQ("2001:db8:1:1234:ffff:ffff:ffff:ffff",
+              lastAddrInPrefix(addr1, 64).toText());
+
+    IOAddress addr2("2001::");
+
+    // These are tricker, though, as they are done in 1 bit increments
+
+    // the last address in 2001::/127 pool should be 2001::1
+    EXPECT_EQ("2001::1", lastAddrInPrefix(addr2, 127).toText());
+
+    EXPECT_EQ("2001::3", lastAddrInPrefix(addr2, 126).toText());
+    EXPECT_EQ("2001::7", lastAddrInPrefix(addr2, 125).toText());
+    EXPECT_EQ("2001::f", lastAddrInPrefix(addr2, 124).toText());
+    EXPECT_EQ("2001::1f", lastAddrInPrefix(addr2, 123).toText());
+    EXPECT_EQ("2001::3f", lastAddrInPrefix(addr2, 122).toText());
+    EXPECT_EQ("2001::7f", lastAddrInPrefix(addr2, 121).toText());
+    EXPECT_EQ("2001::ff", lastAddrInPrefix(addr2, 120).toText());
+}
+
+TEST(Pool6Test, firstAddrInPrefix) {
+    IOAddress addr1("2001:db8:1:1234:5678:abcd:1234:beef");
+
+    // Prefixes rounded to nibbles are easy...
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1234:0",
+              firstAddrInPrefix(addr1, 112).toText());
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1230:0",
+              firstAddrInPrefix(addr1, 108).toText());
+    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1200:0",
+              firstAddrInPrefix(addr1, 104).toText());
+    EXPECT_EQ("2001:db8:1:1234::",
+              firstAddrInPrefix(addr1, 64).toText());
+
+    IOAddress addr2("2001::ffff");
+
+    // These are tricker, though, as they are done in 1 bit increments
+
+    // the first address in 2001::/127 pool should be 2001::1
+    EXPECT_EQ("2001::fffe", firstAddrInPrefix(addr2, 127).toText());
+
+    EXPECT_EQ("2001::fffc", firstAddrInPrefix(addr2, 126).toText());
+    EXPECT_EQ("2001::fff8", firstAddrInPrefix(addr2, 125).toText());
+    EXPECT_EQ("2001::fff0", firstAddrInPrefix(addr2, 124).toText());
+    EXPECT_EQ("2001::ffe0", firstAddrInPrefix(addr2, 123).toText());
+    EXPECT_EQ("2001::ffc0", firstAddrInPrefix(addr2, 122).toText());
+    EXPECT_EQ("2001::ff80", firstAddrInPrefix(addr2, 121).toText());
+    EXPECT_EQ("2001::ff00", firstAddrInPrefix(addr2, 120).toText());
+}
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index d599668..c56e4b8 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -28,7 +28,6 @@ libb10_util_la_SOURCES += encode/binary_from_base32hex.h
 libb10_util_la_SOURCES += encode/binary_from_base16.h
 libb10_util_la_SOURCES += random/qid_gen.h random/qid_gen.cc
 libb10_util_la_SOURCES += random/random_number_generator.h
-libb10_util_la_SOURCES += addr_utilities.cc addr_utilities.h
 
 EXTRA_DIST = python/pycppwrapper_util.h
 
diff --git a/src/lib/util/addr_utilities.cc b/src/lib/util/addr_utilities.cc
deleted file mode 100644
index 481c0e3..0000000
--- a/src/lib/util/addr_utilities.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2012 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
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <util/addr_utilities.h>
-
-namespace isc {
-namespace util {
-
-isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len) {
-
-    static char bitMask[]= { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
-    uint8_t packed[16];
-
-    memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
-
-    if (len % 8 != 0) {
-        uint8_t mask = bitMask[len % 8];
-        packed[len / 8] = packed[len / 8] & mask;
-        len = (len/8 + 1) * 8;
-    }
-    for (int i = len / 8; i < 16; ++i) {
-        packed[i] = 0x0;
-    }
-
-    return (isc::asiolink::IOAddress::from_bytes(AF_INET6, packed));
-}
-
-isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                          uint8_t len) {
-
-    static char bitMask[]= { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
-    uint8_t packed[16];
-
-    memcpy(packed, prefix.getAddress().to_v6().to_bytes().data(), 16);
-
-    if (len % 8 != 0) {
-        uint8_t mask = bitMask[len % 8];
-        packed[len / 8] = packed[len / 8] | ~mask;
-        len = (len/8 + 1) * 8;
-    }
-    for (int i = len / 8; i < 16; ++i) {
-        packed[i] = 0xff;
-    }
-
-    return (isc::asiolink::IOAddress::from_bytes(AF_INET6, packed));
-}
-
-};
-};
diff --git a/src/lib/util/addr_utilities.h b/src/lib/util/addr_utilities.h
deleted file mode 100644
index 7f35326..0000000
--- a/src/lib/util/addr_utilities.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2012 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
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <asiolink/io_address.h>
-
-namespace isc {
-namespace util {
-
-/// This code is based on similar code from the Dibbler project. I, Tomasz Mrugalski,
-/// as a sole creater of that code hereby release it under BSD license for the benefit
-/// of the BIND10 project.
-
-/// @brief returns a first address in a given prefix
-///
-/// Example: For 2001:db8:1::deaf:beef and length /120 the function will return
-/// 2001:db8:1::dead:bee0. See also @ref lastAddrInPrefix.
-///
-/// @param prefix and address that belongs to a prefix
-/// @param len prefix length
-///
-/// @return first address from a prefix
-isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len);
-
-/// @brief returns a last address in a given prefix
-///
-/// Example: For 2001:db8:1::deaf:beef and length /112 the function will return
-/// 2001:db8:1::dead:ffff. See also @ref firstAddrInPrefix.
-///
-/// @param prefix and address that belongs to a prefix
-/// @param len prefix length
-///
-/// @return first address from a prefix
-isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                          uint8_t len);
-
-};
-};
diff --git a/src/lib/util/tests/Makefile.am b/src/lib/util/tests/Makefile.am
index 5f3705d..105322f 100644
--- a/src/lib/util/tests/Makefile.am
+++ b/src/lib/util/tests/Makefile.am
@@ -41,7 +41,6 @@ run_unittests_SOURCES += socketsession_unittest.cc
 run_unittests_SOURCES += strutil_unittest.cc
 run_unittests_SOURCES += time_utilities_unittest.cc
 run_unittests_SOURCES += range_utilities_unittest.cc
-run_unittests_SOURCES += addr_utilities_unittest.cc
 
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
@@ -51,7 +50,6 @@ run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libb10-util-io.la
 run_unittests_LDADD += \
 	$(top_builddir)/src/lib/util/unittests/libutil_unittests.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
-run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
 run_unittests_LDADD += $(GTEST_LDADD)
 endif
 
diff --git a/src/lib/util/tests/addr_utilities_unittest.cc b/src/lib/util/tests/addr_utilities_unittest.cc
deleted file mode 100644
index 6fef61c..0000000
--- a/src/lib/util/tests/addr_utilities_unittest.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-
-// Copyright (C) 2010  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
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <config.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <gtest/gtest.h>
-#include <vector>
-
-#include <util/addr_utilities.h>
-
-using namespace std;
-using namespace isc::util;
-using namespace isc::asiolink;
-
-TEST(Pool6Test, lastAddrInPrefix) {
-    IOAddress addr1("2001:db8:1:1234:5678:abcd:1234:beef");
-
-    // Prefixes rounded to nibbles are easy...
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1234:ffff",
-              lastAddrInPrefix(addr1, 112).toText());
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:123f:ffff",
-              lastAddrInPrefix(addr1, 108).toText());
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:12ff:ffff",
-              lastAddrInPrefix(addr1, 104).toText());
-    EXPECT_EQ("2001:db8:1:1234:ffff:ffff:ffff:ffff",
-              lastAddrInPrefix(addr1, 64).toText());
-
-    IOAddress addr2("2001::");
-
-    // These are tricker, though, as they are done in 1 bit increments
-
-    // the last address in 2001::/127 pool should be 2001::1
-    EXPECT_EQ("2001::1", lastAddrInPrefix(addr2, 127).toText());
-
-    EXPECT_EQ("2001::3", lastAddrInPrefix(addr2, 126).toText());
-    EXPECT_EQ("2001::7", lastAddrInPrefix(addr2, 125).toText());
-    EXPECT_EQ("2001::f", lastAddrInPrefix(addr2, 124).toText());
-    EXPECT_EQ("2001::1f", lastAddrInPrefix(addr2, 123).toText());
-    EXPECT_EQ("2001::3f", lastAddrInPrefix(addr2, 122).toText());
-    EXPECT_EQ("2001::7f", lastAddrInPrefix(addr2, 121).toText());
-    EXPECT_EQ("2001::ff", lastAddrInPrefix(addr2, 120).toText());
-}
-
-TEST(Pool6Test, firstAddrInPrefix) {
-    IOAddress addr1("2001:db8:1:1234:5678:abcd:1234:beef");
-
-    // Prefixes rounded to nibbles are easy...
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1234:0",
-              firstAddrInPrefix(addr1, 112).toText());
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1230:0",
-              firstAddrInPrefix(addr1, 108).toText());
-    EXPECT_EQ("2001:db8:1:1234:5678:abcd:1200:0",
-              firstAddrInPrefix(addr1, 104).toText());
-    EXPECT_EQ("2001:db8:1:1234::",
-              firstAddrInPrefix(addr1, 64).toText());
-
-    IOAddress addr2("2001::ffff");
-
-    // These are tricker, though, as they are done in 1 bit increments
-
-    // the first address in 2001::/127 pool should be 2001::1
-    EXPECT_EQ("2001::fffe", firstAddrInPrefix(addr2, 127).toText());
-
-    EXPECT_EQ("2001::fffc", firstAddrInPrefix(addr2, 126).toText());
-    EXPECT_EQ("2001::fff8", firstAddrInPrefix(addr2, 125).toText());
-    EXPECT_EQ("2001::fff0", firstAddrInPrefix(addr2, 124).toText());
-    EXPECT_EQ("2001::ffe0", firstAddrInPrefix(addr2, 123).toText());
-    EXPECT_EQ("2001::ffc0", firstAddrInPrefix(addr2, 122).toText());
-    EXPECT_EQ("2001::ff80", firstAddrInPrefix(addr2, 121).toText());
-    EXPECT_EQ("2001::ff00", firstAddrInPrefix(addr2, 120).toText());
-}



More information about the bind10-changes mailing list