Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / gdp / gdp_stat.h @ master

History | View | Annotate | Download (11.4 KB)

1 a901db09 Eric Allman
/* vim: set ai sw=4 sts=4 ts=4 : */
2 0c663d10 Eric Allman
3 055d3009 Eric Allman
/*
4 a901db09 Eric Allman
**        GDP_STAT.H --- status codes specific to the Global Data Plane
5 eaf2fd26 Eric Allman
**
6 a901db09 Eric Allman
**                If you add codes here, be sure to add a string description
7
**                in gdp_stat.c.
8 eaf2fd26 Eric Allman
**
9 055d3009 Eric Allman
**        ----- BEGIN LICENSE BLOCK -----
10
**        GDP: Global Data Plane Support Library
11
**        From the Ubiquitous Swarm Lab, 490 Cory Hall, U.C. Berkeley.
12
**
13 c87dd166 Eric Allman
**        Copyright (c) 2015-2019, Regents of the University of California.
14 6bd5476b Eric Allman
**        All rights reserved.
15 055d3009 Eric Allman
**
16 6bd5476b Eric Allman
**        Permission is hereby granted, without written agreement and without
17
**        license or royalty fees, to use, copy, modify, and distribute this
18
**        software and its documentation for any purpose, provided that the above
19
**        copyright notice and the following two paragraphs appear in all copies
20
**        of this software.
21 055d3009 Eric Allman
**
22 6bd5476b Eric Allman
**        IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
23
**        SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
24
**        PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
25
**        EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 055d3009 Eric Allman
**
27 6bd5476b Eric Allman
**        REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
28 055d3009 Eric Allman
**        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 6bd5476b Eric Allman
**        FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION,
30
**        IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO
31
**        OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
32
**        OR MODIFICATIONS.
33 055d3009 Eric Allman
**        ----- END LICENSE BLOCK -----
34
*/
35 47c6ea64 Eric Allman
36
#include <ep/ep_stat.h>
37
38 0314a7a7 Eric Allman
extern void                _gdp_stat_init(void);
39
40 0c663d10 Eric Allman
// XXX        should really be in an include shared with other projects
41 a901db09 Eric Allman
//                to avoid conflicts in the future
42
#define GDP_MODULE                        1
43 92243bf4 Eric Allman
#define SQLITE_MODULE                2                // SQLite-specific error codes
44 47c6ea64 Eric Allman
45 92243bf4 Eric Allman
#define GDP_STAT_NEW(sev, det)                EP_STAT_NEW(EP_STAT_SEV_ ## sev, \
46 a901db09 Eric Allman
                                                                                EP_REGISTRY_UCB, GDP_MODULE, det)
47 08be4c9c Eric Allman
#define GDP_STAT_IS_GDP(estat)                (EP_STAT_REGISTRY(estat) == EP_REGISTRY_UCB && \
48
                                                                         EP_STAT_MODULE(estat) == GDP_MODULE)
