Fix some syntax issues in SCTP implementation
Change-Id: I718fd060e313d544a5470fa20183db04ef89b1ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
c0637c0298
commit
733c4de36e
@ -37,8 +37,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Sample program for configure to test for SCTP sockets support
|
/*
|
||||||
on target platforms. */
|
Sample program for configure to test for SCTP sockets support
|
||||||
|
on target platforms.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
@ -288,7 +288,8 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
|
|||||||
QHash<QString, QNetworkProxy> taggedProxies;
|
QHash<QString, QNetworkProxy> taggedProxies;
|
||||||
const QString requiredTag = query.protocolTag();
|
const QString requiredTag = query.protocolTag();
|
||||||
// windows tags are only for clients
|
// windows tags are only for clients
|
||||||
bool checkTags = !requiredTag.isEmpty() && query.queryType() != QNetworkProxyQuery::TcpServer
|
bool checkTags = !requiredTag.isEmpty()
|
||||||
|
&& query.queryType() != QNetworkProxyQuery::TcpServer
|
||||||
&& query.queryType() != QNetworkProxyQuery::SctpServer;
|
&& query.queryType() != QNetworkProxyQuery::SctpServer;
|
||||||
for (const QString &entry : proxyList) {
|
for (const QString &entry : proxyList) {
|
||||||
int server = 0;
|
int server = 0;
|
||||||
|
@ -915,7 +915,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
|
|||||||
|
|
||||||
if (recvResult == -1) {
|
if (recvResult == -1) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#if EWOULDBLOCK-0 && EWOULDBLOCK != EAGAIN
|
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#endif
|
#endif
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
@ -1105,7 +1105,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
|
|||||||
|
|
||||||
if (sentBytes < 0) {
|
if (sentBytes < 0) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#if EWOULDBLOCK-0 && EWOULDBLOCK != EAGAIN
|
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
#endif
|
#endif
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
|
@ -162,8 +162,12 @@ bool QSctpSocketPrivate::canReadNotification()
|
|||||||
do {
|
do {
|
||||||
// Determine the size of the pending datagram.
|
// Determine the size of the pending datagram.
|
||||||
qint64 bytesToRead = socketEngine->bytesAvailable();
|
qint64 bytesToRead = socketEngine->bytesAvailable();
|
||||||
if (bytesToRead == 0)
|
if (bytesToRead == 0) {
|
||||||
|
// As a corner case, if we can't determine the size of the pending datagram,
|
||||||
|
// try to read 4K of data from the socket. Subsequent ::recvmsg call either
|
||||||
|
// fails or returns the actual length of the datagram.
|
||||||
bytesToRead = 4096;
|
bytesToRead = 4096;
|
||||||
|
}
|
||||||
|
|
||||||
Q_ASSERT((datagramSize + int(bytesToRead)) < MaxByteArraySize);
|
Q_ASSERT((datagramSize + int(bytesToRead)) < MaxByteArraySize);
|
||||||
incomingDatagram.resize(datagramSize + int(bytesToRead));
|
incomingDatagram.resize(datagramSize + int(bytesToRead));
|
||||||
@ -479,7 +483,7 @@ QNetworkDatagram QSctpSocket::readDatagram()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d->currentReadChannel >= d->readHeaders.size()
|
if (d->currentReadChannel >= d->readHeaders.size()
|
||||||
|| (d->readHeaders[d->currentReadChannel].size() == 0)) {
|
|| d->readHeaders[d->currentReadChannel].size() == 0) {
|
||||||
Q_ASSERT(d->buffer.isEmpty());
|
Q_ASSERT(d->buffer.isEmpty());
|
||||||
return QNetworkDatagram();
|
return QNetworkDatagram();
|
||||||
}
|
}
|
||||||
|
@ -118,13 +118,13 @@ void tst_QSctpSocket::constructing()
|
|||||||
|
|
||||||
char c;
|
char c;
|
||||||
QCOMPARE(socket.getChar(&c), false);
|
QCOMPARE(socket.getChar(&c), false);
|
||||||
QCOMPARE((int) socket.bytesAvailable(), 0);
|
QCOMPARE(socket.bytesAvailable(), Q_INT64_C(0));
|
||||||
QCOMPARE(socket.canReadLine(), false);
|
QCOMPARE(socket.canReadLine(), false);
|
||||||
QCOMPARE(socket.readLine(), QByteArray());
|
QCOMPARE(socket.readLine(), QByteArray());
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
QCOMPARE(socket.socketDescriptor(), qintptr(-1));
|
||||||
QCOMPARE((int) socket.localPort(), 0);
|
QCOMPARE(int(socket.localPort()), 0);
|
||||||
QVERIFY(socket.localAddress() == QHostAddress());
|
QVERIFY(socket.localAddress() == QHostAddress());
|
||||||
QCOMPARE((int) socket.peerPort(), 0);
|
QCOMPARE(int(socket.peerPort()), 0);
|
||||||
QVERIFY(socket.peerAddress() == QHostAddress());
|
QVERIFY(socket.peerAddress() == QHostAddress());
|
||||||
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
|
||||||
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
||||||
@ -139,11 +139,11 @@ void tst_QSctpSocket::bind_data()
|
|||||||
|
|
||||||
// iterate all interfaces, add all addresses on them as test data
|
// iterate all interfaces, add all addresses on them as test data
|
||||||
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
|
||||||
foreach (const QNetworkInterface &interface, interfaces) {
|
for (const QNetworkInterface &interface : interfaces) {
|
||||||
if (!interface.isValid())
|
if (!interface.isValid())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (const QNetworkAddressEntry &entry, interface.addressEntries()) {
|
for (const QNetworkAddressEntry &entry : interface.addressEntries()) {
|
||||||
if (entry.ip().isInSubnet(QHostAddress::parseSubnet("fe80::/10"))
|
if (entry.ip().isInSubnet(QHostAddress::parseSubnet("fe80::/10"))
|
||||||
|| entry.ip().isInSubnet(QHostAddress::parseSubnet("169.254/16")))
|
|| entry.ip().isInSubnet(QHostAddress::parseSubnet("169.254/16")))
|
||||||
continue; // link-local bind will fail, at least on Linux, so skip it.
|
continue; // link-local bind will fail, at least on Linux, so skip it.
|
||||||
@ -178,11 +178,10 @@ void tst_QSctpSocket::bind()
|
|||||||
QSctpSocket socket;
|
QSctpSocket socket;
|
||||||
qDebug() << "Binding " << addr;
|
qDebug() << "Binding " << addr;
|
||||||
|
|
||||||
if (successExpected) {
|
if (successExpected)
|
||||||
QVERIFY2(socket.bind(addr), qPrintable(socket.errorString()));
|
QVERIFY2(socket.bind(addr), qPrintable(socket.errorString()));
|
||||||
} else {
|
else
|
||||||
QVERIFY(!socket.bind(addr));
|
QVERIFY(!socket.bind(addr));
|
||||||
}
|
|
||||||
|
|
||||||
QCOMPARE(socket.localAddress(), expectedLocalAddress);
|
QCOMPARE(socket.localAddress(), expectedLocalAddress);
|
||||||
}
|
}
|
||||||
@ -191,9 +190,9 @@ void tst_QSctpSocket::bind()
|
|||||||
void tst_QSctpSocket::setInvalidSocketDescriptor()
|
void tst_QSctpSocket::setInvalidSocketDescriptor()
|
||||||
{
|
{
|
||||||
QSctpSocket socket;
|
QSctpSocket socket;
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)INVALID_SOCKET);
|
QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET));
|
||||||
QVERIFY(!socket.setSocketDescriptor(-5, QAbstractSocket::UnconnectedState));
|
QVERIFY(!socket.setSocketDescriptor(-5, QAbstractSocket::UnconnectedState));
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)INVALID_SOCKET);
|
QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET));
|
||||||
|
|
||||||
QCOMPARE(socket.error(), QAbstractSocket::UnsupportedSocketOperationError);
|
QCOMPARE(socket.error(), QAbstractSocket::UnsupportedSocketOperationError);
|
||||||
}
|
}
|
||||||
@ -211,7 +210,7 @@ void tst_QSctpSocket::setSocketDescriptor()
|
|||||||
QVERIFY(sock != INVALID_SOCKET);
|
QVERIFY(sock != INVALID_SOCKET);
|
||||||
QSctpSocket socket;
|
QSctpSocket socket;
|
||||||
QVERIFY(socket.setSocketDescriptor(sock, QAbstractSocket::UnconnectedState));
|
QVERIFY(socket.setSocketDescriptor(sock, QAbstractSocket::UnconnectedState));
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)sock);
|
QCOMPARE(socket.socketDescriptor(), qintptr(sock));
|
||||||
QCOMPARE(socket.readChannelCount(), 0);
|
QCOMPARE(socket.readChannelCount(), 0);
|
||||||
QCOMPARE(socket.writeChannelCount(), 0);
|
QCOMPARE(socket.writeChannelCount(), 0);
|
||||||
|
|
||||||
@ -237,7 +236,7 @@ void tst_QSctpSocket::socketDescriptor()
|
|||||||
|
|
||||||
QVERIFY(server.listen());
|
QVERIFY(server.listen());
|
||||||
|
|
||||||
QCOMPARE(socket.socketDescriptor(), (qintptr)INVALID_SOCKET);
|
QCOMPARE(socket.socketDescriptor(), qintptr(INVALID_SOCKET));
|
||||||
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
|
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
|
||||||
QVERIFY(server.waitForNewConnection(3000));
|
QVERIFY(server.waitForNewConnection(3000));
|
||||||
if (socket.state() != QAbstractSocket::ConnectedState) {
|
if (socket.state() != QAbstractSocket::ConnectedState) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user