sameAddr(), isPrivate()

pull/3/head
Ryan Tharp 6 years ago
parent 07f0653e83
commit 9636beaeeb

@ -192,11 +192,27 @@ namespace llarp
&& port() == other.port();
}
bool
sameAddr(const Addr& other) const
{
return memcmp(addr6(), other.addr6(), 16) == 0;
}
bool
operator!=(const Addr& other) const
{
return !(*this == other);
}
bool isPrivate()
{
in_addr_t addr = this->addr4()->s_addr;
unsigned byte = ntohl(addr);
unsigned byte1 = byte >> 24 & 0xff;
unsigned byte2 = byte >> 16 & 0xff;
return (byte1 == 10 || (byte1 == 192 && byte2 == 168) || (byte1 == 172 && (byte2 & 0xf0) == 16));
}
};
struct addrhash

Loading…
Cancel
Save