[svn-commits] murf: trunk r140057 - in /trunk: ./ configs/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Aug 26 10:57:50 CDT 2008


Author: murf
Date: Tue Aug 26 10:57:49 2008
New Revision: 140057

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140057
Log:
(closes issue #13366)
Reported by: erousseau

This was a reasonable enhancement request, which was
easy to implement. Since it's an enhancement, it 
could only be applied to trunk.

Basically, for accounting where "initiated" seconds
are billed for, if the microseconds field on the end
time is greater than the microseconds field for the
answer time, add one second to the billsec field.

The implementation was requested by erousseau, and
I've implemented it as requested. I've updated the
CHANGES, the cdr.conf.sample, and the .h files
accordingly, to accept and set a flag for the
corresponding new option. cdr.c adds in the extra
second based on the usec fields if the option is
set. Tested, seems to be working fine.


Modified:
    trunk/CHANGES
    trunk/configs/cdr.conf.sample
    trunk/include/asterisk/options.h
    trunk/main/cdr.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=140057&r1=140056&r2=140057
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Aug 26 10:57:49 2008
@@ -209,6 +209,11 @@
     operator.  This is most helpful when working with long SQL queries in
     func_odbc.conf, as the queries no longer need to be specified on a single
     line.
+  * CDR config file, cdr.conf, has an added option, "initiatedseconds", 
+    which will add a second to the billsec when the ending
+    time is set, if the number in the microseconds field of the end time is 
+    greater than the number of microseconds in the answer time. This allows
+    users to count the 'initiated' seconds in their billing records. 
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.4.X to Asterisk 1.6.0  -------------

Modified: trunk/configs/cdr.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/cdr.conf.sample?view=diff&rev=140057&r1=140056&r2=140057
==============================================================================
--- trunk/configs/cdr.conf.sample (original)
+++ trunk/configs/cdr.conf.sample Tue Aug 26 10:57:49 2008
@@ -64,6 +64,15 @@
 ; the "h" extension so that CDR values such as "end" and "billsec" may be
 ; retrieved inside of of this extension.
 ;endbeforehexten=no
+
+; Normally, the 'billsec' field logged to the backends (text files or databases)
+; is simply the end time (hangup time) minus the answer time in seconds. Internally,
+; asterisk stores the time in terms of microseconds and seconds. By setting 
+; initiatedseconds to 'yes', you can force asterisk to report any seconds
+; that were initiated (a sort of round up method). Technically, this is
+; when the microsecond part of the end time is greater than the microsecond
+; part of the answer time, then the billsec time is incremented one second.
+;initiatedseconds=no
 
 ;
 ;

Modified: trunk/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/options.h?view=diff&rev=140057&r1=140056&r2=140057
==============================================================================
--- trunk/include/asterisk/options.h (original)
+++ trunk/include/asterisk/options.h Tue Aug 26 10:57:49 2008
@@ -84,6 +84,8 @@
 	AST_OPT_FLAG_VERBOSE_FILE = (1 << 24),
 	/*! Terminal colors should be adjusted for a light-colored background */
 	AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
+	/*! Count Initiated seconds in CDR's */
+	AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
 };
 
 /*! These are the options that set by default when Asterisk starts */

Modified: trunk/main/cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cdr.c?view=diff&rev=140057&r1=140056&r2=140057
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Tue Aug 26 10:57:49 2008
@@ -874,8 +874,11 @@
 				ast_log(LOG_WARNING, "CDR on channel '%s' has no answer time but is 'ANSWERED'\n", S_OR(cdr->channel, "<unknown>"));
 				cdr->disposition = AST_CDR_FAILED;
 			}
-		} else
+		} else {
 			cdr->billsec = cdr->end.tv_sec - cdr->answer.tv_sec;
+			if (ast_test_flag(&ast_options, AST_OPT_FLAG_INITIATED_SECONDS))
+				cdr->billsec += cdr->end.tv_usec > cdr->answer.tv_usec ? 1 : 0;
+		}
 	}
 }
 
@@ -1386,6 +1389,7 @@
 	const char *size_value;
 	const char *time_value;
 	const char *end_before_h_value;
+	const char *initiatedseconds_value;
 	int cfg_size;
 	int cfg_time;
 	int was_enabled;
@@ -1444,6 +1448,8 @@
 		}
 		if ((end_before_h_value = ast_variable_retrieve(config, "general", "endbeforehexten")))
 			ast_set2_flag(&ast_options, ast_true(end_before_h_value), AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN);
+		if ((initiatedseconds_value = ast_variable_retrieve(config, "general", "initiatedseconds")))
+			ast_set2_flag(&ast_options, ast_true(initiatedseconds_value), AST_OPT_FLAG_INITIATED_SECONDS);
 	}
 
 	if (enabled && !batchmode) {




More information about the svn-commits mailing list