# Message

This module includes functions that manipulate OpenThread message buffers.

## Summary

| ### Enumerations ||
|---|---|
| `https://openthread.io/reference/group/api-message#group__api-message_1gab45120482c382618d9c075d7bf61a6d3{ https://openthread.io/reference/group/api-message#group__api-message_1ggab45120482c382618d9c075d7bf61a6d3a742bb10059cc6366799ed63cbc25e736 = 0, https://openthread.io/reference/group/api-message#group__api-message_1ggab45120482c382618d9c075d7bf61a6d3ae79a038fd2dd521c056e67a2f748ef6f = 1, https://openthread.io/reference/group/api-message#group__api-message_1ggab45120482c382618d9c075d7bf61a6d3a8937e4f4fa6caf46966c897c2eab56d0 = 2 }` | enumDefines the OpenThread message origins. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gafb260c302eeeeb1a29dce59f7c86d18b{ https://openthread.io/reference/group/api-message#group__api-message_1ggafb260c302eeeeb1a29dce59f7c86d18ba3b16d79c57f28c2f525d790897c26631 = 0, https://openthread.io/reference/group/api-message#group__api-message_1ggafb260c302eeeeb1a29dce59f7c86d18ba488f5dc3b298571ef13f603ebfbca25e = 1, https://openthread.io/reference/group/api-message#group__api-message_1ggafb260c302eeeeb1a29dce59f7c86d18ba64a2c55a23103e3249a3d049156eaf31 = 2 }` | enumDefines the OpenThread message priority levels. |

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-message#group__api-message_1gaadcdabf89dd602ab60efa78fad4f011f` | typedef `struct https://openthread.io/reference/struct/ot-buffer-info` Represents the message buffer information for different queues used by OpenThread stack. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955` | typedef `struct https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955` An opaque representation of an OpenThread message buffer. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga479669788b481d3b9966fcbf64518234` | typedef `enum https://openthread.io/reference/group/api-message#group__api-message_1gab45120482c382618d9c075d7bf61a6d3` Defines the OpenThread message origins. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaeea6ac34b255ce40ede10862e7178a70` | typedef `enum https://openthread.io/reference/group/api-message#group__api-message_1gafb260c302eeeeb1a29dce59f7c86d18b` Defines the OpenThread message priority levels. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga575412dabfad22d96324ba33fc77fc71` | typedef `struct https://openthread.io/reference/struct/ot-message-queue-info` Represents information about a message queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaf37e48e3a23d9c9349abd2676a343e42` | typedef `struct https://openthread.io/reference/struct/ot-message-settings` Represents a message settings. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga8a6d81b00ed4a6fde623d5b377bd130b)(const otMessage *aMessage, otError aError, void *aContext)` | typedef `void(*` Represents the callback function pointer to notify the transmission outcome (success or failure) of a message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaf28392143bbd4560da020a86098ad831` | typedef `struct https://openthread.io/reference/struct/ot-thread-link-info` Represents link-specific information for messages received from the Thread radio. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, const void *aBuf, uint16_t aLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Append bytes to a message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga4e70c0b700cf87ee7a9827c4e8cb4ae6(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *` Creates a clone of a given message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `void` Free an allocated message buffer. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga46a0fcbffb8239ea24e343c2f154cc0e(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/struct/ot-buffer-info *aBufferInfo)` | `void` Get the Message Buffer information. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gab261d5a01de0e80274029bb8a194055d(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *` Gets the `otInstance` associated with a given message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `uint16_t` Get the message length in bytes. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `uint16_t` Get the message offset in bytes. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga9fbb38f17795f5c3e1afdedd71010cfb(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `https://openthread.io/reference/group/api-message#group__api-message_1gab45120482c382618d9c075d7bf61a6d3` Gets the message origin. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga0a3269120475ee876e2e655219dea16f(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `int8_t` Returns the average RSS (received signal strength) associated with the message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga190106c402cdb094ec2d3168ada5fac5(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, https://openthread.io/reference/struct/ot-thread-link-info *aLinkInfo)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Retrieves the link-specific information for a message received over Thread radio. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga6d253c0e4d97684e7e31a46abb6c25bc(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `bool` Indicates whether or not link security is enabled for the message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga05514a4dc01eb7ebe1c6fc5330fd97f2(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `bool` Indicates whether or not the message is allowed to be looped back to host. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga72fb7f1253839d49d887b4df00fe4e71(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `bool` Indicates whether the given message may be looped back in a case of a multicast destination address. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaa81d3473b9073d90411389544c89c017(https://openthread.io/reference/struct/ot-message-queue *aQueue, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `void` Removes a message from the given message queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga7e8d3a257a275c87112b8f54bc95696e(https://openthread.io/reference/struct/ot-message-queue *aQueue, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `void` Adds a message to the end of the given message queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaa72353af61f09d8eb945e027ef248de5(https://openthread.io/reference/struct/ot-message-queue *aQueue, https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `void` Adds a message at the head/front of the given message queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga71b38c9c904ecead877e9f344e213513(https://openthread.io/reference/struct/ot-message-queue *aQueue)` | `https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *` Returns a pointer to the message at the head of the queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gaefee0f07ee9fa021081afb52f74a0776(https://openthread.io/reference/struct/ot-message-queue *aQueue, const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage)` | `https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *` Returns a pointer to the next message in the queue by iterating forward (from head to tail). |
| `https://openthread.io/reference/group/api-message#group__api-message_1gab51851baffa16c7f0ba802c8badd129e(https://openthread.io/reference/struct/ot-message-queue *aQueue)` | `void` Initialize the message queue. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036(const https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength)` | `uint16_t` Read bytes from a message. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga1b78863c46b6daec04ab02a79be3579b(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, https://openthread.io/reference/group/api-message#group__api-message_1ga8a6d81b00ed4a6fde623d5b377bd130b aCallback, void *aContext)` | `void` Registers a callback to be notified of a message's transmission outcome. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga55b5343c6dd72682d3d1785bb30fe5d0(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `void` Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga73c39b38aaf0cff5f0a9687576af0ede(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, bool aEnabled)` | `void` Sets/forces the message to be forwarded using direct transmission. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, uint16_t aLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Set the message length in bytes. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga703b4ee07670fe6d57f539f3610efe48(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, bool aAllowLoopbackToHost)` | `void` Sets whether or not the message is allowed to be looped back to host. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gab09aac2f9d9b531c14d15d0d1179063c(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, bool aEnabled)` | `void` Controls whether the given message may be looped back in a case of a multicast destination address. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, uint16_t aOffset)` | `void` Set the message offset in bytes. |
| `https://openthread.io/reference/group/api-message#group__api-message_1ga5b356307467c43800af25076eb05e6f9(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, https://openthread.io/reference/group/api-message#group__api-message_1gab45120482c382618d9c075d7bf61a6d3 aOrigin)` | `void` Sets the message origin. |
| `https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef(https://openthread.io/reference/group/api-message#group__api-message_1ga42d128a0a9ad58de0eb79673843c2955 *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength)` | `int` Write bytes to a message. |

| ### Structs ||
|---|---|
| [otBufferInfo](https://openthread.io/reference/struct/ot-buffer-info) | Represents the message buffer information for different queues used by OpenThread stack. |
| [otMessageQueue](https://openthread.io/reference/struct/ot-message-queue) | Represents an OpenThread message queue. |
| [otMessageQueueInfo](https://openthread.io/reference/struct/ot-message-queue-info) | Represents information about a message queue. |
| [otMessageSettings](https://openthread.io/reference/struct/ot-message-settings) | Represents a message settings. |
| [otThreadLinkInfo](https://openthread.io/reference/struct/ot-thread-link-info) | Represents link-specific information for messages received from the Thread radio. |

## Enumerations

### otMessageOrigin

```
 otMessageOrigin
```
Defines the OpenThread message origins.

| Properties ||
|---|---|
| `OT_MESSAGE_ORIGIN_HOST_TRUSTED` | Message from a trusted source on host. |
| `OT_MESSAGE_ORIGIN_HOST_UNTRUSTED` | Message from an untrusted source on host. |
| `OT_MESSAGE_ORIGIN_THREAD_NETIF` | Message from Thread Netif. |

### otMessagePriority

```
 otMessagePriority
```
Defines the OpenThread message priority levels.

| Properties ||
|---|---|
| `OT_MESSAGE_PRIORITY_HIGH` | High priority level. |
| `OT_MESSAGE_PRIORITY_LOW` | Low priority level. |
| `OT_MESSAGE_PRIORITY_NORMAL` | Normal priority level. |

## Typedefs

### otBufferInfo

```
struct otBufferInfo otBufferInfo
```
Represents the message buffer information for different queues used by OpenThread stack.

### otMessage

```
struct otMessage otMessage
```
An opaque representation of an OpenThread message buffer.

### otMessageOrigin

```
enum otMessageOrigin otMessageOrigin
```
Defines the OpenThread message origins.

### otMessagePriority

```
enum otMessagePriority otMessagePriority
```
Defines the OpenThread message priority levels.

### otMessageQueueInfo

```
struct otMessageQueueInfo otMessageQueueInfo
```
Represents information about a message queue.

### otMessageSettings

```
struct otMessageSettings otMessageSettings
```
Represents a message settings.

### otMessageTxCallback

```
void(* otMessageTxCallback)(const otMessage *aMessage, otError aError, void *aContext)
```
Represents the callback function pointer to notify the transmission outcome (success or failure) of a message.

The error indicates the transmission status of the IPv6 message from this device to an immediate neighbor (one-hop transmission). It doesn't indicate that the message is received by its final intended destination (multi-hop away).

For a unicast IPv6 message, an `OT_ERROR_NONE` error indicates that the message (all its corresponding fragment frames if the message is larger and requires fragmentation) was successfully delivered to the immediate neighbor, and a MAC layer acknowledgment was received for all fragments. This is reported regardless of whether the message is sent using direct TX or indirect TX (to a sleepy child using CSL or data poll triggered TX).

For a multicast message, an `OT_ERROR_NONE` status indicates that the message (all its fragment frames) was successfully broadcast. Note that no MAC-level acknowledgment is required for broadcast frame TX.

The OpenThread stack may alter the content of the message as it is prepared for transmission (e.g., IPv6 headers may be prepended, or additional metadata appended at the end). So, the content of `aMessage` when this callback is invoked may differ from its original content (e.g., when it was given as input in `https://openthread.io/reference/group/api-ip6#group__api-ip6_1ga6dc618bef02089e031ee882cd8bfd63c` for transmission).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to the message. | | `[in] aError` | The TX error when sending the message. | | `[in] aContext` | A pointer to the user-provided context when the callback was registered. | |

### otThreadLinkInfo

```
struct otThreadLinkInfo otThreadLinkInfo
```
Represents link-specific information for messages received from the Thread radio.

## Functions

### otMessageAppend

```
otError otMessageAppend(
  otMessage *aMessage,
  const void *aBuf,
  uint16_t aLength
)
```
Append bytes to a message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aBuf` | A pointer to the data to append. | | `[in] aLength` | Number of bytes to append. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully appended to the message | | `OT_ERROR_NO_BUFS` | No available buffers to grow the message. | |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageClone

```
otMessage * otMessageClone(
  const otMessage *aMessage
)
```
Creates a clone of a given message.

The new message is allocated from the same message pool as `aMessage`. The entire message content from `aMessage` is copied to the new message.

The caller takes ownership of the returned message and must free it by calling `https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20` when it is no longer needed.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to the message to clone. | |
| **Returns** | A pointer to the new message clone, or `nullptr` if no message buffers are available. |

### otMessageFree

```
void otMessageFree(
  otMessage *aMessage
)
```
Free an allocated message buffer.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |

**See also:**   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageGetBufferInfo

```
void otMessageGetBufferInfo(
  otInstance *aInstance,
  otBufferInfo *aBufferInfo
)
```
Get the Message Buffer information.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | | `[out] aBufferInfo` | A pointer where the message buffer information is written. | |

### otMessageGetInstance

```
otInstance * otMessageGetInstance(
  const otMessage *aMessage
)
```
Gets the `otInstance` associated with a given message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A message. | |
| **Returns** | The `otInstance` associated with `aMessage`. |

### otMessageGetLength

```
uint16_t otMessageGetLength(
  const otMessage *aMessage
)
```
Get the message length in bytes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| **Returns** | The message length in bytes. |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   

### otMessageGetOffset

```
uint16_t otMessageGetOffset(
  const otMessage *aMessage
)
```
Get the message offset in bytes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| **Returns** | The message offset value. |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageGetOrigin

```
otMessageOrigin otMessageGetOrigin(
  const otMessage *aMessage
)
```
Gets the message origin.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| **Returns** | The message origin. |

### otMessageGetRss

```
int8_t otMessageGetRss(
  const otMessage *aMessage
)
```
Returns the average RSS (received signal strength) associated with the message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| **Returns** | The average RSS value (in dBm) or OT_RADIO_RSSI_INVALID if no average RSS is available. |

### otMessageGetThreadLinkInfo

```
otError otMessageGetThreadLinkInfo(
  const otMessage *aMessage,
  otThreadLinkInfo *aLinkInfo
)
```
Retrieves the link-specific information for a message received over Thread radio.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | The message from which to retrieve `https://openthread.io/reference/struct/ot-thread-link-info`. \[out\] aLinkInfo A pointer to an `https://openthread.io/reference/struct/ot-thread-link-info` to populate. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully retrieved the link info, `` `aLinkInfo` `` is updated. | | `OT_ERROR_NOT_FOUND` | Message origin is not `OT_MESSAGE_ORIGIN_THREAD_NETIF`. | |

### otMessageIsLinkSecurityEnabled

```
bool otMessageIsLinkSecurityEnabled(
  const otMessage *aMessage
)
```
Indicates whether or not link security is enabled for the message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| Return Values | |---|---| | `TRUE` | If link security is enabled. | | `FALSE` | If link security is not enabled. | |

### otMessageIsLoopbackToHostAllowed

```
bool otMessageIsLoopbackToHostAllowed(
  const otMessage *aMessage
)
```
Indicates whether or not the message is allowed to be looped back to host.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | |
| Return Values | |---|---| | `TRUE` | If the message is allowed to be looped back to host. | | `FALSE` | If the message is not allowed to be looped back to host. | |

### otMessageIsMulticastLoopEnabled

```
bool otMessageIsMulticastLoopEnabled(
  otMessage *aMessage
)
```
Indicates whether the given message may be looped back in a case of a multicast destination address.

If `aMessage` is used along with an `https://openthread.io/reference/struct/ot-message-info`, the `mMulticastLoop` field from `https://openthread.io/reference/struct/ot-message-info` structure takes precedence and will be used instead of the value set on `aMessage`.

This API is mainly intended for use along with `https://openthread.io/reference/group/api-ip6#group__api-ip6_1ga6dc618bef02089e031ee882cd8bfd63c` which expects an already prepared IPv6 message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to the message. | |

### otMessageQueueDequeue

```
void otMessageQueueDequeue(
  otMessageQueue *aQueue,
  otMessage *aMessage
)
```
Removes a message from the given message queue.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to the message queue. | | `[in] aMessage` | The message to remove. | |

### otMessageQueueEnqueue

```
void otMessageQueueEnqueue(
  otMessageQueue *aQueue,
  otMessage *aMessage
)
```
Adds a message to the end of the given message queue.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to the message queue. | | `[in] aMessage` | The message to add. | |

### otMessageQueueEnqueueAtHead

```
void otMessageQueueEnqueueAtHead(
  otMessageQueue *aQueue,
  otMessage *aMessage
)
```
Adds a message at the head/front of the given message queue.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to the message queue. | | `[in] aMessage` | The message to add. | |

### otMessageQueueGetHead

```
otMessage * otMessageQueueGetHead(
  otMessageQueue *aQueue
)
```
Returns a pointer to the message at the head of the queue.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to a message queue. | |
| **Returns** | A pointer to the message at the head of queue or NULL if queue is empty. |

### otMessageQueueGetNext

```
otMessage * otMessageQueueGetNext(
  otMessageQueue *aQueue,
  const otMessage *aMessage
)
```
Returns a pointer to the next message in the queue by iterating forward (from head to tail).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to a message queue. | | `[in] aMessage` | A pointer to current message buffer. | |
| **Returns** | A pointer to the next message in the queue after `aMessage` or NULL if `aMessage is the tail of queue. NULL is returned if`aMessage`is not in the queue`aQueue\`. |

### otMessageQueueInit

```
void otMessageQueueInit(
  otMessageQueue *aQueue
)
```
Initialize the message queue.

MUST be called once and only once for a `https://openthread.io/reference/struct/ot-message-queue` instance before any other `https://openthread.io/reference/struct/ot-message-queue` functions. The behavior is undefined if other queue APIs are used with an `https://openthread.io/reference/struct/ot-message-queue` before it being initialized or if it is initialized more than once.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aQueue` | A pointer to a message queue. | |

### otMessageRead

```
uint16_t otMessageRead(
  const otMessage *aMessage,
  uint16_t aOffset,
  void *aBuf,
  uint16_t aLength
)
```
Read bytes from a message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aOffset` | An offset in bytes. | | `[in] aBuf` | A pointer to a buffer that message bytes are read to. | | `[in] aLength` | Number of bytes to read. | |
| **Returns** | The number of bytes read. |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageRegisterTxCallback

```
void otMessageRegisterTxCallback(
  otMessage *aMessage,
  otMessageTxCallback aCallback,
  void *aContext
)
```
Registers a callback to be notified of a message's transmission outcome.

Calling this function again for the same message will replace any previously registered callback.

If the message is never actually sent (e.g., it's not passed to `https://openthread.io/reference/group/api-ip6#group__api-ip6_1ga6dc618bef02089e031ee882cd8bfd63c` or other send APIs), the callback will still be invoked when the message is freed. In this case, `OT_ERROR_DROP` will be passed as the error.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | The message to register the callback with. | | `[in] aCallback` | The TX callback. | | `[in] aContext` | A pointer to a user-provided arbitrary context for the callback. | |

### otMessageResetBufferInfo

```
void otMessageResetBufferInfo(
  otInstance *aInstance
)
```
Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time.

This resets `mMaxUsedBuffers` in `https://openthread.io/reference/struct/ot-buffer-info`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to the OpenThread instance. | |

### otMessageSetDirectTransmission

```
void otMessageSetDirectTransmission(
  otMessage *aMessage,
  bool aEnabled
)
```
Sets/forces the message to be forwarded using direct transmission.

Default setting for a new message is `false`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aEnabled` | If `true`, the message is forced to use direct transmission. If `false`, the message follows the normal procedure. | |

### otMessageSetLength

```
otError otMessageSetLength(
  otMessage *aMessage,
  uint16_t aLength
)
```
Set the message length in bytes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aLength` | A length in bytes. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully set the message length. | | `OT_ERROR_NO_BUFS` | No available buffers to grow the message. | |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageSetLoopbackToHostAllowed

```
void otMessageSetLoopbackToHostAllowed(
  otMessage *aMessage,
  bool aAllowLoopbackToHost
)
```
Sets whether or not the message is allowed to be looped back to host.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aAllowLoopbackToHost` | Whether to allow the message to be looped back to host. | |

### otMessageSetMulticastLoopEnabled

```
void otMessageSetMulticastLoopEnabled(
  otMessage *aMessage,
  bool aEnabled
)
```
Controls whether the given message may be looped back in a case of a multicast destination address.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to the message. | | `[in] aEnabled` | The configuration value. | |

### otMessageSetOffset

```
void otMessageSetOffset(
  otMessage *aMessage,
  uint16_t aOffset
)
```
Set the message offset in bytes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aOffset` | An offset in bytes. | |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   
[otMessageWrite](https://openthread.io/reference/group/api-message#group__api-message_1gae4d611947a3d3831b5a7a803fa9bc1ef)   

### otMessageSetOrigin

```
void otMessageSetOrigin(
  otMessage *aMessage,
  otMessageOrigin aOrigin
)
```
Sets the message origin.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aOrigin` | The message origin. | |

### otMessageWrite

```
int otMessageWrite(
  otMessage *aMessage,
  uint16_t aOffset,
  const void *aBuf,
  uint16_t aLength
)
```
Write bytes to a message.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMessage` | A pointer to a message buffer. | | `[in] aOffset` | An offset in bytes. | | `[in] aBuf` | A pointer to a buffer that message bytes are written from. | | `[in] aLength` | Number of bytes to write. | |
| **Returns** | The number of bytes written. |

**See also:**   
[otMessageFree](https://openthread.io/reference/group/api-message#group__api-message_1ga70291a9d11f2f2a0bff290bf8ff4ea20)   
[otMessageAppend](https://openthread.io/reference/group/api-message#group__api-message_1gab1cef88f8ddbe6b3e274aaf6bad46c9b)   
[otMessageGetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga3ae928dc8b31e8808ba1b07abf3dd34b)   
[otMessageSetLength](https://openthread.io/reference/group/api-message#group__api-message_1ga9aeff1951aa15aef4d5ded02ee85bb6b)   
[otMessageGetOffset](https://openthread.io/reference/group/api-message#group__api-message_1gafe5a5df3035db36438525eca45d9756d)   
[otMessageSetOffset](https://openthread.io/reference/group/api-message#group__api-message_1ga8c3fd9db9281f48dd52445fd8a5657f5)   
[otMessageRead](https://openthread.io/reference/group/api-message#group__api-message_1ga868b00fd04baf6849df6f518a0758036)   

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