Browse Source

acc: new skip_cdr modparam to prevent cdr generation

This commit adds a new modparam called cdr_skip to acc module that allows
excluding certain calls from CDRs in Kamailio route logic.

Dialogs ended with chosen dlg_var set (no matter the value) won't generate
a CDR (both database and log) even though cdr_enable modparam is set.
Carlos Cruz 5 năm trước cách đây
mục cha
commit
7bedc58851

+ 10 - 0
src/modules/acc/acc_cdr.c

@@ -392,6 +392,16 @@ static int write_cdr( struct dlg_cell* dialog,
 		return -1;
 	}
 
+	/* Skip cdr if cdr_skip dlg_var exists */
+	if (cdr_skip.len > 0) {
+		str* nocdr_val = 0;
+		nocdr_val = dlgb.get_dlg_var( dialog, &cdr_skip);
+		if ( nocdr_val ){
+			LM_DBG( "cdr_skip dlg_var set, skip cdr!");
+			return 0;
+		}
+	}
+
 	ret = log_write_cdr(dialog, message);
 	ret |= db_write_cdr(dialog, message);
 	return ret;

+ 2 - 0
src/modules/acc/acc_mod.c

@@ -121,6 +121,7 @@ int cdr_start_on_confirmed = 0;
 int cdr_expired_dlg_enable = 0;
 static char* cdr_facility_str = 0;
 static char* cdr_log_extra_str = 0;
+str cdr_skip = {NULL, 0};
 
 str cdr_start_str = str_init("start_time");
 str cdr_end_str = str_init("end_time");
@@ -206,6 +207,7 @@ static param_export_t params[] = {
 	{"log_extra",            PARAM_STRING, &log_extra_str        },
 	/* cdr specific */
 	{"cdr_enable",           INT_PARAM, &cdr_enable                 },
+	{"cdr_skip",             PARAM_STR, &cdr_skip                   },
 	{"cdr_log_enable",         INT_PARAM, &cdr_log_enable           },
 	{"cdr_start_on_confirmed", INT_PARAM, &cdr_start_on_confirmed   },
 	{"cdr_facility",         PARAM_STRING, &cdr_facility_str           },

+ 1 - 0
src/modules/acc/acc_mod.h

@@ -53,6 +53,7 @@ extern int cdr_extra_nullable;
 extern int cdr_start_on_confirmed;
 extern int cdr_log_facility;
 extern int cdr_expired_dlg_enable;
+extern str cdr_skip;
 
 extern int db_flag;
 extern int db_missed_flag;

+ 17 - 0
src/modules/acc/doc/acc_admin.xml

@@ -1034,6 +1034,23 @@ modparam("acc", "db_insert_mode", 1)
 ...
 modparam("acc", "cdr_enable", 1)
 ...
+</programlisting>
+		</example>
+	</section>
+	<section id="acc.p.cdr_skip">
+		<title><varname>cdr_skip</varname> (string)</title>
+		<para>
+		Skip cdr generation for dialogs with this dlg_var set.
+		</para>
+		<para>
+		Default value is NULL.
+		</para>
+		<example>
+		<title>cdr_skip example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc", "cdr_skip", "nocdr")
+...
 </programlisting>
 		</example>
 	</section>