dialog Module

Bogdan-Andrei Iancu

Voice Sistem SRL

Edited by

Bogdan-Andrei Iancu


Table of Contents
1. User's Guide
1.1. Overview
1.2. How it works
1.3. Dependencies
1.3.1. OpenSER Modules
1.3.2. External Libraries or Applications
1.4. Exported Parameters
1.4.1. enable_stats (integer)
1.4.2. hash_size (integer)
1.4.3. rr_param (string)
1.4.4. dlg_flag (integer)
1.4.5. timeout_avp (string)
1.4.6. default_timeout (integer)
1.4.7. dlg_extra_hdrs (string)
1.4.8. dlg_match_mode (integer)
1.4.9. db_url (string)
1.4.10. db_mode (integer)
1.4.11. db_update_period (integer)
1.4.12. db_fetch_rows (integer)
1.4.13. table_name (string)
1.4.14. callid_column (string)
1.4.15. from_uri_column (string)
1.4.16. from_tag_column (string)
1.4.17. to_uri_column (string)
1.4.18. to_tag_column (string)
1.4.19. caller_cseq_column (string)
1.4.20. callee_cseq_column (string)
1.4.21. caller_route_column (string)
1.4.22. callee_route_column (string)
1.4.23. caller_contact_column (string)
1.4.24. callee_contact_column (string)
1.4.25. caller_sock_column (string)
1.4.26. callee_sock_column (string)
1.4.27. h_id_column (string)
1.4.28. h_entry_column (string)
1.4.29. state_column (string)
1.4.30. start_time_column (string)
1.4.31. timeout_column (string)
1.5. Exported Functions
1.6. Exported statistics
1.6.1. active_dialogs
1.6.2. early_dialogs
1.6.3. processed_dialogs
1.6.4. expired_dialogs
1.6.5. failed_dialogs
1.7. Exported MI Functions
1.7.1. dlg_list
1.7.2. dlg_end_dlg
1.8. Exported pseudo-variables
1.8.1. $DLG_count
1.8.2. $DLG_status
1.8.3. $DLG_lifetime
2. Developer's Guide
2.1. Available Functions
2.1.1. register_dlgcb (dialog, type, cb, param)
3. Frequently Asked Questions
List of Examples
1-1. Set enable_stats parameter
1-2. Set hash_size parameter
1-3. Set rr_param parameter
1-4. Set dlg_flag parameter
1-5. Set timeout_avp parameter
1-6. Set default_timeout parameter
1-7. Set dlf_extra_hdrs parameter
1-8. Set dlg_match_mode parameter
1-9. Set db_url parameter
1-10. Set db_mode parameter
1-11. Set db_update_period parameter
1-12. Set db_fetch_rows parameter
1-13. Set table_name parameter
1-14. Set callid_column parameter
1-15. Set from_uri_column parameter
1-16. Set from_tag_column parameter
1-17. Set to_uri_column parameter
1-18. Set to_tag_column parameter
1-19. Set caller_cseq_column parameter
1-20. Set callee_cseq_column parameter
1-21. Set caller_route_column parameter
1-22. Set to_route_column parameter
1-23. Set caller_contact_column parameter
1-24. Set callee_contact_column parameter
1-25. Set caller_sock_column parameter
1-26. Set callee_sock_column parameter
1-27. Set h_id_column parameter
1-28. Set h_entry_column parameter
1-29. Set state_column parameter
1-30. Set start_time_column parameter
1-31. Set timeout_column parameter

Chapter 1. User's Guide

1.1. Overview

The dialog module provides dialog awareness to OpenSER proxy. Its functionality is to keep trace of the current dialogs, to offer information about them (like how many dialogs are active). The module exports no functions that could be used directly from scripts.

The module, via an internal API, also provide the foundation to build on top of it more complex dialog-based functionalities via other OpenSER modules.


1.2. How it works

To create the dialog associated to an initial request, the flag "dlg_flag" (Section 1.4.4) must be set before creating the corresponding transaction.

The dialog is automatically destroyed when a "BYE" is received. In case of no "BYE", the dialog lifetime is controlled via the default timeout (see "default_timeout" - Section 1.4.6) and custom timeout (see "timeout_avp" - Section 1.4.5). The dialog timeout is reset each time a sequential request passes.


1.3. Dependencies

1.3.1. OpenSER Modules

The following modules must be loaded before this module:

  • TM - Transaction module

  • RR - Record-Route module


