diff --git a/include/coap3/coap_pdu_internal.h b/include/coap3/coap_pdu_internal.h index f112ac21..df2aa6d6 100644 --- a/include/coap3/coap_pdu_internal.h +++ b/include/coap3/coap_pdu_internal.h @@ -102,6 +102,9 @@ #define COAP_PDU_IS_REQUEST(pdu) (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) #define COAP_PDU_IS_RESPONSE(pdu) ((pdu)->code >= 64 && (pdu)->code < 224) #define COAP_PDU_IS_SIGNALING(pdu) ((pdu)->code >= 224) +#define COAP_PDU_IS_PING(pdu) ((COAP_PDU_IS_EMPTY(pdu) && \ + ((pdu)->type == COAP_MESSAGE_CON)) || \ + ((pdu)->code == COAP_SIGNALING_CODE_PING)) #define COAP_PDU_MAX_UDP_HEADER_SIZE 4 #define COAP_PDU_MAX_TCP_HEADER_SIZE 6 diff --git a/src/coap_oscore.c b/src/coap_oscore.c index eeccaee8..e9c5d0a2 100644 --- a/src/coap_oscore.c +++ b/src/coap_oscore.c @@ -271,7 +271,7 @@ coap_oscore_new_pdu_encrypted(coap_session_t *session, coap_pdu_t *pdu, coap_bin_const_t *kid_context, oscore_partial_iv_t send_partial_iv) { - uint8_t coap_request = COAP_PDU_IS_REQUEST(pdu); + uint8_t coap_request = COAP_PDU_IS_REQUEST(pdu) || COAP_PDU_IS_PING(pdu); coap_pdu_code_t code = coap_request ? COAP_REQUEST_CODE_POST : COAP_RESPONSE_CODE(204); coap_pdu_t *osc_pdu;