h_table.h
Go to the documentation of this file.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
00042
00043 #ifndef _H_TABLE_H
00044 #define _H_TABLE_H
00045
00046 #include <stdio.h>
00047 #include <stdlib.h>
00048
00049 #include "../../parser/msg_parser.h"
00050 #include "../../proxy.h"
00051 #include "../../md5utils.h"
00052 #include "../../usr_avp.h"
00053 #include "config.h"
00054
00055 struct s_table;
00056 struct entry;
00057 struct cell;
00058 struct timer;
00059 struct retr_buf;
00060
00061 #include "../../mem/shm_mem.h"
00062 #include "lock.h"
00063 #include "sip_msg.h"
00064 #include "t_reply.h"
00065 #include "t_hooks.h"
00066 #include "timer.h"
00067
00068 #define LOCK_HASH(_h) lock_hash((_h))
00069 #define UNLOCK_HASH(_h) unlock_hash((_h))
00070
00071 void lock_hash(int i);
00072 void unlock_hash(int i);
00073
00074
00075 #define NO_CANCEL ( (char*) 0 )
00076 #define EXTERNAL_CANCEL ( (char*) -1)
00077
00078 #define TYPE_LOCAL_CANCEL -1
00079 #define TYPE_REQUEST 0
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 enum kill_reason { REQ_FWDED=1, REQ_RPLD=2, REQ_RLSD=4, REQ_EXIST=8 };
00099
00100 typedef void (*setkr_f)(enum kill_reason mykr);
00101
00102 typedef struct retr_buf
00103 {
00104 int activ_type;
00105
00106
00107
00108 str buffer;
00109
00110 struct dest_info dst;
00111
00112
00113 struct timer_link retr_timer;
00114 struct timer_link fr_timer;
00115 enum lists retr_list;
00116
00117
00118 struct cell* my_T;
00119 unsigned int branch;
00120 } retr_buf_type;
00121
00122
00123
00124
00125 typedef struct ua_server
00126 {
00127 struct sip_msg *request;
00128 char *end_request;
00129 struct retr_buf response;
00130 unsigned int status;
00131
00132
00133
00134 str local_totag;
00135 }ua_server_type;
00136
00137
00138
00139
00140 typedef struct ua_client
00141 {
00142 struct retr_buf request;
00143 struct proxy_l *proxy;
00144
00145
00146
00147
00148
00149 struct retr_buf local_cancel;
00150
00151
00152 str uri;
00153
00154 str path_vec;
00155
00156 unsigned int added_rr;
00157
00158 struct sip_msg *reply;
00159
00160 short last_received;
00161
00162 short flags;
00163
00164 int br_flags;
00165 }ua_client_type;
00166
00167
00168 struct totag_elem {
00169 str tag;
00170 short acked;
00171 struct totag_elem *next;
00172 };
00173
00174
00175
00176
00177
00178 #define T_IS_INVITE_FLAG (1<<0)
00179 #define T_IS_LOCAL_FLAG (1<<1)
00180 #define T_WAS_CANCELLED_FLAG (1<<3)
00181
00182 #define T_HOPBYHOP_CANCEL_FLAG (1<<4)
00183 #define T_NO_AUTOACK_FLAG (1<<5)
00184 #define T_PASS_PROVISIONAL_FLAG (1<<6)
00185 #define T_NO_DNS_FAILOVER_FLAG (1<<7)
00186 #define T_NO_NEW_BRANCHES_FLAG (1<<8)
00187 #define T_BLIND_UAC (1<<9)
00188
00189
00190 #define T_UAC_TO_CANCEL_FLAG (1<<0)
00191 #define T_UAC_HAS_RECV_REPLY (1<<1)
00192
00193
00194
00195
00196
00197 typedef struct cell
00198 {
00199
00200 struct cell* next_cell;
00201 struct cell* prev_cell;
00202 unsigned int hash_index;
00203 unsigned int label;
00204 unsigned int flags;
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 volatile unsigned int ref_count;
00217
00218
00219
00220
00221
00222
00223
00224
00225 str from, callid, cseq_n, to;
00226
00227
00228
00229
00230
00231
00232 str method;
00233
00234 struct tmcb_head_list tmcb_hl;
00235
00236 struct timer_link wait_tl;
00237 struct timer_link dele_tl;
00238
00239 int first_branch;
00240
00241 int nr_of_outgoings;
00242 int relayed_reply_branch;
00243
00244 struct ua_server uas;
00245 struct ua_client uac[ MAX_BRANCHES ];
00246
00247 ser_lock_t reply_mutex;
00248
00249 unsigned int on_negative;
00250 unsigned int on_reply;
00251 unsigned int on_branch;
00252
00253 char md5[MD5_LEN];
00254
00255 #ifdef EXTRA_DEBUG
00256 short damocles;
00257 #endif
00258
00259
00260
00261
00262 struct totag_elem *fwded_totags;
00263
00264 struct usr_avp *user_avps;
00265
00266 void *dialog_ctx;
00267 } cell_type;
00268
00269
00270
00271
00272 typedef struct entry
00273 {
00274 struct cell* first_cell;
00275 struct cell* last_cell;
00276
00277 unsigned int next_label;
00278
00279 ser_lock_t mutex;
00280 unsigned long acc_entries;
00281 unsigned long cur_entries;
00282 }entry_type;
00283
00284
00285
00286
00287 struct s_table
00288 {
00289
00290 struct entry entrys[ TM_TABLE_ENTRIES ];
00291 };
00292
00293
00294 #define list_entry(ptr, type, member) \
00295 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
00296
00297 #define get_retr_timer_payload(_tl_) \
00298 list_entry( _tl_, struct retr_buf, retr_timer)
00299 #define get_fr_timer_payload(_tl_) \
00300 list_entry( _tl_, struct retr_buf, fr_timer)
00301 #define get_wait_timer_payload(_tl_) \
00302 list_entry( _tl_, struct cell, wait_tl)
00303 #define get_dele_timer_payload(_tl_) \
00304 list_entry( _tl_, struct cell, dele_tl)
00305
00306 #define get_T_from_reply_rb(_rb_) \
00307 list_entry( list_entry( _rb_, (struct ua_server), response),\
00308 struct cell, uas)
00309 #define get_T_from_request_rb(_rb_, _br_) \
00310 list_entry( list_entry( (rb_, (struct ua_client), request) - \
00311 (_br_)*sizeof(struct retr_buf), struct cell, uas)
00312 #define get_T_from_cancel_rb(_rb_, _br_) \
00313 list_entry( list_entry( (rb_, (struct ua_client), local_cancel) - \
00314 (_br_)*sizeof(struct retr_buf), struct cell, uas)
00315
00316 #define is_invite(_t_) ((_t_)->flags&T_IS_INVITE_FLAG)
00317 #define is_local(_t_) ((_t_)->flags&T_IS_LOCAL_FLAG)
00318 #define was_cancelled(_t_) ((_t_)->flags&T_WAS_CANCELLED_FLAG)
00319 #define is_hopbyhop_cancel(_t_) ((_t_)->flags&T_HOPBYHOP_CANCEL_FLAG)
00320 #define no_autoack(_t_) ((_t_)->flags&T_NO_AUTOACK_FLAG)
00321 #define pass_provisional(_t_) ((_t_)->flags&T_PASS_PROVISIONAL_FLAG)
00322 #define no_new_branches(_t_) ((_t_)->flags&T_NO_NEW_BRANCHES_FLAG)
00323
00324
00325 extern int syn_branch;
00326
00327
00328 void reset_kr(void);
00329 void set_kr( enum kill_reason kr );
00330 enum kill_reason get_kr(void);
00331
00332 struct s_table* get_tm_table(void);
00333 struct s_table* init_hash_table(void);
00334 void free_hash_table(void);
00335 void free_cell( struct cell* dead_cell );
00336 struct cell* build_cell( struct sip_msg* p_msg );
00337 void remove_from_hash_table_unsafe( struct cell * p_cell);
00338 #ifdef OBSOLETED
00339 void insert_into_hash_table( struct cell * p_cell, unsigned int _hash);
00340 #endif
00341 void insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash );
00342
00343 unsigned int transaction_count(void);
00344
00345
00346 int unixsock_hash(str* msg);
00347
00348 #endif
00349
00350