# ICMPv6

# ICMPv6

This module includes functions that control ICMPv6 communication.

## Summary

| ### Enumerations ||
|---|---|
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaa450e86d1ce189d9e63fbac579b7ed52{ https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaa450e86d1ce189d9e63fbac579b7ed52a77d2963da7877c8ba0e6271133f48085 = 0, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaa450e86d1ce189d9e63fbac579b7ed52a65b8f254ce901e5d6a9096b8251d0122 = 1, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaa450e86d1ce189d9e63fbac579b7ed52a727986c748ebb9160f88f6dc87477753 = 1 }` | enumICMPv6 Message Codes. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaf0f7322f337d6ee09400573034f31112{ https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaf0f7322f337d6ee09400573034f31112a31a4ed520fea54919883d30c580a2a26 = 0, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaf0f7322f337d6ee09400573034f31112a5d4148df384fceba9a351cfdc9f04cba = 1, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaf0f7322f337d6ee09400573034f31112aa4a92cb882089c4b5a77050a59b63037 = 2, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaf0f7322f337d6ee09400573034f31112a61110f67064e8de91338410eace9ba04 = 3, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ggaf0f7322f337d6ee09400573034f31112ac3c7040b88cdf70db8f355c5704eef54 = 4 }` | enumICMPv6 Echo Reply Modes. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga46eca7be8d616e02e989eabee82aed74{ https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a4d49cfc7ec111c6c3cb57998c7deb96b = 1, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74ade2e81fc60cf551cd41a25b8017bb0be = 2, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a6343e318b4d66afa0574e7a62b06a717 = 3, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a9368ae68607872d91e63fd6f16de4911 = 4, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a962d7aa89495bf45fd4ddbf4d1cbbce9 = 128, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74ae58b36375748bd0f6c45529bf262b105 = 129, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a50c884c6e586070050512dab93f7a0df = 133, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a791de3190461cdbde6feff174f1bfe60 = 134, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74ad3f715b86cb9497e7bb3c8d8673b363d = 135, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gga46eca7be8d616e02e989eabee82aed74a13b4fb58de7a39b26e113445399df372 = 136 }` | enumICMPv6 Message Types. |

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga985908b790ddbf3667413e1ea5524238` | typedef `enum https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaa450e86d1ce189d9e63fbac579b7ed52` ICMPv6 Message Codes. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gab040942193e813d4c0a97b6391bf4715` | typedef `enum https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaf0f7322f337d6ee09400573034f31112` ICMPv6 Echo Reply Modes. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga94e7b1d64c53e6af3e31852c20604890` | typedef `struct https://openthread.io/reference/struct/ot-icmp6-handler` Implements ICMPv6 message handler. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaf42fe0068268c0b83bb582051ef14a38` | typedef `struct https://openthread.io/reference/struct/ot-icmp6-header` Represents an ICMPv6 header. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga8e6867a15dec97de6ff79bc5b36d6d94)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otIcmp6Header *aIcmpHeader)` | typedef `void(*` This callback allows OpenThread to inform the application of a received ICMPv6 message. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga2439b605551cd48970716113404e9089` | typedef `enum https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga46eca7be8d616e02e989eabee82aed74` ICMPv6 Message Types. |

| ### Variables ||
|---|---|
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gabe694b357b1601d7dbc7b470843edc03` | `https://openthread.io/reference/group/plat-toolchain#group__plat-toolchain_1gaba6ad63129c3a790957a9b149a65891b struct https://openthread.io/reference/struct/ot-icmp6-header` |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga11cec3f91f1a6029fe260456be2e18af(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaf0f7322f337d6ee09400573034f31112` Indicates whether or not ICMPv6 Echo processing is enabled. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gab9a082038baf6cbecb214c438d295475(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/struct/ot-icmp6-handler *aHandler)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Registers a handler to provide received ICMPv6 messages. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga04e32eb170938e020fb6c9ed3101300f(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, const https://openthread.io/reference/struct/ot-message-info *aMessageInfo, uint16_t aIdentifier)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Sends an ICMPv6 Echo Request via the Thread interface. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga847de8e01d0c5470d9bc0e7b1a5055a9(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1gaf0f7322f337d6ee09400573034f31112 aMode)` | `void` Sets whether or not ICMPv6 Echo processing is enabled. |

| ### Macros ||
|---|---|
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga0210879c5d3311331c16428fad8521d3 4` | Size of ICMPv6 Header. |
| `https://openthread.io/reference/group/api-icmp6#group__api-icmp6_1ga5c9416f7bcdcf3bbe6a128fd31b10959 16` | Size of a Router Advertisement message without any options. |

