net.c: fixed calculation of mask bit for no-response option

* The shift in function no_response was off by one bit.
* The response code must be checked, not the request method.
This commit is contained in:
Olaf Bergmann committed 2015-06-07 12:21:58 +02:00
1 parent bf9a3c7a1b
commit 6db8e5172d
1 file changed
+6 -2
+6 -2
View File
@@ -1325,8 +1325,12 @@ no_response(coap_pdu_t *request, coap_pdu_t *response) {
val = coap_decode_var_bytes(coap_opt_value(nores), coap_opt_length(nores));
}
return (COAP_RESPONSE_CLASS(request->hdr->code) > 0)
&& (((2 << (COAP_RESPONSE_CLASS(request->hdr->code) - 1)) & val) > 0);
debug("response class is %d (bit %d), val is %02x\n",
COAP_RESPONSE_CLASS(response->hdr->code),
(1 << (COAP_RESPONSE_CLASS(response->hdr->code) - 1)),
val);
return (COAP_RESPONSE_CLASS(response->hdr->code) > 0)
&& (((1 << (COAP_RESPONSE_CLASS(response->hdr->code) - 1)) & val) > 0);
}
#define WANT_WKC(Pdu,Key) \