summaryrefslogtreecommitdiff
path: root/cdr/cdr_adaptive_odbc.c
diff options
context:
space:
mode:
Diffstat (limited to 'cdr/cdr_adaptive_odbc.c')
-rw-r--r--cdr/cdr_adaptive_odbc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index 3c52658d4..50577db7e 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -611,6 +611,23 @@ static int odbc_log(struct ast_cdr *cdr)
continue;
} else {
double number = 0.0;
+
+ if (!strcasecmp(entry->cdrname, "billsec")) {
+ if (!ast_tvzero(cdr->answer)) {
+ snprintf(colbuf, sizeof(colbuf), "%lf",
+ (double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0));
+ } else {
+ ast_copy_string(colbuf, "0", sizeof(colbuf));
+ }
+ } else if (!strcasecmp(entry->cdrname, "duration")) {
+ snprintf(colbuf, sizeof(colbuf), "%lf",
+ (double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0));
+
+ if (!ast_strlen_zero(colbuf)) {
+ colptr = colbuf;
+ }
+ }
+
if (sscanf(colptr, "%30lf", &number) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
continue;
@@ -628,6 +645,23 @@ static int odbc_log(struct ast_cdr *cdr)
continue;
} else {
double number = 0.0;
+
+ if (!strcasecmp(entry->cdrname, "billsec")) {
+ if (!ast_tvzero(cdr->answer)) {
+ snprintf(colbuf, sizeof(colbuf), "%lf",
+ (double) (ast_tvdiff_us(cdr->end, cdr->answer) / 1000000.0));
+ } else {
+ ast_copy_string(colbuf, "0", sizeof(colbuf));
+ }
+ } else if (!strcasecmp(entry->cdrname, "duration")) {
+ snprintf(colbuf, sizeof(colbuf), "%lf",
+ (double) (ast_tvdiff_us(cdr->end, cdr->start) / 1000000.0));
+
+ if (!ast_strlen_zero(colbuf)) {
+ colptr = colbuf;
+ }
+ }
+
if (sscanf(colptr, "%30lf", &number) != 1) {
ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
continue;