18#if defined(HAVE_LIMITS_H)
26#ifdef HAVE_ARPA_INET_H
37#define min(a,b) ((a) < (b) ? (a) : (b))
41#define max(a,b) ((a) > (b) ? (a) : (b))
76coap_pdu_from_pbuf(
struct pbuf *pbuf) {
82 LWIP_ASSERT(
"Can only deal with contiguous PBUFs (increase PBUF_POOL_BUFSIZE)",
83 pbuf->tot_len == pbuf->len);
84 LWIP_ASSERT(
"coap_io_do_io needs to receive an exclusive copy of the incoming pbuf",
110 assert(code <= 0xff);
111 assert(mid >= 0 && mid <= 0xffff);
114#if defined(WITH_LWIP) && MEMP_USE_CUSTOM_POOLS
117 if (memp_pools[MEMP_COAP_PDU]->stats->used + 1 >=
118 memp_pools[MEMP_COAP_PDU]->stats->avail) {
119 memp_pools[MEMP_COAP_PDU]->stats->err++;
128#if COAP_DEFAULT_MAX_PDU_RX_SIZE <= COAP_MAX_MESSAGE_SIZE_TCP16
143 if (pdu->pbuf ==
NULL) {
184 coap_log_crit(
"coap_new_pdu: cannot allocate memory for new PDU (size = %" PRIuS ")\n",
204 pbuf_free(pdu->pbuf);
218 const uint8_t *token,
240 const uint8_t *token,
243#if COAP_CLIENT_SUPPORT
244 uint8_t doing_first = session->doing_first;
255#if COAP_CLIENT_SUPPORT
256 session->doing_first = 0;
262#if COAP_CLIENT_SUPPORT
264 session->doing_first = doing_first;
300 const char *next = strchr(exp,
'/');
303 next ? (
int)(next - exp) : (
int)strlen(exp),
304 (
const uint8_t *)exp))
313 coap_log_info(
"coap_pdu_duplicate: Uri-Path-Abbrev value %" PRIu32 " not known for fallback\n",
344#if !defined(WITH_LWIP)
347 struct pbuf *new_hdr;
361#if !defined(WITH_LWIP)
366 new_hdr = pbuf_alloc(PBUF_TRANSPORT, new_size + pdu->
max_hdr_size, PBUF_RAM);
368 if (new_hdr ==
NULL) {
372#if !defined(WITH_LWIP)
375 memcpy(new_hdr->payload, pdu->pbuf->payload, pdu->pbuf->len);
376 pbuf_free(pdu->pbuf);
399 while (size > new_size)
421 coap_log_warn(
"coap_add_token: The token must defined first. Token ignored\n");
432 coap_log_warn(
"coap_add_token: Token size too large. Token ignored\n");
436 coap_log_warn(
"coap_add_token: Insufficient space for token. Token ignored\n");
446 memcpy(pdu->
token, data, len);
450 memcpy(&pdu->
token[1], data, len);
455 memcpy(&pdu->
token[2], data, len);
491 coap_log_warn(
"coap_update_token: Token size too large. Token ignored\n");
522 if (memcmp(pdu->
token, data, len) != 0)
523 memcpy(pdu->
token, data, len);
527 memcpy(&pdu->
token[1], data, len);
532 memcpy(&pdu->
token[2], data, len);
557 if (opt_iter.
number == number) {
575 opt_delta = decode_this.
delta + decode_next.
delta;
576 if (opt_delta < 13) {
578 next_option[0] = (next_option[0] & 0x0f) + (
coap_opt_t)(opt_delta << 4);
579 }
else if (opt_delta < 269 && decode_next.
delta < 13) {
582 next_option[0] = (next_option[1] & 0x0f) + (13 << 4);
583 next_option[1] = (
coap_opt_t)(opt_delta - 13);
584 }
else if (opt_delta < 269) {
586 next_option[1] = (
coap_opt_t)(opt_delta - 13);
587 }
else if (decode_next.
delta < 13) {
589 if (next_option - option < 2) {
597 if (opt_iter.
number == number) {
603 assert(option !=
NULL);
604 assert(next_option !=
NULL);
605 memmove(&next_option[1], next_option,
613 next_option[0] = (next_option[2] & 0x0f) + (14 << 4);
614 next_option[1] = (
coap_opt_t)((opt_delta - 269) >> 8);
615 next_option[2] = (opt_delta - 269) & 0xff;
616 }
else if (decode_next.
delta < 269) {
619 next_option[0] = (next_option[1] & 0x0f) + (14 << 4);
620 next_option[1] = (
coap_opt_t)((opt_delta - 269) >> 8);
621 next_option[2] = (opt_delta - 269) & 0xff;
623 next_option[1] = (
coap_opt_t)((opt_delta - 269) >> 8);
624 next_option[2] = (opt_delta - 269) & 0xff;
632 memmove(option, next_option, pdu->
used_size - (next_option - pdu->
token));
635 pdu->
data -= next_option - option;
645 coap_log_info(
"Option 'Echo' (4) cannot be repeated on a Response - dropped\n");
679 coap_log_info(
"Option '%s' (%d) is not defined as repeatable - dropped\n",
683 coap_log_info(
"Option number %d is not defined as repeatable\n",
693 const uint8_t *data) {
696 uint16_t prev_number = 0;
708 if (opt_iter.
number > number) {
712 prev_number = opt_iter.
number;
714 if (option ==
NULL) {
726 opt_delta = opt_iter.
number - number;
727 if (opt_delta == 0) {
740 if (opt_iter.
number > number) {
745 assert(option !=
NULL);
747 if (decode.
delta < 13) {
749 option[0] = (option[0] & 0x0f) + (
coap_opt_t)(opt_delta << 4);
750 }
else if (decode.
delta < 269 && opt_delta < 13) {
752 option[1] = (option[0] & 0x0f) + (
coap_opt_t)(opt_delta << 4);
754 }
else if (decode.
delta < 269 && opt_delta < 269) {
757 }
else if (opt_delta < 13) {
759 option[2] = (option[0] & 0x0f) + (
coap_opt_t)(opt_delta << 4);
761 }
else if (opt_delta < 269) {
763 option[1] = (option[0] & 0x0f) + 0xd0;
768 option[1] = (
coap_opt_t)((opt_delta - 269) >> 8);
769 option[2] = (opt_delta - 269) & 0xff;
772 memmove(&option[shift], &option[shrink],
775 number - prev_number, data, len))
778 if (shift >= shrink) {
781 pdu->
data += shift - shrink;
785 pdu->
data -= shrink - shift;
792 const uint8_t *data) {
796 size_t new_length = 0;
797 size_t old_length = 0;
808 if (new_length > old_length) {
810 pdu->
used_size + new_length - old_length))
816 if (new_length != old_length)
817 memmove(&option[new_length], &option[old_length],
821 decode.
delta, data, len))
824 if (new_length >= old_length) {
825 pdu->
used_size += new_length - old_length;
827 pdu->
data += new_length - old_length;
829 pdu->
used_size -= old_length - new_length;
831 pdu->
data -= old_length - new_length;
838 const uint8_t *data) {
840 coap_log_warn(
"coap_add_option: PDU already contains data\n");
844 coap_log_warn(
"qcoap_add_option: %d: Invalid option length / data\n", number);
852 const uint8_t *data) {
879 if (number < pdu->max_opt) {
880 coap_log_debug(
"coap_add_option: options are not in correct order\n");
891 memmove(&pdu->
data[optsize-1], &pdu->
data[-1],
894 pdu->
data += optsize;
901 number - pdu->
max_opt, data, len);
922 memcpy(payload, data, len);
923 return payload !=
NULL;
956 size_t *offset,
size_t *total) {
982#ifndef SHORT_ERROR_RESPONSE
1047 assert(optsize <= *length);
1054 *max_opt += option.
delta;
1063 const uint8_t *data) {
1065 size_t header_size = 0;
1068 uint8_t len = *data >> 4;
1086#if !COAP_DISABLE_TCP
1094 const uint8_t *data,
1102 const uint8_t *token_start =
NULL;
1105 uint8_t len = *data >> 4;
1106 uint8_t tkl = *data & 0x0f;
1110 token_start = &data[2];
1111 }
else if (length >= 2) {
1114 token_start = &data[3];
1115 }
else if (length >= 3) {
1118 token_start = &data[4];
1119 }
else if (length >= 5) {
1120 size = ((size_t)data[1] << 24) + ((
size_t)data[2] << 16)
1122 token_start = &data[6];
1133 size += ((uint16_t)token_start[0] << 8) + token_start[1] +
1148 uint8_t e_token_length;
1156 pdu->
type = (hdr[0] >> 4) & 0x03;
1158 pdu->
mid = (uint16_t)hdr[2] << 8 | hdr[3];
1174 e_token_length = hdr[0] & 0x0f;
1200 coap_log_debug(
"coap_pdu_parse: PDU header extended token size broken\n");
1243 if (len < 1 || len > 255)
1284 if (len < 1 || len > 255)
1288 if (len < 1 || len > 8)
1328 if (len < 1 || len > 255)
1368 if (len < 1 || len > 1034)
1372 if (len < 1 || len > 255)
1400 if (*len < prflen +1) {
1404 memcpy(*obp, prf, prflen);
1418 const uint8_t hex[] =
"0123456789abcdef";
1419 (*obp)[0] = hex[(c & 0xf0) >> 4];
1420 (*obp)[1] = hex[c & 0x0f];
1422 (*obp)[0] = isprint(c) ? c :
'.';
1437 if (pdu->
code == 0) {
1450 if (pdu->
code == 0) {
1460#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_WARN)
1465 const uint8_t *opt_val;
1468 coap_log_debug(
"coap_pdu_parse: %d.%02d: offset %u malformed option\n",
1480 coap_log_warn(
"coap_pdu_parse: %d.%02d: offset %u option %u has bad length %" PRIu32 " or value\n",
1502 for (i = 0; i < 2; i++) {
1507 outbuflen =
sizeof(outbuf);
1516 const uint32_t len =
1518 const uint8_t *opt_val =
1533 tlen = opt - opt_last;
1536 ok = ok &&
write_char(&obp, &outbuflen, *opt_last, i);
1555 coap_log_debug(
"coap_pdu_parse: message ending in payload start marker\n");
1560 pdu->
data = (uint8_t *)opt;
1570 const uint8_t *data,
1580 const uint8_t *data,
1589 if (!hdr_size || hdr_size > length)
1595 if (pdu->
token - hdr_size != data)
1596 memcpy(pdu->
token - hdr_size, data, length);
1604 uint8_t e_token_length;
1613 coap_log_warn(
"coap_pdu_encode_header: Token size too large. PDU ignored\n");
1619 coap_log_warn(
"coap_pdu_encode_header: not enough space for UDP-style header\n");
1626 pdu->
token[-2] = (uint8_t)(pdu->
mid >> 8);
1627 pdu->
token[-1] = (uint8_t)(pdu->
mid);
1629#if !COAP_DISABLE_TCP
1649 coap_log_warn(
"coap_pdu_encode_header: not enough space for TCP0 header\n");
1652 pdu->
token[-2] = (uint8_t)len << 4
1659 coap_log_warn(
"coap_pdu_encode_header: not enough space for TCP8 header\n");
1662 pdu->
token[-3] = 13 << 4 | e_token_length;
1669 coap_log_warn(
"coap_pdu_encode_header: not enough space for TCP16 header\n");
1672 pdu->
token[-4] = 14 << 4 | e_token_length;
1680 coap_log_warn(
"coap_pdu_encode_header: not enough space for TCP32 header\n");
1683 pdu->
token[-6] = 15 << 4 | e_token_length;
1693 coap_log_warn(
"coap_pdu_encode_header: unsupported protocol\n");
1706 assert(code <= 0xff);
1718 assert(type <= 0x3);
1734#if (UINT_MAX > 65535)
1735 assert(mid >= 0 && mid <= 0xffff);
1755 memcpy(&pdu_rw, &pdu,
sizeof(pdu_rw));
const char * coap_option_string(coap_pdu_code_t code, coap_option_num_t number)
Returns a textual description of the option name.
Library specific build wrapper for coap_internal.h.
void * coap_realloc_type(coap_memory_tag_t type, void *p, size_t size)
Reallocates a chunk p of bytes created by coap_malloc_type() or coap_realloc_type() and returns a poi...
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
size_t coap_opt_parse(const coap_opt_t *opt, size_t length, coap_option_t *result)
Parses the option pointed to by opt into result.
uint16_t coap_option_num_t
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
#define COAP_MAX_OPT
the highest option number we know
@ COAP_SIG_OPT_BLOCK_WISE_TRANSFER
@ COAP_SIG_OPT_EXTENDED_TOKEN_LENGTH
@ COAP_SIG_OPT_MAX_MESSAGE_SIZE
@ COAP_SIG_OPT_ALTERNATIVE_ADDRESS
@ COAP_OPTION_IF_NONE_MATCH
@ COAP_OPTION_PROXY_SCHEME
@ COAP_OPTION_CONTENT_FORMAT
@ COAP_OPTION_LOCATION_QUERY
@ COAP_OPTION_LOCATION_PATH
@ COAP_OPTION_URI_PATH_ABB
@ COAP_SIG_OPT_BAD_CSM_OPTION
static int coap_pdu_parse_opt_csm(coap_pdu_code_t code, coap_option_num_t option, uint16_t len)
static size_t next_option_safe(coap_opt_t **optp, size_t *length, uint16_t *max_opt)
Advances *optp to next option if still in PDU.
error_desc_t coap_error[]
static int write_prefix(char **obp, size_t *len, const char *prf, size_t prflen)
static int write_char(char **obp, size_t *len, int c, int printable)
uint16_t coap_new_message_id_lkd(coap_session_t *session)
Returns a new message id and updates session->tx_mid accordingly.
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t len)
Decodes multiple-length byte sequences.
#define coap_lock_unlock()
Dummy for no thread-safe code.
#define coap_lock_check_locked()
Dummy for no thread-safe code.
#define coap_lock_lock(failed)
Dummy for no thread-safe code.
#define coap_log_debug(...)
#define coap_log_info(...)
#define coap_log_warn(...)
#define coap_log_crit(...)
coap_opt_t * coap_option_next(coap_opt_iterator_t *oi)
Updates the iterator oi to point to the next option.
size_t coap_opt_encode(coap_opt_t *opt, size_t maxlen, uint16_t delta, const uint8_t *val, size_t length)
Encodes option with given delta into opt.
uint32_t coap_opt_length(const coap_opt_t *opt)
Returns the length of the given option.
coap_opt_iterator_t * coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, const coap_opt_filter_t *filter)
Initializes the given option iterator oi to point to the beginning of the pdu's option list.
size_t coap_opt_encode_size(uint16_t delta, size_t length)
Compute storage bytes needed for an option with given delta and length.
#define COAP_OPT_ALL
Pre-defined filter that includes all options.
void coap_option_filter_clear(coap_opt_filter_t *filter)
Clears filter filter.
coap_opt_t * coap_check_option(const coap_pdu_t *pdu, coap_option_num_t number, coap_opt_iterator_t *oi)
Retrieves the first option of number number from pdu.
const uint8_t * coap_opt_value(const coap_opt_t *opt)
Returns a pointer to the value of the given option.
int coap_option_filter_get(coap_opt_filter_t *filter, coap_option_num_t option)
Checks if number is contained in filter.
int coap_option_filter_set(coap_opt_filter_t *filter, coap_option_num_t option)
Sets the corresponding entry for number in filter.
#define COAP_MESSAGE_SIZE_OFFSET_TCP8
coap_pdu_t * coap_pdu_reference_lkd(coap_pdu_t *pdu)
Increment reference counter on a pdu to stop it prematurely getting freed off when coap_delete_pdu() ...
void coap_delete_pdu_lkd(coap_pdu_t *pdu)
Dispose of an CoAP PDU and free off associated storage.
#define COAP_DEBUG_BUF_SIZE
#define COAP_TOKEN_EXT_2B_TKL
size_t coap_insert_option(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Inserts option of given number in the pdu with the appropriate data.
int coap_remove_option(coap_pdu_t *pdu, coap_option_num_t number)
Removes (first) option of given number from the pdu.
int coap_update_token(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Updates token in pdu with length len and data.
#define COAP_TOKEN_EXT_1B_BIAS
#define COAP_PDU_MAX_UDP_HEADER_SIZE
int coap_pdu_parse_opt(coap_pdu_t *pdu, coap_opt_filter_t *error_opts)
Verify consistency in the given CoAP PDU structure and locate the data.
int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto)
Decode the protocol specific header for the specified PDU.
size_t coap_pdu_parse_header_size(coap_proto_t proto, const uint8_t *data)
Interprets data to determine the number of bytes in the header.
coap_pdu_t * coap_new_pdu_lkd(coap_pdu_type_t type, coap_pdu_code_t code, coap_session_t *session)
Creates a new CoAP PDU.
int coap_pdu_parse_opt_base(coap_option_num_t number, size_t len, const uint8_t *opt_val)
Check the length / data (if appropriate) of an option.
#define COAP_PDU_MAX_TCP_HEADER_SIZE
#define COAP_MAX_MESSAGE_SIZE_TCP8
#define COAP_DEFAULT_MAX_PDU_RX_SIZE
#define COAP_PDU_IS_SIGNALING(pdu)
#define COAP_TOKEN_EXT_2B_BIAS
#define COAP_MAX_MESSAGE_SIZE_TCP0
#define COAP_MESSAGE_SIZE_OFFSET_TCP16
void coap_pdu_clear(coap_pdu_t *pdu, size_t size)
Clears any contents from pdu and resets used_size, and data pointers.
coap_pdu_t * coap_pdu_duplicate_lkd(const coap_pdu_t *old_pdu, coap_session_t *session, size_t token_length, const uint8_t *token, coap_opt_filter_t *drop_options, coap_bool_t expand_opt_abb)
Duplicate an existing PDU.
#define COAP_MESSAGE_SIZE_OFFSET_TCP32
int coap_option_check_repeatable(coap_pdu_t *pdu, coap_option_num_t number)
Check whether the option is allowed to be repeated or not.
size_t coap_update_option(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Updates existing first option of given number in the pdu with the new data.
#define COAP_TOKEN_EXT_1B_TKL
size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto)
Compose the protocol specific header for the specified PDU.
#define COAP_DEFAULT_VERSION
int coap_pdu_parse2(coap_proto_t proto, const uint8_t *data, size_t length, coap_pdu_t *pdu, coap_opt_filter_t *error_opts)
Parses data into the CoAP PDU structure given in result.
#define COAP_PAYLOAD_START
int coap_pdu_check_resize(coap_pdu_t *pdu, size_t size)
Dynamically grows the size of pdu to new_size if needed.
size_t coap_pdu_parse_size(coap_proto_t proto, const uint8_t *data, size_t length)
Parses data to extract the message size.
coap_pdu_t * coap_const_pdu_reference_lkd(const coap_pdu_t *pdu)
Increment reference counter on a const pdu to stop it prematurely getting freed off when coap_delete_...
int coap_pdu_resize(coap_pdu_t *pdu, size_t new_size)
Dynamically grows the size of pdu to new_size.
#define COAP_PDU_IS_REQUEST(pdu)
#define COAP_MAX_MESSAGE_SIZE_TCP16
size_t coap_add_option_internal(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Adds option of given number to pdu that is passed as first parameter.
coap_pdu_code_t coap_pdu_get_code(const coap_pdu_t *pdu)
Gets the PDU code associated with pdu.
const char * coap_response_phrase(unsigned char code)
Returns a human-readable response phrase for the specified CoAP response code.
COAP_API void coap_delete_pdu(coap_pdu_t *pdu)
Dispose of an CoAP PDU and free off associated storage.
uint8_t * coap_add_data_after(coap_pdu_t *pdu, size_t len)
Adds given data to the pdu that is passed as first parameter but does not.
void coap_pdu_set_code(coap_pdu_t *pdu, coap_pdu_code_t code)
Sets the PDU code in the pdu.
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
COAP_API coap_pdu_t * coap_pdu_duplicate(const coap_pdu_t *old_pdu, coap_session_t *session, size_t token_length, const uint8_t *token, coap_opt_filter_t *drop_options)
Duplicate an existing PDU.
#define COAP_TOKEN_EXT_MAX
#define COAP_RESPONSE_CODE(N)
coap_proto_t
CoAP protocol types Note: coap_layers_coap[] needs updating if extended.
coap_pdu_code_t
Set of codes available for a PDU.
coap_pdu_type_t
CoAP PDU message type definitions.
int coap_add_token(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Adds token of length len to pdu.
void coap_pdu_set_type(coap_pdu_t *pdu, coap_pdu_type_t type)
Sets the PDU type in the pdu.
size_t coap_add_option(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Adds option of given number to pdu that is passed as first parameter.
coap_pdu_signaling_proto_t
coap_pdu_type_t coap_pdu_get_type(const coap_pdu_t *pdu)
Gets the PDU type associated with pdu.
int coap_get_data(const coap_pdu_t *pdu, size_t *len, const uint8_t **data)
Retrieves the length and data pointer of specified PDU.
int coap_pdu_parse(coap_proto_t proto, const uint8_t *data, size_t length, coap_pdu_t *pdu)
Parses data into the CoAP PDU structure given in result.
void coap_pdu_set_mid(coap_pdu_t *pdu, coap_mid_t mid)
Sets the message id in the pdu.
COAP_API coap_pdu_t * coap_new_pdu(coap_pdu_type_t type, coap_pdu_code_t code, coap_session_t *session)
Creates a new CoAP PDU.
coap_pdu_t * coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, coap_mid_t mid, size_t size)
Creates a new CoAP PDU with at least enough storage space for the given size maximum message size.
int coap_get_data_large(const coap_pdu_t *pdu, size_t *len, const uint8_t **data, size_t *offset, size_t *total)
Retrieves the data from a PDU, with support for large bodies of data that spans multiple PDUs.
coap_mid_t coap_pdu_get_mid(const coap_pdu_t *pdu)
Gets the message id associated with pdu.
int coap_add_data(coap_pdu_t *pdu, size_t len, const uint8_t *data)
Adds given data to the pdu that is passed as first parameter.
coap_bin_const_t coap_pdu_get_token(const coap_pdu_t *pdu)
Gets the token associated with pdu.
size_t coap_session_max_pdu_size_lkd(const coap_session_t *session)
Get maximum acceptable PDU size.
#define COAP_PROTO_NOT_RELIABLE(p)
#define COAP_PROTO_RELIABLE(p)
void coap_delete_binary(coap_binary_t *s)
Deletes the given coap_binary_t object and releases any memory allocated.
int coap_check_dots(const uint8_t *s, size_t len)
Checks if path segment s consists of one or two dots.
coap_upa_chain_t * coap_upa_server_mapping_chain
const char * coap_map_abbrev_uri_path(coap_upa_chain_t *chain, uint32_t value)
Determine the expanded Uri-Path-Abbrev option value.
CoAP binary data definition with const data.
size_t length
length of binary data
const uint8_t * s
read-only binary data
Iterator to run through PDU options.
coap_option_num_t number
decoded option number
Representation of CoAP options.
uint8_t max_hdr_size
space reserved for protocol-specific header
uint16_t max_opt
highest option number in PDU
uint8_t * token
first byte of token (or extended length bytes prefix), if any, or options
coap_lg_xmit_t * lg_xmit
Holds ptr to lg_xmit if sending a set of blocks.
size_t body_length
Holds body data length.
size_t max_size
maximum size for token, options and payload, or zero for variable size pdu
const uint8_t * body_data
Holds ptr to re-assembled data or NULL.
size_t body_offset
Holds body data offset.
unsigned ref
reference count
coap_pdu_code_t code
request method (value 1–31) or response code (value 64-255)
uint8_t hdr_size
actual size used for protocol-specific header (0 until header is encoded)
coap_bin_const_t actual_token
Actual token in pdu.
uint8_t * data
first byte of payload, if any
coap_mid_t mid
message id, if any, in regular host byte order
uint32_t e_token_length
length of Token space (includes leading extended bytes
size_t used_size
used bytes of storage for token, options and payload
uint8_t crit_opt
Set if unknown critical option for proxy.
coap_binary_t * data_free
Data to be freed off by coap_delete_pdu().
size_t alloc_size
allocated storage for token, options and payload
coap_session_t * session
Session responsible for PDU or NULL.
size_t body_total
Holds body data total size.
coap_pdu_type_t type
message type
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
coap_proto_t proto
protocol used