OpenThread  1.05.03.02
Data Structures | Macros | Typedefs | Functions | Variables

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...

+ Collaboration diagram for NAT64:

Data Structures

struct  otIp4Address
 
struct  otIp4Cidr
 

Macros

#define OT_IP4_ADDRESS_SIZE   4
 Size of an IPv4 address (bytes) More...
 

Typedefs

typedef struct otIp4Address otIp4Address
 
typedef struct otIp4Cidr otIp4Cidr
 
typedef void(* otNat64ReceiveIp4Callback) (otMessage *aMessage, void *aContext)
 

Functions

void otIp4ExtractFromIp6Address (uint8_t aPrefixLength, const otIp6Address *aIp6Address, otIp4Address *aIp4Address)
 
bool otIp4IsAddressEqual (const otIp4Address *aFirst, const otIp4Address *aSecond)
 
otMessageotIp4NewMessage (otInstance *aInstance, const otMessageSettings *aSettings)
 
otError otNat64Send (otInstance *aInstance, otMessage *aMessage)
 
otError otNat64SetIp4Cidr (otInstance *aInstance, const otIp4Cidr *aCidr)
 
void otNat64SetReceiveIp4Callback (otInstance *aInstance, otNat64ReceiveIp4Callback aCallback, void *aContext)
 

Variables

OT_TOOL_PACKED_BEGIN struct otIp4Address OT_TOOL_PACKED_END
 

Detailed Description

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.

Macro Definition Documentation

§ OT_IP4_ADDRESS_SIZE

#define OT_IP4_ADDRESS_SIZE   4

Size of an IPv4 address (bytes)

Typedef Documentation

§ otIp4Address

typedef struct otIp4Address otIp4Address

This structure represents an IPv4 address.

§ otIp4Cidr

typedef struct otIp4Cidr 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]aMessageA 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]aContextA pointer to application-specific context.

Function Documentation

§ otIp4NewMessage()

otMessage* otIp4NewMessage ( otInstance aInstance,
const otMessageSettings aSettings 
)

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]aInstanceA pointer to an OpenThread instance.
[in]aSettingsA 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()

otError otNat64SetIp4Cidr ( otInstance aInstance,
const otIp4Cidr aCidr 
)

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]aInstanceA pointer to an OpenThread instance.
[in]aCidrA pointer to an otIp4Cidr for the IPv4 CIDR block for NAT64.
Return values
OT_ERROR_INVALID_ARGSThe given CIDR is not a valid IPv4 CIDR for NAT64.
OT_ERROR_NONESuccessfully set the CIDR for NAT64.
See also
otBorderRouterSend
otBorderRouterSetReceiveCallback

Referenced by otSysGetThreadNetifIndex().

§ otNat64Send()

otError otNat64Send ( otInstance aInstance,
otMessage aMessage 
)

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]aInstanceA pointer to an OpenThread instance.
[in]aMessageA pointer to the message buffer containing the IPv4 datagram.
Return values
OT_ERROR_NONESuccessfully processed the message.
OT_ERROR_DROPMessage was well-formed but not fully processed due to packet processing rules.
OT_ERROR_NO_BUFSCould not allocate necessary message buffers when processing the datagram.
OT_ERROR_NO_ROUTENo route to host.
OT_ERROR_INVALID_SOURCE_ADDRESSSource address is invalid, e.g. an anycast address or a multicast address.
OT_ERROR_PARSEEncountered a malformed header when processing the message.

Referenced by otSysGetThreadNetifIndex().

§ otNat64SetReceiveIp4Callback()

void otNat64SetReceiveIp4Callback ( otInstance aInstance,
otNat64ReceiveIp4Callback  aCallback,
void *  aContext 
)

Registers a callback to provide received IPv4 datagrams.

Parameters
[in]aInstanceA pointer to an OpenThread instance.
[in]aCallbackA pointer to a function that is called when an IPv4 datagram is received or NULL to disable the callback.
[in]aCallbackContextA pointer to application-specific context.

Referenced by otSysGetThreadNetifIndex().

§ otIp4IsAddressEqual()

bool otIp4IsAddressEqual ( const otIp4Address aFirst,
const otIp4Address aSecond 
)

Test if two IPv4 addresses are the same.

Parameters
[in]aFirstA pointer to the first IPv4 address to compare.
[in]aSecondA pointer to the second IPv4 address to compare.
Return values
TRUEThe two IPv4 addresses are the same.
FALSEThe two IPv4 addresses are not the same.

References ot::AsCoreType().

§ otIp4ExtractFromIp6Address()

void otIp4ExtractFromIp6Address ( uint8_t  aPrefixLength,
const otIp6Address aIp6Address,
otIp4Address aIp4Address 
)

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]aPrefixLengthThe prefix length to use for IPv4/IPv6 translation.
[in]aIp6AddressA pointer to an IPv6 address.
[out]aIp4AddressA pointer to output the IPv4 address.

References ot::AsCoreType().

Variable Documentation

§ OT_TOOL_PACKED_END

OT_TOOL_PACKED_BEGIN struct otIp4Address OT_TOOL_PACKED_END
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale