Browse code

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 authored on 08/06/2020 09:02:10 • Henning Westerholt committed on 11/06/2020 08:42:12
Showing 4 changed files
... ...
@@ -392,6 +392,16 @@ static int write_cdr( struct dlg_cell* dialog,
392 392
 		return -1;
393 393
 	}
394 394
 
395
+	/* Skip cdr if cdr_skip dlg_var exists */
396
+	if (cdr_skip.len > 0) {
397
+		str* nocdr_val = 0;
398
+		nocdr_val = dlgb.get_dlg_var( dialog, &cdr_skip);
399
+		if ( nocdr_val ){
400
+			LM_DBG( "cdr_skip dlg_var set, skip cdr!");
401
+			return 0;
402
+		}
403
+	}
404
+
395 405
 	ret = log_write_cdr(dialog, message);
396 406
 	ret |= db_write_cdr(dialog, message);
397 407
 	return ret;
... ...
@@ -121,6 +121,7 @@ int cdr_start_on_confirmed = 0;
121 121
 int cdr_expired_dlg_enable = 0;
122 122
 static char* cdr_facility_str = 0;
123 123
 static char* cdr_log_extra_str = 0;
124
+str cdr_skip = {NULL, 0};
124 125
 
125 126
 str cdr_start_str = str_init("start_time");
126 127
 str cdr_end_str = str_init("end_time");
... ...
@@ -206,6 +207,7 @@ static param_export_t params[] = {
206 207
 	{"log_extra",            PARAM_STRING, &log_extra_str        },
207 208
 	/* cdr specific */
208 209
 	{"cdr_enable",           INT_PARAM, &cdr_enable                 },
210
+	{"cdr_skip",             PARAM_STR, &cdr_skip                   },
209 211
 	{"cdr_log_enable",         INT_PARAM, &cdr_log_enable           },
210 212
 	{"cdr_start_on_confirmed", INT_PARAM, &cdr_start_on_confirmed   },
211 213
 	{"cdr_facility",         PARAM_STRING, &cdr_facility_str           },
... ...
@@ -53,6 +53,7 @@ extern int cdr_extra_nullable;
53 53
 extern int cdr_start_on_confirmed;
54 54
 extern int cdr_log_facility;
55 55
 extern int cdr_expired_dlg_enable;
56
+extern str cdr_skip;
56 57
 
57 58
 extern int db_flag;
58 59
 extern int db_missed_flag;
... ...
@@ -1034,6 +1034,23 @@ modparam("acc", "db_insert_mode", 1)
1034 1034
 ...
1035 1035
 modparam("acc", "cdr_enable", 1)
1036 1036
 ...
1037
+</programlisting>
1038
+		</example>
1039
+	</section>
1040
+	<section id="acc.p.cdr_skip">
1041
+		<title><varname>cdr_skip</varname> (string)</title>
1042
+		<para>
1043
+		Skip cdr generation for dialogs with this dlg_var set.
1044
+		</para>
1045
+		<para>
1046
+		Default value is NULL.
1047
+		</para>
1048
+		<example>
1049
+		<title>cdr_skip example</title>
1050
+		<programlisting format="linespecific">
1051
+...
1052
+modparam("acc", "cdr_skip", "nocdr")
1053
+...
1037 1054
 </programlisting>
1038 1055
 		</example>
1039 1056
 	</section>