Loading...
Searching...
No Matches
coap.h File Reference

Generic CoAP values as defined by RFC7252. More...

Detailed Description

Generic CoAP values as defined by RFC7252.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file coap.h.

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COAP_PORT   (5683)
 Default CoAP port.
 
#define COAPS_PORT   (5684)
 Default CoAP DTLS port.
 
#define COAP_V1   (1)
 Identifier for CoAP version 1 (RFC 7252)
 
#define COAP_PAYLOAD_MARKER   (0xFF)
 Marks the boundary between header and payload.
 

Enumerations

enum  coap_blksize_t {
  COAP_BLOCKSIZE_16 = 0 , COAP_BLOCKSIZE_32 , COAP_BLOCKSIZE_64 , COAP_BLOCKSIZE_128 ,
  COAP_BLOCKSIZE_256 , COAP_BLOCKSIZE_512 , COAP_BLOCKSIZE_1024
}
 Coap block-wise-transfer size SZX. More...
 

CoAP option numbers

#define COAP_OPT_IF_MATCH   (1)
 
#define COAP_OPT_URI_HOST   (3)
 
#define COAP_OPT_ETAG   (4)
 
#define COAP_OPT_IF_NONE_MATCH   (5)
 
#define COAP_OPT_OBSERVE   (6)
 
#define COAP_OPT_LOCATION_PATH   (8)
 
#define COAP_OPT_OSCORE   (9)
 OSCORE option.
 
#define COAP_OPT_URI_PATH   (11)
 
#define COAP_OPT_CONTENT_FORMAT   (12)
 
#define COAP_OPT_MAX_AGE   (14)
 
#define COAP_OPT_URI_QUERY   (15)
 
#define COAP_OPT_HOP_LIMIT   (16)
 Hop-Limit option.
 
#define COAP_OPT_ACCEPT   (17)
 
#define COAP_OPT_Q_BLOCK1   (19)
 Q-Block1 option.
 
#define COAP_OPT_LOCATION_QUERY   (20)
 
#define COAP_OPT_EDHOC   (21)
 EDHOC option.
 
#define COAP_OPT_BLOCK2   (23)
 
#define COAP_OPT_BLOCK1   (27)
 
#define COAP_OPT_SIZE2   (28)
 Size2 option.
 
#define COAP_OPT_Q_BLOCK2   (31)
 Q-Block2 option.
 
#define COAP_OPT_PROXY_URI   (35)
 
#define COAP_OPT_PROXY_SCHEME   (39)
 
#define COAP_OPT_SIZE1   (60)
 Size1 option.
 
#define COAP_OPT_ECHO   (252)
 Echo option.
 
#define COAP_OPT_NO_RESPONSE   (258)
 suppress CoAP response
 
#define COAP_OPT_REQUEST_TAG   (292)
 Request-Tag option.
 

Message types – confirmable, non-confirmable, etc.

#define COAP_TYPE_CON   (0)
 
#define COAP_TYPE_NON   (1)
 
#define COAP_TYPE_ACK   (2)
 
#define COAP_TYPE_RST   (3)
 

CoAP method codes used in header

#define COAP_CLASS_REQ   (0)
 Code Class for Request.
 
enum  coap_method_t {
  COAP_METHOD_GET = 1 , COAP_METHOD_POST = 2 , COAP_METHOD_PUT = 3 , COAP_METHOD_DELETE = 4 ,
  COAP_METHOD_FETCH = 5 , COAP_METHOD_PATCH = 6 , COAP_METHOD_IPATCH = 7
}
 CoAP method codes used in request. More...
 

Empty CoAP message code

#define COAP_CODE_EMPTY   (0)
 

Response message codes: success

#define COAP_CLASS_SUCCESS   (2)
 
#define COAP_CODE_CREATED   ((2 << 5) | 1)
 
#define COAP_CODE_DELETED   ((2 << 5) | 2)
 
#define COAP_CODE_VALID   ((2 << 5) | 3)
 
#define COAP_CODE_CHANGED   ((2 << 5) | 4)
 
#define COAP_CODE_204   ((2 << 5) | 4)
 
#define COAP_CODE_CONTENT   ((2 << 5) | 5)
 
#define COAP_CODE_205   ((2 << 5) | 5)
 
#define COAP_CODE_CONTINUE   ((2 << 5) | 31)
 
#define COAP_CODE_231   ((2 << 5) | 31)
 

Response message codes: client error

#define COAP_CLASS_CLIENT_FAILURE   (4)
 
#define COAP_CODE_BAD_REQUEST   ((4 << 5) | 0)
 
#define COAP_CODE_UNAUTHORIZED   ((4 << 5) | 1)
 
#define COAP_CODE_BAD_OPTION   ((4 << 5) | 2)
 
#define COAP_CODE_FORBIDDEN   ((4 << 5) | 3)
 
#define COAP_CODE_PATH_NOT_FOUND   ((4 << 5) | 4)
 
