Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature-wisun] Added initialization check to RADIUS ipv6 address #13588

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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