1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 12:14:26 +01:00

Add IPv4Address::from_prefix_length

This commit is contained in:
Matias Fontanini
2016-03-19 16:26:00 -07:00
parent 3773443fc8
commit a70ce10bed
3 changed files with 14 additions and 6 deletions

View File

@@ -54,7 +54,11 @@ 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::from_prefix_length(uint32_t prefix_length) {
return IPv4Address(Endian::host_to_be(0xffffffff << (32 - prefix_length)));
}
IPv4Address::IPv4Address(uint32_t ip)
: ip_addr_(Endian::be_to_host(ip)) {