coap_pdu_t: Obfuscate coap_pdu_t for applications

Move coap_pdu_t to coap_pdu_internal.h.

Move internal PDU based function definitions to coap_pdu_internal.h.

Replace most references to "struct coap_pdu_t" with "coap_pdu_t".

Create new enum coap_pdu_type_t, enum coap_pdu_code_t and coap_option_num_t,
using them where appropriate for clarity of documentation.

Provide new functions to allow applications to access/update parts of
coap_pdu_t as appropriate and document as appropriate.

Update examples to use these new access functions where appropriate.
This commit is contained in:
Jon Shallow committed 2021-04-20 10:31:14 +01:00
1 parent b9989ef485
commit e4e067e5fb
42 files changed
+1456 -749

No files matched your search

+3 -3
View File
@@ -87,7 +87,7 @@ coap_cache_derive_key(const coap_session_t *session,
}
}
while ((option = coap_option_next(&opt_iter))) {
if (is_cache_key(session->context, opt_iter.type)) {
if (is_cache_key(session->context, opt_iter.number)) {
if (!coap_digest_update(dctx, option, coap_opt_size(option))) {
coap_digest_free(dctx);
return NULL;
@@ -97,9 +97,9 @@ coap_cache_derive_key(const coap_session_t *session,
/* The body of a FETCH payload is part of the cache key,
* see https://tools.ietf.org/html/rfc8132#section-2 */
if (pdu->code == COAP_REQUEST_FETCH) {
if (pdu->code == COAP_REQUEST_CODE_FETCH) {
size_t len;
uint8_t *data;
const uint8_t *data;
if (coap_get_data(pdu, &len, &data)) {
if (!coap_digest_update(dctx, data, len)) {
coap_digest_free(dctx);