49 47c6ea64 Eric Allman
50 a901db09 Eric Allman
#define GDP_STAT_MSGFMT                                        GDP_STAT_NEW(ERROR, 1)
51
#define GDP_STAT_SHORTMSG                                GDP_STAT_NEW(ERROR, 2)
52
#define GDP_STAT_READ_OVERFLOW                        GDP_STAT_NEW(WARN, 3)
53
#define GDP_STAT_NOT_IMPLEMENTED                GDP_STAT_NEW(SEVERE, 4)
54 549b367d Eric Allman
#define GDP_STAT_PDU_WRITE_FAIL                        GDP_STAT_NEW(ERROR, 5)
55
#define GDP_STAT_PDU_READ_FAIL                        GDP_STAT_NEW(ERROR, 6)
56
#define GDP_STAT_PDU_VERSION_MISMATCH        GDP_STAT_NEW(SEVERE, 7)
57
#define GDP_STAT_PDU_NO_SEQ                                GDP_STAT_NEW(ERROR, 8)
58 a901db09 Eric Allman
#define GDP_STAT_KEEP_READING                        GDP_STAT_NEW(WARN, 9)
59 92243bf4 Eric Allman
#define GDP_STAT_LOG_NOT_OPEN                        GDP_STAT_NEW(ERROR, 10)
60 a901db09 Eric Allman
#define GDP_STAT_UNKNOWN_RID                        GDP_STAT_NEW(SEVERE, 11)
61
#define GDP_STAT_INTERNAL_ERROR                        GDP_STAT_NEW(ABORT, 12)
62
#define GDP_STAT_BAD_IOMODE                                GDP_STAT_NEW(ERROR, 13)
63 eae1d3ec Eric Allman
#define GDP_STAT_GDP_NAME_INVALID                GDP_STAT_NEW(ERROR, 14)
64 cd2ef2a6 Eric Allman
#define GDP_STAT_BUFFER_FAILURE                        GDP_STAT_NEW(ABORT, 15)
65 eae1d3ec Eric Allman
#define GDP_STAT_NULL_GOB                                GDP_STAT_NEW(ERROR, 16)
66
#define GDP_STAT_NULL_GIN                                GDP_STAT_NEW(ERROR, 17)
67
#define GDP_STAT_PROTOCOL_FAIL                        GDP_STAT_NEW(SEVERE, 18)
68 92243bf4 Eric Allman
#define GDP_STAT_CORRUPT_LOG                        GDP_STAT_NEW(SEVERE, 19)
69 36cc958b Eric Allman
#define GDP_STAT_DEAD_DAEMON                        GDP_STAT_NEW(ABORT, 20)
70 92243bf4 Eric Allman
#define GDP_STAT_LOG_VERSION_MISMATCH        GDP_STAT_NEW(SEVERE, 21)
71 5c6e2b40 Eric Allman
#define GDP_STAT_READONLY                                GDP_STAT_NEW(ERROR, 22)
72
#define GDP_STAT_NOTFOUND                                GDP_STAT_NEW(ERROR, 23)
73 a0a21282 Eric Allman
#define GDP_STAT_PDU_CORRUPT                        GDP_STAT_NEW(ABORT, 24)
74 49d76189 Eric Allman
#define GDP_STAT_CRYPTO_SKEY_REQUIRED        GDP_STAT_NEW(ERROR, 25)
75
#define GDP_STAT_CRYPTO_SKEY_MISSING        GDP_STAT_NEW(WARN, 25)
76 92243bf4 Eric Allman
#define GDP_STAT_LOG_READ_ERROR                        GDP_STAT_NEW(ERROR, 26)
77 f7307b63 Eric Allman
#define GDP_STAT_RECNO_SEQ_ERROR                GDP_STAT_NEW(ERROR, 27)
78 caef25cd Eric Allman
#define GDP_STAT_CRYPTO_VRFY_FAIL                GDP_STAT_NEW(ERROR, 28)
79 7b2b4d4c Eric Allman
#define GDP_STAT_PHYSIO_ERROR                        GDP_STAT_NEW(ERROR, 29)
80 c2e8809e Eric Allman
#define GDP_STAT_RECORD_EXPIRED                        GDP_STAT_NEW(WARN, 30)
81 6a78b581 Eric Allman
#define GDP_STAT_USING_FREE_REQ                        GDP_STAT_NEW(ABORT, 31)
82 e539f4d3 Eric Allman
#define GDP_STAT_BAD_REFCNT                                GDP_STAT_NEW(ABORT, 32)
83 02356366 Eric Allman
#define GDP_STAT_RECORD_MISSING                        GDP_STAT_NEW(WARN, 33)
84
#define GDP_STAT_RECORD_DUPLICATED                GDP_STAT_NEW(WARN, 34)
85 8701c522 Eric Allman
#define GDP_STAT_DATUM_REQUIRED                        GDP_STAT_NEW(ERROR, 35)
86 23c926fa Eric Allman
#define GDP_STAT_SQLITE_ERROR                        GDP_STAT_NEW(SEVERE, 36)
87 66ba1423 Eric Allman
#define GDP_STAT_INVOKE_TIMEOUT                        GDP_STAT_NEW(SEVERE, 37)
88 5a73c6ad Eric Allman
#define GDP_STAT_PDU_TOO_LONG                        GDP_STAT_NEW(SEVERE, 38)
89 2af11a08 Eric Allman
#define GDP_STAT_CHAN_NOT_CONNECTED                GDP_STAT_NEW(ABORT, 39)
90 9852be60 Eric Allman
#define GDP_STAT_METADATA_REQUIRED                GDP_STAT_NEW(SEVERE, 40)
91 bd278f2e Eric Allman
#define GDP_STAT_RESPONSE_SENT                        GDP_STAT_NEW(WARN, 41)
92 1c4fea03 Eric Allman
#define GDP_STAT_NO_METADATA                        GDP_STAT_NEW(ABORT, 42)
93 59c6c7e0 Eric Allman
#define GDP_STAT_NAME_UNKNOWN                        GDP_STAT_NEW(ERROR, 43)
94
#define GDP_STAT_MYSQL_ERROR                        GDP_STAT_NEW(SEVERE, 44)
95 caef25cd Eric Allman
#define GDP_STAT_CRYPTO_SIG_MISSING                GDP_STAT_NEW(WARN, 45)
96 6654cd63 Eric Allman
#define GDP_STAT_CRYPTO_NO_PUB_KEY                GDP_STAT_NEW(WARN, 46)
97 caef25cd Eric Allman
#define GDP_STAT_CRYPTO_NO_SIG                        GDP_STAT_NEW(ERROR, 47)
98 80da996e Eric Allman
#define GDP_STAT_SVC_NAME_REQ                        GDP_STAT_NEW(SEVERE, 48)
99 dec37a7b Eric Allman
#define GDP_STAT_NAME_SHA                                GDP_STAT_NEW(WARN, 49)
100
#define GDP_STAT_OK_NAME_HONGD                        GDP_STAT_NEW(OK, 50)
101
#define GDP_STAT_OK_NAME_PNAME                        GDP_STAT_NEW(OK, 51)
102
#define GDP_STAT_OK_NAME_HEX                        GDP_STAT_NEW(OK, 52)
103 f5cccbca Eric Allman
#define GDP_STAT_HONGD_UNAVAILABLE                GDP_STAT_NEW(ERROR, 53)
104 1042a70f Eric Allman
#define GDP_STAT_CRYPTO_ERROR                        GDP_STAT_NEW(ERROR, 54)
105 0c663d10 Eric Allman
106 13429833 Eric Allman
107
/*
108
**  Both GDP ACK/NAK commands and status codes are based on status
109
**  codes from CoAP and HTTP, which are themselves related.  In most
110
**  (but not all) cases the CoAP codes are more appropriate.
111 02356366 Eric Allman
**  There are also some codes that have no CoAP or HTTP equivalents.
112 13429833 Eric Allman
**
113
**  This list uses the HTTP-style (three digit) representation, and
114
**  will be massaged later into both status codes and PDU commands.
115
**  I've tried to show the equivalent HTTP/CoAP codes (with CoAP
116
**  scaled from x.yz to xyz).
117
**
118
**  CoAP is based on RFC7252.  HTTP codes are based on version 1.1.
119
*/
120
121
#define _GDP_CCODE_SUCCESS                        200                // HTTP/CoAP Success
122
#define _GDP_CCODE_CREATED                        201                // HTTP/CoAP Created (201)
123
#define _GDP_CCODE_DELETED                        202                // CoAP Deleted
124
                                                                                        // (HTTP 202 Accepted)
