diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/network/kernel/qhostaddress.cpp | 16 | ||||
| -rw-r--r-- | src/network/kernel/qhostaddress.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 3d51ab40255..579567023e5 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -1090,6 +1090,22 @@ bool QHostAddress::isLoopback() const return false; } +/*! + \since 5.6 + + Returns \c true if the address is an IPv4 or IPv6 multicast address, \c + false otherwise. +*/ +bool QHostAddress::isMulticast() const +{ + QT_ENSURE_PARSED(this); + if ((d->a & 0xF0000000) == 0xE0000000) + return true; // 224.0.0.0-239.255.255.255 (including v4-mapped IPv6 addresses) + if (d->protocol == QAbstractSocket::IPv6Protocol) + return d->a6.c[0] == 0xff; + return false; +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const QHostAddress &address) { diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 8478240d286..cea54a2984f 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -124,6 +124,7 @@ public: bool isInSubnet(const QPair<QHostAddress, int> &subnet) const; bool isLoopback() const; + bool isMulticast() const; static QPair<QHostAddress, int> parseSubnet(const QString &subnet); |
