return an ACK2 from processControl

This commit is contained in:
Stephen Birarda 2015-07-27 17:48:38 -07:00
parent 75765d02e4
commit f176c45a61
3 changed files with 19 additions and 1 deletions

View file

@ -132,6 +132,10 @@ void Connection::processControl(std::unique_ptr<ControlPacket> controlPacket) {
case ControlPacket::ACK:
break;
case ControlPacket::ACK2:
// change the type of the packet to an ACK2 and send it back
controlPacket->setType(ControlPacket::ACK2);
_sendQueue->sendPacket(*controlPacket);
break;
case ControlPacket::NAK:
break;

View file

@ -94,12 +94,24 @@ ControlPacket& ControlPacket::operator=(ControlPacket&& other) {
static const uint32_t CONTROL_BIT_MASK = 1 << (sizeof(ControlPacket::ControlBitAndType) - 1);
void ControlPacket::setType(udt::ControlPacket::Type type) {
_type = type;
writeType();
}
void ControlPacket::writeControlBitAndType() {
ControlBitAndType* bitAndType = reinterpret_cast<ControlBitAndType*>(_packet.get());
// write the control bit by OR'ing the current value with the CONTROL_BIT_MASK
*bitAndType = (*bitAndType | CONTROL_BIT_MASK);
// write the type by OR'ing the type with the current value & CONTROL_BIT_MASK
writeType();
}
void ControlPacket::writeType() {
ControlBitAndType* bitAndType = reinterpret_cast<ControlBitAndType*>(_packet.get());
// write the type by OR'ing the new type with the current value & CONTROL_BIT_MASK
*bitAndType = (*bitAndType & CONTROL_BIT_MASK) | (_type << sizeof((ControlPacket::Type) - 1));
}

View file

@ -41,6 +41,7 @@ public:
virtual qint64 totalHeadersSize() const; // Cumulated size of all the headers
Type getType() const { return _type; }
void setType(Type type);
private:
ControlPacket(Type type);
@ -54,6 +55,7 @@ private:
// Header writers
void writeControlBitAndType();
void writeType();
Type _type;
};