1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 21:14:28 +01:00

Added address_range.cpp.

This commit is contained in:
Matias Fontanini
2013-09-21 01:21:15 -03:00
parent 54d012b92e
commit 74ef177e25
12 changed files with 424 additions and 314 deletions

View File

@@ -108,19 +108,5 @@ bool IPv6Address::is_loopback() const {
bool IPv6Address::is_multicast() const {
return multicast_range.contains(*this);
}
AddressRange<IPv6Address> operator/(const IPv6Address &addr, int mask) {
if(mask > 128)
throw std::logic_error("Prefix length cannot exceed 128");
IPv6Address last_addr;
IPv6Address::iterator it = last_addr.begin();
while(mask > 8) {
*it = 0xff;
++it;
mask -= 8;
}
*it = 0xff << (8 - mask);
return AddressRange<IPv6Address>::from_mask(addr, last_addr);
}
}