Acc Module

Jiri Kuthan

Bogdan-Andrei Iancu

Ramona-Elena Modroiu

Edited by

Bogdan-Andrei Iancu

Edited by

Irina-Maria Stanescu

Revision History
Revision $Revision: 8740 $$Date$

Table of Contents

1. Admin Guide
1.1. Overview
1.1.1. General Example
1.2. Extra accounting
1.2.1. Overview
1.2.2. Definitions and syntax
1.2.3. How it works
1.3. Multi Call-Legs accounting
1.3.1. Overview
1.3.2. Configuration
1.3.3. Logged data
1.4. CDRs accounting
1.4.1. Overview
1.4.2. Configuration
1.4.3. How it works
1.5. Dependencies
1.5.1. OpenSIPS Modules
1.5.2. External Libraries or Applications
1.6. Exported Parameters
1.6.1. early_media (integer)
1.6.2. failed_transaction_flag (string/integer)
1.6.3. report_cancels (integer)
1.6.4. detect_direction (integer)
1.6.5. multi_leg_info (string)
1.6.6. multi_leg_bye_info (string)
1.6.7. log_flag (string/integer)
1.6.8. log_missed_flag (string/integer)
1.6.9. log_level (integer)
1.6.10. log_facility (string)
1.6.11. log_extra (string)
1.6.12. log_extra_bye (string)
1.6.13. aaa_url (string)
1.6.14. aaa_flag (string/integer)
1.6.15. aaa_missed_flag (string/integer)
1.6.16. service_type (integer)
1.6.17. aaa_extra (string)
1.6.18. aaa_extra_bye (string)
1.6.19. db_flag (string/integer)
1.6.20. db_missed_flag (string/integer)
1.6.21. db_table_acc (string)
1.6.22. db_table_avp (string)
1.6.23. db_table_missed_calls (string)
1.6.24. db_url (string)
1.6.25. acc_method_column (string)
1.6.26. acc_from_tag_column (string)
1.6.27. acc_to_tag_column (string)
1.6.28. acc_callid_column (string)
1.6.29. acc_sip_code_column (string)
1.6.30. acc_sip_reason_column (string)
1.6.31. acc_time_column (string)
1.6.32. db_extra (string)
1.6.33. db_extra_bye (string)
1.6.34. diameter_flag (string/integer)
1.6.35. diameter_missed_flag (string/integer)
1.6.36. diameter_client_host (string)
1.6.37. diameter_client_port (int)
1.6.38. diameter_extra (string)
1.6.39. evi_flag (string/integer)
1.6.40. evi_missed_flag (string/integer)
1.6.41. evi_extra (string)
1.6.42. evi_extra_bye (string)
1.6.43. cdr_flag (string/integer)
1.7. Exported Functions
1.7.1. acc_log_request(comment)
1.7.2. acc_db_request(comment, table)
1.7.3. acc_aaa_request(comment)
1.7.4. acc_diam_request(comment)
1.7.5. acc_evi_request(comment)
1.8. Exported Events
1.8.1. E_ACC_CDR
1.8.2. E_ACC_EVENT
1.8.3. E_ACC_MISSED_EVENT
2. Frequently Asked Questions

List of Examples

1.1. early_media example
1.2. failed_transaction_flag example
1.3. report_cancels example
1.4. detect_direction example
1.5. multi_leg_info example
1.6. multi_leg_bye_info example
1.7. log_flag example
1.8. log_missed_flag example
1.9. log_level example
1.10. log_facility example
1.11. log_extra example
1.12. log_extra_bye example
1.13. Set aaa_url parameter
1.14. aaa_flag example
1.15. aaa_missed_flag example
1.16. service_type example
1.17. aaa_extra example
1.18. aaa_extra_bye example
1.19. db_flag example
1.20. db_missed_flag example
1.21. db_table_acc example
1.22. db_table_avp example
1.23. db_table_missed_calls example
1.24. db_url example
1.25. acc_method_column example
1.26. acc_from_tag_column example
1.27. acc_to_tag_column example
1.28. acc_callid_column example
1.29. acc_sip_code_column example
1.30. acc_sip_reason_column example
1.31. acc_time_column example
1.32. db_extra example
1.33. db_extra_bye example
1.34. diameter_flag example
1.35. diameter_missed_flag example
1.36. diameter_client_host example
1.37. diameter_client_host example
1.38. diameter_extra example
1.39. evi_flag example
1.40. evi_missed_flag example
1.41. evi_extra example
1.42. evi_extra_bye example
1.43. cdr_flag example
1.44. acc_log_request usage
1.45. acc_db_request usage
1.46. acc_aaa_request usage
1.47. acc_diam_request usage
1.48. acc_evi_request usage

