///
/// @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");
}
// 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
///
/// @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");
}
///
/// @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");
}
///
/// @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");
}
// 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));
}
}
-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));
}
}
-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];
}
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");
}
}
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");
}
-// 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
#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
/// @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
///
/// @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).
/// @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).
///
/// @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.
///