Skip to content

Commit 4d8c03b

Browse files
author
Mika Leppänen
authored
Border Router RADIUS client basic authentication functionality (ARMmbed#2406)
* Border Router RADIUS client basic authentication functionality Basic RADIUS authentication functionality.
1 parent fbfada9 commit 4d8c03b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3033
-227
lines changed

nanostack/ws_bbr_api.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,4 +355,39 @@ int ws_bbr_key_storage_memory_set(int8_t interface_id, uint8_t key_storages_numb
355355
*/
356356
int ws_bbr_key_storage_settings_set(int8_t interface_id, uint8_t alloc_max_number, uint16_t alloc_size, uint16_t storing_interval);
357357

358+
/**
359+
* ws_bbr_radius_address_set Set RADIUS server IPv6 address
360+
*
361+
* Function sets external RADIUS server IPv6 address to Border Router. Setting the
362+
* address enables external RADIUS server interface on Border Router. To disable external
363+
* RADIUS server interface, call the function with remote address set to NULL. The RADIUS
364+
* shared secret must be set before address is set using ws_bbr_radius_shared_secret_set()
365+
* call.
366+
*
367+
* \param interface_id Network interface ID.
368+
* \param address Pointer to IPv6 address or NULL to disable RADIUS. Address is in binary format (16 bytes).
369+
*
370+
* \return < 0 failure
371+
* \return >= 0 success
372+
*
373+
*/
374+
int ws_bbr_radius_address_set(int8_t interface_id, const uint8_t *address);
375+
376+
/**
377+
* ws_bbr_radius_shared_secret_set set RADIUS shared secret
378+
*
379+
* Function sets RADIUS shared secret to Border Router. Shared secret is usually an
380+
* ASCII string. Check the format and length constraints for the shared secret from
381+
* the documentation of RADIUS server you are connecting to.
382+
*
383+
* \param interface_id Network interface ID.
384+
* \param shared_secret_len The length of the shared secret in bytes. Maximum length is 255 bytes.
385+
* \param shared_secret Pointer to shared secret. Can be 8-bit ASCII string or byte array. Is not NUL terminated.
386+
*
387+
* \return < 0 failure
388+
* \return >= 0 success
389+
*
390+
*/
391+
int ws_bbr_radius_shared_secret_set(int8_t interface_id, const uint8_t shared_secret_len, const uint8_t *shared_secret);
392+
358393
#endif /* WS_BBR_API_H_ */

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ void ws_bbr_dhcp_address_lifetime_set(protocol_interface_info_entry_t *cur, uint
156156
DHCPv6_server_service_set_address_validlifetime(cur->id, current_global_prefix, dhcp_address_lifetime);
157157
}
158158

159+
bool ws_bbr_backbone_address_get(uint8_t *address)
160+
{
161+
if (backbone_interface_id < 0) {
162+
return false;
163+
}
164+
165+
if (arm_net_address_get(backbone_interface_id, ADDR_IPV6_GP, address) != 0) {
166+
// No global prefix available
167+
return false;
168+
}
169+
170+
return true;
171+
}
172+
159173
static void ws_bbr_rpl_root_start(protocol_interface_info_entry_t *cur, uint8_t *dodag_id)
160174
{
161175
tr_info("RPL root start");
@@ -1072,3 +1086,26 @@ int ws_bbr_key_storage_settings_set(int8_t interface_id, uint8_t alloc_max_numbe
10721086
return -1;
10731087
#endif
10741088
}
1089+
1090+
int ws_bbr_radius_address_set(int8_t interface_id, const uint8_t *address)
1091+
{
1092+
#ifdef HAVE_WS_BORDER_ROUTER
1093+
return ws_pae_controller_radius_address_set(interface_id, address);
1094+
#else
1095+
(void) interface_id;
1096+
(void) address;
1097+
return -1;
1098+
#endif
1099+
}
1100+
1101+
int ws_bbr_radius_shared_secret_set(int8_t interface_id, const uint8_t shared_secret_len, const uint8_t *shared_secret)
1102+
{
1103+
#ifdef HAVE_WS_BORDER_ROUTER
1104+
return ws_pae_controller_radius_shared_secret_set(interface_id, shared_secret_len, shared_secret);
1105+
#else
1106+
(void) interface_id;
1107+
(void) shared_secret_len;
1108+
(void) shared_secret;
1109+
return -1;
1110+
#endif
1111+
}

source/6LoWPAN/ws/ws_bbr_api_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void ws_bbr_dhcp_address_lifetime_set(protocol_interface_info_entry_t *cur, uint
3535

3636
bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
3737

38+
bool ws_bbr_backbone_address_get(uint8_t *address);
3839

3940
#else
4041

@@ -44,6 +45,7 @@ bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
4445
#define ws_bbr_rpl_config( cur, imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase)
4546
#define ws_bbr_dhcp_address_lifetime_set(cur, dhcp_address_lifetime)
4647
#define ws_bbr_ready_to_start(cur) true
48+
#define ws_bbr_backbone_address_get(address) 0
4749

4850
#endif //HAVE_WS_BORDER_ROUTER
4951

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,6 +3030,18 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
30303030
ws_llc_asynch_request(cur, &async_req);
30313031
}
30323032

3033+
static int8_t ws_bootstrap_backbone_ip_addr_get(protocol_interface_info_entry_t *interface_ptr, uint8_t *address)
3034+
{
3035+
(void) interface_ptr;
3036+
(void) address;
3037+
3038+
if (ws_bbr_backbone_address_get(address)) {
3039+
return 0;
3040+
}
3041+
3042+
return -1;
3043+
}
3044+
30333045
static void ws_bootstrap_event_handler(arm_event_s *event)
30343046
{
30353047
ws_bootsrap_event_type_e event_type;
@@ -3121,6 +3133,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
31213133
// Set PAN ID and network name to controller
31223134
ws_pae_controller_nw_info_set(cur, cur->ws_info->network_pan_id, cur->ws_info->pan_information.pan_version, cur->ws_info->cfg->gen.network_name);
31233135

3136+
// Set backbone IP address get callback
3137+
ws_pae_controller_auth_cb_register(cur, ws_bootstrap_backbone_ip_addr_get);
3138+
31243139
// Set PAE port to 10254 and authenticator relay to 10253 (and to own ll address)
31253140
ws_pae_controller_authenticator_start(cur, PAE_AUTH_SOCKET_PORT, ll_addr, EAPOL_RELAY_SOCKET_PORT);
31263141

0 commit comments

Comments
 (0)