aboutsummaryrefslogtreecommitdiff
path: root/src/QXmppStun.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-09-01 11:58:31 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-09-01 11:58:31 +0000
commitcd218ff692df40b0324ea6834eb4924293970de0 (patch)
treea9b0cc13722e3a149ee14c59e58e6e144faf5794 /src/QXmppStun.cpp
parent4cc43f4f91ea32eee2537184d78c98e4d8755076 (diff)
downloadqxmpp-cd218ff692df40b0324ea6834eb4924293970de0.tar.gz
unify random number generation
Diffstat (limited to 'src/QXmppStun.cpp')
-rw-r--r--src/QXmppStun.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/QXmppStun.cpp b/src/QXmppStun.cpp
index 092484b4..283d0ba8 100644
--- a/src/QXmppStun.cpp
+++ b/src/QXmppStun.cpp
@@ -124,14 +124,6 @@ static void encodeString(QDataStream &stream, quint16 type, const QString &strin
}
}
-static QByteArray randomByteArray(int length)
-{
- QByteArray result(length, 0);
- for (int i = 0; i < length; ++i)
- result[i] = quint8(qrand() % 255);
- return result;
-}
-
/// Constructs a new QXmppStunMessage.
QXmppStunMessage::QXmppStunMessage()
@@ -653,7 +645,7 @@ QXmppStunSocket::Pair::Pair()
{
// FIXME : calculate priority
priority = 1862270975;
- transaction = randomByteArray(ID_SIZE);
+ transaction = generateRandomBytes(ID_SIZE);
}
QString QXmppStunSocket::Pair::toString() const
@@ -891,7 +883,7 @@ void QXmppStunSocket::setStunServer(const QHostAddress &host, quint16 port)
{
m_stunHost = host;
m_stunPort = port;
- m_stunId = randomByteArray(ID_SIZE);
+ m_stunId = generateRandomBytes(ID_SIZE);
}
void QXmppStunSocket::readyRead()
@@ -1046,7 +1038,7 @@ void QXmppStunSocket::readyRead()
#if 0
// send a binding indication
QXmppStunMessage indication;
- indication.setId(randomByteArray(ID_SIZE));
+ indication.setId(generateRandomBytes(ID_SIZE));
indication.setType(BindingIndication);
m_socket->writeStun(indication, pair);
#endif