125
#define _GDP_CCODE_VALID                        203                // CoAP Valid
126
                                                                                        // (HTTP 203 Non-Authoritative Info)
127
#define _GDP_CCODE_CHANGED                        204                // CoAP Changed
128
                                                                                        // (HTTP 204 No Content)
129
#define _GDP_CCODE_CONTENT                        205                // Content (~200, GET only)
130
                                                                                        // (HTTP 205 Reset Content)
131
                                                                                        // (HTTP 206 Partial Content)
132 bd278f2e Eric Allman
#define _GDP_CCODE_END_OF_RESULTS        263                // end of results (subscr/mread)
133 13429833 Eric Allman
134
#define _GDP_CCODE_BADREQ                        400                // HTTP/CoAP Bad Request
135
#define _GDP_CCODE_UNAUTH                        401                // HTTP/CoAP Unauthorized
136
#define _GDP_CCODE_BADOPT                        402                // CoAP Bad Option
137
                                                                                        // (HTTP 402 Payment Required)
138
#define _GDP_CCODE_FORBIDDEN                403                // HTTP/CoAP Forbidden
139
#define _GDP_CCODE_NOTFOUND                        404                // HTTP/CoAP Not Found
140
#define _GDP_CCODE_METHNOTALLOWED        405                // HTTP/CoAP Method Not Allowed
141
#define _GDP_CCODE_NOTACCEPTABLE        406                // HTTP/CoAP Not Acceptable
142
                                                                                        // (HTTP 407 Proxy Auth Required)
