mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 05:07:47 +00:00
[mac] move "FillMacCountersTlv()" to NetworkDiagnostic class (#3263)
This commit is contained in:
committed by
Jonathan Hui
parent
4a89cc63b6
commit
b6cdb09f38
@@ -2155,22 +2155,6 @@ otError Mac::SetEnabled(bool aEnable)
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
void Mac::FillMacCountersTlv(NetworkDiagnostic::MacCountersTlv &aMacCounters) const
|
||||
{
|
||||
aMacCounters.SetIfInUnknownProtos(mCounters.mRxOther);
|
||||
aMacCounters.SetIfInErrors(mCounters.mRxErrNoFrame + mCounters.mRxErrUnknownNeighbor +
|
||||
mCounters.mRxErrInvalidSrcAddr + mCounters.mRxErrSec + mCounters.mRxErrFcs +
|
||||
mCounters.mRxErrOther);
|
||||
aMacCounters.SetIfOutErrors(mCounters.mTxErrCca);
|
||||
aMacCounters.SetIfInUcastPkts(mCounters.mRxUnicast);
|
||||
aMacCounters.SetIfInBroadcastPkts(mCounters.mRxBroadcast);
|
||||
aMacCounters.SetIfInDiscards(mCounters.mRxAddressFiltered + mCounters.mRxDestAddrFiltered +
|
||||
mCounters.mRxDuplicated);
|
||||
aMacCounters.SetIfOutUcastPkts(mCounters.mTxUnicast);
|
||||
aMacCounters.SetIfOutBroadcastPkts(mCounters.mTxBroadcast);
|
||||
aMacCounters.SetIfOutDiscards(mCounters.mTxErrBusyChannel);
|
||||
}
|
||||
|
||||
void Mac::ResetCounters(void)
|
||||
{
|
||||
memset(&mCounters, 0, sizeof(mCounters));
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "thread/key_manager.hpp"
|
||||
#include "thread/link_quality.hpp"
|
||||
#include "thread/network_diagnostic_tlvs.hpp"
|
||||
#include "thread/topology.hpp"
|
||||
|
||||
namespace ot {
|
||||
@@ -508,14 +507,6 @@ public:
|
||||
*/
|
||||
void SetPromiscuous(bool aPromiscuous);
|
||||
|
||||
/**
|
||||
* This method fills network diagnostic MacCounterTlv.
|
||||
*
|
||||
* @param[in] aMacCountersTlv The reference to the network diagnostic MacCounterTlv.
|
||||
*
|
||||
*/
|
||||
void FillMacCountersTlv(NetworkDiagnostic::MacCountersTlv &aMacCounters) const;
|
||||
|
||||
/**
|
||||
* This method resets mac counters
|
||||
*
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/instance.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "mac/mac_frame.hpp"
|
||||
#include "net/netif.hpp"
|
||||
#include "thread/mesh_forwarder.hpp"
|
||||
@@ -269,6 +270,24 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void NetworkDiagnostic::FillMacCountersTlv(MacCountersTlv &aMacCountersTlv)
|
||||
{
|
||||
const otMacCounters &macCounters = GetInstance().Get<Mac::Mac>().GetCounters();
|
||||
|
||||
aMacCountersTlv.SetIfInUnknownProtos(macCounters.mRxOther);
|
||||
aMacCountersTlv.SetIfInErrors(macCounters.mRxErrNoFrame + macCounters.mRxErrUnknownNeighbor +
|
||||
macCounters.mRxErrInvalidSrcAddr + macCounters.mRxErrSec + macCounters.mRxErrFcs +
|
||||
macCounters.mRxErrOther);
|
||||
aMacCountersTlv.SetIfOutErrors(macCounters.mTxErrCca);
|
||||
aMacCountersTlv.SetIfInUcastPkts(macCounters.mRxUnicast);
|
||||
aMacCountersTlv.SetIfInBroadcastPkts(macCounters.mRxBroadcast);
|
||||
aMacCountersTlv.SetIfInDiscards(macCounters.mRxAddressFiltered + macCounters.mRxDestAddrFiltered +
|
||||
macCounters.mRxDuplicated);
|
||||
aMacCountersTlv.SetIfOutUcastPkts(macCounters.mTxUnicast);
|
||||
aMacCountersTlv.SetIfOutBroadcastPkts(macCounters.mTxBroadcast);
|
||||
aMacCountersTlv.SetIfOutDiscards(macCounters.mTxErrBusyChannel);
|
||||
}
|
||||
|
||||
otError NetworkDiagnostic::FillRequestedTlvs(Message & aRequest,
|
||||
Message & aResponse,
|
||||
NetworkDiagnosticTlv &aNetworkDiagnosticTlv)
|
||||
@@ -377,7 +396,7 @@ otError NetworkDiagnostic::FillRequestedTlvs(Message & aRequest,
|
||||
MacCountersTlv tlv;
|
||||
memset(&tlv, 0, sizeof(tlv));
|
||||
tlv.Init();
|
||||
netif.GetMac().FillMacCountersTlv(tlv);
|
||||
FillMacCountersTlv(tlv);
|
||||
SuccessOrExit(error = aResponse.Append(&tlv, tlv.GetSize()));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
private:
|
||||
otError AppendIp6AddressList(Message &aMessage);
|
||||
otError AppendChildTable(Message &aMessage);
|
||||
void FillMacCountersTlv(MacCountersTlv &aMacCountersTlv);
|
||||
otError FillRequestedTlvs(Message &aRequest, Message &aResponse, NetworkDiagnosticTlv &aNetworkDiagnosticTlv);
|
||||
|
||||
static void HandleDiagnosticGetRequest(void * aContext,
|
||||
|
||||
Reference in New Issue
Block a user