This module includes functions that control IPv6 communication.
More...
|
otError | otIp6SetEnabled (otInstance *aInstance, bool aEnabled) |
|
bool | otIp6IsEnabled (otInstance *aInstance) |
|
otError | otIp6AddUnicastAddress (otInstance *aInstance, const otNetifAddress *aAddress) |
|
otError | otIp6RemoveUnicastAddress (otInstance *aInstance, const otIp6Address *aAddress) |
|
const otNetifAddress * | otIp6GetUnicastAddresses (otInstance *aInstance) |
|
otError | otIp6SubscribeMulticastAddress (otInstance *aInstance, const otIp6Address *aAddress) |
|
otError | otIp6UnsubscribeMulticastAddress (otInstance *aInstance, const otIp6Address *aAddress) |
|
const otNetifMulticastAddress * | otIp6GetMulticastAddresses (otInstance *aInstance) |
|
bool | otIp6IsMulticastPromiscuousEnabled (otInstance *aInstance) |
|
void | otIp6SetMulticastPromiscuousEnabled (otInstance *aInstance, bool aEnabled) |
|
otMessage * | otIp6NewMessage (otInstance *aInstance, const otMessageSettings *aSettings) |
|
otMessage * | otIp6NewMessageFromBuffer (otInstance *aInstance, const uint8_t *aData, uint16_t aDataLength, const otMessageSettings *aSettings) |
|
void | otIp6SetReceiveCallback (otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext) |
|
void | otIp6SetAddressCallback (otInstance *aInstance, otIp6AddressCallback aCallback, void *aCallbackContext) |
|
bool | otIp6IsReceiveFilterEnabled (otInstance *aInstance) |
|
void | otIp6SetReceiveFilterEnabled (otInstance *aInstance, bool aEnabled) |
|
otError | otIp6Send (otInstance *aInstance, otMessage *aMessage) |
|
otError | otIp6AddUnsecurePort (otInstance *aInstance, uint16_t aPort) |
|
otError | otIp6RemoveUnsecurePort (otInstance *aInstance, uint16_t aPort) |
|
void | otIp6RemoveAllUnsecurePorts (otInstance *aInstance) |
|
const uint16_t * | otIp6GetUnsecurePorts (otInstance *aInstance, uint8_t *aNumEntries) |
|
bool | otIp6IsAddressEqual (const otIp6Address *aFirst, const otIp6Address *aSecond) |
|
otError | otIp6AddressFromString (const char *aString, otIp6Address *aAddress) |
|
uint8_t | otIp6PrefixMatch (const otIp6Address *aFirst, const otIp6Address *aSecond) |
|
bool | otIp6IsAddressUnspecified (const otIp6Address *aAddress) |
|
otError | otIp6SelectSourceAddress (otInstance *aInstance, otMessageInfo *aMessageInfo) |
|
bool | otIp6IsSlaacEnabled (otInstance *aInstance) |
|
void | otIp6SetSlaacEnabled (otInstance *aInstance, bool aEnabled) |
|
void | otIp6SetSlaacPrefixFilter (otInstance *aInstance, otIp6SlaacPrefixFilter aFilter) |
|
This module includes functions that control IPv6 communication.
This structure represents an IPv6 address.
typedef void(* otIp6AddressCallback)(const otIp6Address *aAddress, uint8_t aPrefixLength, bool aIsAdded, void *aContext) |
This function pointer is called when an internal IPv6 address is added or removed.
- Parameters
-
[in] | aAddress | A pointer to the IPv6 address. |
[in] | aPrefixLength | The prefix length if aAddress is unicast address, and 128 for multicast address. |
[in] | aIsAdded | TRUE if the aAddress was added, FALSE if aAddress was removed. |
[in] | aContext | A pointer to application-specific context. |
This structure represents an IPv6 prefix.
typedef void(* otIp6ReceiveCallback)(otMessage *aMessage, void *aContext) |
This function pointer is called when an IPv6 datagram is received.
- Parameters
-
[in] | aMessage | A pointer to the message buffer containing the received IPv6 datagram. This function transfers the ownership of the aMessage to the receiver of the callback. The message should be freed by the receiver of the callback after it is processed (see otMessageFree()). |
[in] | aContext | A pointer to application-specific context. |
This function pointer allows user to filter prefixes and not allow an SLAAC address based on a prefix to be added.
otIp6SetSlaacPrefixFilter()
can be used to set the filter handler. The filter handler is invoked by SLAAC module when it is about to add a SLAAC address based on a prefix. Its boolean return value determines whether the address is filtered (not added) or not.
- Parameters
-
[in] | aInstacne | A pointer to an OpenThread instance. |
[in] | aPrefix | A pointer to prefix for which SLAAC address is about to be added. |
- Return values
-
TRUE | Indicates that the SLAAC address based on the prefix should be filtered and NOT added. |
FALSE | Indicates that the SLAAC address based on the prefix should be added. |
This structure represents the local and peer IPv6 socket addresses.
This structure represents an IPv6 network interface unicast address.
This structure represents an IPv6 network interface multicast address.
This structure represents an IPv6 socket address.
Convert a human-readable IPv6 address string into a binary representation.
- Parameters
-
[in] | aString | A pointer to a NULL-terminated string. |
[out] | aAddress | A pointer to an IPv6 address. |
- Return values
-
OT_ERROR_NONE | Successfully parsed the string. |
OT_ERROR_INVALID_ARGS | Failed to parse the string. |
Add a Network Interface Address to the Thread interface.
The passed-in instance aAddress
is copied by the Thread interface. The Thread interface only supports a fixed number of externally added unicast addresses. See OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aAddress | A pointer to a Network Interface Address. |
- Return values
-
OT_ERROR_NONE | Successfully added (or updated) the Network Interface Address. |
OT_ERROR_INVALID_ARGS | The IP Address indicated by aAddress is an internal address. |
OT_ERROR_NO_BUFS | The Network Interface is already storing the maximum allowed external addresses. |
This function adds a port to the allowed unsecured port list.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aPort | The port value. |
- Return values
-
OT_ERROR_NONE | The port was successfully added to the allowed unsecure port list. |
OT_ERROR_NO_BUFS | The unsecure port list is full. |
Get the list of IPv6 multicast addresses subscribed to the Thread interface.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
- Returns
- A pointer to the first Network Interface Multicast Address.
Get the list of IPv6 addresses assigned to the Thread interface.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
- Returns
- A pointer to the first Network Interface Address.
const uint16_t* otIp6GetUnsecurePorts |
( |
otInstance * |
aInstance, |
|
|
uint8_t * |
aNumEntries |
|
) |
| |
This function returns a pointer to the unsecure port list.
- Note
- Port value 0 is used to indicate an invalid entry.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[out] | aNumEntries | The number of entries in the list. |
- Returns
- A pointer to the unsecure port list.
Test if two IPv6 addresses are the same.
- Parameters
-
[in] | aFirst | A pointer to the first IPv6 address to compare. |
[in] | aSecond | A pointer to the second IPv6 address to compare. |
- Return values
-
TRUE | The two IPv6 addresses are the same. |
FALSE | The two IPv6 addresses are not the same. |
bool otIp6IsAddressUnspecified |
( |
const otIp6Address * |
aAddress | ) |
|
This function indicates whether or not a given IPv6 address is the Unspecified Address.
- Parameters
-
[in] | aAddress | A pointer to an IPv6 address. |
- Return values
-
TRUE | If the IPv6 address is the Unspecified Address. |
FALSE | If the IPv6 address is not the Unspecified Address. |
This function indicates whether or not the IPv6 interface is up.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
- Return values
-
TRUE | The IPv6 interface is enabled. |
FALSE | The IPv6 interface is disabled. |
bool otIp6IsMulticastPromiscuousEnabled |
( |
otInstance * |
aInstance | ) |
|
Check if multicast promiscuous mode is enabled on the Thread interface.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
- See also
- otIp6SetMulticastPromiscuousEnabled
bool otIp6IsReceiveFilterEnabled |
( |
otInstance * |
aInstance | ) |
|
bool otIp6IsSlaacEnabled |
( |
otInstance * |
aInstance | ) |
|
This function indicates whether the SLAAC module is enabled or not.
This function requires the build-time feature OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
to be enabled.
- Return values
-
TRUE | SLAAC module is enabled. |
FALSE | SLAAC module is disabled. |
Allocate a new message buffer for sending an IPv6 message.
- Note
- If
aSettings
is 'NULL', the link layer security is enabled and the message priority is set to OT_MESSAGE_PRIORITY_NORMAL by default.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aSettings | A pointer to the message settings or NULL to set default settings. |
- Returns
- A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
- See also
- otMessageFree
Allocate a new message buffer and write the IPv6 datagram to the message buffer for sending an IPv6 message.
- Note
- If
aSettings
is NULL, the link layer security is enabled and the message priority is obtained from IPv6 message itself. If aSettings
is not NULL, the aSetting->mPriority
is ignored and obtained from IPv6 message itself.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aData | A pointer to the IPv6 datagram buffer. |
[in] | aDataLength | The size of the IPv6 datagram buffer pointed by aData . |
[in] | aSettings | A pointer to the message settings or NULL to set default settings. |
- Returns
- A pointer to the message or NULL if malformed IPv6 header or insufficient message buffers are available.
- See also
- otMessageFree
This function returns the prefix match length (bits) for two IPv6 addresses.
- Parameters
-
[in] | aFirst | A pointer to the first IPv6 address. |
[in] | aSecond | A pointer to the second IPv6 address. |
- Returns
- The prefix match length in bits.
void otIp6RemoveAllUnsecurePorts |
( |
otInstance * |
aInstance | ) |
|
This function removes all ports from the allowed unsecure port list.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
Remove a Network Interface Address from the Thread interface.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aAddress | A pointer to an IP Address. |
- Return values
-
OT_ERROR_NONE | Successfully removed the Network Interface Address. |
OT_ERROR_INVALID_ARGS | The IP Address indicated by aAddress is an internal address. |
OT_ERROR_NOT_FOUND | The IP Address indicated by aAddress was not found. |
This function removes a port from the allowed unsecure port list.
- Note
- This function removes
aPort
by overwriting aPort
with the element after aPort
in the internal port list. Be careful when calling otIp6GetUnsecurePorts() followed by otIp6RemoveUnsecurePort() to remove unsecure ports.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aPort | The port value. |
- Return values
-
OT_ERROR_NONE | The port was successfully removed from the allowed unsecure port list. |
OT_ERROR_NOT_FOUND | The port was not found in the unsecure port list. |
This function perform OpenThread source address selection.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in,out] | aMessageInfo | A pointer to the message information. |
- Return values
-
OT_ERROR_NONE | Found a source address and is filled into mSockAddr of aMessageInfo . |
OT_ERROR_NOT_FOUND | No source address was found and aMessageInfo is unchanged. |
This function sends an IPv6 datagram via the Thread interface.
The caller transfers ownership of aMessage
when making this call. OpenThread will free aMessage
when processing is complete, including when a value other than OT_ERROR_NONE
is returned.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aMessage | A pointer to the message buffer containing the IPv6 datagram. |
- Return values
-
OT_ERROR_NONE | Successfully processed the message. |
OT_ERROR_DROP | Message was well-formed but not fully processed due to packet processing rules. |
OT_ERROR_NO_BUFS | Could not allocate necessary message buffers when processing the datagram. |
OT_ERROR_NO_ROUTE | No route to host. |
OT_ERROR_PARSE | Encountered a malformed header when processing the message. |
This function registers a callback to notify internal IPv6 address changes.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aCallback | A pointer to a function that is called when an internal IPv6 address is added or removed. NULL to disable the callback. |
[in] | aCallbackContext | A pointer to application-specific context. |
This function brings up/down the IPv6 interface.
Call this function to enable/disable IPv6 communication.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aEnabled | TRUE to enable IPv6, FALSE otherwise. |
- Return values
-
OT_ERROR_NONE | Successfully brought the IPv6 interface up/down. |
OT_ERROR_INVALID_STATE | IPv6 interface is not available since device is operating in raw-link mode (applicable only when OPENTHREAD_CONFIG_LINK_RAW_ENABLE feature is enabled). |
void otIp6SetMulticastPromiscuousEnabled |
( |
otInstance * |
aInstance, |
|
|
bool |
aEnabled |
|
) |
| |
Enable multicast promiscuous mode on the Thread interface.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aEnabled | TRUE to enable Multicast Promiscuous mode, FALSE otherwise. |
- See also
- otIp6IsMulticastPromiscuousEnabled
This function registers a callback to provide received IPv6 datagrams.
By default, this callback does not pass Thread control traffic. See otIp6SetReceiveFilterEnabled() to change the Thread control traffic filter setting.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aCallback | A pointer to a function that is called when an IPv6 datagram is received or NULL to disable the callback. |
[in] | aCallbackContext | A pointer to application-specific context. |
- See also
- otIp6IsReceiveFilterEnabled
-
otIp6SetReceiveFilterEnabled
void otIp6SetReceiveFilterEnabled |
( |
otInstance * |
aInstance, |
|
|
bool |
aEnabled |
|
) |
| |
This function sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams via the callback specified in otIp6SetReceiveCallback().
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aEnabled | TRUE if Thread control traffic is filtered out, FALSE otherwise. |
- See also
- otIp6SetReceiveCallback
-
otIsReceiveIp6FilterEnabled
void otIp6SetSlaacEnabled |
( |
otInstance * |
aInstance, |
|
|
bool |
aEnabled |
|
) |
| |
This function enables/disables the SLAAC module.
This function requires the build-time feature OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
to be enabled.
When SLAAC module is enabled, SLAAC addresses (based on on-mesh prefixes in Network Data) are added to the interface. When SLAAC module is disabled any previously added SLAAC address is removed.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aEnabled | TRUE to enable, FALSE to disable. |
This function sets the SLAAC module filter handler.
This function requires the build-time feature OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
to be enabled.
The filter handler is called by SLAAC module when it is about to add a SLAAC address based on a prefix to decide whether the address should be added or not.
A NULL filter handler disables filtering and allows all SLAAC addresses to be added.
If this function is not called, the default filter used by SLAAC module will be NULL (filtering is disabled).
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aFilter | A pointer to SLAAC prefix filter handler, or NULL to disable filtering. |
Subscribe the Thread interface to a Network Interface Multicast Address.
The passed in instance aAddress
will be copied by the Thread interface. The Thread interface only supports a fixed number of externally added multicast addresses. See OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aAddress | A pointer to an IP Address. |
- Return values
-
OT_ERROR_NONE | Successfully subscribed to the Network Interface Multicast Address. |
OT_ERROR_ALREADY | The multicast address is already subscribed. |
OT_ERROR_INVALID_ARGS | The IP Address indicated by aAddress is invalid address. |
OT_ERROR_INVALID_STATE | The Network Interface is not up. |
OT_ERROR_NO_BUFS | The Network Interface is already storing the maximum allowed external multicast addresses. |
Unsubscribe the Thread interface to a Network Interface Multicast Address.
- Parameters
-
[in] | aInstance | A pointer to an OpenThread instance. |
[in] | aAddress | A pointer to an IP Address. |
- Return values
-
OT_ERROR_NONE | Successfully unsubscribed to the Network Interface Multicast Address. |
OT_ERROR_INVALID_ARGS | The IP Address indicated by aAddress is an internal address. |
OT_ERROR_NOT_FOUND | The IP Address indicated by aAddress was not found. |