1 /* $Id$ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #ifndef __PJLIB_UTIL_ERRNO_H__
21 #define __PJLIB_UTIL_ERRNO_H__
22 
23 
24 #include <pj/errno.h>
25 
26 /**
27  * @defgroup PJLIB_UTIL_ERROR Error Codes
28  * @ingroup PJLIB_UTIL_BASE
29  * @{
30  */
31 
32 /**
33  * Start of error code relative to PJ_ERRNO_START_USER.
34  * This value is 320000.
35  */
36 #define PJLIB_UTIL_ERRNO_START    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
37 
38 
39 /************************************************************
40  * STUN ERROR
41  ***********************************************************/
42 /**
43  * @hideinitializer
44  * Unable to resolve STUN server
45  */
46 #define PJLIB_UTIL_ESTUNRESOLVE	    (PJLIB_UTIL_ERRNO_START+1)	/* 320001 */
47 /**
48  * @hideinitializer
49  * Unknown STUN message type.
50  */
51 #define PJLIB_UTIL_ESTUNINMSGTYPE   (PJLIB_UTIL_ERRNO_START+2)	/* 320002 */
52 /**
53  * @hideinitializer
54  * Invalid STUN message length
55  */
56 #define PJLIB_UTIL_ESTUNINMSGLEN    (PJLIB_UTIL_ERRNO_START+3)	/* 320003 */
57 /**
58  * @hideinitializer
59  * Invalid STUN attribute length
60  */
61 #define PJLIB_UTIL_ESTUNINATTRLEN   (PJLIB_UTIL_ERRNO_START+4)	/* 320004 */
62 /**
63  * @hideinitializer
64  * Invalid STUN attribute type
65  */
66 #define PJLIB_UTIL_ESTUNINATTRTYPE  (PJLIB_UTIL_ERRNO_START+5)	/* 320005 */
67 /**
68  * @hideinitializer
69  * Invalid STUN server/socket index
70  */
71 #define PJLIB_UTIL_ESTUNININDEX     (PJLIB_UTIL_ERRNO_START+6)	/* 320006 */
72 /**
73  * @hideinitializer
74  * No STUN binding response in the message
75  */
76 #define PJLIB_UTIL_ESTUNNOBINDRES   (PJLIB_UTIL_ERRNO_START+7)	/* 320007 */
77 /**
78  * @hideinitializer
79  * Received STUN error attribute
80  */
81 #define PJLIB_UTIL_ESTUNRECVERRATTR (PJLIB_UTIL_ERRNO_START+8)	/* 320008 */
82 /**
83  * @hideinitializer
84  * No STUN mapped address attribute
85  */
86 #define PJLIB_UTIL_ESTUNNOMAP       (PJLIB_UTIL_ERRNO_START+9)	/* 320009 */
87 /**
88  * @hideinitializer
89  * Received no response from STUN server
90  */
91 #define PJLIB_UTIL_ESTUNNOTRESPOND  (PJLIB_UTIL_ERRNO_START+10)	/* 320010 */
92 /**
93  * @hideinitializer
94  * Symetric NAT detected by STUN
95  */
96 #define PJLIB_UTIL_ESTUNSYMMETRIC   (PJLIB_UTIL_ERRNO_START+11)	/* 320011 */
97 /**
98  * @hideinitializer
99  * Invalid STUN magic value
100  */
101 #define PJLIB_UTIL_ESTUNNOTMAGIC    (PJLIB_UTIL_ERRNO_START+12)	/* 320012 */
102 /**
103  * @hideinitializer
104  * Invalid STUN fingerprint value
105  */
106 #define PJLIB_UTIL_ESTUNFINGERPRINT (PJLIB_UTIL_ERRNO_START+13)	/* 320013 */
107 
108 
109 
110 /************************************************************
111  * XML ERROR
112  ***********************************************************/
113 /**
114  * @hideinitializer
115  * General invalid XML message.
116  */
117 #define PJLIB_UTIL_EINXML	    (PJLIB_UTIL_ERRNO_START+20)	/* 320020 */
118 
119 
120 /************************************************************
121  * JSON ERROR
122  ***********************************************************/
123 /**
124  * @hideinitializer
125  * General invalid JSON message.
126  */
127 #define PJLIB_UTIL_EINJSON	    (PJLIB_UTIL_ERRNO_START+30)	/* 320030 */
128 
129 
130 /************************************************************
131  * DNS ERROR
132  ***********************************************************/
133 /**
134  * @hideinitializer
135  * DNS query packet buffer is too small.
136  * This error occurs when the user supplied buffer for creating DNS
137  * query (#pj_dns_make_query() function) is too small.
138  */
139 #define PJLIB_UTIL_EDNSQRYTOOSMALL  (PJLIB_UTIL_ERRNO_START+40)	/* 320040 */
140 /**
141  * @hideinitializer
142  * Invalid DNS packet length.
143  * This error occurs when the received DNS response packet does not
144  * match all the fields length.
145  */
146 #define PJLIB_UTIL_EDNSINSIZE	    (PJLIB_UTIL_ERRNO_START+41)	/* 320041 */
147 /**
148  * @hideinitializer
149  * Invalid DNS class.
150  * This error occurs when the received DNS response contains network
151  * class other than IN (Internet).
152  */
153 #define PJLIB_UTIL_EDNSINCLASS	    (PJLIB_UTIL_ERRNO_START+42)	/* 320042 */
154 /**
155  * @hideinitializer
156  * Invalid DNS name pointer.
157  * This error occurs when parsing the compressed names inside DNS
158  * response packet, when the name pointer points to an invalid address
159  * or the parsing has triggerred too much recursion.
160  */
161 #define PJLIB_UTIL_EDNSINNAMEPTR    (PJLIB_UTIL_ERRNO_START+43)	/* 320043 */
162 /**
163  * @hideinitializer
164  * Invalid DNS nameserver address. If hostname was specified for nameserver
165  * address, this error means that the function was unable to resolve
166  * the nameserver hostname.
167  */
168 #define PJLIB_UTIL_EDNSINNSADDR	    (PJLIB_UTIL_ERRNO_START+44)	/* 320044 */
169 /**
170  * @hideinitializer
171  * No nameserver is in DNS resolver. No nameserver is configured in the
172  * resolver.
173  */
174 #define PJLIB_UTIL_EDNSNONS	    (PJLIB_UTIL_ERRNO_START+45)	/* 320045 */
175 /**
176  * @hideinitializer
177  * No working DNS nameserver. All nameservers have been queried,
178  * but none was able to serve any DNS requests. These "bad" nameservers
179  * will be re-tested again for "goodness" after some period.
180  */
181 #define PJLIB_UTIL_EDNSNOWORKINGNS  (PJLIB_UTIL_ERRNO_START+46)	/* 320046 */
182 /**
183  * @hideinitializer
184  * No answer record in the DNS response.
185  */
186 #define PJLIB_UTIL_EDNSNOANSWERREC  (PJLIB_UTIL_ERRNO_START+47)	/* 320047 */
187 /**
188  * @hideinitializer
189  * Invalid DNS answer. This error is raised for example when the DNS
190  * answer does not have a query section, or the type of RR in the answer
191  * doesn't match the query.
192  */
193 #define PJLIB_UTIL_EDNSINANSWER	    (PJLIB_UTIL_ERRNO_START+48)	/* 320048 */
194 
195 
196 /* DNS ERRORS MAPPED FROM RCODE: */
197 
198 /**
199  * Start of error code mapped from DNS RCODE
200  */
201 #define PJLIB_UTIL_DNS_RCODE_START  (PJLIB_UTIL_ERRNO_START+50)	/* 320050 */
202 
203 /**
204  * Map DNS RCODE status into pj_status_t.
205  */
206 #define PJ_STATUS_FROM_DNS_RCODE(rcode)	(rcode==0 ? PJ_SUCCESS : \
207 					 PJLIB_UTIL_DNS_RCODE_START+rcode)
208 /**
209  * @hideinitializer
210  * Format error - The name server was unable to interpret the query.
211  * This corresponds to DNS RCODE 1.
212  */
213 #define PJLIB_UTIL_EDNS_FORMERR	    PJ_STATUS_FROM_DNS_RCODE(1)	/* 320051 */
214 /**
215  * @hideinitializer
216  * Server failure - The name server was unable to process this query due to a
217  * problem with the name server.
218  * This corresponds to DNS RCODE 2.
219  */
220 #define PJLIB_UTIL_EDNS_SERVFAIL    PJ_STATUS_FROM_DNS_RCODE(2)	/* 320052 */
221 /**
222  * @hideinitializer
223  * Name Error - Meaningful only for responses from an authoritative name
224  * server, this code signifies that the domain name referenced in the query
225  * does not exist.
226  * This corresponds to DNS RCODE 3.
227  */
228 #define PJLIB_UTIL_EDNS_NXDOMAIN    PJ_STATUS_FROM_DNS_RCODE(3)	/* 320053 */
229 /**
230  * @hideinitializer
231  * Not Implemented - The name server does not support the requested kind of
232  * query.
233  * This corresponds to DNS RCODE 4.
234  */
235 #define PJLIB_UTIL_EDNS_NOTIMPL    PJ_STATUS_FROM_DNS_RCODE(4)	/* 320054 */
236 /**
237  * @hideinitializer
238  * Refused - The name server refuses to perform the specified operation for
239  * policy reasons.
240  * This corresponds to DNS RCODE 5.
241  */
242 #define PJLIB_UTIL_EDNS_REFUSED	    PJ_STATUS_FROM_DNS_RCODE(5)	/* 320055 */
243 /**
244  * @hideinitializer
245  * The name exists.
246  * This corresponds to DNS RCODE 6.
247  */
248 #define PJLIB_UTIL_EDNS_YXDOMAIN    PJ_STATUS_FROM_DNS_RCODE(6)	/* 320056 */
249 /**
250  * @hideinitializer
251  * The RRset (name, type) exists.
252  * This corresponds to DNS RCODE 7.
253  */
254 #define PJLIB_UTIL_EDNS_YXRRSET	    PJ_STATUS_FROM_DNS_RCODE(7)	/* 320057 */
255 /**
256  * @hideinitializer
257  * The RRset (name, type) does not exist.
258  * This corresponds to DNS RCODE 8.
259  */
260 #define PJLIB_UTIL_EDNS_NXRRSET	    PJ_STATUS_FROM_DNS_RCODE(8)	/* 320058 */
261 /**
262  * @hideinitializer
263  * The requestor is not authorized to perform this operation.
264  * This corresponds to DNS RCODE 9.
265  */
266 #define PJLIB_UTIL_EDNS_NOTAUTH	    PJ_STATUS_FROM_DNS_RCODE(9)	/* 320059 */
267 /**
268  * @hideinitializer
269  * The zone specified is not a zone.
270  * This corresponds to DNS RCODE 10.
271  */
272 #define PJLIB_UTIL_EDNS_NOTZONE	    PJ_STATUS_FROM_DNS_RCODE(10)/* 320060 */
273 
274 
275 /************************************************************
276  * NEW STUN ERROR
277  ***********************************************************/
278 /* Messaging errors */
279 /**
280  * @hideinitializer
281  * Too many STUN attributes.
282  */
283 #define PJLIB_UTIL_ESTUNTOOMANYATTR (PJLIB_UTIL_ERRNO_START+110)/* 320110 */
284 /**
285  * @hideinitializer
286  * Unknown STUN attribute. This error happens when the decoder encounters
287  * mandatory attribute type which it doesn't understand.
288  */
289 #define PJLIB_UTIL_ESTUNUNKNOWNATTR (PJLIB_UTIL_ERRNO_START+111)/* 320111 */
290 /**
291  * @hideinitializer
292  * Invalid STUN socket address length.
293  */
294 #define PJLIB_UTIL_ESTUNINADDRLEN   (PJLIB_UTIL_ERRNO_START+112)/* 320112 */
295 /**
296  * @hideinitializer
297  * STUN IPv6 attribute not supported
298  */
299 #define PJLIB_UTIL_ESTUNIPV6NOTSUPP (PJLIB_UTIL_ERRNO_START+113)/* 320113 */
300 /**
301  * @hideinitializer
302  * Expecting STUN response message.
303  */
304 #define PJLIB_UTIL_ESTUNNOTRESPONSE (PJLIB_UTIL_ERRNO_START+114)/* 320114 */
305 /**
306  * @hideinitializer
307  * STUN transaction ID mismatch.
308  */
309 #define PJLIB_UTIL_ESTUNINVALIDID   (PJLIB_UTIL_ERRNO_START+115)/* 320115 */
310 /**
311  * @hideinitializer
312  * Unable to find handler for the request.
313  */
314 #define PJLIB_UTIL_ESTUNNOHANDLER   (PJLIB_UTIL_ERRNO_START+116)/* 320116 */
315 /**
316  * @hideinitializer
317  * Found non-FINGERPRINT attribute after MESSAGE-INTEGRITY. This is not
318  * valid since MESSAGE-INTEGRITY MUST be the last attribute or the
319  * attribute right before FINGERPRINT before the message.
320  */
321 #define PJLIB_UTIL_ESTUNMSGINTPOS    (PJLIB_UTIL_ERRNO_START+118)/* 320118 */
322 /**
323  * @hideinitializer
324  * Found attribute after FINGERPRINT. This is not valid since FINGERPRINT
325  * MUST be the last attribute in the message.
326  */
327 #define PJLIB_UTIL_ESTUNFINGERPOS   (PJLIB_UTIL_ERRNO_START+119)/* 320119 */
328 /**
329  * @hideinitializer
330  * Missing STUN USERNAME attribute.
331  * When credential is included in the STUN message (MESSAGE-INTEGRITY is
332  * present), the USERNAME attribute must be present in the message.
333  */
334 #define PJLIB_UTIL_ESTUNNOUSERNAME  (PJLIB_UTIL_ERRNO_START+120)/* 320120 */
335 /**
336  * @hideinitializer
337  * Unknown STUN username/credential.
338  */
339 #define PJLIB_UTIL_ESTUNUSERNAME    (PJLIB_UTIL_ERRNO_START+121)/* 320121 */
340 /**
341  * @hideinitializer
342  * Missing/invalidSTUN MESSAGE-INTEGRITY attribute.
343  */
344 #define PJLIB_UTIL_ESTUNMSGINT	    (PJLIB_UTIL_ERRNO_START+122)/* 320122 */
345 /**
346  * @hideinitializer
347  * Found duplicate STUN attribute.
348  */
349 #define PJLIB_UTIL_ESTUNDUPATTR	    (PJLIB_UTIL_ERRNO_START+123)/* 320123 */
350 /**
351  * @hideinitializer
352  * Missing STUN REALM attribute.
353  */
354 #define PJLIB_UTIL_ESTUNNOREALM	    (PJLIB_UTIL_ERRNO_START+124)/* 320124 */
355 /**
356  * @hideinitializer
357  * Missing/stale STUN NONCE attribute value.
358  */
359 #define PJLIB_UTIL_ESTUNNONCE	    (PJLIB_UTIL_ERRNO_START+125)/* 320125 */
360 /**
361  * @hideinitializer
362  * STUN transaction terminates with failure.
363  */
364 #define PJLIB_UTIL_ESTUNTSXFAILED    (PJLIB_UTIL_ERRNO_START+126)/* 320126 */
365 
366 
367 //#define PJ_STATUS_FROM_STUN_CODE(code)	(PJLIB_UTIL_ERRNO_START+code)
368 
369 /************************************************************
370  * HTTP Client ERROR
371  ***********************************************************/
372 /**
373  * @hideinitializer
374  * Invalid URL format
375  */
376 #define PJLIB_UTIL_EHTTPINURL	    (PJLIB_UTIL_ERRNO_START+151)/* 320151 */
377 /**
378  * @hideinitializer
379  * Invalid port number
380  */
381 #define PJLIB_UTIL_EHTTPINPORT	    (PJLIB_UTIL_ERRNO_START+152)/* 320152 */
382 /**
383  * @hideinitializer
384  * Incomplete headers received
385  */
386 #define PJLIB_UTIL_EHTTPINCHDR	    (PJLIB_UTIL_ERRNO_START+153)/* 320153 */
387 /**
388  * @hideinitializer
389  * Insufficient buffer
390  */
391 #define PJLIB_UTIL_EHTTPINSBUF	    (PJLIB_UTIL_ERRNO_START+154)/* 320154 */
392 /**
393  * @hideinitializer
394  * Connection lost
395  */
396 #define PJLIB_UTIL_EHTTPLOST	    (PJLIB_UTIL_ERRNO_START+155)/* 320155 */
397 
398 /************************************************************
399  * CLI ERROR
400  ***********************************************************/
401 
402 /**
403  * @hideinitializer
404  * End the current session. This is a special error code returned by
405  * pj_cli_sess_exec() to indicate that "exit" or equivalent command has been
406  * called to end the current session.
407  */
408 #define PJ_CLI_EEXIT        	    (PJLIB_UTIL_ERRNO_START+201)/* 320201 */
409 /**
410  * @hideinitializer
411  * A required CLI argument is not specified.
412  */
413 #define PJ_CLI_EMISSINGARG    	    (PJLIB_UTIL_ERRNO_START+202)/* 320202 */
414  /**
415  * @hideinitializer
416  * Too many CLI arguments.
417  */
418 #define PJ_CLI_ETOOMANYARGS    	    (PJLIB_UTIL_ERRNO_START+203)/* 320203 */
419 /**
420  * @hideinitializer
421  * Invalid CLI argument. Typically this is caused by extra characters
422  * specified in the command line which does not match any arguments.
423  */
424 #define PJ_CLI_EINVARG        	    (PJLIB_UTIL_ERRNO_START+204)/* 320204 */
425 /**
426  * @hideinitializer
427  * CLI command with the specified name already exist.
428  */
429 #define PJ_CLI_EBADNAME        	    (PJLIB_UTIL_ERRNO_START+205)/* 320205 */
430 /**
431  * @hideinitializer
432  * CLI command with the specified id already exist.
433  */
434 #define PJ_CLI_EBADID        	    (PJLIB_UTIL_ERRNO_START+206)/* 320206 */
435 /**
436  * @hideinitializer
437  * Invalid XML format for CLI command specification.
438  */
439 #define PJ_CLI_EBADXML        	    (PJLIB_UTIL_ERRNO_START+207)/* 320207 */
440 /**
441  * @hideinitializer
442  * CLI command entered by user match with more than one command/argument
443  * specification.
444  */
445 #define PJ_CLI_EAMBIGUOUS	    (PJLIB_UTIL_ERRNO_START+208)/* 320208 */
446 /**
447  * @hideinitializer
448  * Telnet connection lost.
449  */
450 #define PJ_CLI_ETELNETLOST          (PJLIB_UTIL_ERRNO_START+211)/* 320211 */
451 
452 /**
453  * @}
454  */
455 
456 #endif	/* __PJLIB_UTIL_ERRNO_H__ */
457