1.3.2. External Libraries or Applications

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

  • None.


1.4. Exported Parameters

1.4.1. enable_stats (integer)

If the statistics support should be enabled or not. Via statistic variables, the module provide information about the dialog processing. Set it to zero to disable or to non-zero to enable it.

Default value is "1 (enabled)".

Example 1-1. Set enable_stats parameter

...
modparam("dialog", "enable_stats", 0)
...

1.4.2. hash_size (integer)

The size of the hash table internally used to keep the dialogs. A larger table is much faster but consumes more memory. The hash size must be a power of 2 number.

IMPORTANT: If dialogs' information should be stored in a database, a constant hash_size should be used, otherwise the restored process will not take place. If you really want to modify the hash_size you must delete all table's rows before restarting openser.

Default value is "4096".

Example 1-2. Set hash_size parameter

...
modparam("dialog", "hash_size", 1024)
...

1.4.3. rr_param (string)

Name of the Record-Route parameter to be added with the dialog cookie. It is used for fast dialog matching of the sequential requests.

Default value is "did".

Example 1-3. Set rr_param parameter

...
modparam("dialog", "rr_param", "xyz")
...

1.4.4. dlg_flag (integer)

Flag to be used for marking if a dialog should be constructed for the current request (make sense only for initial requests).

Default value is "none".

Example 1-4. Set dlg_flag parameter

...
modparam("dialog", "dlg_flag", 4)
...

1.4.5. timeout_avp (string)

The specification of an AVP to contain a custom timeout (in seconds) for the dialog. It may be used only in a request (initial or sequential) context

Default value is "none".

Example 1-5. Set timeout_avp parameter

...
modparam("dialog", "timeout_avp", "$avp(i:10)")
...

1.4.6. default_timeout (integer)

The default dialog timeout (in seconds) if no custom one is set.

Default value is "43200 (12 hours)".

Example 1-6. Set default_timeout parameter

...
modparam("dialog", "default_timeout", 21600)
...

1.4.7. dlg_extra_hdrs (string)

A string containing the extra headers (full format, with EOH) to be added in the requests generated by the module (like BYEs).

Default value is "NULL".

Example 1-7. Set dlf_extra_hdrs parameter

...
modparam("dialog", "dlg_extra_hdrs", "Hint: credit expired\r\n")
...

1.4.8. dlg_match_mode (integer)

How the seqential requests should be matched against the known dialogs. The modes are a combination between matching based on a cookie (DID) stored as cookie in Record-Route header and the matching based on SIP elements (as in RFC3261).

The supported modes are:

  • 0 - DID_ONLY - the match is done exclusivly based on DID;

  • 1 - DID_FALLBACK - the match is first tried based on DID and if not present, it will fallback to SIP matching;

  • 2 - DID_NONE - the match is done exclusivly based on SIP elements; no DID information is added in RR.

Default value is "0 (DID_ONLY)".

Example 1-8. Set dlg_match_mode parameter

...
modparam("dialog", "dlg_match_mode", 1)
...

1.4.9. db_url (string)

If you want to store the information about the dialogs in a database a database url must be specified.

Default value is "mysql://openser:openserrw@localhost/openser".

Example 1-9. Set db_url parameter

...
modparam("dialog", "db_url", "dbdriver://username:password@dbhost/dbname")
...

1.4.10. db_mode (integer)

Describe how to push into the DB the dialogs' information from memory.

The supported modes are:

  • 0 - NO_DB - the memory content is not flushed into DB;

  • 1 - REALTIME - any dialog information changes will be reflected into the database immediatly.

  • 2 - DELAYED - the dialog information changes will be flushed into DB periodically, based on a timre routine.

Default value is "0".

Example 1-10. Set db_mode parameter

...
modparam("dialog", "db_mode", 1)
...

1.4.11. db_update_period (integer)

The interval (seconds) at which to update dialogs' information if you chose to store the dialogs' info at a given interval. A too short interval will generate intensiv database operations, a too large one will not notice short dialogs.

Default value is "60".

Example 1-11. Set db_update_period parameter

...
modparam("dialog", "db_update_period", 120)
...

1.4.12. db_fetch_rows (integer)

The number of the rows to be fetched at once from database when loading the dialog records at startup from the database. This value can be used to tune the load time at startup. For 1MB of private memory (default) it should be below 400. The database driver must support fetch_result() capability. A value of 0 means the functionality is disabled.

