diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-02-11 12:41:31 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-02-14 16:38:16 +0000 |
commit | 088ee510879a0ce45e82eed38167b3fd47becd9e (patch) | |
tree | 4ff0c8fea84ac1a3a6e33d5d466fbc14ad1e4c6b /src | |
parent | a73527239ff6f0d6db6097d156e069780d9aa130 (diff) |
Introduce timeouts needed for multicast requests
Change-Id: I7abb22364531af43e0ab4f10436f0b787cd36291
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/coap/doc/src/external-resources.qdoc | 5 | ||||
-rw-r--r-- | src/coap/qcoapclient.cpp | 14 | ||||
-rw-r--r-- | src/coap/qcoapclient.h | 1 | ||||
-rw-r--r-- | src/coap/qcoapprotocol.cpp | 42 | ||||
-rw-r--r-- | src/coap/qcoapprotocol.h | 4 | ||||
-rw-r--r-- | src/coap/qcoapprotocol_p.h | 1 |
6 files changed, 67 insertions, 0 deletions
diff --git a/src/coap/doc/src/external-resources.qdoc b/src/coap/doc/src/external-resources.qdoc index 142466d..34f2420 100644 --- a/src/coap/doc/src/external-resources.qdoc +++ b/src/coap/doc/src/external-resources.qdoc @@ -29,3 +29,8 @@ \externalpage http://coap.technology/ \title CoAP */ + +/*! + \externalpage https://tools.ietf.org/search/rfc7390#section-2.5 + \title RFC 7390 - Section 2.5 +*/ diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp index 816e88c..4b36b80 100644 --- a/src/coap/qcoapclient.cpp +++ b/src/coap/qcoapclient.cpp @@ -725,6 +725,20 @@ void QCoapClient::setSocketOption(QAbstractSocket::SocketOption option, const QV Q_ARG(QVariant, value)); } +/*! + Sets the \c MAX_SERVER_RESPONSE_DELAY value to \a responseDelay in milliseconds. + The default is 250 seconds. + + As defined in \l {RFC 7390 - Section 2.5}, \c MAX_SERVER_RESPONSE_DELAY is the expected + maximum response delay over all servers that the client can send a multicast request to. +*/ +void QCoapClient::setMaxServerResponseDelay(uint responseDelay) +{ + Q_D(QCoapClient); + QMetaObject::invokeMethod(d->protocol, "setMaxServerResponseDelay", Qt::QueuedConnection, + Q_ARG(uint, responseDelay)); +} + #if 0 //! Disabled until fully supported /*! diff --git a/src/coap/qcoapclient.h b/src/coap/qcoapclient.h index bce7446..9a49e5d 100644 --- a/src/coap/qcoapclient.h +++ b/src/coap/qcoapclient.h @@ -82,6 +82,7 @@ public: void setSecurityConfiguration(const QCoapSecurityConfiguration &configuration); void setBlockSize(quint16 blockSize); void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value); + void setMaxServerResponseDelay(uint responseDelay); #if 0 void setProtocol(QCoapProtocol *protocol); diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp index 00075f0..95a574d 100644 --- a/src/coap/qcoapprotocol.cpp +++ b/src/coap/qcoapprotocol.cpp @@ -932,6 +932,33 @@ int QCoapProtocol::maxTimeout() const } /*! + Returns the \c NON_LIFETIME in milliseconds, as defined in + \l{https://tools.ietf.org/search/rfc7252#section-4.8.2}{RFC 7252}. + + It is the time from sending a non-confirmable message to the time its + message ID can be safely reused. +*/ +uint QCoapProtocol::nonConfirmLifetime() const +{ + return static_cast<uint>(maxTransmitSpan() + maxLatency()); +} + +/*! + Returns the \c MAX_SERVER_RESPONSE_DELAY in milliseconds, as defined in + \l {RFC 7390 - Section 2.5}. + + It is the expected maximum response delay over all servers that the client + can send a multicast request to. + + \sa setMaxServerResponseDelay() +*/ +uint QCoapProtocol::maxServerResponseDelay() const +{ + Q_D(const QCoapProtocol); + return d->maxServerResponseDelay; +} + +/*! Sets the ACK_TIMEOUT value to \a ackTimeout in milliseconds. The default is 2000 ms. @@ -1012,6 +1039,21 @@ void QCoapProtocol::setBlockSize(quint16 blockSize) d->blockSize = blockSize; } +/*! + Sets the \c MAX_SERVER_RESPONSE_DELAY value to \a responseDelay in milliseconds. + The default is 250 seconds. + + As defined in \l {RFC 7390 - Section 2.5}, \c MAX_SERVER_RESPONSE_DELAY is the expected + maximum response delay over all servers that the client can send a multicast request to. + + \sa maxServerResponseDelay() +*/ +void QCoapProtocol::setMaxServerResponseDelay(uint responseDelay) +{ + Q_D(QCoapProtocol); + d->maxServerResponseDelay = responseDelay; +} + QT_END_NAMESPACE #include "moc_qcoapprotocol.cpp" diff --git a/src/coap/qcoapprotocol.h b/src/coap/qcoapprotocol.h index b357db7..38fc375 100644 --- a/src/coap/qcoapprotocol.h +++ b/src/coap/qcoapprotocol.h @@ -62,6 +62,9 @@ public: int minTimeout() const; int maxTimeout() const; + uint nonConfirmLifetime() const; + uint maxServerResponseDelay() const; + static QVector<QCoapResource> resourcesFromCoreLinkList( const QHostAddress &sender, const QByteArray &data); @@ -74,6 +77,7 @@ public Q_SLOTS: void setAckRandomFactor(double ackRandomFactor); void setMaxRetransmit(int maxRetransmit); void setBlockSize(quint16 blockSize); + void setMaxServerResponseDelay(uint responseDelay); private Q_SLOTS: void sendRequest(QPointer<QCoapReply> reply, QCoapConnection *connection); diff --git a/src/coap/qcoapprotocol_p.h b/src/coap/qcoapprotocol_p.h index 22f34f8..6651f37 100644 --- a/src/coap/qcoapprotocol_p.h +++ b/src/coap/qcoapprotocol_p.h @@ -107,6 +107,7 @@ public: int maxRetransmit = 4; int ackTimeout = 2000; double ackRandomFactor = 1.5; + uint maxServerResponseDelay = 250 * 1000; Q_DECLARE_PUBLIC(QCoapProtocol) }; |