[api] add API to extract an extended address from an IPv6 address (#11933)

The application of the P2P module may only record the P2P peer's
link-local address for communication. This commit adds an API to
convert the peer's link-local unicast address to the peer's extended
address for tearing down the P2P link.
This commit is contained in:
Zhanglong Xia
2025-10-27 09:26:31 -07:00
committed by GitHub
parent 35cacd6d5f
commit 317321fef2
3 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ extern "C" {
*
* @note This number versions both OpenThread platform and user APIs.
*/
#define OPENTHREAD_API_VERSION (545)
#define OPENTHREAD_API_VERSION (546)
/**
* @addtogroup api-instance
+8
View File
@@ -576,6 +576,14 @@ bool otIp6IsLinkLocalUnicast(const otIp6Address *aAddress);
*/
void otIp6FormLinkLocalAddressFromExtAddress(const otExtAddress *aExtAddress, otIp6Address *aAddress);
/**
* Extracts the MAC Extended Address from the Interface Identifier of the given IPv6 address.
*
* @param[in] aAddress A pointer to the IPv6 address.
* @param[out] aExtAddress A pointer to output the MAC Extended Address (generated from the IID).
*/
void otIp6ExtractExtAddressFromIp6AddressIid(const otIp6Address *aAddress, otExtAddress *aExtAddress);
/**
* Test if two IPv6 prefixes are the same.
*
+5
View File
@@ -178,6 +178,11 @@ void otIp6FormLinkLocalAddressFromExtAddress(const otExtAddress *aExtAddress, ot
AsCoreType(aAddress).SetToLinkLocalAddress(AsCoreType(aExtAddress));
}
void otIp6ExtractExtAddressFromIp6AddressIid(const otIp6Address *aAddress, otExtAddress *aExtAddress)
{
AsCoreType(aExtAddress).SetFromIid(AsCoreType(aAddress).GetIid());
}
bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond)
{
return AsCoreType(aFirst) == AsCoreType(aSecond);