mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 17:09:51 +00:00
[lowpan] introduce buffer writer to lowpan compressor (#3597)
This commit is contained in:
committed by
Jonathan Hui
parent
0f2502833e
commit
49641e1d4e
@@ -178,15 +178,20 @@ static void Test(TestIphcVector &aVector, bool aCompress, bool aDecompress)
|
||||
|
||||
if (aCompress)
|
||||
{
|
||||
Lowpan::BufferWriter buffer(result, 127);
|
||||
|
||||
VerifyOrQuit((message = sInstance->GetMessagePool().New(Message::kTypeIp6, 0)) != NULL,
|
||||
"6lo: Ip6::NewMessage failed");
|
||||
|
||||
aVector.GetUncompressedStream(*message);
|
||||
|
||||
int compressBytes = sLowpan->Compress(*message, aVector.mMacSource, aVector.mMacDestination, result);
|
||||
VerifyOrQuit(sLowpan->Compress(*message, aVector.mMacSource, aVector.mMacDestination, buffer) == aVector.mError,
|
||||
"6lo: Lowpan:Compress failed");
|
||||
|
||||
if (aVector.mError == OT_ERROR_NONE)
|
||||
{
|
||||
uint8_t compressBytes = buffer.GetWritePointer() - result;
|
||||
|
||||
// Append payload to the LOWPAN_IPHC.
|
||||
message->Read(message->GetOffset(), message->GetLength() - message->GetOffset(), result + compressBytes);
|
||||
|
||||
@@ -198,10 +203,6 @@ static void Test(TestIphcVector &aVector, bool aCompress, bool aDecompress)
|
||||
VerifyOrQuit(message->GetOffset() == aVector.mPayloadOffset, "6lo: Lowpan::Compress failed");
|
||||
VerifyOrQuit(memcmp(iphc, result, iphcLength) == 0, "6lo: Lowpan::Compress failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyOrQuit(compressBytes < 0, "6lo: Lowpan::Compress failed");
|
||||
}
|
||||
|
||||
message->Free();
|
||||
message = NULL;
|
||||
|
||||
Reference in New Issue
Block a user