mirror of
https://github.com/espressif/openthread.git
synced 2026-08-21 18:09:52 +00:00
[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:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user