Chapter 1. Admin Guide

1.1. Overview

ACC module is used to account transactions information to different backends like syslog, SQL, AAA and DIAMETER (beta version).

To account a transaction and to choose which set of backends to be used, the script writer just has to set some flags (see the module parameters section for flag definitions Section 1.6, “Exported Parameters”). If the accounting flag for a specific backend is set, the acc module will then report on completed transaction. A typical usage of the module takes no acc-specific script command -- the functionality binds invisibly through transaction processing. Script writers just need to mark the transaction for accounting with proper setflag. Even so, the module allows the script writter to force accounting in special cases via some script functions.

The accounting module will log by default a fixed set of attributes for the transaction - if you customize your accounting by adding more information to be logged, please see the next chapter about extra accounting - Section 1.2, “Extra accounting”.

The fixed minimal accounting information is:

  • Request Method name

  • From header TAG parameter

  • To header TAG parameter

  • Call-Id

  • 3-digit Status code from final reply

  • Reason phrase from final reply

  • Time stamp when transaction was completed

If a value is not present in request, the empty string is accounted instead.

Note that:

  • A single INVITE may produce multiple accounting reports -- that's due to SIP forking feature.

  • All flags related to accounting need to be set in request processing route - only the "missed-call" flag may be toggled from other types of routes.

  • OpenSIPS now supports session/dialog accounting. It can automatically correlate INVITEs with BYEs for generating proper CDRs, for example for purpose of billing.

  • If a UA fails in middle of conversation, a proxy will never find out about it. In general, a better practice is to account from an end-device (such as PSTN gateway), which best knows about call status (including media status and PSTN status in case of the gateway).

The SQL, Event Interface and AAA backend support are compiled in the module. For DIAMETER you need to enable it by recompiling the module with properly set defines: uncomment DIAM_ACC line in modules/acc/Makefile. The AAA client needs to be configured properly.

NOTE: diameter support was developed for DISC (DIameter Server Client project at http://developer.berlios.de/projects/disc/). This project seems to be no longer maintained and DIAMETER specifications were updated in the meantime. Thus, the DIAMETER part in the module is obsolete and needs rework to be usable with opendiameter or other DIAMETER servers.

1.1.1. General Example

loadmodule "modules/acc/acc.so"
modparam("acc", "log_level", 1)
modparam("acc", "log_flag", "LOG_FLAG")

if (uri=~"sip:+40") /* calls to Romania */ {
    if (!proxy_authorize("sip_domain.net" /* realm */,
    "subscriber" /* table name */))  {
        proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );
        exit;
    }

    if (is_method("INVITE") && !db_check_from()) {
        log("from!=digest\n");
        sl_send_reply("403","Forbidden");
    }

    setflag(LOG_FLAG); /* set for accounting (the same value as in log_flag!)
    t_relay(); 	/* enter stateful mode now */
};

1.2. Extra accounting

1.2.1. Overview

Along the static default information, ACC modules allows dynamical selection of extra information to be logged. This allows you to log any pseudo-variable (AVPs, parts of the request, parts of the reply, etc).

1.2.2. Definitions and syntax

Selection of extra information is done via xxx_extra parameters by specifying the names of additional information you want to log. This information is defined via pseudo-variables and may include headers, AVPs values or other message or system values. The syntax of the parameter is:

  • xxx_extra = extra_definition (';'extra_definition)*

  • extra_definition = log_name '=' pseudo_variable ['/reply']

