rippled
Loading...
Searching...
No Matches
IPAddressV4.cpp
1#include <xrpl/beast/net/IPAddressV4.h>
2
3namespace beast {
4namespace IP {
5
6bool
7is_private(AddressV4 const& addr)
8{
9 return ((addr.to_uint() & 0xff000000) == 0x0a000000) || // Prefix /8, 10. #.#.#
10 ((addr.to_uint() & 0xfff00000) == 0xac100000) || // Prefix /12 172. 16.#.# - 172.31.#.#
11 ((addr.to_uint() & 0xffff0000) == 0xc0a80000) || // Prefix /16 192.168.#.#
12 addr.is_loopback();
13}
14
15bool
16is_public(AddressV4 const& addr)
17{
18 return !is_private(addr) && !addr.is_multicast();
19}
20
21char
22get_class(AddressV4 const& addr)
23{
24 static char const* table = "AAAABBCD"; // cspell:disable-line
25 return table[(addr.to_uint() & 0xE0000000) >> 29];
26}
27
28} // namespace IP
29} // namespace beast
char get_class(AddressV4 const &address)
Returns the address class for the given address.
bool is_public(Address const &addr)
Returns true if the address is a public routable address.
Definition IPAddress.h:58
boost::asio::ip::address_v4 AddressV4
Definition IPAddressV4.h:10
bool is_private(Address const &addr)
Returns true if the address is a private unroutable address.
Definition IPAddress.h:51