00001
00056 #ifndef P_CSCF_DLG_STATE_H
00057 #define P_CSCF_DLG_STATE_H
00058
00059 #include "../../sr_module.h"
00060 #include "mod.h"
00061 #include "../../locking.h"
00062 #include "../tm/dlg.h"
00063 #include "../tm/tm_load.h"
00064
00065 enum p_dialog_method {
00066 DLG_METHOD_OTHER=0,
00067 DLG_METHOD_INVITE=1,
00068 DLG_METHOD_SUBSCRIBE=2
00069 };
00070
00072 #define DLG_METHOD_MAX DLG_METHOD_SUBSCRIBE
00073
00074 enum p_dialog_state {
00075 DLG_STATE_UNKNOWN=0,
00076 DLG_STATE_INITIAL=1,
00077 DLG_STATE_EARLY=2,
00078 DLG_STATE_CONFIRMED=3,
00079 DLG_STATE_TERMINATED_ONE_SIDE=4,
00080 DLG_STATE_TERMINATED=5
00081 };
00082
00083 enum p_dialog_direction {
00084 DLG_MOBILE_ORIGINATING=0,
00085 DLG_MOBILE_TERMINATING=1,
00086 DLG_MOBILE_UNKNOWN=2
00087 };
00088
00089 typedef struct _p_dialog {
00090 unsigned int hash;
00091 str call_id;
00092 enum p_dialog_direction direction;
00093
00094 str host;
00095 unsigned short port;
00096 char transport;
00098 str *routes;
00099 unsigned short routes_cnt;
00100
00101 enum p_dialog_method method;
00102 str method_str;
00103 int first_cseq;
00104 int last_cseq;
00105 enum p_dialog_state state;
00106 time_t expires;
00107 time_t lr_session_expires;
00108 str refresher;
00109 unsigned char uac_supp_timer;
00111 unsigned char is_releasing;
00114 dlg_t *dialog_s;
00115 dlg_t *dialog_c;
00116
00117 struct _p_dialog *next,*prev;
00118 } p_dialog;
00119
00120 typedef struct {
00121 p_dialog *head,*tail;
00122 gen_lock_t *lock;
00123 } p_dialog_hash_slot;
00124
00125
00126 inline unsigned int get_p_dialog_hash(str call_id);
00127
00128 int p_dialogs_init(int hash_size);
00129
00130 void p_dialogs_destroy();
00131
00132 inline void d_lock(unsigned int hash);
00133 inline void d_unlock(unsigned int hash);
00134
00135
00136 p_dialog* new_p_dialog(str call_id,str host,int port, int transport);
00137 p_dialog* add_p_dialog(str call_id,str host,int port, int transport);
00138 int is_p_dialog(str call_id,str host,int port, int transport,enum p_dialog_direction *dir);
00139 int is_p_dialog_dir(str call_id,enum p_dialog_direction dir);
00140 p_dialog* get_p_dialog(str call_id,str host,int port, int transport,enum p_dialog_direction *dir);
00141 p_dialog* get_p_dialog_dir(str call_id,enum p_dialog_direction dir);
00142 p_dialog* get_p_dialog_dir_nolock(str call_id,enum p_dialog_direction dir);
00143 int terminate_p_dialog(p_dialog *d);
00144 void del_p_dialog(p_dialog *d);
00145 void free_p_dialog(p_dialog *d);
00146 void print_p_dialogs(int log_level);
00147
00148
00149
00150 int P_is_in_dialog(struct sip_msg* msg, char* str1, char* str2);
00151
00152 int P_save_dialog(struct sip_msg* msg, char* str1, char* str2);
00153
00154 int P_update_dialog(struct sip_msg* msg, char* str1, char* str2);
00155
00156 int P_drop_dialog(struct sip_msg* msg, char* str1, char* str2);
00157
00158 int P_drop_all_dialogs(str host,int port, int transport);
00159
00160 int P_follows_dialog_routes(struct sip_msg *msg,char *str1,char *str2);
00161
00162 int P_enforce_dialog_routes(struct sip_msg *msg,char *str1,char*str2);
00163
00164 int P_record_route(struct sip_msg *msg,char *str1,char *str2);
00165
00166 int P_check_session_expires(struct sip_msg* msg, char* str1, char* str2);
00167
00168 int P_422_session_expires(struct sip_msg* msg, char* str1, char* str2);
00169
00170 void dialog_timer(unsigned int ticks, void* param);
00171
00172 #endif