mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-11 17:29:16 +05:00
tpws: is_localnet: convert network byte order
This commit is contained in:
parent
ef7cbc1ec9
commit
93aa69ff7b
@ -167,12 +167,12 @@ bool saconvmapped(struct sockaddr_storage *a)
|
||||
bool is_localnet(const struct sockaddr *a)
|
||||
{
|
||||
// match 127.0.0.0/8, 0.0.0.0, ::1, ::0, :ffff:127.0.0.0/104, :ffff:0.0.0.0
|
||||
return (a->sa_family==AF_INET && (IN_LOOPBACK(htonl(((struct sockaddr_in *)a)->sin_addr.s_addr)) ||
|
||||
INADDR_ANY == (((struct sockaddr_in *)a)->sin_addr.s_addr))) ||
|
||||
return (a->sa_family==AF_INET && (IN_LOOPBACK(ntohl(((struct sockaddr_in *)a)->sin_addr.s_addr)) ||
|
||||
INADDR_ANY == ntohl((((struct sockaddr_in *)a)->sin_addr.s_addr)))) ||
|
||||
(a->sa_family==AF_INET6 && (IN6_IS_ADDR_LOOPBACK(((struct sockaddr_in6 *)a)->sin6_addr.s6_addr) ||
|
||||
IN6_IS_ADDR_UNSPECIFIED(((struct sockaddr_in6 *)a)->sin6_addr.s6_addr) ||
|
||||
(IN6_IS_ADDR_V4MAPPED(((struct sockaddr_in6 *)a)->sin6_addr.s6_addr) && (IN_LOOPBACK(htonl(IN6_EXTRACT_MAP4(((struct sockaddr_in6*)a)->sin6_addr.s6_addr))) ||
|
||||
INADDR_ANY == IN6_EXTRACT_MAP4(((struct sockaddr_in6*)a)->sin6_addr.s6_addr)))));
|
||||
(IN6_IS_ADDR_V4MAPPED(((struct sockaddr_in6 *)a)->sin6_addr.s6_addr) && (IN_LOOPBACK(ntohl(IN6_EXTRACT_MAP4(((struct sockaddr_in6*)a)->sin6_addr.s6_addr))) ||
|
||||
INADDR_ANY == ntohl(IN6_EXTRACT_MAP4(((struct sockaddr_in6*)a)->sin6_addr.s6_addr))))));
|
||||
}
|
||||
bool is_linklocal(const struct sockaddr_in6 *a)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user