Loading...
Searching...
No Matches
CoAP defines

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

Detailed Description

Generic CoAP values as defined by RFC7252.

Topics

 CoAP compile configurations
 

Files

file  coap.h
 Generic CoAP values as defined by RFC7252.
 

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.
 
#define COAP_PAYLOAD_MARKER_SIZE   (1U)
 Size of the payload marker.
 
#define COAP_SZX2SIZE(szx)
 Convert a coap_blksize_t constant to a size in bytes without error checking.
 

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...
 

Functions

static unsigned coap_szx2size (coap_blksize_t szx)
 Convert a coap_blksize_t constant to a size in bytes.
 
static coap_blksize_t coap_size2szx (unsigned size)
 Get the closest blocksize enum for given size.
 

CoAP method codes used in header

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...
 
#define COAP_CLASS_REQ   (0)
 Code Class for Request.
 

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)
 

Empty CoAP message code

#define COAP_CODE_EMPTY   (0)
 No method/code, used in RST and empty ACKs.
 

Response message codes: success

#define COAP_CLASS_SUCCESS   (2)
 Class 2.xx contains response codes indicating success.
 
#define COAP_CODE_CREATED   ((2 << 5) | 1)
 Response Code: 2.01 Created.
 
#define COAP_CODE_DELETED   ((2 << 5) | 2)
 Response Code: 2.02 Deleted.
 
#define COAP_CODE_VALID   ((2 << 5) | 3)
 Response Code: 2.03 Valid.
 
#define COAP_CODE_CHANGED   ((2 << 5) | 4)
 Response Code: 2.04 Changed.
 
#define COAP_CODE_204   ((2 << 5) | 4)
 Alias for COAP_CODE_CHANGED in case you want to annoy code reviewers.
 
#define COAP_CODE_CONTENT   ((2 << 5) | 5)
 Response Code: 2.05 Content.
 
#define COAP_CODE_205   ((2 << 5) | 5)
 Alias for COAP_CODE_CONTENT in case you want to annoy code reviewers.
 
#define COAP_CODE_CONTINUE   ((2 << 5) | 31)
 Response Code: 2.31 Continue.
 
#define COAP_CODE_231   ((2 << 5) | 31)
 Alias for COAP_CODE_CONTINUE in case you want to annoy code reviewers.
 

Response message codes: client error

#define COAP_CLASS_CLIENT_FAILURE   (4)
 Class 4.xx contains response codes indicating client failure.
 
#define COAP_CODE_BAD_REQUEST   ((4 << 5) | 0)
 Response Code: 4.00 Bad Request.
 
#define COAP_CODE_UNAUTHORIZED   ((4 << 5) | 1)
 Response Code: 4.01 Unauthorized.
 
#define COAP_CODE_BAD_OPTION   ((4 << 5) | 2)
 Response Code: 4.02 Bad Option.
 
#define COAP_CODE_FORBIDDEN   ((4 << 5) | 3)
 Response Code: 4.03 Forbidden.
 
#define COAP_CODE_PATH_NOT_FOUND   ((4 << 5) | 4)
 Response Code: 4.04 Not Found.
 
#define COAP_CODE_404   ((4 << 5) | 4)
 Alias for COAP_CODE_PATH_NOT_FOUND when you want to annoy code reviewers.
 
#define COAP_CODE_METHOD_NOT_ALLOWED   ((4 << 5) | 5)
 Response Code: 4.05 Method Not Allowed.
 
#define COAP_CODE_NOT_ACCEPTABLE   ((4 << 5) | 6)
 Response Code: 4.06 Not Acceptable.
 
#define COAP_CODE_REQUEST_ENTITY_INCOMPLETE   ((4 << 5) | 8)
 Response Code: 4.08 Request Entity Incomplete.
 
#define COAP_CODE_CONFLICT   ((4 << 5) | 9)
 Response Code: 4.09 Conflict.
 
#define COAP_CODE_PRECONDITION_FAILED   ((4 << 5) | 12
 Response Code: 4.12 Precondition Failed.
 
#define COAP_CODE_REQUEST_ENTITY_TOO_LARGE   ((4 << 5) | 13
 Response Code: 4.13 Request Entity Too Large.
 
#define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT   ((4 << 5) | 15
 Response Code: 4.15 Unsupported Content Format.
 
#define COAP_CODE_UNPROCESSABLE_ENTITY   ((4 << 5) | 22
 Response Code: 4.22 Unprocessable Entity.
 
#define COAP_CODE_TOO_MANY_REQUESTS   ((4 << 5) | 29
 Response Code: 4.29 Too Many Requests.
 

Response message codes: server error

#define COAP_CLASS_SERVER_FAILURE   (5)
 Class 5.xx contains response codes server failure.
 
#define COAP_CODE_INTERNAL_SERVER_ERROR   ((5 << 5) | 0)
 Response Code: 5.00 Internal Server Error.
 
#define COAP_CODE_NOT_IMPLEMENTED   ((5 << 5) | 1)
 Response Code: 5.01 Not Implemented.
 
