MCPcopy Create free account
hub / github.com/apache/trafficserver / ats_is_ip_private

Function ats_is_ip_private

include/tscore/ink_inet.h:737–754  ·  view source on GitHub ↗

Check for Private. @return @true if @a ip is private.

Source from the content-addressed store, hash-verified

735/// Check for Private.
736/// @return @true if @a ip is private.
737inline bool
738ats_is_ip_private(sockaddr const *ip)
739{
740 bool zret = false;
741 if (ats_is_ip4(ip)) {
742 in_addr_t a = ats_ip4_addr_cast(ip);
743 zret = ((a & htonl(0xFF000000)) == htonl(0x0A000000)) || // 10.0.0.0/8
744 ((a & htonl(0xFFC00000)) == htonl(0x64400000)) || // 100.64.0.0/10
745 ((a & htonl(0xFFF00000)) == htonl(0xAC100000)) || // 172.16.0.0/12
746 ((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)) // 192.168.0.0/16
747 ;
748 } else if (ats_is_ip6(ip)) {
749 in6_addr a = ats_ip6_addr_cast(ip);
750 zret = ((a.s6_addr[0] & 0xFE) == 0xFC) // fc00::/7
751 ;
752 }
753 return zret;
754}
755
756/// Check for Private.
757/// @return @true if @a ip is private.

Callers 2

MachineMethod · 0.85
ats_ip_getbestaddrinfoFunction · 0.85

Calls 2

ats_is_ip4Function · 0.85
ats_is_ip6Function · 0.85

Tested by

no test coverage detected