libcoap
4.3.0
|
CoAP PDU Structures, Enums and Functions that are not exposed to applications. More...
Data Structures | |
struct | coap_pdu_t |
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload marker (0xff), then the payload if stored inline. More... | |
Functions | |
int | coap_pdu_resize (coap_pdu_t *pdu, size_t new_size) |
Dynamically grows the size of pdu to new_size . More... | |
int | coap_pdu_check_resize (coap_pdu_t *pdu, size_t new_size) |
Dynamically grows the size of pdu to new_size if needed. More... | |
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. More... | |
size_t | coap_pdu_parse_size (coap_proto_t proto, const uint8_t *data, size_t length) |
Parses data to extract the message size. More... | |
int | coap_pdu_parse_header (coap_pdu_t *pdu, coap_proto_t proto) |
Decode the protocol specific header for the specified PDU. More... | |
int | coap_pdu_parse_opt (coap_pdu_t *pdu) |
Verify consistency in the given CoAP PDU structure and locate the data. More... | |
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 . More... | |
void | coap_pdu_clear (coap_pdu_t *pdu, size_t size) |
Clears any contents from pdu and resets used_size , and data pointers. More... | |
int | coap_remove_option (coap_pdu_t *pdu, coap_option_num_t number) |
Removes (first) option of given number from the pdu . More... | |
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. More... | |
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. More... | |
size_t | coap_pdu_encode_header (coap_pdu_t *pdu, coap_proto_t proto) |
Compose the protocol specific header for the specified PDU. More... | |
int | coap_update_token (coap_pdu_t *pdu, size_t len, const uint8_t *data) |
Updates token in pdu with length len and data . More... | |
CoAP PDU Structures, Enums and Functions that are not exposed to applications.
#define COAP_DEBUG_BUF_SIZE (8 + 1024 * 2) |
Definition at line 51 of file coap_pdu_internal.h.
#define COAP_DEFAULT_MAX_PDU_RX_SIZE (8UL*1024*1024+256) |
Definition at line 60 of file coap_pdu_internal.h.
#define COAP_DEFAULT_VERSION 1 /* version of CoAP supported */ |
Definition at line 33 of file coap_pdu_internal.h.
#define COAP_DROPPED_RESPONSE -2 |
Indicates that a response is suppressed.
This will occur for error responses if the request was received via IP multicast.
Definition at line 68 of file coap_pdu_internal.h.
#define COAP_MAX_MESSAGE_SIZE_TCP0 (COAP_MESSAGE_SIZE_OFFSET_TCP8-1) /* 12 */ |
Definition at line 41 of file coap_pdu_internal.h.
#define COAP_MAX_MESSAGE_SIZE_TCP16 (COAP_MESSAGE_SIZE_OFFSET_TCP32-1) /* 65804 */ |
Definition at line 43 of file coap_pdu_internal.h.
#define COAP_MAX_MESSAGE_SIZE_TCP32 (COAP_MESSAGE_SIZE_OFFSET_TCP32+0xFFFFFFFF) |
Definition at line 44 of file coap_pdu_internal.h.
#define COAP_MAX_MESSAGE_SIZE_TCP8 (COAP_MESSAGE_SIZE_OFFSET_TCP16-1) /* 268 */ |
Definition at line 42 of file coap_pdu_internal.h.
#define COAP_MESSAGE_SIZE_OFFSET_TCP16 269 /* 13 + 256 */ |
Definition at line 37 of file coap_pdu_internal.h.
#define COAP_MESSAGE_SIZE_OFFSET_TCP32 65805 /* 269 + 65536 */ |
Definition at line 38 of file coap_pdu_internal.h.
#define COAP_MESSAGE_SIZE_OFFSET_TCP8 13 |
Definition at line 36 of file coap_pdu_internal.h.
#define COAP_PAYLOAD_START 0xFF /* payload marker */ |
Definition at line 72 of file coap_pdu_internal.h.
#define COAP_PDU_DELAYED -3 |
Definition at line 70 of file coap_pdu_internal.h.
#define COAP_PDU_IS_EMPTY | ( | pdu | ) | ((pdu)->code == 0) |
Definition at line 74 of file coap_pdu_internal.h.
#define COAP_PDU_IS_REQUEST | ( | pdu | ) | (!COAP_PDU_IS_EMPTY(pdu) && (pdu)->code < 32) |
Definition at line 75 of file coap_pdu_internal.h.
#define COAP_PDU_IS_RESPONSE | ( | pdu | ) | ((pdu)->code >= 64 && (pdu)->code < 224) |
Definition at line 76 of file coap_pdu_internal.h.
#define COAP_PDU_IS_SIGNALING | ( | pdu | ) | ((pdu)->code >= 224) |
Definition at line 77 of file coap_pdu_internal.h.
#define COAP_PDU_MAX_TCP_HEADER_SIZE 6 |
Definition at line 80 of file coap_pdu_internal.h.
#define COAP_PDU_MAX_UDP_HEADER_SIZE 4 |
Definition at line 79 of file coap_pdu_internal.h.
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.
The option will be inserted in the appropriate place in the options in the pdu.
pdu | The PDU where the option is to be inserted. |
number | The number of the new option. |
len | The length of the new option. |
data | The data of the new option. |
0
on failure. Definition at line 414 of file pdu.c.
int coap_pdu_check_resize | ( | coap_pdu_t * | pdu, |
size_t | new_size | ||
) |
Dynamically grows the size of pdu
to new_size
if needed.
The new size must not exceed the PDU's configured maximum size. On success, this function returns 1, otherwise 0.
pdu | The PDU to resize. |
new_size | The new size in bytes. |
Definition at line 241 of file pdu.c.
void coap_pdu_clear | ( | coap_pdu_t * | pdu, |
size_t | size | ||
) |
Clears any contents from pdu
and resets used_size
, and data
pointers.
max_size
is set to size
, any other field is set to 0
. Note that pdu
must be a valid pointer to a coap_pdu_t object created e.g. by coap_pdu_init().
pdu | The PDU to clear. |
size | The maximum size of the PDU. |
Definition at line 37 of file pdu.c.
size_t coap_pdu_encode_header | ( | coap_pdu_t * | pdu, |
coap_proto_t | proto | ||
) |
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
.
The target pdu must be large enough to This function returns 0
on error or a number greater than zero on success.
proto | Session's protocol |
data | The raw data to parse as CoAP PDU. |
length | The actual size of data . |
pdu | The PDU structure to fill. Note that the structure must provide space to hold at least the token and options part of the message. |
0
on error. Definition at line 1102 of file pdu.c.
int coap_pdu_parse_header | ( | coap_pdu_t * | pdu, |
coap_proto_t | proto | ||
) |
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.
This function returns 0
on error or a number greater than zero on success.
proto | Session's protocol |
data | The first byte of raw data to parse as CoAP PDU. |
0
on error. Definition at line 770 of file pdu.c.
int coap_pdu_parse_opt | ( | coap_pdu_t * | pdu | ) |
Verify consistency in the given CoAP PDU structure and locate the data.
This function returns 0
on error or a number greater than zero on success. This function only parses the token and options, up to the payload start marker.
pdu | The PDU structure to check. |
0
on error. Definition at line 977 of file pdu.c.
size_t coap_pdu_parse_size | ( | coap_proto_t | proto, |
const uint8_t * | data, | ||
size_t | length | ||
) |
Parses data
to extract the message size.
length
must be at least coap_pdu_parse_header_size(proto, data). This function returns 0
on error or a number greater than zero on success.
proto | Session's protocol |
data | The raw data to parse as CoAP PDU. |
length | The actual size of data . |
0
on error. Definition at line 793 of file pdu.c.
int coap_pdu_resize | ( | coap_pdu_t * | pdu, |
size_t | new_size | ||
) |
Dynamically grows the size of pdu
to new_size
.
The new size must not exceed the PDU's configure maximum size. On success, this function returns 1, otherwise 0.
pdu | The PDU to resize. |
new_size | The new size in bytes. |
Definition at line 207 of file pdu.c.
int coap_remove_option | ( | coap_pdu_t * | pdu, |
coap_option_num_t | number | ||
) |
Removes (first) option of given number from the pdu
.
pdu | The PDU to remove the option from. |
number | The number of the CoAP option to remove (first only removed). |
1
if success else 0
if error. Definition at line 314 of file pdu.c.
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.
pdu | The PDU where the option is to be updated. |
number | The number of the option to update (first only updated). |
len | The length of the updated option. |
data | The data of the updated option. |
0
on failure. Definition at line 503 of file pdu.c.
int coap_update_token | ( | coap_pdu_t * | pdu, |
size_t | len, | ||
const uint8_t * | data | ||
) |
Updates token in pdu
with length len
and data
.
This function returns 0
on error or a value greater than zero on success.
pdu | The PDU where the token is to be updated. |
len | The length of the new token. |
data | The token to add. |
0
on error. Definition at line 282 of file pdu.c.