#define COAP_CODE_BAD_GATEWAY   ((5 << 5) | 2)
 Response Code: 5.02 Bad Gateway.
 
#define COAP_CODE_SERVICE_UNAVAILABLE   ((5 << 5) | 3)
 Response Code: 5.03 Service Unavailable.
 
#define COAP_CODE_GATEWAY_TIMEOUT   ((5 << 5) | 4)
 Response Code: 5.04 Gateway Timeout.
 
#define COAP_CODE_PROXYING_NOT_SUPPORTED   ((5 << 5) | 5)
 Response Code: 5.05 Proxying Not Supported.
 

Content-Format option codes

#define COAP_FORMAT_TEXT   (0)
 Content-Type text/plain;charset=utf-8
 
#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)
 
#define COAP_OBS_MAX_VALUE_MASK   (0xffffff)
 observe value is 24 bits
 

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
 

Fixed timing parameters

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

Blockwise transfer (RFC7959)

#define COAP_BLOCKWISE_NUM_OFF   (4)
 offset of the NUM field in bits
 
#define COAP_BLOCKWISE_NUM_MAX   (0xfffffU)
 highest possible block number (20 bits)
 
#define COAP_BLOCKWISE_MORE_OFF   (3)
 offset of the more field in bits
 
#define COAP_BLOCKWISE_SZX_MASK   (0x07)
 bitmask to get the SZX field
 
#define COAP_BLOCKWISE_SZX_MAX   (7)
 largest valid SZX value
 

Macro Definition Documentation

◆ COAP_BLOCKWISE_MORE_OFF

#define COAP_BLOCKWISE_MORE_OFF   (3)

offset of the more field in bits

Definition at line 624 of file coap.h.

◆ COAP_BLOCKWISE_NUM_MAX

#define COAP_BLOCKWISE_NUM_MAX   (0xfffffU)

highest possible block number (20 bits)

Definition at line 623 of file coap.h.

◆ COAP_BLOCKWISE_NUM_OFF

#define COAP_BLOCKWISE_NUM_OFF   (4)

offset of the NUM field in bits

Definition at line 622 of file coap.h.

◆ COAP_BLOCKWISE_SZX_MASK

#define COAP_BLOCKWISE_SZX_MASK   (0x07)

bitmask to get the SZX field

Definition at line 625 of file coap.h.

◆ COAP_BLOCKWISE_SZX_MAX

#define COAP_BLOCKWISE_SZX_MAX   (7)

largest valid SZX value

Definition at line 626 of file coap.h.

◆ COAP_CLASS_CLIENT_FAILURE

#define COAP_CLASS_CLIENT_FAILURE   (4)

Class 4.xx contains response codes indicating client failure.

Definition at line 213 of file coap.h.

◆ COAP_CLASS_REQ

#define COAP_CLASS_REQ   (0)

Code Class for Request.

Definition at line 166 of file coap.h.

◆ COAP_CLASS_SERVER_FAILURE

#define COAP_CLASS_SERVER_FAILURE   (5)

Class 5.xx contains response codes server failure.

Definition at line 237 of file coap.h.

◆ COAP_CLASS_SUCCESS

#define COAP_CLASS_SUCCESS   (2)

Class 2.xx contains response codes indicating success.

Definition at line 193 of file coap.h.

◆ COAP_CODE_204

#define COAP_CODE_204   ((2 << 5) | 4)

Alias for COAP_CODE_CHANGED in case you want to annoy code reviewers.

Definition at line 199 of file coap.h.

◆ COAP_CODE_205

#define COAP_CODE_205   ((2 << 5) | 5)

Alias for COAP_CODE_CONTENT in case you want to annoy code reviewers.

Definition at line 202 of file coap.h.

◆ COAP_CODE_231

#define COAP_CODE_231   ((2 << 5) | 31)

Alias for COAP_CODE_CONTINUE in case you want to annoy code reviewers.

Definition at line 205 of file coap.h.

◆ COAP_CODE_404

#define COAP_CODE_404   ((4 << 5) | 4)

Alias for COAP_CODE_PATH_NOT_FOUND when you want to annoy code reviewers.

Definition at line 220 of file coap.h.

◆ COAP_CODE_BAD_GATEWAY

#define COAP_CODE_BAD_GATEWAY   ((5 << 5) | 2)

Response Code: 5.02 Bad Gateway.

Definition at line 241 of file coap.h.

◆ COAP_CODE_BAD_OPTION

#define COAP_CODE_BAD_OPTION   ((4 << 5) | 2)

Response Code: 4.02 Bad Option.

Definition at line 217 of file coap.h.

◆ COAP_CODE_BAD_REQUEST

#define COAP_CODE_BAD_REQUEST   ((4 << 5) | 0)

Response Code: 4.00 Bad Request.

Definition at line 215 of file coap.h.

◆ COAP_CODE_CHANGED

#define COAP_CODE_CHANGED   ((2 << 5) | 4)

