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