Skip to content

Commit

Permalink
Merge pull request #13588 from mikaleppanen/radius_trace_corr
Browse files Browse the repository at this point in the history
[feature-wisun] Added initialization check to RADIUS ipv6 address
  • Loading branch information
Arto Kinnunen authored Sep 10, 2020
2 parents 42047d3 + 013ab40 commit b204ba5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class WisunBorderRouter {
char *_shared_secret = NULL;
uint16_t _shared_secret_len = 0;
int8_t _mesh_if_id = -1;
bool _radius_ipv6_addr_init = false;
bool _radius_ipv6_addr_set = false;
bool _configured = false;
bool _radius_timing_set = false;
Expand Down
10 changes: 8 additions & 2 deletions features/nanostack/mbed-mesh-api/source/WisunBorderRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void WisunBorderRouter::stop()

mesh_error_t WisunBorderRouter::configure()
{
#if defined(MBED_CONF_MBED_MESH_API_RADIUS_SHARED_SECRET) || defined(MBED_CONF_MBED_MESH_API_RADIUS_SERVER_IPV6_ADDRESS) || defined(MBED_CONF_MBED_MESH_API_RADIUS_RETRY_IMIN)
#if defined(MBED_CONF_MBED_MESH_API_RADIUS_SHARED_SECRET) || defined(MBED_CONF_MBED_MESH_API_RADIUS_SERVER_IPV6_ADDRESS)
mesh_error_t status;
#endif

Expand Down Expand Up @@ -281,8 +281,10 @@ mesh_error_t WisunBorderRouter::set_radius_server_ipv6_address(const char *addre
}
// Stored address (returned by get) is in the format given by user of the interface
strcpy(_radius_ipv6_addr, address);
_radius_ipv6_addr_init = true;
_radius_ipv6_addr_set = true;
} else {
_radius_ipv6_addr_init = true;
_radius_ipv6_addr_set = false;
}

Expand All @@ -303,6 +305,10 @@ mesh_error_t WisunBorderRouter::set_bbr_radius_address(void)
{
int status;

if (!_radius_ipv6_addr_init) {
return MESH_ERROR_NONE;
}

if (_radius_ipv6_addr_set) {
uint8_t ipv6_addr[16];
if (!stoip6(_radius_ipv6_addr, strlen(_radius_ipv6_addr), ipv6_addr)) {
Expand Down Expand Up @@ -348,7 +354,7 @@ mesh_error_t WisunBorderRouter::set_radius_shared_secret(uint16_t shared_secret_
mesh_error_t WisunBorderRouter::set_bbr_radius_shared_secret(void)
{
if (_shared_secret_len == 0 || _shared_secret == NULL) {
return MESH_ERROR_UNKNOWN;
return MESH_ERROR_NONE;
}

int status = ws_bbr_radius_shared_secret_set(_mesh_if_id, _shared_secret_len, (uint8_t *) _shared_secret);
Expand Down

0 comments on commit b204ba5

Please sign in to comment.