[tmf] add method to read entry from ChildTableTlv (#4147)

This commit add a method to read entry from ChildTableTlv. The
GetEntry() cannot be used because the current read ChildTableTlv
operation doesn't read child table entries.
This commit is contained in:
huamenggg
2019-09-11 11:09:55 -07:00
committed by Jonathan Hui
parent 957d79d786
commit 050682ddc3
@@ -1348,6 +1348,26 @@ public:
return *reinterpret_cast<ChildTableEntry *>(GetValue() + (aIndex * sizeof(ChildTableEntry)));
}
/**
* This method reads the Child Table entry at @p aIndex.
*
* @param[out] aEntry A reference to a ChildTableEntry.
* @param[in] aMessage A reference to the message.
* @param[in] aOffset The offset of the ChildTableTLV in aMessage.
* @param[in] aIndex The index into the Child Table list.
*
* @retval OT_ERROR_NOT_FOUND No such entry is found.
* @retval OT_ERROR_NONE Successfully read the entry.
*/
otError ReadEntry(ChildTableEntry &aEntry, Message &aMessage, uint16_t aOffset, uint8_t aIndex) const
{
return (aIndex < GetNumEntries() &&
aMessage.Read(aOffset + sizeof(ChildTableTlv) + (aIndex * sizeof(ChildTableEntry)),
sizeof(ChildTableEntry), &aEntry) == sizeof(ChildTableEntry))
? OT_ERROR_NONE
: OT_ERROR_INVALID_ARGS;
}
} OT_TOOL_PACKED_END;
/**