mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 21:14:28 +01:00
Added IPv4Address, IPv6Address and HWAddress<> 'is_multicast' member function.
This commit is contained in:
@@ -43,6 +43,7 @@ const AddressRange<IPv4Address> private_ranges[] = {
|
||||
};
|
||||
|
||||
const AddressRange<IPv4Address> loopback_range = IPv4Address("127.0.0.0") / 8;
|
||||
const AddressRange<IPv4Address> multicast_range = IPv4Address("224.0.0.0") / 4;
|
||||
|
||||
IPv4Address::IPv4Address(uint32_t ip)
|
||||
: ip_addr(Endian::be_to_host(ip)) {
|
||||
@@ -118,6 +119,10 @@ bool IPv4Address::is_loopback() const {
|
||||
return loopback_range.contains(*this);
|
||||
}
|
||||
|
||||
bool IPv4Address::is_multicast() const {
|
||||
return multicast_range.contains(*this);
|
||||
}
|
||||
|
||||
AddressRange<IPv4Address> operator/(const IPv4Address &addr, int mask) {
|
||||
if(mask > 32)
|
||||
throw std::logic_error("Prefix length cannot exceed 32");
|
||||
|
||||
Reference in New Issue
Block a user