aboutsummaryrefslogtreecommitdiff
path: root/src/QXmppStun.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-12-06 09:22:06 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-12-06 09:22:06 +0000
commitfab2e18c6451705be9fb784a248260d304f621c7 (patch)
treeecbcdcb6821e0001f9003ab07a6b80907fcdd7e1 /src/QXmppStun.cpp
parente207ab2c6fbdf046129978d812936af9d34c302f (diff)
downloadqxmpp-fab2e18c6451705be9fb784a248260d304f621c7.tar.gz
rework QXmppStunMessage::peekType to return magic cookie
Diffstat (limited to 'src/QXmppStun.cpp')
-rw-r--r--src/QXmppStun.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/QXmppStun.cpp b/src/QXmppStun.cpp
index 0c2443db..5bebb379 100644
--- a/src/QXmppStun.cpp
+++ b/src/QXmppStun.cpp
@@ -661,7 +661,7 @@ QByteArray QXmppStunMessage::encode(const QString &password, bool addFingerprint
///
/// \param buffer
-quint16 QXmppStunMessage::peekType(const QByteArray &buffer, QByteArray &id)
+quint16 QXmppStunMessage::peekType(const QByteArray &buffer, quint32 &cookie, QByteArray &id)
{
if (buffer.size() < STUN_HEADER)
return 0;
@@ -670,7 +670,6 @@ quint16 QXmppStunMessage::peekType(const QByteArray &buffer, QByteArray &id)
QDataStream stream(buffer);
quint16 type;
quint16 length;
- quint32 cookie;
stream >> type;
stream >> length;
stream >> cookie;
@@ -1033,9 +1032,10 @@ void QXmppIceComponent::readyRead()
socket->readDatagram(buffer.data(), buffer.size(), &remoteHost, &remotePort);
// if this is not a STUN message, emit it
+ quint32 messageCookie;
QByteArray messageId;
- quint16 messageType = QXmppStunMessage::peekType(buffer, messageId);
- if (!messageType)
+ quint16 messageType = QXmppStunMessage::peekType(buffer, messageCookie, messageId);
+ if (!messageType || messageCookie != STUN_MAGIC)
{
// use this as an opportunity to flag a potential pair
if (!m_fallbackPair) {