Selaa lähdekoodia

acc, dialog: change cdr dialog duration

- CDR duration for timed out acknowledged dialogs is no longer left empty
lucian balanceanu 10 vuotta sitten
vanhempi
commit
d46f3f642f
3 muutettua tiedostoa jossa 26 lisäystä ja 1 poistoa
  1. 17 0
      modules/acc/acc_cdr.c
  2. 2 0
      modules/dialog/dlg_cb.h
  3. 7 1
      modules/dialog/dlg_handlers.c

+ 17 - 0
modules/acc/acc_cdr.c

@@ -692,6 +692,23 @@ static void cdr_on_expired( struct dlg_cell* dialog,
     }
 
     LM_DBG("dialog '%p' expired!\n", dialog);
+    /* compute duration for timed out acknowledged dialog */
+	if ( params && params->dlg_data ) {
+		if ( (void*)CONFIRMED_DIALOG_STATE == params->dlg_data) {
+			if( set_end_time( dialog) != 0)
+			{
+				LM_ERR( "failed to set end time!\n");
+				return;
+			}	
+			
+			if( set_duration( dialog) != 0)
+			{
+				LM_ERR( "failed to set duration!\n");
+				return;
+			}
+			
+		}
+	}
 
     if( cdr_expired_dlg_enable  && (write_cdr( dialog, 0) != 0))
     {

+ 2 - 0
modules/dialog/dlg_cb.h

@@ -58,6 +58,8 @@ typedef int (*set_dlg_variable_f)( struct dlg_cell* dlg,
 typedef str* (*get_dlg_variable_f)( struct dlg_cell* dlg,
                                     str* key);
 
+#define CONFIRMED_DIALOG_STATE 1
+
 #define DLGCB_LOADED          (1<<0)
 #define DLGCB_CREATED         (1<<1)
 #define DLGCB_FAILED          (1<<2)

+ 7 - 1
modules/dialog/dlg_handlers.c

@@ -1371,6 +1371,7 @@ void dlg_ontimeout(struct dlg_tl *tl)
 	dlg_cell_t *dlg;
 	int new_state, old_state, unref;
 	sip_msg_t *fmsg;
+	void* timeout_cb = 0;
 
 	/* get the dialog tl payload */
 	dlg = ((struct dlg_cell*)((char *)(tl) -
@@ -1413,6 +1414,11 @@ void dlg_ontimeout(struct dlg_tl *tl)
 	}
 
 	next_state_dlg( dlg, DLG_EVENT_REQBYE, &old_state, &new_state, &unref);
+    /* used for computing duration for timed out acknowledged dialog */
+	if (DLG_STATE_CONFIRMED == old_state) {
+		timeout_cb = (void *)CONFIRMED_DIALOG_STATE;
+	}	
+
 	dlg_run_event_route(dlg, NULL, old_state, new_state);
 
 	if (new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) {
@@ -1422,7 +1428,7 @@ void dlg_ontimeout(struct dlg_tl *tl)
 			dlg->tag[DLG_CALLEE_LEG].len, dlg->tag[DLG_CALLEE_LEG].s);
 
 		/* dialog timeout */
-		run_dlg_callbacks( DLGCB_EXPIRED, dlg, NULL, NULL, DLG_DIR_NONE, 0);
+		run_dlg_callbacks( DLGCB_EXPIRED, dlg, NULL, NULL, DLG_DIR_NONE, timeout_cb);
 
 		dlg_unref(dlg, unref+1);