Skip to content

Commit

Permalink
[Ameba] Add ipv4 and ipv6 addresses into GetNetworkInterfaces (#15622)
Browse files Browse the repository at this point in the history
* Add ipv4 and ipv6 addresses into GetNetworkInterfaces

* Add checks for valid ipv4 and ipv6 addresses

* Fix restyle
  • Loading branch information
pankore authored and pull[bot] committed Nov 14, 2023
1 parent 90aedd3 commit 1010812
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/platform/Ameba/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6);
}

if (ifa->ip_addr.u_addr.ip4.addr != 0)
{
memcpy(ifp->Ipv4AddressesBuffer[0], &(ifa->ip_addr.u_addr.ip4.addr), kMaxIPv4AddrSize);
ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize);
ifp->IPv4Addresses = chip::app::DataModel::List<chip::ByteSpan>(ifp->Ipv4AddressSpans, 1);
}

if (ifa->ip6_addr->u_addr.ip6.addr != 0)
{
memcpy(ifp->Ipv6AddressesBuffer[0], &(ifa->ip6_addr->u_addr.ip6.addr), kMaxIPv6AddrSize);
ifp->Ipv6AddressSpans[0] = ByteSpan(ifp->Ipv6AddressesBuffer[0], kMaxIPv6AddrSize);
ifp->IPv6Addresses = chip::app::DataModel::List<chip::ByteSpan>(ifp->Ipv6AddressSpans, 1);
}

ifp->Next = head;
head = ifp;
}
Expand Down

0 comments on commit 1010812

Please sign in to comment.