summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp69
1 files changed, 17 insertions, 52 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 4fa4a55..8416ed2 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -586,79 +586,50 @@ int QNativeSocketEnginePrivate::nativeAccept()
return acceptedDescriptor;
}
-#if !defined(IP_ADD_SOURCE_MEMBERSHIP)
-# define QT_NO_MULTICAST_SSM
-# define IP_ADD_SOURCE_MEMBERSHIP -1
-# define IP_DROP_SOURCE_MEMBERSHIP -1
-#endif
static bool doMulticast(QNativeSocketEnginePrivate *d,
- int howAsm6,
- int howAsm4,
- int howSsm4,
+ int how6,
+ int how4,
const QHostAddress &groupAddress,
- const QHostAddress &sourceAddress,
const QNetworkInterface &interface)
{
- Q_UNUSED(howSsm4);
-
int sockOpt = 0;
void *sockArg;
int sockArgSize;
- ip_mreq asm4;
-#ifndef QT_NO_MULTICAST_SSM
- ip_mreq_source ssm4;
-#endif
+ ip_mreq mreq4;
#ifndef QT_NO_IPV6
- ipv6_mreq asm6;
+ ipv6_mreq mreq6;
if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
- sockOpt = howAsm6;
- sockArg = &asm6;
- sockArgSize = sizeof(asm6);
- memset(&asm6, 0, sizeof(asm6));
+ sockOpt = how6;
+ sockArg = &mreq6;
+ sockArgSize = sizeof(mreq6);
+ memset(&mreq6, 0, sizeof(mreq6));
Q_IPV6ADDR ip6 = groupAddress.toIPv6Address();
- memcpy(&asm6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
- Q_UNUSED(sourceAddress); // ### not possible to specify a single source when using IPv6?
- asm6.ipv6mr_interface = interface.index();
+ memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
+ mreq6.ipv6mr_interface = interface.index();
} else
#endif
if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
- if (sourceAddress != QHostAddress::Any) {
-#ifndef QT_NO_MULTICAST_SSM
- sockOpt = howSsm4;
- sockArg = &ssm4;
- sockArgSize = sizeof(ssm4);
- memset(&ssm4, 0, sizeof(ssm4));
- ssm4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
- ssm4.imr_sourceaddr.s_addr = htonl(sourceAddress.toIPv4Address());
-#else
- // system doesn't support SSM
- d->setError(QAbstractSocket::UnsupportedSocketOperationError,
- QNativeSocketEnginePrivate::OperationUnsupportedErrorString);
- return false;
-#endif
- } else {
- sockOpt = howAsm4;
- sockArg = &asm4;
- sockArgSize = sizeof(asm4);
- memset(&asm4, 0, sizeof(asm4));
- asm4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
- }
+ sockOpt = how4;
+ sockArg = &mreq4;
+ sockArgSize = sizeof(mreq4);
+ memset(&mreq4, 0, sizeof(mreq4));
+ mreq4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
if (interface.isValid()) {
QList<QNetworkAddressEntry> addressEntries = interface.addressEntries();
if (!addressEntries.isEmpty()) {
QHostAddress firstIP = addressEntries.first().ip();
- asm4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
+ mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
} else {
d->setError(QAbstractSocket::NetworkError,
QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
return false;
}
} else {
- asm4.imr_interface.s_addr = INADDR_ANY;
+ mreq4.imr_interface.s_addr = INADDR_ANY;
}
} else {
// unreachable
@@ -685,7 +656,6 @@ static bool doMulticast(QNativeSocketEnginePrivate *d,
}
bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &groupAddress,
- const QHostAddress &sourceAddress,
const QNetworkInterface &interface)
{
return doMulticast(this,
@@ -695,14 +665,11 @@ bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &gr
0,
#endif
IP_ADD_MEMBERSHIP,
- IP_ADD_SOURCE_MEMBERSHIP,
groupAddress,
- sourceAddress,
interface);
}
bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &groupAddress,
- const QHostAddress &sourceAddress,
const QNetworkInterface &interface)
{
return doMulticast(this,
@@ -712,9 +679,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
0,
#endif
IP_DROP_MEMBERSHIP,
- IP_DROP_SOURCE_MEMBERSHIP,
groupAddress,
- sourceAddress,
interface);
}