]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[551-wrong-namespace-for-address-utilities] Moved address utils to isc::asiolink... 551-wrong-namespace-for-address-utilities
authorFrancis Dupont <fdupont@isc.org>
Tue, 4 Jun 2019 14:29:08 +0000 (16:29 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 24 Jun 2019 09:18:58 +0000 (05:18 -0400)
src/lib/asiolink/addr_utilities.cc
src/lib/asiolink/addr_utilities.h
src/lib/asiolink/tests/addr_utilities_unittest.cc
src/lib/yang/translator_pool.cc

index fb2ff366c6b329638fb8c289441b2ab7d8836c5f..62a59a565bb9fc7d78a92ce643a5710e889c1863 100644 (file)
@@ -45,8 +45,7 @@ const uint8_t revMask6[]= { 0xff, 0x7f, 0x3f, 0x1f, 0xf, 0x7, 0x3, 0x1 };
 ///
 /// @param prefix IPv6 prefix
 /// @param len prefix length
-isc::asiolink::IOAddress firstAddrInPrefix6(const isc::asiolink::IOAddress& prefix,
-                                            uint8_t len) {
+IOAddress firstAddrInPrefix6(const IOAddress& prefix, uint8_t len) {
     if (len > 128) {
         isc_throw(isc::BadValue,
                   "Too large netmask. 0..128 is allowed in IPv6");
@@ -82,7 +81,7 @@ isc::asiolink::IOAddress firstAddrInPrefix6(const isc::asiolink::IOAddress& pref
     }
 
     // Finally, let's wrap this into nice and easy IOAddress object.
-    return (isc::asiolink::IOAddress::fromBytes(AF_INET6, packed));
+    return (IOAddress::fromBytes(AF_INET6, packed));
 }
 
 /// @brief calculates the first IPv4 address in a IPv4 prefix
@@ -92,8 +91,7 @@ isc::asiolink::IOAddress firstAddrInPrefix6(const isc::asiolink::IOAddress& pref
 ///
 /// @param prefix IPv4 prefix
 /// @param len netmask length (0-32)
-isc::asiolink::IOAddress firstAddrInPrefix4(const isc::asiolink::IOAddress& prefix,
-                                            uint8_t len) {
+IOAddress firstAddrInPrefix4(const IOAddress& prefix, uint8_t len) {
     if (len > 32) {
         isc_throw(isc::BadValue, "Too large netmask. 0..32 is allowed in IPv4");
     }
@@ -112,8 +110,7 @@ isc::asiolink::IOAddress firstAddrInPrefix4(const isc::asiolink::IOAddress& pref
 ///
 /// @param prefix IPv4 prefix that we calculate first address for
 /// @param len netmask length (0-32)
-isc::asiolink::IOAddress lastAddrInPrefix4(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len) {
+IOAddress lastAddrInPrefix4(const IOAddress& prefix, uint8_t len) {
     if (len > 32) {
         isc_throw(isc::BadValue, "Too large netmask. 0..32 is allowed in IPv4");
     }
@@ -129,8 +126,7 @@ isc::asiolink::IOAddress lastAddrInPrefix4(const isc::asiolink::IOAddress& prefi
 ///
 /// @param prefix IPv6 prefix that we calculate first address for
 /// @param len netmask length (0-128)
-isc::asiolink::IOAddress lastAddrInPrefix6(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len) {
+IOAddress lastAddrInPrefix6(const IOAddress& prefix, uint8_t len) {
     if (len > 128) {
         isc_throw(isc::BadValue,
                   "Too large netmask. 0..128 is allowed in IPv6");
@@ -165,16 +161,15 @@ isc::asiolink::IOAddress lastAddrInPrefix6(const isc::asiolink::IOAddress& prefi
     }
 
     // Finally, let's wrap this into nice and easy IOAddress object.
-    return (isc::asiolink::IOAddress::fromBytes(AF_INET6, packed));
+    return (IOAddress::fromBytes(AF_INET6, packed));
 }
 
 }; // end of anonymous namespace
 
 namespace isc {
-namespace dhcp {
+namespace asiolink {
 
-isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len) {
+IOAddress firstAddrInPrefix(const IOAddress& prefix, uint8_t len) {
     if (prefix.isV4()) {
         return (firstAddrInPrefix4(prefix, len));
 
@@ -184,8 +179,7 @@ isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefi
     }
 }
 
-isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len) {
+IOAddress lastAddrInPrefix(const IOAddress& prefix, uint8_t len) {
     if (prefix.isV4()) {
         return (lastAddrInPrefix4(prefix, len));
 
@@ -195,10 +189,10 @@ isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix
     }
 }
 
-isc::asiolink::IOAddress getNetmask4(uint8_t len) {
+IOAddress getNetmask4(uint8_t len) {
     if (len > 32) {
-      isc_throw(BadValue, "Invalid netmask size "
-                << static_cast<unsigned>(len) << ", allowed range is 0..32");
+        isc_throw(BadValue, "Invalid netmask size "
+                  << static_cast<unsigned>(len) << ", allowed range is 0..32");
     }
     uint32_t x = ~bitMask4[len];
 
@@ -206,8 +200,7 @@ isc::asiolink::IOAddress getNetmask4(uint8_t len) {
 }
 
 uint64_t
-addrsInRange(const isc::asiolink::IOAddress& min,
-             const isc::asiolink::IOAddress& max) {
+addrsInRange(const IOAddress& min, const IOAddress& max) {
     if (min.getFamily() != max.getFamily()) {
         isc_throw(BadValue, "Both addresses have to be the same family");
     }
@@ -277,8 +270,7 @@ addrsInRange(const isc::asiolink::IOAddress& min,
 }
 
 int
-prefixLengthFromRange(const isc::asiolink::IOAddress& min,
-                      const isc::asiolink::IOAddress& max) {
+prefixLengthFromRange(const IOAddress& min, const IOAddress& max) {
     if (min.getFamily() != max.getFamily()) {
         isc_throw(BadValue, "Both addresses have to be the same family");
     }
index c2a44d5aea2f76435186abb32b59757898d2816b..a461bd119acdbc210fcbdb4576127d9cbcccf444 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -10,7 +10,7 @@
 #include <asiolink/io_address.h>
 
 namespace isc {
-namespace dhcp {
+namespace asiolink {
 
 /// This code is based on similar code from the Dibbler project. I, Tomasz Mrugalski,
 /// as a sole creator of that code hereby release it under BSD license for the benefit
@@ -25,8 +25,7 @@ namespace dhcp {
 /// @param len prefix length
 ///
 /// @return first address from a prefix
-isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                            uint8_t len);
+IOAddress firstAddrInPrefix(const IOAddress& prefix, uint8_t len);
 
 /// @brief returns a last address in a given prefix
 ///
@@ -37,13 +36,12 @@ isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefi
 /// @param len prefix length
 ///
 /// @return first address from a prefix
-isc::asiolink::IOAddress lastAddrInPrefix(const isc::asiolink::IOAddress& prefix,
-                                           uint8_t len);
+IOAddress lastAddrInPrefix(const IOAddress& prefix, uint8_t len);
 
 /// @brief Generates an IPv4 netmask of specified length
 /// @throw BadValue if len is greater than 32
 /// @return netmask
-isc::asiolink::IOAddress getNetmask4(uint8_t len);
+IOAddress getNetmask4(uint8_t len);
 
 
 /// @brief Returns number of available addresses in the specified range (min - max).
@@ -56,8 +54,7 @@ isc::asiolink::IOAddress getNetmask4(uint8_t len);
 /// @param min the first address in range
 /// @param max the last address in range
 /// @return number of addresses in range
-uint64_t addrsInRange(const isc::asiolink::IOAddress& min,
-                      const isc::asiolink::IOAddress& max);
+uint64_t addrsInRange(const IOAddress& min, const IOAddress& max);
 
 /// @brief Returns prefix length from the specified range (min - max).
 ///
@@ -68,8 +65,7 @@ uint64_t addrsInRange(const isc::asiolink::IOAddress& min,
 /// @param min the first address in range
 /// @param max the last address in range
 /// @return the prefix length or -1 if the range is not from a prefix
-int prefixLengthFromRange(const isc::asiolink::IOAddress& min,
-                          const isc::asiolink::IOAddress& max);
+int prefixLengthFromRange(const IOAddress& min, const IOAddress& max);
 
 /// @brief Returns number of available IPv6 prefixes in the specified prefix.
 ///
index 200e35f2d8555d24bb0b033b1539596340938cc6..53279a4c7f5146273eaf1282f7c678305e090705 100644 (file)
@@ -17,7 +17,6 @@
 #include <stdlib.h>
 
 using namespace std;
-using namespace isc::dhcp;
 using namespace isc::asiolink;
 
 namespace {
index efcd2dcee23acd92cbfae28a545e87da8c234597..320bfddadad14b20c9bc92c1be282c808aeea217 100644 (file)
@@ -17,7 +17,6 @@
 using namespace std;
 using namespace isc::data;
 using namespace isc::asiolink;
-using namespace isc::dhcp;
 #ifndef HAVE_PRE_0_7_6_SYSREPO
 using namespace sysrepo;
 #endif