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 #ifndef _DIALOG_DLG_CB_H_
00033 #define _DIALOG_DLG_CB_H_
00034
00035 #include "../../parser/msg_parser.h"
00036
00037 struct dlg_cell;
00038
00039 struct dlg_cb_params {
00040 struct sip_msg* req;
00041 struct sip_msg* rpl;
00042 unsigned int direction;
00043 void *dlg_data;
00044 void **param;
00045 };
00046
00047
00048 typedef void (dialog_cb) (struct dlg_cell* dlg, int type,
00049 struct dlg_cb_params * params);
00050
00051 typedef void (param_free_cb) (void *param);
00052
00053 typedef int (*register_dlgcb_f)(struct dlg_cell* dlg, int cb_types,
00054 dialog_cb f, void *param, param_free_cb ff);
00055
00056
00057 typedef int (*set_dlg_variable_f)( struct dlg_cell* dlg,
00058 str* key,
00059 str* val);
00060
00061 typedef str* (*get_dlg_variable_f)( struct dlg_cell* dlg,
00062 str* key);
00063
00064 #define DLGCB_LOADED (1<<0)
00065 #define DLGCB_CREATED (1<<1)
00066 #define DLGCB_FAILED (1<<2)
00067 #define DLGCB_CONFIRMED_NA (1<<3)
00068 #define DLGCB_CONFIRMED (1<<4)
00069 #define DLGCB_REQ_WITHIN (1<<5)
00070 #define DLGCB_TERMINATED (1<<6)
00071 #define DLGCB_EXPIRED (1<<7)
00072 #define DLGCB_EARLY (1<<8)
00073 #define DLGCB_RESPONSE_FWDED (1<<9)
00074 #define DLGCB_RESPONSE_WITHIN (1<<10)
00075 #define DLGCB_MI_CONTEXT (1<<11)
00076 #define DLGCB_RPC_CONTEXT (1<<12)
00077 #define DLGCB_DESTROY (1<<13)
00078 #define DLGCB_SPIRALED (1<<14)
00079 #define DLGCB_TERMINATED_CONFIRMED (1<<15)
00080
00081 struct dlg_callback {
00082 int types;
00083 dialog_cb* callback;
00084 void *param;
00085 param_free_cb* callback_param_free;
00086 struct dlg_callback* next;
00087 };
00088
00089
00090 struct dlg_head_cbl {
00091 struct dlg_callback *first;
00092 int types;
00093 };
00094
00095
00096 void destroy_dlg_callbacks(unsigned int type);
00097
00098 void destroy_dlg_callbacks_list(struct dlg_callback *cb);
00099
00100 int register_dlgcb( struct dlg_cell* dlg, int types, dialog_cb f, void *param, param_free_cb ff);
00101
00102 void run_create_callbacks(struct dlg_cell *dlg, struct sip_msg *msg);
00103
00104 void run_dlg_callbacks( int type ,
00105 struct dlg_cell *dlg,
00106 struct sip_msg *req,
00107 struct sip_msg *rpl,
00108 unsigned int dir,
00109 void *dlg_data);
00110
00111 void run_load_callbacks( void );
00112
00113
00119 static inline struct sip_msg *dlg_get_valid_msg(struct dlg_cb_params *cb_params)
00120 {
00121 struct sip_msg *msg;
00122
00123 if (cb_params == NULL) {
00124 LM_ERR("no dialog parameters given\n");
00125 return NULL;
00126 }
00127
00128 msg = cb_params->req;
00129 if (msg == NULL) {
00130 msg = cb_params->rpl;
00131 if (msg == NULL || msg == FAKED_REPLY) {
00132 return NULL;
00133 }
00134 }
00135
00136 return msg;
00137 };
00138
00139 #endif