Copyright © 2006 voice-system.ro
Revision History | |
---|---|
Revision $Revision: 4594 $ | $Date: 2008-08-06 12:08:33 +0200 (Wed, 06 Aug 2008) $ |
Table of Contents
enable_stats
(integer)hash_size
(integer)rr_param
(string)dlg_flag
(integer)timeout_avp
(string)default_timeout
(integer)dlg_extra_hdrs
(string)dlg_match_mode
(integer)db_url
(string)db_mode
(integer)db_update_period
(integer)db_fetch_rows
(integer)table_name
(string)callid_column
(string)from_uri_column
(string)from_tag_column
(string)to_uri_column
(string)to_tag_column
(string)caller_cseq_column
(string)callee_cseq_column
(string)caller_route_column
(string)callee_route_column
(string)caller_contact_column
(string)callee_contact_column
(string)caller_sock_column
(string)callee_sock_column
(string)h_id_column
(string)h_entry_column
(string)state_column
(string)start_time_column
(string)timeout_column
(string)sflags_column
(string)toroute_column
(string)profiles_with_value
(string)profiles_no_value
(string)bridge_controller
(string)set_dlg_profile(profile,[value])
unset_dlg_profile(profile,[value])
is_in_profile(profile,[value])
get_profile_size(profile,[value],size)
dlg_isflagset(flag)
dlg_setflag(flag)
dlg_resetflag(flag)
dlg_bye(side)
dlg_refer(side, address)
dlg_manage()
dlg_bridge(from, to, op)
dlg_get(callid, ftag, ttag)
List of Examples
enable_stats
parameterhash_size
parameterrr_param
parameterdlg_flag
parametertimeout_avp
parameterdefault_timeout
parameterdlf_extra_hdrs
parameterdlg_match_mode
parameterdb_url
parameterdb_mode
parameterdb_update_period
parameterdb_fetch_rows
parametertable_name
parametercallid_column
parameterfrom_uri_column
parameterfrom_tag_column
parameterto_uri_column
parameterto_tag_column
parametercaller_cseq_column
parametercallee_cseq_column
parametercaller_route_column
parameterto_route_column
parametercaller_contact_column
parametercallee_contact_column
parametercaller_sock_column
parametercallee_sock_column
parameterh_id_column
parameterh_entry_column
parameterstate_column
parameterstart_time_column
parametertimeout_column
parametersflags_column
parametertoroute_column
parameterprofiles_with_value
parameterprofiles_no_value
parameterbridge_controller
parameterset_dlg_profile
usageunset_dlg_profile
usageis_in_profile
usageget_profile_size
usagedlg_isflagset
usagedlg_setflag
usagedlg_resetflag
usagedlg_bye
usagedlg_refer
usagedlg_manage
usagedlg_bridge
usagedlg_get
usageThe dialog module provides dialog awareness to the Kamailio 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 several 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 Kamailio modules.
To create the dialog associated to an initial request, the flag
“dlg_flag” (Section 1.5.4, “dlg_flag
(integer)”) 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.5.6, “default_timeout
(integer)”) and custom timeout (see
“timeout_avp” - Section 1.5.5, “timeout_avp
(string)”). The
dialog timeout is reset each time a sequential request passes.
Dialog profiling is a mechanism that helps in classifying, sorting and keeping trace of certain types of dialogs, using whatever properties of the dialog (like caller, destination, type of calls, etc). Dialogs can be dynamically added in different (and several) profile tables - logically, each profile table can have a special meaning (like dialogs outside the domain, dialogs terminated to PSTN, etc).
There are two types of profiles:
with no value - a dialog simply belongs to a profile. (like outbound calls profile). There is no other additional information to describe the dialog's belonging to the profile;
with value - a dialog belongs to a profile having a certain value (like in caller profile, where the value is the caller ID). The belonging of the dialog to the profile is strictly related to the value.
A dialog can be added to multiple profiles in the same time.
Profiles are visible (at the moment) in the request route (for initial and sequential requests) and in the branch, failure and reply routes of the original request.
The following modules must be loaded before this module:
TM - Transaction module
RR - Record-Route module
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)”.
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”.
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”.
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”.
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”.
The default dialog timeout (in seconds) if no custom one is set.
Default value is “43200 (12 hours)”.
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") ...
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 exclusively 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 exclusively based on SIP elements; no DID information is added in RR.
Default value is “0 (DID_ONLY)”.
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") ...
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 timer routine.
3 - SHUTDOWN - the dialog information will be flushed into DB only at shutdown - no runtime updates.
Default value is “0”.
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”.
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”.
If you want to store the information about the dialogs in a database a table name must be specified.
Default value is “dialog”.
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
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") ...
The column's name in the database to store the dialogs' hash id information.
Default value is “hash_id”.
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") ...
The column's name in the database to store the dialogs' state information.
Default value is “state”.
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") ...
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") ...
The column's name in the database to store the script flags.
Default value is “sflags”.
The column's name in the database to store the index of the route to be executed at timeout.
Default value is “toroute”.
Example 1.33. Set toroute_column
parameter
... modparam("dialog", "toroute_column", "timeout_route") ...
List of names for profiles with values.
Default value is “empty”.
Example 1.34. Set profiles_with_value
parameter
... modparam("dialog", "profiles_with_value", "caller ; my_profile") ...
Inserts the current dialog into a profile. Note that the profile does not supports values, this will be silently discarded. Also, there is no check for inserting the same dialog in the same profile for multiple times.
Meaning of the parameters is as follows:
profile - name of the profile to be added to;
value (optional) - string value to define the belonging of the dialog to the profile - note that the profile must support values. Pseudo-variables are supported.
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, REPLY_ROUTE and FAILURE_ROUTE.
Example 1.37. set_dlg_profile
usage
... set_dlg_profile("inbound_call"); set_dlg_profile("caller","$fu"); ...
Removes the current dialog from a profile.
Meaning of the parameters is as follows:
profile - name of the profile to be removed from;
value (optional) - string value to define the belonging of the dialog to the profile - note that the profile must support values. Pseudo-variables are supported.
This function can be used from BRANCH_ROUTE, REPLY_ROUTE and FAILURE_ROUTE.
Example 1.38. unset_dlg_profile
usage
... unset_dlg_profile("inbound_call"); unset_dlg_profile("caller","$fu"); ...
Checks if the current dialog belongs to a profile. If the profile supports values, the check can be reinforced to take into account a specific value - if the dialog was inserted into the profile for a specific value. If no value is passed, only simply belonging of the dialog to the profile is checked. Note that if the profile does not supports values, this will be silently discarded.
Meaning of the parameters is as follows:
profile - name of the profile to be checked against;
value (optional) - string value to further restrict the check. Pseudo-variables are supported.
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, REPLY_ROUTE and FAILURE_ROUTE.
Example 1.39. is_in_profile
usage
... if (is_in_profile("inbound_call")) { log("this request belongs to a inbound call\n"); } ... if (is_in_profile("caller","XX")) { log("this request belongs to a call of user XX\n"); } ...
Returns the number of dialogs belonging to a profile. If the profile supports values, the check can be reinforced to take into account a specific value - how many dialogs were inserted into the profile with a specific value. If no value is passed, only simply belonging of the dialog to the profile is checked. Note that if the profile does not supports values, this will be silently discarded.
Meaning of the parameters is as follows:
profile - name of the profile to get the size for;
value (optional) - string value to further restrict the check. Pseudo-variables are supported;
size - an AVP or script variable to return the profile size in.
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, REPLY_ROUTE and FAILURE_ROUTE.
Example 1.40. get_profile_size
usage
... if(get_profile_size("inbound_call","$avp(size)")) xlog("currently there are $avp(size) inbound calls\n"); ... if(get_profile_size("caller","$fu","$avp(size)")) xlog("currently, the user $fu has $avp(size) active outgoing calls\n"); ...
Check if the dialog flag is set or not.
Meaning of the parameters is as follows:
flag - index of the flag - can be pseudo-variable.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Set the dialog flag.
Meaning of the parameters is as follows:
flag - index of the flag - can be pseudo-variable.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Reset the dialog flag.
Meaning of the parameters is as follows:
flag - index of the flag - can be pseudo-variable.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Send BYE to parties in dialog.
Meaning of the parameters is as follows:
side - where to send the BYE. It can be: caller, callee or all.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Refer the 'side' to a new SIP 'address'.
Meaning of the parameters is as follows:
side - which part to REFER. It can be: caller or callee.
address - SIP address to refer to.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Process current SIP request with dialog module. It is alternative to setting dialog flag for initial INVITE and Route-parameter-callback execution for within-dialog requests.
This function can be used from REQUEST_ROUTE.
Example 1.46. dlg_manage
usage
... modparam("dialog", "default_timeout", 100) ... route { ... if(is_method("INVITE") && !has_totag()) { $dlg_ctx(timeout_route) = 12; $dlg_ctx(timeout_bye) = 1; } dlg_manage(); ... } ...
Bridge 'from' SIP address to 'to' SIP address via outbound proxy 'op'.
Meaning of the parameters is as follows:
from - SIP address of first side to call.
to - SIP address to refer 'from' to.
op - outbound proxy SIP address.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Example 1.47. dlg_bridge
usage
... dlg_bridge("sip:user@kamailio.org", "sip:annoucement@kamailio.org", "sip:kamailio.org:5080"); ...
Search and set current dialog based on Call-ID, From-Tag and To-Tag parameters.
Meaning of the parameters is as follows:
callid - SIP call-id.
ftag - SIP From tag.
ttag - SIP To tag.
This function can be used from BRANCH_ROUTE, REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
Returns the total number of processed dialogs (terminated, expired or active) from the startup.
Lists the description of a dialog or of all dialogs (calls). If only one dialogs is to be listed, the dialog identifiers are to be passed as parameter (callid and fromtag).
Name: dlg_list
Parameters:
callid (optional) - callid if a single dialog to be listed.
from_tag (optional, but cannot be present without the callid parameter) - fromtag (as per initial request) of the dialog to be listed. Note that if the from_tag is not specified, only dialogs created by a request without a from tag are matched, which will only occur with broken clients and is thus a very rare situation.
MI FIFO Command Format:
:dlg_list:_reply_fifo_file_ _empty_line_
:dlg_list:_reply_fifo_file_ abcdrssfrs122444@192.168.1.1 AAdfeEFF33
The same as the “dlg_list” but including in the dialog description the associated context from modules sitting on top of the dialog module.
Name: dlg_list_ctx
Parameters: see “dlg_list”
MI FIFO Command Format:
:dlg_list_ctx:_reply_fifo_file_ _empty_line_
Terminates a confirmed dialog by sending BYE requests 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_
Returns the number of dialogs belonging to a profile. If the profile supports values, the check can be reinforced to take into account a specific value - how many dialogs were inserted into the profile with a specific value. If no value is passed, only simply belonging of the dialog to the profile is checked. Note that if the profile does not supports values, this will be silently discarded.
Name: profile_get_size
Parameters:
profile - name of the profile to get the value for.
value (optional)- string value to further restrict the check;
MI FIFO Command Format:
:profile_get_size:_reply_fifo_file_ inbound_calls _empty_line_
Lists all the dialogs belonging to a profile. If the profile supports values, the check can be reinforced to take into account a specific value - list only the dialogs that were inserted into the profile with that specific value. If no value is passed, all dialogs belonging to the profile will be listed. Note that the profile does not supports values, this will be silently discarded.
Name: profile_list_dlgs
Parameters:
profile - name of the profile to list the dialog for.
value (optional)- string value to further restrict the check;
MI FIFO Command Format:
:profile_list_dlgs:_reply_fifo_file_ inbound_calls _empty_line_
Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE mechanism.
Name: dlg_bridge
Parameters:
from - SIP address to initiate the call
to - SIP address to refer 'from' to
op (optional) - outbound proxy SIP address
MI FIFO Command Format:
:dlg_bridge:_reply_fifo_file_ from to op _empty_line_
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.
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.
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 DLGCB_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 DLGCB_CREATED must be register alone. Possible types:
DLGCB_LOADED
DLGCB_CREATED - called when a new dialog is created - it's a global type (not associated to any dialog)
DLGCB_FAILED - called when the dialog was negatively replied (non-2xx) - it's a per dialog type.
DLGCB_CONFIRMED - called when the dialog is confirmed (2xx replied) and the setup-concluding ACK message from the caller has been seen - it's a per dialog type.
DLGCB_REQ_WITHIN - called when the dialog matches a sequential request - it's a per dialog type.
DLGCB_TERMINATED - called when the dialog is terminated via BYE - it's a per dialog type.
DLGCB_EXPIRED - called when the dialog expires without receiving a BYE - it's a per dialog type.
DLGCB_EARLY - called when the dialog is created in an early state (18x replied) - it's a per dialog type.
DLGCB_RESPONSE_FWDED - called when the dialog matches a reply to the initial INVITE request - it's a per dialog type.
DLGCB_RESPONSE_WITHIN - called when the dialog matches a reply to a subsequent in dialog request - it's a per dialog type.
DLGCB_MI_CONTEXT - called when the mi dlg_list_ctx command is invoked - it's a per dialog type.
DLGCB_DESTROY
dialog_cb cb - callback function to be called. Prototype is: “void (dialog_cb) (struct dlg_cell* dlg, int type, struct dlg_cb_params * params); ”
void *param - parameter to be passed to the callback function.
param_free callback_param_free - callback function to be called to free the param. Prototype is: “void (param_free_cb) (void *param);”
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 Kamailio? |
Take a look at http://www.kamailio.org/. | |
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 Kamailio release 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. |