#define COAP_CODE_404   ((4 << 5) | 4)
 
#define COAP_CODE_METHOD_NOT_ALLOWED   ((4 << 5) | 5)
 
#define COAP_CODE_NOT_ACCEPTABLE   ((4 << 5) | 6)
 
#define COAP_CODE_REQUEST_ENTITY_INCOMPLETE   ((4 << 5) | 8)
 
#define COAP_CODE_CONFLICT   ((4 << 5) | 9)
 
#define COAP_CODE_PRECONDITION_FAILED   ((4 << 5) | 12)
 
#define COAP_CODE_REQUEST_ENTITY_TOO_LARGE   ((4 << 5) | 13)
 
#define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT   ((4 << 5) | 15)
 
#define COAP_CODE_UNPROCESSABLE_ENTITY   ((4 << 5) | 22)
 
#define COAP_CODE_TOO_MANY_REQUESTS   ((4 << 5) | 29)
 

Response message codes: server error

#define COAP_CLASS_SERVER_FAILURE   (5)
 
#define COAP_CODE_INTERNAL_SERVER_ERROR   ((5 << 5) | 0)
 
#define COAP_CODE_NOT_IMPLEMENTED   ((5 << 5) | 1)
 
#define COAP_CODE_BAD_GATEWAY   ((5 << 5) | 2)
 
#define COAP_CODE_SERVICE_UNAVAILABLE   ((5 << 5) | 3)
 
#define COAP_CODE_GATEWAY_TIMEOUT   ((5 << 5) | 4)
 
#define COAP_CODE_PROXYING_NOT_SUPPORTED   ((5 << 5) | 5)
 

Content-Format option codes

#define COAP_FORMAT_TEXT   (0)
 
#define COAP_FORMAT_COSE_ENCRYPT0   (16)
 Content-Type application/cose; cose-type="cose-encrypt0"
 
#define COAP_FORMAT_COSE_MAC0   (17)
 Content-Type application/cose; cose-type="cose-mac0"
 
#define COAP_FORMAT_COSE_SIGN1   (18)
 Content-Type application/cose; cose-type="cose-sign1"
 
#define COAP_FORMAT_ACE_CBOR   (19)
 Content-Type application/ace+cbor
 
#define COAP_FORMAT_IMAGE_GIF   (21)
 Content-Type image/gif
 
#define COAP_FORMAT_IMAGE_JPEG   (22)
 Content-Type image/jpeg
 
#define COAP_FORMAT_IMAGE_PNG   (23)
 Content-Type image/png
 
#define COAP_FORMAT_LINK   (40)
 
#define COAP_FORMAT_XML   (41)
 
#define COAP_FORMAT_OCTET   (42)
 
#define COAP_FORMAT_EXI   (47)
 
#define COAP_FORMAT_JSON   (50)
 
#define COAP_FORMAT_JSON_PATCH_JSON   (51)
 
#define COAP_FORMAT_MERGE_PATCH_JSON   (52)
 
#define COAP_FORMAT_CBOR   (60)
 
#define COAP_FORMAT_CWT   (61)
 Content-Type application/cwt
 
#define COAP_FORMAT_MULTIPART_CORE   (62)
 Content-Type application/multipart-core
 
#define COAP_FORMAT_CBOR_SEQ   (63)
 Content-Type application/cbor-seq
 
#define COAP_FORMAT_COSE_ENCRYPT   (96)
 Content-Type application/cose; cose-type="cose-encrypt"
 
#define COAP_FORMAT_COSE_MAC   (97)
 Content-Type application/cose; cose-type="cose-mac"
 
#define COAP_FORMAT_COSE_SIGN   (98)
 Content-Type application/cose; cose-type="cose-sign"
 
#define COAP_FORMAT_COSE_KEY   (101)
 Content-Type application/cose-key
 
#define COAP_FORMAT_COSE_KEY_SET   (102)
 Content-Type application/cose-key-set
 
#define COAP_FORMAT_SENML_JSON   (110)
 
#define COAP_FORMAT_SENSML_JSON   (111)
 
#define COAP_FORMAT_SENML_CBOR   (112)
 
#define COAP_FORMAT_SENSML_CBOR   (113)
 
#define COAP_FORMAT_SENML_EXI   (114)
 
#define COAP_FORMAT_SENSML_EXI   (115)
 
#define COAP_FORMAT_YANG_DATA_CBOR_SID   (140)
 Content-Type application/yang-data+cbor; id=sid
 
#define COAP_FORMAT_COAP_GROUP_JSON   (256)
 Content-Type application/coap-group+json
 
#define COAP_FORMAT_PROBLEM_DETAILS_CBOR   (257)
 Content-Type application/concise-problem-details+cbor
 
#define COAP_FORMAT_SWID_CBOR   (258)
 Content-Type application/swid+cbor
 
#define COAP_FORMAT_PKIXCMP   (259)
 Content-Type application/pkixcmp
 
#define COAP_FORMAT_DOTS_CBOR   (271)
 Content-Type application/dots+cbor
 