Response Code: 2.04 Changed.

Definition at line 198 of file coap.h.

◆ COAP_CODE_CONFLICT

#define COAP_CODE_CONFLICT   ((4 << 5) | 9)

Response Code: 4.09 Conflict.

Definition at line 225 of file coap.h.

◆ COAP_CODE_CONTENT

#define COAP_CODE_CONTENT   ((2 << 5) | 5)

Response Code: 2.05 Content.

Definition at line 201 of file coap.h.

◆ COAP_CODE_CONTINUE

#define COAP_CODE_CONTINUE   ((2 << 5) | 31)

Response Code: 2.31 Continue.

Definition at line 204 of file coap.h.

◆ COAP_CODE_CREATED

#define COAP_CODE_CREATED   ((2 << 5) | 1)

Response Code: 2.01 Created.

Definition at line 195 of file coap.h.

◆ COAP_CODE_DELETED

#define COAP_CODE_DELETED   ((2 << 5) | 2)

Response Code: 2.02 Deleted.

Definition at line 196 of file coap.h.

◆ COAP_CODE_EMPTY

#define COAP_CODE_EMPTY   (0)

No method/code, used in RST and empty ACKs.

Definition at line 186 of file coap.h.

◆ COAP_CODE_FORBIDDEN

#define COAP_CODE_FORBIDDEN   ((4 << 5) | 3)

Response Code: 4.03 Forbidden.

Definition at line 218 of file coap.h.

◆ COAP_CODE_GATEWAY_TIMEOUT

#define COAP_CODE_GATEWAY_TIMEOUT   ((5 << 5) | 4)

Response Code: 5.04 Gateway Timeout.

Definition at line 243 of file coap.h.

◆ COAP_CODE_INTERNAL_SERVER_ERROR

#define COAP_CODE_INTERNAL_SERVER_ERROR   ((5 << 5) | 0)

Response Code: 5.00 Internal Server Error.

Definition at line 239 of file coap.h.

◆ COAP_CODE_METHOD_NOT_ALLOWED

#define COAP_CODE_METHOD_NOT_ALLOWED   ((4 << 5) | 5)

Response Code: 4.05 Method Not Allowed.

Definition at line 222 of file coap.h.

◆ COAP_CODE_NOT_ACCEPTABLE

#define COAP_CODE_NOT_ACCEPTABLE   ((4 << 5) | 6)

Response Code: 4.06 Not Acceptable.

Definition at line 223 of file coap.h.

◆ COAP_CODE_NOT_IMPLEMENTED

#define COAP_CODE_NOT_IMPLEMENTED   ((5 << 5) | 1)

Response Code: 5.01 Not Implemented.

Definition at line 240 of file coap.h.

◆ COAP_CODE_PATH_NOT_FOUND

#define COAP_CODE_PATH_NOT_FOUND   ((4 << 5) | 4)

Response Code: 4.04 Not Found.

Definition at line 219 of file coap.h.

◆ COAP_CODE_PRECONDITION_FAILED

#define COAP_CODE_PRECONDITION_FAILED   ((4 << 5) | 12

Response Code: 4.12 Precondition Failed.

Definition at line 226 of file coap.h.

◆ COAP_CODE_PROXYING_NOT_SUPPORTED

#define COAP_CODE_PROXYING_NOT_SUPPORTED   ((5 << 5) | 5)

Response Code: 5.05 Proxying Not Supported.

Definition at line 244 of file coap.h.

◆ COAP_CODE_REQUEST_ENTITY_INCOMPLETE

#define COAP_CODE_REQUEST_ENTITY_INCOMPLETE   ((4 << 5) | 8)

Response Code: 4.08 Request Entity Incomplete.

Definition at line 224 of file coap.h.

◆ COAP_CODE_REQUEST_ENTITY_TOO_LARGE

#define COAP_CODE_REQUEST_ENTITY_TOO_LARGE   ((4 << 5) | 13

Response Code: 4.13 Request Entity Too Large.

Definition at line 227 of file coap.h.

◆ COAP_CODE_SERVICE_UNAVAILABLE

#define COAP_CODE_SERVICE_UNAVAILABLE   ((5 << 5) | 3)

Response Code: 5.03 Service Unavailable.

Definition at line 242 of file coap.h.

◆ COAP_CODE_TOO_MANY_REQUESTS

#define COAP_CODE_TOO_MANY_REQUESTS   ((4 << 5) | 29

Response Code: 4.29 Too Many Requests.

Definition at line 230 of file coap.h.

◆ COAP_CODE_UNAUTHORIZED

#define COAP_CODE_UNAUTHORIZED   ((4 << 5) | 1)

Response Code: 4.01 Unauthorized.

Definition at line 216 of file coap.h.

◆ COAP_CODE_UNPROCESSABLE_ENTITY

#define COAP_CODE_UNPROCESSABLE_ENTITY   ((4 << 5) | 22

Response Code: 4.22 Unprocessable Entity.

Definition at line 229 of file coap.h.

