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] RADIUS shared secret .json parameter set correction #13517

Merged
merged 1 commit into from
Sep 2, 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 @@ -264,7 +264,10 @@ class WisunBorderRouter {
mesh_error_t configure();
mesh_error_t apply_configuration(int8_t mesh_if_id);
mesh_error_t set_bbr_radius_address(void);
mesh_error_t set_bbr_radius_shared_secret();
char _radius_ipv6_addr[40];
char *_shared_secret = NULL;
uint16_t _shared_secret_len = 0;
int8_t _mesh_if_id = -1;
bool _radius_ipv6_addr_set = false;
bool _configured = false;
Expand Down
35 changes: 33 additions & 2 deletions features/nanostack/mbed-mesh-api/source/WisunBorderRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ mesh_error_t WisunBorderRouter::configure()
status = set_radius_shared_secret(radius_shared_secret_len, (uint8_t *) radius_shared_secret);
if (status != MESH_ERROR_NONE) {
tr_error("Failed to set RADIUS shared secret!");
return status;
}
#endif

Expand All @@ -139,7 +138,6 @@ mesh_error_t WisunBorderRouter::configure()
status = set_radius_server_ipv6_address(radius_server_ipv6_addr);
if (status != MESH_ERROR_NONE) {
tr_error("Failed to set RADIUS server IPv6 address!");
return status;
}
#endif

Expand All @@ -153,6 +151,13 @@ mesh_error_t WisunBorderRouter::apply_configuration(int8_t mesh_if_id)
tr_error("Failed to apply RADIUS server IPv6 address!");
return MESH_ERROR_PARAM;
}

status = set_bbr_radius_shared_secret();
if (status != MESH_ERROR_NONE) {
tr_error("Failed to apply RADIUS server IPv6 address!");
return MESH_ERROR_PARAM;
}

return MESH_ERROR_NONE;
}

Expand Down Expand Up @@ -303,11 +308,37 @@ mesh_error_t WisunBorderRouter::set_radius_shared_secret(uint16_t shared_secret_
return MESH_ERROR_PARAM;
}

if (_shared_secret != NULL) {
delete[] _shared_secret;
}

_shared_secret = new (std::nothrow) char[shared_secret_len];
if (_shared_secret == NULL) {
return MESH_ERROR_MEMORY;
}

memcpy(_shared_secret, shared_secret, shared_secret_len);
_shared_secret_len = shared_secret_len;

int status = ws_bbr_radius_shared_secret_set(_mesh_if_id, shared_secret_len, shared_secret);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}

return set_bbr_radius_shared_secret();
}

mesh_error_t WisunBorderRouter::set_bbr_radius_shared_secret()
{
if (_shared_secret_len == 0 || _shared_secret == NULL) {
return MESH_ERROR_UNKNOWN;
}

int status = ws_bbr_radius_shared_secret_set(_mesh_if_id, _shared_secret_len, (uint8_t *) _shared_secret);
if (status != 0) {
return MESH_ERROR_UNKNOWN;
}

return MESH_ERROR_NONE;
}

Expand Down