mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8255264: Support for identifying the full range of IPv4 localhost addresses on Windows
Reviewed-by: alanb
This commit is contained in:
parent
8a05d60532
commit
7e01bc967d
1 changed files with 17 additions and 11 deletions
|
@ -90,24 +90,30 @@ struct ipv6bind {
|
|||
/**
|
||||
* With dual socket implementation the
|
||||
* IPv4 addresseses might be mapped as IPv6.
|
||||
* The IPv4 loopback adapter address will
|
||||
* be mapped as the following IPv6 ::ffff:127.0.0.1.
|
||||
* The IPv4 loopback adapter address ranges (127.0.0.0 through 127.255.255.255) will
|
||||
* be mapped as the following IPv6 ::ffff:127.0.0.0 through ::ffff:127.255.255.255.
|
||||
* For example, this is done by NET_InetAddressToSockaddr.
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4MAPPED_LOOPBACK(x) ( \
|
||||
(((x)->s6_words[0] == 0) && \
|
||||
((x)->s6_words[1] == 0) && \
|
||||
((x)->s6_words[2] == 0) && \
|
||||
((x)->s6_words[3] == 0) && \
|
||||
((x)->s6_words[4] == 0) && \
|
||||
((x)->s6_words[5] == 0xFFFF) && \
|
||||
((x)->s6_words[6] == 0x007F) && \
|
||||
((x)->s6_words[7] == 0x0100)) \
|
||||
(((x)->s6_words[0] == 0) && \
|
||||
((x)->s6_words[1] == 0) && \
|
||||
((x)->s6_words[2] == 0) && \
|
||||
((x)->s6_words[3] == 0) && \
|
||||
((x)->s6_words[4] == 0) && \
|
||||
((x)->s6_words[5] == 0xFFFF) && \
|
||||
(((x)->s6_words[6] & 0x00FF) == 0x007F)) \
|
||||
)
|
||||
|
||||
/**
|
||||
* Check for IPv4 loopback adapter address ranges (127.0.0.0 through 127.255.255.255)
|
||||
*/
|
||||
#define IN4_IS_ADDR_NETLONG_LOOPBACK(l) ( \
|
||||
((l & 0xFF000000) == 0x7F000000) \
|
||||
)
|
||||
|
||||
#define IS_LOOPBACK_ADDRESS(x) ( \
|
||||
((x)->sa.sa_family == AF_INET) ? \
|
||||
(ntohl((x)->sa4.sin_addr.s_addr) == INADDR_LOOPBACK) : \
|
||||
(IN4_IS_ADDR_NETLONG_LOOPBACK(ntohl((x)->sa4.sin_addr.s_addr))) : \
|
||||
((IN6_IS_ADDR_LOOPBACK(&(x)->sa6.sin6_addr)) || \
|
||||
(IN6_IS_ADDR_V4MAPPED_LOOPBACK(&(x)->sa6.sin6_addr))) \
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue