src/modules/acc/doc/acc_admin.xml
33d03d8d
 <?xml version="1.0" encoding='ISO-8859-1'?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
 
 <!-- Include general documentation entities -->
6deb5fcf
 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
33d03d8d
 %docentities;
 
 ]>
 
31ccf6a2
 <!-- Acc Module User's Guide -->
 
 <chapter>
4a545bac
 
9fc784c6
 	<title>&adminguide;</title>
4a545bac
 
31ccf6a2
 	<section>
 	<title>Overview</title>
 	<para>
8ec042ca
 		ACC module is used to account transactions information to different
59a58e8a
 		backends like syslog and <abbrev>SQL</abbrev>. With the separate module
 		<quote>acc_radius</quote> support for <acronym>radius</acronym> is enabled.
8e44cf56
 	</para>
 	<para>
59a58e8a
 		There is some very early support of the <acronym>Diameter</acronym>
402515c9
 		protocol in the <quote>acc_diameter</quote> module, but is not up to date
 		with the current Diameter protocols. If you need Diameter support,
 		please use the <acronym>ims_charging</acronym> module.
31ccf6a2
 	</para>
 	<para>
4a545bac
 		To account a transaction and to choose which set of backends to be
8ec042ca
 		used, the script writer just has to set some flags (see the module
f969ffc1
 		parameters section for flag definitions <xref linkend="acc.i.params"/>).
4a545bac
 		If the accounting flag for a specific backend is set, the acc module
 		will then report on completed transaction. A typical usage of the
 		module takes no acc-specific script command -- the functionality
 		binds invisibly through transaction processing. Script writers just
 		need to mark the transaction for accounting with proper setflag.
 		Even so, the module allows the script writter to force accounting in
8ec042ca
 		special cases via some script functions.
31ccf6a2
 	</para>
 	<para>
4a545bac
 		The accounting module will log by default a fixed set of attributes
44ccb33b
 		for the transaction - if you customize your accounting by adding more
8ec042ca
 		information to be logged, please see the next chapter about extra
f969ffc1
 		accounting - <xref linkend="acc.i.extra-accounting"/>.
8ec042ca
 	</para>
 	<para>
4a545bac
 		The fixed minimal accounting information is:
31ccf6a2
 		<itemizedlist>
 		<listitem>
8ec042ca
 			<para>Request Method name</para>
31ccf6a2
 		</listitem>
 		<listitem>
8ec042ca
 			<para>From header TAG parameter</para>
31ccf6a2
 		</listitem>
2f041149
 		<listitem>
8ec042ca
 			<para>To header TAG parameter</para>
2f041149
 		</listitem>
 		<listitem>
8ec042ca
 			<para>Call-Id</para>
18321123
 		</listitem>
 		<listitem>
8ec042ca
 			<para>3-digit Status code from final reply</para>
2f041149
 		</listitem>
 		<listitem>
8ec042ca
 			<para>Reason phrase from final reply</para>
2f041149
 		</listitem>
 		<listitem>
8ec042ca
 			<para>Time stamp when transaction was completed</para>
2f041149
 		</listitem>
31ccf6a2
 		</itemizedlist>
4a545bac
 		If a value is not present in request, the empty string is accounted
8ec042ca
 		instead.
31ccf6a2
 	</para>
 	<para>
 		Note that:
 		<itemizedlist>
 		<listitem>
 			<para>
 			A single INVITE may produce multiple accounting reports -- that's
44ccb33b
 			due to SIP forking feature.
31ccf6a2
 			</para>
 		</listitem>
 		<listitem>
 			<para>
44ccb33b
 			All flags related to accounting need to be set in request processing
 			route - only the "missed-call" flag may be toggled from other
8ec042ca
 			types of routes.
31ccf6a2
 			</para>
 		</listitem>
 		<listitem>
 			<para>
4a545bac
 			If a UA fails in middle of conversation, a proxy will never
 			find out about it. In general, a better practice is to account from an
 			end-device (such as PSTN gateway), which best knows about call
 			status (including media status and PSTN status in case of the
57177cf1
 			gateway). However, CDR-base logging has the option to log existing
 			information from expired dialogs (the dlg_vars in cdr_extra)
 			Please see cdr_expired_dlg_enable parameter - <xref linkend="acc.p.cdr_expired_dlg_enable"/>.
31ccf6a2
 			</para>
 		</listitem>
 		</itemizedlist>
 	</para>
 	<para>
d8cede17
 		The SQL backend support is compiled in the module.
25a2c995
         </para>
31ccf6a2
 	<section>
 		<title>General Example</title>
 		<programlisting format="linespecific">
 loadmodule "modules/acc/acc.so"
 modparam("acc", "log_level", 1)
 modparam("acc", "log_flag", 1)
 
 if (uri=~"sip:+40") /* calls to Romania */ {
e4567684
     if (!proxy_authorize("sip_domain.net" /* realm */,
567a6f5e
     "subscriber" /* table name */))  {
e4567684
         proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );
66cfca8b
         exit;
567a6f5e
     }
31ccf6a2
 
d77df08a
     if (method=="INVITE" &amp;&amp; !check_from()) {
567a6f5e
         log("from!=digest\n");
         sl_send_reply("403","Forbidden");
     }
31ccf6a2
 
567a6f5e
     setflag(1); /* set for accounting (the same value as in log_flag!)
     t_relay(); 	/* enter stateful mode now */
31ccf6a2
 };
 </programlisting>
 	</section>
 	</section>
567a6f5e
 
f969ffc1
 	<section id="acc.i.extra-accounting">
31ccf6a2
 		<title>Extra accounting</title>
567a6f5e
 		<section>
 			<title>Overview</title>
 			<para>
4a545bac
 			Along the static default information, ACC modules
 			allows dynamical selection of extra information to be logged.
 			This allows you to log any pseudo-variable (AVPs, parts of
8ec042ca
 			the request, etc).
567a6f5e
 			</para>
 		</section>
bbb6df5d
 		<section id="acc-def-syn">
567a6f5e
 			<title>Definitions and syntax</title>
 			<para>
4a545bac
 			Selection of extra information is done via
d77df08a
 			<emphasis>xxx_extra</emphasis> parameters by specifying the names
4a545bac
 			of additional information you want to log. This information is
44ccb33b
 			defined via pseudo-variables and may include headers, AVPs values
3406cb39
 			or other message or system values. The syntax of the parameter is:
 			</para>
567a6f5e
 			<itemizedlist>
 				<listitem><para><emphasis>
 				xxx_extra = extra_definition (';'extra_definition)*
 				</emphasis></para></listitem>
 				<listitem><para><emphasis>
3406cb39
 				extra_definition = log_name '=' pseudo_variable
567a6f5e
 				</emphasis></para></listitem>
 			</itemizedlist>
3406cb39
 			<para>
a118a328
 			The full list of supported pseudo-variables in &kamailio; is
4a545bac
 			available at:
f0c467f6
 			<ulink url="http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables">
 			http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables</ulink>
567a6f5e
 			</para>
 			<para>
eb6d6cbd
 			Note: For all the ACK processed by tm, the registered callbacks
 			(like acc module) will be called with the corresponding INVITE
 			transaction contexts as long as this is still available. This means
 			that the ACK callbacks will see the AVPs setup for the INVITE
 			transaction and not the AVPs setup before t_relay().
 			</para>
 			<para>
4a545bac
 			Via <emphasis>log_name</emphasis> you define how/where the
 			<emphasis>data</emphasis> will be logged. Its meaning depends
567a6f5e
 			of the accounting support which is used:
 			<itemizedlist>
 				<listitem><para><emphasis>LOG accounting</emphasis> - log_name
 				will be just printed along with the data in <emphasis>
 				log_name=data</emphasis> format;
 				</para></listitem>
4a545bac
 				<listitem><para><emphasis>DB accounting</emphasis> - log_name
 				will be the name of the DB column where the data will be
 				stored.<emphasis>IMPORTANT</emphasis>: add in db
 				<emphasis>acc</emphasis> table the columns corresponding to
567a6f5e
 				each extra data;
 				</para></listitem>
4a545bac
 				<listitem><para><emphasis>RADIUS accounting</emphasis> -
 				log_name will be the AVP name used for packing the data into
 				RADIUS message. The log_name will be translated to AVP number
 				via the dictionary. <emphasis>IMPORTANT</emphasis>: add in
567a6f5e
 				RADIUS dictionary the <emphasis>log_name</emphasis> attribute.
 				</para></listitem>
4a545bac
 				<listitem><para><emphasis>DIAMETER accounting</emphasis> -
 				log_name will be the AVP code used for packing the data
 				into DIAMETER message. The AVP code is given directly as
567a6f5e
 				integer, since DIAMETER has no dictionary support yet.
 				<emphasis>IMPORTANT</emphasis>:	<emphasis>log_name</emphasis>
 				must be a number.
 				</para></listitem>
 			</itemizedlist>
 			</para>
 		</section>
 		<section>
 			<title>How it works</title>
 			<para>
4a545bac
 			Some pseudo variables may return more than one value (like
3406cb39
 			headers or AVPs). In this case, the returned values are
 			embedded in a single string in a comma-separated format.
567a6f5e
 			</para>
 		</section>
31ccf6a2
 	</section>
9de35847
 
f969ffc1
 	<section id="acc.i.multi-call-legs">
567a6f5e
 		<title>Multi Call-Legs accounting</title>
 		<section>
 			<title>Overview</title>
 			<para>
4a545bac
 			A SIP call can have multiple legs due forwarding actions. For
 			example user A calls user B which forwards the call to user C.
 			There is only one SIP call but with 2 legs ( A to B and B to C).
 			Accounting the legs of a call is required for proper billing of
 			the calls (if C is a PSTN number and the call is billed, user B
8ebf6bd0
 			must pay for the call - as last party modifying the call
4a545bac
 			destination-, and not A - as initiator of the call. Call
 			forwarding on server is only one example which shows the
 			necessity of the having an accounting engine with multiple legs
567a6f5e
 			support.
 			</para>
 		</section>
 		<section>
 			<title>Configuration</title>
 			<para>
44ccb33b
 			First how it works: The idea is to have a set of AVPs and for each
 			call leg to store a set of values in the AVPs. The meaning of
8ebf6bd0
 			the AVP content is strictly decided by the script writer - it can
4a545bac
 			be the origin and source of the leg, its status or any other
44ccb33b
 			related information. If you have a set of 4 AVPS (AVP1, AVP2, AVP3,
4a545bac
 			AVP4), then for the "A call B and B forwards to C" example,
44ccb33b
 			you need to set a different set of values for the AVPs
 			for each leg ([A,B] and [B,C]) .
4a545bac
 			The script writer must take care and properly insert all
44ccb33b
 			these AVP from the script (in proper order and with the correct type).
567a6f5e
 			</para>
 			<para>
4a545bac
 			When the accounting information for the call will be written/sent,
44ccb33b
 			all the call-leg pairs will be added (based on the found AVP sets).
567a6f5e
 			</para>
 			<para>
44ccb33b
 			By default, the multiple call-leg support is disabled - it can be
4a545bac
 			enabled just be setting the per-leg set of AVPs via the
6d2bf5d5
 			<varname>multi_leg_info</varname> module parameter.
567a6f5e
 			</para>
 		</section>
 		<section>
 			<title>Logged data</title>
 			<para>
4a545bac
 			For each call, all the values of the AVP set (which defines a
0aee8885
 			call-leg) will be logged. How the information will be actually
567a6f5e
 			logged, depends of the data backend:
 			</para>
 			<itemizedlist>
 				<listitem>
6d2bf5d5
 				<para><emphasis>syslog</emphasis> -- all leg-sets will be added
 				to one record string as AVP1=xxx, AVP2=xxxx ,... sets.
567a6f5e
 				</para>
 				</listitem>
 				<listitem>
4a545bac
 				<para><emphasis>database</emphasis> -- each pair will be
0aee8885
 				separately logged (due DB data structure constraints); several
4a545bac
 				records will be written, the difference between them being
6d2bf5d5
 				only the fields corresponding to the call-leg info.
 				</para>
567a6f5e
 				<note><para>You will need to add in your DB (all acc related
8ebf6bd0
 				tables) the columns for call-leg info (a column for each AVP
44ccb33b
 				of the set).
567a6f5e
 				</para></note>
 				</listitem>
 				<listitem>
6d2bf5d5
 				<para><emphasis>Radius</emphasis> -- all sets will be added
44ccb33b
 				to the same Radius accounting message as RADIUS AVPs - for each
6d2bf5d5
 				call-leg a set of RADIUS AVPs will be added (corresponding
4a545bac
 				to the per-leg AVP set). Note that Radius support is in a
21fab708
 				separate module - acc_radius.
567a6f5e
 				</para>
44ccb33b
 				<note><para>You will need to add in your dictionary the
6d2bf5d5
 				RADIUS AVPs used in call-leg AVP set definition.
567a6f5e
 				</para></note>
 				</listitem>
 			</itemizedlist>
 		</section>
 	</section>
bbb6df5d
 	<section>
 		<title>Call Data Record generation</title>
         <section>
             <title>Overview</title>
                 <para>
caee2ded
                 In addition to transaction-based logging, it is possible to generate and log Call Data
                 Records (CDRs) directly from &kamailio;. Apart from a basic set of CDR fields which
bbb6df5d
                 are always included (covering start time, end time, and duration), the approach allows
                 flexible specification of additional fields that should be taken into account using
                 the configuration script. This is very similar to how transaction-based logging may
                 be customized with the exception that CDRs rely on dialogs instead of transactions
                 to store relevant information during a call.
                 </para>
 
                 <para>
                 In order to set up CDR generation, you must enable the CDR switch and load the dialog
                 module. You probably also want to specify a set of pseudo-variables that define more
                 relevant CDR fields. Pseudo-variables may be assigned arbitrarily during script
                 execution, and the module will make sure that the variable content will be transformed
                 into a CDR by the end of the dialog.
                 </para>
 
                 <para>
                 To use CDR logging in a correct manner, you should only use the dialog-based
                 pseudo-variables (dlg_var) from the dialog module. This allows you to save values
                 right from the beginning through all requests and replies until termination of the
                 call. While not recommended, it is still possible to use other pseudo-variables as
                 well. Except for pseudo-variables valid in the call-final transaction, however,
                 information given will not be stored in the CDR as they cannot be accessed by the
                 end of the call when the CDR is logged.
                 </para>
caee2ded
 
57177cf1
                 <para>
 				Sometimes, dialogs expire because the UA has a problem and a final message is never
 				transmitted. You can toggle on/off the generation of CDR-based logging in such cases
 				with only the dlg_vars showing by using the cdr_expired_dlg_enable parameter
 				- <xref linkend="acc.p.cdr_expired_dlg_enable"/>. Default behavior is not logging.
                 </para>
bbb6df5d
         </section>
f969ffc1
 		<section id="acc.i.cdr-extra">
bbb6df5d
 			<title>CDR Extra</title>
 					This section is similar to the <quote>LOG accounting</quote> part of
f969ffc1
 					<xref linkend="acc.i.extra-accounting"/>.
bbb6df5d
 			<section>
 				<title>Definitions and syntax</title>
 					<para>
 					Selection of extra information is done similar to the transaction extra
 					<xref linkend="acc-def-syn"/>.
 					</para>
 					<itemizedlist>
 						<listitem><para><emphasis>
f4aa54a8
 						cdr_extra = cdr_extra_definition (';'cdr_extra_definition)*
bbb6df5d
 						</emphasis></para></listitem>
 						<listitem><para><emphasis>
 						cdr_extra_definition = cdr_log_name '=' pseudo_variable
 						</emphasis></para></listitem>
 					</itemizedlist>
f0f31127
 					See also <xref linkend="acc.p.cdr_extra"/>.
bbb6df5d
 					<para>
659e2c3e
 					The list with all pseudo-variables in &kamailio; can
 					be found at: &kamwikilink;.
bbb6df5d
 					</para>
 			</section>
 		</section>
 		<section id="multi-cdr-call-legs">
 			<title>CDR with Multi Call-Legs</title>
 			<section>
 				<title>Overview</title>
 				<para>
0e30a2d5
 				As mentioned in <xref linkend="acc.i.multi-call-legs"/>, a leg represents a parallel
bbb6df5d
 				or forwarded call. In contrast to the normal accounting the cdr logging uses dialogs
4a545bac
 				instead of transaction to log data. This may reduce the amount of information
 				but it also make it possible to combine all important data in one cdr at
bbb6df5d
 				once. A second mechanism to process multiple data-sets into one cdr is not further
 				necessary.
 				</para>
 			</section>
 			<section>
 				<title>Configuration</title>
 				<para>
 				When you route messages multiple times through your proxy (e.g. to
 				handle <quote>call-forwardings</quote>) you have to use detect_spirals
 				from the dialog modules. Otherwise the proxy can't identify and reuse existing
 				dialogs.
 				</para>
 				<para>
 				To get the correct call-forwarding-chain you have to store each cf* with the
 				corresponding caller and callee in a dialog based pseudo-variable (dlg_var)
 				(e.g. chain=B;cfa;C|C;cfnr;D). Additionally it is necessary to store the
 				caller and callee for each leg. All this helps to identify the involved
8ebf6bd0
 				phone partners and forwarding chain. When you route such calls multiple times
bbb6df5d
 				to the same Proxy, you could store the caller and callee within an transaction
 				based avp and write it into the dialog based dlg_var pv during a 200 INVITE.
 				</para>
 				<section>
 					<title>Example for a spiraled Proxy</title>
 					<programlisting format="linespecific">
88e2da3c
 ...
bbb6df5d
 # A calls B (transaction 1)
 $avp(caller)='A'
 $avp(callee)='B';
 $dlg_var(chain)='';
567a6f5e
 
bbb6df5d
 # B cfa C (transaction 2)
 $avp(caller)='B'
 $avp(callee)='C';
 $dlg_var(chain)='B;cfu;C';
567a6f5e
 
bbb6df5d
 # C cfnr D (transaction 3)
 $avp(caller)='C'
 $avp(callee)='D';
 $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D";
 
 # C confirms call (200 reply of transaction 2)
 $dlg_var(caller) = $avp(caller); #caller='B'
 $dlg_var(callee) = $avp(callee); #callee='C'
88e2da3c
 ...
bbb6df5d
 					</programlisting>
 				</section>
 			</section>
 			<section>
 				<title>Logged data</title>
 				For each call, all dialog corresponding variables will be logged. After a call
 				is finished, the generated call data record information will be logged as string
 				(VAR1=xxx,VAR2=xxxx,...) to the syslog.
 			</section>
 		</section>
 	</section>
31ccf6a2
 	<section>
9de35847
 		<title>Dependencies</title>
 		<section>
a118a328
 			<title>&kamailio; Modules</title>
9de35847
 			<para>
4a545bac
 			The module depends on the following modules (in the other words
9de35847
 			the listed modules must be loaded before this module):
 			<itemizedlist>
 				<listitem>
 				<para><emphasis>tm</emphasis> -- Transaction Manager</para>
 				</listitem>
 				<listitem>
4a545bac
 				<para><emphasis>a database module</emphasis> -- If SQL
18321123
 				support is used.</para>
 				</listitem>
 				<listitem>
4a545bac
 				<para><emphasis>rr</emphasis> -- Record Route, if
18321123
 				<quote>detect_direction</quote> module parameter is enabled.
 				</para>
9de35847
 				</listitem>
bbb6df5d
 				<listitem>
 				<para><emphasis>dialog</emphasis> -- Dialog, if
 				<quote>cdr_enable</quote> module parameter is enabled.
 				</para>
 				</listitem>
9de35847
 			</itemizedlist>
 			</para>
 		</section>
 		<section>
 			<title>External Libraries or Applications</title>
 			<para>
4a545bac
 			The following libraries or applications must be installed
a118a328
 			before running &kamailio; with this module loaded:
d77df08a
 			</para>
9de35847
 			<itemizedlist>
 				<listitem>
c2c7e5b7
 				<para>None</para>
9de35847
 				</listitem>
 			</itemizedlist>
 		</section>
31ccf6a2
 	</section>
9de35847
 
f969ffc1
 	<section id="acc.i.params">
9114eebc
 	<title>Parameters</title>
e4567684
 	<!-- Generic ACC parameters -->
f0f31127
 	<section id="acc.p.early_media">
e4567684
 		<title><varname>early_media</varname> (integer)</title>
31ccf6a2
 		<para>
a523d211
 		Should be early media (any provisional reply with body) accounted too ?
31ccf6a2
 		</para>
 		<para>
e4567684
 		Default value is 0 (no).
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>early_media example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "early_media", 1)
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.failed_transaction_flag">
e4567684
 		<title><varname>failed_transaction_flag</varname> (integer)</title>
31ccf6a2
 		<para>
4a545bac
 		Per transaction flag which says if the transaction should be
40905046
 		accounted also in case of failure (SIP status code >= 300).
 		This flag triggers accouting when the whole transaction fails
 		(on the server side).
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is not-set (no flag).
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>failed_transaction_flag example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "failed_transaction_flag", 4)
88e2da3c
 ...
959ab319
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.failed_filter">
959ab319
 		<title><varname>failed_filter</varname> (string)</title>
 		<para>
 		A string of failure response codes from 300 to 999
 		separated by commas. Failed transaction will not be accounted
 		if its response code is in the list even when
4a545bac
 		failed_transaction_flag is set.
959ab319
 		</para>
 		<para>
 		Default value is not-set (failure filtering is off).
 		</para>
 		<example>
 		<title>failed_filter example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
959ab319
 modparam("acc", "failed_filter", "404,407")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.report_ack">
e4567684
 		<title><varname>report_ack</varname> (integer)</title>
31ccf6a2
 		<para>
4a545bac
 		Shall acc attempt to account e2e ACKs too ? Note that this is really
 		only an attempt, as e2e ACKs may take a different path
 		(unless RR enabled) and mismatch original INVITE (e2e ACKs are
6656d445
 		a separate transaction). The flag for accounting has to be set
 		for each ACK as well.
e4567684
 		</para>
 		<para>
f9284fac
 		Default value is 0 (no).
e4567684
 		</para>
 		<example>
 		<title>report_ack example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
f9284fac
 modparam("acc", "report_ack", 1)
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.report_cancels">
e4567684
 		<title><varname>report_cancels</varname> (integer)</title>
 		<para>
 		By default, CANCEL reporting is disabled -- most accounting
44ccb33b
 		applications wants to see INVITE's cancellation status.
e4567684
 		Turn on if you explicitly want to account CANCEL transactions.
31ccf6a2
 		</para>
 		<para>
 		Default value is 0 (no).
 		</para>
 		<example>
e4567684
 		<title>report_cancels example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "report_cancels", 1)
88e2da3c
 ...
8ec042ca
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.detect_direction">
8ec042ca
 		<title><varname>detect_direction</varname> (integer)</title>
 		<para>
8ebf6bd0
 		Controls the direction detection for sequential requests. If
8ec042ca
 		enabled (non zero value), for sequential requests with upstream
 		direction (from callee to caller), the FROM and TO will be swapped
 		(the direction will be preserved as in the original request).
 		</para>
 		<para>
4a545bac
 		It affects all values related to TO and FROM headers (body, URI,
8ec042ca
 		username, domain, TAG).
 		</para>
 		<para>
 		Default value is 0 (disabled).
 		</para>
 		<example>
 		<title>detect_direction example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "detect_direction", 1)
88e2da3c
 ...
b986c7f0
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_prepare_flag">
b986c7f0
 		<title><varname>acc_prepare_flag</varname> (integer)</title>
 		<para>
 		Per transaction flag which says if the transaction may be accounted
 		later, with flags set in TM module specific routes (e.g., like
 		failure_route). If this flag is not set and acc or missed_call flag
 		are not set either in request route block, there is no way to mark the
16c2fcb3
 		request for transaction later unless you set acc_prepare_always. If either acc or missed_call flags are
f0f31127
 		set in request route block, there is no need to set this flag.
b986c7f0
 		</para>
 		<para>
 		Default value is not-set (no flag).
 		</para>
 		<example>
 		<title>acc_prepare_flag example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
b986c7f0
 modparam("acc", "acc_prepare_flag", 5)
88e2da3c
 ...
16c2fcb3
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.acc_prepare_always">
 		<title><varname>acc_prepare_always</varname> (integer)</title>
 		<para>
 		Prepare all request even if acc_prepare_flag is not set to mark the request for transaction later.
 		</para>
 		<para>
 		Default value is not-set (previous behaviour).
 		</para>
 		<example>
 		<title>acc_prepare_flag example</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "acc_prepare_always", 1)
 ...
340f38f5
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.acc_extra_nullable">
 		<title><varname>acc_extra_nullable</varname> (integer)</title>
 		<para>
 			If set to 1, the database acc extra fields are set to NULL if the
 			corresponding script variable is not defined or has $null value. If
 			set to 0, the value is saved as empty string (the existing behavior).
 		</para>
 		<para>
93934221
 		Database columns may need to be altered to DROP NOT NULL constraints
 		and DROP DEFAULT values in order to accept NULL values.
 		</para>
 		<para>
340f38f5
 		Default value is 0.
 		</para>
 		<example>
 		<title>acc_extra_nullable example</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "acc_extra_nullable", 1)
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.multi_leg_info">
6d2bf5d5
 		<title><varname>multi_leg_info</varname> (string)</title>
31ccf6a2
 		<para>
44ccb33b
 		Defines the AVP set to be used in per-call-leg accounting.
4a545bac
 		See <xref linkend="acc.i.multi-call-legs"/> for a
e4567684
 		detailed description of the Multi Call-Legs accounting.
31ccf6a2
 		</para>
 		<para>
d1dbab43
 		If empty, the multi-leg accounting support will be disabled.
e4567684
 		</para>
 		<para>
6d2bf5d5
 		Default value is 0 (disabled).
e4567684
 		</para>
 		<example>
6d2bf5d5
 		<title>multi_leg_info example</title>
e4567684
 		<programlisting format="linespecific">
88e2da3c
 ...
d1dbab43
 # for syslog-based accounting, use any text you want to be printed
6d2bf5d5
 modparam("acc", "multi_leg_info",
     "text1=$avp(src);text2=$avp(dst)")
d1dbab43
 # for mysql-based accounting, use the names of the columns
6d2bf5d5
 modparam("acc", "multi_leg_info",
     "leg_src=$avp(src);leg_dst=$avp(dst)")
d1dbab43
 # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer)
6d2bf5d5
 modparam("acc", "multi_leg_info",
     "2345=$avp(src);2346=$avp(dst)")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
e4567684
 	<!-- SYSLOG specific ACC parameters -->
f0f31127
 	<section id="acc.p.log_flag">
31ccf6a2
 		<title><varname>log_flag</varname> (integer)</title>
 		<para>
8ec042ca
 		Request flag which needs to be set to account a transaction via syslog.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is not-set (no flag).
31ccf6a2
 		</para>
 		<example>
 		<title>log_flag example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
31ccf6a2
 modparam("acc", "log_flag", 2)
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.log_missed_flag">
31ccf6a2
 		<title><varname>log_missed_flag</varname> (integer)</title>
 		<para>
8ec042ca
 		Request flag which needs to be set to account missed calls via syslog.
f7f3222e
 		This can be used to e.g. account failures during the call setup phase
40905046
 		from the callee (client) side, for example if you do forking to several
f7f3222e
 		destinations.
 		</para>
 		<para>
40905046
 		Keep in mind that this flag is reset after branch completion. Therefore
 		it is necessary to set it again e.g. in a failure_route if you do serial
f7f3222e
 		forking and want to log all attempts.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is not-set (no flag).
31ccf6a2
 		</para>
 		<example>
 		<title>log_missed_flag example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
31ccf6a2
 modparam("acc", "log_missed_flag", 3)
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.log_level">
e4567684
 		<title><varname>log_level</varname> (integer)</title>
31ccf6a2
 		<para>
e4567684
 		Log level at which accounting messages are issued to syslog.
31ccf6a2
 		</para>
 		<para>
4a19f63f
 		Default value is 1 (L_NOTICE).
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>log_level example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
4a19f63f
 modparam("acc", "log_level", 2)   # Set log_level to 2 (L_INFO)
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.log_facility">
c329cff8
 		<title><varname>log_facility</varname> (string)</title>
 		<para>
 		Log facility to which accounting messages are issued to syslog.
8ebf6bd0
 		This allows to easily separate the accounting specific logging
c329cff8
 		from the other log messages.
 		</para>
 		<para>
 		Default value is LOG_DAEMON.
 		</para>
 		<example>
 		<title>log_facility example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
c329cff8
 modparam("acc", "log_facility", "LOG_DAEMON")
88e2da3c
 ...
c329cff8
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.log_extra">
e4567684
 		<title><varname>log_extra</varname> (string)</title>
 		<para>
 		Extra values to be logged.
f969ffc1
 		See section <xref linkend="acc.i.extra-accounting"/> for more details.
e4567684
 		</para>
 		<para>
 		Default value is NULL.
 		</para>
 		<example>
 		<title>log_extra example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
 	<!-- SQL specific ACC parameters -->
f0f31127
 	<section id="acc.p.db_flag">
31ccf6a2
 		<title><varname>db_flag</varname> (integer)</title>
 		<para>
4a545bac
 		Request flag which needs to be set to account a
e4567684
 		transaction -- database specific.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is not-set (no flag).
31ccf6a2
 		</para>
 		<example>
 		<title>db_flag example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
31ccf6a2
 modparam("acc", "db_flag", 2)
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.db_missed_flag">
31ccf6a2
 		<title><varname>db_missed_flag</varname> (integer)</title>
 		<para>
40905046
 		Request flag which needs to be set to account missed calls via database.
 		This can be used to e.g. account failures during the call setup phase
 		from the callee (client) side, for example if you do forking to several
 		destinations.
 		</para>
 		<para>
 		Keep in mind that this flag is reset after branch completion. Therefore
 		it is necessary to set it again e.g. in a failure_route if you do serial
 		forking and want to log all attempts.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is not-set (no flag).
31ccf6a2
 		</para>
 		<example>
 		<title>db_missed_flag example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
31ccf6a2
 modparam("acc", "db_missed_flag", 3)
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section  id="acc.p.db_table_acc">
e4567684
 		<title><varname>db_table_acc</varname> (string)</title>
31ccf6a2
 		<para>
8ebf6bd0
 		Table name of accounting successful calls -- database specific. It
91d6d3c8
 		can contain config variables that will be evaluated at runtime.
31ccf6a2
 		</para>
 		<para>
e4567684
 		Default value is <quote>acc</quote>
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>db_table_acc example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "db_table_acc", "myacc_table")
91d6d3c8
 modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.db_table_missed_calls">
e4567684
 		<title><varname>db_table_missed_calls</varname> (string)</title>
31ccf6a2
 		<para>
91d6d3c8
 		Table name for accounting missed calls -- database specific. It
 		can contain config variables that will be evaluated at runtime.
31ccf6a2
 		</para>
 		<para>
e4567684
 		Default value is <quote>missed_calls</quote>
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>db_table_missed_calls example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "db_table_missed_calls", "myMC_table")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.db_url">
e4567684
 		<title><varname>db_url</varname> (string)</title>
31ccf6a2
 		<para>
8ebf6bd0
 		SQL address -- database specific. If is set to NULL or empty string,
f063428a
 		the SQL support is disabled.
31ccf6a2
 		</para>
 		<para>
f063428a
 		Default value is <quote>NULL</quote> (SQL disabled).
31ccf6a2
 		</para>
 		<example>
e4567684
 		<title>db_url example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
f0f31127
 modparam("acc", "db_url", "mysql://user:password@localhost/kamailio")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section  id="acc.p.acc_method_column">
8ec042ca
 		<title><varname>acc_method_column</varname> (string)</title>
31ccf6a2
 		<para>
d1dbab43
 		Column name in accounting table to store the request's method name as
8ec042ca
 		string.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>method</quote>.
31ccf6a2
 		</para>
 		<example>
8ec042ca
 		<title>acc_method_column example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_method_column", "method")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_from_tag_column">
8ec042ca
 		<title><varname>acc_from_tag_column</varname> (string)</title>
31ccf6a2
 		<para>
d1dbab43
 		Column name in accounting table to store the From header TAG parameter.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>from_tag</quote>.
31ccf6a2
 		</para>
 		<example>
8ec042ca
 		<title>acc_from_tag_column example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_from_tag_column", "from_tag")
88e2da3c
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_to_tag_column">
8ec042ca
 		<title><varname>acc_to_tag_column</varname> (string)</title>
31ccf6a2
 		<para>
d1dbab43
 		Column name in accounting table to store the To header TAG parameter.
31ccf6a2
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>to_tag</quote>.
31ccf6a2
 		</para>
 		<example>
8ec042ca
 		<title>acc_to_tag_column example</title>
