00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _T_FUNCS_H
00042 #define _T_FUNCS_H
00043
00044 #include "defs.h"
00045
00046
00047 #include <errno.h>
00048 #include <netdb.h>
00049
00050 #include "../../mem/shm_mem.h"
00051 #include "../../parser/msg_parser.h"
00052 #include "../../globals.h"
00053 #include "../../udp_server.h"
00054 #include "../../msg_translator.h"
00055 #include "../../timer.h"
00056 #include "../../forward.h"
00057 #include "../../mem/mem.h"
00058 #include "../../md5utils.h"
00059 #include "../../ip_addr.h"
00060 #include "../../parser/parse_uri.h"
00061 #include "../../usr_avp.h"
00062 #include "../../atomic_ops.h"
00063
00064 #include "config.h"
00065 #include "lock.h"
00066 #include "timer.h"
00067 #include "sip_msg.h"
00068 #include "h_table.h"
00069 #include "ut.h"
00070
00071 struct s_table;
00072 struct timer;
00073 struct entry;
00074 struct cell;
00075
00076 extern int tm_error;
00077 extern struct msgid_var user_cell_set_flags;
00078 extern struct msgid_var user_cell_reset_flags;
00079
00080 extern int fr_inv_timer_avp_type;
00081 extern int_str fr_inv_timer_avp;
00082 extern int contacts_avp_type;
00083 extern int_str contacts_avp;
00084
00085
00086 #define FR_TIMER_AVP "callee_fr_timer"
00087 #define FR_INV_TIMER_AVP "callee_fr_inv_timer"
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifdef EXTRA_DEBUG
00100 int send_pr_buffer( struct retr_buf *rb,
00101 void *buf, int len, char* file, const char *function, int line );
00102 #define SEND_PR_BUFFER(_rb,_bf,_le ) \
00103 send_pr_buffer( (_rb), (_bf), (_le), __FILE__, __FUNCTION__, __LINE__ )
00104 #else
00105 int send_pr_buffer( struct retr_buf *rb, void *buf, int len);
00106 #define SEND_PR_BUFFER(_rb,_bf,_le ) \
00107 send_pr_buffer( (_rb), (_bf), (_le))
00108 #endif
00109
00110 #define SEND_BUFFER( _rb ) \
00111 SEND_PR_BUFFER( (_rb) , (_rb)->buffer , (_rb)->buffer_len )
00112
00113
00114
00115 #ifdef TM_DEL_UNREF
00116
00117 #define UNREF_FREE(_T_cell) \
00118 do{\
00119 if (atomic_dec_and_test(&(_T_cell)->ref_count)){ \
00120 unlink_timers((_T_cell)); \
00121 free_cell((_T_cell)); \
00122 }else \
00123 t_stats_delayed_free(); \
00124 }while(0)
00125
00126 #define UNREF_NOSTATS(_T_cell) \
00127 do{\
00128 if (atomic_dec_and_test(&(_T_cell)->ref_count)){ \
00129 unlink_timers((_T_cell)); \
00130 free_cell((_T_cell)); \
00131 }\
00132 }while(0)
00133
00134 #define UNREF_UNSAFE(_T_cell) UNREF_NOSTATS(_T_cell)
00135
00136 #define UNREF(_T_cell) UNREF_UNSAFE(_T_cell);
00137 #define REF(_T_cell) (atomic_inc(&(_T_cell)->ref_count))
00138 #define REF_UNSAFE(_T_cell) REF(_T_cell)
00139 #define INIT_REF(_T_cell, v) atomic_set(&(_T_cell)->ref_count, v)
00140
00141 #else
00142
00143 #define UNREF_UNSAFE(_T_cell) ((_T_cell)->ref_count--)
00144 #define UNREF(_T_cell) do{ \
00145 LOCK_HASH( (_T_cell)->hash_index ); \
00146 UNREF_UNSAFE(_T_cell); \
00147 UNLOCK_HASH( (_T_cell)->hash_index ); }while(0)
00148 #define REF_UNSAFE(_T_cell) ((_T_cell)->ref_count++)
00149 #define INIT_REF_UNSAFE(_T_cell) ((_T_cell)->ref_count=1)
00150 #define IS_REFFED_UNSAFE(_T_cell) ((_T_cell)->ref_count!=0)
00151
00152 #endif
00153
00154
00155
00156 int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
00157 char *contacts_avp_param);
00158
00159
00160 typedef void (*unref_cell_f)(struct cell *t);
00161 void unref_cell(struct cell *t);
00162
00163
00164
00165 int fr_avp2timer(unsigned int* timer);
00166 int fr_inv_avp2timer(unsigned int* timer);
00167
00168
00169 #ifdef TIMER_DEBUG
00170 #define start_retr(rb) \
00171 _set_fr_retr((rb), \
00172 ((rb)->dst.proto==PROTO_UDP) ? RT_T1_TIMEOUT_MS(rb) : \
00173 (unsigned)(-1), \
00174 __FILE__, __FUNCTION__, __LINE__)
00175
00176 #define force_retr(rb) \
00177 _set_fr_retr((rb), RT_T1_TIMEOUT_MS(rb), __FILE__, __FUNCTION__, __LINE__)
00178
00179 #else
00180 #define start_retr(rb) \
00181 _set_fr_retr((rb), \
00182 ((rb)->dst.proto==PROTO_UDP) ? RT_T1_TIMEOUT_MS(rb) : \
00183 (unsigned)(-1))
00184
00185 #define force_retr(rb) \
00186 _set_fr_retr((rb), RT_T1_TIMEOUT_MS(rb))
00187
00188 #endif
00189
00190
00191
00192
00193 void tm_shutdown(void);
00194
00195
00196
00197
00198
00199
00200 int t_add_transaction( struct sip_msg* p_msg );
00201
00202
00203
00204 int t_release_transaction( struct cell *trans );
00205
00206
00207 int get_ip_and_port_from_uri( str* uri , unsigned int *param_ip,
00208 unsigned int *param_port);
00209
00210
00211 void put_on_wait( struct cell *Trans );
00212
00213
00214 int t_relay_to( struct sip_msg *p_msg ,
00215 struct proxy_l *proxy, int proto, int replicate ) ;
00216
00217 int kill_transaction( struct cell *trans, int error );
00218 int kill_transaction_unsafe( struct cell *trans, int error );
00219 #endif
00220