Default value is "200".

Example 1-12. Set db_fetch_rows parameter

...
modparam("dialog", "db_fetch_rows", 500)
...
		

1.4.13. table_name (string)

If you want to store the information about the dialogs in a database a table name must be specified.

Default value is "dialog".

Example 1-13. Set table_name parameter

...
modparam("dialog", "table_name", "my_dialog")
...

1.4.14. callid_column (string)

The column's name in the database to store the dialogs' callid.

Default value is "callid".

Example 1-14. Set callid_column parameter

...
modparam("dialog", "callid_column", "callid_c_name")
...

1.4.15. from_uri_column (string)

The column's name in the database to store the caller's sip address.

Default value is "from_uri".

Example 1-15. Set from_uri_column parameter

...
modparam("dialog", "from_uri_column", "from_uri_c_name")
...

1.4.16. from_tag_column (string)

The column's name in the database to store the From tag from the Invite request.

Default value is "from_tag".

Example 1-16. Set from_tag_column parameter

...
modparam("dialog", "from_tag_column", "from_tag_c_name")
...

1.4.17. to_uri_column (string)

The column's name in the database to store the calee's sip address.

Default value is "to_uri".

Example 1-17. Set to_uri_column parameter

...
modparam("dialog", "to_uri_column", "to_uri_c_name")
...

1.4.18. to_tag_column (string)

The column's name in the database to store the To tag from the 200 OK response to the Invite request, if present.

Default value is "to_tag".

Example 1-18. Set to_tag_column parameter

...
modparam("dialog", "to_tag_column", "to_tag_c_name")
...

1.4.19. caller_cseq_column (string)

The column's name in the database to store the cseq from caller side.

Default value is "caller_cseq".

Example 1-19. Set caller_cseq_column parameter

...
modparam("dialog", "caller_cseq_column", "column_name")
...

1.4.20. callee_cseq_column (string)

The column's name in the database to store the cseq from callee side.

Default value is "callee_cseq".

Example 1-20. Set callee_cseq_column parameter

...
modparam("dialog", "callee_cseq_column", "column_name")
...

1.4.21. caller_route_column (string)

The column's name in the database to store the route records from caller side (proxy to caller).

Default value is "caller_route_set".

Example 1-21. Set caller_route_column parameter

...
modparam("dialog", "caller_route_column", "column_name")
...

1.4.22. callee_route_column (string)

The column's name in the database to store the route records from callee side (proxy to callee).

Default value is "callee_route_set".

Example 1-22. Set to_route_column parameter

...
modparam("dialog", "to_route_column", "column_name")
...

1.4.23. caller_contact_column (string)

The column's name in the database to store the caller's contact uri.

Default value is "from_contact".

Example 1-23. Set caller_contact_column parameter

...
modparam("dialog", "caller_contact_column", "column_name")
...

1.4.24. callee_contact_column (string)

The column's name in the database to store the callee's contact uri.

Default value is "callee_contact".

Example 1-24. Set callee_contact_column parameter

...
modparam("dialog", "callee_contact_column", "column_name")
...

1.4.25. caller_sock_column (string)

The column's name in the database to store the information about the local interface receiving the traffic from caller.

Default value is "caller_sock".

Example 1-25. Set caller_sock_column parameter

...
modparam("dialog", "caller_sock_column", "column_name")
...

1.4.26. callee_sock_column (string)

The column's name in the database to store information about the local interface receiving the traffic from callee.

Default value is "callee_contact".

Example 1-26. Set callee_sock_column parameter

...
modparam("dialog", "callee_sock_column", "column_name")
...

1.4.27. h_id_column (string)

The column's name in the database to store the dialogs' hash id information.

Default value is "hash_id".

Example 1-27. Set h_id_column parameter

...
modparam("dialog", "h_id_column", "hash_id_c_name")
...

1.4.28. h_entry_column (string)

The column's name in the database to store the dialogs' hash entry information.

Default value is "hash_entry".

Example 1-28. Set h_entry_column parameter

...
modparam("dialog", "h_entry_column", "h_entry_c_name")
...

1.4.29. state_column (string)

The column's name in the database to store the dialogs' state information.

Default value is "state".

Example 1-29. Set state_column parameter

...
modparam("dialog", "state_column", "state_c_name")
...

1.4.30. start_time_column (string)

