Skip to content

Commit

Permalink
[Infineon][TC-DGGEN-2.1] CYW30739 supports responding IPv6Addresses i…
Browse files Browse the repository at this point in the history
…n NetworkInterface. (#19866)

Co-authored-by: Justin Wood <woody@apple.com>
  • Loading branch information
2 people authored and pull[bot] committed Aug 30, 2022
1 parent 4bf9449 commit 1493878
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
21 changes: 18 additions & 3 deletions src/platform/CYW30739/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,33 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp)
{
auto ifp = Platform::New<ThreadNetworkInterface>();
auto ifp = Platform::New<NetworkInterface>();
VerifyOrReturnError(ifp != nullptr, CHIP_ERROR_NO_MEMORY);

const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance());
ifp->name = Span<const char>(threadNetworkName, strlen(threadNetworkName));
ifp->isOperational = true;
ifp->offPremiseServicesReachableIPv4.SetNull();
ifp->offPremiseServicesReachableIPv6.SetNull();
ifp->hardwareAddress = ByteSpan(ifp->macBuffer);
ifp->hardwareAddress = ByteSpan(ifp->MacAddress);
ifp->type = app::Clusters::GeneralDiagnostics::InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD;

ConfigurationMgr().GetPrimary802154MACAddress(ifp->macBuffer);
static_assert(sizeof(ifp->MacAddress) >= ConfigurationManager::kPrimaryMACAddressLength, "Invalid MacAddress buffer size");
ConfigurationMgr().GetPrimary802154MACAddress(ifp->MacAddress);

/* Thread only support IPv6 */
uint8_t ipv6AddressesCount = 0;
for (Inet::InterfaceAddressIterator iterator; iterator.Next() && ipv6AddressesCount < kMaxIPv6AddrCount;)
{
chip::Inet::IPAddress ipv6Address;
if (iterator.GetAddress(ipv6Address) == CHIP_NO_ERROR)
{
memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize);
ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]);
ipv6AddressesCount++;
}
}
ifp->IPv6Addresses = app::DataModel::List<const ByteSpan>(ifp->Ipv6AddressSpans, ipv6AddressesCount);

*netifpp = ifp;
return CHIP_NO_ERROR;
Expand Down
10 changes: 0 additions & 10 deletions src/platform/CYW30739/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override;
void ReleaseNetworkInterfaces(NetworkInterface * netifp) override;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */

private:
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
struct ThreadNetworkInterface : public NetworkInterface
{
~ThreadNetworkInterface() = delete;

uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength];
};
#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */
};

} // namespace DeviceLayer
Expand Down

0 comments on commit 1493878

Please sign in to comment.