# Infrastructure Interface

# Infrastructure Interface

This module includes the platform abstraction for the adjacent infrastructure network interface.

## Summary

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gaed1029fd855460388a860c4d3f40e065` | typedef `struct https://openthread.io/reference/struct/ot-plat-infra-if-link-layer-address` Represents an InfraIf Link-Layer Address. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gaaf88d52213f986beb48a25bdf2150e7e(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aIfIndex, https://openthread.io/reference/struct/ot-plat-infra-if-link-layer-address *aInfraIfLinkLayerAddress)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Get the link-layer address of the infrastructure interface. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga60ff89720a47be57fd1fa21c0af4d5d5(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, uint32_t aInfraIfIndex)` | `void` Callback from the platform to notify the OpenThread stack of a received DHCPv6 message. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gae7ff11215dca594976a9c8eb42db82ec(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, https://openthread.io/reference/struct/ot-ip6-address *aDestAddress, uint32_t aInfraIfIndex)` | `void` Sends a DHCPv6 message to a unicast or multicast destination address. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga058e220b023a029b870cf9413db4ef77(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aEnable, uint32_t aInfraIfIndex)` | `void` Enables or disables listening for DHCPv6 Prefix Delegation (PD) messages on client. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gab0cdc4a831714d1df3be62ccda420ad3(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Send a request to discover the NAT64 prefix on the infrastructure interface with `aInfraIfIndex`. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga93baa62c14f5edf942be770b1d304b48(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex, const https://openthread.io/reference/struct/ot-ip6-prefix *aIp6Prefix)` | `void` The infra interface driver calls this method to notify OpenThread that the discovery of NAT64 prefix is done. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gaf37b6f1d518fc69a75fea72abc313fb7(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex, const https://openthread.io/reference/struct/ot-ip6-address *aAddress)` | `bool` Tells whether an infra interface has the given IPv6 address assigned. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga835bd546c900b9561348cba1b1537327(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex, const https://openthread.io/reference/struct/ot-ip6-address *aSrcAddress, const uint8_t *aBuffer, uint16_t aBufferLength)` | `void` The infra interface driver calls this method to notify OpenThread that an ICMPv6 Neighbor Discovery message is received. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1gac6ff5ef19c5ffe31b24c6456fed01a85(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex, const https://openthread.io/reference/struct/ot-ip6-address *aDestAddress, const uint8_t *aBuffer, uint16_t aBufferLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends an ICMPv6 Neighbor Discovery message on given infrastructure interface. |
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga972ec6661c5c3f2d917dbb55a954f622(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, uint32_t aInfraIfIndex, bool aIsRunning)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` The infra interface driver calls this method to notify OpenThread of the interface state changes. |

| ### Macros ||
|---|---|
| `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga7b1119f8415588fbbf0316b1776d0445 16` | Maximum InfraIf Link-layer address length. |

| ### Structs ||
|---|---|
| [otPlatInfraIfLinkLayerAddress](https://openthread.io/reference/struct/ot-plat-infra-if-link-layer-address) | Represents an InfraIf Link-Layer Address. |

## Typedefs

### otPlatInfraIfLinkLayerAddress

```
struct otPlatInfraIfLinkLayerAddress otPlatInfraIfLinkLayerAddress
```
Represents an InfraIf Link-Layer Address.

## Functions

### otPlatGetInfraIfLinkLayerAddress

```
otError otPlatGetInfraIfLinkLayerAddress(
  otInstance *aInstance,
  uint32_t aIfIndex,
  otPlatInfraIfLinkLayerAddress *aInfraIfLinkLayerAddress
)
```
Get the link-layer address of the infrastructure interface.

OpenThread invokes this method when the address is required, for example: when generating an ND6 message which includes a source link-layer address option.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aInfraIfIndex` | The index of the infrastructure interface. | | `[out] aInfraIfLinkLayerAddress` | A pointer to infrastructure interface link-layer address. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully get the infrastructure interface link-layer address. | | `OT_ERROR_FAILED` | Failed to get the infrastructure interface link-layer address. | |

### otPlatInfraIfDhcp6PdClientHandleReceived

