~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjsip/src/pjsip/sip_errno.c

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: sip_errno.c 3553 2011-05-05 06:14:19Z nanang $ */
 
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
#include <pjsip/sip_errno.h>
 
21
#include <pjsip/sip_msg.h>
 
22
#include <pj/string.h>
 
23
#include <pj/errno.h>
 
24
 
 
25
/* PJSIP's own error codes/messages 
 
26
 * MUST KEEP THIS ARRAY SORTED!!
 
27
 */
 
28
 
 
29
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
 
30
 
 
31
static const struct 
 
32
{
 
33
    int code;
 
34
    const char *msg;
 
35
} err_str[] = 
 
36
{
 
37
    /* Generic SIP errors */
 
38
    PJ_BUILD_ERR( PJSIP_EBUSY,          "Object is busy" ),
 
39
    PJ_BUILD_ERR( PJSIP_ETYPEEXISTS ,   "Object with the same type exists" ),
 
40
    PJ_BUILD_ERR( PJSIP_ESHUTDOWN,      "SIP stack shutting down" ),
 
41
    PJ_BUILD_ERR( PJSIP_ENOTINITIALIZED,"SIP object is not initialized." ),
 
42
    PJ_BUILD_ERR( PJSIP_ENOROUTESET,    "Missing route set (for tel: URI)" ),
 
43
 
 
44
    /* Messaging errors */
 
45
    PJ_BUILD_ERR( PJSIP_EINVALIDMSG,    "Invalid message/syntax error" ),
 
46
    PJ_BUILD_ERR( PJSIP_ENOTREQUESTMSG, "Expecting request message"),
 
47
    PJ_BUILD_ERR( PJSIP_ENOTRESPONSEMSG,"Expecting response message"),
 
48
    PJ_BUILD_ERR( PJSIP_EMSGTOOLONG,    "Message too long" ),
 
49
    PJ_BUILD_ERR( PJSIP_EPARTIALMSG,    "Partial message" ),
 
50
 
 
51
    PJ_BUILD_ERR( PJSIP_EINVALIDSTATUS, "Invalid/unexpected SIP status code"),
 
52
 
 
53
    PJ_BUILD_ERR( PJSIP_EINVALIDURI,    "Invalid URI" ),
 
54
    PJ_BUILD_ERR( PJSIP_EINVALIDSCHEME, "Invalid URI scheme" ),
 
55
    PJ_BUILD_ERR( PJSIP_EMISSINGREQURI, "Missing Request-URI" ),
 
56
    PJ_BUILD_ERR( PJSIP_EINVALIDREQURI, "Invalid Request URI" ),
 
57
    PJ_BUILD_ERR( PJSIP_EURITOOLONG,    "URI is too long" ), 
 
58
 
 
59
    PJ_BUILD_ERR( PJSIP_EMISSINGHDR,    "Missing required header(s)" ),
 
60
    PJ_BUILD_ERR( PJSIP_EINVALIDHDR,    "Invalid header field"),
 
61
    PJ_BUILD_ERR( PJSIP_EINVALIDVIA,    "Invalid Via header" ),
 
62
    PJ_BUILD_ERR( PJSIP_EMULTIPLEVIA,   "Multiple Via headers in response" ),
 
63
 
 
64
    PJ_BUILD_ERR( PJSIP_EMISSINGBODY,   "Missing message body" ),
 
65
    PJ_BUILD_ERR( PJSIP_EINVALIDMETHOD, "Invalid/unexpected method" ),
 
66
 
 
67
    /* Transport errors */
 
68
    PJ_BUILD_ERR( PJSIP_EUNSUPTRANSPORT,"Unsupported transport"),
 
69
    PJ_BUILD_ERR( PJSIP_EPENDINGTX,     "Transmit buffer already pending"),
 
70
    PJ_BUILD_ERR( PJSIP_ERXOVERFLOW,    "Rx buffer overflow"),
 
71
    PJ_BUILD_ERR( PJSIP_EBUFDESTROYED,  "Buffer destroyed"),
 
72
    PJ_BUILD_ERR( PJSIP_ETPNOTSUITABLE, "Unsuitable transport selected"),
 
73
    PJ_BUILD_ERR( PJSIP_ETPNOTAVAIL,    "Transport not available for use"),
 
74
 
 
75
    /* Transaction errors */
 
76
    PJ_BUILD_ERR( PJSIP_ETSXDESTROYED,  "Transaction has been destroyed"),
 
77
    PJ_BUILD_ERR( PJSIP_ENOTSX,         "No transaction is associated with the object "
 
78
                                        "(expecting stateful processing)" ),
 
79
 
 
80
    /* URI comparison status */
 
81
    PJ_BUILD_ERR( PJSIP_ECMPSCHEME,     "URI scheme mismatch" ),
 
82
    PJ_BUILD_ERR( PJSIP_ECMPUSER,       "URI user part mismatch" ),
 
83
    PJ_BUILD_ERR( PJSIP_ECMPPASSWD,     "URI password part mismatch" ),
 
84
    PJ_BUILD_ERR( PJSIP_ECMPHOST,       "URI host part mismatch" ),
 
85
    PJ_BUILD_ERR( PJSIP_ECMPPORT,       "URI port mismatch" ),
 
86
    PJ_BUILD_ERR( PJSIP_ECMPTRANSPORTPRM,"URI transport param mismatch" ),
 
87
    PJ_BUILD_ERR( PJSIP_ECMPTTLPARAM,   "URI ttl param mismatch" ),
 
88
    PJ_BUILD_ERR( PJSIP_ECMPUSERPARAM,  "URI user param mismatch" ),
 
89
    PJ_BUILD_ERR( PJSIP_ECMPMETHODPARAM,"URI method param mismatch" ),
 
90
    PJ_BUILD_ERR( PJSIP_ECMPMADDRPARAM, "URI maddr param mismatch" ),
 
91
    PJ_BUILD_ERR( PJSIP_ECMPOTHERPARAM, "URI other param mismatch" ),
 
92
    PJ_BUILD_ERR( PJSIP_ECMPHEADERPARAM,"URI header parameter mismatch" ),
 
93
 
 
94
    /* Authentication. */
 
95
    PJ_BUILD_ERR( PJSIP_EFAILEDCREDENTIAL, "Credential failed to authenticate"),
 
96
    PJ_BUILD_ERR( PJSIP_ENOCREDENTIAL,     "No suitable credential"),
 
97
    PJ_BUILD_ERR( PJSIP_EINVALIDALGORITHM, "Invalid/unsupported digest algorithm" ),
 
98
    PJ_BUILD_ERR( PJSIP_EINVALIDQOP,       "Invalid/unsupported digest qop" ),
 
99
    PJ_BUILD_ERR( PJSIP_EINVALIDAUTHSCHEME,"Unsupported authentication scheme" ),
 
100
    PJ_BUILD_ERR( PJSIP_EAUTHNOPREVCHAL,   "No previous challenge" ),
 
101
    PJ_BUILD_ERR( PJSIP_EAUTHNOAUTH,       "No suitable authorization header" ),
 
102
    PJ_BUILD_ERR( PJSIP_EAUTHACCNOTFOUND,  "Account or credential not found" ),
 
103
    PJ_BUILD_ERR( PJSIP_EAUTHACCDISABLED,  "Account or credential is disabled" ),
 
104
    PJ_BUILD_ERR( PJSIP_EAUTHINVALIDREALM, "Invalid authorization realm"),
 
105
    PJ_BUILD_ERR( PJSIP_EAUTHINVALIDDIGEST,"Invalid authorization digest" ),
 
106
    PJ_BUILD_ERR( PJSIP_EAUTHSTALECOUNT,   "Maximum number of stale retries exceeded"),
 
107
    PJ_BUILD_ERR( PJSIP_EAUTHINNONCE,      "Invalid nonce value in authentication challenge"),
 
108
    PJ_BUILD_ERR( PJSIP_EAUTHINAKACRED,    "Invalid AKA credential"),
 
109
    PJ_BUILD_ERR( PJSIP_EAUTHNOCHAL,       "No challenge is found"),
 
110
 
 
111
    /* UA/dialog layer. */
 
112
    PJ_BUILD_ERR( PJSIP_EMISSINGTAG,    "Missing From/To tag parameter" ),
 
113
    PJ_BUILD_ERR( PJSIP_ENOTREFER,      "Expecting REFER request") ,
 
114
    PJ_BUILD_ERR( PJSIP_ENOREFERSESSION,"Not associated with REFER subscription"),
 
115
 
 
116
    /* Invite session. */
 
117
    PJ_BUILD_ERR( PJSIP_ESESSIONTERMINATED, "INVITE session already terminated" ),
 
118
    PJ_BUILD_ERR( PJSIP_ESESSIONSTATE,      "Invalid INVITE session state" ),
 
119
    PJ_BUILD_ERR( PJSIP_ESESSIONINSECURE,   "Require secure session/transport"),
 
120
 
 
121
    /* SSL errors */
 
122
    PJ_BUILD_ERR( PJSIP_TLS_EUNKNOWN,   "Unknown TLS error" ),
 
123
    PJ_BUILD_ERR( PJSIP_TLS_EINVMETHOD, "Invalid SSL protocol method" ),
 
124
    PJ_BUILD_ERR( PJSIP_TLS_ECACERT,    "Error loading/verifying SSL CA list file"),
 
125
    PJ_BUILD_ERR( PJSIP_TLS_ECERTFILE,  "Error loading SSL certificate chain file"),
 
126
    PJ_BUILD_ERR( PJSIP_TLS_EKEYFILE,   "Error adding private key from SSL certificate file"),
 
127
    PJ_BUILD_ERR( PJSIP_TLS_ECIPHER,    "Error setting SSL cipher list"),
 
128
    PJ_BUILD_ERR( PJSIP_TLS_ECTX,       "Error creating SSL context"),
 
129
    PJ_BUILD_ERR( PJSIP_TLS_ESSLCONN,   "Error creating SSL connection object"),
 
130
    PJ_BUILD_ERR( PJSIP_TLS_ECONNECT,   "Unknown error when performing SSL connect()"),
 
131
    PJ_BUILD_ERR( PJSIP_TLS_EACCEPT,    "Unknown error when performing SSL accept()"),
 
132
    PJ_BUILD_ERR( PJSIP_TLS_ESEND,      "Unknown error when sending SSL data"),
 
133
    PJ_BUILD_ERR( PJSIP_TLS_EREAD,      "Unknown error when reading SSL data"),
 
134
    PJ_BUILD_ERR( PJSIP_TLS_ETIMEDOUT,  "SSL negotiation has timed out"),
 
135
    PJ_BUILD_ERR( PJSIP_TLS_ECERTVERIF, "SSL certificate verification error"),
 
136
};
 
