1
0
Fork 0

fix flags+length writing

This commit is contained in:
Kevin Matz 2021-09-01 12:24:48 -04:00
parent 4e38144e9f
commit e0d142797a
1 changed files with 13 additions and 6 deletions

View File

@ -228,14 +228,21 @@ void Pdu::oStream(Stream stream) const
}
// inject flags onto the high 4 bits of the length
auto flength = reinterpret_cast<uint8_t*>(length);
if (flags.hasLength)
flength[2] = (flength[2] & 0x0f) | (uint8_t)flags;
{
uint8_t flength[3];
flength[0] = ((length >> 16) & 0x0f) | (uint8_t)flags;
flength[1] = length >> 8;
flength[2] = length;
stream->write(flength, sizeof(flength));
}
else
flength[1] = (flength[1] & 0x0f) | (uint8_t)flags;
// write the flength to stream
stream->write(flength, (flags.hasLength ? 3 : 2));
{
uint8_t flength[2];
flength[0] = ((length >> 8) & 0x0f) | (uint8_t)flags;
flength[1] = length;
stream->write(flength, sizeof(flength));
}
// write the vector to stream
if (flags.hasVector)