◆ COAP_CODE_UNSUPPORTED_CONTENT_FORMAT

#define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT   ((4 << 5) | 15

Response Code: 4.15 Unsupported Content Format.

Definition at line 228 of file coap.h.

◆ COAP_CODE_VALID

#define COAP_CODE_VALID   ((2 << 5) | 3)

Response Code: 2.03 Valid.

Definition at line 197 of file coap.h.

◆ COAP_DEFAULT_LEISURE

#define COAP_DEFAULT_LEISURE   (5)

Definition at line 615 of file coap.h.

◆ COAP_ETAG_LENGTH_MAX

#define COAP_ETAG_LENGTH_MAX   (8U)

maximum length of the ETag option

Definition at line 547 of file coap.h.

◆ COAP_FORMAT_ACE_CBOR

#define COAP_FORMAT_ACE_CBOR   (19)

Content-Type application/ace+cbor

See also
RFC 9200

Definition at line 276 of file coap.h.

◆ COAP_FORMAT_AIF_CBOR

#define COAP_FORMAT_AIF_CBOR   (290)

Content-Type application/aif+cbor

See also
RFC 9237

Definition at line 425 of file coap.h.

◆ COAP_FORMAT_AIF_JSON

#define COAP_FORMAT_AIF_JSON   (291)

Content-Type application/aif+json

See also
RFC 9237

Definition at line 430 of file coap.h.

◆ COAP_FORMAT_CBOR

#define COAP_FORMAT_CBOR   (60)

Definition at line 299 of file coap.h.

◆ COAP_FORMAT_CBOR_DEFLATE

#define COAP_FORMAT_CBOR_DEFLATE   (11060)

Content-Type application/cbor with Content Coding deflate

See also
RFC 8949
RFC 9110, Section 8.4.1.2

Definition at line 499 of file coap.h.

◆ COAP_FORMAT_CBOR_SEQ

#define COAP_FORMAT_CBOR_SEQ   (63)

Content-Type application/cbor-seq

See also
RFC 8742

Definition at line 314 of file coap.h.

◆ COAP_FORMAT_COAP_GROUP_JSON

#define COAP_FORMAT_COAP_GROUP_JSON   (256)

Content-Type application/coap-group+json

See also
RFC 7390

Definition at line 355 of file coap.h.

◆ COAP_FORMAT_COSE_ENCRYPT

#define COAP_FORMAT_COSE_ENCRYPT   (96)

Content-Type application/cose; cose-type="cose-encrypt"

See also
RFC 9052

Definition at line 319 of file coap.h.

◆ COAP_FORMAT_COSE_ENCRYPT0

#define COAP_FORMAT_COSE_ENCRYPT0   (16)

Content-Type application/cose; cose-type="cose-encrypt0"

See also
RFC 9052

Definition at line 261 of file coap.h.

◆ COAP_FORMAT_COSE_KEY

#define COAP_FORMAT_COSE_KEY   (101)

Content-Type application/cose-key

See also
RFC 9052

Definition at line 334 of file coap.h.

◆ COAP_FORMAT_COSE_KEY_SET

#define COAP_FORMAT_COSE_KEY_SET   (102)

Content-Type application/cose-key-set

See also
RFC 9052

Definition at line 339 of file coap.h.

◆ COAP_FORMAT_COSE_MAC

#define COAP_FORMAT_COSE_MAC   (97)

Content-Type application/cose; cose-type="cose-mac"

See also
RFC 9052

Definition at line 324 of file coap.h.

◆ COAP_FORMAT_COSE_MAC0

#define COAP_FORMAT_COSE_MAC0   (17)

Content-Type application/cose; cose-type="cose-mac0"

See also
RFC 9052

Definition at line 266 of file coap.h.

◆ COAP_FORMAT_COSE_SIGN

#define COAP_FORMAT_COSE_SIGN   (98)

Content-Type application/cose; cose-type="cose-sign"

See also
RFC 9052

Definition at line 329 of file coap.h.

◆ COAP_FORMAT_COSE_SIGN1

#define COAP_FORMAT_COSE_SIGN1   (18)

Content-Type application/cose; cose-type="cose-sign1"

See also
RFC 9052

Definition at line 271 of file coap.h.

◆ COAP_FORMAT_CSRATTRS

#define COAP_FORMAT_CSRATTRS   (285)

Content-Type application/csrattrs

See also
RFC 7030
RFC 9148

Definition at line 407 of file coap.h.

◆ COAP_FORMAT_CWT

#define COAP_FORMAT_CWT   (61)

Content-Type application/cwt

See also
RFC 8392

Definition at line 304 of file coap.h.

◆ COAP_FORMAT_DNS_MESSAGE

#define COAP_FORMAT_DNS_MESSAGE   (553)

Content-Type application/dns-message

See also
draft-ietf-core-dns-over-coap

Definition at line 467 of file coap.h.

◆ COAP_FORMAT_DOTS_CBOR

#define COAP_FORMAT_DOTS_CBOR   (271)

