Skip to content

Commit

Permalink
Pull request project-chip#1638: Pull request project-chip#1610: MATTE…
Browse files Browse the repository at this point in the history
…R-3235 Cherry-pick: Fix gendiag network interface attribute (project-chip#32390)

Merge in WMN_TOOLS/matter from cherry-pick/fix_gendiag_network_interface to RC_2.3.0-1.3-alpha.3

Squashed commit of the following:

commit 933bdcd4d196d5d0ec9c18933a54ebb28450c679
Author: Junior Martinez <[email protected]>
Date:   Tue Mar 5 20:40:01 2024 +0000

    Pull request project-chip#1610: MATTER-3235 Cherry-pick: Fix gendiag network interface attribute (project-chip#32390)

    Merge in WMN_TOOLS/matter from cherry-pick/fix_gendiag_networkinterace to RC_2.3.0-1.3

    Squashed commit of the following:

    commit 247758db24fd10d49d8376b561905aae96b2cbaf
    Author: Junior Martinez <[email protected]>
    Date:   Fri Mar 1 20:02:29 2024 -0500

        Fix gendiag network interface attribute (project-chip#32390)
  • Loading branch information
mkardous-silabs committed Mar 13, 2024
1 parent 3eccf48 commit 1222f2d
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 1222f2d

Please sign in to comment.