Each PV (pseudo variable) may be evaluated in the context of the request message (to access info from it) or in the context of the reply message (final reply for the request).

Using /reply marker, the PV will be evaluated in the context of the reply; by default (without the marker), the evaluation is done in the contect of the request. This will allow you to automatically account information (message or network related) from both request and reply in the same time.

The full list of supported pseudo-variables in OpenSIPS is availabe at: http://www.opensips.org/pmwiki.php?n=Resources.DocsCoreVar

Via log_name you define how/where the data will be logged. Its meaning depends of the accounting support which is used:

  • LOG accounting - log_name will be just printed along with the data in log_name=data format;

  • DB accounting - log_name will be the name of the DB column where the data will be stored.IMPORTANT: add in db acc table the columns corresponding to each extra data;

  • AAA accounting - log_name will be the AVP name used for packing the data into AAA message. The log_name will be translated to AVP number via the dictionary. IMPORTANT: add in AAA dictionary the log_name attribute.

  • DIAMETER accounting - log_name will be the AVP code used for packing the data into DIAMETER message. The AVP code is given directly as integer, since DIAMETER has no dictionary support yet. IMPORTANT: log_name must be a number.

  • Events accounting - log_name will be the name of the parameter in the event raised.

1.2.3. How it works

Some pseudo variables may return more than one value (like headers or AVPs). In this case, the returned values are embedded in a single string in a comma-separated format.

1.3. Multi Call-Legs accounting

1.3.1. Overview

