37#define COAP_DEFAULT_PORT 5683
38#define COAPS_DEFAULT_PORT 5684
39#define COAP_DEFAULT_MAX_AGE 60
40#ifndef COAP_DEFAULT_MTU
41#define COAP_DEFAULT_MTU 1152
44#define COAP_BERT_BASE 1152
46#ifndef COAP_DEFAULT_HOP_LIMIT
47#define COAP_DEFAULT_HOP_LIMIT 16
50#define COAP_DEFAULT_SCHEME "coap"
53#define COAP_DEFAULT_URI_WELLKNOWN ".well-known/core"
56#define COAP_TOKEN_DEFAULT_MAX 8
57#if (UINT_MAX > 65804UL)
58#define COAP_TOKEN_EXT_MAX 65804UL
60#define COAP_TOKEN_EXT_MAX 4096
119#define COAP_OPTION_IF_MATCH 1
120#define COAP_OPTION_URI_HOST 3
121#define COAP_OPTION_ETAG 4
122#define COAP_OPTION_IF_NONE_MATCH 5
123#define COAP_OPTION_OBSERVE 6
124#define COAP_OPTION_URI_PORT 7
125#define COAP_OPTION_LOCATION_PATH 8
126#define COAP_OPTION_OSCORE 9
127#define COAP_OPTION_URI_PATH 11
128#define COAP_OPTION_CONTENT_FORMAT 12
129#define COAP_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
131#define COAP_OPTION_MAXAGE 14
132#define COAP_OPTION_URI_QUERY 15
133#define COAP_OPTION_HOP_LIMIT 16
134#define COAP_OPTION_ACCEPT 17
135#define COAP_OPTION_Q_BLOCK1 19
136#define COAP_OPTION_LOCATION_QUERY 20
137#define COAP_OPTION_BLOCK2 23
138#define COAP_OPTION_BLOCK1 27
139#define COAP_OPTION_SIZE2 28
140#define COAP_OPTION_Q_BLOCK2 31
141#define COAP_OPTION_PROXY_URI 35
142#define COAP_OPTION_PROXY_SCHEME 39
143#define COAP_OPTION_SIZE1 60
144#define COAP_OPTION_ECHO 252
145#define COAP_OPTION_NORESPONSE 258
146#define COAP_OPTION_RTAG 292
148#if (UINT_MAX > 65535)
149#define COAP_MAX_OPT 65535
151#define COAP_MAX_OPT 65534
160#define COAP_RESPONSE_CODE(N) (((N)/100 << 5) | (N)%100)
163#define COAP_RESPONSE_CLASS(C) (((C) >> 5) & 0xFF)
165#ifndef SHORT_ERROR_RESPONSE
178#define COAP_ERROR_PHRASE_LENGTH 32
181#define coap_response_phrase(x) ((char *)NULL)
183#define COAP_ERROR_PHRASE_LENGTH 0
186#define COAP_SIGNALING_CODE(N) (((N)/100 << 5) | (N)%100)
197#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE 2
198#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER 4
199#define COAP_SIGNALING_OPTION_EXTENDED_TOKEN_LENGTH 6
202#define COAP_SIGNALING_OPTION_CUSTODY 2
205#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS 2
206#define COAP_SIGNALING_OPTION_HOLD_OFF 4
209#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION 2
213#define COAP_MEDIATYPE_TEXT_PLAIN 0
214#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT 40
215#define COAP_MEDIATYPE_APPLICATION_XML 41
216#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM 42
217#define COAP_MEDIATYPE_APPLICATION_RDF_XML 43
218#define COAP_MEDIATYPE_APPLICATION_EXI 47
219#define COAP_MEDIATYPE_APPLICATION_JSON 50
220#define COAP_MEDIATYPE_APPLICATION_CBOR 60
221#define COAP_MEDIATYPE_APPLICATION_CWT 61
224#define COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON 256
227#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN 98
228#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1 18
229#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT 96
230#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0 16
231#define COAP_MEDIATYPE_APPLICATION_COSE_MAC 97
232#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0 17
234#define COAP_MEDIATYPE_APPLICATION_COSE_KEY 101
235#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET 102
238#define COAP_MEDIATYPE_APPLICATION_SENML_JSON 110
239#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON 111
240#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR 112
241#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR 113
242#define COAP_MEDIATYPE_APPLICATION_SENML_EXI 114
243#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI 115
244#define COAP_MEDIATYPE_APPLICATION_SENML_XML 310
245#define COAP_MEDIATYPE_APPLICATION_SENSML_XML 311
248#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR 271
251#define COAP_MEDIATYPE_APPLICATION_ACE_CBOR 19
254#define COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ 272
257#define COAP_MEDIATYPE_APPLICATION_OSCORE 10001
266#define COAP_INVALID_MID -1
272#define COAP_INVALID_TID COAP_INVALID_MID
286#define COAP_OPTION_KEY(option) (option).key
287#define COAP_OPTION_LENGTH(option) (option).length
288#define COAP_OPTION_DATA(option) ((unsigned char *)&(option) + sizeof(coap_option))
306coap_pdu_t *coap_pdu_from_pbuf(
struct pbuf *pbuf);
428 const uint8_t *token,
466 const uint8_t *data);
492 const uint8_t *data);
507 const uint8_t *data);
537 const uint8_t **data);
558 const uint8_t **data,
Helpers for handling options in CoAP PDUs.
uint16_t coap_option_num_t
Helper functions for URI treatment.
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.
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_delete_pdu(coap_pdu_t *pdu)
Dispose of an CoAP PDU and frees associated storage.
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.
coap_request_t
CoAP PDU Request methods.
#define COAP_RESPONSE_CODE(N)
#define COAP_SIGNALING_CODE(N)
coap_proto_t
CoAP protocol types.
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.
@ COAP_RESPONSE_CODE_INTERNAL_ERROR
@ COAP_RESPONSE_CODE_HOP_LIMIT_REACHED
@ COAP_SIGNALING_CODE_ABORT
@ COAP_RESPONSE_CODE_PRECONDITION_FAILED
@ COAP_RESPONSE_CODE_NOT_ALLOWED
@ COAP_RESPONSE_CODE_CHANGED
@ COAP_RESPONSE_CODE_NOT_ACCEPTABLE
@ COAP_SIGNALING_CODE_CSM
@ COAP_REQUEST_CODE_PATCH
@ COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED
@ COAP_RESPONSE_CODE_BAD_REQUEST
@ COAP_SIGNALING_CODE_PING
@ COAP_RESPONSE_CODE_INCOMPLETE
@ COAP_REQUEST_CODE_DELETE
@ COAP_SIGNALING_CODE_PONG
@ COAP_RESPONSE_CODE_NOT_IMPLEMENTED
@ COAP_RESPONSE_CODE_NOT_FOUND
@ COAP_RESPONSE_CODE_BAD_GATEWAY
@ COAP_RESPONSE_CODE_BAD_OPTION
@ COAP_RESPONSE_CODE_REQUEST_TOO_LARGE
@ COAP_RESPONSE_CODE_TOO_MANY_REQUESTS
@ COAP_RESPONSE_CODE_CONFLICT
@ COAP_RESPONSE_CODE_DELETED
@ COAP_RESPONSE_CODE_UNAUTHORIZED
@ COAP_RESPONSE_CODE_CREATED
@ COAP_RESPONSE_CODE_CONTENT
@ COAP_RESPONSE_CODE_UNPROCESSABLE
@ COAP_RESPONSE_CODE_CONTINUE
@ COAP_RESPONSE_CODE_VALID
@ COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT
@ COAP_SIGNALING_CODE_RELEASE
@ COAP_REQUEST_CODE_FETCH
@ COAP_RESPONSE_CODE_GATEWAY_TIMEOUT
@ COAP_REQUEST_CODE_IPATCH
@ COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE
@ COAP_RESPONSE_CODE_FORBIDDEN
CoAP binary data definition with const data.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...