@@ -50,6 +50,18 @@ typedef struct ws_br_route_info {
5050 uint8_t parent[8 ];
5151} ws_br_route_info_t ;
5252
53+ /* *
54+ * \brief Struct ws_br_radius_timing_t is RADIUS timing configuration structure.
55+ */
56+ typedef struct ws_br_radius_timing {
57+ /* * RADIUS retry trickle timer Imin; in 100ms units; range 1-1200; default 20 (2 seconds) */
58+ uint16_t radius_retry_imin;
59+ /* * RADIUS retry trickle timer Imax; in 100ms units; range 1-1200; default 30 (3 seconds) */
60+ uint16_t radius_retry_imax;
61+ /* * RADIUS retry trickle count; default 3 */
62+ uint8_t radius_retry_count;
63+ } ws_br_radius_timing_t ;
64+
5365/* * Wi-SUN Border Router class
5466 *
5567 * Class can be used to start, stop and configure Wi-SUN Border Router.
@@ -60,7 +72,7 @@ class WisunBorderRouter {
6072 /* * Create WisunBorderRouter
6173 *
6274 * */
63- WisunBorderRouter () { }
75+ WisunBorderRouter ();
6476
6577 /* *
6678 * \brief Start Wi-SUN Border Router
@@ -209,9 +221,106 @@ class WisunBorderRouter {
209221 * */
210222 int routing_table_get (ws_br_route_info_t *table_ptr, uint16_t table_len);
211223
224+ /* *
225+ * \brief Set Wi-SUN RADIUS server IPv6 address.
226+ *
227+ * Function sets external RADIUS server IPv6 address to Border Router. Setting the address enables
228+ * external RADIUS server interface on Border Router. To disable external RADIUS server interface,
229+ * call the function with address set to NULL. The RADIUS shared secret must be set before address
230+ * is set using set_radius_shared_secret() call.
231+ *
232+ * \param address Pointer to IPv6 address string or NULL to disable RADIUS. Address string format is e.g. 2001:1234::1 and it is NUL terminated.
233+ * \return MESH_ERROR_NONE on success.
234+ * \return MESH_ERROR_UNKNOWN in case of failure.
235+ * */
236+ mesh_error_t set_radius_server_ipv6_address (const char *address);
237+
238+ /* *
239+ * \brief Get Wi-SUN RADIUS server IPv6 address.
240+ *
241+ * Function gets external RADIUS server IPv6 address from Border Router.
242+ *
243+ * \param address Pointer to buffer where to write IPv6 address string. Must have space at least for 39 characters and NUL terminator.
244+ * \return MESH_ERROR_NONE on success.
245+ * \return error value in case of failure, e.g. if address has not been set to Border Router.
246+ * */
247+ mesh_error_t get_radius_server_ipv6_address (char *address);
248+
249+ /* *
250+ * \brief Set Wi-SUN RADIUS shared secret.
251+ *
252+ * Function sets RADIUS shared secret to Border Router. Shared secret may be an ASCII string. Check
253+ * the format and length constraints for the shared secret from the documentation of RADIUS server you
254+ * are connecting to.
255+ *
256+ * \param shared_secret_len The length of the shared secret in bytes.
257+ * \param shared_secret Pointer to shared secret. Can be 8-bit ASCII string or byte array. Is not NUL terminated.
258+ * \return MESH_ERROR_NONE on success.
259+ * \return error value in case of failure.
260+ * */
261+ mesh_error_t set_radius_shared_secret (uint16_t shared_secret_len, const uint8_t *shared_secret);
262+
263+ /* *
264+ * \brief Get Wi-SUN RADIUS shared secret.
265+ *
266+ * Function gets RADIUS shared secret from Border Router.
267+ *
268+ * \param shared_secret_len On function call, is the size of the shared secret write buffer in bytes, on return is the shared secret length in bytes.
269+ * \param shared_secret Pointer to buffer where to write shared secret or NULL. At maximum, bytes set by the length parameter are written. If NULL only buffer length is returned.
270+ * \return MESH_ERROR_NONE on success.
271+ * \return error value in case of failure.
272+ * */
273+ mesh_error_t get_radius_shared_secret (uint16_t *shared_secret_len, uint8_t *shared_secret);
274+
275+ /* *
276+ * \brief Set Wi-SUN RADIUS timing parameters.
277+ *
278+ * Function sets RADIUS timing parameters to Border Router. For RADIUS retry trickle timer default
279+ * settings are that the first retry is done between 1 to 3 seconds after the initial attempt and
280+ * all retries are done in maximum in 9 seconds.
281+ *
282+ * \param timing Timing parameters.
283+ * \return MESH_ERROR_NONE on success.
284+ * \return error value in case of failure.
285+ * */
286+ mesh_error_t set_radius_timing (ws_br_radius_timing_t *timing);
287+
288+ /* *
289+ * \brief Get Wi-SUN RADIUS timing parameters.
290+ *
291+ * Function gets RADIUS timing parameters from Border Router.
292+ *
293+ * \param timing Timing parameters.
294+ * \return MESH_ERROR_NONE on success.
295+ * \return error value in case of failure.
296+ * */
297+ mesh_error_t get_radius_timing (ws_br_radius_timing_t *timing);
298+
299+ /* *
300+ * \brief Validate Wi-SUN RADIUS timing parameters.
301+ *
302+ * Function validates RADIUS timing parameters on Border Router.
303+ *
304+ * \param timing Timing parameters.
305+ * \return MESH_ERROR_NONE on success.
306+ * \return error value in case of failure.
307+ * */
308+ mesh_error_t validate_radius_timing (ws_br_radius_timing_t *timing);
309+
212310private:
311+ mesh_error_t configure ();
312+ mesh_error_t apply_configuration (int8_t mesh_if_id);
313+ mesh_error_t set_bbr_radius_address (void );
314+ mesh_error_t set_bbr_radius_shared_secret (void );
315+ mesh_error_t set_bbr_radius_timing (void );
316+ char _radius_ipv6_addr[40 ];
317+ ws_br_radius_timing_t _radius_timing;
318+ char *_shared_secret = NULL ;
319+ uint16_t _shared_secret_len = 0 ;
213320 int8_t _mesh_if_id = -1 ;
214-
321+ bool _radius_ipv6_addr_set = false ;
322+ bool _configured = false ;
323+ bool _radius_timing_set = false ;
215324};
216325
217326#endif
0 commit comments