Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Infineon][TC-DGGEN-2.1] CYW30739 supports responding IPv6Addresses in NetworkInterface. #19866

Merged
merged 3 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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