mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
repair ping packet parsing in creation of reply
This commit is contained in:
parent
821e25a72a
commit
c989a64e90
2 changed files with 10 additions and 5 deletions
|
@ -119,13 +119,15 @@ void NodeList::timePingReply(const QByteArray& packet) {
|
|||
|
||||
if (matchingNode) {
|
||||
QDataStream packetStream(packet);
|
||||
packetStream.device()->seek(numBytesForPacketHeader(packet));
|
||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||
|
||||
qint64 ourOriginalTime, othersReplyTime;
|
||||
quint64 ourOriginalTime, othersReplyTime;
|
||||
|
||||
packetStream >> ourOriginalTime >> othersReplyTime;
|
||||
|
||||
qint64 now = usecTimestampNow();
|
||||
qDebug() << "OT:" << ourOriginalTime << "OR:" << othersReplyTime;
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
int pingTime = now - ourOriginalTime;
|
||||
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
||||
|
||||
|
@ -554,8 +556,11 @@ QByteArray NodeList::constructPingPacket() {
|
|||
}
|
||||
|
||||
QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||
QDataStream pingPacketStream(pingPacket);
|
||||
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||
|
||||
quint64 timeFromOriginalPing;
|
||||
memcpy(&timeFromOriginalPing, pingPacket.data() + numBytesForPacketHeader(pingPacket), sizeof(timeFromOriginalPing));
|
||||
pingPacketStream >> timeFromOriginalPing;
|
||||
|
||||
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
||||
|
|
|
@ -80,7 +80,7 @@ bool packetVersionMatch(const QByteArray& packet) {
|
|||
// currently this just checks if the version in the packet matches our return from versionForPacketType
|
||||
// may need to be expanded in the future for types and versions that take > than 1 byte
|
||||
|
||||
if (packet[1] == versionForPacketType(packetTypeForPacket(packet)) || packet[0] == PacketTypeStunResponse) {
|
||||
if (packet[1] == versionForPacketType(packetTypeForPacket(packet)) || packetTypeForPacket(packet) == PacketTypeStunResponse) {
|
||||
return true;
|
||||
} else {
|
||||
PacketType mismatchType = packetTypeForPacket(packet);
|
||||
|
|
Loading…
Reference in a new issue