31ccf6a2
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_to_tag_column", "to_tag")
88e2da3c
 ...
567a6f5e
 </programlisting>
 		</example>
31ccf6a2
 	</section>
f0f31127
 	<section id="acc.p.acc_callid_column">
8ec042ca
 		<title><varname>acc_callid_column</varname> (string)</title>
567a6f5e
 		<para>
d1dbab43
 		Column name in accounting table to store the request's Callid value.
567a6f5e
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>callid</quote>.
567a6f5e
 		</para>
 		<example>
8ec042ca
 		<title>acc_callid_column example</title>
567a6f5e
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_callid_column", "callid")
88e2da3c
 ...
567a6f5e
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_sip_code_column">
8ec042ca
 		<title><varname>acc_sip_code_column</varname> (string)</title>
567a6f5e
 		<para>
8ebf6bd0
 		Column name in accounting table to store the final reply's numeric code
8ec042ca
 		value in string format.
567a6f5e
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>sip_code</quote>.
567a6f5e
 		</para>
 		<example>
8ec042ca
 		<title>acc_sip_code_column example</title>
567a6f5e
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_sip_code_column", "sip_code")
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_sip_reason_column">
8ec042ca
 		<title><varname>acc_sip_reason_column</varname> (string)</title>
e4567684
 		<para>
d1dbab43
 		Column name in accounting table to store the final reply's reason
8ec042ca
 		phrase value.
e4567684
 		</para>
 		<para>
8ec042ca
 		Default value is <quote>sip_reason</quote>.
e4567684
 		</para>
 		<example>
8ec042ca
 		<title>acc_sip_reason_column example</title>
e4567684
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "acc_sip_reason_column", "sip_reason")
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.acc_time_column">
e4567684
 		<title><varname>acc_time_column</varname> (string)</title>
 		<para>
4a545bac
 		Column name in accounting table to store the time stamp of the
8ec042ca
 		transaction completion in date-time format.
e4567684
 		</para>
 		<para>
 		Default value is <quote>time</quote>.
 		</para>
 		<example>
 		<title>acc_time_column example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
e4567684
 modparam("acc", "acc_time_column", "time")
88e2da3c
 ...
e4567684
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.db_extra">
8ec042ca
 		<title><varname>db_extra</varname> (string)</title>
e4567684
 		<para>
8ec042ca
 		Extra values to be logged into database - DB specific.
f969ffc1
 		See section <xref linkend="acc.i.extra-accounting"/> for more details.
e4567684
 		</para>
 		<para>
8ec042ca
 		Default value is NULL.
e4567684
 		</para>
 		<example>
8ec042ca
 		<title>db_extra example</title>
e4567684
 		<programlisting format="linespecific">
88e2da3c
 ...
8ec042ca
 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
88e2da3c
 ...
9bd65819
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.db_insert_mode">
9bd65819
 		<title><varname>db_insert_mode</varname> (integer)</title>
 		<para>
 		If set to 1, use INSERT DELAYED to add records to accounting tables
 		when the DB driver has support for it. If no INSERT DELAYED support
d26eff22
 		is offered by DB driver, then standard INSERT is used. Beware that
 		MySQL InnoDB engine doesn't support INSERT DELAYED, thus be sure
 		the acc tables are defined with different type (e.g., MyISAM).
9bd65819
 		</para>
 		<para>
c92ec42a
 		If set to 2, async insert is used if the db driver module has
4a545bac
 		support for it and if async_workers core parameter value is greater
 		than 0. If not, then standard INSERT is used.
c92ec42a
 		</para>
 		<para>
a11a1f4e
 		Default value is 0 (no INSERT DELAYED nor async insert).
9bd65819
 		</para>
 		<example>
 		<title>db_insert_mode example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
9bd65819
 modparam("acc", "db_insert_mode", 1)
88e2da3c
 ...
567a6f5e
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_enable">
bbb6df5d
 		<title><varname>cdr_enable</varname> (integer)</title>
 		<para>
 		Should CDR-based logging be enabled?
 		</para>
 		<para>
70ec02cf
 		0 - off (default).
 		1 - on.
bbb6df5d
 		</para>
 		<example>
 		<title>cdr_enable example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
bbb6df5d
 modparam("acc", "cdr_enable", 1)
88e2da3c
 ...
7bedc588
 </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")
 ...
57177cf1
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.cdr_expired_dlg_enable">
 		<title><varname>cdr_expired_dlg_enable</varname> (integer)</title>
 		<para>
 		Should CDR-based logging be enabled in case of expired dialogs?
 		</para>
 		<para>
 		0 - off (default).
 		1 - on.
 		</para>
 		<example>
 		<title>cdr_expired_dlg_enable example</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "cdr_expired_dlg_enable", 1)
 ...
bbb6df5d
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_start_on_confirmed">
f4aa54a8
 		<title><varname>cdr_start_on_confirmed</varname> (integer)</title>
bbb6df5d
 		<para>
 		Should the start time be taken from the time when the dialog is created,
f0f31127
         	or when the dialog is confirmed?
bbb6df5d
 		</para>
 		<para>
 		0 - use time of dialog creation (default).
 		1 - use time of dialog confirmation.
 		</para>
 		<example>
f4aa54a8
 		<title>cdr_start_on_confirmed example</title>
bbb6df5d
 		<programlisting format="linespecific">
88e2da3c
 ...
f4aa54a8
 modparam("acc", "cdr_start_on_confirmed", 1)
88e2da3c
 ...
bbb6df5d
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_facility">
f4aa54a8
 		<title><varname>cdr_facility</varname> (integer)</title>
bbb6df5d
 		<para>
 		Log facility to which CDR messages are issued to syslog.
 		This allows to easily seperate CDR-specific logging from
 		the other log messages.
 		</para>
 		<para>
 		Default value is LOG_DAEMON.
 		</para>
 		<example>
f4aa54a8
 		<title>cdr_facility example</title>
bbb6df5d
 		<programlisting format="linespecific">
88e2da3c
 ...
f4aa54a8
 modparam("acc", "cdr_facility", "LOG_DAEMON")
88e2da3c
 ...
bbb6df5d
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_extra">
f4aa54a8
 		<title><varname>cdr_extra</varname> (string)</title>
bbb6df5d
 		<para>
 		Set of pseudo-variables defining custom CDR fields. See
f969ffc1
         <xref linkend="acc.i.cdr-extra"/> for more details.
bbb6df5d
 		</para>
 		<para>
 		Default value is NULL.
 		</para>
 		<example>
f4aa54a8
 		<title>cdr_extra example</title>
bbb6df5d
 		<programlisting format="linespecific">
88e2da3c
 ...
f4aa54a8
 modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)"
88e2da3c
 ...