A SIP call can have multiple legs due forwarding actions. For example user A calls user B which forwards the call to user C. There is only one SIP call but with 2 legs ( A to B and B to C). Accounting the legs of a call is required for proper billing of the calls (if C is a PSTN number and the call is billed, user B must pay for the call - as last party modifing the call destination-, and not A - as initiator of the call. Call forwarding on server is only one example which shows the necessity of the having an accounting engine with multiple legs support.

1.3.2. Configuration

First how it works: The idea is to have a set of AVPs and for each call leg to store a set of values in the AVPs. The meaning of the AVP content is stricly decided by the script writer - it can be the origin and source of the leg, its status or any other related information. If you have a set of 4 AVPS (AVP1, AVP2, AVP3, AVP4), then for the "A call B and B forwards to C" example, you need to set a different set of values for the AVPs for each leg ([A,B] and [B,C]) . The script writer must take care and properly insert all these AVP from the script (in proper order and with the correct type).

When the accounting information for the call will be written/sent, all the call-leg pairs will be added (based on the found AVP sets).

By default, the multiple call-leg support is disabled - it can be enabled just by setting the per-leg set of AVPs via the multi_leg_info and/or multi_leg_bye_info module parameters. Note that the last one only makes sense only for CDRs that are generated automatically by OpenSIPS.

Important: when both multi-leg accounting is done (for INVITE and BYE), you have to make sure that the AVPs are populated with the same number of legs, otherwise the multi-leg accounting will have an unexpected behavior (values may no longer match the leg number).

1.3.3. Logged data

For each call, all the values of the AVP set (which defines a call-leg) will be logged. How the information will be actually logged, depends of the data backend:

  • syslog -- all leg-sets will be added to one record string as AVP1=xxx, AVP2=xxxx ,... sets.

  • database -- each pair will be separately logged (due DB data structure constraints); several records will be written, the difference between them being only the fields corresponding to the call-leg info.

    Note

    You will need to add in your DB (all acc related tables) the colums for call-leg info (a column for each AVP of the set).

  • AAA -- all sets will be added to the same AAA accounting message as AAA AVPs - for each call-leg a set of AAA AVPs will be added (corresponding to the per-leg AVP set)

    Note

    You will need to add in your dictionary the AAA AVPs used in call-leg AVP set definition.

  • Diameter same as for AAA.

  • events -- each pair will appear as a different parameter-value pair in the event. Similar to the database behavior, multiple events will be raised, and the only difference between them is the leg information.

1.4. CDRs accounting

1.4.1. Overview

ACC module can now also maintain session/dialog accounting. This allows you to log useful information like call duration, call start time and setup time.

1.4.2. Configuration

In order to have CDRs accounting, first you need to specify the cdr_flag parameter. In the script, you must set the corresponding flag for the calls that you want to log. The flag is only meant to be set on the initial INVITE of the dialog.

1.4.3. How it works

This type of accounting is based on the dialog module. When an initial INVITE is received, if the cdr_flag is set, then the dialog creation time is saved. Once the call is answered and the ACK is received, other information like extra values or leg values are saved. When the corresponding BYE is received, the call duration is computed and all information is stored to the desired backend.

1.5. Dependencies

1.5.1. OpenSIPS Modules

The module depends on the following modules (in the other words the listed modules must be loaded before this module):

  • tm -- Transaction Manager

  • a database module -- If SQL support is used.

  • rr -- Record Route, if detect_direction module parameter is enabled.

  • an aaa module

  • dialog -- Dialog, if cdr_flag is set.

1.5.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • none.

1.6. Exported Parameters

1.6.1. early_media (integer)

Should be early media (any provisional reply with body) accounted too ?

Default value is 0 (no).

Example 1.1. early_media example

modparam("acc", "early_media", 1)

1.6.2. failed_transaction_flag (string/integer)

Per transaction flag which says if the transaction should be accounted also in case of failure (status>=300).

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.2. failed_transaction_flag example

modparam("acc", "failed_transaction_flag", "FAIL_TRANS_FLAG")

1.6.3. report_cancels (integer)

By default, CANCEL reporting is disabled -- most accounting applications wants to see INVITE's cancellation status. Turn on if you explicitly want to account CANCEL transactions.

Default value is 0 (no).

Example 1.3. report_cancels example

modparam("acc", "report_cancels", 1)

1.6.4. detect_direction (integer)

Controls the direction detection for sequential requests. If enabled (non zero value), for sequential requests with upstream direction (from callee to caller), the FROM and TO will be swapped (the direction will be preserved as in the original request).

It affects all values related to TO and FROM headers (body, URI, username, domain, TAG).

Default value is 0 (disabled).

Example 1.4. detect_direction example

modparam("acc", "detect_direction", 1)

1.6.5. multi_leg_info (string)

Defines the AVP set to be used in per-call-leg accounting. See Section 1.3, “Multi Call-Legs accounting” for a detailed description of the Multi Call-Legs accounting.

If empty, the multi-leg accounting support will be disabled.

Default value is 0 (disabled).

Example 1.5. multi_leg_info example

# for syslog-based accounting, use any text you want to be printed
modparam("acc", "multi_leg_info",
    "text1=$avp(src);text2=$avp(dst)")
# for mysql-based accounting, use the names of the columns
modparam("acc", "multi_leg_info",
    "leg_src=$avp(src);leg_dst=$avp(dst)")
# for AAA-based accounting, use the names of the AAA AVPs
modparam("acc", "multi_leg_info",
    "AAA_LEG_SRC=$avp(src);AAA_LEG_DST=$avp(dst)")
# for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer)
modparam("acc", "multi_leg_info",
    "2345=$avp(src);2346=$avp(dst)")

1.6.6. multi_leg_bye_info (string)

Defines the AVP set to be used in per-call-leg accounting. See Section 1.3, “Multi Call-Legs accounting” for a detailed description of the Multi Call-Legs accounting. This parameter evaluates the AVPs set for BYE requests. It makes sense only when the CDRs are automatically generated, using the dialog support.

If empty, the multi-leg support for BYE requests is disabled.

Default value is 0 (disabled).

Example 1.6. multi_leg_bye_info example

# for syslog-based accounting, use any text you want to be printed
modparam("acc", "multi_leg_bye_info",
    "text1=$avp(src);text2=$avp(dst)")
# for mysql-based accounting, use the names of the columns
modparam("acc", "multi_leg_bye_info",
    "leg_src=$avp(src);leg_dst=$avp(dst)")
# for AAA-based accounting, use the names of the AAA AVPs
modparam("acc", "multi_leg_bye_info",
    "AAA_LEG_SRC=$avp(src);AAA_LEG_SRC=$avp(dst)")

1.6.7. log_flag (string/integer)

Request flag which needs to be set to account a transaction via syslog.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.7. log_flag example

modparam("acc", "log_flag", "LOG_FLAG")

1.6.8. log_missed_flag (string/integer)

Request flag which needs to be set to account missed calls via syslog.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.8. log_missed_flag example

modparam("acc", "log_missed_flag", "LOG_MISSED_FLAG")

1.6.9. log_level (integer)

Log level at which accounting messages are issued to syslog.

Default value is L_NOTICE.

Example 1.9. log_level example

modparam("acc", "log_level", 2)   # Set log_level to 2

1.6.10. log_facility (string)

Log facility to which accounting messages are issued to syslog. This allows to easily seperate the accounting specific logging from the other log messages.

Default value is LOG_DAEMON.

Example 1.10. log_facility example

modparam("acc", "log_facility", "LOG_DAEMON")

1.6.11. log_extra (string)

Extra values to be logged.

Default value is NULL.

Example 1.11. log_extra example

modparam("acc", "log_extra",
	"uaA=$hdr(User-Agent);uaB=$hdr(Server)/reply;uuid=$avp(123)")

1.6.12. log_extra_bye (string)

Extra values to be logged to logfile. Note that this parameter makes sense only when the cdr_flag is used.

Default value is NULL.

Example 1.12. log_extra_bye example

modparam("acc", "log_extra_bye",
	"uaA=$hdr(User-Agent);uaB=$hdr(Server)/reply;uuid=$avp(123)")

1.6.13. aaa_url (string)

This is the url representing the AAA protocol used and the location of the configuration file of this protocol.

If the parameter is set to empty string, the AAA accounting support will be disabled.

Default value is NULL.

Example 1.13. Set aaa_url parameter

...
modparam("acc", "aaa_url", "radius:/etc/radiusclient-ng/radiusclient.conf")
...

1.6.14. aaa_flag (string/integer)

Request flag which needs to be set to account a transaction -- AAA specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.14. aaa_flag example

modparam("acc", "aaa_flag", "AAA_FLAG")

1.6.15. aaa_missed_flag (string/integer)

Request flag which needs to be set to account missed calls -- AAA specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.15. aaa_missed_flag example

modparam("acc", "aaa_missed_flag", "AAA_MISSED_FLAG")

1.6.16. service_type (integer)

AAA service type used for accounting.

Default value is not-set.

Example 1.16. service_type example

# Default value of service type for SIP is 15
modparam("acc", "service_type", 15)

1.6.17. aaa_extra (string)

Extra values to be logged via AAA - AAA specific.

Default value is NULL.

Example 1.17. aaa_extra example

modparam("acc", "aaa_extra",
	"via=$hdr(Via[*]); email=$avp(email); Bcontact=$ct / reply")

1.6.18. aaa_extra_bye (string)

Extra values to be logged via AAA when a BYE message is received - AAA specific. Note that this parameter makes sense only when the cdr_flag is used.

Default value is NULL.

Example 1.18. aaa_extra_bye example

modparam("acc", "aaa_extra_bye",
	"via=$hdr(Via[*]); email=$avp(email); Bcontact=$ct / reply")

1.6.19. db_flag (string/integer)

Request flag which needs to be set to account a transaction -- database specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.19. db_flag example

modparam("acc", "db_flag", "DB_FLAG")

1.6.20. db_missed_flag (string/integer)

Request flag which needs to be set to account missed calls -- database specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.20. db_missed_flag example

modparam("acc", "db_missed_flag", "DB_MISSED_FLAG")

1.6.21. db_table_acc (string)

Table name of accounting successfull calls -- database specific.

Default value is acc

Example 1.21. db_table_acc example

modparam("acc", "db_table_acc", "myacc_table")

1.6.22. db_table_avp (string)

This parameter should contain a string with an AVP. This AVP should be populated later in the script with the database table name where the request accounting should be stored. This parameter is optional and if it is not used or set in the script, all requests will be stored in the table specified by db_table_acc parameter or it's default value.

NOTE: when using auto CDR generation, the AVP with the table name should be set in the initial INVITE.

Default value is acc

Example 1.22. db_table_avp example

modparam("acc", "db_table_avp", "$avp(acc_table)")
...
route(OUTBOUND_ACC) {
	setflag(CDR_FLAG); # do accounting
	$avp(acc_table) = "acc_outbound"; # store request in the "acc_outbound" table
}

1.6.23. db_table_missed_calls (string)

Table name for accounting missed calls -- database specific.

Default value is missed_calls

Example 1.23. db_table_missed_calls example

modparam("acc", "db_table_missed_calls", "myMC_table")

1.6.24. db_url (string)

SQL address -- database specific. If is set to NULL or empty string, the SQL support is disabled.

Default value is NULL (SQL disabled).

Example 1.24. db_url example

modparam("acc", "db_url", "mysql://user:password@localhost/opensips")

1.6.25. acc_method_column (string)

Column name in accounting table to store the request's method name as string.

Default value is method.

Example 1.25. acc_method_column example

modparam("acc", "acc_method_column", "method")

1.6.26. acc_from_tag_column (string)

Column name in accounting table to store the From header TAG parameter.

Default value is from_tag.

Example 1.26. acc_from_tag_column example

modparam("acc", "acc_from_tag_column", "from_tag")

1.6.27. acc_to_tag_column (string)

Column name in accounting table to store the To header TAG parameter.

Default value is to_tag.

Example 1.27. acc_to_tag_column example

modparam("acc", "acc_to_tag_column", "to_tag")

1.6.28. acc_callid_column (string)

Column name in accounting table to store the request's Callid value.

Default value is callid.

Example 1.28. acc_callid_column example

modparam("acc", "acc_callid_column", "callid")

1.6.29. acc_sip_code_column (string)

Column name in accounting table to store the final reply's numeric code value in string format.

Default value is sip_code.

Example 1.29. acc_sip_code_column example

modparam("acc", "acc_sip_code_column", "sip_code")

1.6.30. acc_sip_reason_column (string)

Column name in accounting table to store the final reply's reason phrase value.

Default value is sip_reason.

Example 1.30. acc_sip_reason_column example

modparam("acc", "acc_sip_reason_column", "sip_reason")

1.6.31. acc_time_column (string)

Column name in accounting table to store the time stamp of the transaction completion in date-time format.

Default value is time.

Example 1.31. acc_time_column example

modparam("acc", "acc_time_column", "time")

1.6.32. db_extra (string)

Extra values to be logged into database - DB specific.

Default value is NULL.

Example 1.32. db_extra example

modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(email)")

1.6.33. db_extra_bye (string)

Extra values to be logged into database when a BYE message is received - DB specific. Note that this parameter makes sense only when the cdr_flag is used.

Default value is NULL.

Example 1.33. db_extra_bye example

modparam("acc", "db_extra_bye", "ct=$hdr(Content-type); email=$avp(email)")

1.6.34. diameter_flag (string/integer)

Request flag which needs to be set to account a transaction -- DIAMETER specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.34. diameter_flag example

modparam("acc", "diameter_flag", "DIAMETER_FLAG")

1.6.35. diameter_missed_flag (string/integer)

Request flag which needs to be set to account missed calls -- DIAMETER specific.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.35. diameter_missed_flag example

modparam("acc", "diameter_missed_flag", "DIAMETER_MISSED_FLAG")

1.6.36. diameter_client_host (string)

Hostname of the machine where the DIAMETER Client is running -- DIAMETER specific.

Default value is localhost.

Example 1.36. diameter_client_host example

modparam("acc", "diameter_client_host", "3a_server.net")

1.6.37. diameter_client_port (int)

Port number where the Diameter Client is listening -- DIAMETER specific.

Default value is 3000.

Example 1.37. diameter_client_host example

modparam("acc", "diameter_client_port", 3000)

1.6.38. diameter_extra (string)

Extra values to be logged via DIAMETER - DIAMETER specific.

Default value is NULL.

Example 1.38. diameter_extra example

modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(email)")

1.6.39. evi_flag (string/integer)

Request flag which needs to be set to account a transaction through the Event Interface.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.39. evi_flag example

modparam("acc", "evi_flag", "EVI_FLAG")

1.6.40. evi_missed_flag (string/integer)

Request flag which needs to be set to account missed calls throught the Event Interface.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.40. evi_missed_flag example

modparam("acc", "evi_missed_flag", "EVI_MISSED_FLAG")

1.6.41. evi_extra (string)

Extra values to be attached as event's parameters.

Default value is NULL.

Example 1.41. evi_extra example

modparam("acc", "evi_extra",
	"uaA=$hdr(User-Agent);uaB=$hdr(Server)/reply;uuid=$avp(123)")

1.6.42. evi_extra_bye (string)

Extra values to be attached as event's parameters for BYE messages. Note that this parameter makes sense only when the cdr_flag is used.

Default value is NULL.

Example 1.42. evi_extra_bye example

modparam("acc", "evi_extra_bye",
	"uaA=$hdr(User-Agent);uaB=$hdr(Server)/reply;uuid=$avp(123)")

1.6.43. cdr_flag (string/integer)

Request flag which needs to be set to account a transaction, including CDR details.

WARNING: Setting INT flags is deprecated! Use quoted strings instead!

Default value is not-set (no flag).

Example 1.43. cdr_flag example

modparam("acc", "cdr_flag", "CDR_FLAG")

1.7. Exported Functions

1.7.1.  acc_log_request(comment)

acc_request reports on a request, for example, it can be used to report on missed calls to off-line users who are replied 404 - Not Found. To avoid multiple reports on UDP request retransmission, you would need to embed the action in stateful processing.

Meaning of the parameters is as follows:

  • comment - Comment describing how the request completed - this string has to contain a reply code followed by a reply reason phrase (ex: "404 Nobody home"). Variables are accepted in this string.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.

Example 1.44. acc_log_request usage

...
acc_log_request("403 Destination not allowed");
...

1.7.2.  acc_db_request(comment, table)

Like acc_log_request, acc_db_request reports on a request. The report is sent to database at db_url, in the table referred to in the second action parameter.

Meaning of the parameters is as follows:

  • comment - Comment describing how the request completed - this string has to contain a reply code followed by a reply reason phrase (ex: "404 Nobody home"). Variables are accepted in this string.

  • table - Database table to be used.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.

Example 1.45. acc_db_request usage

...
acc_db_request("Some comment", "Some table");
acc_db_request("$T_reply_code $(<reply>rr)","acc");
...

1.7.3.  acc_aaa_request(comment)

Like acc_log_request, acc_aaa_request reports on a request. It reports to aaa server as configured in aaa_url.

Meaning of the parameters is as follows:

  • comment - Comment describing how the request completed - this string has to contain a reply code followed by a reply reason phrase (ex: "404 Nobody home"). Variables are accepted in this string.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.

Example 1.46. acc_aaa_request usage

...
acc_aaa_request("403 Destination not allowed");
...

1.7.4.  acc_diam_request(comment)

Like acc_log_request, acc_diam_request reports on a request. It reports to the configured Diameter server.

Meaning of the parameters is as follows:

  • comment - Comment describing how the request completed - this string has to contain a reply code followed by a reply reason phrase (ex: "404 Nobody home"). Variables are accepted in this string.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.

Example 1.47. acc_diam_request usage

...
acc_diam_request("403 Destination not allowed");
...

1.7.5.  acc_evi_request(comment)

Like acc_log_request, acc_evi_request reports on a request. The report is packed as an event sent through the OpenSIPS Event Interface as E_ACC_EVENT if the reply code is a positive one (lower than 300), or E_ACC_MISSED_EVENT for negative or no codes. More information on this in Section 1.8, “Exported Events”.

Meaning of the parameters is as follows:

  • comment - Comment describing how the request completed - this string has to contain a reply code followed by a reply reason phrase (ex: "404 Nobody home"). Variables are accepted in this string.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE and LOCAL_ROUTE.

Example 1.48. acc_evi_request usage

...
acc_evi_request("403 Destination not allowed");
...

1.8. Exported Events

1.8.1.  E_ACC_CDR

The event raised when a CDR is generated. Note that this event will only be triggered if the auto CDR accounting is used.

Parameters:

  • method - Request method name

  • from_tag - From header tag parameter

  • to_tag - To header tag parameter

  • callid - Message Call-id

  • sip_code - The status code from the final reply

  • sip_reason - The status reason from the final reply

  • time - The timestamp when the call was established

  • evi_extra* - Extra parameters added by the evi_extra parameter.

  • evi_extra_bye* - Extra parameters added by the evi_extra_bye parameter

  • multi_leg_info* - Extra parameters added by the multi_leg_info parameter

  • multi_leg_bye_info* - Extra parameters added by the multi_leg_bye_info parameter

  • duration - The call duration in seconds

  • setuptime - The call setup time in seconds

  • created - The timestamp when the call was created (the initial Invite was received)

1.8.2.  E_ACC_EVENT

This event is triggered when old-style accounting is used. It is generated when the requests (INVITE and BYE) transaction have positive final replies, or by the acc_evi_request() function that has a positive reply code in comment.

Parameters:

  • method - Request method name

  • from_tag - From header tag parameter

  • to_tag - To header tag parameter

  • callid - Message Call-id

  • sip_code - The status code from the final reply

  • sip_reason - The status reason from the final reply

  • time - The timestamp when the transaction was created

  • evi_extra* - Extra parameters added by the evi_extra parameter

  • multi_leg_info* - Extra parameters added by the multi_leg_info parameter

1.8.3.  E_ACC_MISSED_EVENT

This event is triggered when old-style accounting is used. It is generated when the requests (INVITE and BYE) transaction have negative final replies, or by the acc_evi_request() function that has a negative reply code in comment.

Parameters:

  • method - Request method name

  • from_tag - From header tag parameter

  • to_tag - To header tag parameter

  • callid - Message Call-id

  • sip_code - The status code from the final reply

  • sip_reason - The status reason from the final reply

  • time - The timestamp when the transaction was created

  • evi_extra* - Extra parameters added by the evi_extra parameter

  • multi_leg_info* - Extra parameters added by the multi_leg_info parameter

Chapter 2. Frequently Asked Questions

$

2.1.

What happened with old report_ack parameter

The parameter is considered obsolete. It was removed as acc module is doing SIP transaction based accouting and according to SIP RFC, end2end ACKs are a different transaction (still part of the same dialog). ACKs can be individually accouted as any other sequential (in-dialog) request.

2.2.

What happened with old log_fmt parameter

The parameter became obsolete with the restructure of the data logged by ACC module (refer to the Overview chapter). For similar behaviour you can use the extra accouting (see the corresponding chapter).

2.3.

What happened with old multi_leg_enabled parameter

The parameter became obsolete by the addition of the new multi_leg_info parameter. The multi-leg accouting is automatically enabled when multi_leg_info is defined.

2.4.

What happened with old src_leg_avp_id and dst_leg_avp_id parameters

The parameter was replaced by the more generic new parameter multi_leg_info. This allows logging (per-leg) of more information than just dst and src.

2.5.

Where can I find more about OpenSIPS?

Take a look at http://www.opensips.org/.

2.6.

Where can I post a question about this module?

First at all check if your question was already answered on one of our mailing lists:

E-mails regarding any stable OpenSIPS release should be sent to and e-mails regarding development versions should be sent to .

If you want to keep the mail private, send it to .

2.7.

How can I report a bug?

Please follow the guidelines provided at: https://github.com/OpenSIPS/opensips/issues.