[network-diagnostic] add Iterator type (#4992)

This commit is contained in:
Abtin Keshavarzian
2020-05-21 12:05:13 -07:00
committed by Jonathan Hui
parent c90f5f3f3e
commit f0df3e3d6b
2 changed files with 18 additions and 8 deletions
+3 -3
View File
@@ -792,9 +792,9 @@ static inline void ParseChildEntry(const ChildTableEntry &aChildTableTlvEntry, o
ParseMode(aChildTableTlvEntry.GetMode(), aChildEntry.mMode);
}
otError NetworkDiagnostic::GetNextDiagTlv(const Coap::Message & aMessage,
otNetworkDiagIterator &aIterator,
otNetworkDiagTlv & aNetworkDiagTlv)
otError NetworkDiagnostic::GetNextDiagTlv(const Coap::Message &aMessage,
Iterator & aIterator,
otNetworkDiagTlv & aNetworkDiagTlv)
{
otError error = OT_ERROR_PARSE;
uint16_t offset = aMessage.GetOffset();
+15 -5
View File
@@ -63,6 +63,17 @@ namespace NetworkDiagnostic {
class NetworkDiagnostic : public InstanceLocator
{
public:
enum
{
kIteratorInit = OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT, ///< Initializer value for Iterator.
};
/**
* This type represents an iterator used to iterate through Network Diagnostic TLVs from `GetNextDiagTlv()`.
*
*/
typedef otNetworkDiagIterator Iterator;
/**
* This constructor initializes the object.
*
@@ -104,8 +115,7 @@ public:
* This static method gets the next Network Diagnostic TLV in a given message.
*
* @param[in] aMessage A message.
* @param[inout] aIterator The Network Diagnostic iterator. To get the first TLV it should be set to
* OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT.
* @param[inout] aIterator The Network Diagnostic iterator. To get the first TLV set it to `kIteratorInit`.
* @param[out] aNetworkDiagTlv A reference to a Network Diagnostic TLV to output the next TLV.
*
* @retval OT_ERROR_NONE Successfully found the next Network Diagnostic TLV.
@@ -113,9 +123,9 @@ public:
* @retval OT_ERROR_PARSE Parsing the next Network Diagnostic failed.
*
*/
static otError GetNextDiagTlv(const Coap::Message & aMessage,
otNetworkDiagIterator &aIterator,
otNetworkDiagTlv & aNetworkDiagTlv);
static otError GetNextDiagTlv(const Coap::Message &aMessage,
Iterator & aIterator,
otNetworkDiagTlv & aNetworkDiagTlv);
private:
otError AppendIp6AddressList(Message &aMessage);