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 __PJSIP_SIP_ERRNO_H__ 21 #define __PJSIP_SIP_ERRNO_H__ 22 23 /** 24 * @file sip_errno.h 25 * @brief PJSIP Specific Error Code 26 */ 27 28 #include <pj/errno.h> 29 30 PJ_BEGIN_DECL 31 32 /** 33 * @defgroup PJSIP_CORE_ERRNO PJSIP Specific Error Code 34 * @ingroup PJSIP_BASE 35 * @brief PJSIP specific error constants. 36 * @{ 37 */ 38 39 /* 40 * PJSIP error codes occupies 170000 - 219000, and mapped as follows: 41 * - 170100 - 170799: mapped to SIP status code in response msg. 42 * - 171000 - 171999: mapped to errors generated from PJSIP core. 43 */ 44 45 /** 46 * Start of error code relative to PJ_ERRNO_START_USER. 47 */ 48 #define PJSIP_ERRNO_START (PJ_ERRNO_START_USER) 49 50 /** 51 * Create error value from SIP status code. 52 * @param code SIP status code. 53 * @return Error code in pj_status_t namespace. 54 */ 55 #define PJSIP_ERRNO_FROM_SIP_STATUS(code) (PJSIP_ERRNO_START+code) 56 57 /** 58 * Get SIP status code from error value. 59 * If conversion to SIP status code is not available, a SIP status code 60 * 599 will be returned. 61 * 62 * @param status Error code in pj_status_t namespace. 63 * @return SIP status code. 64 */ 65 #define PJSIP_ERRNO_TO_SIP_STATUS(status) \ 66 ((status>=PJSIP_ERRNO_FROM_SIP_STATUS(100) && \ 67 status<PJSIP_ERRNO_FROM_SIP_STATUS(800)) ? \ 68 status-PJSIP_ERRNO_FROM_SIP_STATUS(0) : 599) 69 70 71 /** 72 * Start of PJSIP generated error code values. 73 */ 74 #define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000) 75 76 /************************************************************ 77 * GENERIC/GENERAL SIP ERRORS 78 ***********************************************************/ 79 /** 80 * @hideinitializer 81 * SIP object is busy. 82 */ 83 #define PJSIP_EBUSY (PJSIP_ERRNO_START_PJSIP + 1) /* 171001 */ 84 /** 85 * @hideinitializer 86 * SIP object with the same type already exists. 87 */ 88 #define PJSIP_ETYPEEXISTS (PJSIP_ERRNO_START_PJSIP + 2) /* 171002 */ 89 /** 90 * @hideinitializer 91 * SIP stack is shutting down. 92 */ 93 #define PJSIP_ESHUTDOWN (PJSIP_ERRNO_START_PJSIP + 3) /* 171003 */ 94 /** 95 * @hideinitializer 96 * SIP object is not initialized. 97 */ 98 #define PJSIP_ENOTINITIALIZED (PJSIP_ERRNO_START_PJSIP + 4) /* 171004 */ 99 /** 100 * @hideinitializer 101 * Missing route set (for tel: URI) 102 */ 103 #define PJSIP_ENOROUTESET (PJSIP_ERRNO_START_PJSIP + 5) /* 171005 */ 104 105 106 /************************************************************ 107 * MESSAGING ERRORS 108 ***********************************************************/ 109 /** 110 * @hideinitializer 111 * General invalid message error (e.g. syntax error) 112 */ 113 #define PJSIP_EINVALIDMSG (PJSIP_ERRNO_START_PJSIP + 20) /* 171020 */ 114 /** 115 * @hideinitializer 116 * Expecting request message. 117 */ 118 #define PJSIP_ENOTREQUESTMSG (PJSIP_ERRNO_START_PJSIP + 21) /* 171021 */ 119 /** 120 * @hideinitializer 121 * Expecting response message. 122 */ 123 #define PJSIP_ENOTRESPONSEMSG (PJSIP_ERRNO_START_PJSIP + 22) /* 171022 */ 124 /** 125 * @hideinitializer 126 * Message too long. See also PJSIP_ERXOVERFLOW. 127 */ 128 #define PJSIP_EMSGTOOLONG (PJSIP_ERRNO_START_PJSIP + 23) /* 171023 */ 129 /** 130 * @hideinitializer 131 * Message not completely received. 132 */ 133 #define PJSIP_EPARTIALMSG (PJSIP_ERRNO_START_PJSIP + 24) /* 171024 */ 134 135 /** 136 * @hideinitializer 137 * Status code is invalid. 138 */ 139 #define PJSIP_EINVALIDSTATUS (PJSIP_ERRNO_START_PJSIP + 30) /* 171030 */ 140 141 /** 142 * @hideinitializer 143 * General Invalid URI error. 144 */ 145 #define PJSIP_EINVALIDURI (PJSIP_ERRNO_START_PJSIP + 39) /* 171039 */ 146 /** 147 * @hideinitializer 148 * Unsupported URL scheme. 149 */ 150 #define PJSIP_EINVALIDSCHEME (PJSIP_ERRNO_START_PJSIP + 40) /* 171040 */ 151 /** 152 * @hideinitializer 153 * Missing Request-URI. 154 */ 155 #define PJSIP_EMISSINGREQURI (PJSIP_ERRNO_START_PJSIP + 41) /* 171041 */ 156 /** 157 * @hideinitializer 158 * Invalid request URI. 159 */ 160 #define PJSIP_EINVALIDREQURI (PJSIP_ERRNO_START_PJSIP + 42) /* 171042 */ 161 /** 162 * @hideinitializer 163 * URI is too long. 164 */ 165 #define PJSIP_EURITOOLONG (PJSIP_ERRNO_START_PJSIP + 43) /* 171043 */ 166 167 /** 168 * @hideinitializer 169 * Missing required header(s). 170 */ 171 #define PJSIP_EMISSINGHDR (PJSIP_ERRNO_START_PJSIP + 50) /* 171050 */ 172 /** 173 * @hideinitializer 174 * Invalid header field. 175 */ 176 #define PJSIP_EINVALIDHDR (PJSIP_ERRNO_START_PJSIP + 51) /* 171051 */ 177 /** 178 * @hideinitializer 179 * Invalid Via header in response (sent-by, etc). 180 */ 181 #define PJSIP_EINVALIDVIA (PJSIP_ERRNO_START_PJSIP + 52) /* 171052 */ 182 /** 183 * @hideinitializer 184 * Multiple Via headers in response. 185 */ 186 #define PJSIP_EMULTIPLEVIA (PJSIP_ERRNO_START_PJSIP + 53) /* 171053 */ 187 /** 188 * @hideinitializer 189 * Missing message body. 190 */ 191 #define PJSIP_EMISSINGBODY (PJSIP_ERRNO_START_PJSIP + 54) /* 171054 */ 192 /** 193 * @hideinitializer 194 * Invalid/unexpected method. 195 */ 196 #define PJSIP_EINVALIDMETHOD (PJSIP_ERRNO_START_PJSIP + 55) /* 171055 */ 197 198 199 /************************************************************ 200 * TRANSPORT ERRORS 201 ***********************************************************/ 202 /** 203 * @hideinitializer 204 * Unsupported transport type. 205 */ 206 #define PJSIP_EUNSUPTRANSPORT (PJSIP_ERRNO_START_PJSIP + 60) /* 171060 */ 207 /** 208 * @hideinitializer 209 * Buffer is being sent, operation still pending. 210 */ 211 #define PJSIP_EPENDINGTX (PJSIP_ERRNO_START_PJSIP + 61) /* 171061 */ 212 /** 213 * @hideinitializer 214 * Rx buffer overflow. See also PJSIP_EMSGTOOLONG. 215 */ 216 #define PJSIP_ERXOVERFLOW (PJSIP_ERRNO_START_PJSIP + 62) /* 171062 */ 217 /** 218 * @hideinitializer 219 * This is not really an error, it just informs application that 220 * transmit data has been deleted on return of pjsip_tx_data_dec_ref(). 221 */ 222 #define PJSIP_EBUFDESTROYED (PJSIP_ERRNO_START_PJSIP + 63) /* 171063 */ 223 /** 224 * @hideinitializer 225 * Unsuitable transport selected. This error occurs when application 226 * has explicitly requested to use a particular transport/listener, 227 * but the selected transport is not suitable to send request to 228 * the specified destination. 229 */ 230 #define PJSIP_ETPNOTSUITABLE (PJSIP_ERRNO_START_PJSIP + 64) /* 171064 */ 231 /** 232 * @hideinitializer 233 * Transport not available. This error occurs for example when the SIP stack 234 * is trying to use a SIP transport while the transport is being paused by 235 * application. 236 */ 237 #define PJSIP_ETPNOTAVAIL (PJSIP_ERRNO_START_PJSIP + 65) /* 171065 */ 238 239 /************************************************************ 240 * TRANSACTION ERRORS 241 ***********************************************************/ 242 /** 243 * @hideinitializer 244 * Transaction has just been destroyed. 245 */ 246 #define PJSIP_ETSXDESTROYED (PJSIP_ERRNO_START_PJSIP + 70) /* 171070 */ 247 /** 248 * @hideinitializer 249 * No transaction. 250 */ 251 #define PJSIP_ENOTSX (PJSIP_ERRNO_START_PJSIP + 71) /* 171071 */ 252 253 254 /************************************************************ 255 * URI COMPARISON RESULTS 256 ***********************************************************/ 257 /** 258 * @hideinitializer 259 * Scheme mismatch. 260 */ 261 #define PJSIP_ECMPSCHEME (PJSIP_ERRNO_START_PJSIP + 80) /* 171080 */ 262 /** 263 * @hideinitializer 264 * User part mismatch. 265 */ 266 #define PJSIP_ECMPUSER (PJSIP_ERRNO_START_PJSIP + 81) /* 171081 */ 267 /** 268 * @hideinitializer 269 * Password part mismatch. 270 */ 271 #define PJSIP_ECMPPASSWD (PJSIP_ERRNO_START_PJSIP + 82) /* 171082 */ 272 /** 273 * @hideinitializer 274 * Host part mismatch. 275 */ 276 #define PJSIP_ECMPHOST (PJSIP_ERRNO_START_PJSIP + 83) /* 171083 */ 277 /** 278 * @hideinitializer 279 * Port part mismatch. 280 */ 281 #define PJSIP_ECMPPORT (PJSIP_ERRNO_START_PJSIP + 84) /* 171084 */ 282 /** 283 * @hideinitializer 284 * Transport parameter part mismatch. 285 */ 286 #define PJSIP_ECMPTRANSPORTPRM (PJSIP_ERRNO_START_PJSIP + 85) /* 171085 */ 287 /** 288 * @hideinitializer 289 * TTL parameter part mismatch. 290 */ 291 #define PJSIP_ECMPTTLPARAM (PJSIP_ERRNO_START_PJSIP + 86) /* 171086 */ 292 /** 293 * @hideinitializer 294 * User parameter part mismatch. 295 */ 296 #define PJSIP_ECMPUSERPARAM (PJSIP_ERRNO_START_PJSIP + 87) /* 171087 */ 297 /** 298 * @hideinitializer 299 * Method parameter part mismatch. 300 */ 301 #define PJSIP_ECMPMETHODPARAM (PJSIP_ERRNO_START_PJSIP + 88) /* 171088 */ 302 /** 303 * @hideinitializer 304 * Maddr parameter part mismatch. 305 */ 306 #define PJSIP_ECMPMADDRPARAM (PJSIP_ERRNO_START_PJSIP + 89) /* 171089 */ 307 /** 308 * @hideinitializer 309 * Parameter part in other_param mismatch. 310 */ 311 #define PJSIP_ECMPOTHERPARAM (PJSIP_ERRNO_START_PJSIP + 90) /* 171090 */ 312 /** 313 * @hideinitializer 314 * Parameter part in header_param mismatch. 315 */ 316 #define PJSIP_ECMPHEADERPARAM (PJSIP_ERRNO_START_PJSIP + 91) /* 171091 */ 317 318 319 /************************************************************ 320 * AUTHENTICATION FRAMEWORK 321 ***********************************************************/ 322 /** 323 * @hideinitializer 324 * Credential failed to authenticate. For this failure, right credential 325 * for the realm has been found and used to authenticate against the challenge, 326 * but the server has rejected the authorization request with 401/407 response 327 * (either with no stale parameter or with "stale=false" parameter). In most 328 * cases, this indicates that the username/password combination is incorrect. 329 */ 330 #define PJSIP_EFAILEDCREDENTIAL (PJSIP_ERRNO_START_PJSIP + 100) /* 171100 */ 331 /** 332 * @hideinitializer 333 * No suitable credential is found to authenticate the request against 334 * the received authentication challenge in 401/407 response. This often 335 * is caused by different realm supplied in the credential than the realm 336 * found in the challenge. 337 */ 338 #define PJSIP_ENOCREDENTIAL (PJSIP_ERRNO_START_PJSIP + 101) /* 171101 */ 339 /** 340 * @hideinitializer 341 * Invalid/unsupported algorithm. 342 */ 343 #define PJSIP_EINVALIDALGORITHM (PJSIP_ERRNO_START_PJSIP + 102) /* 171102 */ 344 /** 345 * @hideinitializer 346 * Invalid/unsupported qop. 347 */ 348 #define PJSIP_EINVALIDQOP (PJSIP_ERRNO_START_PJSIP + 103) /* 171103 */ 349 /** 350 * @hideinitializer 351 * Invalid/unsupported authentication scheme. 352 */ 353 #define PJSIP_EINVALIDAUTHSCHEME (PJSIP_ERRNO_START_PJSIP + 104)/* 171104 */ 354 /** 355 * @hideinitializer 356 * No previous challenge. 357 */ 358 #define PJSIP_EAUTHNOPREVCHAL (PJSIP_ERRNO_START_PJSIP + 105) /* 171105 */ 359 /** 360 * @hideinitializer 361 * No authorization is found. 362 */ 363 #define PJSIP_EAUTHNOAUTH (PJSIP_ERRNO_START_PJSIP + 106) /* 171106 */ 364 /** 365 * @hideinitializer 366 * Account not found. 367 */ 368 #define PJSIP_EAUTHACCNOTFOUND (PJSIP_ERRNO_START_PJSIP + 107) /* 171107 */ 369 /** 370 * @hideinitializer 371 * Account is disabled. 372 */ 373 #define PJSIP_EAUTHACCDISABLED (PJSIP_ERRNO_START_PJSIP + 108) /* 171108 */ 374 /** 375 * @hideinitializer 376 * Invalid realm. 377 */ 378 #define PJSIP_EAUTHINVALIDREALM (PJSIP_ERRNO_START_PJSIP + 109) /* 171109 */ 379 /** 380 * @hideinitializer 381 * Invalid digest. 382 */ 383 #define PJSIP_EAUTHINVALIDDIGEST (PJSIP_ERRNO_START_PJSIP+110) /* 171110 */ 384 /** 385 * @hideinitializer 386 * Maximum number of stale retries exceeded. This happens when server 387 * keeps rejecting our authorization request with stale=true. 388 */ 389 #define PJSIP_EAUTHSTALECOUNT (PJSIP_ERRNO_START_PJSIP + 111) /* 171111 */ 390 /** 391 * @hideinitializer 392 * Invalid nonce value in the challenge. 393 */ 394 #define PJSIP_EAUTHINNONCE (PJSIP_ERRNO_START_PJSIP + 112) /* 171112 */ 395 /** 396 * @hideinitializer 397 * Invalid AKA credential. 398 */ 399 #define PJSIP_EAUTHINAKACRED (PJSIP_ERRNO_START_PJSIP + 113) /* 171113 */ 400 /** 401 * No challenge is found in the challenge. 402 */ 403 #define PJSIP_EAUTHNOCHAL (PJSIP_ERRNO_START_PJSIP + 114) /* 171114 */ 404 405 /************************************************************ 406 * UA AND DIALOG ERRORS 407 ***********************************************************/ 408 /** 409 * @hideinitializer 410 * Missing From/To tag. 411 */ 412 #define PJSIP_EMISSINGTAG (PJSIP_ERRNO_START_PJSIP+120) /* 171120 */ 413 /** 414 * @hideinitializer 415 * Expecting REFER method 416 */ 417 #define PJSIP_ENOTREFER (PJSIP_ERRNO_START_PJSIP+121) /* 171121 */ 418 /** 419 * @hideinitializer 420 * Not associated with REFER subscription 421 */ 422 #define PJSIP_ENOREFERSESSION (PJSIP_ERRNO_START_PJSIP+122) /* 171122 */ 423 424 /************************************************************ 425 * INVITE SESSIONS ERRORS 426 ***********************************************************/ 427 /** 428 * @hideinitializer 429 * Session already terminated. 430 */ 431 #define PJSIP_ESESSIONTERMINATED (PJSIP_ERRNO_START_PJSIP+140) /* 171140 */ 432 /** 433 * @hideinitializer 434 * Invalid session state for the specified operation. 435 */ 436 #define PJSIP_ESESSIONSTATE (PJSIP_ERRNO_START_PJSIP+141) /* 171141 */ 437 /** 438 * @hideinitializer 439 * The feature being requested requires the use of secure session or 440 * transport. 441 */ 442 #define PJSIP_ESESSIONINSECURE (PJSIP_ERRNO_START_PJSIP+142) /* 171142 */ 443 444 /************************************************************ 445 * TLS TRANSPORT ERRORS 446 ***********************************************************/ 447 /** 448 * @hideinitializer 449 * Unknown TLS error 450 */ 451 #define PJSIP_TLS_EUNKNOWN (PJSIP_ERRNO_START_PJSIP+160) /* 171160 */ 452 /** 453 * @hideinitializer 454 * Invalid SSL protocol method. 455 */ 456 #define PJSIP_TLS_EINVMETHOD (PJSIP_ERRNO_START_PJSIP+161) /* 171161 */ 457 /** 458 * @hideinitializer 459 * Error loading/verifying SSL CA list file. 460 */ 461 #define PJSIP_TLS_ECACERT (PJSIP_ERRNO_START_PJSIP+162) /* 171162 */ 462 /** 463 * @hideinitializer 464 * Error loading SSL certificate chain file. 465 */ 466 #define PJSIP_TLS_ECERTFILE (PJSIP_ERRNO_START_PJSIP+163) /* 171163 */ 467 /** 468 * @hideinitializer 469 * Error adding private key from SSL certificate file. 470 */ 471 #define PJSIP_TLS_EKEYFILE (PJSIP_ERRNO_START_PJSIP+164) /* 171164 */ 472 /** 473 * @hideinitializer 474 * Error setting SSL cipher list. 475 */ 476 #define PJSIP_TLS_ECIPHER (PJSIP_ERRNO_START_PJSIP+165) /* 171165 */ 477 /** 478 * @hideinitializer 479 * Error creating SSL context. 480 */ 481 #define PJSIP_TLS_ECTX (PJSIP_ERRNO_START_PJSIP+166) /* 171166 */ 482 /** 483 * @hideinitializer 484 * Error creating SSL connection object. 485 */ 486 #define PJSIP_TLS_ESSLCONN (PJSIP_ERRNO_START_PJSIP+167) /* 171167 */ 487 /** 488 * @hideinitializer 489 * Unknown error when performing SSL connect(). 490 */ 491 #define PJSIP_TLS_ECONNECT (PJSIP_ERRNO_START_PJSIP+168) /* 171168 */ 492 /** 493 * @hideinitializer 494 * Unknown error when performing SSL accept(). 495 */ 496 #define PJSIP_TLS_EACCEPT (PJSIP_ERRNO_START_PJSIP+169) /* 171169 */ 497 /** 498 * @hideinitializer 499 * Unknown error when sending SSL data 500 */ 501 #define PJSIP_TLS_ESEND (PJSIP_ERRNO_START_PJSIP+170) /* 171170 */ 502 /** 503 * @hideinitializer 504 * Unknown error when reading SSL data 505 */ 506 #define PJSIP_TLS_EREAD (PJSIP_ERRNO_START_PJSIP+171) /* 171171 */ 507 /** 508 * @hideinitializer 509 * SSL negotiation has exceeded the maximum configured timeout. 510 */ 511 #define PJSIP_TLS_ETIMEDOUT (PJSIP_ERRNO_START_PJSIP+172) /* 171172 */ 512 /** 513 * @hideinitializer 514 * SSL certificate verification error. 515 */ 516 #define PJSIP_TLS_ECERTVERIF (PJSIP_ERRNO_START_PJSIP+173) /* 171173 */ 517 518 519 /** 520 * Get error message for the specified error code. Note that this 521 * function is only able to decode PJSIP specific error code. 522 * Application should use pj_strerror(), which should be able to 523 * decode all error codes belonging to all subsystems (e.g. pjlib, 524 * pjmedia, pjsip, etc). 525 * 526 * @param status The error code. 527 * @param buffer The buffer where to put the error message. 528 * @param bufsize Size of the buffer. 529 * 530 * @return The error message as NULL terminated string, 531 * wrapped with pj_str_t. 532 */ 533 PJ_DECL(pj_str_t) pjsip_strerror(pj_status_t status, 534 char *buffer, pj_size_t bufsize); 535 536 537 PJ_END_DECL 538 539 540 /** 541 * @} 542 */ 543 544 #endif /* __PJSIP_SIP_ERRNO_H__ */ 545 546