Rtos API example

Embed: (wiki syntax)

« Back to documentation index

thread_border_router_api.h File Reference

thread_border_router_api.h File Reference

Thread border router application interface. More...

Go to the source code of this file.

Data Structures

struct  thread_border_router_info_t
 Border router network data structure. More...

Typedefs

typedef struct
thread_border_router_info_t 
thread_border_router_info_t
 Border router network data structure.
typedef void( thread_network_data_tlv_cb )(int8_t interface_id, uint8_t *network_data_tlv, uint16_t network_data_tlv_length)
 Callback type for Thread network data TLV registration.

Functions

int thread_border_router_prefix_add (int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len, thread_border_router_info_t *prefix_info_ptr)
 Create local service that is provided to the Thread network.
int thread_border_router_prefix_delete (int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len)
 Delete local service.
int thread_border_router_route_add (int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len, bool stable, int8_t prf)
 Add a new route to the Thread network.
int thread_border_router_route_delete (int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len)
 Delete locally served route.
int thread_border_router_service_add (int8_t interface_id, uint8_t *service_data, uint8_t service_len, uint8_t sid, uint32_t enterprise_number, uint8_t *server_data, uint8_t server_data_len, bool stable)
 Add or modify a local service.
int thread_border_router_service_delete (int8_t interface_id, uint8_t *service_data, uint8_t service_len, uint32_t enterprise_number)
 Delete local service by service data and enterprise number.
int thread_border_router_publish (int8_t interface_id)
 Publish local services to Thread network.
int thread_border_router_delete_all (int8_t interface_id)
 Clear the local service list.
int thread_border_router_recursive_dns_server_option_set (int8_t interface_id, uint8_t *recursive_dns_server_option, uint16_t recursive_dns_server_option_len)
 Set Recursive DNS server (RDNSS) option that is encoded according to RFC6106.
int thread_border_router_dns_search_list_option_set (int8_t interface_id, uint8_t *dns_search_list_option, uint16_t search_list_option_len)
 Set DNS server search list (DNSSL) option that is encoded according to RFC6106.
int thread_border_router_network_data_callback_register (int8_t interface_id, thread_network_data_tlv_cb *nwk_data_cb)
 Register callback function to receive thread network data TLV in byte array.
int thread_border_router_prefix_tlv_find (uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **prefix_tlv, bool *stable)
 Find Prefix TLV from the Network Data TLV byte array.
int thread_border_router_tlv_find (uint8_t *prefix_tlv, uint16_t prefix_tlv_length, uint8_t **border_router_tlv, bool *stable)
 Find Border router TLV from the Network Data TLV (under Prefix TLV) byte array.
int thread_border_router_service_tlv_find (uint8_t *network_data_tlv, uint16_t network_data_tlv_length, uint8_t **service_tlv, bool *stable)
 Find Service TLV from the Network Data TLV byte array.
int thread_border_router_server_tlv_find (uint8_t *service_tlv, uint16_t service_tlv_length, uint8_t **server_tlv, bool *stable)
 Find Server TLV from the Network Data TLV (under Service TLV) byte array.
int thread_border_router_prefix_context_id (uint8_t *prefix_tlv, uint16_t prefix_tlv_length)
 Determine context ID from the Network Data TLV (under Prefix TLV) byte array.
int thread_border_router_mdns_responder_start (int8_t interface_id, int8_t interface_id_mdns, const char *service_name)
 Start mDNS responder service.
int thread_border_router_mdns_responder_stop (void)
 Stop mDNS responder service.

Detailed Description

Thread border router application interface.

This file contains functions for managing Thread border router features. Border routers can set up services in the Thread network including routes, DHCPv6 servers, on-mesh prefixes and services.

Definition in file thread_border_router_api.h.


Typedef Documentation

Border router network data structure.

typedef void( thread_network_data_tlv_cb)(int8_t interface_id, uint8_t *network_data_tlv, uint16_t network_data_tlv_length)

Callback type for Thread network data TLV registration.

Parameters:
interface_idNetwork interface ID.
network_data_tlvThread Network data TLV as specified in Thread specification.
network_data_tlv_lengthlength of the network data TLV.

Definition at line 192 of file thread_border_router_api.h.


Function Documentation

int thread_border_router_delete_all ( int8_t  interface_id )

Clear the local service list.

Parameters:
interface_idNetwork interface ID.
Returns:
0, Push OK.
<0 Push not OK.
int thread_border_router_dns_search_list_option_set ( int8_t  interface_id,
uint8_t *  dns_search_list_option,
uint16_t  search_list_option_len 
)

Set DNS server search list (DNSSL) option that is encoded according to RFC6106.

Setting a new DNSSL will overwrite previous DNSSL option. Set DNSSL will be used until it is cleared.