Content-Type application/dots+cbor

See also
RFC 9132

Definition at line 376 of file coap.h.

◆ COAP_FORMAT_EXI

#define COAP_FORMAT_EXI   (47)

Definition at line 295 of file coap.h.

◆ COAP_FORMAT_IMAGE_GIF

#define COAP_FORMAT_IMAGE_GIF   (21)

Content-Type image/gif

See also
https://www.w3.org/Graphics/GIF/spec-gif89a.txt

Definition at line 281 of file coap.h.

◆ COAP_FORMAT_IMAGE_JPEG

#define COAP_FORMAT_IMAGE_JPEG   (22)

Content-Type image/jpeg

See also
ISO/IEC 10918-5

Definition at line 286 of file coap.h.

◆ COAP_FORMAT_IMAGE_PNG

#define COAP_FORMAT_IMAGE_PNG   (23)

Content-Type image/png

See also
RFC 2083

Definition at line 291 of file coap.h.

◆ COAP_FORMAT_IMAGE_SVG_XML

#define COAP_FORMAT_IMAGE_SVG_XML   (30000)

Content-Type image/svg+xml

See also
RFC 2318

Definition at line 524 of file coap.h.

◆ COAP_FORMAT_JAVASCRIPT

#define COAP_FORMAT_JAVASCRIPT   (10002)

Content-Type application/javascript

See also
RFC 4329

Definition at line 487 of file coap.h.

◆ COAP_FORMAT_JSON

#define COAP_FORMAT_JSON   (50)

Definition at line 296 of file coap.h.

◆ COAP_FORMAT_JSON_DEFLATE

#define COAP_FORMAT_JSON_DEFLATE   (11050)

Content-Type application/json with Content Coding deflate

See also
RFC 8259
RFC 9110, Section 8.4.1.2

Definition at line 493 of file coap.h.

◆ COAP_FORMAT_JSON_PATCH_JSON

#define COAP_FORMAT_JSON_PATCH_JSON   (51)

Definition at line 297 of file coap.h.

◆ COAP_FORMAT_LINK

#define COAP_FORMAT_LINK   (40)

Definition at line 292 of file coap.h.

◆ COAP_FORMAT_MERGE_PATCH_JSON

#define COAP_FORMAT_MERGE_PATCH_JSON   (52)

Definition at line 298 of file coap.h.

◆ COAP_FORMAT_MISSING_BLOCKS_CBOR_SEQ

#define COAP_FORMAT_MISSING_BLOCKS_CBOR_SEQ   (272)

Content-Type application/missing-blocks+cbor-seq

See also
RFC 9177

Definition at line 381 of file coap.h.

◆ COAP_FORMAT_MULTIPART_CORE

#define COAP_FORMAT_MULTIPART_CORE   (62)

Content-Type application/multipart-core

See also
RFC 8710

Definition at line 309 of file coap.h.

◆ COAP_FORMAT_OCTET

#define COAP_FORMAT_OCTET   (42)

Definition at line 294 of file coap.h.

◆ COAP_FORMAT_OSCORE

#define COAP_FORMAT_OSCORE   (10001)

Content-Type application/oscore

See also
RFC 8613

Definition at line 482 of file coap.h.

◆ COAP_FORMAT_PKCS10

#define COAP_FORMAT_PKCS10   (286)

Content-Type application/pkcs10

See also
RFC 5967
RFC 8551
RFC 9148

Definition at line 414 of file coap.h.

◆ COAP_FORMAT_PKCS7_MIME_CERTS_ONLY

#define COAP_FORMAT_PKCS7_MIME_CERTS_ONLY   (281)

Content-Type application/pkcs7-mime; smime-type=certs-only

See also
RFC 8551
RFC 9148

Definition at line 394 of file coap.h.

◆ COAP_FORMAT_PKCS7_MIME_SERVER_GEN

#define COAP_FORMAT_PKCS7_MIME_SERVER_GEN   (280)

Content-Type application/pkcs7-mime; smime-type=server-generated-key

See also
RFC 7030
RFC 8551
RFC 9148

Definition at line 388 of file coap.h.

◆ COAP_FORMAT_PKCS8

#define COAP_FORMAT_PKCS8   (284)

Content-Type application/pkcs8

See also
RFC 5958
RFC 8551
RFC 9148

Definition at line 401 of file coap.h.

◆ COAP_FORMAT_PKIX_CERT

#define COAP_FORMAT_PKIX_CERT   (287)

Content-Type application/pkix-cert

See also
RFC 2585
RFC 9148

Definition at line 420 of file coap.h.

◆ COAP_FORMAT_PKIXCMP

#define COAP_FORMAT_PKIXCMP   (259)

Content-Type application/pkixcmp

See also
draft-ietf-ace-cmpv2-coap-transport
RFC 4210

Definition at line 371 of file coap.h.

◆ COAP_FORMAT_PROBLEM_DETAILS_CBOR

#define COAP_FORMAT_PROBLEM_DETAILS_CBOR   (257)

