mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:57:37 +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) {
|
if (matchingNode) {
|
||||||
QDataStream packetStream(packet);
|
QDataStream packetStream(packet);
|
||||||
packetStream.device()->seek(numBytesForPacketHeader(packet));
|
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
qint64 ourOriginalTime, othersReplyTime;
|
quint64 ourOriginalTime, othersReplyTime;
|
||||||
|
|
||||||
packetStream >> ourOriginalTime >> othersReplyTime;
|
packetStream >> ourOriginalTime >> othersReplyTime;
|
||||||
|
|
||||||
qint64 now = usecTimestampNow();
|
qDebug() << "OT:" << ourOriginalTime << "OR:" << othersReplyTime;
|
||||||
|
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
int pingTime = now - ourOriginalTime;
|
int pingTime = now - ourOriginalTime;
|
||||||
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
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) {
|
QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||||
|
QDataStream pingPacketStream(pingPacket);
|
||||||
|
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||||
|
|
||||||
quint64 timeFromOriginalPing;
|
quint64 timeFromOriginalPing;
|
||||||
memcpy(&timeFromOriginalPing, pingPacket.data() + numBytesForPacketHeader(pingPacket), sizeof(timeFromOriginalPing));
|
pingPacketStream >> timeFromOriginalPing;
|
||||||
|
|
||||||
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
||||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
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
|
// 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
|
// 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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
PacketType mismatchType = packetTypeForPacket(packet);
|
PacketType mismatchType = packetTypeForPacket(packet);
|
||||||
|
|
Loading…
Reference in a new issue