|
libcoap 4.3.5-develop-3035cfd
|
API for PDUs. More...
Data Structures | |
| struct | coap_option |
Macros | |
| #define | COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ |
| #define | COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ |
| #define | COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ |
| #define | COAP_DEFAULT_MTU 1152 |
| #define | COAP_BERT_BASE 1152 |
| #define | COAP_DEFAULT_HOP_LIMIT 16 |
| #define | COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ |
| #define | COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" |
| well-known resources URI | |
| #define | COAP_TOKEN_DEFAULT_MAX 8 |
| #define | COAP_TOKEN_EXT_MAX 4096 |
| #define | COAP_RESPONSE_CODE(N) |
| #define | COAP_RESPONSE_CLASS(C) |
| #define | COAP_ERROR_PHRASE_LENGTH 32 |
| maximum length of error phrase | |
| #define | COAP_SIGNALING_CODE(N) |
| #define | COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ |
| #define | COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ |
| #define | COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ |
| #define | COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ |
| #define | COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ |
| #define | COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ |
| #define | COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ |
| #define | COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ |
| #define | COAP_MEDIATYPE_APPLICATION_CWT 61 /* application/cwt, RFC 8392 */ |
| #define | COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON 256 /* application/coap-group+json */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ |
| #define | COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ |
| #define | COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ |
| #define | COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271 /* application/dots+cbor */ |
| #define | COAP_MEDIATYPE_APPLICATION_ACE_CBOR 19 /* application/ace+cbor */ |
| #define | COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ 272 /* application/missing-blocks+cbor-seq */ |
| #define | COAP_MEDIATYPE_APPLICATION_OSCORE 10001 /* application/oscore */ |
| #define | COAP_INVALID_MID -1 |
| Indicates an invalid message id. | |
| #define | COAP_INVALID_TID COAP_INVALID_MID |
| Indicates an invalid message id. | |
| #define | COAP_OPTION_KEY(option) |
| #define | COAP_OPTION_LENGTH(option) |
| #define | COAP_OPTION_DATA(option) |
Typedefs | |
| typedef enum coap_pdu_type_t | coap_pdu_type_t |
| CoAP PDU message type definitions. | |
| typedef enum coap_request_t | coap_request_t |
| CoAP PDU Request methods. | |
| typedef enum coap_pdu_signaling_proto_t | coap_pdu_signaling_proto_t |
| typedef int | coap_mid_t |
| coap_mid_t is used to store the CoAP Message ID of a CoAP PDU. | |
| typedef enum coap_proto_t | coap_proto_t |
| CoAP protocol types Note: coap_layers_coap[] needs updating if extended. | |
| typedef enum coap_pdu_code_t | coap_pdu_code_t |
| Set of codes available for a PDU. | |
Functions | |
| const char * | coap_response_phrase (unsigned char code) |
Returns a human-readable response phrase for the specified CoAP response code. | |
| 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. | |
| 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_API void | coap_delete_pdu (coap_pdu_t *pdu) |
| Dispose of an CoAP PDU and free off associated storage. | |
| 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. | |
| 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. | |
| int | coap_add_token (coap_pdu_t *pdu, size_t len, const uint8_t *data) |
Adds token of length len to 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. | |
| 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. | |
| 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. | |
| 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_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_pdu_code_t | coap_pdu_get_code (const coap_pdu_t *pdu) |
Gets the PDU code associated with pdu. | |
| void | coap_pdu_set_code (coap_pdu_t *pdu, coap_pdu_code_t code) |
Sets the PDU code in the pdu. | |
| coap_pdu_type_t | coap_pdu_get_type (const coap_pdu_t *pdu) |
Gets the PDU type associated with pdu. | |
| void | coap_pdu_set_type (coap_pdu_t *pdu, coap_pdu_type_t type) |
Sets the PDU type in the pdu. | |
| coap_bin_const_t | coap_pdu_get_token (const coap_pdu_t *pdu) |
Gets the token associated with pdu. | |
| coap_mid_t | coap_pdu_get_mid (const coap_pdu_t *pdu) |
Gets the message id associated with pdu. | |
| void | coap_pdu_set_mid (coap_pdu_t *pdu, coap_mid_t mid) |
Sets the message id in the pdu. | |
API for PDUs.
| #define COAP_BERT_BASE 1152 |
Definition at line 46 of file coap_pdu.h.
| #define COAP_DEFAULT_HOP_LIMIT 16 |
Definition at line 49 of file coap_pdu.h.
| #define COAP_DEFAULT_MAX_AGE 60 /* default maximum object lifetime in seconds */ |
Definition at line 41 of file coap_pdu.h.
| #define COAP_DEFAULT_MTU 1152 |
Definition at line 43 of file coap_pdu.h.
| #define COAP_DEFAULT_PORT 5683 /* CoAP default UDP/TCP port */ |
Definition at line 39 of file coap_pdu.h.
| #define COAP_DEFAULT_SCHEME "coap" /* the default scheme for CoAP URIs */ |
Definition at line 52 of file coap_pdu.h.
| #define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core" |
well-known resources URI
Definition at line 55 of file coap_pdu.h.
| #define COAP_ERROR_PHRASE_LENGTH 32 |
maximum length of error phrase
Definition at line 114 of file coap_pdu.h.
| #define COAP_INVALID_MID -1 |
Indicates an invalid message id.
Definition at line 187 of file coap_pdu.h.
| #define COAP_INVALID_TID COAP_INVALID_MID |
Indicates an invalid message id.
Definition at line 193 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_ACE_CBOR 19 /* application/ace+cbor */ |
Definition at line 172 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_CBOR 60 /* application/cbor */ |
Definition at line 141 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON 256 /* application/coap-group+json */ |
Definition at line 145 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96 /* application/cose; cose-type="cose-encrypt" */ |
Definition at line 150 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16 /* application/cose; cose-type="cose-encrypt0" */ |
Definition at line 151 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101 /* application/cose-key */ |
Definition at line 155 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102 /* application/cose-key-set */ |
Definition at line 156 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97 /* application/cose; cose-type="cose-mac" */ |
Definition at line 152 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17 /* application/cose; cose-type="cose-mac0" */ |
Definition at line 153 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98 /* application/cose; cose-type="cose-sign" */ |
Definition at line 148 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18 /* application/cose; cose-type="cose-sign1" */ |
Definition at line 149 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_CWT 61 /* application/cwt, RFC 8392 */ |
Definition at line 142 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271 /* application/dots+cbor */ |
Definition at line 169 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_EXI 47 /* application/exi */ |
Definition at line 139 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_JSON 50 /* application/json */ |
Definition at line 140 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40 /* application/link-format */ |
Definition at line 135 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ 272 /* application/missing-blocks+cbor-seq */ |
Definition at line 175 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42 /* application/octet-stream */ |
Definition at line 137 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_OSCORE 10001 /* application/oscore */ |
Definition at line 178 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_RDF_XML 43 /* application/rdf+xml */ |
Definition at line 138 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112 /* application/senml+cbor */ |
Definition at line 161 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114 /* application/senml-exi */ |
Definition at line 163 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110 /* application/senml+json */ |
Definition at line 159 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENML_XML 310 /* application/senml+xml */ |
Definition at line 165 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113 /* application/sensml+cbor */ |
Definition at line 162 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115 /* application/sensml-exi */ |
Definition at line 164 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111 /* application/sensml+json */ |
Definition at line 160 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311 /* application/sensml+xml */ |
Definition at line 166 of file coap_pdu.h.
| #define COAP_MEDIATYPE_APPLICATION_XML 41 /* application/xml */ |
Definition at line 136 of file coap_pdu.h.
| #define COAP_MEDIATYPE_TEXT_PLAIN 0 /* text/plain (UTF-8) */ |
Definition at line 134 of file coap_pdu.h.
| #define COAP_OPTION_DATA | ( | option | ) |
Definition at line 209 of file coap_pdu.h.
| #define COAP_OPTION_KEY | ( | option | ) |
Definition at line 207 of file coap_pdu.h.
| #define COAP_OPTION_LENGTH | ( | option | ) |
Definition at line 208 of file coap_pdu.h.
| #define COAP_RESPONSE_CLASS | ( | C | ) |
Definition at line 99 of file coap_pdu.h.
| #define COAP_RESPONSE_CODE | ( | N | ) |
Definition at line 96 of file coap_pdu.h.
| #define COAP_SIGNALING_CODE | ( | N | ) |
Definition at line 122 of file coap_pdu.h.
| #define COAP_TOKEN_DEFAULT_MAX 8 |
Definition at line 58 of file coap_pdu.h.
| #define COAP_TOKEN_EXT_MAX 4096 |
Definition at line 62 of file coap_pdu.h.
| #define COAPS_DEFAULT_PORT 5684 /* CoAP default UDP/TCP port for secure transmission */ |
Definition at line 40 of file coap_pdu.h.
| typedef int coap_mid_t |
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Valid message ids are 0 to 2^16. Negative values are error codes.
Definition at line 184 of file coap_pdu.h.
| typedef enum coap_pdu_code_t coap_pdu_code_t |
Set of codes available for a PDU.
| typedef enum coap_pdu_signaling_proto_t coap_pdu_signaling_proto_t |
| typedef enum coap_pdu_type_t coap_pdu_type_t |
CoAP PDU message type definitions.
| typedef enum coap_proto_t coap_proto_t |
CoAP protocol types Note: coap_layers_coap[] needs updating if extended.
| typedef enum coap_request_t coap_request_t |
CoAP PDU Request methods.
| enum coap_bool_t |
| Enumerator | |
|---|---|
| COAP_BOOL_FALSE | |
| COAP_BOOL_TRUE | |
Definition at line 294 of file coap_pdu.h.
| enum coap_pdu_code_t |
Set of codes available for a PDU.
Definition at line 248 of file coap_pdu.h.
| Enumerator | |
|---|---|
| COAP_SIGNALING_CSM | |
| COAP_SIGNALING_PING | |
| COAP_SIGNALING_PONG | |
| COAP_SIGNALING_RELEASE | |
| COAP_SIGNALING_ABORT | |
Definition at line 124 of file coap_pdu.h.
| enum coap_pdu_type_t |
CoAP PDU message type definitions.
| Enumerator | |
|---|---|
| COAP_MESSAGE_CON | |
| COAP_MESSAGE_NON | |
| COAP_MESSAGE_ACK | |
| COAP_MESSAGE_RST | |
Definition at line 70 of file coap_pdu.h.
| enum coap_proto_t |
CoAP protocol types Note: coap_layers_coap[] needs updating if extended.
| Enumerator | |
|---|---|
| COAP_PROTO_NONE | |
| COAP_PROTO_UDP | |
| COAP_PROTO_DTLS | |
| COAP_PROTO_TCP | |
| COAP_PROTO_TLS | |
| COAP_PROTO_WS | |
| COAP_PROTO_WSS | |
| COAP_PROTO_LAST | |
Definition at line 234 of file coap_pdu.h.
| enum coap_request_t |
CoAP PDU Request methods.
| Enumerator | |
|---|---|
| COAP_REQUEST_GET | |
| COAP_REQUEST_POST | |
| COAP_REQUEST_PUT | |
| COAP_REQUEST_DELETE | |
| COAP_REQUEST_FETCH | |
| COAP_REQUEST_PATCH | |
| COAP_REQUEST_IPATCH | |
Definition at line 80 of file coap_pdu.h.
| 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.
This function will fail if data has already been added to the pdu.
| pdu | The PDU where the data is to be added. |
| len | The length of the data. |
| data | The data to add. |
1 if success, else 0 if failure. Definition at line 916 of file coap_pdu.c.
| 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.
This function will fail if data has already been added to the pdu.
The actual data must be copied at the returned location.
| pdu | The PDU where the data is to be added. |
| len | The length of the data. |
NULL is error. Definition at line 928 of file coap_pdu.c.
| 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.
This function will fail if data has already been added to the pdu.
Hence data must be added after optional coap_add_option() has been called.
Note: Where possible, the option data needs to be stripped of leading zeros (big endian) to reduce the amount of data needed in the PDU, as well as in some cases the maximum data size of an opton can be exceeded if not stripped and hence be illegal. This is done by using coap_encode_var_safe() or coap_encode_var_safe8().
| pdu | The PDU where the option is to be added. |
| 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 837 of file coap_pdu.c.
| int coap_add_token | ( | coap_pdu_t * | pdu, |
| size_t | len, | ||
| const uint8_t * | data ) |
Adds token of length len to pdu.
This function will fail if a token has already been added to the pdu.
Hence options and data must be added after optional coap_add_token() has been called.
| pdu | The PDU where the token is to be added. |
| len | The length of the new token. |
| data | The token to add. |
0 on error. Definition at line 413 of file coap_pdu.c.
| COAP_API void coap_delete_pdu | ( | coap_pdu_t * | pdu | ) |
Dispose of an CoAP PDU and free off associated storage.
Note: In general you should not call this function directly. When a PDU is sent with coap_send(), coap_delete_pdu() will be called automatically for you. This is not for the case for coap_send_recv() where the sending and receiving PDUs need to be explicitly deleted.
Note: If called with a reference count > 0, the reference count is decremented and the PDU still exists.
| pdu | The PDU for free off. |
Definition at line 190 of file coap_pdu.c.
| 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.
Returns 0 on error or 1 if *len and *data have correct values. Note that these values are destroyed with the pdu.
| pdu | The specified PDU. |
| len | Returns the length of the current data |
| data | Returns the ptr to the current data |
1 if len and data are correctly filled in, else 0 if there is no data. Definition at line 947 of file coap_pdu.c.
| 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.
Note: The data pointed to on return is destroyed when the PDU is destroyed.
| pdu | The specified PDU. |
| len | Returns the length of the current data |
| data | Returns the ptr to the current data |
| offset | Returns the offset of the current data from the start of the body comprising of many blocks (RFC7959) |
| total | Returns the total size of the body. If offset + length < total, then there is more data to follow. |
1 if len, data, offset and total are correctly filled in, else 0 if there is no data. Definition at line 955 of file coap_pdu.c.
| 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.
| type | The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, COAP_MESSAGE_ACK, COAP_MESSAGE_RST). |
| code | The message code of the PDU. |
| session | The session that will be using this PDU |
NULL if failure. Definition at line 165 of file coap_pdu.c.
| 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.
Specific options can be ignored and not copied across. The PDU data payload is not copied across.
| old_pdu | The PDU to duplicate |
| session | The session that will be using this PDU. |
| token_length | The length of the token to use in this duplicated PDU. |
| token | The token to use in this duplicated PDU. |
| drop_options | A list of options not to copy into the duplicated PDU. If NULL, then all options are copied across. |
NULL if failure. Definition at line 215 of file coap_pdu.c.
| coap_pdu_code_t coap_pdu_get_code | ( | const coap_pdu_t * | pdu | ) |
Gets the PDU code associated with pdu.
| pdu | The PDU object. |
Definition at line 1699 of file coap_pdu.c.
| coap_mid_t coap_pdu_get_mid | ( | const coap_pdu_t * | pdu | ) |
Gets the message id associated with pdu.
| pdu | The PDU object. |
Definition at line 1728 of file coap_pdu.c.
| coap_bin_const_t coap_pdu_get_token | ( | const coap_pdu_t * | pdu | ) |
Gets the token associated with pdu.
| pdu | The PDU object. |
Definition at line 1723 of file coap_pdu.c.
| coap_pdu_type_t coap_pdu_get_type | ( | const coap_pdu_t * | pdu | ) |
Gets the PDU type associated with pdu.
| pdu | The PDU object. |
Definition at line 1712 of file coap_pdu.c.
| 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.
The function returns a pointer to the node coap_pdu_t object on success, or NULL on error. The storage allocated for the result must be released with coap_delete_pdu() if coap_send() is not called.
| type | The type of the PDU (one of COAP_MESSAGE_CON, COAP_MESSAGE_NON, COAP_MESSAGE_ACK, COAP_MESSAGE_RST). |
| code | The message code of the PDU. |
| mid | The message id to set or 0 if unknown / not applicable. |
| size | The maximum allowed number of byte for the message. |
NULL on error. Definition at line 104 of file coap_pdu.c.
| 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 hold the token, options and 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. |
| pdu | The PDU structure to fill. Note that the structure must provide space to hold the token, optional options and optional data. |
0 on error. Definition at line 1569 of file coap_pdu.c.
| void coap_pdu_set_code | ( | coap_pdu_t * | pdu, |
| coap_pdu_code_t | code ) |
Sets the PDU code in the pdu.
| pdu | The PDU object. |
| code | The code to set in the PDU. |
Definition at line 1704 of file coap_pdu.c.
| void coap_pdu_set_mid | ( | coap_pdu_t * | pdu, |
| coap_mid_t | mid ) |
Sets the message id in the pdu.
| pdu | The PDU object. |
| mid | The message id value to set in the PDU. |
Definition at line 1733 of file coap_pdu.c.
| void coap_pdu_set_type | ( | coap_pdu_t * | pdu, |
| coap_pdu_type_t | type ) |
Sets the PDU type in the pdu.
| pdu | The PDU object. |
| type | The type to set for the PDU. |
Definition at line 1717 of file coap_pdu.c.
| const char * coap_response_phrase | ( | unsigned char | code | ) |
Returns a human-readable response phrase for the specified CoAP response code.
This function returns NULL if not found.
| code | The response code for which the literal phrase should be retrieved. |
NULL if not found. Definition at line 1022 of file coap_pdu.c.