d9913e41
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.cdr_extra_nullable">
 		<title><varname>cdr_extra_nullable</varname> (integer)</title>
 		<para>
 		Should custom CDR fields be saved as NULL?
 		</para>
 		<para>
 		If set to 0, custom CDR fields not defined in config operation (or set to $null) will be saved as empty string.
 		If set to 1, custom CDR fields not defined in config operation (or set to $null) will be saved as NULL.
 		</para>
 		<para>
93934221
 		Database columns may need to be altered to DROP NOT NULL constraints
 		and DROP DEFAULT values in order to accept NULL values.
 		</para>
 		<para>
d9913e41
 		Default value is 0.
 		</para>
 		<example>
 		<title>cdr_extra_nullable example</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "cdr_extra_nullable", 1)
 ...
bbb6df5d
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_start_id">
7b4567c4
 		<title><varname>cdr_start_id</varname> (string)</title>
 		<para>
70ec02cf
 		Modifying the id which is used to store the start time.
7b4567c4
 		</para>
 		<para>
70ec02cf
 		Default value is 'start_time'
7b4567c4
 		</para>
 		<example>
 		<title>cdr_start_id example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
7b4567c4
 modparam("acc", "cdr_start_id", "start")
88e2da3c
 ...
7b4567c4
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_end_id">
7b4567c4
 		<title><varname>cdr_end_id</varname> (string)</title>
 		<para>
70ec02cf
 		Modifying the id which is used to store the end time.
7b4567c4
 		</para>
 		<para>
70ec02cf
 		Default value is 'end_time'
7b4567c4
 		</para>
 		<example>
 		<title>cdr_end_id example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
7b4567c4
 modparam("acc", "cdr_end_id", "end")
88e2da3c
 ...
7b4567c4
 </programlisting>
 		</example>
 	</section>
f0f31127
 	<section id="acc.p.cdr_duration_id">
7b4567c4
 		<title><varname>cdr_duration_id</varname> (string)</title>
 		<para>
70ec02cf
 		Modify the id which is used to store the duration.
7b4567c4
 		</para>
 		<para>
70ec02cf
 		Default value is 'duration'
7b4567c4
 		</para>
 		<example>
 		<title>cdr_duration_id example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
70ec02cf
 modparam("acc", "cdr_duration_id", "d")
88e2da3c
 ...
70ec02cf
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.cdr_log_enable">
367a0e72
 		<title><varname>cdr_log_enable</varname> (int)</title>
70ec02cf
 		<para>
 		Control if CDR-based accounting should be written to syslog.
 		</para>
 		<para>
 		0 - off.
 		1 - on (default).
 		</para>
 		<example>
 		<title>cdr_log_enable example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
70ec02cf
 modparam("acc", "cdr_log_enable", 0)
88e2da3c
 ...
70ec02cf
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.cdrs_table">
 		<title><varname>cdrs_table</varname> (str)</title>
 		<para>
 		Name of db table to store dialog-based CDRs.
 		</para>
 		<para>
 		Default value is "" (no db storage for dialog-based CDRs).
 		</para>
 		<example>
 		<title>cdrs_table example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
70ec02cf
 modparam("acc", "cdrs_table", "acc_cdrs")
88e2da3c
 ...
ea6514c2
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.time_mode">
 		<title><varname>time_mode</varname> (int)</title>
 		<para>
 		Store additional value related to the time of event.
 		</para>
 		<para>
 		Values can be:
 		</para>
 		<itemizedlist>
 		<listitem>
 			<para><emphasis>0</emphasis> -  (default), save only unix
 				timestamp for syslog and datetime for database.</para>
 		</listitem>
 		<listitem>
6dc04484
 			<para><emphasis>1</emphasis> - save seconds in time_attr and
 				microseconds in time_exten.</para>
ea6514c2
 		</listitem>
 		<listitem>
2842990a
 			<para><emphasis>2</emphasis> - save seconds.milliseconds
ea6514c2
 				in time_attr.</para>
 		</listitem>
88e2da3c
 		<listitem>
 			<para><emphasis>3</emphasis> - save formatted time according
49dd734c
 				to time_format parameter, using the output of localtime(). Used for cdr entries too.
88e2da3c
 			</para>
 		</listitem>
 		<listitem>
 			<para><emphasis>4</emphasis> - save formatted time according
49dd734c
 				to time_format parameter, using the output of gmtime(). Used for cdr entries too.
88e2da3c
 			</para>
 		</listitem>
ea6514c2
 		</itemizedlist>
 
 		<example>
 		<title>time_mode example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
ea6514c2
 modparam("acc", "time_mode", 1)
88e2da3c
 ...
ea6514c2
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.time_attr">
 		<title><varname>time_attr</varname> (str)</title>
 		<para>
 		Name of the syslog attribute or database column where to store additional
 		value related to the time of event.
 		</para>
 		<para>
 		For db accounting, the column has to be of different types, depending on
 		time_mode value. When time_mode is:
 		</para>
 		<itemizedlist>
 		<listitem>
 			<para><emphasis>1</emphasis> - time_attr column has to be int.</para>
 		</listitem>
 		<listitem>
 			<para><emphasis>2</emphasis> - time_attr column has to be double.</para>
 		</listitem>
88e2da3c
 		<listitem>
 			<para><emphasis>3</emphasis> - time_attr column has to be varchar(128).</para>
 		</listitem>
 		<listitem>
 			<para><emphasis>4</emphasis> - time_attr column has to be varchar(128).</para>
 		</listitem>
ea6514c2
 		</itemizedlist>
6dc04484
 		<para>
 		For time_mode=1, this attribute is not written in syslog, because time
 		value is already unix timestamp, but in db accounting time value is
 		datetime and requires a function to get the timestamp.
 		</para>
ea6514c2
 		<example>
 		<title>time_attr example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
6dc04484
 modparam("acc", "time_attr", "seconds")
88e2da3c
 ...
6dc04484
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.time_exten">
 		<title><varname>time_exten</varname> (str)</title>
 		<para>
 		Name of the syslog attribute or database column where to store extended
 		value related to the time of event.
 		</para>
 		<para>
 		It is used now only for time_mode=1 and database column has to be int:
 		</para>
 		<example>
 		<title>time_exten example</title>
 		<programlisting format="linespecific">
88e2da3c
 ...
2842990a
 modparam("acc", "time_exten", "microsecs")
88e2da3c
 ...
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.time_format">
 		<title><varname>time_format</varname> (str)</title>
 		<para>
 		Specify the format to print the time for time_mode 3 or 4.
 		</para>
 		<para>
 		Default value is %Y-%m-%d %H:%M:%S".
 		</para>
 		<example>
 		<title>time_format example</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S")
 ...
7f136429
 </programlisting>
 		</example>
 	</section>