```
void otPlatInfraIfDhcp6PdClientHandleReceived(
  otInstance *aInstance,
  otMessage *aMessage,
  uint32_t aInfraIfIndex
)
```
Callback from the platform to notify the OpenThread stack of a received DHCPv6 message.

This function is provided when `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` is enabled.

The platform calls this function whenever a DHCPv6 message is received on the client port (546) while listening on this port is enabled (refer to `https://openthread.io/reference/group/plat-infra-if#group__plat-infra-if_1ga058e220b023a029b870cf9413db4ef77`).

The platform is responsible for allocating the `otMessage` to pass the received UDP payload. Ownership of the `aMessage` is passed to the OpenThread stack (which will free it once no longer needed).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aMessage` | The `otMessage` containing the received DHCPv6 payload. Ownership is passed to OT stack. | | `[in] aInfraIfIndex` | The index of the infrastructure interface from which the message was received.. | |

### otPlatInfraIfDhcp6PdClientSend

```
void otPlatInfraIfDhcp6PdClientSend(
  otInstance *aInstance,
  otMessage *aMessage,
  otIp6Address *aDestAddress,
  uint32_t aInfraIfIndex
)
```
Sends a DHCPv6 message to a unicast or multicast destination address.

This function is only used when `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` is enabled.

The platform is responsible for constructing a UDP datagram with the given DHCPv6 message as its payload. The datagram must be sent from the DHCPv6 client port (546) to the server port (547) on the specified infrastructure interface. The destination IPv6 address can be a unicast address or the multicast `All_DHCP_Relay_Agents_and_Servers` address (`ff02::1:2`).

This function passes the ownership of `aMessage` to the platform layer. Platform MUST then free the message when no longer needed.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aMessage` | An `otMessage` containing the DHCPv6 payload. Ownership is passed to the platform layer. | | `[in] aDestAddress` | The IPv6 multicast or unicast destination address. | | `[in] aInfraIfIndex` | The index of the infrastructure interface from which to send the message. | |

### otPlatInfraIfDhcp6PdClientSetListeningEnabled

```
void otPlatInfraIfDhcp6PdClientSetListeningEnabled(
  otInstance *aInstance,
  bool aEnable,
  uint32_t aInfraIfIndex
)
```
Enables or disables listening for DHCPv6 Prefix Delegation (PD) messages on client.

This function is only used when `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` is enabled.

When enabled, the platform must open a UDP socket on the specified infrastructure interface, binding to the DHCPv6 client port 546 to receive messages from DHCPv6 servers.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aEnable` | A boolean to enable (`true`) or disable (`false`) listening. | | `[in] aInfraIfIndex` | The index of the infrastructure interface to operate on. | |

### otPlatInfraIfDiscoverNat64Prefix

```
otError otPlatInfraIfDiscoverNat64Prefix(
  otInstance *aInstance,
  uint32_t aInfraIfIndex
)
```
Send a request to discover the NAT64 prefix on the infrastructure interface with `aInfraIfIndex`.

OpenThread will call this method periodically to monitor the presence or change of NAT64 prefix.


> [!NOTE]
> **Note:** This function requests the platform to discover a NAT64 prefix (e.g. using RFC 7050 DNS-based discovery). The priority of the discovered prefix is lower than that of the prefix discovered via Router Advertisements PREF64 option (RFC 8781).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aInfraIfIndex` | The index of the infrastructure interface to discover the NAT64 prefix. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully requested NAT64 prefix discovery. | | `OT_ERROR_FAILED` | Failed to request NAT64 prefix discovery. | | `OT_ERROR_NOT_IMPLEMENTED` | Platform does not support this discovery method. will rely on RA-based mechanism. | |

### otPlatInfraIfDiscoverNat64PrefixDone

```
void otPlatInfraIfDiscoverNat64PrefixDone(
  otInstance *aInstance,
  uint32_t aInfraIfIndex,
  const otIp6Prefix *aIp6Prefix
)
```
The infra interface driver calls this method to notify OpenThread that the discovery of NAT64 prefix is done.

Is expected to be invoked after calling otPlatInfraIfDiscoverNat64Prefix. If no NAT64 prefix is discovered, `aIp6Prefix` shall point to an empty prefix with zero length.


