Merge branch 'master' into treimann/acc-cdr
[sip-router] / modules_k / dialog / dialog.c
index d17fdb1..d31135a 100644 (file)
@@ -104,6 +104,7 @@ static char* profiles_wv_s = NULL;
 static char* profiles_nv_s = NULL;
 str dlg_extra_hdrs = {NULL,0};
 static int db_fetch_rows = 200;
+int initial_cbs_inscript = 1;
 
 str dlg_bridge_controller = {"sip:controller@kamailio.org", 27};
 
@@ -241,6 +242,7 @@ static param_export_t mod_params[]={
        { "profiles_no_value",     STR_PARAM, &profiles_nv_s            },
        { "bridge_controller",     STR_PARAM, &dlg_bridge_controller.s  },
        { "ruri_pvar",             STR_PARAM, &ruri_pvar_param.s        },
+       { "initial_cbs_inscript",  INT_PARAM, &initial_cbs_inscript     },
        { 0,0,0 }
 };
 
@@ -372,6 +374,8 @@ int load_dlg( struct dlg_binds *dlgb )
 {
        dlgb->register_dlgcb = register_dlgcb;
        dlgb->terminate_dlg = dlg_bye_all;
+       dlgb->set_dlg_var = set_dlg_variable;
+       dlgb->get_dlg_var = get_dlg_variable;
        return 1;
 }
 
@@ -502,6 +506,11 @@ static int mod_init(void)
                return -1;
        }
 
+       if (initial_cbs_inscript != 0 && initial_cbs_inscript != 1) {
+               LM_ERR("invalid parameter for running initial callbacks in-script (must be either 0 or 1)\n");
+               return -1;
+       }
+
        /* update the len of the extra headers */
        if (dlg_extra_hdrs.s)
                dlg_extra_hdrs.len = strlen(dlg_extra_hdrs.s);
@@ -574,6 +583,11 @@ static int mod_init(void)
                return -1;
        }
 
+       if (register_script_cb( spiral_detect_reset, POST_SCRIPT_CB|REQUEST_CB,0)<0) {
+               LM_ERR("cannot register req pre-script spiral detection reset callback\n");
+               return -1;
+       }
+
        if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
                LM_ERR("failed to register timer \n");
                return -1;
@@ -901,7 +915,7 @@ static int w_dlg_manage(struct sip_msg *msg, char *s1, char *s2)
                dlg_onroute(msg, NULL, NULL);
                seq_match_mode = backup_mode;
        } else {
-               if(dlg_new_dialog(msg, 0)!=0)
+               if(dlg_new_dialog(msg, 0, initial_cbs_inscript)!=0)
                        return -1;
        }
        return 1;
@@ -1212,7 +1226,7 @@ static inline void internal_rpc_print_dlg(rpc_t *rpc, void *c, struct dlg_cell *
        if (with_context) {
                rpc_cb.rpc = rpc;
                rpc_cb.c = c;
-               run_dlg_callbacks( DLGCB_RPC_CONTEXT, dlg, NULL, DLG_DIR_NONE, (void *)&rpc_cb);
+               run_dlg_callbacks( DLGCB_RPC_CONTEXT, dlg, NULL, NULL, DLG_DIR_NONE, (void *)&rpc_cb);
        }
 }