143
                                                                                        // (HTTP 408 Request Timeout)
144
#define _GDP_CCODE_CONFLICT                        409                // HTTP Conflict
145
#define _GDP_CCODE_GONE                                410                // HTTP Gone
146
                                                                                        // (HTTP 411 Length Required)
147
#define _GDP_CCODE_PRECONFAILED                412                // HTTP/CoAP Precondition Failed
148
#define _GDP_CCODE_TOOLARGE                        413                // HTTP/CoAP Request Entity Too Large
149
                                                                                        // (HTTP 414 Request-URI Too Long)
150
#define _GDP_CCODE_UNSUPMEDIA                415                // CoAP Unsupported Content-Format
151
                                                                                        // (HTTP 415 Request URI Too Long)
152
                                                                                        // (HTTP 416 Requested Range Not Satisficable)
153
                                                                                        // (HTTP 417 Expectation Failed)
154 7fdfaa3c Eric Allman
#define _GDP_CCODE_REC_MISSING                430                // GDP missing record (gap)
155
#define _GDP_CCODE_REC_DUP                        431                // GDP Duplicate Record
156 13429833 Eric Allman
157
#define _GDP_CCODE_INTERNAL                        500                // HTTP/CoAP Internal Server Error
158
#define _GDP_CCODE_NOTIMPL                        501                // HTTP/CoAP Not Implemented
159
#define _GDP_CCODE_BADGATEWAY                502                // HTTP/CoAP Bad Gateway
160
#define _GDP_CCODE_SVCUNAVAIL                503                // HTTP/CoAP Service Unavailable
161
#define _GDP_CCODE_GWTIMEOUT                504                // HTTP/CoAP Gateway Timeout
162
#define _GDP_CCODE_PROXYNOTSUP                505                // CoAP Proxying Not Supported
163
                                                                                        // (HTTP 505 HTTP Version Not Supported)
