Skip to content

Commit

Permalink
Fix gendiag network interface attribute (#32390)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinez-silabs authored Mar 2, 2024
1 parent 00227dc commit 9e8a77f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ template <class ConfigClass>
CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetPrimary802154MACAddress(uint8_t * buf)
{
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
return ThreadStackManager().GetPrimary802154MACAddress(buf);
return ThreadStackMgr().GetPrimary802154MACAddress(buf);
#else
return CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
Expand Down
31 changes: 25 additions & 6 deletions src/platform/silabs/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "AppConfig.h"
#include "FreeRTOS.h"
#include "heap_4_silabs.h"
#include <inet/InetInterface.h>
#include <lib/support/CHIPMemString.h>

using namespace ::chip::app::Clusters::GeneralDiagnostics;
Expand Down Expand Up @@ -249,13 +250,32 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance());
ifp->name = Span<const char>(threadNetworkName, strlen(threadNetworkName));
ifp->isOperational = true;
ifp->type = InterfaceTypeEnum::kThread;
ifp->isOperational = ThreadStackMgrImpl().IsThreadAttached();
ifp->offPremiseServicesReachableIPv4.SetNull();
ifp->offPremiseServicesReachableIPv6.SetNull();
ifp->type = InterfaceTypeEnum::kThread;
uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength];
ConfigurationMgr().GetPrimary802154MACAddress(macBuffer);
ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength);

ThreadStackMgrImpl().GetPrimary802154MACAddress(ifp->MacAddress);
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, kMaxHardwareAddrSize);

// The Thread implementation has only 1 interface and is IPv6-only
Inet::InterfaceAddressIterator interfaceAddressIterator;
uint8_t ipv6AddressesCount = 0;
while (interfaceAddressIterator.HasCurrent() && ipv6AddressesCount < kMaxIPv6AddrCount)
{
Inet::IPAddress ipv6Address;
if (interfaceAddressIterator.GetAddress(ipv6Address) == CHIP_NO_ERROR)
{
memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize);
ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]);
ipv6AddressesCount++;
}
interfaceAddressIterator.Next();
}

ifp->IPv6Addresses = app::DataModel::List<ByteSpan>(ifp->Ipv6AddressSpans, ipv6AddressesCount);

*netifpp = ifp;
#else
NetworkInterface * head = NULL;
for (Inet::InterfaceIterator interfaceIterator; interfaceIterator.HasCurrent(); interfaceIterator.Next())
Expand Down Expand Up @@ -331,7 +351,6 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
*netifpp = head;
#endif

*netifpp = ifp;
return CHIP_NO_ERROR;
}

Expand Down

0 comments on commit 9e8a77f

Please sign in to comment.