ser_error processing, ipv6-ization of TM, new TM callbacks;
[sip-router] / error.c
1 /*
2  * $Id$
3  *
4  */
5
6 #include "error.h"
7
8 /* current function's error; */
9 int ser_error=-1;
10 /* previous error */
11 int prev_ser_error=-1;
12
13 int err2reason_phrase( 
14         int ser_error,  /* current itnernal ser error */
15         int *sip_error,  /* the sip error code to which ser     
16                                             ser error will be turned */
17         char *phrase,    /* resulting error text */
18         int etl,                /* error text buffer length */
19         char *signature ) /* extra text to be appended */
20 {
21
22         char *error_txt;
23
24         switch( ser_error ) {
25                 case E_OUT_OF_MEM:
26                         error_txt="Excuse me I ran out of memory";
27                         *sip_error=500;
28                         break;
29                 case E_SEND:
30                         error_txt="Unfortunately error on sending to next hop occured";
31                         *sip_error=-ser_error;
32                         break;
33                 case E_BAD_ADDRESS:
34                         error_txt="Unresolveable destination";
35                         *sip_error=-ser_error;
36                         break;
37                 case E_BAD_REQ:
38                         error_txt="Bad Request";
39                         *sip_error=-ser_error;
40                         break;
41                 case E_BAD_URI:
42                         error_txt="Regretfuly, we were not able to process the URI";
43                         *sip_error=-ser_error;
44                         break;
45                 default:
46                         error_txt="I'm terribly sorry, server error occured";
47                         *sip_error=500;
48                         break;
49         }
50         return snprintf( phrase, etl, "%s (%d/%s)", error_txt, 
51                 -ser_error, signature );
52 }