> [!NOTE]
> **Note:** This function is used to report a NAT64 prefix discovered by the platform (e.g. using RFC 7050 DNS-based discovery). The priority of the discovered prefix is lower than that of the prefix discovered via Router Advertisements PREF64 option (RFC 8781).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aInfraIfIndex` | The index of the infrastructure interface on which the NAT64 prefix is discovered. | | `[in] aIp6Prefix` | A pointer to NAT64 prefix. | |

### otPlatInfraIfHasAddress

```
bool otPlatInfraIfHasAddress(
  otInstance *aInstance,
  uint32_t aInfraIfIndex,
  const otIp6Address *aAddress
)
```
Tells whether an infra interface has the given IPv6 address assigned.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aInfraIfIndex` | The index of the infra interface. | | `[in] aAddress` | The IPv6 address. | |
| **Returns** | TRUE if the infra interface has given IPv6 address assigned, FALSE otherwise. |

### otPlatInfraIfRecvIcmp6Nd

```
void otPlatInfraIfRecvIcmp6Nd(
  otInstance *aInstance,
  uint32_t aInfraIfIndex,
  const otIp6Address *aSrcAddress,
  const uint8_t *aBuffer,
  uint16_t aBufferLength
)
```
The infra interface driver calls this method to notify OpenThread that an ICMPv6 Neighbor Discovery message is received.

See RFC 4861: <https://tools.ietf.org/html/rfc4861>.


> [!NOTE]
> **Note:** Per RFC 4861, the caller should enforce that the source address MUST be a IPv6 link-local address and the IP Hop Limit MUST be 255.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aInfraIfIndex` | The index of the infrastructure interface on which the ICMPv6 message is received. | | `[in] aSrcAddress` | The source address this message is received from. | | `[in] aBuffer` | The ICMPv6 message buffer. | | `[in] aBufferLength` | The length of the ICMPv6 message buffer. | |

### otPlatInfraIfSendIcmp6Nd

```
otError otPlatInfraIfSendIcmp6Nd(
  otInstance *aInstance,
  uint32_t aInfraIfIndex,
  const otIp6Address *aDestAddress,
  const uint8_t *aBuffer,
  uint16_t aBufferLength
)
```
Sends an ICMPv6 Neighbor Discovery message on given infrastructure interface.

See RFC 4861: <https://tools.ietf.org/html/rfc4861>.


> [!NOTE]
> **Note:** Per RFC 4861, the implementation should send the message with IPv6 link-local source address of interface `aInfraIfIndex` and IP Hop Limit 255.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance. | | `[in] aInfraIfIndex` | The index of the infrastructure interface this message is sent to. | | `[in] aDestAddress` | The destination address this message is sent to. | | `[in] aBuffer` | The ICMPv6 message buffer. The ICMPv6 checksum is left zero and the platform should do the checksum calculate. | | `[in] aBufferLength` | The length of the message buffer. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully sent the ICMPv6 message. | | `OT_ERROR_FAILED` | Failed to send the ICMPv6 message. | |

### otPlatInfraIfStateChanged

```
otError otPlatInfraIfStateChanged(
  otInstance *aInstance,
  uint32_t aInfraIfIndex,
  bool aIsRunning
)
```
The infra interface driver calls this method to notify OpenThread of the interface state changes.

It is fine for the platform to call to method even when the running state of the interface hasn't changed. In this case, the Routing Manager state is not affected.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | The OpenThread instance structure. | | `[in] aInfraIfIndex` | The index of the infrastructure interface. | | `[in] aIsRunning` | A boolean that indicates whether the infrastructure interface is running. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully updated the infra interface status. | | `OT_ERROR_INVALID_STATE` | The Routing Manager is not initialized. | | `OT_ERROR_INVALID_ARGS` | The `aInfraIfIndex` doesn't match the infra interface the Routing Manager are initialized with. | |

## Macros

### OT_PLAT_INFRA_IF_MAX_LINK_LAYER_ADDR_LENGTH

```
 OT_PLAT_INFRA_IF_MAX_LINK_LAYER_ADDR_LENGTH 16
```
Maximum InfraIf Link-layer address length.

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).