[api] add API to convert an extended address to a link-local unicast IPv6 address (#11932)

After the P2P link is established, the P2P peer's extended address is
returned as the P2P handle. This commit adds an API to convert the
peer's extended address to the peer's link-local unicast address.
This commit is contained in:
Zhanglong Xia
2025-10-22 16:16:45 +08:00
committed by GitHub
parent 0a4e509f79
commit 6469b1e816
3 changed files with 16 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 (543)
#define OPENTHREAD_API_VERSION (544)
/**
* @addtogroup api-instance
+10
View File
@@ -41,6 +41,7 @@
#include <openthread/error.h>
#include <openthread/instance.h>
#include <openthread/message.h>
#include <openthread/platform/radio.h>
#include <openthread/platform/toolchain.h>
#ifdef __cplusplus
@@ -566,6 +567,15 @@ bool otIp6IsAddressEqual(const otIp6Address *aFirst, const otIp6Address *aSecond
*/
bool otIp6IsLinkLocalUnicast(const otIp6Address *aAddress);
/**
* Forms a link-local unicast IPv6 address from the Interface Identifier generated from the given
* MAC Extended Address with the universal/local bit inverted.
*
* @param[in] aExtAddress A pointer to the MAC Extended Address (used to generate the IID).
* @param[out] aAddress A pointer to output the IPv6 link-local unicast address.
*/
void otIp6FormLinkLocalAddressFromExtAddress(const otExtAddress *aExtAddress, otIp6Address *aAddress);
/**
* Test if two IPv6 prefixes are the same.
*
+5
View File
@@ -173,6 +173,11 @@ bool otIp6IsAddressEqual(const otIp6Address *aFirst, const otIp6Address *aSecond
bool otIp6IsLinkLocalUnicast(const otIp6Address *aAddress) { return AsCoreType(aAddress).IsLinkLocalUnicast(); }
void otIp6FormLinkLocalAddressFromExtAddress(const otExtAddress *aExtAddress, otIp6Address *aAddress)
{
AsCoreType(aAddress).SetToLinkLocalAddress(AsCoreType(aExtAddress));
}
bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond)
{
return AsCoreType(aFirst) == AsCoreType(aSecond);