mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Merge pull request #7398 from huffman/add-request-handshake
Add HandshakeRequest packet
This commit is contained in:
commit
eb5ecc84ff
4 changed files with 24 additions and 4 deletions
|
@ -411,7 +411,15 @@ SequenceNumber Connection::nextACK() const {
|
|||
bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, int packetSize, int payloadSize) {
|
||||
|
||||
if (!_hasReceivedHandshake) {
|
||||
// refuse to process any packets until we've received the handshake
|
||||
// Refuse to process any packets until we've received the handshake
|
||||
// Send handshake request to re-request a handshake
|
||||
auto handshakeRequestPacket = ControlPacket::create(ControlPacket::HandshakeRequest, 0);
|
||||
_parentSocket->writeBasePacket(*handshakeRequestPacket, _destination);
|
||||
|
||||
#ifdef UDT_CONNECTION_DEBUG
|
||||
qCDebug(networking) << "Received packet before receiving handshake, sending HandshakeRequest";
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -537,6 +545,17 @@ void Connection::processControl(std::unique_ptr<ControlPacket> controlPacket) {
|
|||
processProbeTail(move(controlPacket));
|
||||
}
|
||||
break;
|
||||
case ControlPacket::HandshakeRequest:
|
||||
if (_hasReceivedHandshakeACK) {
|
||||
// We're already in a state where we've received a handshake ack, so we are likely in a state
|
||||
// where the other end expired our connection. Let's reset.
|
||||
|
||||
#ifdef UDT_CONNECTION_DEBUG
|
||||
qCDebug(networking) << "Got handshake request, stopping SendQueue";
|
||||
#endif
|
||||
stopSendQueue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ void ControlPacket::readType() {
|
|||
Q_ASSERT_X(bitAndType & CONTROL_BIT_MASK, "ControlPacket::readHeader()", "This should be a control packet");
|
||||
|
||||
uint16_t packetType = (bitAndType & ~CONTROL_BIT_MASK) >> (8 * sizeof(Type));
|
||||
Q_ASSERT_X(packetType <= ControlPacket::Type::ProbeTail, "ControlPacket::readType()", "Received a control packet with wrong type");
|
||||
Q_ASSERT_X(packetType <= ControlPacket::Type::HandshakeRequest, "ControlPacket::readType()", "Received a control packet with wrong type");
|
||||
|
||||
// read the type
|
||||
_type = (Type) packetType;
|
||||
|
|
|
@ -34,7 +34,8 @@ public:
|
|||
TimeoutNAK,
|
||||
Handshake,
|
||||
HandshakeACK,
|
||||
ProbeTail
|
||||
ProbeTail,
|
||||
HandshakeRequest
|
||||
};
|
||||
|
||||
static std::unique_ptr<ControlPacket> create(Type type, qint64 size = -1);
|
||||
|
|
|
@ -529,4 +529,4 @@ void SendQueue::deactivate() {
|
|||
emit queueInactive();
|
||||
|
||||
_state = State::Stopped;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue