0a67b2e89261682dbab9059ed2231bea63737d0e
[sip-router] / src / modules / acc / doc / acc_admin.xml
1 <?xml version="1.0" encoding='ISO-8859-1'?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
5 <!-- Include general documentation entities -->
6 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
7 %docentities;
8
9 ]>
10
11 <!-- Acc Module User's Guide -->
12
13 <chapter>
14         
15         <title>&adminguide;</title>
16         
17         <section>
18         <title>Overview</title>
19         <para>
20                 ACC module is used to account transactions information to different
21                 backends like syslog, <abbrev>SQL</abbrev>,
22                 <acronym>RADIUS</acronym> and <acronym>DIAMETER</acronym> 
23                 (beta version).
24         </para>
25         <para>
26                 To account a transaction and to choose which set of backends to be 
27                 used, the script writer just has to set some flags (see the module
28                 parameters section for flag definitions <xref linkend="acc.i.params"/>).
29                 If the accounting flag for a specific backend is set, the acc module 
30                 will then report on completed transaction. A typical usage of the 
31                 module takes no acc-specific script command -- the functionality 
32                 binds invisibly through transaction processing. Script writers just 
33                 need to mark the transaction for accounting with proper setflag. 
34                 Even so, the module allows the script writter to force accounting in 
35                 special cases via some script functions.
36         </para>
37         <para>
38                 The accounting module will log by default a fixed set of attributes 
39                 for the transaction - if you customize your accounting by adding more
40                 information to be logged, please see the next chapter about extra
41                 accounting - <xref linkend="acc.i.extra-accounting"/>.
42         </para>
43         <para>
44                 The fixed minimal accounting information is: 
45                 <itemizedlist>
46                 <listitem>
47                         <para>Request Method name</para>
48                 </listitem>
49                 <listitem>
50                         <para>From header TAG parameter</para>
51                 </listitem>
52                 <listitem>
53                         <para>To header TAG parameter</para>
54                 </listitem>
55                 <listitem>
56                         <para>Call-Id</para>
57                 </listitem>
58                 <listitem>
59                         <para>3-digit Status code from final reply</para>
60                 </listitem>
61                 <listitem>
62                         <para>Reason phrase from final reply</para>
63                 </listitem>
64                 <listitem>
65                         <para>Time stamp when transaction was completed</para>
66                 </listitem>
67                 </itemizedlist>
68                 If a value is not present in request, the empty string is accounted 
69                 instead.
70         </para>
71         <para>
72                 Note that:
73                 <itemizedlist>
74                 <listitem>
75                         <para>
76                         A single INVITE may produce multiple accounting reports -- that's
77                         due to SIP forking feature.
78                         </para>
79                 </listitem>
80                 <listitem>
81                         <para>
82                         All flags related to accounting need to be set in request processing
83                         route - only the "missed-call" flag may be toggled from other
84                         types of routes.
85                         </para>
86                 </listitem>
87                 <listitem>
88                         <para>
89                         If a UA fails in middle of conversation, a proxy will never 
90                         find out about it. In general, a better practice is to account from an 
91                         end-device (such as PSTN gateway), which best knows about call 
92                         status (including media status and PSTN status in case of the 
93                         gateway). However, CDR-base logging has the option to log existing
94                         information from expired dialogs (the dlg_vars in cdr_extra)
95                         Please see cdr_expired_dlg_enable parameter - <xref linkend="acc.p.cdr_expired_dlg_enable"/>.
96                         </para>
97                 </listitem>
98                 </itemizedlist>
99         </para>
100         <para>
101                 The SQL backend support is compiled in the module. For RADIUS and
102                 DIAMETER you need to enable it by recompiling the module with properly
103                 set defines: uncomment the RAD_ACC or DDIAM_ACC lines in
104                 modules/acc/Makefile. To compile RADIUS support, 
105                 you need to have radiusclient-ng (only versions higher or equal 
106                 to 0.5.0) installed on your system which is available from
107                 <ulink url='http://developer.berlios.de/projects/radiusclient-ng/'>
108                 http://developer.berlios.de/projects/radiusclient-ng/</ulink>.
109                 The radius client needs to be configured properly. To do so, use the 
110                 template at etc/radiusclient.conf and make sure
111                 that module's radius_config parameter points to its location.
112                 In particular, accounting secret must match that one configured in
113                 server and proper dictionary is used (one is available at 
114                 etc/sip_dictionary). Also note that Debian radiusclient-ng uses
115                 /var/run/radius.seq as seqfile but &kamailio; Debian init script expects
116                 /var/run/kamailio/kamailio_radius.seq, so is needed to change it in
117                 radiusclient-ng configuration or in &kamailio; Debian init script (if not,
118                 &kamailio; can't create the seq file when not running as root). Uses along
119                 with FreeRadius (<ulink url='http://www.freeradius.org/'>
120                 http://www.freeradius.org/</ulink>) and Radiator 
121                 (<ulink url='http://www.open.com.au/radiator/'>
122                 http://www.open.com.au/radiator/</ulink>) servers have been
123                 reported to us.
124         </para>
125         <para>
126         NOTE: diameter support was developed for DISC (DIameter Server Client 
127         project at http://developer.berlios.de/projects/disc/). This project 
128         seems to be no longer maintained and DIAMETER specifications were updated
129         in the meantime. Thus, the DIAMETER part in the module is obsolete and 
130         needs rework to be usable with opendiameter or other DIAMETER servers.
131         </para>
132         <section>
133                 <title>General Example</title>
134                 <programlisting format="linespecific">
135 loadmodule "modules/acc/acc.so"
136 modparam("acc", "log_level", 1)
137 modparam("acc", "log_flag", 1)
138
139 if (uri=~"sip:+40") /* calls to Romania */ {
140     if (!proxy_authorize("sip_domain.net" /* realm */,
141     "subscriber" /* table name */))  {
142         proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );
143         exit;
144     }
145
146     if (method=="INVITE" &amp;&amp; !check_from()) {
147         log("from!=digest\n");
148         sl_send_reply("403","Forbidden");
149     }
150
151     setflag(1); /* set for accounting (the same value as in log_flag!)
152     t_relay();  /* enter stateful mode now */
153 };
154 </programlisting>
155         </section>
156         </section>
157
158         <section id="acc.i.extra-accounting">
159                 <title>Extra accounting</title>
160                 <section>
161                         <title>Overview</title>
162                         <para>
163                         Along the static default information, ACC modules 
164                         allows dynamical selection of extra information to be logged. 
165                         This allows you to log any pseudo-variable (AVPs, parts of 
166                         the request, etc).
167                         </para>
168                 </section>
169                 <section id="acc-def-syn">
170                         <title>Definitions and syntax</title>
171                         <para>
172                         Selection of extra information is done via 
173                         <emphasis>xxx_extra</emphasis> parameters by specifying the names
174                         of additional information you want to log. This information is 
175                         defined via pseudo-variables and may include headers, AVPs values
176                         or other message or system values. The syntax of the parameter is:
177                         </para>
178                         <itemizedlist>
179                                 <listitem><para><emphasis>
180                                 xxx_extra = extra_definition (';'extra_definition)*
181                                 </emphasis></para></listitem>
182                                 <listitem><para><emphasis>
183                                 extra_definition = log_name '=' pseudo_variable
184                                 </emphasis></para></listitem>
185                         </itemizedlist>
186                         <para>
187                         The full list of supported pseudo-variables in &kamailio; is
188                         available at: 
189                         <ulink url="http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables">
190                         http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables</ulink>
191                         </para>
192                         <para>
193                         Note: For all the ACK processed by tm, the registered callbacks
194                         (like acc module) will be called with the corresponding INVITE
195                         transaction contexts as long as this is still available. This means
196                         that the ACK callbacks will see the AVPs setup for the INVITE
197                         transaction and not the AVPs setup before t_relay().
198                         </para>
199                         <para>
200                         Via <emphasis>log_name</emphasis> you define how/where the 
201                         <emphasis>data</emphasis> will be logged. Its meaning depends 
202                         of the accounting support which is used:
203                         <itemizedlist>
204                                 <listitem><para><emphasis>LOG accounting</emphasis> - log_name
205                                 will be just printed along with the data in <emphasis>
206                                 log_name=data</emphasis> format;
207                                 </para></listitem>
208                                 <listitem><para><emphasis>DB accounting</emphasis> - log_name 
209                                 will be the name of the DB column where the data will be 
210                                 stored.<emphasis>IMPORTANT</emphasis>: add in db 
211                                 <emphasis>acc</emphasis> table the columns corresponding to 
212                                 each extra data;
213                                 </para></listitem>
214                                 <listitem><para><emphasis>RADIUS accounting</emphasis> - 
215                                 log_name will be the AVP name used for packing the data into 
216                                 RADIUS message. The log_name will be translated to AVP number 
217                                 via the dictionary. <emphasis>IMPORTANT</emphasis>: add in 
218                                 RADIUS dictionary the <emphasis>log_name</emphasis> attribute.
219                                 </para></listitem>
220                                 <listitem><para><emphasis>DIAMETER accounting</emphasis> - 
221                                 log_name will be the AVP code used for packing the data 
222                                 into DIAMETER message. The AVP code is given directly as 
223                                 integer, since DIAMETER has no dictionary support yet.
224                                 <emphasis>IMPORTANT</emphasis>: <emphasis>log_name</emphasis>
225                                 must be a number.
226                                 </para></listitem>
227                         </itemizedlist>
228                         </para>
229                 </section>
230                 <section>
231                         <title>How it works</title>
232                         <para>
233                         Some pseudo variables may return more than one value (like 
234                         headers or AVPs). In this case, the returned values are
235                         embedded in a single string in a comma-separated format.
236                         </para>
237                 </section>
238         </section>
239
240         <section id="acc.i.multi-call-legs">
241                 <title>Multi Call-Legs accounting</title>
242                 <section>
243                         <title>Overview</title>
244                         <para>
245                         A SIP call can have multiple legs due forwarding actions. For 
246                         example user A calls user B which forwards the call to user C. 
247                         There is only one SIP call but with 2 legs ( A to B and B to C). 
248                         Accounting the legs of a call is required for proper billing of 
249                         the calls (if C is a PSTN number and the call is billed, user B 
250                         must pay for the call - as last party modifing the call 
251                         destination-, and not A - as initiator of the call. Call 
252                         forwarding on server is only one example which shows the 
253                         necessity of the having an accounting engine with multiple legs 
254                         support.
255                         </para>
256                 </section>
257                 <section>
258                         <title>Configuration</title>
259                         <para>
260                         First how it works: The idea is to have a set of AVPs and for each
261                         call leg to store a set of values in the AVPs. The meaning of
262                         the AVP content is stricly decided by the script writer - it can
263                         be the origin and source of the leg, its status or any other 
264                         related information. If you have a set of 4 AVPS (AVP1, AVP2, AVP3,
265                         AVP4), then for the "A call B and B forwards to C" example, 
266                         you need to set a different set of values for the AVPs
267                         for each leg ([A,B] and [B,C]) .
268                         The script writer must take care and properly insert all 
269                         these AVP from the script (in proper order and with the correct type).
270                         </para>
271                         <para>
272                         When the accounting information for the call will be written/sent, 
273                         all the call-leg pairs will be added (based on the found AVP sets).
274                         </para>
275                         <para>
276                         By default, the multiple call-leg support is disabled - it can be
277                         enabled just be setting the per-leg set of AVPs via the 
278                         <varname>multi_leg_info</varname> module parameter.
279                         </para>
280                 </section>
281                 <section>
282                         <title>Logged data</title>
283                         <para>
284                         For each call, all the values of the AVP set (which defines a 
285                         call-leg) will be logged. How the information will be actually
286                         logged, depends of the data backend:
287                         </para>
288                         <itemizedlist>
289                                 <listitem>
290                                 <para><emphasis>syslog</emphasis> -- all leg-sets will be added
291                                 to one record string as AVP1=xxx, AVP2=xxxx ,... sets.
292                                 </para>
293                                 </listitem>
294                                 <listitem>
295                                 <para><emphasis>database</emphasis> -- each pair will be 
296                                 separately logged (due DB data structure constraints); several
297                                 records will be written, the difference between them being 
298                                 only the fields corresponding to the call-leg info.
299                                 </para>
300                                 <note><para>You will need to add in your DB (all acc related
301                                 tables) the colums for call-leg info (a column for each AVP
302                                 of the set).
303                                 </para></note>
304                                 </listitem>
305                                 <listitem>
306                                 <para><emphasis>Radius</emphasis> -- all sets will be added
307                                 to the same Radius accounting message as RADIUS AVPs - for each
308                                 call-leg a set of RADIUS AVPs will be added (corresponding
309                                 to the per-leg AVP set)
310                                 </para>
311                                 <note><para>You will need to add in your dictionary the
312                                 RADIUS AVPs used in call-leg AVP set definition.
313                                 </para></note>
314                                 </listitem>
315                                 <listitem>
316                                 <para><emphasis>Diameter</emphasis> same as for RADIUS.
317                                 </para>
318                                 </listitem>
319                         </itemizedlist>
320                 </section>
321         </section>
322         <section>
323                 <title>Call Data Record generation</title>
324         <section>
325             <title>Overview</title>
326                 <para>
327                 In addition to transaction-based logging, it is possible to generate and log Call Data
328                 Records (CDRs) directly from &kamailio;. Apart from a basic set of CDR fields which
329                 are always included (covering start time, end time, and duration), the approach allows
330                 flexible specification of additional fields that should be taken into account using
331                 the configuration script. This is very similar to how transaction-based logging may
332                 be customized with the exception that CDRs rely on dialogs instead of transactions
333                 to store relevant information during a call.
334                 </para>
335
336                 <para>
337                 In order to set up CDR generation, you must enable the CDR switch and load the dialog
338                 module. You probably also want to specify a set of pseudo-variables that define more
339                 relevant CDR fields. Pseudo-variables may be assigned arbitrarily during script
340                 execution, and the module will make sure that the variable content will be transformed
341                 into a CDR by the end of the dialog.
342                 </para>
343
344                 <para>
345                 To use CDR logging in a correct manner, you should only use the dialog-based
346                 pseudo-variables (dlg_var) from the dialog module. This allows you to save values
347                 right from the beginning through all requests and replies until termination of the
348                 call. While not recommended, it is still possible to use other pseudo-variables as
349                 well. Except for pseudo-variables valid in the call-final transaction, however,
350                 information given will not be stored in the CDR as they cannot be accessed by the
351                 end of the call when the CDR is logged.
352                 </para>
353
354                 <para>
355                                 Sometimes, dialogs expire because the UA has a problem and a final message is never
356                                 transmitted. You can toggle on/off the generation of CDR-based logging in such cases
357                                 with only the dlg_vars showing by using the cdr_expired_dlg_enable parameter
358                                 - <xref linkend="acc.p.cdr_expired_dlg_enable"/>. Default behavior is not logging.
359                 </para>
360         </section>
361                 <section id="acc.i.cdr-extra">
362                         <title>CDR Extra</title>
363                                         This section is similar to the <quote>LOG accounting</quote> part of
364                                         <xref linkend="acc.i.extra-accounting"/>.
365                         <section>
366                                 <title>Definitions and syntax</title>
367                                         <para>
368                                         Selection of extra information is done similar to the transaction extra
369                                         <xref linkend="acc-def-syn"/>.
370                                         </para>
371                                         <itemizedlist>
372                                                 <listitem><para><emphasis>
373                                                 cdr_extra = cdr_extra_definition (';'cdr_extra_definition)*
374                                                 </emphasis></para></listitem>
375                                                 <listitem><para><emphasis>
376                                                 cdr_extra_definition = cdr_log_name '=' pseudo_variable
377                                                 </emphasis></para></listitem>
378                                         </itemizedlist>
379                                         See also <xref linkend="acc.p.cdr_extra"/>.
380                                         <para>
381                                         The full list of supported pseudo-variables in Sip-Router is
382                                         available at:
383                                         <ulink url="http://sip-router.org/wiki/cookbooks/pseudo-variables/devel">
384                                         http://sip-router.org/wiki/cookbooks/pseudo-variables/devel</ulink>
385                                         </para>
386                         </section>
387                 </section>
388                 <section id="multi-cdr-call-legs">
389                         <title>CDR with Multi Call-Legs</title>
390                         <section>
391                                 <title>Overview</title>
392                                 <para>
393                                 As mentioned in <xref linkend="acc.i.multi-call-legs"/>, a leg represents a parallel
394                                 or forwarded call. In contrast to the normal accounting the cdr logging uses dialogs
395                                 instead of transaction to log data. This may reduce the amount of information 
396                                 but it also make it possible to combine all important data in one cdr at 
397                                 once. A second mechanism to process multiple data-sets into one cdr is not further
398                                 necessary.
399                                 </para>
400                         </section>
401                         <section>
402                                 <title>Configuration</title>
403                                 <para>
404                                 When you route messages multiple times through your proxy (e.g. to
405                                 handle <quote>call-forwardings</quote>) you have to use detect_spirals
406                                 from the dialog modules. Otherwise the proxy can't identify and reuse existing
407                                 dialogs.
408                                 </para>
409                                 <para>
410                                 To get the correct call-forwarding-chain you have to store each cf* with the
411                                 corresponding caller and callee in a dialog based pseudo-variable (dlg_var)
412                                 (e.g. chain=B;cfa;C|C;cfnr;D). Additionally it is necessary to store the
413                                 caller and callee for each leg. All this helps to identify the involved
414                                 phone parners and forwarding chain. When you route such calls multiple times
415                                 to the same Proxy, you could store the caller and callee within an transaction
416                                 based avp and write it into the dialog based dlg_var pv during a 200 INVITE.
417                                 </para>
418                                 <section>
419                                         <title>Example for a spiraled Proxy</title>
420                                         <programlisting format="linespecific">
421 ...
422 # A calls B (transaction 1)
423 $avp(caller)='A'
424 $avp(callee)='B';
425 $dlg_var(chain)='';
426
427 # B cfa C (transaction 2)
428 $avp(caller)='B'
429 $avp(callee)='C';
430 $dlg_var(chain)='B;cfu;C';
431
432 # C cfnr D (transaction 3)
433 $avp(caller)='C'
434 $avp(callee)='D';
435 $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D";
436
437 # C confirms call (200 reply of transaction 2)
438 $dlg_var(caller) = $avp(caller); #caller='B'
439 $dlg_var(callee) = $avp(callee); #callee='C'
440 ...
441                                         </programlisting>
442                                 </section>
443                         </section>
444                         <section>
445                                 <title>Logged data</title>
446                                 For each call, all dialog corresponding variables will be logged. After a call
447                                 is finished, the generated call data record information will be logged as string
448                                 (VAR1=xxx,VAR2=xxxx,...) to the syslog.
449                         </section>
450                 </section>
451         </section>
452         <section>
453                 <title>Dependencies</title>
454                 <section>
455                         <title>&kamailio; Modules</title>
456                         <para>
457                         The module depends on the following modules (in the other words 
458                         the listed modules must be loaded before this module):
459                         <itemizedlist>
460                                 <listitem>
461                                 <para><emphasis>tm</emphasis> -- Transaction Manager</para>
462                                 </listitem>
463                                 <listitem>
464                                 <para><emphasis>a database module</emphasis> -- If SQL 
465                                 support is used.</para>
466                                 </listitem>
467                                 <listitem>
468                                 <para><emphasis>rr</emphasis> -- Record Route, if 
469                                 <quote>detect_direction</quote> module parameter is enabled.
470                                 </para>
471                                 </listitem>
472                                 <listitem>
473                                 <para><emphasis>dialog</emphasis> -- Dialog, if
474                                 <quote>cdr_enable</quote> module parameter is enabled.
475                                 </para>
476                                 </listitem>
477                         </itemizedlist>
478                         </para>
479                 </section>
480                 <section>
481                         <title>External Libraries or Applications</title>
482                         <para>
483                         The following libraries or applications must be installed 
484                         before running &kamailio; with this module loaded:
485                         </para>
486                         <itemizedlist>
487                                 <listitem>
488                                 <para><emphasis>radiusclient-ng</emphasis> 0.5.0 or higher -- 
489                                 if compiled with RADIUS support. See <ulink 
490                                 url='http://developer.berlios.de/projects/radiusclient-ng/'>
491                                 http://developer.berlios.de/projects/radiusclient-ng/</ulink>.
492                                 </para>
493                                 </listitem>
494                         </itemizedlist>
495                 </section>
496         </section>
497
498         <section id="acc.i.params">
499         <title>Parameters</title>
500         <!-- Generic ACC parameters -->
501         <section id="acc.p.early_media">
502                 <title><varname>early_media</varname> (integer)</title>
503                 <para>
504                 Should be early media (any provisional reply with body) accounted too ?
505                 </para>
506                 <para>
507                 Default value is 0 (no).
508                 </para>
509                 <example>
510                 <title>early_media example</title>
511                 <programlisting format="linespecific">
512 ...
513 modparam("acc", "early_media", 1)
514 ...
515 </programlisting>
516                 </example>
517         </section>
518         <section id="acc.p.failed_transaction_flag">
519                 <title><varname>failed_transaction_flag</varname> (integer)</title>
520                 <para>
521                 Per transaction flag which says if the transaction should be 
522                 accounted also in case of failure (status>=300).
523                 </para>
524                 <para>
525                 Default value is not-set (no flag).
526                 </para>
527                 <example>
528                 <title>failed_transaction_flag example</title>
529                 <programlisting format="linespecific">
530 ...
531 modparam("acc", "failed_transaction_flag", 4)
532 ...
533 </programlisting>
534                 </example>
535         </section>
536         <section id="acc.p.failed_filter">
537                 <title><varname>failed_filter</varname> (string)</title>
538                 <para>
539                 A string of failure response codes from 300 to 999
540                 separated by commas. Failed transaction will not be accounted
541                 if its response code is in the list even when
542                 failed_transaction_flag is set. 
543                 </para>
544                 <para>
545                 Default value is not-set (failure filtering is off).
546                 </para>
547                 <example>
548                 <title>failed_filter example</title>
549                 <programlisting format="linespecific">
550 ...
551 modparam("acc", "failed_filter", "404,407")
552 ...
553 </programlisting>
554                 </example>
555         </section>
556         <section id="acc.p.report_ack">
557                 <title><varname>report_ack</varname> (integer)</title>
558                 <para>
559                 Shall acc attempt to account e2e ACKs too ? Note that this is really 
560                 only an attempt, as e2e ACKs may take a different path 
561                 (unless RR enabled) and mismatch original INVITE (e2e ACKs are 
562                 a separate transaction). The flag for accounting has to be set
563                 for each ACK as well.
564                 </para>
565                 <para>
566                 Default value is 0 (no).
567                 </para>
568                 <example>
569                 <title>report_ack example</title>
570                 <programlisting format="linespecific">
571 ...
572 modparam("acc", "report_ack", 1)
573 ...
574 </programlisting>
575                 </example>
576         </section>
577         <section id="acc.p.report_cancels">
578                 <title><varname>report_cancels</varname> (integer)</title>
579                 <para>
580                 By default, CANCEL reporting is disabled -- most accounting
581                 applications wants to see INVITE's cancellation status.
582                 Turn on if you explicitly want to account CANCEL transactions.
583                 </para>
584                 <para>
585                 Default value is 0 (no).
586                 </para>
587                 <example>
588                 <title>report_cancels example</title>
589                 <programlisting format="linespecific">
590 ...
591 modparam("acc", "report_cancels", 1)
592 ...
593 </programlisting>
594                 </example>
595         </section>
596         <section id="acc.p.detect_direction">
597                 <title><varname>detect_direction</varname> (integer)</title>
598                 <para>
599                 Controlles the direction detection for sequential requests. If 
600                 enabled (non zero value), for sequential requests with upstream
601                 direction (from callee to caller), the FROM and TO will be swapped
602                 (the direction will be preserved as in the original request).
603                 </para>
604                 <para>
605                 It affects all values related to TO and FROM headers (body, URI, 
606                 username, domain, TAG).
607                 </para>
608                 <para>
609                 Default value is 0 (disabled).
610                 </para>
611                 <example>
612                 <title>detect_direction example</title>
613                 <programlisting format="linespecific">
614 ...
615 modparam("acc", "detect_direction", 1)
616 ...
617 </programlisting>
618                 </example>
619         </section>
620         <section id="acc.p.acc_prepare_flag">
621                 <title><varname>acc_prepare_flag</varname> (integer)</title>
622                 <para>
623                 Per transaction flag which says if the transaction may be accounted
624                 later, with flags set in TM module specific routes (e.g., like
625                 failure_route). If this flag is not set and acc or missed_call flag
626                 are not set either in request route block, there is no way to mark the
627                 request for transaction later unless you set acc_prepare_always. If either acc or missed_call flags are
628                 set in request route block, there is no need to set this flag.
629                 </para>
630                 <para>
631                 Default value is not-set (no flag).
632                 </para>
633                 <example>
634                 <title>acc_prepare_flag example</title>
635                 <programlisting format="linespecific">
636 ...
637 modparam("acc", "acc_prepare_flag", 5)
638 ...
639 </programlisting>
640                 </example>
641         </section>
642         <section id="acc.p.acc_prepare_always">
643                 <title><varname>acc_prepare_always</varname> (integer)</title>
644                 <para>
645                 Prepare all request even if acc_prepare_flag is not set to mark the request for transaction later.
646                 </para>
647                 <para>
648                 Default value is not-set (previous behaviour).
649                 </para>
650                 <example>
651                 <title>acc_prepare_flag example</title>
652                 <programlisting format="linespecific">
653 ...
654 modparam("acc", "acc_prepare_always", 1)
655 ...
656 </programlisting>
657                 </example>
658         </section>
659         <section id="acc.p.multi_leg_info">
660                 <title><varname>multi_leg_info</varname> (string)</title>
661                 <para>
662                 Defines the AVP set to be used in per-call-leg accounting.
663                 See <xref linkend="acc.i.multi-call-legs"/> for a 
664                 detailed description of the Multi Call-Legs accounting.
665                 </para>
666                 <para>
667                 If empty, the multi-leg accounting support will be disabled.
668                 </para>
669                 <para>
670                 Default value is 0 (disabled).
671                 </para>
672                 <example>
673                 <title>multi_leg_info example</title>
674                 <programlisting format="linespecific">
675 ...
676 # for syslog-based accounting, use any text you want to be printed
677 modparam("acc", "multi_leg_info",
678     "text1=$avp(src);text2=$avp(dst)")
679 # for mysql-based accounting, use the names of the columns
680 modparam("acc", "multi_leg_info",
681     "leg_src=$avp(src);leg_dst=$avp(dst)")
682 # for RADIUS-based accounting, use the names of the RADIUS AVPs
683 modparam("acc", "multi_leg_info",
684     "RAD_LEG_SRC=$avp(src);RAD_LEG_SRC=$avp(dst)")
685 # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer)
686 modparam("acc", "multi_leg_info",
687     "2345=$avp(src);2346=$avp(dst)")
688 ...
689 </programlisting>
690                 </example>
691         </section>
692         <!-- SYSLOG specific ACC parameters -->
693         <section id="acc.p.log_flag">
694                 <title><varname>log_flag</varname> (integer)</title>
695                 <para>
696                 Request flag which needs to be set to account a transaction via syslog.
697                 </para>
698                 <para>
699                 Default value is not-set (no flag).
700                 </para>
701                 <example>
702                 <title>log_flag example</title>
703                 <programlisting format="linespecific">
704 ...
705 modparam("acc", "log_flag", 2)
706 ...
707 </programlisting>
708                 </example>
709         </section>
710         <section id="acc.p.log_missed_flag">
711                 <title><varname>log_missed_flag</varname> (integer)</title>
712                 <para>
713                 Request flag which needs to be set to account missed calls via syslog.
714                 </para>
715                 <para>
716                 Default value is not-set (no flag).
717                 </para>
718                 <example>
719                 <title>log_missed_flag example</title>
720                 <programlisting format="linespecific">
721 ...
722 modparam("acc", "log_missed_flag", 3)
723 ...
724 </programlisting>
725                 </example>
726         </section>
727         <section id="acc.p.log_level">
728                 <title><varname>log_level</varname> (integer)</title>
729                 <para>
730                 Log level at which accounting messages are issued to syslog.
731                 </para>
732                 <para>
733                 Default value is L_NOTICE.
734                 </para>
735                 <example>
736                 <title>log_level example</title>
737                 <programlisting format="linespecific">
738 ...
739 modparam("acc", "log_level", 2)   # Set log_level to 2
740 ...
741 </programlisting>
742                 </example>
743         </section>
744         <section id="acc.p.log_facility">
745                 <title><varname>log_facility</varname> (string)</title>
746                 <para>
747                 Log facility to which accounting messages are issued to syslog.
748                 This allows to easily seperate the accounting specific logging
749                 from the other log messages.
750                 </para>
751                 <para>
752                 Default value is LOG_DAEMON.
753                 </para>
754                 <example>
755                 <title>log_facility example</title>
756                 <programlisting format="linespecific">
757 ...
758 modparam("acc", "log_facility", "LOG_DAEMON")
759 ...
760 </programlisting>
761                 </example>
762         </section>
763         <section id="acc.p.log_extra">
764                 <title><varname>log_extra</varname> (string)</title>
765                 <para>
766                 Extra values to be logged.
767                 See section <xref linkend="acc.i.extra-accounting"/> for more details.
768                 </para>
769                 <para>
770                 Default value is NULL.
771                 </para>
772                 <example>
773                 <title>log_extra example</title>
774                 <programlisting format="linespecific">
775 ...
776 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
777 ...
778 </programlisting>
779                 </example>
780         </section>
781         <!-- RADIUS specific ACC parameters -->
782         <section id="acc.p.radius_config">
783                 <title><varname>radius_config</varname> (string)</title>
784                 <para>
785                 <emphasis>This parameter is radius specific.</emphasis> Path to 
786                 radius client configuration file, set the referred config file 
787                 correctly and specify there address of server, shared secret 
788                 (should equal that in /usr/local/etc/raddb/clients for
789                 freeRadius servers) and dictionary, see etc for an example of 
790                 config file and dictionary.
791                 </para>
792                 <para>
793                 If the parameter is set to empty string, the RADIUS accounting support
794                 will be disabled (even if compiled).
795                 </para>
796                 <para>
797                 Default value is <quote>NULL</quote>.
798                 </para>
799                 <example>
800                 <title>radius_config example</title>
801                 <programlisting format="linespecific">
802 ...
803 modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
804 ...
805 </programlisting>
806                 </example>
807         </section>
808         <section  id="acc.p.radius_flag">
809                 <title><varname>radius_flag</varname> (integer)</title>
810                 <para>
811                 Request flag which needs to be set to account a 
812                 transaction -- RADIUS specific.
813                 </para>
814                 <para>
815                 Default value is not-set (no flag).
816                 </para>
817                 <example>
818                 <title>radius_flag example</title>
819                 <programlisting format="linespecific">
820 ...
821 modparam("acc", "radius_flag", 2)
822 ...
823 </programlisting>
824                 </example>
825         </section>
826         <section id="acc.p.radius_missed_flag">
827                 <title><varname>radius_missed_flag</varname> (integer)</title>
828                 <para>
829                 Request flag which needs to be set to account missed 
830                 calls -- RADIUS specific.
831                 </para>
832                 <para>
833                 Default value is not-set (no flag).
834                 </para>
835                 <example>
836                 <title>radius_missed_flag example</title>
837                 <programlisting format="linespecific">
838 ...
839 modparam("acc", "radius_missed_flag", 3)
840 ...
841 </programlisting>
842                 </example>
843         </section>
844         <section id="acc.p.service_type">
845                 <title><varname>service_type</varname> (integer)</title>
846                 <para>
847                 Radius service type used for accounting.
848                 </para>
849                 <para>
850                 Default value is 15 (SIP).
851                 </para>
852                 <example>
853                 <title>service_type example</title>
854                 <programlisting format="linespecific">
855 ...
856 modparam("acc", "service_type", 16)
857 ...
858 </programlisting>
859                 </example>
860         </section>
861         <section id="acc.p.radius_extra">
862                 <title><varname>radius_extra</varname> (string)</title>
863                 <para>
864                 Extra values to be logged via RADIUS - RADIUS specific.
865                 See section <xref linkend="acc.i.extra-accounting"/> for more details.
866                 </para>
867                 <para>
868                 Default value is NULL.
869                 </para>
870                 <example>
871                 <title>radius_extra example</title>
872                 <programlisting format="linespecific">
873 ...
874 modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
875 ...
876 </programlisting>
877                 </example>
878         </section>
879         <!-- SQL specific ACC parameters -->
880         <section id="acc.p.db_flag">
881                 <title><varname>db_flag</varname> (integer)</title>
882                 <para>
883                 Request flag which needs to be set to account a 
884                 transaction -- database specific.
885                 </para>
886                 <para>
887                 Default value is not-set (no flag).
888                 </para>
889                 <example>
890                 <title>db_flag example</title>
891                 <programlisting format="linespecific">
892 ...
893 modparam("acc", "db_flag", 2)
894 ...
895 </programlisting>
896                 </example>
897         </section>
898         <section id="acc.p.db_missed_flag">
899                 <title><varname>db_missed_flag</varname> (integer)</title>
900                 <para>
901                 Request flag which needs to be set to account missed 
902                 calls -- database specific.
903                 </para>
904                 <para>
905                 Default value is not-set (no flag).
906                 </para>
907                 <example>
908                 <title>db_missed_flag example</title>
909                 <programlisting format="linespecific">
910 ...
911 modparam("acc", "db_missed_flag", 3)
912 ...
913 </programlisting>
914                 </example>
915         </section>
916         <section  id="acc.p.db_table_acc">
917                 <title><varname>db_table_acc</varname> (string)</title>
918                 <para>
919                 Table name of accounting successfull calls -- database specific. It
920                 can contain config variables that will be evaluated at runtime.
921                 </para>
922                 <para>
923                 Default value is <quote>acc</quote>
924                 </para>
925                 <example>
926                 <title>db_table_acc example</title>
927                 <programlisting format="linespecific">
928 ...
929 modparam("acc", "db_table_acc", "myacc_table")
930 modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
931 ...
932 </programlisting>
933                 </example>
934         </section>
935         <section id="acc.p.db_table_missed_calls">
936                 <title><varname>db_table_missed_calls</varname> (string)</title>
937                 <para>
938                 Table name for accounting missed calls -- database specific. It
939                 can contain config variables that will be evaluated at runtime.
940                 </para>
941                 <para>
942                 Default value is <quote>missed_calls</quote>
943                 </para>
944                 <example>
945                 <title>db_table_missed_calls example</title>
946                 <programlisting format="linespecific">
947 ...
948 modparam("acc", "db_table_missed_calls", "myMC_table")
949 ...
950 </programlisting>
951                 </example>
952         </section>
953         <section id="acc.p.db_url">
954                 <title><varname>db_url</varname> (string)</title>
955                 <para>
956                 SQL address -- database specific. If is set to NULL or emty string,
957                 the SQL support is disabled.
958                 </para>
959                 <para>
960                 Default value is <quote>NULL</quote> (SQL disabled).
961                 </para>
962                 <example>
963                 <title>db_url example</title>
964                 <programlisting format="linespecific">
965 ...
966 modparam("acc", "db_url", "mysql://user:password@localhost/kamailio")
967 ...
968 </programlisting>
969                 </example>
970         </section>
971         <section  id="acc.p.acc_method_column">
972                 <title><varname>acc_method_column</varname> (string)</title>
973                 <para>
974                 Column name in accounting table to store the request's method name as
975                 string.
976                 </para>
977                 <para>
978                 Default value is <quote>method</quote>.
979                 </para>
980                 <example>
981                 <title>acc_method_column example</title>
982                 <programlisting format="linespecific">
983 ...
984 modparam("acc", "acc_method_column", "method")
985 ...
986 </programlisting>
987                 </example>
988         </section>
989         <section id="acc.p.acc_from_tag_column">
990                 <title><varname>acc_from_tag_column</varname> (string)</title>
991                 <para>
992                 Column name in accounting table to store the From header TAG parameter.
993                 </para>
994                 <para>
995                 Default value is <quote>from_tag</quote>.
996                 </para>
997                 <example>
998                 <title>acc_from_tag_column example</title>
999                 <programlisting format="linespecific">
1000 ...
1001 modparam("acc", "acc_from_tag_column", "from_tag")
1002 ...
1003 </programlisting>
1004                 </example>
1005         </section>
1006         <section id="acc.p.acc_to_tag_column">
1007                 <title><varname>acc_to_tag_column</varname> (string)</title>
1008                 <para>
1009                 Column name in accounting table to store the To header TAG parameter.
1010                 </para>
1011                 <para>
1012                 Default value is <quote>to_tag</quote>.
1013                 </para>
1014                 <example>
1015                 <title>acc_to_tag_column example</title>
1016                 <programlisting format="linespecific">
1017 ...
1018 modparam("acc", "acc_to_tag_column", "to_tag")
1019 ...
1020 </programlisting>
1021                 </example>
1022         </section>
1023         <section id="acc.p.acc_callid_column">
1024                 <title><varname>acc_callid_column</varname> (string)</title>
1025                 <para>
1026                 Column name in accounting table to store the request's Callid value.
1027                 </para>
1028                 <para>
1029                 Default value is <quote>callid</quote>.
1030                 </para>
1031                 <example>
1032                 <title>acc_callid_column example</title>
1033                 <programlisting format="linespecific">
1034 ...
1035 modparam("acc", "acc_callid_column", "callid")
1036 ...
1037 </programlisting>
1038                 </example>
1039         </section>
1040         <section id="acc.p.acc_sip_code_column">
1041                 <title><varname>acc_sip_code_column</varname> (string)</title>
1042                 <para>
1043                 Column name in accounting table to store the final reply's numric code
1044                 value in string format.
1045                 </para>
1046                 <para>
1047                 Default value is <quote>sip_code</quote>.
1048                 </para>
1049                 <example>
1050                 <title>acc_sip_code_column example</title>
1051                 <programlisting format="linespecific">
1052 ...
1053 modparam("acc", "acc_sip_code_column", "sip_code")
1054 ...
1055 </programlisting>
1056                 </example>
1057         </section>
1058         <section id="acc.p.acc_sip_reason_column">
1059                 <title><varname>acc_sip_reason_column</varname> (string)</title>
1060                 <para>
1061                 Column name in accounting table to store the final reply's reason
1062                 phrase value.
1063                 </para>
1064                 <para>
1065                 Default value is <quote>sip_reason</quote>.
1066                 </para>
1067                 <example>
1068                 <title>acc_sip_reason_column example</title>
1069                 <programlisting format="linespecific">
1070 ...
1071 modparam("acc", "acc_sip_reason_column", "sip_reason")
1072 ...
1073 </programlisting>
1074                 </example>
1075         </section>
1076         <section id="acc.p.acc_time_column">
1077                 <title><varname>acc_time_column</varname> (string)</title>
1078                 <para>
1079                 Column name in accounting table to store the time stamp of the 
1080                 transaction completion in date-time format.
1081                 </para>
1082                 <para>
1083                 Default value is <quote>time</quote>.
1084                 </para>
1085                 <example>
1086                 <title>acc_time_column example</title>
1087                 <programlisting format="linespecific">
1088 ...
1089 modparam("acc", "acc_time_column", "time")
1090 ...
1091 </programlisting>
1092                 </example>
1093         </section>
1094         <section id="acc.p.db_extra">
1095                 <title><varname>db_extra</varname> (string)</title>
1096                 <para>
1097                 Extra values to be logged into database - DB specific.
1098                 See section <xref linkend="acc.i.extra-accounting"/> for more details.
1099                 </para>
1100                 <para>
1101                 Default value is NULL.
1102                 </para>
1103                 <example>
1104                 <title>db_extra example</title>
1105                 <programlisting format="linespecific">
1106 ...
1107 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
1108 ...
1109 </programlisting>
1110                 </example>
1111         </section>
1112         <section id="acc.p.db_insert_mode">
1113                 <title><varname>db_insert_mode</varname> (integer)</title>
1114                 <para>
1115                 If set to 1, use INSERT DELAYED to add records to accounting tables
1116                 when the DB driver has support for it. If no INSERT DELAYED support
1117                 is offered by DB driver, then standard INSERT is used. Beware that
1118                 MySQL InnoDB engine doesn't support INSERT DELAYED, thus be sure
1119                 the acc tables are defined with different type (e.g., MyISAM).
1120                 </para>
1121                 <para>
1122                 If set to 2, async insert is used if the db driver module has
1123                 support for it and if async_workers core parameter value is greater than 0. If not, then standard INSERT is used.
1124                 </para>
1125                 <para>
1126                 Default value is 0 (no INSERT DELAYED nor async insert).
1127                 </para>
1128                 <example>
1129                 <title>db_insert_mode example</title>
1130                 <programlisting format="linespecific">
1131 ...
1132 modparam("acc", "db_insert_mode", 1)
1133 ...
1134 </programlisting>
1135                 </example>
1136         </section>
1137         <!-- DIAMETER specific ACC parameters -->
1138         <section id="acc.p.diameter_flag">
1139                 <title><varname>diameter_flag</varname> (integer)</title>
1140                 <para>
1141                 Request flag which needs to be set to account a 
1142                 transaction -- DIAMETER specific.
1143                 </para>
1144                 <para>
1145                 Default value is not-set (no flag).
1146                 </para>
1147                 <example>
1148                 <title>diameter_flag example</title>
1149                 <programlisting format="linespecific">
1150 ...
1151 modparam("acc", "diameter_flag", 2)
1152 ...
1153 </programlisting>
1154                 </example>
1155         </section>
1156         <section id="acc.p.diameter_missed_flag">
1157                 <title><varname>diameter_missed_flag</varname> (integer)</title>
1158                 <para>
1159                 Request flag which needs to be set to account missed 
1160                 calls -- DIAMETER specific.
1161                 </para>
1162                 <para>
1163                 Default value is not-set (no flag).
1164                 </para>
1165                 <example>
1166                 <title>diameter_missed_flag example</title>
1167                 <programlisting format="linespecific">
1168 ...
1169 modparam("acc", "diameter_missed_flag", 3)
1170 ...
1171 </programlisting>
1172                 </example>
1173         </section>
1174         <section id="acc.p.diameter_client_host">
1175                 <title><varname>diameter_client_host</varname> (string)</title>
1176                 <para>
1177                 Hostname of the machine where the DIAMETER Client is 
1178                 running -- DIAMETER specific.
1179                 </para>
1180                 <para>
1181                 Default value is <quote>localhost</quote>.
1182                 </para>
1183                 <example>
1184                 <title>diameter_client_host example</title>
1185                 <programlisting format="linespecific">
1186 ...
1187 modparam("acc", "diameter_client_host", "3a_server.net")
1188 ...
1189 </programlisting>
1190                 </example>
1191         </section>
1192         <section id="acc.p.diameter_client_port">
1193                 <title><varname>diameter_client_port</varname> (int)</title>
1194                 <para>
1195                 Port number where the Diameter Client is 
1196                 listening -- DIAMETER specific.
1197                 </para>
1198                 <para>
1199                 Default value is 3000.
1200                 </para>
1201                 <example>
1202                 <title>diameter_client_host example</title>
1203                 <programlisting format="linespecific">
1204 ...
1205 modparam("acc", "diameter_client_port", 3000)
1206 ...
1207 </programlisting>
1208                 </example>
1209         </section>
1210         <section id="acc.p.diameter_extra">
1211                 <title><varname>diameter_extra</varname> (string)</title>
1212                 <para>
1213                 Extra values to be logged via DIAMETER - DIAMETER specific.
1214                 See section <xref linkend="acc.i.extra-accounting"/> for more details.
1215                 </para>
1216                 <para>
1217                 Default value is NULL.
1218                 </para>
1219                 <example>
1220                 <title>diameter_extra example</title>
1221                 <programlisting format="linespecific">
1222 ...
1223 modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
1224 ...
1225 </programlisting>
1226                 </example>
1227         </section>
1228         <section id="acc.p.cdr_enable">
1229                 <title><varname>cdr_enable</varname> (integer)</title>
1230                 <para>
1231                 Should CDR-based logging be enabled?
1232                 </para>
1233                 <para>
1234                 0 - off (default).
1235                 1 - on.
1236                 </para>
1237                 <example>
1238                 <title>cdr_enable example</title>
1239                 <programlisting format="linespecific">
1240 ...
1241 modparam("acc", "cdr_enable", 1)
1242 ...
1243 </programlisting>
1244                 </example>
1245         </section>
1246         <section id="acc.p.cdr_expired_dlg_enable">
1247                 <title><varname>cdr_expired_dlg_enable</varname> (integer)</title>
1248                 <para>
1249                 Should CDR-based logging be enabled in case of expired dialogs?
1250                 </para>
1251                 <para>
1252                 0 - off (default).
1253                 1 - on.
1254                 </para>
1255                 <example>
1256                 <title>cdr_expired_dlg_enable example</title>
1257                 <programlisting format="linespecific">
1258 ...
1259 modparam("acc", "cdr_expired_dlg_enable", 1)
1260 ...
1261 </programlisting>
1262                 </example>
1263         </section>
1264         <section id="acc.p.cdr_start_on_confirmed">
1265                 <title><varname>cdr_start_on_confirmed</varname> (integer)</title>
1266                 <para>
1267                 Should the start time be taken from the time when the dialog is created,
1268                 or when the dialog is confirmed?
1269                 </para>
1270                 <para>
1271                 0 - use time of dialog creation (default).
1272                 1 - use time of dialog confirmation.
1273                 </para>
1274                 <example>
1275                 <title>cdr_start_on_confirmed example</title>
1276                 <programlisting format="linespecific">
1277 ...
1278 modparam("acc", "cdr_start_on_confirmed", 1)
1279 ...
1280 </programlisting>
1281                 </example>
1282         </section>
1283         <section id="acc.p.cdr_facility">
1284                 <title><varname>cdr_facility</varname> (integer)</title>
1285                 <para>
1286                 Log facility to which CDR messages are issued to syslog.
1287                 This allows to easily seperate CDR-specific logging from
1288                 the other log messages.
1289                 </para>
1290                 <para>
1291                 Default value is LOG_DAEMON.
1292                 </para>
1293                 <example>
1294                 <title>cdr_facility example</title>
1295                 <programlisting format="linespecific">
1296 ...
1297 modparam("acc", "cdr_facility", "LOG_DAEMON")
1298 ...
1299 </programlisting>
1300                 </example>
1301         </section>
1302         <section id="acc.p.cdr_extra">
1303                 <title><varname>cdr_extra</varname> (string)</title>
1304                 <para>
1305                 Set of pseudo-variables defining custom CDR fields. See
1306         <xref linkend="acc.i.cdr-extra"/> for more details.
1307                 </para>
1308                 <para>
1309                 Default value is NULL.
1310                 </para>
1311                 <example>
1312                 <title>cdr_extra example</title>
1313                 <programlisting format="linespecific">
1314 ...
1315 modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)"
1316 ...
1317 </programlisting>
1318                 </example>
1319         </section>
1320         <section id="acc.p.cdr_start_id">
1321                 <title><varname>cdr_start_id</varname> (string)</title>
1322                 <para>
1323                 Modifying the id which is used to store the start time.
1324                 </para>
1325                 <para>
1326                 Default value is 'start_time'
1327                 </para>
1328                 <example>
1329                 <title>cdr_start_id example</title>
1330                 <programlisting format="linespecific">
1331 ...
1332 modparam("acc", "cdr_start_id", "start")
1333 ...
1334 </programlisting>
1335                 </example>
1336         </section>
1337         <section id="acc.p.cdr_end_id">
1338                 <title><varname>cdr_end_id</varname> (string)</title>
1339                 <para>
1340                 Modifying the id which is used to store the end time.
1341                 </para>
1342                 <para>
1343                 Default value is 'end_time'
1344                 </para>
1345                 <example>
1346                 <title>cdr_end_id example</title>
1347                 <programlisting format="linespecific">
1348 ...
1349 modparam("acc", "cdr_end_id", "end")
1350 ...
1351 </programlisting>
1352                 </example>
1353         </section>
1354         <section id="acc.p.cdr_duration_id">
1355                 <title><varname>cdr_duration_id</varname> (string)</title>
1356                 <para>
1357                 Modify the id which is used to store the duration.
1358                 </para>
1359                 <para>
1360                 Default value is 'duration'
1361                 </para>
1362                 <example>
1363                 <title>cdr_duration_id example</title>
1364                 <programlisting format="linespecific">
1365 ...
1366 modparam("acc", "cdr_duration_id", "d")
1367 ...
1368 </programlisting>
1369                 </example>
1370         </section>
1371         <section id="acc.p.cdr_log_enable">
1372                 <title><varname>cdr_log_enable</varname> (int)</title>
1373                 <para>
1374                 Control if CDR-based accounting should be written to syslog.
1375                 </para>
1376                 <para>
1377                 0 - off.
1378                 1 - on (default).
1379                 </para>
1380                 <example>
1381                 <title>cdr_log_enable example</title>
1382                 <programlisting format="linespecific">
1383 ...
1384 modparam("acc", "cdr_log_enable", 0)
1385 ...
1386 </programlisting>
1387                 </example>
1388         </section>
1389         <section id="acc.p.cdrs_table">
1390                 <title><varname>cdrs_table</varname> (str)</title>
1391                 <para>
1392                 Name of db table to store dialog-based CDRs.
1393                 </para>
1394                 <para>
1395                 Default value is "" (no db storage for dialog-based CDRs).
1396                 </para>
1397                 <example>
1398                 <title>cdrs_table example</title>
1399                 <programlisting format="linespecific">
1400 ...
1401 modparam("acc", "cdrs_table", "acc_cdrs")
1402 ...
1403 </programlisting>
1404                 </example>
1405         </section>
1406         <section id="acc.p.time_mode">
1407                 <title><varname>time_mode</varname> (int)</title>
1408                 <para>
1409                 Store additional value related to the time of event.
1410                 </para>
1411                 <para>
1412                 Values can be:
1413                 </para>
1414                 <itemizedlist>
1415                 <listitem>
1416                         <para><emphasis>0</emphasis> -  (default), save only unix
1417                                 timestamp for syslog and datetime for database.</para>
1418                 </listitem>
1419                 <listitem>
1420                         <para><emphasis>1</emphasis> - save seconds in time_attr and
1421                                 microseconds in time_exten.</para>
1422                 </listitem>
1423                 <listitem>
1424                         <para><emphasis>2</emphasis> - save seconds.miliseconds
1425                                 in time_attr.</para>
1426                 </listitem>
1427                 <listitem>
1428                         <para><emphasis>3</emphasis> - save formatted time according
1429                                 to time_format parameter, using the output of localtime().
1430                         </para>
1431                 </listitem>
1432                 <listitem>
1433                         <para><emphasis>4</emphasis> - save formatted time according
1434                                 to time_format parameter, using the output of gmtime().
1435                         </para>
1436                 </listitem>
1437                 </itemizedlist>
1438
1439                 <example>
1440                 <title>time_mode example</title>
1441                 <programlisting format="linespecific">
1442 ...
1443 modparam("acc", "time_mode", 1)
1444 ...
1445 </programlisting>
1446                 </example>
1447         </section>
1448         <section id="acc.p.time_attr">
1449                 <title><varname>time_attr</varname> (str)</title>
1450                 <para>
1451                 Name of the syslog attribute or database column where to store additional
1452                 value related to the time of event.
1453                 </para>
1454                 <para>
1455                 For db accounting, the column has to be of different types, depending on
1456                 time_mode value. When time_mode is:
1457                 </para>
1458                 <itemizedlist>
1459                 <listitem>
1460                         <para><emphasis>1</emphasis> - time_attr column has to be int.</para>
1461                 </listitem>
1462                 <listitem>
1463                         <para><emphasis>2</emphasis> - time_attr column has to be double.</para>
1464                 </listitem>
1465                 <listitem>
1466                         <para><emphasis>3</emphasis> - time_attr column has to be varchar(128).</para>
1467                 </listitem>
1468                 <listitem>
1469                         <para><emphasis>4</emphasis> - time_attr column has to be varchar(128).</para>
1470                 </listitem>
1471                 </itemizedlist>
1472                 <para>
1473                 For time_mode=1, this attribute is not written in syslog, because time
1474                 value is already unix timestamp, but in db accounting time value is
1475                 datetime and requires a function to get the timestamp.
1476                 </para>
1477                 <example>
1478                 <title>time_attr example</title>
1479                 <programlisting format="linespecific">
1480 ...
1481 modparam("acc", "time_attr", "seconds")
1482 ...
1483 </programlisting>
1484                 </example>
1485         </section>
1486         <section id="acc.p.time_exten">
1487                 <title><varname>time_exten</varname> (str)</title>
1488                 <para>
1489                 Name of the syslog attribute or database column where to store extended
1490                 value related to the time of event.
1491                 </para>
1492                 <para>
1493                 It is used now only for time_mode=1 and database column has to be int:
1494                 </para>
1495                 <example>
1496                 <title>time_exten example</title>
1497                 <programlisting format="linespecific">
1498 ...
1499 modparam("acc", "time_exten", "micorsecs")
1500 ...
1501 </programlisting>
1502                 </example>
1503         </section>
1504         <section id="acc.p.time_format">
1505                 <title><varname>time_format</varname> (str)</title>
1506                 <para>
1507                 Specify the format to print the time for time_mode 3 or 4.
1508                 </para>
1509                 <para>
1510                 Default value is %Y-%m-%d %H:%M:%S".
1511                 </para>
1512                 <example>
1513                 <title>time_format example</title>
1514                 <programlisting format="linespecific">
1515 ...
1516 modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S")
1517 ...
1518 </programlisting>
1519                 </example>
1520         </section>
1521         <section id="acc.p.reason_from_hf">
1522                 <title><varname>reason_from_hf</varname> (int)</title>
1523                 <para>
1524                 Tells where to take sip_reason from.  If value is 0,
1525                 sip_reason is taken from status line.  Otherwise, sip_reason
1526                 is taken from Reason header field(s) if present.
1527                 Currently only the first Reason header is used.
1528                 </para>
1529                 <para>
1530                 Default value is 0.
1531                 </para>
1532                 <example>
1533                 <title>reason_from_hf</title>
1534                 <programlisting format="linespecific">
1535 ...
1536 modparam("acc", "reason_from_hf", 1)
1537 ...
1538 </programlisting>
1539                 </example>
1540         </section>
1541         <section id="acc.p.clone_msg">
1542                 <title><varname>clone_msg</varname> (int)</title>
1543                 <para>
1544                 If set to 1, request structure from transaction is cloned temporarily
1545                 in the callback to get acc attributes. It is required if you account
1546                 values from SIP headers to avoid concurent access to the shared memory
1547                 transaction structure, specially when accounting 1xx events. If set to
1548                 0, it uses directly the shared memory structure, be sure you store all
1549                 needed attributes in AVPs/XAVPs inside request route.
1550                 </para>
1551                 <para>
1552                 Default value is 1.
1553                 </para>
1554                 <example>
1555                 <title>clone_msg</title>
1556                 <programlisting format="linespecific">
1557 ...
1558 modparam("acc", "clone_msg", 0)
1559 ...
1560 </programlisting>
1561                 </example>
1562         </section>
1563         <section id="acc.p.cdr_on_failed">
1564                 <title><varname>cdr_on_failed</varname> (int)</title>
1565                 <para>
1566                 If set to 1, the module stores the CDR for a failed dialog (calls not
1567                 answered). If set to 0, those records are not stored, only those for
1568                 answered calls.
1569                 </para>
1570                 <para>
1571                 Default value is 1.
1572                 </para>
1573                 <example>
1574                 <title>cdr_on_failed</title>
1575                 <programlisting format="linespecific">
1576 ...
1577 modparam("acc", "cdr_on_failed", 0)
1578 ...
1579 </programlisting>
1580                 </example>
1581         </section>
1582         </section>
1583
1584         <section>
1585         <title>Functions</title>
1586         <section id="acc.f.acc_log_request">
1587                 <title>
1588                         <function moreinfo="none">acc_log_request(comment)</function>
1589                 </title>
1590                 <para>
1591                 <function moreinfo="none">acc_request</function> reports on a request, 
1592                 for example, it can be used to report on missed calls to off-line users 
1593                 who are replied 404 - Not Found. To avoid multiple reports on UDP 
1594                 request retransmission, you would need to embed the
1595                 action in stateful processing.
1596                 </para> 
1597                 <para>
1598                 Meaning of the parameters is as follows:</para>
1599                 <itemizedlist>
1600                 <listitem>
1601                         <para><emphasis>comment</emphasis> - Comment to be appended.
1602                         The string can contain any number of pseudo-variables.
1603                         </para>
1604                 </listitem>
1605                 </itemizedlist>
1606                 <para>
1607                 This function can be used from ANY_ROUTE.
1608                 </para>
1609                 <example>
1610                 <title>acc_log_request usage</title>
1611                 <programlisting format="linespecific">
1612 ...
1613 acc_log_request("Some comment");
1614 $var(code) = 404;
1615 $avp(reason) = "Not found";
1616 acc_log_request("$var(code) Error: $avp(reason)");
1617 ...
1618 </programlisting>
1619                 </example>
1620         </section>
1621         <section id="acc.f.acc_db_request">
1622                 <title>
1623                         <function moreinfo="none">acc_db_request(comment, table)</function>
1624                 </title>
1625                 <para>
1626                 Like <function moreinfo="none">acc_log_request</function>, 
1627                 <function moreinfo="none">acc_db_request</function> reports on a 
1628                 request. The report is sent to database at <quote>db_url</quote>, in 
1629                 the table referred to in the second action parameter.
1630                 </para>
1631                 <para>
1632                 Meaning of the parameters is as follows:
1633                 </para>
1634                 <itemizedlist>
1635                 <listitem>
1636                         <para><emphasis>comment</emphasis> - Comment to be appended.
1637                         The string can contain any number of pseudo-variables.
1638                         </para>
1639                 </listitem>
1640                 <listitem>
1641                         <para><emphasis>table</emphasis> - Database table to be used. It
1642                         can contain config variables that are evaluated at runtime.</para>
1643                 </listitem>
1644                 </itemizedlist>
1645                 <para>
1646                 This function can be used from ANY_ROUTE.
1647                 </para>
1648                 <example>
1649                 <title>acc_db_request usage</title>
1650                 <programlisting format="linespecific">
1651 ...
1652 acc_db_request("Some comment", "SomeTable");
1653 acc_db_request("Some comment", "acc_$time(year)_$time(mon)");
1654 acc_db_request("$var(code) Error: $avp(reason)", "SomeTable");
1655 ...
1656 </programlisting>
1657                 </example>
1658         </section>
1659         <section id="acc.f.acc_rad_request">
1660                 <title>
1661                         <function moreinfo="none">acc_rad_request(comment)</function>
1662                 </title>
1663                 <para>
1664                 Like <function moreinfo="none">acc_log_request</function>, 
1665                 <function moreinfo="none">acc_rad_request</function> reports on 
1666                 a request. It reports to radius server as configured in 
1667                 <quote>radius_config</quote>.
1668                 </para>
1669                 <para>
1670                 Meaning of the parameters is as follows:</para>
1671                 <itemizedlist>
1672                 <listitem>
1673                         <para><emphasis>comment</emphasis> - Comment to be appended.
1674                         The string can contain any number of pseudo-variables.
1675                         </para>
1676                 </listitem>
1677                 </itemizedlist>
1678                 <para>
1679                 This function can be used from ANY_ROUTE.
1680                 </para>
1681                 <example>
1682                 <title>acc_rad_request usage</title>
1683                 <programlisting format="linespecific">
1684 ...
1685 acc_rad_request("Some comment");
1686 acc_rad_request("$var(code) Error: $avp(reason)");
1687 ...
1688 </programlisting>
1689                 </example>
1690         </section>
1691         <section id="acc.f.acc_diam_request">
1692                 <title>
1693                         <function moreinfo="none">acc_diam_request(comment)</function>
1694                 </title>
1695                 <para>
1696                 Like <function moreinfo="none">acc_log_request</function>, 
1697                 <function moreinfo="none">acc_diam_request</function> reports on 
1698                 a request. It reports to the configured Diameter server.
1699                 </para> 
1700                 <para>
1701                 Meaning of the parameters is as follows:</para>
1702                 <itemizedlist>
1703                 <listitem>
1704                         <para><emphasis>comment</emphasis> - Comment to be appended.
1705                         The string can contain any number of pseudo-variables.
1706                         </para>
1707                 </listitem>
1708                 </itemizedlist>
1709                 <para>
1710                 This function can be used from ANY_ROUTE.
1711                 </para>
1712                 <example>
1713                 <title>acc_diam_request usage</title>
1714                 <programlisting format="linespecific">
1715 ...
1716 acc_diam_request("Some comment");
1717 acc_diam_request("$var(code) Error: $avp(reason)");
1718 ...
1719 </programlisting>
1720                 </example>
1721         </section>
1722         </section>
1723 </chapter>
1724