164 6d70b9d9 Eric Allman
#define _GDP_CCODE_REPLICATE_FAIL        514                // couldn't replicate
165 02356366 Eric Allman
#define _GDP_CCODE_LOST_SUBSCR                515                // GDP Lost Subscription
166 13429833 Eric Allman
167
#define _GDP_CCODE_NOROUTE                        600                // no advertisement found for name
168
169 21ab3878 Eric Allman
//                values from 200 up are reserved for this
170 13429833 Eric Allman
171
#define GDP_STAT_ACK_SUCCESS                GDP_STAT_NEW(OK, _GDP_CCODE_SUCCESS)
172
#define GDP_STAT_ACK_CREATED                GDP_STAT_NEW(OK, _GDP_CCODE_CREATED)
173
#define GDP_STAT_ACK_DELETED                GDP_STAT_NEW(OK, _GDP_CCODE_DELETED)
174
#define GDP_STAT_ACK_VALID                        GDP_STAT_NEW(OK, _GDP_CCODE_VALID)
175
#define GDP_STAT_ACK_CHANGED                GDP_STAT_NEW(OK, _GDP_CCODE_CHANGED)
176
#define GDP_STAT_ACK_CONTENT                GDP_STAT_NEW(OK, _GDP_CCODE_CONTENT)
177 bd278f2e Eric Allman
#define GDP_STAT_ACK_END_OF_RESULTS        GDP_STAT_NEW(WARN, _GDP_CCODE_END_OF_RESULTS)
178 13429833 Eric Allman
179
#define GDP_STAT_NAK_BADREQ                        GDP_STAT_NEW(ERROR, _GDP_CCODE_BADREQ)
180
#define GDP_STAT_NAK_UNAUTH                        GDP_STAT_NEW(ERROR, _GDP_CCODE_UNAUTH)
181
#define GDP_STAT_NAK_BADOPT                        GDP_STAT_NEW(ERROR, _GDP_CCODE_BADOPT)
182
#define GDP_STAT_NAK_FORBIDDEN                GDP_STAT_NEW(ERROR, _GDP_CCODE_FORBIDDEN)
183 956efe51 Eric Allman
#define GDP_STAT_NAK_NOTFOUND                GDP_STAT_NEW(ERROR, _GDP_CCODE_NOTFOUND)
184 13429833 Eric Allman
#define GDP_STAT_NAK_METHNOTALLOWED        GDP_STAT_NEW(ERROR, _GDP_CCODE_METHNOTALLOWED)
185
#define GDP_STAT_NAK_NOTACCEPTABLE        GDP_STAT_NEW(ERROR, _GDP_CCODE_NOTACCEPTABLE)
186
#define GDP_STAT_NAK_CONFLICT                GDP_STAT_NEW(ERROR, _GDP_CCODE_CONFLICT)
187 9742b2f7 Eric Allman
#define GDP_STAT_NAK_GONE                        GDP_STAT_NEW(WARN,  _GDP_CCODE_GONE)
188 13429833 Eric Allman
#define GDP_STAT_NAK_PRECONFAILED        GDP_STAT_NEW(ERROR, _GDP_CCODE_PRECONFAILED)
189
#define GDP_STAT_NAK_TOOLARGE                GDP_STAT_NEW(ERROR, _GDP_CCODE_TOOLARGE)
190
#define GDP_STAT_NAK_UNSUPMEDIA                GDP_STAT_NEW(ERROR, _GDP_CCODE_UNSUPMEDIA)
191 7fdfaa3c Eric Allman
#define GDP_STAT_NAK_REC_MISSING        GDP_STAT_NEW(WARN, _GDP_CCODE_REC_MISSING)
192
#define GDP_STAT_NAK_REC_DUP                GDP_STAT_NEW(WARN, _GDP_CCODE_REC_DUP)
193 13429833 Eric Allman
194
#define GDP_STAT_NAK_INTERNAL                GDP_STAT_NEW(SEVERE, _GDP_CCODE_INTERNAL)
195
#define GDP_STAT_NAK_NOTIMPL                GDP_STAT_NEW(SEVERE, _GDP_CCODE_NOTIMPL)
196
#define GDP_STAT_NAK_BADGATEWAY                GDP_STAT_NEW(SEVERE, _GDP_CCODE_BADGATEWAY)
197
#define GDP_STAT_NAK_SVCUNAVAIL                GDP_STAT_NEW(SEVERE, _GDP_CCODE_SVCUNAVAIL)
198
#define GDP_STAT_NAK_GWTIMEOUT                GDP_STAT_NEW(SEVERE, _GDP_CCODE_GWTIMEOUT)
199
#define GDP_STAT_NAK_PROXYNOTSUP        GDP_STAT_NEW(SEVERE, _GDP_CCODE_PROXYNOTSUP)
200 6d70b9d9 Eric Allman
#define GDP_STAT_NAK_REPLICATE_FAIL        GDP_STAT_NEW(ERROR, _GDP_CCODE_REPLICATE_FAIL)
201 02356366 Eric Allman
#define GDP_STAT_NAK_LOST_SUBSCR        GDP_STAT_NEW(WARN, _GDP_CCODE_LOST_SUBSCR)
202 13429833 Eric Allman
203
#define GDP_STAT_NAK_NOROUTE                GDP_STAT_NEW(ERROR, _GDP_CCODE_NOROUTE)
204
205
206
/*
207
**  Create EP_STAT from protocol command codes for acks and naks
208
*/
209
210 92243bf4 Eric Allman
#define GDP_STAT_FROM_ACK(c)                EP_STAT_NEW(EP_STAT_SEV_OK, 0, 0, (c) - GDP_ACK_MIN + 200)
211 13429833 Eric Allman
#define GDP_STAT_FROM_C_NAK(c)                GDP_STAT_NEW(ERROR, (c) - GDP_NAK_C_MIN + 400)
212
#define GDP_STAT_FROM_S_NAK(c)                GDP_STAT_NEW(SEVERE, (c) - GDP_NAK_S_MIN + 500)
213
#define GDP_STAT_FROM_R_NAK(c)                GDP_STAT_NEW(ERROR, (c) - GDP_NAK_R_MIN + 600)
214
215 8cc28925 Eric Allman
EP_STAT                                        _gdp_stat_from_acknak(int acknak);
216
217 13429833 Eric Allman
218
/*
219
**  Tests to see if an EP_STAT corresponds directly to a protocol command code
220
**
221
**                Detail values from 200 through 699 are reserved for this.
222
**                Note that these don't do serious error checking.
223
*/
224 8ec0d882 Eric Allman
225 916c2137 Eric Allman
#define GDP_STAT_IS_ACKNAK(estat)        (GDP_STAT_IS_GDP(estat) && \
226
                                                                         EP_STAT_DETAIL(estat) >= 200 && \
