1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qcoapnamespace_p.h"
QT_BEGIN_NAMESPACE
/*!
\namespace QtCoap
\inmodule QtCoap
\brief Contains miscellaneous identifiers used throughout the Qt CoAP module.
\keyword {QtCoap Namespace}
*/
/*!
\enum QtCoap::ResponseCode
This enum represents the response code from the CoAP protocol, as defined in
\l{https://tools.ietf.org/html/rfc7252#section-5.9}{RFC 7252} and
\l{https://tools.ietf.org/html/rfc7959#section-2.9}{RFC 7959}.
\value EmptyMessage The response code for an empty message.
\value Created The request was successful and has resulted in new resources
being created.
This response code corresponds to HTTP 201 "Created".
\value Deleted The resource has been successfully deleted. This response code
corresponds to HTTP 204 "No Content" but is only used in
response to requests that cause the resource to cease being
available, such as DELETE and, in certain circumstances, POST.
\value Valid This response code is related to HTTP 304 "Not Modified" but
is only used to indicate that the response identified by the
entity-tag given in the ETag Option is valid.
\value Changed The resource has been successfully modified.
This response code corresponds to HTTP 204 "No Content" but
is only used in response to POST and PUT requests.
\value Content The request has succeeded. This response code corresponds to
HTTP 200 "OK" but is only used in response to GET requests.
\value Continue Indicates that the transfer of the current block was successful,
and the server will send more blocks.
\value BadRequest The request was not recognized.
This response code corresponds to HTTP 400 "Bad Request".
\value Unauthorized The client is not authorized to perform the requested action.
This response code corresponds to HTTP 401 "Unauthorized".
\value BadOption The request could not be understood by the server due to
unrecognized options.
\value Forbidden Access to this resource is forbidden.
This response code corresponds to HTTP 403 "Forbidden".
\value NotFound The resource requested was not found.
This response code corresponds to HTTP 404 "Not Found".
\value MethodNotAllowed The server does not allow the method used for the URL requested.
This response code corresponds to HTTP 405 "Method Not Allowed"
but with no parallel to the "Allow" header field.
\value NotAcceptable No resource satisfying the request's acceptance criteria
was found. This response code corresponds to HTTP 406
"Not Acceptable", but with no response entity.
\value RequestEntityIncomplete The server has not received all blocks, of the request body,
that it needs to proceed.
\value PreconditionFailed Preconditions given in the request header fields evaluated to
\c false when tested on the server.
This response code corresponds to HTTP 412
"Precondition Failed".
\value RequestEntityTooLarge The request payload is larger than the server is willing or
able to process. This response code corresponds to HTTP 413
"Request Entity Too Large".
\value UnsupportedContentFormat The payload is in a format not supported by this method on
the target resource. This response code corresponds to HTTP 415
"Unsupported Media Type".
\value InternalServerFault The server encountered an unexpected condition that prevented
it from fulfilling the request. This response code corresponds
to HTTP 500 "Internal Server Error".
\value NotImplemented The server does not support the functionality required to
fulfill the request. This response code corresponds to HTTP 501
"Not Implemented".
\value BadGateway An error occurred with an upstream server.
This response code corresponds to HTTP 502 "Bad Gateway".
\value ServiceUnavailable The service is currently unavailable.
This response code corresponds to HTTP 503
"Service Unavailable".
\value GatewayTimeout The server, while acting as a gateway or proxy, did not
receive a timely response from an upstream server.
This response code corresponds to HTTP 504 "Gateway Timeout".
\value ProxyingNotSupported The server is unable or unwilling to act as a forward-proxy
for the URI specified in the Proxy-Uri Option or using
the scheme specified in Proxy-Scheme.
\value InvalidCode An invalid response code.
*/
/*!
\enum QtCoap::Error
Indicates the error condition found during processing of the request.
\value Ok No error condition.
\value HostNotFound The remote host name was not found.
\value AddressInUse The address is already in use.
\value TimeOut The response did not arrive in time.
\value BadRequest The request was not recognized.
\value Unauthorized The client is not authorized to perform
the requested action.
\value BadOption The request could not be understood by
the server due to one or more unrecognized
or malformed options.
\value Forbidden Access to this resource is forbidden.
\value NotFound The resource requested was not found.
\value MethodNotAllowed The server does not allow the method used
for the URL requested.
\value NotAcceptable No resource satisfying the request's acceptance
criteria was found.
\value RequestEntityIncomplete The server has not received the blocks of
the request body that it needs to proceed.
The client has not sent all blocks,
has not sent them in the order required by the
server, or sent them long enough ago
that the server has already discarded them.
\value PreconditionFailed One or more conditions given in the request
header fields evaluated to false when tested
on the server.
\value RequestEntityTooLarge The request payload is larger than the
server is willing or able to process.
\value UnsupportedContentFormat The payload is in a format not supported
by this method on the target resource.
\value InternalServerFault The server encountered an unexpected
condition that prevented it from
fulfilling the request.
\value NotImplemented The server does not support the
functionality required to fulfill the
request.
\value BadGateway An error occurred with an upstream
server.
\value ServiceUnavailable The service is currently unavailable.
\value GatewayTimeout The server, while acting as a gateway
or proxy, did not receive a timely
response from an upstream server it needed
to access in order to complete the request.
\value ProxyingNotSupported The server is unable or unwilling to act
as a forward-proxy for the URI specified
in the Proxy-Uri Option or using the scheme
specified in Proxy-Scheme.
\value Unknown An unknown error occurred.
*/
/*!
\enum QtCoap::Method
This enum specifies CoAP request methods.
\value Invalid The default request method for an empty request.
\value Get GET method.
\value Post POST method.
\value Put PUT method.
\value Delete DELETE method.
\value Other Other request method.
*/
/*!
\enum QtCoap::Port
This enum specifies the default CoAP port values.
\value DefaultPort The default port used for the non-secure transmission.
\value DefaultSecurePort The default port used for the secure transmission.
*/
/*!
\enum QtCoap::SecurityMode
Specifies the security mode used for securing a CoAP connection, as defined in
\l{https://tools.ietf.org/html/rfc7252#section-9}{RFC 7252}.
\value NoSecurity There is no protocol-level security (DTLS is disabled).
\value PreSharedKey DTLS is enabled. PSK authentication will be used for security.
\value RawPublicKey DTLS is enabled. An asymmetric key pair without a certificate
(a raw public key) will be used for security. This mode is not
supported yet.
\value Certificate DTLS is enabled. An asymmetric key pair with an X.509 certificate
will be used for security.
*/
/*!
\enum QtCoap::MulticastGroup
This enum represents CoAP multicast group addresses defined in
\l{https://tools.ietf.org/html/rfc7252#section-12.8}{RFC 7252}.
\value AllCoapNodesIPv4 IPv4 "All CoAP Nodes" address \e {224.0.1.187}, from
the "IPv4 Multicast Address Space Registry".
\value AllCoapNodesIPv6LinkLocal IPv6 "All CoAP Nodes" link-local scoped address
\e {FF02::FD}, from the "IPv6 Multicast Address Space
Registry".
\value AllCoapNodesIPv6SiteLocal IPv6 "All CoAP Nodes" site-local scoped address
\e {FF05::FD}, from the "IPv6 Multicast Address Space
Registry".
*/
/*!
\internal
Returns \c true if \a code corresponds to an error, returns \c false otherwise.
*/
bool QtCoap::isError(QtCoap::ResponseCode code)
{
return static_cast<int>(code) >= 0x80;
}
/*!
\internal
Returns the QtCoap::Error corresponding to the \a code passed to this
method.
*/
QtCoap::Error QtCoap::errorForResponseCode(QtCoap::ResponseCode code)
{
if (!isError(code))
return QtCoap::Error::Ok;
switch (code) {
#define SINGLE_CASE(name, ignored) case ResponseCode::name: return Error::name;
FOR_EACH_COAP_ERROR(SINGLE_CASE)
#undef SINGLE_CASE
default:
return Error::Unknown;
}
}
/*!
\internal
Returns the internal random generator used for generating token values and
message IDs.
*/
QRandomGenerator &QtCoap::randomGenerator()
{
static QRandomGenerator randomGenerator = QRandomGenerator::securelySeeded();
return randomGenerator;
}
QT_END_NAMESPACE
|