Parameters:
interface_idNetwork interface ID.
dns_search_list_optionDNS search list option encoded according to rfc6106, can be NULL to clear existing DNSSL.
search_list_option_lenLength of the dns_search_list_option in bytes.
Returns:
0, Option saved OK.
<0 when error occurs during option processing.
int thread_border_router_mdns_responder_start ( int8_t  interface_id,
int8_t  interface_id_mdns,
const char *  service_name 
)

Start mDNS responder service.

The responder will respond to DNS-SD queries and send announcement when Thread network data is updated.

The mDNS responder can be closed by calling thread_border_router_mdns_responder_stop(). Closing the Thread network interface will stop the mDNS responder automatically.

Parameters:
interface_idinterface ID of the Thread network
interface_id_mdnsinterface where mDNS messaging occurs
service_namemDNS instance name
Returns:
0 on success
<0 in case of errors
int thread_border_router_mdns_responder_stop ( void   )

Stop mDNS responder service.

Returns:
0 on success
<0 in case of errors
int thread_border_router_network_data_callback_register ( int8_t  interface_id,
thread_network_data_tlv_cb nwk_data_cb 
)

Register callback function to receive thread network data TLV in byte array.

For the first time the callback will be called before returning from the function. Afterwards the callback will be called when there is a change to the network data or when the network data is advertised. Application is not allowed to block the callback execution and must make a copy of the network data if it is needed afterwards.

Setting nwk_data_cb to NULL will prevent further calls to the callback function.

Parameters:
interface_idNetwork interface ID.
nwk_data_cbcallback function to receive network data TLV in byte array as specified in the Thread specification.
Returns:
0, Callback function registered successfully.
<0 when error occurs during registering the callback function.
int thread_border_router_prefix_add ( int8_t  interface_id,
uint8_t *  prefix_ptr,
uint8_t  prefix_len,
thread_border_router_info_t prefix_info_ptr 
)

Create local service that is provided to the Thread network.

If a prefix exists it is updated. For example, when removing SLAAC (Stateless Address Autoconfiguration) you should modify the prefix first to remove the creation of new addresses and after a while, remove the prefix.

When you have configured the services locally, you need to call thread_border_router_publish to make the services available in the network.

Parameters:
interface_idNetwork interface ID.
prefix_ptrPointer prefix.
prefix_lenLength of prefix.
prefix_info_ptrPrefix service structure configuring the published service.
Returns:
0, Set OK.
<0 Set not OK.
int thread_border_router_prefix_context_id ( uint8_t *  prefix_tlv,
uint16_t  prefix_tlv_length 
)

Determine context ID from the Network Data TLV (under Prefix TLV) byte array.

Parameters:
prefix_tlv[IN] Prefix TLV in byte array.
prefix_tlv_length[IN] Length of the Prefix TLV byte array in bytes.
Returns:
The context ID value found
-1 if error in input parameters.
-2 if no context ID value found.
int thread_border_router_prefix_delete ( int8_t  interface_id,
uint8_t *  prefix_ptr,
uint8_t  prefix_len 
)

Delete local service.

Parameters:
interface_idNetwork interface ID.
prefix_ptrPointer prefix.
prefix_lenLength of prefix.
Returns:
0, Set OK.
<0 Set not OK.
int thread_border_router_prefix_tlv_find ( uint8_t *  network_data_tlv,
uint16_t  network_data_tlv_length,
uint8_t **  prefix_tlv,
bool *  stable 
)

Find Prefix TLV from the Network Data TLV byte array.

Parameters:
network_data_tlv[IN] Network data TLV in byte array.
network_data_tlv_length[IN] Length of the network data TLV byte array in bytes.
prefix_tlv[IN] pointer to the previous prefix_tlv, NULL if previous TLV not known. [OUT] Pointer to the prefix TLV found.
stable[OUT] value set to true if found TLV is stable, false otherwise.
Returns:
Length of the found Prefix TLV
0 if TLV is empty or no Prefix TLV found.
negative value indicates error in input parameters.
int thread_border_router_publish ( int8_t  interface_id )

Publish local services to Thread network.

If local services are deleted before calling this, all services are deregistered from the network.

Parameters:
interface_idNetwork interface ID.
Returns:
0, Push OK.
<0 Push not OK.
int thread_border_router_recursive_dns_server_option_set ( int8_t  interface_id,
uint8_t *  recursive_dns_server_option,
uint16_t  recursive_dns_server_option_len 
)

Set Recursive DNS server (RDNSS) option that is encoded according to RFC6106.

Setting a new RDNSS will overwrite previous RDNSS option. Set RNDDS will be used until it is cleared.

