Module: sip-router
Branch: master
Commit: 7b4567c4cc4611ee32e403b41f53ed9a34ce9727
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7b4567c…
Author: Sven Knoblich <sven.knoblich(a)1und1.de>
Committer: Sven Knoblich <sven.knoblich(a)1und1.de>
Date: Thu Feb 23 14:33:19 2012 +0100
Add new cdr-feature 'modifying cdr basic parameter st/et/d'. This is necessary for
the upcoming db-storage of cdr's.
---
modules_k/acc/acc_cdr.c | 33 +++++++-------
modules_k/acc/acc_mod.c | 88 +++++++++++++++++++++++++--------------
modules_k/acc/doc/acc_admin.xml | 46 ++++++++++++++++++++-
3 files changed, 119 insertions(+), 48 deletions(-)
diff --git a/modules_k/acc/acc_cdr.c b/modules_k/acc/acc_cdr.c
index a3760b9..996ebf4 100644
--- a/modules_k/acc/acc_cdr.c
+++ b/modules_k/acc/acc_cdr.c
@@ -36,6 +36,7 @@
*
*/
#include "../../modules/tm/tm_load.h"
+#include "../../str.h"
#include "../dialog/dlg_load.h"
#include "acc_api.h"
@@ -66,9 +67,6 @@ struct dlg_binds dlgb;
struct acc_extra* cdr_extra = NULL;
int cdr_facility = LOG_DAEMON;
-static const str start_id = { "st", 2};
-static const str end_id = { "et", 2};
-static const str duration_id = { "d", 1};
static const str zero_duration = { "0", 1};
static const char time_separator = {'.'};
static char time_buffer[ TIME_BUFFER_LENGTH];
@@ -81,6 +79,9 @@ static int cdr_int_arr[ MAX_CDR_CORE + MAX_CDR_EXTRA];
static char cdr_type_array[ MAX_CDR_CORE + MAX_CDR_EXTRA];
extern struct tm_binds tmb;
+extern str cdr_start_str;
+extern str cdr_end_str;
+extern str cdr_duration_str;
/* write all basic information to buffers(e.g. start-time ...) */
static int cdr_core2strar( struct dlg_cell* dlg,
@@ -98,9 +99,9 @@ static int cdr_core2strar( struct dlg_cell* dlg,
return 0;
}
- start = dlgb.get_dlg_var( dlg, (str*)&start_id);
- end = dlgb.get_dlg_var( dlg, (str*)&end_id);
- duration = dlgb.get_dlg_var( dlg, (str*)&duration_id);
+ start = dlgb.get_dlg_var( dlg, (str*)&cdr_start_str);
+ end = dlgb.get_dlg_var( dlg, (str*)&cdr_end_str);
+ duration = dlgb.get_dlg_var( dlg, (str*)&cdr_duration_str);
values[0] = ( start != NULL ? *start : empty_string);
types[0] = ( start != NULL ? TYPE_STR : TYPE_NULL);
@@ -284,11 +285,11 @@ static int set_duration( struct dlg_cell* dialog)
return -1;
}
- if ( string2time( dlgb.get_dlg_var( dialog, (str*)&start_id), &start_time)
< 0) {
+ if ( string2time( dlgb.get_dlg_var( dialog, (str*)&cdr_start_str),
&start_time) < 0) {
LM_ERR( "failed to extract start time\n");
return -1;
}
- if ( string2time( dlgb.get_dlg_var( dialog, (str*)&end_id), &end_time) <
0) {
+ if ( string2time( dlgb.get_dlg_var( dialog, (str*)&cdr_end_str), &end_time)
< 0) {
LM_ERR( "failed to extract end time\n");
return -1;
}
@@ -301,7 +302,7 @@ static int set_duration( struct dlg_cell* dialog)
}
if( dlgb.set_dlg_var( dialog,
- (str*)&duration_id,
+ (str*)&cdr_duration_str,
(str*)&duration_str) != 0)
{
LM_ERR( "failed to set duration time");
@@ -335,7 +336,7 @@ static int set_start_time( struct dlg_cell* dialog)
}
if( dlgb.set_dlg_var( dialog,
- (str*)&start_id,
+ (str*)&cdr_start_str,
(str*)&start_time) != 0)
{
LM_ERR( "failed to set start time\n");
@@ -343,7 +344,7 @@ static int set_start_time( struct dlg_cell* dialog)
}
if( dlgb.set_dlg_var( dialog,
- (str*)&end_id,
+ (str*)&cdr_end_str,
(str*)&start_time) != 0)
{
LM_ERR( "failed to set initiation end time\n");
@@ -351,7 +352,7 @@ static int set_start_time( struct dlg_cell* dialog)
}
if( dlgb.set_dlg_var( dialog,
- (str*)&duration_id,
+ (str*)&cdr_duration_str,
(str*)&zero_duration) != 0)
{
LM_ERR( "failed to set initiation duration time\n");
@@ -385,7 +386,7 @@ static int set_end_time( struct dlg_cell* dialog)
}
if( dlgb.set_dlg_var( dialog,
- (str*)&end_id,
+ (str*)&cdr_end_str,
(str*)&end_time) != 0)
{
LM_ERR( "failed to set start time");
@@ -595,9 +596,9 @@ int set_cdr_extra( char* cdr_extra_value)
}
/* fixed core attributes */
- cdr_attrs[ counter++] = start_id;
- cdr_attrs[ counter++] = end_id;
- cdr_attrs[ counter++] = duration_id;
+ cdr_attrs[ counter++] = cdr_start_str;
+ cdr_attrs[ counter++] = cdr_end_str;
+ cdr_attrs[ counter++] = cdr_duration_str;
for(extra=cdr_extra; extra ; extra=extra->next)
{
diff --git a/modules_k/acc/acc_mod.c b/modules_k/acc/acc_mod.c
index c1d6d68..15bfe9e 100644
--- a/modules_k/acc/acc_mod.c
+++ b/modules_k/acc/acc_mod.c
@@ -66,6 +66,7 @@
#include "../../dprint.h"
#include "../../mem/mem.h"
#include "../../modules/tm/tm_load.h"
+#include "../../str.h"
#include "../rr/api.h"
#include "acc.h"
#include "acc_api.h"
@@ -132,6 +133,11 @@ int cdr_enable = 0;
int cdr_start_on_confirmed = 0;
static char* cdr_facility_str = 0;
static char* cdr_log_extra_str = 0;
+
+str cdr_start_str = str_init("st");
+str cdr_end_str = str_init("et");
+str cdr_duration_str = str_init("d");
+
/*@{*/
/* ----- RADIUS acc variables ----------- */
@@ -243,11 +249,14 @@ static param_export_t params[] = {
{"log_level", INT_PARAM, &log_level },
{"log_facility", STR_PARAM, &log_facility_str },
{"log_extra", STR_PARAM, &log_extra_str },
- /* cdr specific */
- {"cdr_enable", INT_PARAM, &cdr_enable },
- {"cdr_start_on_confirmed", INT_PARAM, &cdr_start_on_confirmed },
- {"cdr_facility", STR_PARAM, &cdr_facility_str
},
- {"cdr_extra", STR_PARAM, &cdr_log_extra_str },
+ /* cdr specific */
+ {"cdr_enable", INT_PARAM, &cdr_enable },
+ {"cdr_start_on_confirmed", INT_PARAM, &cdr_start_on_confirmed },
+ {"cdr_facility", STR_PARAM, &cdr_facility_str },
+ {"cdr_extra", STR_PARAM, &cdr_log_extra_str },
+ {"cdr_start_id", STR_PARAM, &cdr_start_str.s },
+ {"cdr_stop_id", STR_PARAM, &cdr_end_str.s },
+ {"cdr_duration_id", STR_PARAM, &cdr_duration_str.s },
#ifdef RAD_ACC
{"radius_config", STR_PARAM, &radius_config },
{"radius_flag", INT_PARAM, &radius_flag },
@@ -504,34 +513,51 @@ static int mod_init( void )
acc_log_init();
- /* ----------- INIT CDR GENERATION ----------- */
+ /* ----------- INIT CDR GENERATION ----------- */
- if( cdr_enable < 0 || cdr_enable > 1)
- {
- LM_ERR("cdr_enable is out of range\n");
- return -1;
- }
+ if( cdr_enable < 0 || cdr_enable > 1)
+ {
+ LM_ERR("cdr_enable is out of range\n");
+ return -1;
+ }
- if( cdr_enable)
- {
- if( set_cdr_extra( cdr_log_extra_str) != 0)
- {
- LM_ERR( "failed to set cdr extra '%s'\n",
cdr_log_extra_str);
- return -1;
- }
-
- if( cdr_facility_str && set_cdr_facility( cdr_facility_str) != 0)
- {
- LM_ERR( "failed to set cdr facility '%s'\n",
cdr_facility_str);
- return -1;
- }
-
- if( init_cdr_generation() != 0)
- {
- LM_ERR("failed to init cdr generation\n");
- return -1;
- }
- }
+ if( cdr_enable)
+ {
+ if( !cdr_start_str.s || !cdr_end_str.s || !cdr_duration_str.s)
+ {
+ LM_ERR( "necessary cdr_parameters are not set\n");
+ return -1;
+ }
+
+ cdr_start_str.len = strlen(cdr_start_str.s);
+ cdr_end_str.len = strlen(cdr_end_str.s);
+ cdr_duration_str.len = strlen(cdr_duration_str.s);
+
+ if( !cdr_start_str.len || !cdr_end_str.len || !cdr_duration_str.len)
+ {
+ LM_ERR( "necessary cdr_parameters are empty\n");
+ return -1;
+ }
+
+
+ if( set_cdr_extra( cdr_log_extra_str) != 0)
+ {
+ LM_ERR( "failed to set cdr extra '%s'\n", cdr_log_extra_str);
+ return -1;
+ }
+
+ if( cdr_facility_str && set_cdr_facility( cdr_facility_str) != 0)
+ {
+ LM_ERR( "failed to set cdr facility '%s'\n", cdr_facility_str);
+ return -1;
+ }
+
+ if( init_cdr_generation() != 0)
+ {
+ LM_ERR("failed to init cdr generation\n");
+ return -1;
+ }
+ }
/* ------------ SQL INIT SECTION ----------- */
diff --git a/modules_k/acc/doc/acc_admin.xml b/modules_k/acc/doc/acc_admin.xml
index 50fb91d..afb4934 100644
--- a/modules_k/acc/doc/acc_admin.xml
+++ b/modules_k/acc/doc/acc_admin.xml
@@ -1179,7 +1179,51 @@ modparam("acc", "cdr_extra",
"c1=$dlg_var(caller);c2=$dlg_var(callee)"
</programlisting>
</example>
</section>
-
+ <section id="cdr_start_id">
+ <title><varname>cdr_start_id</varname> (string)</title>
+ <para>
+ Modifying the start id which is used to store the start time.
+ </para>
+ <para>
+ Default value is 'st'
+ </para>
+ <example>
+ <title>cdr_start_id example</title>
+ <programlisting format="linespecific">
+modparam("acc", "cdr_start_id", "start")
+</programlisting>
+ </example>
+ </section>
+ <section id="cdr_end_id">
+ <title><varname>cdr_end_id</varname> (string)</title>
+ <para>
+ Modifying the end id which is used to store the end time.
+ </para>
+ <para>
+ Default value is 'et'
+ </para>
+ <example>
+ <title>cdr_end_id example</title>
+ <programlisting format="linespecific">
+modparam("acc", "cdr_end_id", "end")
+</programlisting>
+ </example>
+ </section>
+ <section id="cdr_duration_id">
+ <title><varname>cdr_duration_id</varname> (string)</title>
+ <para>
+ Modifying the duration id which is used to store the duration.
+ </para>
+ <para>
+ Default value is 'd'
+ </para>
+ <example>
+ <title>cdr_duration_id example</title>
+ <programlisting format="linespecific">
+modparam("acc", "cdr_duration_id", "start")
+</programlisting>
+ </example>
+ </section>
</section>
<section>