227 13429833 Eric Allman
                                                                         EP_STAT_DETAIL(estat) <= 615)
228 916c2137 Eric Allman
229 08be4c9c Eric Allman
#define GDP_STAT_IS_ACK(estat)                (GDP_STAT_IS_GDP(estat) && \
230
                                                                         EP_STAT_DETAIL(estat) >= 200 && \
231 13429833 Eric Allman
                                                                         EP_STAT_DETAIL(estat) <= 263)
232 08be4c9c Eric Allman
#define GDP_STAT_IS_C_NAK(estat)        (GDP_STAT_IS_GDP(estat) && \
233
                                                                         EP_STAT_DETAIL(estat) >= 400 && \
234 13429833 Eric Allman
                                                                         EP_STAT_DETAIL(estat) <= 431)
235 916c2137 Eric Allman
#define GDP_STAT_IS_S_NAK(estat)        (GDP_STAT_IS_GDP(estat) && \
236 08be4c9c Eric Allman
                                                                         EP_STAT_DETAIL(estat) >= 500 && \
237 13429833 Eric Allman
                                                                         EP_STAT_DETAIL(estat) <= 531)
238 916c2137 Eric Allman
#define GDP_STAT_IS_R_NAK(estat)        (GDP_STAT_IS_GDP(estat) && \
239 08be4c9c Eric Allman
                                                                         EP_STAT_DETAIL(estat) >= 600 && \
240
                                                                         EP_STAT_DETAIL(estat) <= 699)