mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 03:00:09 +00:00
[ip6-address] update and use Ip6::InterfaceIdentifier class (#5194)
This commit updates `Ip6::InterfaceIdentifier` class adding new helper methods to it (e.g., generate random IID, or convert IID to/from a MAC Extended Address). It also updates the `Ip6::Address` methods (related to getting/setting/checking IID) to use the `Ip6::InterfaceIdentifier` type. The larger change in this commit is to update other core classes and modules (`Lowpan`, `Mle`, `Settings`, 'AddressResolver', `Child`, etc.) to use the `Ip6::InterfaceIdentifier`/`Ip6::Address` type and their new/changed methods. This commit also adds a new `struct` type `otIp6AddressComponents` to the public OT API header `ip6.h`. This type represents the components of a (unicast) IPv6 address, i.e. a network prefix and an IID. The `otIp6Address` uses the new type as one of its `union` representations of an IPv6 address.
This commit is contained in:
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (12)
|
||||
#define OPENTHREAD_API_VERSION (13)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -66,7 +66,12 @@ extern "C" {
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6InterfaceIdentifier
|
||||
{
|
||||
uint8_t m8[OT_IP6_IID_SIZE]; ///< The Interface Identifier of an IPv6 address.
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_IP6_IID_SIZE]; ///< 8-bit fields
|
||||
uint16_t m16[OT_IP6_IID_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[OT_IP6_IID_SIZE / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
} mFields; ///< The Interface Identifier accessor fields
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
@@ -75,6 +80,43 @@ struct otIp6InterfaceIdentifier
|
||||
*/
|
||||
typedef struct otIp6InterfaceIdentifier otIp6InterfaceIdentifier;
|
||||
|
||||
/**
|
||||
* @struct otIp6NetworkPrefix
|
||||
*
|
||||
* This structure represents the Network Prefix of an IPv6 address (most significant 64 bits of the address).
|
||||
*
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6NetworkPrefix
|
||||
{
|
||||
uint8_t m8[OT_IP6_PREFIX_SIZE]; ///< The Network Prefix.
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* This structure represents the Network Prefix of an IPv6 address (most significant 64 bits of the address).
|
||||
*
|
||||
*/
|
||||
typedef struct otIp6NetworkPrefix otIp6NetworkPrefix;
|
||||
|
||||
/**
|
||||
* @struct otIp6AddressComponents
|
||||
*
|
||||
* This structure represents the components of an IPv6 address.
|
||||
*
|
||||
*/
|
||||
OT_TOOL_PACKED_BEGIN
|
||||
struct otIp6AddressComponents
|
||||
{
|
||||
otIp6NetworkPrefix mNetworkPrefix; ///< The Network Prefix (most significant 64 bits of the address)
|
||||
otIp6InterfaceIdentifier mIid; ///< The Interface Identifier (least significant 64 bits of the address)
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
* This structure represents the components of an IPv6 address.
|
||||
*
|
||||
*/
|
||||
typedef struct otIp6AddressComponents otIp6AddressComponents;
|
||||
|
||||
/**
|
||||
* @struct otIp6Address
|
||||
*
|
||||
@@ -86,10 +128,11 @@ struct otIp6Address
|
||||
{
|
||||
union OT_TOOL_PACKED_FIELD
|
||||
{
|
||||
uint8_t m8[OT_IP6_ADDRESS_SIZE]; ///< 8-bit fields
|
||||
uint16_t m16[OT_IP6_ADDRESS_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[OT_IP6_ADDRESS_SIZE / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
} mFields; ///< IPv6 accessor fields
|
||||
uint8_t m8[OT_IP6_ADDRESS_SIZE]; ///< 8-bit fields
|
||||
uint16_t m16[OT_IP6_ADDRESS_SIZE / sizeof(uint16_t)]; ///< 16-bit fields
|
||||
uint32_t m32[OT_IP6_ADDRESS_SIZE / sizeof(uint32_t)]; ///< 32-bit fields
|
||||
otIp6AddressComponents mComponents; ///< IPv6 address components
|
||||
} mFields; ///< IPv6 accessor fields
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user