coap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NET_COAP_H
23 #define NET_COAP_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 #define COAP_PORT (5683)
33 
38 #define COAP_OPT_URI_HOST (3)
39 #define COAP_OPT_OBSERVE (6)
40 #define COAP_OPT_LOCATION_PATH (8)
41 #define COAP_OPT_URI_PATH (11)
42 #define COAP_OPT_CONTENT_FORMAT (12)
43 #define COAP_OPT_URI_QUERY (15)
44 #define COAP_OPT_ACCEPT (17)
45 #define COAP_OPT_LOCATION_QUERY (20)
46 #define COAP_OPT_BLOCK2 (23)
47 #define COAP_OPT_BLOCK1 (27)
48 #define COAP_OPT_PROXY_URI (35)
49 #define COAP_OPT_PROXY_SCHEME (39)
50 
56 #define COAP_TYPE_CON (0)
57 #define COAP_TYPE_NON (1)
58 #define COAP_TYPE_ACK (2)
59 #define COAP_TYPE_RST (3)
60 
66 #define COAP_CLASS_REQ (0)
67 #define COAP_METHOD_GET (1)
68 #define COAP_METHOD_POST (2)
69 #define COAP_METHOD_PUT (3)
70 #define COAP_METHOD_DELETE (4)
71 #define COAP_METHOD_FETCH (5)
72 #define COAP_METHOD_PATCH (6)
73 #define COAP_METHOD_IPATCH (7)
74 
80 #define COAP_CODE_EMPTY (0)
81 
87 #define COAP_CLASS_SUCCESS (2)
88 #define COAP_CODE_CREATED ((2 << 5) | 1)
89 #define COAP_CODE_DELETED ((2 << 5) | 2)
90 #define COAP_CODE_VALID ((2 << 5) | 3)
91 #define COAP_CODE_CHANGED ((2 << 5) | 4)
92 #define COAP_CODE_204 ((2 << 5) | 4)
93 #define COAP_CODE_CONTENT ((2 << 5) | 5)
94 #define COAP_CODE_205 ((2 << 5) | 5)
95 #define COAP_CODE_CONTINUE ((2 << 5) | 31)
96 #define COAP_CODE_231 ((2 << 5) | 31)
97 
103 #define COAP_CLASS_CLIENT_FAILURE (4)
104 #define COAP_CODE_BAD_REQUEST ((4 << 5) | 0)
105 #define COAP_CODE_UNAUTHORIZED ((4 << 5) | 1)
106 #define COAP_CODE_BAD_OPTION ((4 << 5) | 2)
107 #define COAP_CODE_FORBIDDEN ((4 << 5) | 3)
108 #define COAP_CODE_PATH_NOT_FOUND ((4 << 5) | 4)
109 #define COAP_CODE_404 ((4 << 5) | 4)
110 #define COAP_CODE_METHOD_NOT_ALLOWED ((4 << 5) | 5)
111 #define COAP_CODE_NOT_ACCEPTABLE ((4 << 5) | 6)
112 #define COAP_CODE_REQUEST_ENTITY_INCOMPLETE ((4 << 5) | 8)
113 #define COAP_CODE_CONFLICT ((4 << 5) | 9)
114 #define COAP_CODE_PRECONDITION_FAILED ((4 << 5) | 12)
115 #define COAP_CODE_REQUEST_ENTITY_TOO_LARGE ((4 << 5) | 13)
116 #define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT ((4 << 5) | 15)
117 #define COAP_CODE_UNPROCESSABLE_ENTITY ((4 << 5) | 22)
118 
124 #define COAP_CLASS_SERVER_FAILURE (5)
125 #define COAP_CODE_INTERNAL_SERVER_ERROR ((5 << 5) | 0)
126 #define COAP_CODE_NOT_IMPLEMENTED ((5 << 5) | 1)
127 #define COAP_CODE_BAD_GATEWAY ((5 << 5) | 2)
128 #define COAP_CODE_SERVICE_UNAVAILABLE ((5 << 5) | 3)
129 #define COAP_CODE_GATEWAY_TIMEOUT ((5 << 5) | 4)
130 #define COAP_CODE_PROXYING_NOT_SUPPORTED ((5 << 5) | 5)
131 
138 #define COAP_FORMAT_TEXT (0)
139 #define COAP_FORMAT_LINK (40)
140 #define COAP_FORMAT_XML (41)
141 #define COAP_FORMAT_OCTET (42)
142 #define COAP_FORMAT_EXI (47)
143 #define COAP_FORMAT_JSON (50)
144 #define COAP_FORMAT_JSON_PATCH_JSON (51)
145 #define COAP_FORMAT_MERGE_PATCH_JSON (52)
146 #define COAP_FORMAT_CBOR (60)
147 #define COAP_FORMAT_SENML_JSON (110)
148 #define COAP_FORMAT_SENSML_JSON (111)
149 #define COAP_FORMAT_SENML_CBOR (112)
150 #define COAP_FORMAT_SENSML_CBOR (113)
151 #define COAP_FORMAT_SENML_EXI (114)
152 #define COAP_FORMAT_SENSML_EXI (115)
153 #define COAP_FORMAT_SENML_XML (310)
154 #define COAP_FORMAT_SENSML_XML (311)
155 
161 #define COAP_OBS_REGISTER (0)
162 #define COAP_OBS_DEREGISTER (1)
163 
169 #define COAP_TOKEN_LENGTH_MAX (8)
170 
194 #ifndef CONFIG_COAP_ACK_TIMEOUT
195 #define CONFIG_COAP_ACK_TIMEOUT (2U)
196 #endif
197 
207 #ifndef CONFIG_COAP_RANDOM_FACTOR_1000
208 #define CONFIG_COAP_RANDOM_FACTOR_1000 (1500)
209 #endif
210 
212 #ifndef CONFIG_COAP_MAX_RETRANSMIT
213 #define CONFIG_COAP_MAX_RETRANSMIT (4)
214 #endif
215 
222 #define COAP_NSTART (1)
223 #define COAP_DEFAULT_LEISURE (5)
224 
230 #define COAP_BLOCKWISE_NUM_OFF (4)
231 #define COAP_BLOCKWISE_MORE_OFF (3)
232 #define COAP_BLOCKWISE_SZX_MASK (0x07)
233 #define COAP_BLOCKWISE_SZX_MAX (7)
234 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* NET_COAP_H */
241