[network-data] optimize network data update via MLE (#2612)

This commit reduces stack usage when receiving/updating network data via MLE
by copying the network data directly out of the message and skipping the TLV
read.
This commit is contained in:
Jonathan Hui
2018-03-12 18:27:07 +00:00
committed by GitHub
parent 8ad0e8e0c9
commit 51c62a29d0
5 changed files with 49 additions and 36 deletions
+9 -1
View File
@@ -114,6 +114,9 @@ static void Init()
// Emulate global prefixes with contextes.
uint8_t mockNetworkData[] = {
0x0c, // MLE Network Data Type
0x20, // MLE Network Data Length
// Prefix 2001:2:0:1::/64
0x03, 0x0e, // Prefix TLV
0x00, 0x40, 0x20, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x07, 0x02, // 6LoWPAN Context ID TLV
@@ -125,7 +128,12 @@ static void Init()
0x02, 0x40 // Context ID = 2, C = FALSE
};
sThreadNetif->GetNetworkDataLeader().SetNetworkData(0, 0, true, mockNetworkData, sizeof(mockNetworkData));
Message *message = sInstance->GetMessagePool().New(Message::kTypeIp6, 0);
VerifyOrQuit(message != NULL, "6lo: Ip6::NewMessage failed");
SuccessOrQuit(message->Append(mockNetworkData, sizeof(mockNetworkData)), "6lo: Message::Append failed");
sThreadNetif->GetNetworkDataLeader().SetNetworkData(0, 0, true, *message, 0);
}
/**