Mistake on this page?
Report an issue in GitHub or email us
WisunBorderRouter.h
1 /*
2  * Copyright (c) 2020 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WISUNBORDERROUTER_H
18 #define WISUNBORDERROUTER_H
19 
20 /**
21  * \brief Struct br_information Border router dynamic information.
22  */
23 typedef struct ws_br_info {
24  /** Address prefix given to devices in network set to 0 if not available*/
25  uint8_t ipv6_prefix[8];
26  /** IID of Border router */
27  uint8_t ipv6_iid[8];
28  /** Border router dodag id */
29  uint8_t rpl_dodag_id[16];
30  /** Border router instance identifier defined in RPL */
31  uint8_t instance_id;
32  /** RPL version number */
33  uint8_t version;
34  /** Timestamp of the the device. Can be used as version number*/
35  uint64_t host_timestamp;
36  /** Amount of devices in the network. */
37  uint16_t device_count;
38 } ws_br_info_t;
39 
40 /**
41  * \brief Struct br_route_info is parent child relation structure.
42  */
43 typedef struct ws_br_route_info {
44  /** IID of target device
45  * Public IPv6 address can be formed by combining prefix + IID*/
46  uint8_t target[8];
47  /** IID of parent*/
48  uint8_t parent[8];
50 
51 /** Wi-SUN Border Router class
52  *
53  * Class can be used to start, stop and configure Wi-SUN Border Router.
54  */
56 public:
57 
58  /** Create WisunBorderRouter
59  *
60  * */
62 
63  /**
64  * \brief Start Wi-SUN Border Router
65  *
66  * Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Network interfaces
67  * must be initialized and connected before calling the start. Backbone interface can be either Ethernet
68  * (EMAC) or Cellular.
69  *
70  * \param mesh_if Wi-SUN mesh network interface
71  * \param backbone_if Backbone network interface
72  * \return MESH_ERROR_NONE on success.
73  * \return MESH_ERROR_UNKNOWN in case of failure.
74  * */
75  mesh_error_t start(NetworkInterface *mesh_if, NetworkInterface *backbone_if);
76 
77  /**
78  * \brief Start Wi-SUN Border Router
79  *
80  * Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Mesh network interface
81  * must be initialized and connected before calling the start. Backbone OnboardNetworkStack::Interface must
82  * be brought up before calling the start. Backbone interface can be either Ethernet (EMAC) or Cellular (PPP).
83  *
84  * \param mesh_if Wi-SUN mesh network interface
85  * \param backbone_if Backbone OnboardNetworkStack::Interface interface
86  * \return MESH_ERROR_NONE on success.
87  * \return MESH_ERROR_UNKNOWN in case of failure.
88  * */
89  mesh_error_t start(NetworkInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if);
90 
91  /**
92  * \brief Stop Wi-SUN Border Router
93  *
94  * Stops Wi-SUN Border Router.
95  *
96  * */
97  void stop();
98 
99  /**
100  * \brief Set Wi-SUN RPL DIO trickle parameters.
101  *
102  * Function stores new parameters to Border Router and uses them when mesh interface connect() is called
103  * next time. If device is already connected to the Wi-SUN network then device will restart Wi-SUN network after
104  * changing the RPL DIO trickle parameters. Mesh interface must be initialized before calling this
105  * function.
106  *
107  * \param dio_interval_min DIO trickle timer Imin parameter. Use 0x00 to use leave parameter unchanged.
108  * \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin. Use 0x00 to use leave parameter unchanged.
109  * \param dio_redundancy_constant DIO trickle timer redundancy constant. Use 0xff to use leave parameter unchanged.
110  * \return MESH_ERROR_NONE on success.
111  * \return MESH_ERROR_UNKNOWN in case of failure.
112  * */
113  mesh_error_t set_rpl_parameters(uint8_t dio_interval_min, uint8_t dio_interval_doublings, uint8_t dio_redundancy_constant);
114 
115  /**
116  * \brief Get Wi-SUN RPL DIO trickle parameters.
117  *
118  * Function reads DIO trickle timer Imin, DIO trickle timer Imax and DIO trickle timer redundancy
119  * constant from Border Router. Mesh interface must be initialized before calling this function.
120  *
121  * \param dio_interval_min DIO trickle timer Imin parameter.
122  * \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin.
123  * \param dio_redundancy_constant DIO trickle timer redundancy constant.
124  * \return MESH_ERROR_NONE on success.
125  * \return MESH_ERROR_UNKNOWN in case of failure.
126  * */
127  mesh_error_t get_rpl_parameters(uint8_t *dio_interval_min, uint8_t *dio_interval_doublings, uint8_t *dio_redundancy_constant);
128 
129  /**
130  * \brief Validate Wi-SUN RPL DIO trickle parameters.
131  *
132  * Function validates DIO trickle timer Imin, DIO trickle timer Imax and DIO trickle timer redundancy
133  * constant. Function can be used to test that values that will be used on set function are valid.
134  * Mesh interface must be initialized before the calling this function.
135  *
136  * \param dio_interval_min DIO trickle timer Imin parameter.
137  * \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin.
138  * \param dio_redundancy_constant DIO trickle timer redundancy constant.
139  * \return MESH_ERROR_NONE on success.
140  * \return MESH_ERROR_UNKNOWN in case of failure.
141  * */
142  mesh_error_t validate_rpl_parameters(uint8_t dio_interval_min, uint8_t dio_interval_doublings, uint8_t dio_redundancy_constant);
143 
144  /**
145  * \brief Set Wi-SUN PAN configuration parameters.
146  *
147  * Function stores new parameters to Border Router and uses them when mesh interface connect() is called
148  * next time. If device is already connected to the Wi-SUN network then device will restart Wi-SUN network after
149  * changing the PAN configuration parameters. Mesh interface must be initialized before calling this
150  * function.
151  *
152  * \param pan_id PAN ID. 0xffff will generate the PAN ID on the mesh interface connect() call if not already generated.
153  * \return MESH_ERROR_NONE on success.
154  * \return MESH_ERROR_UNKNOWN in case of failure.
155  * */
156  mesh_error_t set_pan_configuration(uint16_t pan_id);
157 
158  /**
159  * \brief Get Wi-SUN PAN configuration parameters.
160  *
161  * Function reads PAN ID from Border Router. Mesh interface must be initialized before calling this function.
162  *
163  * \param pan_id PAN ID.
164  * \return MESH_ERROR_NONE on success.
165  * \return MESH_ERROR_UNKNOWN in case of failure.
166  * */
167  mesh_error_t get_pan_configuration(uint16_t *pan_id);
168 
169  /**
170  * \brief Validate Wi-SUN PAN configuration parameters.
171  *
172  * Function validates PAN ID. Function can be used to test that values that will be used on set function are valid.
173  * Mesh interface must be initialized before calling this function.
174  *
175  * \param pan_id PAN ID.
176  * \return MESH_ERROR_NONE on success.
177  * \return MESH_ERROR_UNKNOWN in case of failure.
178  * */
179  mesh_error_t validate_pan_configuration(uint16_t pan_id);
180 
181  /**
182  * \brief Get Wi-SUN Border Router information.
183  *
184  * Function reads RPL information from Border Router.
185  * Mesh interface must be initialized before calling this function.
186  *
187  * \param info_ptr Structure given to stack where information will be stored
188  *
189  * \return MESH_ERROR_NONE on success.
190  * \return MESH_ERROR_UNKNOWN in case of failure.
191  * */
192  mesh_error_t info_get(ws_br_info_t *info_ptr);
193 
194  /**
195  * \brief Get Wi-SUN neighbor table information.
196  *
197  * Function reads Routing Table information from Border Router.
198  * Table is Parent child relation using the Global address IID of the devices.
199  * To get the full IPv6 address of the device, IPv6 = Global Prefix + IID.
200  * Mesh interface must be initialized before calling this function.
201  *
202  * \param table_ptr Application allocated memory block where routing table is written.
203  * \param table_len Length of the table allocated by application given as amount of entries.
204  *
205  * \returns 0 - x on success indicates number of entries written to the table_ptr.
206  * \return <0 in case of errors.
207  * */
208  int routing_table_get(ws_br_route_info_t *table_ptr, uint16_t table_len);
209 
210 private:
211  int8_t _mesh_if_id = -1;
212 
213 };
214 
215 #endif
Wi-SUN Border Router class.
uint8_t version
RPL version number.
Representation of a stack&#39;s view of an interface.
Struct br_information Border router dynamic information.
uint8_t rpl_dodag_id[16]
Border router dodag id.
uint64_t host_timestamp
Timestamp of the the device.
uint8_t instance_id
Border router instance identifier defined in RPL.
uint16_t device_count
Amount of devices in the network.
Common interface that is shared between network devices.
Struct br_route_info is parent child relation structure.
uint8_t ipv6_iid[8]
IID of Border router.
uint8_t ipv6_prefix[8]
Address prefix given to devices in network set to 0 if not available.
WisunBorderRouter()
Create WisunBorderRouter.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.