6214fe87
 	<section id="acc.p.reason_from_hf">
 		<title><varname>reason_from_hf</varname> (int)</title>
7f136429
 		<para>
 		Tells where to take sip_reason from.  If value is 0,
 		sip_reason is taken from status line.  Otherwise, sip_reason
 		is taken from Reason header field(s) if present.
 		Currently only the first Reason header is used.
 		</para>
 		<para>
 		Default value is 0.
 		</para>
 		<example>
6214fe87
 		<title>reason_from_hf</title>
7f136429
 		<programlisting format="linespecific">
 ...
6214fe87
 modparam("acc", "reason_from_hf", 1)
7f136429
 ...
941de2f0
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.clone_msg">
 		<title><varname>clone_msg</varname> (int)</title>
 		<para>
 		If set to 1, request structure from transaction is cloned temporarily
 		in the callback to get acc attributes. It is required if you account
8ebf6bd0
 		values from SIP headers to avoid concurrent access to the shared memory
941de2f0
 		transaction structure, specially when accounting 1xx events. If set to
 		0, it uses directly the shared memory structure, be sure you store all
 		needed attributes in AVPs/XAVPs inside request route.
 		</para>
 		<para>
 		Default value is 1.
 		</para>
 		<example>
 		<title>clone_msg</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "clone_msg", 0)
 ...
0e30a2d5
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.p.cdr_on_failed">
 		<title><varname>cdr_on_failed</varname> (int)</title>
 		<para>
 		If set to 1, the module stores the CDR for a failed dialog (calls not
 		answered). If set to 0, those records are not stored, only those for
 		answered calls.
 		</para>
 		<para>
 		Default value is 1.
 		</para>
 		<example>
 		<title>cdr_on_failed</title>
 		<programlisting format="linespecific">
 ...
 modparam("acc", "cdr_on_failed", 0)
 ...
7b4567c4
 </programlisting>
 		</example>
 	</section>
567a6f5e
 	</section>
 
31ccf6a2
 	<section>
9114eebc
 	<title>Functions</title>
1e82ef70
 	<section id="acc.f.acc_log_request">
e4567684
 		<title>
 			<function moreinfo="none">acc_log_request(comment)</function>
 		</title>
 		<para>
4a545bac
 		<function moreinfo="none">acc_request</function> reports on a request,
 		for example, it can be used to report on missed calls to off-line users
 		who are replied 404 - Not Found. To avoid multiple reports on UDP
e4567684
 		request retransmission, you would need to embed the
31ccf6a2
 		action in stateful processing.
4a545bac
 		</para>
31ccf6a2
 		<para>
 		Meaning of the parameters is as follows:</para>
 		<itemizedlist>
 		<listitem>
 			<para><emphasis>comment</emphasis> - Comment to be appended.
1e82ef70
 			The string can contain any number of pseudo-variables.
31ccf6a2
 			</para>
 		</listitem>
 		</itemizedlist>
7b56ffd7
 		<para>
8858e0d2
 		This function can be used from ANY_ROUTE.
7b56ffd7
 		</para>
31ccf6a2
 		<example>
 		<title>acc_log_request usage</title>
 		<programlisting format="linespecific">
 ...
 acc_log_request("Some comment");
1e82ef70
 $var(code) = 404;
 $avp(reason) = "Not found";
 acc_log_request("$var(code) Error: $avp(reason)");
31ccf6a2
 ...
 </programlisting>
 		</example>
 	</section>
1e82ef70
 	<section id="acc.f.acc_db_request">
e4567684
 		<title>
 			<function moreinfo="none">acc_db_request(comment, table)</function>
 		</title>
31ccf6a2
 		<para>
4a545bac
 		Like <function moreinfo="none">acc_log_request</function>,
 		<function moreinfo="none">acc_db_request</function> reports on a
 		request. The report is sent to database at <quote>db_url</quote>, in
e4567684
 		the table referred to in the second action parameter.
31ccf6a2
 		</para>
 		<para>
 		Meaning of the parameters is as follows:
 		</para>
 		<itemizedlist>
 		<listitem>
1e82ef70
 			<para><emphasis>comment</emphasis> - Comment to be appended.
 			The string can contain any number of pseudo-variables.
 			</para>
31ccf6a2
 		</listitem>
 		<listitem>
91d6d3c8
 			<para><emphasis>table</emphasis> - Database table to be used. It
 			can contain config variables that are evaluated at runtime.</para>
31ccf6a2
 		</listitem>
 		</itemizedlist>
7b56ffd7
 		<para>
8858e0d2
 		This function can be used from ANY_ROUTE.
7b56ffd7
 		</para>
31ccf6a2
 		<example>
 		<title>acc_db_request usage</title>
 		<programlisting format="linespecific">
 ...
3bd01c03
 acc_db_request("Some comment", "SomeTable");
 acc_db_request("Some comment", "acc_$time(year)_$time(mon)");
1e82ef70
 acc_db_request("$var(code) Error: $avp(reason)", "SomeTable");
31ccf6a2
 ...
4a545bac
 </programlisting>
 		</example>
 	</section>
 	<section id="acc.f.acc_request">
 		<title>
 			<function moreinfo="none">acc_request(comment, table)</function>
 		</title>
 		<para>
e875863f
 		Wrapper around <function moreinfo="none">acc_log_request</function>
4a545bac
 		and <function moreinfo="none">acc_db_request</function> functions,
 		writing the accounting record to LOG and DATABASE backends. If
 		<quote>db_url</quote> parameter is not set, the acc record is written
 		only to LOG backend.
 		</para>
 		<para>
 		Meaning of the parameters is as follows:
 		</para>
 		<itemizedlist>
 		<listitem>
 			<para><emphasis>comment</emphasis> - Comment to be used for
 			generating the SIP response code and text fields, if in the
 			format <quote>CODE TEXT</quote>. The CODE should be a valid
 			SIP response code (100..699). The TEXT can be one or many words.
 			If CODE is missing, then 0 is used.
 			The parameter can contain pseudo-variables.
 			</para>
 		</listitem>
 		<listitem>
 			<para><emphasis>table</emphasis> - Database table to be used. It
 			can contain config variables that are evaluated at runtime.</para>
 		</listitem>
 		</itemizedlist>
 		<para>
 		This function can be used from ANY_ROUTE.
 		</para>
 		<example>
 		<title>acc_db_request usage</title>
 		<programlisting format="linespecific">
 ...
 acc_request("100 Received", "acc");
 acc_request("100 Received", "acc_$time(year)_$time(mon)");
 acc_db_request("$var(code) $avp(reason)", "acc");
 ...
31ccf6a2
 </programlisting>
 		</example>
 	</section>
 	</section>
 </chapter>