From 6db8e5172dcc4b30b8124bd3c91cf469b705b54f Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Fri, 5 Jun 2015 17:45:01 +0200 Subject: [PATCH] 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. --- src/net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/net.c b/src/net.c index c7c08c50..27a1ca1a 100644 --- a/src/net.c +++ b/src/net.c @@ -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) \