Content-Type application/concise-problem-details+cbor

See also
RFC 9290

Definition at line 360 of file coap.h.

◆ COAP_FORMAT_SENML_CBOR

#define COAP_FORMAT_SENML_CBOR   (112)

Definition at line 342 of file coap.h.

◆ COAP_FORMAT_SENML_EXI

#define COAP_FORMAT_SENML_EXI   (114)

Definition at line 344 of file coap.h.

◆ COAP_FORMAT_SENML_JSON

#define COAP_FORMAT_SENML_JSON   (110)

Definition at line 340 of file coap.h.

◆ COAP_FORMAT_SENML_XML

#define COAP_FORMAT_SENML_XML   (310)

Definition at line 431 of file coap.h.

◆ COAP_FORMAT_SENSML_CBOR

#define COAP_FORMAT_SENSML_CBOR   (113)

Definition at line 343 of file coap.h.

◆ COAP_FORMAT_SENSML_EXI

#define COAP_FORMAT_SENSML_EXI   (115)

Definition at line 345 of file coap.h.

◆ COAP_FORMAT_SENSML_JSON

#define COAP_FORMAT_SENSML_JSON   (111)

Definition at line 341 of file coap.h.

◆ COAP_FORMAT_SENSML_XML

#define COAP_FORMAT_SENSML_XML   (311)

Definition at line 432 of file coap.h.

◆ COAP_FORMAT_SNML_ETCH_CBOR

#define COAP_FORMAT_SNML_ETCH_CBOR   (322)

Content-Type application/senml-etch+cbor

See also
RFC 8790

Definition at line 442 of file coap.h.

◆ COAP_FORMAT_SNML_ETCH_JSON

#define COAP_FORMAT_SNML_ETCH_JSON   (320)

Content-Type application/senml-etch+json

See also
RFC 8790

Definition at line 437 of file coap.h.

◆ COAP_FORMAT_SWID_CBOR

#define COAP_FORMAT_SWID_CBOR   (258)

Content-Type application/swid+cbor

See also
RFC 9393

Definition at line 365 of file coap.h.

◆ COAP_FORMAT_TD_JSON

#define COAP_FORMAT_TD_JSON   (432)

Content-Type application/td+json

See also
Web of Things (WoT) Thing Description 1.1

Definition at line 457 of file coap.h.

◆ COAP_FORMAT_TEXT

#define COAP_FORMAT_TEXT   (0)

Content-Type text/plain;charset=utf-8

See also
RFC 7242 Section 12.3

Definition at line 256 of file coap.h.

◆ COAP_FORMAT_TEXT_CSS

#define COAP_FORMAT_TEXT_CSS   (20000)

Content-Type text/css

See also
https://datatracker.ietf.org/doc/html/rfc2318

Definition at line 519 of file coap.h.

◆ COAP_FORMAT_TM_JSON

#define COAP_FORMAT_TM_JSON   (433)

Content-Type application/tm+json

See also
Web of Things (WoT) Thing Description 1.1

Definition at line 462 of file coap.h.

◆ COAP_FORMAT_VND_OCF_CBOR

#define COAP_FORMAT_VND_OCF_CBOR   (10000)

Content-Type application/vnd.ocf+cbor

Definition at line 477 of file coap.h.

◆ COAP_FORMAT_VND_OMA_LWM2M_CBOR

#define COAP_FORMAT_VND_OMA_LWM2M_CBOR   (11544)

Content-Type application/vnd.oma.lwm2m+cbor

See also
OMA-TS-LightweightM2M-V1_2

Definition at line 514 of file coap.h.

◆ COAP_FORMAT_VND_OMA_LWM2M_JSON

#define COAP_FORMAT_VND_OMA_LWM2M_JSON   (11543)

Content-Type application/vnd.oma.lwm2m+json

See also
OMA-TS-LightweightM2M-V1_0

Definition at line 509 of file coap.h.

◆ COAP_FORMAT_VND_OMA_LWM2M_TLV

#define COAP_FORMAT_VND_OMA_LWM2M_TLV   (11542)

Content-Type application/vnd.oma.lwm2m+tlv

See also
OMA-TS-LightweightM2M-V1_0

Definition at line 504 of file coap.h.

◆ COAP_FORMAT_VOUCER_COSE_CBOR

#define COAP_FORMAT_VOUCER_COSE_CBOR   (836)

Content-Type application/voucher-cose+cbor

See also
draft-ietf-anima-constrained-voucher
Note
Temporary registration until April 12, 2024.

Definition at line 473 of file coap.h.

◆ COAP_FORMAT_XML

#define COAP_FORMAT_XML   (41)

Definition at line 293 of file coap.h.

◆ COAP_FORMAT_YAML_DATA_CBOR

#define COAP_FORMAT_YAML_DATA_CBOR   (340)

Content-Type application/yang-data+cbor

See also
RFC 9254

Definition at line 447 of file coap.h.

◆ COAP_FORMAT_YAML_DATA_CBOR_ID_NAME