137
 
 
138
 
 
139
#endif  /* PJ_HAS_ERROR_STRING */
 
140
 
 
141
 
 
142
/*
 
143
 * pjsip_strerror()
 
144
 */
 
145
PJ_DEF(pj_str_t) pjsip_strerror( pj_status_t statcode, 
 
146
                                 char *buf, pj_size_t bufsize )
 
147
{
 
148
    pj_str_t errstr;
 
149
 
 
150
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
 
151
 
 
152
    if (statcode >= PJSIP_ERRNO_START && statcode < PJSIP_ERRNO_START+800) 
 
153
    {
 
154
        /* Status code. */
 
155
        const pj_str_t *status_text = 
 
156
            pjsip_get_status_text(PJSIP_ERRNO_TO_SIP_STATUS(statcode));
 
157
 
 
158
        errstr.ptr = buf;
 
159
        pj_strncpy_with_null(&errstr, status_text, bufsize);
 
160
        return errstr;
 
161
    }
 
162
    else if (statcode >= PJSIP_ERRNO_START_PJSIP && 
 
163
             statcode < PJSIP_ERRNO_START_PJSIP + 1000)
 
164
    {
 
165
        /* Find the error in the table.
 
166
         * Use binary search!
 
167
         */
 
168
        int first = 0;
 
169
        int n = PJ_ARRAY_SIZE(err_str);
 
170
 
 
171
        while (n > 0) {
 
172
            int half = n/2;
 
173
            int mid = first + half;
 
174
 
 
175
            if (err_str[mid].code < statcode) {
 
176
                first = mid+1;
 
177
                n -= (half+1);
 
178
            } else if (err_str[mid].code > statcode) {
 
179
                n = half;
 
180
            } else {
 
181
                first = mid;
 
182
                break;
 
183
            }
 
184
        }
 
185
 
 
186
 
 
187
        if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) {
 
188
            pj_str_t msg;
 
189
            
 
190
            msg.ptr = (char*)err_str[first].msg;
 
191
            msg.slen = pj_ansi_strlen(err_str[first].msg);
 
192
 
 
193
            errstr.ptr = buf;
 
194
            pj_strncpy_with_null(&errstr, &msg, bufsize);
 
195
            return errstr;
 
196
 
 
197
        } 
 
198
    }
 
199
 
 
200
#endif  /* PJ_HAS_ERROR_STRING */
 
201
 
 
202
    /* Error not found. */
 
203
    errstr.ptr = buf;
 
204
    errstr.slen = pj_ansi_snprintf(buf, bufsize, 
 
205
                                   "Unknown pjsip error %d",
 
206
                                   statcode);
 
207
 
 
208
    return errstr;
 
209
 
 
210
}
 
211