Parameters:
interface_idNetwork interface ID.
recursive_dns_server_optionRecursive DNS server option encoded according to rfc6106, can be NULL to clear existing RDNSS.
recursive_dns_server_option_lenLength of the recursive_dns_server_option in bytes.
Returns:
0, Option saved OK.
<0 when error occurs during option processing.
int thread_border_router_route_add ( int8_t  interface_id,
uint8_t *  prefix_ptr,
uint8_t  prefix_len,
bool  stable,
int8_t  prf 
)

Add a new route to the Thread network.

Other devices can use the route. For example, 0::0/0 means that this device provides the default route. For example, 2001::0/64 means that this device provides a more specific route.

If a prefix exists it is updated.

Parameters:
interface_idNetwork interface ID.
prefix_ptrPointer prefix. Can be NULL for the default route.
prefix_lenLength of prefix.
stableThis data is stable and expected to be available at least 48h.
prfRoute preference, 01 = High, 00 = Default, 11 = Low, 10 = Reserved.
Returns:
0, Set OK.
<0 Set not OK.
int thread_border_router_route_delete ( int8_t  interface_id,
uint8_t *  prefix_ptr,
uint8_t  prefix_len 
)

Delete locally served route.

Parameters:
interface_idNetwork interface ID.
prefix_ptrPointer prefix.
prefix_lenLength of prefix.
Returns:
0, Set OK.
<0 Set not OK.
int thread_border_router_server_tlv_find ( uint8_t *  service_tlv,
uint16_t  service_tlv_length,
uint8_t **  server_tlv,
bool *  stable 
)

Find Server TLV from the Network Data TLV (under Service TLV) byte array.

Parameters:
service_tlv[IN] Network data TLV in byte array.
service_tlv_length[IN] Length of the Network data TLV byte array in bytes.
server_tlv[IN] pointer to the previous Server TLV, NULL if not known. [OUT] Pointer to the Server TLV found.
stable[OUT] value set to true if found TLV is stable, false otherwise
Returns:
Length of the Prefix found
0 if TLV is empty or no TLV found.
negative value indicates error in input parameters.
int thread_border_router_service_add ( int8_t  interface_id,
uint8_t *  service_data,
uint8_t  service_len,
uint8_t  sid,
uint32_t  enterprise_number,
uint8_t *  server_data,
uint8_t  server_data_len,
bool  stable 
)

Add or modify a local service.

Parameters:
interface_idNetwork interface ID.
service_dataPointer to a byte string specifying the type of service.
service_lenLength of service data.
sidService Type ID, a value between 0 and 15, inclusive, assigned to this service data.
enterprise_numberEnterprise number of the vendor that defined the type of the server.
server_dataPointer to a byte string containing server-specific information.
server_data_lenLength of server data.
stableThis data is stable and expected to be available at least 48h.
Returns:
0, Addition OK.
<0 Addition not OK.
int thread_border_router_service_delete ( int8_t  interface_id,
uint8_t *  service_data,
uint8_t  service_len,
uint32_t  enterprise_number 
)

Delete local service by service data and enterprise number.

Parameters:
interface_idNetwork interface ID.
service_dataPointer to a byte string specifying the type of service.
service_lenLength of service.
enterprise_numberEnterprise number of the vendor that defined the type of the server.
Returns:
0, Delete OK.
<0 Delete not OK.
int thread_border_router_service_tlv_find ( uint8_t *  network_data_tlv,
uint16_t  network_data_tlv_length,
uint8_t **  service_tlv,
bool *  stable 
)

Find Service TLV from the Network Data TLV byte array.

Parameters:
network_data_tlv[IN] Network data TLV in byte array.
network_data_tlv_length[IN] Length of the network data TLV byte array in bytes.
service_tlv[IN] pointer to the previous Service TLV, NULL if previous TLV not known. [OUT] Pointer to the Service TLV found.
stable[OUT] value set to true if found TLV is stable, false otherwise.
Returns:
Length of the found Service TLV
0 if TLV is empty or no Service TLV found.
negative value indicates error in input parameters.
int thread_border_router_tlv_find ( uint8_t *  prefix_tlv,
uint16_t  prefix_tlv_length,
uint8_t **  border_router_tlv,
bool *  stable 
)

Find Border router TLV from the Network Data TLV (under Prefix TLV) byte array.

Parameters:
prefix_tlv[IN] Network data TLV in byte array.
prefix_tlv_length[IN] Length of the Network data TLV byte array in bytes.
border_router_tlv[IN] pointer to the previous Border Router TLV, NULL if not known. [OUT] Pointer to the Border Router TLV found.
stable[OUT] value set to true if found TLV is stable, false otherwise
Returns:
Length of the Prefix found
0 if TLV is empty or no TLV found.
negative value indicates error in input parameters.