#define COAP_FORMAT_YAML_DATA_CBOR_ID_NAME   (341)

Content-Type application/yang-data+cbor; id=name

See also
RFC 9254

Definition at line 452 of file coap.h.

◆ COAP_FORMAT_YANG_DATA_CBOR_SID

#define COAP_FORMAT_YANG_DATA_CBOR_SID   (140)

Content-Type application/yang-data+cbor; id=sid

See also
RFC 9254

Definition at line 350 of file coap.h.

◆ COAP_NSTART

#define COAP_NSTART   (1)

Definition at line 614 of file coap.h.

◆ COAP_OBS_DEREGISTER

#define COAP_OBS_DEREGISTER   (1)

Definition at line 532 of file coap.h.

◆ COAP_OBS_MAX_VALUE_MASK

#define COAP_OBS_MAX_VALUE_MASK   (0xffffff)

observe value is 24 bits

Definition at line 533 of file coap.h.

◆ COAP_OBS_REGISTER

#define COAP_OBS_REGISTER   (0)

Definition at line 531 of file coap.h.

◆ COAP_OPT_ACCEPT

#define COAP_OPT_ACCEPT   (17)

Definition at line 72 of file coap.h.

◆ COAP_OPT_BLOCK1

#define COAP_OPT_BLOCK1   (27)

Definition at line 92 of file coap.h.

◆ COAP_OPT_BLOCK2

#define COAP_OPT_BLOCK2   (23)

Definition at line 91 of file coap.h.

◆ COAP_OPT_CONTENT_FORMAT

#define COAP_OPT_CONTENT_FORMAT   (12)

Definition at line 61 of file coap.h.

◆ COAP_OPT_ECHO

#define COAP_OPT_ECHO   (252)

Echo option.

Enables a CoAP server to verify the freshness of a request or to force a client to demonstrate reachability at its claimed network address.

See also
RFC 9175

Definition at line 135 of file coap.h.

◆ COAP_OPT_EDHOC

#define COAP_OPT_EDHOC   (21)

EDHOC option.

Used in a CoAP request to signal that the request payload conveys both an EDHOC message_3 and OSCORE protected data, combined together.

See also
draft-ietf-core-oscore-edhoc-02

Definition at line 90 of file coap.h.

◆ COAP_OPT_ETAG

#define COAP_OPT_ETAG   (4)

Definition at line 47 of file coap.h.

◆ COAP_OPT_HOP_LIMIT

#define COAP_OPT_HOP_LIMIT   (16)

Hop-Limit option.

Used to prevent infinite loops when communicating over multiple proxies.

See also
RFC 8768

Definition at line 71 of file coap.h.

◆ COAP_OPT_IF_MATCH

#define COAP_OPT_IF_MATCH   (1)

Definition at line 45 of file coap.h.

◆ COAP_OPT_IF_NONE_MATCH

#define COAP_OPT_IF_NONE_MATCH   (5)

Definition at line 48 of file coap.h.

◆ COAP_OPT_LOCATION_PATH

#define COAP_OPT_LOCATION_PATH   (8)

Definition at line 50 of file coap.h.

◆ COAP_OPT_LOCATION_QUERY

#define COAP_OPT_LOCATION_QUERY   (20)

Definition at line 81 of file coap.h.

◆ COAP_OPT_MAX_AGE

#define COAP_OPT_MAX_AGE   (14)

Definition at line 62 of file coap.h.

◆ COAP_OPT_NO_RESPONSE

#define COAP_OPT_NO_RESPONSE   (258)

suppress CoAP response

See also
RFC 7968

Definition at line 140 of file coap.h.

◆ COAP_OPT_OBSERVE

#define COAP_OPT_OBSERVE   (6)

Definition at line 49 of file coap.h.

◆ COAP_OPT_OSCORE

#define COAP_OPT_OSCORE   (9)

OSCORE option.

Indicates that the CoAP message is an OSCORE message and that it contains a compressed COSE object.

See also
RFC 8613

Definition at line 59 of file coap.h.

◆ COAP_OPT_PROXY_SCHEME

#define COAP_OPT_PROXY_SCHEME   (39)

Definition at line 113 of file coap.h.

◆ COAP_OPT_PROXY_URI

#define COAP_OPT_PROXY_URI   (35)

Definition at line 112 of file coap.h.

◆ COAP_OPT_Q_BLOCK1

#define COAP_OPT_Q_BLOCK1   (19)

Q-Block1 option.

Used for block-wise transfer supporting robust transmission in requests.

See also
RFC 9177

Definition at line 80 of file coap.h.

◆ COAP_OPT_Q_BLOCK2

#define COAP_OPT_Q_BLOCK2   (31)

Q-Block2 option.

Used for block-wise transfer supporting robust transmission in responses.

See also
RFC 9177

Definition at line 111 of file coap.h.

◆ COAP_OPT_REQUEST_TAG

#define COAP_OPT_REQUEST_TAG   (292)

Request-Tag option.