#define COAP_FORMAT_MISSING_BLOCKS_CBOR_SEQ   (272)
 Content-Type application/missing-blocks+cbor-seq
 
#define COAP_FORMAT_PKCS7_MIME_SERVER_GEN   (280)
 Content-Type application/pkcs7-mime; smime-type=server-generated-key
 
#define COAP_FORMAT_PKCS7_MIME_CERTS_ONLY   (281)
 Content-Type application/pkcs7-mime; smime-type=certs-only
 
#define COAP_FORMAT_PKCS8   (284)
 Content-Type application/pkcs8
 
#define COAP_FORMAT_CSRATTRS   (285)
 Content-Type application/csrattrs
 
#define COAP_FORMAT_PKCS10   (286)
 Content-Type application/pkcs10
 
#define COAP_FORMAT_PKIX_CERT   (287)
 Content-Type application/pkix-cert
 
#define COAP_FORMAT_AIF_CBOR   (290)
 Content-Type application/aif+cbor
 
#define COAP_FORMAT_AIF_JSON   (291)
 Content-Type application/aif+json
 
#define COAP_FORMAT_SENML_XML   (310)
 
#define COAP_FORMAT_SENSML_XML   (311)
 
#define COAP_FORMAT_SNML_ETCH_JSON   (320)
 Content-Type application/senml-etch+json
 
#define COAP_FORMAT_SNML_ETCH_CBOR   (322)
 Content-Type application/senml-etch+cbor
 
#define COAP_FORMAT_YAML_DATA_CBOR   (340)
 Content-Type application/yang-data+cbor
 
#define COAP_FORMAT_YAML_DATA_CBOR_ID_NAME   (341)
 Content-Type application/yang-data+cbor; id=name
 
#define COAP_FORMAT_TD_JSON   (432)
 Content-Type application/td+json
 
#define COAP_FORMAT_TM_JSON   (433)
 Content-Type application/tm+json
 
#define COAP_FORMAT_DNS_MESSAGE   (553)
 Content-Type application/dns-message
 
#define COAP_FORMAT_VOUCER_COSE_CBOR   (836)
 Content-Type application/voucher-cose+cbor
 
#define COAP_FORMAT_VND_OCF_CBOR   (10000)
 Content-Type application/vnd.ocf+cbor
 
#define COAP_FORMAT_OSCORE   (10001)
 Content-Type application/oscore
 
#define COAP_FORMAT_JAVASCRIPT   (10002)
 Content-Type application/javascript
 
#define COAP_FORMAT_JSON_DEFLATE   (11050)
 Content-Type application/json with Content Coding deflate
 
#define COAP_FORMAT_CBOR_DEFLATE   (11060)
 Content-Type application/cbor with Content Coding deflate
 
#define COAP_FORMAT_VND_OMA_LWM2M_TLV   (11542)
 Content-Type application/vnd.oma.lwm2m+tlv
 
#define COAP_FORMAT_VND_OMA_LWM2M_JSON   (11543)
 Content-Type application/vnd.oma.lwm2m+json
 
#define COAP_FORMAT_VND_OMA_LWM2M_CBOR   (11544)
 Content-Type application/vnd.oma.lwm2m+cbor
 
#define COAP_FORMAT_TEXT_CSS   (20000)
 Content-Type text/css
 
#define COAP_FORMAT_IMAGE_SVG_XML   (30000)
 Content-Type image/svg+xml
 

Observe (RFC 7641) constants

#define COAP_OBS_REGISTER   (0)
 
#define COAP_OBS_DEREGISTER   (1)
 

CoAP message format constants

#define COAP_TOKEN_LENGTH_MAX   (8)
 

CoAP option constants

#define COAP_ETAG_LENGTH_MAX   (8U)
 maximum length of the ETag option
 

Timing parameters

These parameters are defined as configurable in [RFC 7252, section 4.8.1] (https://tools.ietf.org/html/rfc7252#section-4.8.1).

#define CONFIG_COAP_ACK_TIMEOUT_MS   (2000)
 Timeout in milliseconds for a response to a confirmable request.
 
#define CONFIG_COAP_RANDOM_FACTOR_1000   (1500)
 Used to calculate upper bound for timeout.
 
#define CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS   (10 * MS_PER_SEC)
 Timeout in milliseconds for a separate (deferred) response sent after an empty ACK.
 
#define CONFIG_COAP_MAX_RETRANSMIT   (4)
 Maximum number of retransmissions for a confirmable request.
 

Fixed timing parameters

#define COAP_NSTART   (1)
 
#define COAP_DEFAULT_LEISURE   (5)
 

Blockwise transfer (RFC7959)

#define COAP_BLOCKWISE_NUM_OFF   (4)
 
#define COAP_BLOCKWISE_MORE_OFF   (3)
 
#define COAP_BLOCKWISE_SZX_MASK   (0x07)
 
#define COAP_BLOCKWISE_SZX_MAX   (7)