mirror of
https://github.com/espressif/openthread.git
synced 2026-09-13 12:40:05 +00:00
[meshcop] process ChannelMaskTlv in message (#3690)
Allows arbitrary number of Channel Mask entries.
This commit is contained in:
@@ -236,11 +236,39 @@ exit:
|
|||||||
|
|
||||||
uint32_t ChannelMaskTlv::GetChannelMask(const Message &aMessage)
|
uint32_t ChannelMaskTlv::GetChannelMask(const Message &aMessage)
|
||||||
{
|
{
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
ChannelMaskTlv channelMaskTlv;
|
uint16_t offset;
|
||||||
|
uint16_t end;
|
||||||
|
|
||||||
SuccessOrExit(GetTlv(aMessage, kChannelMask, sizeof(channelMaskTlv), channelMaskTlv));
|
SuccessOrExit(GetValueOffset(aMessage, kChannelMask, offset, end));
|
||||||
mask = channelMaskTlv.GetChannelMask();
|
end += offset;
|
||||||
|
|
||||||
|
while (offset + sizeof(ChannelMaskEntryBase) <= end)
|
||||||
|
{
|
||||||
|
ChannelMaskEntry entry;
|
||||||
|
|
||||||
|
aMessage.Read(offset, sizeof(ChannelMaskEntryBase), &entry);
|
||||||
|
VerifyOrExit(offset + entry.GetEntrySize() <= end);
|
||||||
|
|
||||||
|
switch (entry.GetChannelPage())
|
||||||
|
{
|
||||||
|
#if OPENTHREAD_CONFIG_RADIO_2P4GHZ_OQPSK_SUPPORT
|
||||||
|
case OT_RADIO_CHANNEL_PAGE_0:
|
||||||
|
aMessage.Read(offset, sizeof(entry), &entry);
|
||||||
|
mask |= entry.GetMask() & OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MASK;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
|
||||||
|
case OT_RADIO_CHANNEL_PAGE_2:
|
||||||
|
aMessage.Read(offset, sizeof(entry), &entry);
|
||||||
|
mask |= entry.GetMask() & OT_RADIO_915MHZ_OQPSK_CHANNEL_MASK;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += entry.GetEntrySize();
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return mask;
|
return mask;
|
||||||
|
|||||||
Reference in New Issue
Block a user