net: coap: Fix coap_packet_is_request() check for empty code
Empty code was incorrectly matched as a request, fix that. Align coap_handle_request_len() function to behave as documented in the API documentation - in case of invalid request code (which is also the case for empty code) -ENOTSUP Should be returned. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
13cd48a431
commit
64e5a31b61
1 changed files with 2 additions and 2 deletions
|
@ -1172,7 +1172,7 @@ bool coap_packet_is_request(const struct coap_packet *cpkt)
|
||||||
{
|
{
|
||||||
uint8_t code = coap_header_get_code(cpkt);
|
uint8_t code = coap_header_get_code(cpkt);
|
||||||
|
|
||||||
return !(code & ~COAP_REQUEST_MASK);
|
return (code != COAP_CODE_EMPTY) && !(code & ~COAP_REQUEST_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int coap_handle_request_len(struct coap_packet *cpkt,
|
int coap_handle_request_len(struct coap_packet *cpkt,
|
||||||
|
@ -1183,7 +1183,7 @@ int coap_handle_request_len(struct coap_packet *cpkt,
|
||||||
struct sockaddr *addr, socklen_t addr_len)
|
struct sockaddr *addr, socklen_t addr_len)
|
||||||
{
|
{
|
||||||
if (!coap_packet_is_request(cpkt)) {
|
if (!coap_packet_is_request(cpkt)) {
|
||||||
return 0;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: deal with hierarchical resources */
|
/* FIXME: deal with hierarchical resources */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue