# Border Router

# Border Router

This module includes functions to manage local network data with the OpenThread Border Router.

## Summary

| ### Typedefs ||
|---|---|
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga6733a121f2599366b6f40e69d545a92d)(void *aContext)` | typedef `void(*` Function pointer callback which is invoked when Network Data (local or leader) gets full. |

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga477ec836f37da7aff55f71969f88ad38(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-border-router-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Add a border router configuration to the local network data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1gadf032489e68e845335f7ebb996c02cea(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-external-route-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Add an external route configuration to the local network data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga3d6d77e26df1c526ebcaa2c3026f3786(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Provides a full or stable copy of the local Thread Network Data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1gaead412dd0ed6a471e2ef44e11d643563(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-thread-general#group__api-thread-general_1gac4be34b26a43e67d12ee7e0352ee4927 *aIterator, https://openthread.io/reference/struct/ot-border-router-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Gets the next On Mesh Prefix in the local Network Data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1gad07e7e4e3bfd97c56ce87701b8fe2870(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-thread-general#group__api-thread-general_1gac4be34b26a43e67d12ee7e0352ee4927 *aIterator, https://openthread.io/reference/struct/ot-external-route-config *aConfig)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Gets the next external route in the local Network Data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga9bf67515e6170e67abf4d7cb57a80f42(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Immediately register the local network data with the Leader. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga95ab1af21b65ec0de11f4295ae4c2084(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-ip6-prefix *aPrefix)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Remove a border router configuration from the local network data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga8f527ca56c96b028deb7693c7456b5df(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, const https://openthread.io/reference/struct/ot-ip6-prefix *aPrefix)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Remove an external route configuration from the local network data. |
| `https://openthread.io/reference/group/api-border-router#group__api-border-router_1gacb980010ba555472a8bbed2a9d7bdb9d(https://openthread.io/reference/group/api-instance#group__api-instance_1ga25440551213fb5b40869725378584960 *aInstance, https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga6733a121f2599366b6f40e69d545a92d aCallback, void *aContext)` | `void` Sets the callback to indicate when Network Data gets full. |

## Typedefs

### otBorderRouterNetDataFullCallback

```
void(* otBorderRouterNetDataFullCallback)(void *aContext)
```
Function pointer callback which is invoked when Network Data (local or leader) gets full.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aContext` | A pointer to arbitrary context information. | |

## Functions

### otBorderRouterAddOnMeshPrefix

```
otError otBorderRouterAddOnMeshPrefix(
  otInstance *aInstance,
  const otBorderRouterConfig *aConfig
)
```
Add a border router configuration to the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aConfig` | A pointer to the border router configuration. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully added the configuration to the local network data. | | `OT_ERROR_INVALID_ARGS` | One or more configuration parameters were invalid. | | `OT_ERROR_NO_BUFS` | Not enough room is available to add the configuration to the local network data. | |

**See also:**   
[otBorderRouterRemoveOnMeshPrefix](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga95ab1af21b65ec0de11f4295ae4c2084)   
[otBorderRouterRegister](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga9bf67515e6170e67abf4d7cb57a80f42)   

### otBorderRouterAddRoute

```
otError otBorderRouterAddRoute(
  otInstance *aInstance,
  const otExternalRouteConfig *aConfig
)
```
Add an external route configuration to the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aConfig` | A pointer to the external route configuration. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully added the configuration to the local network data. | | `OT_ERROR_INVALID_ARGS` | One or more configuration parameters were invalid. | | `OT_ERROR_NO_BUFS` | Not enough room is available to add the configuration to the local network data. | |

**See also:**   
[otBorderRouterRemoveRoute](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga8f527ca56c96b028deb7693c7456b5df)   
[otBorderRouterRegister](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga9bf67515e6170e67abf4d7cb57a80f42)   

### otBorderRouterGetNetData

```
otError otBorderRouterGetNetData(
  otInstance *aInstance,
  bool aStable,
  uint8_t *aData,
  uint8_t *aDataLength
)
```
Provides a full or stable copy of the local Thread Network Data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aStable` | TRUE when copying the stable version, FALSE when copying the full version. | | `[out] aData` | A pointer to the data buffer. | | `[in,out] aDataLength` | On entry, size of the data buffer pointed to by `aData`. On exit, number of copied bytes. | |

### otBorderRouterGetNextOnMeshPrefix

```
otError otBorderRouterGetNextOnMeshPrefix(
  otInstance *aInstance,
  otNetworkDataIterator *aIterator,
  otBorderRouterConfig *aConfig
)
```
Gets the next On Mesh Prefix in the local Network Data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in,out] aIterator` | A pointer to the Network Data iterator context. To get the first on-mesh entry it should be set to OT_NETWORK_DATA_ITERATOR_INIT. | | `[out] aConfig` | A pointer to the On Mesh Prefix information. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully found the next On Mesh prefix. | | `OT_ERROR_NOT_FOUND` | No subsequent On Mesh prefix exists in the Thread Network Data. | |

### otBorderRouterGetNextRoute

```
otError otBorderRouterGetNextRoute(
  otInstance *aInstance,
  otNetworkDataIterator *aIterator,
  otExternalRouteConfig *aConfig
)
```
Gets the next external route in the local Network Data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in,out] aIterator` | A pointer to the Network Data iterator context. To get the first external route entry it should be set to OT_NETWORK_DATA_ITERATOR_INIT. | | `[out] aConfig` | A pointer to the External Route information. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully found the next External Route. | | `OT_ERROR_NOT_FOUND` | No subsequent external route entry exists in the Thread Network Data. | |

