This module includes functions and structs for the NAT64 function on the border router. These functions are only available when OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE is enabled.
More...
This module includes functions and structs for the NAT64 function on the border router. These functions are only available when OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE is enabled.
§ OT_IP4_ADDRESS_SIZE
| #define OT_IP4_ADDRESS_SIZE 4 |
Size of an IPv4 address (bytes)
§ otIp4Address
This structure represents an IPv4 address.
§ otIp4Cidr
§ otNat64ReceiveIp4Callback
| typedef void(* otNat64ReceiveIp4Callback) (otMessage *aMessage, void *aContext) |
This function pointer is called when an IPv4 datagram (translated by NAT64 translator) 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. |
| [in] | aContext | A pointer to application-specific context. |
§ otIp4NewMessage()
Allocate a new message buffer for sending an IPv4 message to the NAT64 translator.
Message buffers allocated by this function will have 20 bytes (difference between the size of IPv6 headers and IPv4 header sizes) reserved.
This function is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled.
- 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
- otNat64Send
Referenced by otSysGetThreadNetifIndex().
§ otNat64SetIp4Cidr()
Sets the CIDR used when setting the source address of the outgoing translated IPv4 packets.
This function is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled.
- Note
- A valid CIDR must have a non-zero prefix length. The actual addresses pool is limited by the size of the mapping pool and the number of addresses available in the CIDR block.
-
This function can be called at any time, but the NAT64 translator will be reset and all existing sessions will be expired when updating the configured CIDR.
- Parameters
-
| [in] | aInstance | A pointer to an OpenThread instance. |
| [in] | aCidr | A pointer to an otIp4Cidr for the IPv4 CIDR block for NAT64. |
- Return values
-
| OT_ERROR_INVALID_ARGS | The given CIDR is not a valid IPv4 CIDR for NAT64. |
| OT_ERROR_NONE | Successfully set the CIDR for NAT64. |
- See also
- otBorderRouterSend
-
otBorderRouterSetReceiveCallback
Referenced by otSysGetThreadNetifIndex().
§ otNat64Send()
Translates an IPv4 datagram to an IPv6 datagram and sends 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 IPv4 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_INVALID_SOURCE_ADDRESS | Source address is invalid, e.g. an anycast address or a multicast address. |
| OT_ERROR_PARSE | Encountered a malformed header when processing the message. |
Referenced by otSysGetThreadNetifIndex().
§ otNat64SetReceiveIp4Callback()
Registers a callback to provide received IPv4 datagrams.
- Parameters
-
| [in] | aInstance | A pointer to an OpenThread instance. |
| [in] | aCallback | A pointer to a function that is called when an IPv4 datagram is received or NULL to disable the callback. |
| [in] | aCallbackContext | A pointer to application-specific context. |
Referenced by otSysGetThreadNetifIndex().
§ otIp4IsAddressEqual()
Test if two IPv4 addresses are the same.
- Parameters
-
| [in] | aFirst | A pointer to the first IPv4 address to compare. |
| [in] | aSecond | A pointer to the second IPv4 address to compare. |
- Return values
-
| TRUE | The two IPv4 addresses are the same. |
| FALSE | The two IPv4 addresses are not the same. |
References ot::AsCoreType().
§ otIp4ExtractFromIp6Address()
Set aIp4Address by performing NAT64 address translation from aIp6Address as specified in RFC 6052.
The NAT64 aPrefixLength MUST be one of the following values: 32, 40, 48, 56, 64, or 96, otherwise the behavior of this method is undefined.
- Parameters
-
| [in] | aPrefixLength | The prefix length to use for IPv4/IPv6 translation. |
| [in] | aIp6Address | A pointer to an IPv6 address. |
| [out] | aIp4Address | A pointer to output the IPv4 address. |
References ot::AsCoreType().
§ OT_TOOL_PACKED_END