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
00034 #ifndef DLG_H
00035 #define DLG_H
00036
00037
00038 #include <stdio.h>
00039 #include "../../str.h"
00040 #include "../../ip_addr.h"
00041 #include "../../parser/parse_rr.h"
00042 #include "../../parser/msg_parser.h"
00043
00044
00045
00046
00047
00048 #ifdef DIALOG_CALLBACKS
00049 #include "t_hooks.h"
00050 #include "h_table.h"
00051
00052 #define DLG_CB_UAC 30
00053 #define DLG_CB_UAS 31
00054
00055 #endif
00056
00057
00058
00059
00060
00061 typedef struct dlg_seq {
00062 unsigned int value;
00063 unsigned char is_set;
00064 } dlg_seq_t;
00065
00066
00067
00068
00069
00070 typedef enum dlg_state {
00071 DLG_NEW = 0,
00072 DLG_EARLY,
00073 DLG_CONFIRMED,
00074 DLG_DESTROYED
00075 } dlg_state_t;
00076
00077
00078
00079
00080
00081 typedef struct dlg_id {
00082 str call_id;
00083 str rem_tag;
00084 str loc_tag;
00085 } dlg_id_t;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 typedef struct dlg_hooks {
00097 str ru;
00098 str nh;
00099 str* request_uri;
00100 str* next_hop;
00101 rr_t* first_route;
00102 str* last_route;
00103 } dlg_hooks_t;
00104
00105
00106
00107
00108
00109 typedef struct dlg {
00110 dlg_id_t id;
00111 dlg_seq_t loc_seq;
00112 dlg_seq_t rem_seq;
00113 str loc_uri;
00114 str rem_uri;
00115 str rem_target;
00116 str dst_uri;
00117 str loc_dname;
00118 str rem_dname;
00119 unsigned char secure;
00120 dlg_state_t state;
00121 rr_t* route_set;
00122 dlg_hooks_t hooks;
00123
00124
00125
00126 struct socket_info* send_sock;
00127 #ifdef DIALOG_CALLBACKS
00128 struct tmcb_head_list dlg_callbacks;
00129 #endif
00130 } dlg_t;
00131
00132 typedef enum {
00133 IS_TARGET_REFRESH,
00134 IS_NOT_TARGET_REFRESH,
00135 TARGET_REFRESH_UNKNOWN
00136 } target_refresh_t;
00137
00138
00139
00140
00141 int new_dlg_uac(str* _cid, str* _ltag, unsigned int _lseq, str* _luri, str* _ruri, dlg_t** _d);
00142 typedef int (*new_dlg_uac_f)(str* _cid, str* _ltag, unsigned int _lseq, str* _luri, str* _ruri, dlg_t** _d);
00143
00144
00148 int dlg_add_extra(dlg_t* _d, str* _ldname, str* _rdname);
00149 typedef int (*dlg_add_extra_f)(dlg_t* _d, str* _ldname, str* _rdname);
00150
00151
00152
00153
00154
00155 int dlg_response_uac(dlg_t* _d, struct sip_msg* _m, target_refresh_t is_target_refresh);
00156 typedef int (*dlg_response_uac_f)(dlg_t* _d, struct sip_msg* _m, target_refresh_t is_target_refresh);
00157
00158
00159
00160
00161 int new_dlg_uas(struct sip_msg* _req, int _code, dlg_t** _d);
00162 typedef int (*new_dlg_uas_f)(struct sip_msg* _req, int _code, dlg_t** _d);
00163
00164
00165
00166
00167 int update_dlg_uas(dlg_t *_d, int _code, str* _tag);
00168 typedef int (*update_dlg_uas_f)(dlg_t *_d, int _code, str* _tag);
00169
00170
00171
00172
00173 int dlg_request_uas(dlg_t* _d, struct sip_msg* _m, target_refresh_t is_target_request);
00174 typedef int (*dlg_request_uas_f)(dlg_t* _d, struct sip_msg* _m, target_refresh_t is_target_request);
00175
00176
00177
00178
00179
00180 void free_dlg(dlg_t* _d);
00181 typedef void (*free_dlg_f)(dlg_t* _d);
00182
00183
00184
00185
00186
00187 void print_dlg(FILE* out, dlg_t* _d);
00188 typedef void (*print_dlg_f)(FILE* out, dlg_t* _d);
00189
00190
00191
00192
00193
00194 int calculate_routeset_length(dlg_t* _d);
00195
00196
00197
00198
00199
00200
00201 char* print_routeset(char* buf, dlg_t* _d);
00202
00203
00204
00205
00206
00207 int w_calculate_hooks(dlg_t* _d);
00208 typedef int (*calculate_hooks_f)(dlg_t* _d);
00209
00210
00211
00212
00213 int set_dlg_target(dlg_t* _d, str* _ruri, str* _duri);
00214 typedef int (*set_dlg_target_f)(dlg_t* _d, str* _ruri, str* _duri);
00215
00216 #ifdef DIALOG_CALLBACKS
00217
00218
00219
00220
00221
00222
00223
00224 typedef void (dialog_cb) (int type, dlg_t* dlg, struct sip_msg* msg);
00225
00226
00227
00228
00229 int register_new_dlg_cb(int types, dialog_cb f, void* param);
00230
00231 int register_dlg_tmcb(int type, dlg_t* dlg, transaction_cb f, void* param);
00232 void run_trans_dlg_callbacks(dlg_t* dlg, struct cell* trans,
00233 struct retr_buf* rbuf);
00234
00235 void destroy_new_dlg_cbs(void);
00236
00237 typedef int (*register_new_dlg_cb_f)(int, dialog_cb, void*);
00238 typedef int (*register_dlg_tmcb_f)(int, dlg_t*, transaction_cb, void*);
00239 #endif
00240
00241
00242 #endif