Pr/slaac utility (#698)

* Provide utility for IPv6 SLAAC (#651)

* Semantically Opaque Interface Identifier with IPv6 SLAAC (#651)
This commit is contained in:
Hubert Miś
2016-09-29 08:37:10 -07:00
committed by Jonathan Hui
parent 537f0fdac8
commit aeba71b1a1
15 changed files with 599 additions and 97 deletions
+23
View File
@@ -132,6 +132,11 @@ typedef enum ThreadError
*/
kThreadError_BlacklistFiltered = 27,
/**
* The creation of IPv6 address failed.
*/
kThreadError_Ipv6AddressCreationFailure = 28,
kThreadError_Error = 255,
} ThreadError;
@@ -807,6 +812,24 @@ typedef struct otNetifAddress
struct otNetifAddress *mNext; ///< A pointer to the next network interface address.
} otNetifAddress;
/**
* This structure represents data used by Semantically Opaque IID Generator.
*
*/
typedef struct
{
uint8_t *mInterfaceId; ///< String of bytes representing interface ID. Like "eth0" or "wlan0".
uint8_t mInterfaceIdLength; ///< Length of interface ID string.
uint8_t *mNetworkId; ///< Network ID (or name). Can be null if mNetworkIdLength is 0.
uint8_t mNetworkIdLength; ///< Length of Network ID string.
uint8_t mDadCounter; ///< Duplicate address detection counter.
uint8_t *mSecretKey; ///< Secret key used to create IID. Cannot be null.
uint16_t mSecretKeyLength; ///< Secret key length in bytes. Should be at least 16 bytes == 128 bits.
} otSemanticallyOpaqueIidGeneratorData;
/**
* @addtogroup messages Message Buffers
*
+64
View File
@@ -83,6 +83,7 @@ extern "C" {
*
* @defgroup core-6lowpan 6LoWPAN
* @defgroup core-coap CoAP
* @defgroup core-global-address Global IPv6 Address
* @defgroup core-ipv6 IPv6
* @defgroup core-mac MAC
* @defgroup core-mesh-forwarding Mesh Forwarding
@@ -786,6 +787,69 @@ ThreadError otAddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAd
*/
ThreadError otRemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
* This function pointer is called to create IPv6 IID during SLAAC procedure.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[inout] aContext A pointer to creator-specific context.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
* @retval kThreadError_Ipv6AddressCreationFailure Creation of valid IID for given IPv6 address failed.
*
*/
typedef ThreadError(*otSlaacIidCreate)(otInstance *aInstance, otNetifAddress *aAddress, void *aContext);
/**
* Update all automatically created IPv6 addresses for prefixes from current Network Data with SLAAC procedure.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddresses A pointer to an array of automatically created IPv6 addresses.
* @param[in] aNumAddresses The number of slots in aAddresses array.
* @param[in] aIidCreate A pointer to a function that is called to create IPv6 IIDs.
* @param[in] aContext A pointer to data passed to aIidCreate function.
*
*/
void otSlaacUpdate(otInstance *aInstance, otNetifAddress *aAddresses, uint32_t aNumAddresses,
otSlaacIidCreate aIidCreate, void *aContext);
/**
* Create random IID for given IPv6 address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
*
*/
ThreadError otCreateRandomIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* Create IID for given IPv6 address using extended MAC address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[in] aContext A pointer to unused data.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
*
*/
ThreadError otCreateMacIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* Create semantically opaque IID for given IPv6 address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[inout] aAddress A pointer to structure containing IPv6 address for which IID is being created.
* @param[inout] aContext A pointer to a otSemanticallyOpaqueIidGeneratorData structure.
*
* @retval kThreadError_None Created valid IID for given IPv6 address.
* @retval kThreadError_Ipv6AddressCreationFailure Could not create valid IID for given IPv6 address.
*
*/
ThreadError otCreateSemanticallyOpaqueIid(otInstance *aInstance, otNetifAddress *aAddresses, void *aContext);
/**
* This function pointer is called to notify certain configuration or state changes within OpenThread.
*