mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
fix(IPAddress): IPAddress::isLoopback() returns false for IPv4 mapped in IPv6 #3399
This commit is contained in:
parent
fd75336a98
commit
5bac3e303f
@ -564,6 +564,9 @@ bool IPv6AddressImpl::isBroadcast() const
|
||||
|
||||
bool IPv6AddressImpl::isLoopback() const
|
||||
{
|
||||
if (isIPv4Mapped())
|
||||
return (ByteOrder::fromNetwork(_addr.s6_addr[6]) & 0xFF000000) == 0x7F000000;
|
||||
|
||||
const UInt16* words = reinterpret_cast<const UInt16*>(&_addr);
|
||||
return words[0] == 0 && words[1] == 0 && words[2] == 0 && words[3] == 0 &&
|
||||
words[4] == 0 && words[5] == 0 && words[6] == 0 && ByteOrder::fromNetwork(words[7]) == 0x0001;
|
||||
|
@ -453,6 +453,36 @@ void IPAddressTest::testClassification6()
|
||||
assertTrue (!ip7.isSiteLocalMC());
|
||||
assertTrue (!ip7.isOrgLocalMC());
|
||||
assertTrue (!ip7.isGlobalMC());
|
||||
|
||||
IPAddress ip8("::ffff:127.0.0.1"); // IPv4-mapped loopback
|
||||
assertTrue (!ip3.isWildcard());
|
||||
assertTrue (!ip3.isBroadcast());
|
||||
assertTrue (ip3.isLoopback());
|
||||
assertTrue (!ip3.isMulticast());
|
||||
assertTrue (ip3.isUnicast());
|
||||
assertTrue (!ip3.isLinkLocal());
|
||||
assertTrue (!ip3.isSiteLocal());
|
||||
assertTrue (!ip3.isWellKnownMC());
|
||||
assertTrue (!ip3.isNodeLocalMC());
|
||||
assertTrue (!ip3.isLinkLocalMC());
|
||||
assertTrue (!ip3.isSiteLocalMC());
|
||||
assertTrue (!ip3.isOrgLocalMC());
|
||||
assertTrue (!ip3.isGlobalMC());
|
||||
|
||||
IPAddress ip9("::ffff:127.255.255.254"); // IPv4-mapped loopback
|
||||
assertTrue (!ip3.isWildcard());
|
||||
assertTrue (!ip3.isBroadcast());
|
||||
assertTrue (ip3.isLoopback());
|
||||
assertTrue (!ip3.isMulticast());
|
||||
assertTrue (ip3.isUnicast());
|
||||
assertTrue (!ip3.isLinkLocal());
|
||||
assertTrue (!ip3.isSiteLocal());
|
||||
assertTrue (!ip3.isWellKnownMC());
|
||||
assertTrue (!ip3.isNodeLocalMC());
|
||||
assertTrue (!ip3.isLinkLocalMC());
|
||||
assertTrue (!ip3.isSiteLocalMC());
|
||||
assertTrue (!ip3.isOrgLocalMC());
|
||||
assertTrue (!ip3.isGlobalMC());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user