| ### Structs ||
|---|---|
| [otIcmp6Handler](https://openthread.io/reference/struct/ot-icmp6-handler) | Implements ICMPv6 message handler. |
| [otIcmp6Header](https://openthread.io/reference/struct/ot-icmp6-header) | Represents an ICMPv6 header. |

| ### Unions ||
|---|---|
| [otIcmp6Header::OT_TOOL_PACKED_FIELD](https://openthread.io/reference/union/ot-icmp6-header/o-t-t-o-o-l-p-a-c-k-e-d-f-i-e-l-d) |   |

## Enumerations

### otIcmp6Code

```
 otIcmp6Code
```
ICMPv6 Message Codes.

| Properties ||
|---|---|
| `OT_ICMP6_CODE_DST_UNREACH_NO_ROUTE` | Destination Unreachable (Type 1) - No Route. |
| `OT_ICMP6_CODE_DST_UNREACH_PROHIBITED` | Destination Unreachable (Type 1) - Administratively Prohibited. |
| `OT_ICMP6_CODE_FRAGM_REAS_TIME_EX` | Time Exceeded (Type 3) - Fragment Reassembly. |

### otIcmp6EchoMode

```
 otIcmp6EchoMode
```
ICMPv6 Echo Reply Modes.

| Properties ||
|---|---|
| `OT_ICMP6_ECHO_HANDLER_ALL` | ICMPv6 Echo processing enabled for unicast and multicast requests. |
| `OT_ICMP6_ECHO_HANDLER_DISABLED` | ICMPv6 Echo processing disabled. |
| `OT_ICMP6_ECHO_HANDLER_MULTICAST_ONLY` | ICMPv6 Echo processing enabled only for multicast requests only. |
| `OT_ICMP6_ECHO_HANDLER_RLOC_ALOC_ONLY` | ICMPv6 Echo processing enabled for RLOC/ALOC destinations only. |
| `OT_ICMP6_ECHO_HANDLER_UNICAST_ONLY` | ICMPv6 Echo processing enabled only for unicast requests only. |

### otIcmp6Type

```
 otIcmp6Type
```
ICMPv6 Message Types.

| Properties ||
|---|---|
| `OT_ICMP6_TYPE_DST_UNREACH` | Destination Unreachable. |
| `OT_ICMP6_TYPE_ECHO_REPLY` | Echo Reply. |
| `OT_ICMP6_TYPE_ECHO_REQUEST` | Echo Request. |
| `OT_ICMP6_TYPE_NEIGHBOR_ADVERT` | Neighbor Advertisement. |
| `OT_ICMP6_TYPE_NEIGHBOR_SOLICIT` | Neighbor Solicitation. |
| `OT_ICMP6_TYPE_PACKET_TO_BIG` | Packet To Big. |
| `OT_ICMP6_TYPE_PARAMETER_PROBLEM` | Parameter Problem. |
| `OT_ICMP6_TYPE_ROUTER_ADVERT` | Router Advertisement. |
| `OT_ICMP6_TYPE_ROUTER_SOLICIT` | Router Solicitation. |
| `OT_ICMP6_TYPE_TIME_EXCEEDED` | Time Exceeded. |

## Typedefs

### otIcmp6Code

```
enum otIcmp6Code otIcmp6Code
```
ICMPv6 Message Codes.

### otIcmp6EchoMode

```
enum otIcmp6EchoMode otIcmp6EchoMode
```
ICMPv6 Echo Reply Modes.

### otIcmp6Handler

```
struct otIcmp6Handler otIcmp6Handler
```
Implements ICMPv6 message handler.

### otIcmp6Header

```
struct otIcmp6Header otIcmp6Header
```
Represents an ICMPv6 header.

### otIcmp6ReceiveCallback

```
void(* otIcmp6ReceiveCallback)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otIcmp6Header *aIcmpHeader)
```
This callback allows OpenThread to inform the application of a received ICMPv6 message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aContext` | A pointer to arbitrary context information. | | `[in] aMessage` | A pointer to the received message. | | `[in] aMessageInfo` | A pointer to message information associated with `aMessage`. | | `[in] aIcmpHeader` | A pointer to the received ICMPv6 header. | |

### otIcmp6Type

```
enum otIcmp6Type otIcmp6Type
```
ICMPv6 Message Types.

## Variables

### OT_TOOL_PACKED_END

```
OT_TOOL_PACKED_BEGIN struct otIcmp6Header OT_TOOL_PACKED_END
```

## Functions

### otIcmp6GetEchoMode

```
otIcmp6EchoMode otIcmp6GetEchoMode(
  otInstance *aInstance
)
```
Indicates whether or not ICMPv6 Echo processing is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_ICMP6_ECHO_HANDLER_DISABLED` | ICMPv6 Echo processing is disabled. | | `OT_ICMP6_ECHO_HANDLER_UNICAST_ONLY` | ICMPv6 Echo processing enabled for unicast requests only | | `OT_ICMP6_ECHO_HANDLER_MULTICAST_ONLY` | ICMPv6 Echo processing enabled for multicast requests only | | `OT_ICMP6_ECHO_HANDLER_ALL` | ICMPv6 Echo processing enabled for unicast and multicast requests | |

### otIcmp6RegisterHandler

```
otError otIcmp6RegisterHandler(
  otInstance *aInstance,
  otIcmp6Handler *aHandler
)
```
Registers a handler to provide received ICMPv6 messages.


> [!NOTE]
> **Note:** A handler structure `aHandler` has to be stored in persistent (static) memory. OpenThread does not make a copy of handler structure.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aHandler` | A pointer to a handler containing callback that is called when an ICMPv6 message is received. | |

### otIcmp6SendEchoRequest

```
otError otIcmp6SendEchoRequest(
  otInstance *aInstance,
  otMessage *aMessage,
  const otMessageInfo *aMessageInfo,
  uint16_t aIdentifier
)
```
Sends an ICMPv6 Echo Request via the Thread interface.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aMessage` | A pointer to the message buffer containing the ICMPv6 payload. | | `[in] aMessageInfo` | A reference to message information associated with `aMessage`. | | `[in] aIdentifier` | An identifier to aid in matching Echo Replies to this Echo Request. May be zero. | |

### otIcmp6SetEchoMode

```
void otIcmp6SetEchoMode(
  otInstance *aInstance,
  otIcmp6EchoMode aMode
)
```
Sets whether or not ICMPv6 Echo processing is enabled.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aMode` | The ICMPv6 Echo processing mode. | |

## Macros

### OT_ICMP6_HEADER_DATA_SIZE

```
 OT_ICMP6_HEADER_DATA_SIZE 4
```
Size of ICMPv6 Header.

### OT_ICMP6_ROUTER_ADVERT_MIN_SIZE

```
 OT_ICMP6_ROUTER_ADVERT_MIN_SIZE 16
```
Size of a Router Advertisement message without any options.

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