Allows a CoAP server to match block-wise message fragments belonging to the same request.

See also
RFC 9175

Definition at line 149 of file coap.h.

◆ COAP_OPT_SIZE1

#define COAP_OPT_SIZE1   (60)

Size1 option.

Used by clients to give servers an estimate of the total request payload size during block-wise server and by servers to indicate the maximum acceptable payload size in a 4.13 ("Request Entity Too Large") response.

See also
RFC 7252
RFC 7959
RFC 8613

Definition at line 126 of file coap.h.

◆ COAP_OPT_SIZE2

#define COAP_OPT_SIZE2   (28)

Size2 option.

Used by clients to request an estimate of a resource's total size from a server during block-wise transfer and by servers to inform clients about the size.

See also
RFC 7959
RFC 8613

Definition at line 103 of file coap.h.

◆ COAP_OPT_URI_HOST

#define COAP_OPT_URI_HOST   (3)

Definition at line 46 of file coap.h.

◆ COAP_OPT_URI_PATH

#define COAP_OPT_URI_PATH   (11)

Definition at line 60 of file coap.h.

◆ COAP_OPT_URI_QUERY

#define COAP_OPT_URI_QUERY   (15)

Definition at line 63 of file coap.h.

◆ COAP_PAYLOAD_MARKER

#define COAP_PAYLOAD_MARKER   (0xFF)

Marks the boundary between header and payload.

Definition at line 553 of file coap.h.

◆ COAP_PAYLOAD_MARKER_SIZE

#define COAP_PAYLOAD_MARKER_SIZE   (1U)

Size of the payload marker.

Definition at line 554 of file coap.h.

◆ COAP_PORT

#define COAP_PORT   (5683)

Default CoAP port.

Definition at line 32 of file coap.h.

◆ COAP_SZX2SIZE

#define COAP_SZX2SIZE ( szx)
Value:
(1U << (4U + (szx)))

Convert a coap_blksize_t constant to a size in bytes without error checking.

Parameters
[in]szxConstant to convert
Returns
The number of bytes that constant encodes.

From RFC7959:

The block size is represented as a three-bit unsigned integer indicating the size of a block to the power of two. Thus, block size = 2**(SZX + 4).

Definition at line 656 of file coap.h.

◆ COAP_TOKEN_LENGTH_MAX

#define COAP_TOKEN_LENGTH_MAX   (8)

Definition at line 540 of file coap.h.

◆ COAP_TYPE_ACK

#define COAP_TYPE_ACK   (2)

Definition at line 158 of file coap.h.

◆ COAP_TYPE_CON

#define COAP_TYPE_CON   (0)

Definition at line 156 of file coap.h.

◆ COAP_TYPE_NON

#define COAP_TYPE_NON   (1)

Definition at line 157 of file coap.h.

◆ COAP_TYPE_RST

#define COAP_TYPE_RST   (3)

Definition at line 159 of file coap.h.

◆ COAP_V1

#define COAP_V1   (1)

Identifier for CoAP version 1 (RFC 7252)

Definition at line 39 of file coap.h.

◆ COAPS_PORT

#define COAPS_PORT   (5684)

Default CoAP DTLS port.

Definition at line 37 of file coap.h.

Enumeration Type Documentation

◆ coap_blksize_t

CoAP block-wise-transfer size SZX.

Definition at line 632 of file coap.h.

◆ coap_method_t

CoAP method codes used in request.

Enumerator
COAP_METHOD_GET 

GET request (no paylod)

COAP_METHOD_POST 

POST request (resource processes payload)

COAP_METHOD_PUT 

PUT request (update resource with payload)

COAP_METHOD_DELETE 

DELETE request (no payload, remove resource)

COAP_METHOD_FETCH 

FETCH request (RFC 8132)

COAP_METHOD_PATCH 

PATCH request (RFC 8132)

COAP_METHOD_IPATCH 

iPATCH request (RFC 8132)

Definition at line 171 of file coap.h.

Function Documentation

◆ coap_size2szx()

static coap_blksize_t coap_size2szx ( unsigned size)
inlinestatic

Get the closest blocksize enum for given size.

Parameters
[in]sizeTarget size in bytes
Warning
If size is smaller than 16, COAP_BLOCKSIZE_16 is returned as there is no smaller blocksize than that.
Returns
The largest blocksize fitting into size bytes
Return values
COAP_BLOCKSIZE_16size was smaller than 32
COAP_BLOCKSIZE_1024size was at least 1024

Definition at line 693 of file coap.h.

◆ coap_szx2size()

static unsigned coap_szx2size ( coap_blksize_t szx)
inlinestatic

Convert a coap_blksize_t constant to a size in bytes.

Parameters
[in]szxConstant to convert
Returns
The number of bytes that constant encodes.
Return values
0szx was invalid

Example usage:

assert(coap_blksize_to_bytes(COAP_BLOCKSIZE_128) == 128);
#define assert(cond)
abort the program if assertion is false
Definition assert.h:143

Definition at line 672 of file coap.h.