From: Francis Dupont Date: Tue, 4 Jun 2019 14:29:08 +0000 (+0200) Subject: [551-wrong-namespace-for-address-utilities] Moved address utils to isc::asiolink... X-Git-Tag: Kea-1.6.0-beta2~224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65021b840b94da3d118e541fba5469c8ed15175b;p=thirdparty%2Fkea.git [551-wrong-namespace-for-address-utilities] Moved address utils to isc::asiolink namespace --- diff --git a/src/lib/asiolink/addr_utilities.cc b/src/lib/asiolink/addr_utilities.cc index fb2ff366c6..62a59a565b 100644 --- a/src/lib/asiolink/addr_utilities.cc +++ b/src/lib/asiolink/addr_utilities.cc @@ -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(len) << ", allowed range is 0..32"); + isc_throw(BadValue, "Invalid netmask size " + << static_cast(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"); } diff --git a/src/lib/asiolink/addr_utilities.h b/src/lib/asiolink/addr_utilities.h index c2a44d5aea..a461bd119a 100644 --- a/src/lib/asiolink/addr_utilities.h +++ b/src/lib/asiolink/addr_utilities.h @@ -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 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. /// diff --git a/src/lib/asiolink/tests/addr_utilities_unittest.cc b/src/lib/asiolink/tests/addr_utilities_unittest.cc index 200e35f2d8..53279a4c7f 100644 --- a/src/lib/asiolink/tests/addr_utilities_unittest.cc +++ b/src/lib/asiolink/tests/addr_utilities_unittest.cc @@ -17,7 +17,6 @@ #include using namespace std; -using namespace isc::dhcp; using namespace isc::asiolink; namespace { diff --git a/src/lib/yang/translator_pool.cc b/src/lib/yang/translator_pool.cc index efcd2dcee2..320bfddada 100644 --- a/src/lib/yang/translator_pool.cc +++ b/src/lib/yang/translator_pool.cc @@ -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