The column's name in the database to store the dialogs' start time information.

Default value is "start_time".

Example 1-30. Set start_time_column parameter

...
modparam("dialog", "start_time_column", "start_time_c_name")
...

1.4.31. timeout_column (string)

The column's name in the database to store the dialogs' timeout.

Default value is "timeout".

Example 1-31. Set timeout_column parameter

...
modparam("dialog", "timeout_column", "timeout_c_name")
...

1.5. Exported Functions

There are no exported functions that could be used in scripts.


1.6. Exported statistics

1.6.1. active_dialogs

Returns the number of current active dialogs (may be confirmed or not).


1.6.2. early_dialogs

Returns the number of early dialogs.


1.6.3. processed_dialogs

Returns the total number of processed dialogs (terminated, expired or active) from the startup.


1.6.4. expired_dialogs

Returns the total number of expired dialogs from the startup.


1.6.5. failed_dialogs

Returns the number of failed dialogs.


1.7. Exported MI Functions

1.7.1. dlg_list

It returns a listing of all dialogs (calls).

Name: dlg_list

Parameters: none

MI FIFO Command Format:

		:dlg_list:_reply_fifo_file_
		_empty_line_
		

1.7.2. dlg_end_dlg

Terminates an ongoing dialog by sending BYE in both directions.

Name: dlg_end_dlg

Parameters:

  • h_entry - hash entry of the dialog in the internal dialog table

  • h_id - hash id of the dialog on the hash entry

  • extra_hdrs - (optional) string containg extra headers (full format) to be added to the BYE requests.

The values for the h_entry and h_id can be get via the dlg_list MI command.

MI FIFO Command Format:

		:dlg_end_dlg:_reply_fifo_file_
		342
		56
		_empty_line_
		

1.8. Exported pseudo-variables

1.8.1. $DLG_count

Returns the number of current active dialogs (may be confirmed or not).


1.8.2. $DLG_status

Returns the status of the dialog corresponding to the processed sequential request. This PV will be available only for sequential requests, after doing loose_route().

Value may be:

  • NULL - Dialog not found.

  • 3 - Confirmed by a final reply but no ACK received yet.

  • 4 - Confirmed by a final reply and ACK received.

  • 5 - Dialog ended.


1.8.3. $DLG_lifetime

Returns the duration (in seconds) of the dialog corresponding to the processed sequential request. The duration is calculated from the dialog confirmation and the current moment. This PV will be available only for sequential requests, after doing loose_route().

NULL will be returned if there is no dialog for the request.


Chapter 2. Developer's Guide

2.1. Available Functions

2.1.1. register_dlgcb (dialog, type, cb, param)

Register a new callback to the dialog.

Meaning of the parameters is as follows:

  • struct dlg_cell* dlg - dialog to register callback to. If maybe NULL only for DLG_CREATED callback type, which is not a per dialog type.

  • int type - types of callbacks; more types may be register for the same callback function; only DLG_CREATED must be register alone. Possible types:

    • DLG_CREATED - called when a new dialog is created - it's a global type (not associated to any dialog)

    • DLG_FAILED - called when the dialog was negatively replied (non-2xx) - it's a per dialog type.

    • DLG_CONFIRMED - called when the dialog is confirmed (2xx replied) - it's a per dialog type.

    • DLG_REQ_WITHIN - called when the dialog matches a sequential request - it's a per dialog type.

    • DLG_TERMINATED - called when the dialog is terminated via BYE - it's a per dialog type.

    • DLG_EXPIRED - called when the dialog expires without receiving a BYE - it's a per dialog type.

  • dialog_cb f - callback function to be called. Prototype is: "void (dialog_cb) (struct dlg_cell* dlg, int type, struct sip_msg* msg, void** param);"

  • void *param - parameter to be passed to the callback function.


Chapter 3. Frequently Asked Questions

3.1. What happend with "use_tight_match" parameter?
3.2. Where can I find more about OpenSER?
3.3. Where can I post a question about this module?
3.4. How can I report a bug?

3.1. What happend with "use_tight_match" parameter?

The parameter was removed with version 1.3 as the option of tight matching became mandatory and not configurable. Now, the tight matching is done all the time (when using DID matching).

3.2. Where can I find more about OpenSER?

3.3. 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 OpenSER 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 .

3.4. How can I report a bug?

Please follow the guidelines provided at: http://sourceforge.net/tracker/?group_id=139143.