Merge pull request #7832 from juhaylinen/fix-nanostack-setsockoptions

Nanostack: Fix return code for unsupported socket options
pull/7890/head
Cruz Monrreal 2018-08-21 09:58:59 -05:00 committed by GitHub
commit d9367f88f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 11 deletions

View File

@ -793,12 +793,15 @@ nsapi_error_t Nanostack::setsockopt(void *handle, int level, int optname, const
break;
}
default:
return NSAPI_ERROR_PARAMETER;
return NSAPI_ERROR_UNSUPPORTED;
}
}
if (::socket_setsockopt(socket->socket_id, level, optname, optval, optlen) == 0) {
int retcode = ::socket_setsockopt(socket->socket_id, level, optname, optval, optlen);
if (retcode == 0) {
return NSAPI_ERROR_OK;
} else if (retcode == -2) {
return NSAPI_ERROR_UNSUPPORTED;
} else {
return NSAPI_ERROR_PARAMETER;
}
@ -812,19 +815,19 @@ nsapi_error_t Nanostack::getsockopt(void *handle, int level, int optname, void *
return NSAPI_ERROR_NO_SOCKET;
}
nsapi_error_t ret;
NanostackLockGuard lock;
uint16_t optlen16 = *optlen;
if (::socket_getsockopt(socket->socket_id, level, optname, optval, &optlen16) == 0) {
ret = NSAPI_ERROR_OK;
*optlen = optlen16;
} else {
ret = NSAPI_ERROR_PARAMETER;
}
return ret;
int retcode = ::socket_getsockopt(socket->socket_id, level, optname, optval, &optlen16);
if (retcode == 0) {
*optlen = optlen16;
return NSAPI_ERROR_OK;
} else if (retcode == -2) {
return NSAPI_ERROR_UNSUPPORTED;
} else {
return NSAPI_ERROR_PARAMETER;
}
}
nsapi_error_t Nanostack::socket_listen(void *handle, int backlog)