Lee Kai Xuan / mbed-os

Fork of mbed-os by erkin yucel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thread_border_router_api.h Source File

thread_border_router_api.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014-2016 ARM Limited. All rights reserved.
00003  *
00004  * SPDX-License-Identifier: LicenseRef-PBL
00005  *
00006  * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * https://www.mbed.com/licenses/PBL-1.0
00010  *
00011  * See the License for the specific language governing permissions and limitations under the License.
00012  *
00013  */
00014 
00015 /**
00016  * \file thread_border_router_api.h
00017  * \brief Thread border router application interface.
00018  *
00019  * This file contains functions for managing Thread border router features.
00020  * Border routers can set up services in the Thread network including routes,
00021  * DHCPv6 servers, on-mesh prefixes and services.
00022  *
00023  */
00024 
00025 #ifndef THREAD_BORDER_ROUTER_API_H_
00026 #define THREAD_BORDER_ROUTER_API_H_
00027 
00028 #include "ns_types.h"
00029 
00030 /**
00031  * \brief Border router network data structure.
00032  */
00033 typedef struct thread_border_router_info_t {
00034     unsigned            Prf: 2;               /**!< Prefix preference, 01 = High, 00 = Default, 11 = Low, 10 = Reserved. */
00035     bool                P_preferred: 1;       /**!< Address is considered preferred address. */
00036     bool                P_slaac: 1;           /**!< Allowed to configure a new address */
00037     bool                P_dhcp: 1;            /**!< DHCPv6 server is available in the network. */
00038     bool                P_configure: 1;       /**!< DHCPv6 agent provides other configuration. */
00039     bool                P_default_route: 1;   /**!< This device provides the default route. */
00040     bool                P_on_mesh: 1;         /**!< This prefix is considered to be on-mesh */
00041     bool                P_nd_dns: 1;          /**!< this border router is able to provide DNS information */
00042     bool                stableData: 1;        /**!< This data is stable and expected to be available at least 48h. */
00043 } thread_border_router_info_t;
00044 
00045 /**
00046  * \brief Create local service that is provided to the Thread network.
00047  * If a prefix exists it is updated. For example, when removing SLAAC (Stateless Address Autoconfiguration) you should modify the prefix
00048  * first to remove the creation of new addresses and after a while, remove the prefix.
00049  *
00050  * When you have configured the services locally, you need to call
00051  * thread_border_router_publish to make the services available in the network.
00052  *
00053  * \param interface_id Network interface ID.
00054  * \param prefix_ptr Pointer prefix.
00055  * \param prefix_len Length of prefix.
00056  * \param prefix_info_ptr Prefix service structure configuring the published service.
00057  *
00058  * \return 0, Set OK.
00059  * \return <0 Set not OK.
00060  */
00061 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);
00062 
00063 /**
00064  * \brief Delete local service.
00065  *
00066  * \param interface_id Network interface ID.
00067  * \param prefix_ptr Pointer prefix.
00068  * \param prefix_len Length of prefix.
00069  *
00070  * \return 0, Set OK.
00071  * \return <0 Set not OK.
00072  */
00073 int thread_border_router_prefix_delete(int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len);
00074 
00075 /**
00076  * \brief Add a new route to the Thread network. Other devices can use the route.
00077  * For example, 0::0/0 means that this device provides the default route.
00078  * For example, 2001::0/64 means that this device provides a more specific route.
00079  *
00080  * If a prefix exists it is updated.
00081  *
00082  * \param interface_id Network interface ID.
00083  * \param prefix_ptr Pointer prefix. Can be NULL for the default route.
00084  * \param prefix_len Length of prefix.
00085  * \param stable This data is stable and expected to be available at least 48h.
00086  * \param prf Route preference, 01 = High, 00 = Default, 11 = Low, 10 = Reserved.
00087  *
00088  * \return 0, Set OK.
00089  * \return <0 Set not OK.
00090  */
00091 int thread_border_router_route_add(int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len, bool stable, int8_t prf);
00092 
00093 /**
00094  * \brief Delete locally served route.
00095  *
00096  * \param interface_id Network interface ID.
00097  * \param prefix_ptr Pointer prefix.
00098  * \param prefix_len Length of prefix.
00099  *
00100  * \return 0, Set OK.
00101  * \return <0 Set not OK.
00102  */
00103 int thread_border_router_route_delete(int8_t interface_id, uint8_t *prefix_ptr, uint8_t prefix_len);
00104 
00105 /**
00106  * \brief Add local service.
00107  *
00108  * \param interface_id Network interface ID.
00109  * \param service_ptr Pointer to service data.
00110  * \param service_len Length of service.
00111  * \param thread_enteprise True if Thread enterprise number is used.
00112  * \param sid Service identifier.
00113  * \param enterprise_number If thread_enteprise is false this must be given.
00114  *
00115  * \return 0, Set OK.
00116  * \return <0 Set not OK.
00117  */
00118 //TODO PUUTTUUU SERVER data
00119 int thread_border_router_service_add(int8_t interface_id, uint8_t *service_ptr, uint8_t service_len, bool thread_enteprise, uint8_t sid, uint32_t enterprise_number);
00120 
00121 /**
00122  * \brief Delete local service.
00123  *
00124  * \param interface_id Network interface ID.
00125  * \param service_ptr Pointer to service data.
00126  * \param service_len Length of service.
00127  *
00128  * \return 0, Set OK.
00129  * \return <0 Set not OK.
00130  */
00131 int thread_border_router_service_delete(int8_t interface_id, uint8_t *service_ptr, uint8_t service_len);
00132 
00133 /**
00134  * \brief Publish local services to Thread network.
00135  *
00136  * If local services are deleted before calling this, all services are deregistered from the network.
00137  *
00138  * \param interface_id Network interface ID.
00139  *
00140  * \return 0, Push OK.
00141  * \return <0 Push not OK.
00142  */
00143 int thread_border_router_publish(int8_t interface_id);
00144 
00145 /**
00146  * \brief Clear the local service list.
00147  *
00148  * \param interface_id Network interface ID.
00149  *
00150  * \return 0, Push OK.
00151  * \return <0 Push not OK.
00152  */
00153 int thread_border_router_delete_all(int8_t interface_id);
00154 
00155 /**
00156  * \brief Set Recursive DNS server (RDNSS) option that is encoded according to RFC6106.
00157  * Setting a new RDNSS will overwrite previous RDNSS option. Set RNDDS will be used
00158  * until it is cleared.
00159  *
00160  * \param interface_id Network interface ID.
00161  * \param recursive_dns_server_option Recursive DNS server option encoded according to rfc6106, can be NULL to clear existing RDNSS.
00162  * \param recursive_dns_server_option_len Length of the recursive_dns_server_option in bytes.
00163  *
00164  * \return 0, Option saved OK.
00165  * \return <0 when error occurs during option processing.
00166  */
00167 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);
00168 
00169 /**
00170  * \brief Set DNS server search list (DNSSL) option that is encoded according to RFC6106.
00171  * Setting a new DNSSL will overwrite previous DNSSL option. Set DNSSL will be used
00172  * until it is cleared.
00173  *
00174  * \param interface_id Network interface ID.
00175  * \param dns_search_list_option DNS search list option encoded according to rfc6106, can be NULL to clear existing DNSSL.
00176  * \param search_list_option_len Length of the dns_search_list_option in bytes.
00177  *
00178  * \return 0, Option saved OK.
00179  * \return <0 when error occurs during option processing.
00180  */
00181 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);
00182 
00183 #endif /* THREAD_DHCPV6_SERVER_H_ */