%docentities; ]> &adminguide;
Overview Kamailio can behave as a stateful proxy through the TM module. However, "stateful" in this context refers to transaction state, not dialog state. Certain applications benefit from the proxy's awareness of "calls", not just SIP transactions. For example, a common need is to limit the number of calls that can be made concurrently by an endpoint, account, user group, etc. In order to count the number of calls in progress, it is necessary for the proxy to be aware of whole dialogs, not just transactions, and to provide some means of programmatically classifying these dialogs. This is just one common application discussed for illustrative purposes; there are many others. The dialog module provides dialog awareness for the &kamailio; proxy. Its functionality is to keep track of the current dialogs, to offer information about them (e.g. how many dialogs are active), and to manage various characteristics of dialogs. The module exports several functions that could be used directly from the configuration route script. This module also provides a foundational API on which to build more complex dialog-oriented functionality in other &kamailio; modules.
How it works To create the dialog associated with an initial request, the flag dlg_flag () 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 - ) and custom timeout (see timeout_avp - ). The dialog timeout is reset each time a sequential request is processed.
Dialog states Dialogs have states that are shown in the RPC interface as well as stored in the database. 1 : Unconfirmed dialog 2 : Early dialog (ringing) 3 : Confirmed dialog (waiting for ACK) 4 : Confirmed dialog (active call) 5 : Deleted dialog
Dialog profiling Dialog profiling is a mechanism that helps in classifying, sorting and keeping track of certain types of dialogs. The classification criteria can be any attributes desired by the user; they can come from SIP message attributes, other pseudo-variables, custom values, etc. Dialogs can be dynamically added into one or more profile tables. Logically, each profile table can have a special meaning (like dialogs outside the domain, dialogs terminated to the PSTN, etc.). There are two types of profiles: with no value - a dialog simply belongs to a profile (for instance, an outbound calls profile). There is no other additional information to describe the dialog beyond its membership in the profile per se. with value - a dialog belongs to a profile having a certain value (like in a caller profile, where the value is the caller ID). The membership of the dialog in the profile is strictly related to the value. For example, if the account ID of the caller is stored in the pseudo-variable $var(account_id), you can use $var(account_id) as a value/key by which to group dialogs so that you can count the number of open dialogs for each account, enforce concurrent call limits as necessary, etc. A dialog can be added to multiple profiles at 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.
Dependencies
&kamailio; Modules The following modules must be loaded before this module: TM - Transaction module RR - Record-Route module PV - Pseudovariables module
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: None.
Parameters
<varname>enable_stats</varname> (integer) If statistics support should be enabled or not. Via statistics 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). Set <varname>enable_stats</varname> parameter ... modparam("dialog", "enable_stats", 0) ...
<varname>hash_size</varname> (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 two. IMPORTANT: If dialogs' information should be stored in a database, a constant hash_size should be used, otherwise the restoring process will not take place. If you really want to modify the hash_size, you must delete all table's rows before restarting the server. Default value is 4096. Set <varname>hash_size</varname> parameter ... modparam("dialog", "hash_size", 1024) ...
<varname>rr_param</varname> (string) Name of the Record-Route parameter used to store the dialog cookie. It is used for the fast matching of sequential requests to tracked dialogs. Default value is did. Set <varname>rr_param</varname> parameter ... modparam("dialog", "rr_param", "xyz") ...
<varname>dlg_flag</varname> (integer) Flag to be used for marking if a dialog should be constructed for the current request (this make sense only for initial requests). Default value is none. Set <varname>dlg_flag</varname> parameter ... modparam("dialog", "dlg_flag", 4) ...
<varname>timeout_avp</varname> (string) The specification of an AVP that contains a custom timeout value (in seconds) for the dialog. It may be used only in a request (initial or sequential) context. Default value is none. Set <varname>timeout_avp</varname> parameter ... modparam("dialog", "timeout_avp", "$avp(i:10)") ...
<varname>default_timeout</varname> (integer) The default dialog timeout (in seconds), in the absence of a custom value provided in an AVP. Default value is 43200 (12 hours). Set <varname>default_timeout</varname> parameter ... modparam("dialog", "default_timeout", 21600) ...
<varname>dlg_extra_hdrs</varname> (string) A string containing the extra headers (full format, with EOH) to be added to requests generated locally by the module (like BYEs). Default value is NULL. Set <varname>dlf_extra_hdrs</varname> parameter ... modparam("dialog", "dlg_extra_hdrs", "Hint: credit expired\r\n") ...
<varname>dlg_match_mode</varname> (integer) How the sequential requests should be matched against the known dialogs. The modes are a combination of matching based on a cookie (DID) stored as cookie in Record-Route header and matching based on SIP elements (as in RFC 3261). Note: DID-based matching does not replace callid/fromtag/totag comparison. It will speed up dialog matching by not iterating over the whole dialog list for callid/fromtag/totag comparison, but instead it uses a hash table to find the respective dialog and then doing only one callid/fromtag/totag comparison. Thus, there is no security issue when using DID based matching. Use DID_FALLBACK for maximum interoperability or use DID_ONLY to reject buggy clients or hacking attempts. DID_NONE is only useful, when you want to hide dialog-tracking from the users (preventing the DID Record-Route cookie). 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 fall back 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). Set <varname>dlg_match_mode</varname> parameter ... modparam("dialog", "dlg_match_mode", 1) ...
<varname>detect_spirals</varname> (integer) Whether spirals (i.e., messages routed through the proxy multiple times) should be detected. If set to 0, spirals will not be detected and result in the generation of a new, possibly dangling dialog structure per occurring spiral. If set to 1, spirals are detected and internally mapped to existing dialog structures. Default value is 1. Set <varname>detect_spirals</varname> parameter ... modparam("dialog", "detect_spirals", 1) ...
<varname>db_url</varname> (string) If you want to store the information about the dialogs in a database, a database URL must be specified. Default value is &defaultdb;. Set <varname>db_url</varname> parameter ... modparam("dialog", "db_url", "&exampledb;") ...
<varname>db_mode</varname> (integer) Mode of synchronisation of dialog information from memory to an underlying database (if desired): 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. Set <varname>db_mode</varname> parameter ... modparam("dialog", "db_mode", 1) ...
<varname>db_update_period</varname> (integer) The interval (seconds) at which to update dialogs' information, if you chose to store the dialogs' info at a given interval. Too short an interval will generate intensive database operations, while an excessively long one will miss dialogs with a short lifetime. Default value is 60. Set <varname>db_update_period</varname> parameter ... modparam("dialog", "db_update_period", 120) ...
<varname>db_fetch_rows</varname> (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 the fetch_result() capability. A value of 0 means the database fetch is not limited. Default value is 200. Set <varname>db_fetch_rows</varname> parameter ... modparam("dialog", "db_fetch_rows", 500) ...
<varname>db_skip_load</varname> (integer) Set db_skip_load to 1, to skip the loading of dialogs from the database alltogether. Default value is 0 ( not skipped ). Set <varname>db_skip_load</varname> parameter ... modparam("dialog", "db_skip_load", 1) ...
<varname>table_name</varname> (string) If you want to store the information about the dialogs in a database a table name must be specified. Default value is dialog. Set <varname>table_name</varname> parameter ... modparam("dialog", "table_name", "my_dialog") ...
<varname>call_id_column</varname> (string) The column name in the database to store the dialogs' callid. Default value is callid. Set <varname>callid_column</varname> parameter ... modparam("dialog", "call_id_column", "callid_c_name") ...
<varname>from_uri_column</varname> (string) The column name in the database to store the caller's sip address. Default value is from_uri. Set <varname>from_uri_column</varname> parameter ... modparam("dialog", "from_uri_column", "from_uri_c_name") ...
<varname>from_tag_column</varname> (string) The column name in the database to store the From tag from the INVITE request. Default value is from_tag. Set <varname>from_tag_column</varname> parameter ... modparam("dialog", "from_tag_column", "from_tag_c_name") ...
<varname>to_uri_column</varname> (string) The column name in the database to store the callee's sip address. Default value is to_uri. Set <varname>to_uri_column</varname> parameter ... modparam("dialog", "to_uri_column", "to_uri_c_name") ...
<varname>to_tag_column</varname> (string) The column 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. Set <varname>to_tag_column</varname> parameter ... modparam("dialog", "to_tag_column", "to_tag_c_name") ...
<varname>from_cseq_column</varname> (string) The column name in the database to store the cseq from caller side. Default value is caller_cseq. Set <varname>from_cseq_column</varname> parameter ... modparam("dialog", "from_cseq_column", "column_name") ...
<varname>to_cseq_column</varname> (string) The column name in the database to store the cseq from callee side. Default value is callee_cseq. Set <varname>to_cseq_column</varname> parameter ... modparam("dialog", "to_cseq_column", "column_name") ...
<varname>from_route_column</varname> (string) The column name in the database to store the route records from caller side (proxy to caller). Default value is caller_route_set. Set <varname>from_route_column</varname> parameter ... modparam("dialog", "from_route_column", "column_name") ...
<varname>to_route_column</varname> (string) The column name in the database to store the route records from callee side (proxy to callee). Default value is callee_route_set. Set <varname>to_route_column</varname> parameter ... modparam("dialog", "to_route_column", "column_name") ...
<varname>from_contact_column</varname> (string) The column name in the database to store the caller's contact uri. Default value is caller_contact. Set <varname>from_contact_column</varname> parameter ... modparam("dialog", "from_contact_column", "column_name") ...
<varname>to_contact_column</varname> (string) The column name in the database to store the callee's contact uri. Default value is callee_contact. Set <varname>to_contact_column</varname> parameter ... modparam("dialog", "to_contact_column", "column_name") ...
<varname>from_sock_column</varname> (string) The column name in the database to store the information about the local interface receiving the traffic from caller. Default value is caller_sock. Set <varname>from_sock_column</varname> parameter ... modparam("dialog", "from_sock_column", "column_name") ...
<varname>to_sock_column</varname> (string) The column name in the database to store information about the local interface receiving the traffic from callee. Default value is callee_sock. Set <varname>to_sock_column</varname> parameter ... modparam("dialog", "to_sock_column", "column_name") ...
<varname>h_id_column</varname> (string) The column name in the database to store the dialogs' hash id information. Default value is hash_id. Set <varname>h_id_column</varname> parameter ... modparam("dialog", "h_id_column", "hash_id_c_name") ...
<varname>h_entry_column</varname> (string) The column name in the database to store the dialogs' hash entry information. Default value is hash_entry. Set <varname>h_entry_column</varname> parameter ... modparam("dialog", "h_entry_column", "h_entry_c_name") ...
<varname>state_column</varname> (string) The column name in the database to store the dialogs' state information. Default value is state. Set <varname>state_column</varname> parameter ... modparam("dialog", "state_column", "state_c_name") ...
<varname>start_time_column</varname> (string) The column name in the database to store the dialogs' start time information. Default value is start_time. Set <varname>start_time_column</varname> parameter ... modparam("dialog", "start_time_column", "start_time_c_name") ...
<varname>timeout_column</varname> (string) The column name in the database to store the dialogs' timeout. Default value is timeout. Set <varname>timeout_column</varname> parameter ... modparam("dialog", "timeout_column", "timeout_c_name") ...
<varname>sflags_column</varname> (string) The column name in the database to store the script flags. Default value is sflags. Set <varname>sflags_column</varname> parameter ... modparam("dialog", "sflags_column", "s_flags") ...
<varname>toroute_column</varname> (string) The column name in the database to store the index of the route to be executed at timeout. Default value is toroute_name. Set <varname>toroute_column</varname> parameter ... modparam("dialog", "toroute_column", "timeout_route") ...
<varname>vars_table_name</varname> (string) If you want to store the variables for a dialog in a database a table name must be specified. Default value is dialog_vars. Set <varname>vars_table_name</varname> parameter ... modparam("dialog", "vars_table_name", "my_dialog_vars") ...
<varname>vars_h_id_column</varname> (string) The column name in the database to store the dialogs' hash id information (as a reference to the dialog table). Default value is hash_id. Set <varname>vars_h_id_column</varname> parameter ... modparam("dialog", "vars_h_id_column", "vars_h_id_name") ...
<varname>vars_h_entry_column</varname> (string) The column name in the database to store the dialogs' hash entry information (as a reference to the dialog table). Default value is hash_entry. Set <varname>vars_h_entry_column</varname> parameter ... modparam("dialog", "vars_h_entry_column", "vars_h_entry_name") ...
<varname>vars_key_column</varname> (string) The column name in the database to store the keys of a variable. Default value is dialog_key. Set <varname>vars_key_column</varname> parameter ... modparam("dialog", "vars_key_column", "vars_key_name") ...
<varname>vars_value_column</varname> (string) The column name in the database to store the keys of a variable. Default value is dialog_value. Set <varname>vars_value_column</varname> parameter ... modparam("dialog", "vars_value_column", "vars_value_name") ...
<varname>profiles_with_value</varname> (string) List of names for profiles with values. Default value is empty. Set <varname>profiles_with_value</varname> parameter ... modparam("dialog", "profiles_with_value", "caller ; my_profile") ...
<varname>profiles_no_value</varname> (string) List of names for profiles without values. Default value is empty. Set <varname>profiles_no_value</varname> parameter ... modparam("dialog", "profiles_no_value", "inbound ; outbound") ...
<varname>bridge_controller</varname> (string) SIP address to be used in From header when initiating a call bridge. Default value is sip:controller@kamailio.org. Set <varname>bridge_controller</varname> parameter ... modparam("dialog", "bridge_controller", "sip:ctd@kamailio.org") ...
<varname>bridge_contact</varname> (string) SIP address to be used in Contact header when doing a call bridge. Default value is sip:controller@kamailio.org:5060. Set <varname>bridge_contact</varname> parameter ... modparam("dialog", "bridge_contact", "sip:ctd@127.0.0.1:5060") ...
<varname>initial_cbs_inscript</varname> (int) If the initial dialog callbacks (i.e., DLGCB_CREATED and DLGCB_SPIRALED) should be executed in-script or post-script. If dlg_manage() is not used, the setting of this parameter does not matter; otherwise, initial callbacks will be executed directly after dlg_manage() is called if this parameter is enabled. If it is disabled, initial callback execution will be postponed until configuration script execution completes. The supported values are: 0 - POST-SCRIPT - execute initial callbacks after the script completes; 1 - IN-SCRIPT - execute initial callbacks during script execution, i.e., right after dlg_manage() is called; Default value is 1. Set <varname>initial_cbs_inscript</varname> parameter ... modparam("dialog", "initial_cbs_inscript", 0) ...
<varname>send_bye</varname> (int) If set to 1, BYE requests will be sent out for each dialog that timed out. It is an alternative to $dlg_ctx(timeout_bye)=1 for all dialogs. Default value is 0. Set <varname>send_bye</varname> parameter ... modparam("dialog", "send_bye", 1) ...
<varname>wait_ack</varname> (int) If set to 1, dialog will be keept a bit longer in memory in order to absorb the ACK negative replies of initial INVITE. If not, the dialog is destroyed when negative reply is sent out (less internal complexity). Default value is 1. Set <varname>wait_ack</varname> parameter ... modparam("dialog", "wait_ack", 0) ...
<varname>ka_timer</varname> (int) Keep-alive timer step - how often to execute the callback to send dialog keep alives (SIP OPTIONS requests within dialog). The value represents the number of seconds. Default value is 0 (no keep alive). Set <varname>ka_timer</varname> parameter ... modparam("dialog", "ka_timer", 10) ...
<varname>ka_interval</varname> (int) The interval between keep alives within dialog (SIP OPTIONS requests), sent to caller or callee. The keep alive request will be sent by the first callback fired by KA timer after the ka_interval elapsed from dialog setup or previous keep-alive. The value represents the number of seconds. If the requests times out (generating a 408) or if the UA responds with 481 the lifetime is set to 10 seconds. When lifetime expires the dialog will be terminated. Any other response (including error responses) will reset the timers. Default value is 0 (no keep alive). The lowest settable interval is 30 seconds. Set <varname>ka_interval</varname> parameter ... modparam("dialog", "ka_interval", 300) ...
<varname>timeout_noreset</varname> (int) If set to 1, the dialog timeout won't be reset each time a sequential request is processed. It is an alternative to dlg_set_property("timeout-noreset") for all dialogs. Default value is 0. Set <varname>timeout_noreset</varname> parameter ... modparam("dialog", "timeout_noreset", 1) ...
<varname>timer_procs</varname> (int) If set to 1, the dialog will run own timer process to execute dialog timeout tasks. Default value is 0 (use core time process). Set <varname>timer_procs</varname> parameter ... modparam("dialog", "timer_procs", 1) ...
<varname>track_cseq_updates</varname> (int) Enable the callbacks for tracking if CSeq number needs to be updated. It is the case when the INVITE has to be authenticated to downstream provider using uac_auth() from uac module. This is done only for requests in downstream direction. The CSeq difference is stored in $dlg_var(cseq_diff), be sure this variable is not overwritten via config operation. Default value is 0 (disabled). Set <varname>track_cseq_updates</varname> parameter ... modparam("dialog", "track_cseq_updates", 1) ...
<varname>lreq_callee_headers</varname> (string) SIP headers to be added when sending local generated requests (e.g., BYE) to callee. It can be useful when you use topoh module with call-id masking (see the docs of topoh module). Default value is null. Set <varname>lreq_callee_headers</varname> parameter ... modparam("dialog", "lreq_callee_headers", "TH: dlh\r\n") ...
Functions
<function moreinfo="none">set_dlg_profile(profile,[value])</function> Inserts the current dialog into a profile. Note that if the profile does not support values, they will be silently discarded. Also, there is no check for inserting the same dialog into the same profile 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 membership of the dialog in 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. <function>set_dlg_profile</function> usage ... set_dlg_profile("inbound_call"); set_dlg_profile("caller","$fu"); ...
<function moreinfo="none">unset_dlg_profile(profile,[value])</function> 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. <function>unset_dlg_profile</function> usage ... unset_dlg_profile("inbound_call"); unset_dlg_profile("caller","$fu"); ...
<function moreinfo="none">is_in_profile(profile,[value])</function> 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 the membership of the dialog in the profile per se is checked. Note that if the profile does not support values, the value parameter 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. <function>is_in_profile</function> 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"); } ...
<function moreinfo="none">get_profile_size(profile,[value],size)</function> 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, i.e. how many dialogs were inserted into the profile with a specific value. If no value is passed, only the membersip of the dialog in the profile per se is checked. Note that if the profile does not support values, the value parameter 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. <function>get_profile_size</function> 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"); ...
<function moreinfo="none">dlg_isflagset(flag)</function> 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. <function>dlg_isflagset</function> usage ... if(dlg_isflagset("1")) { ... } ...
<function moreinfo="none">dlg_setflag(flag)</function> 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. <function>dlg_setflag</function> usage ... dlg_setflag("1"); ...
<function moreinfo="none">dlg_resetflag(flag)</function> 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. <function>dlg_resetflag</function> usage ... redlg_setflag("1"); ...
<function moreinfo="none">dlg_bye(side)</function> Send BYE to both parties of a dialog. Meaning of the parameters is as follows: side - where to send the BYE. It can be: 'caller', 'callee', or 'all' (send to both sides). This function can be used from ANY_ROUTE. <function>dlg_bye</function> usage ... dlg_bye("all"); ...
<function moreinfo="none">dlg_refer(side, address)</function> Refer the 'side' to a new SIP 'address'. Meaning of the parameters is as follows: side - which side of the dialog 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. <function>dlg_refer</function> usage ... dlg_refer("caller", "sip:announcement@kamailio.org"); ...
<function moreinfo="none">dlg_manage()</function> Process current SIP request with dialog module. It is an 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. <function>dlg_manage</function> 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(); ... } ...
<function moreinfo="none">dlg_bridge(from, to, op)</function> 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. <function>dlg_bridge</function> usage ... dlg_bridge("sip:user@kamailio.org", "sip:annoucement@kamailio.org", "sip:kamailio.org:5080"); ...
<function moreinfo="none">dlg_get(callid, ftag, ttag)</function> 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. <function>dlg_get</function> usage ... if(dlg_get("abcdef", "123", "456")) { dlg_bye("all"); } ...
<function moreinfo="none">is_known_dlg()</function> This function checks if the current SIP message being processed belongs to any transaction within an active dialog that the dialog module is currently tracking. This is a check for tracking of any kind, without regard to profiles. This function has numerous potential applications, among which is that it can be used to strengthen security for loose-routing sequential (in-dialog) requests or responses to them, as by providing a preventative check against spoofing on the proxy level instead of leaving the issue purely to the receiving UA. This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, REPLY_ROUTE and FAILURE_ROUTE. <function>is_known_dlg()</function> usage ... if(!uri == myself) { if(is_known_dlg()) { xlog("Request $rm from $ci is in-dialog\n"); } } ...
<function moreinfo="none">dlg_set_timeout(timeout [, h_entry, h_id])</function> Set the dialog timeout. Dialog timeout will be updated if it was already set. If h_entry and h_id parameters are not provided, the dialog will be searched based on (callid, fromtag, totag) of currently processed SIP message. Meaning of the parameters is as follows: timeout - the interval in seconds after which the dialog will time out. h_entry - h_entry value of the iternal dialog identifier. h_id - h_id valye if the internal dialog identifier. This function can be used from ANY_ROUTE. <function>dlg_set_timeout</function> usage ... if(dlg_set_timeout("180", "123", "456")) { ... } ...
<function moreinfo="none">dlg_set_timeout_by_profile(profile, [value], timeout)</function> Like dlg_set_timeout(), but simultaneously sets the timeout of all dialogs in a given profile. Can be constrained by profile value. Meaning of the parameters is as follows: profile - The dialog profile across which to apply the timeout. value (optional) - The profile value to use when applying the dialog timeout. timeout - the interval in seconds after which the dialog will time out. This function can be used from ANY_ROUTE. <function>dlg_set_timeout_by_profile</function> usage ... # All dialogs belonging to user abc123 (tracked via set_dlg_profile()) # will be timed out in 3 seconds. dlg_set_timeout_by_profile("users", "abc123", "3"); ...
<function moreinfo="none">dlg_set_property(attr)</function> Set a dialog property - an attribute that enable/disable various behaviours (e.g., sending keep alive requests). Meaning of the parameters is as follows: attr - name of property. It can be: 'ka-src' - send keep alive OPTION requests to caller 'ka-dst' - send keep alive OPTION requests to callee 'timeout-noreset' - don't reset timeout on in-dialog messages reception If keep alive is enabled for a dialog, the module will send SIP OPTIONS requests with CSeq lower or equal than last request within dialog, with the scope of detecting if the destination is still in the call. If the keep alive request results in a local timeout or '481 Call Leg/Transaction Does Not Exist', then the dialog is ended from the server. If 'timeout-noreset' is set, dialog timeout won't be reset upon reception of in-dialog messages (default behavior). This function can be used from ANY_ROUTE. <function>dlg_set_property</function> usage ... dlg_set_property("ka-src"); dlg_set_property("ka-dst"); dlg_set_property("timeout-noreset"); ...
<function moreinfo="none">dlg_remote_profile(cmd, profile, value, uid, expires)</function> Manage remote profile via config file. A remote profile item is considered when the dialog is not managed by this server instance. The notification to add/remove can be received via SIP or a RPC command, the operation can be then triggered from configuration file. This should allow counting active dialogs in a profile that are managed by multiple SIP server instances. Meaning of the parameters is as follows: cmd - the operations to do: add - add an item in profile; rm - remove an item from profile profile - name of profile value - value for profile (if no value is needed for that profile, use an empty string. expires - absolute time (unix timestamp) when this profile item should be removed automatically (time based), if still in the profile This function can be used from ANY_ROUTE. <function>dlg_remote_profile</function> usage ... $var(exp) = 3600 + $Ts; dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); ...
Statistics
<varname>active_dialogs</varname> Returns the number of current active dialogs (may be confirmed or not).
<varname>early_dialogs</varname> Returns the number of early dialogs.
<varname>processed_dialogs</varname> Returns the total number of processed dialogs (terminated, expired or active) from the startup.
<varname>expired_dialogs</varname> Returns the total number of expired dialogs from the startup.
<varname>failed_dialogs</varname> Returns the number of failed dialogs.
MI Commands
<varname>dlg_list</varname> 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) - from tag (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
<varname>dlg_list_ctx</varname> 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_
<varname>dlg_end_dlg</varname> 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. Note: Works only for confirmed dialogs. MI FIFO Command Format: :dlg_end_dlg:_reply_fifo_file_ 342 56 _empty_line_
<varname>dlg_terminate_dlg</varname> Terminates a singe dialog, identified by a Call-ID. Name: dlg_terminate_dlg Parameters: callid - callid of the dialog to be terminated. from_tag (optional, but cannot be present without the callid parameter) - from tag (as per initial request) of the dialog to be terminated. 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. Note: Works only for confirmed dialogs. MI FIFO Command Format: :dlg_terminate_dlg:_reply_fifo_file_ abcdrssfrs122444@192.168.1.1 AAdfeEFF33
<varname>profile_get_size</varname> 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 the 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_
<varname>profile_list_dlgs</varname> 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 if 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_
<varname>dlg_bridge</varname> 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_
Exported RPC Functions
<varname>dlg.list</varname> Lists the description of all dialogs (calls). Name: dlg.list RPC Command Format: serctl dlg_list
<varname>dlg.list_ctx</varname> 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 RPC Command Format: serctl dlg.list_ctx
<varname>dlg.dlg_list</varname> Lists the description of one dialog. The dialog identifiers are to be passed as parameter (callid and fromtag). Name: dlg.dlg_list Parameters: callid callid of the dialog to be listed. from_tag from tag (as per initial request) of the dialog to be listed. RPC Command Format: serctl dlg.list abcdrssfrs122444@192.168.1.1 AAdfeEFF33
<varname>dlg.dlg_list_ctx</varname> The same as the dlg.list_ctx but including in the dialog description the associated context from modules sitting on top of the dialog module. Name: dlg.dlg_list_ctx Parameters: see dlg_list RPC Command Format: serctl dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33
<varname>dlg.end_dlg</varname> 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 RPC command. RPC Command Format: serctl dlg.end_dlg 342 56
<varname>dlg.profile_get_size</varname> 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 the simply belonging of the dialog to the profile is checked. Note that if the profile does not support values, the value parameter will be silently discarded. Name: dlg.profile_get_size Parameters: profile - name of the profile to get the value for. value (optional)- string value to further restrict the check; RPC Command Format: serctl dlg.dlg.profile_get_size inbound_calls
<varname>dlg.profile_list</varname> 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, i.e. 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 if the profile does not supports values, this will be silently discarded. Name: dlg.profile_list Parameters: profile - name of the profile to list the dialog for. value (optional)- string value to further restrict the check; RPC Command Format: serctl dlg.profile_list inbound_calls
<varname>dlg.bridge_dlg</varname> Bridge two SIP addresses into a call using INVITE(hold)-REFER-BYE mechanism. Name: dlg.bridge_dlg Parameters: from - SIP address to initiate the call to - SIP address to refer 'from' to op (optional) - outbound proxy SIP address RPC Command Format: serctl dlg.list from to op
Exported pseudo-variables
<varname>$DLG_count</varname> Returns the number of current active dialogs (may be confirmed or not).
<varname>$DLG_status</varname> 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.
<varname>$DLG_lifetime</varname> 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.
<varname>$dlg(...)</varname> Access to dialog attributes.
<varname>$dlg_ctx(...)</varname> Access to dialog context attributes.
<varname>$dlg_var(key)</varname> This is a read/write variable that can be used to store custom values assigned with a dialog (e.g. the URI of a billing-server, an assigned emergency-server). This pseudo-variable will be available only for subsequential requests after doing loose_route(). Note: You will receive "NULL", if there is no dialog for this request.
Event Routes
<varname>event_route[dialog:start]</varname> Executed when 200OK for INVITE is processed.
<varname>event_route[dialog:end]</varname> Executed when BYE is processed or dialog timed out.
<varname>event_route[dialog:failed]</varname> Executed when dialog is not completed (+300 reply to INVITE).