Merge pull request #5577 from VeijoPesonen/realtek_rtl8195am_gt_wifi-set-credential

REALTEK_RTL8195AM Wifi driver - adds check of credentials validity
pull/5693/head
Martin Kojtal 2017-12-12 17:31:04 +00:00 committed by GitHub
commit aff1d3002f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 1 deletions

View File

@ -130,6 +130,25 @@ nsapi_error_t RTWInterface::set_dhcp(bool dhcp)
*/
nsapi_error_t RTWInterface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security)
{
if(!ssid) {
return NSAPI_ERROR_PARAMETER;
}
switch (security) {
case NSAPI_SECURITY_WPA:
case NSAPI_SECURITY_WPA2:
case NSAPI_SECURITY_WPA_WPA2:
case NSAPI_SECURITY_WEP:
if((strlen(pass) < 8) || (strlen(pass) > 63)) { // 802.11 password 8-63 characters
return NSAPI_ERROR_PARAMETER;
}
break;
case NSAPI_SECURITY_NONE:
break;
default:
return NSAPI_ERROR_PARAMETER;
}
strncpy(_ssid, ssid, 255);
strncpy(_pass, pass, 255);
_security = security;