### otBorderRouterRegister

```
otError otBorderRouterRegister(
  otInstance *aInstance
)
```
Immediately register the local network data with the Leader.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully queued a Server Data Request message for delivery. | |

**See also:**   
[otBorderRouterAddOnMeshPrefix](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga477ec836f37da7aff55f71969f88ad38)   
[otBorderRouterRemoveOnMeshPrefix](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga95ab1af21b65ec0de11f4295ae4c2084)   
[otBorderRouterAddRoute](https://openthread.io/reference/group/api-border-router#group__api-border-router_1gadf032489e68e845335f7ebb996c02cea)   
[otBorderRouterRemoveRoute](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga8f527ca56c96b028deb7693c7456b5df)   

### otBorderRouterRemoveOnMeshPrefix

```
otError otBorderRouterRemoveOnMeshPrefix(
  otInstance *aInstance,
  const otIp6Prefix *aPrefix
)
```
Remove a border router configuration from the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aPrefix` | A pointer to an IPv6 prefix. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully removed the configuration from the local network data. | | `OT_ERROR_NOT_FOUND` | Could not find the Border Router entry. | |

**See also:**   
[otBorderRouterAddOnMeshPrefix](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga477ec836f37da7aff55f71969f88ad38)   
[otBorderRouterRegister](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga9bf67515e6170e67abf4d7cb57a80f42)   

### otBorderRouterRemoveRoute

```
otError otBorderRouterRemoveRoute(
  otInstance *aInstance,
  const otIp6Prefix *aPrefix
)
```
Remove an external route configuration from the local network data.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aPrefix` | A pointer to an IPv6 prefix. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully removed the configuration from the local network data. | | `OT_ERROR_NOT_FOUND` | Could not find the Border Router entry. | |

**See also:**   
[otBorderRouterAddRoute](https://openthread.io/reference/group/api-border-router#group__api-border-router_1gadf032489e68e845335f7ebb996c02cea)   
[otBorderRouterRegister](https://openthread.io/reference/group/api-border-router#group__api-border-router_1ga9bf67515e6170e67abf4d7cb57a80f42)   

### otBorderRouterSetNetDataFullCallback

```
void otBorderRouterSetNetDataFullCallback(
  otInstance *aInstance,
  otBorderRouterNetDataFullCallback aCallback,
  void *aContext
)
```
Sets the callback to indicate when Network Data gets full.

Requires `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL`.

The callback is invoked whenever:

- The device is acting as a leader and receives a Network Data registration from a Border Router (BR) that it cannot add to Network Data (running out of space).
- The device is acting as a BR and new entries cannot be added to its local Network Data.
- The device is acting as a BR and tries to register its local Network Data entries with the leader, but determines that its local entries will not fit.

<br />

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aInstance` | A pointer to an OpenThread instance. | | `[in] aCallback` | The callback. | | `[in] aContext` | A pointer to arbitrary context information used with `aCallback`. | |

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