# &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 may benefit from an awareness of "calls" in the proxy, 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 can be used directly from the configuration route script as well as functions for the RPC interface.

This module also provides an API foundation on which to build more complex dialog-oriented functionality in other &kamailio; modules.

## How it works

To create the dialog associated with an initial INVITE request, execute the function dlg_manage() 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 - dialog.p.default_timeout) and custom timeout (see timeout_avp - dialog.p.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

The early and deleted dialog states are not updated in database storage.

## 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 administrator; it can be 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

### `enable_stats` (integer)

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

Default value is 1 (enabled).

#### Set `enable_stats` parameter

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

### `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 two.

IMPORTANT: If dialog 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 `hash_size` parameter

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

### `rr_param` (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 `rr_param` parameter

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

### `timeout_avp` (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 `timeout_avp` parameter

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

### `default_timeout` (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 `default_timeout` parameter

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

### `early_timeout` (integer)

The timeout (in seconds) after which the dialogs in unconfirmed or early state (no final response received) are destroyed.

Default value is 300 (5 minutes).

#### Set `early_timeout` parameter

    ...
    modparam("dialog", "early_timeout", 180)
    ...

### `noack_timeout` (integer)

The timeout (in seconds) after which the dialogs which were answered with 200 OK but didn't receive the ACK are marked for termination (the lifetime is set to 10 more seconds).

Default value is 60 (1 minute).

#### Set `noack_timeout` parameter

    ...
    modparam("dialog", "noack_timeout", 90)
    ...

### `end_timeout` (integer)

The timeout (in seconds) after which the dialogs in terminated state are destroyed.

Default value is 300 (5 minutes).

#### Set `end_timeout` parameter

    ...
    modparam("dialog", "end_timeout", 180)
    ...

### `dlg_extra_hdrs` (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 `dlf_extra_hdrs` parameter

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

### `dlg_match_mode` (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 `dlg_match_mode` parameter

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

### `detect_spirals` (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 `detect_spirals` parameter

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

### `db_url` (string)

In order to store information about dialogs in a database, a database URL must be specified.

Default value is &defaultdb;.

#### Set `db_url` parameter

    ...
    modparam("dialog", "db_url", "&exampledb;")
    ...

### `db_mode` (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 immediately.

- 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 `db_mode` parameter

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

### `db_update_period` (integer)

The interval (seconds) at which to update dialogs' information, if the server is configured to store the dialog information at a given interval. A too short interval will generate intensive database operations, while an excessively long one will miss dialogs with a short lifetime.

Default value is 60 seconds.

#### Set `db_update_period` parameter

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

### `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 the fetch_result() capability. A value of 0 means the database fetch is not limited.

Default value is 200.

#### Set `db_fetch_rows` parameter

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

### `db_skip_load` (integer)

Set db_skip_load to 1, to skip the loading of dialog data from the database.

Default value is 0 ( not skipped ).

#### Set `db_skip_load` parameter

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

### `table_name` (string)

Database table name used for storing dialog information.

Default value is dialog.

#### Set `table_name` parameter

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

### `call_id_column` (string)

The column name in the database to store the dialog call-id.

Default value is callid.

#### Set `call_id_column` parameter

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

### `from_uri_column` (string)

The column name in the database to store the caller's SIP address (URI).

Default value is from_uri.

#### Set `from_uri_column` parameter

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

### `from_tag_column` (string)

The column name in the database to store the From header tag from the INVITE request.

Default value is from_tag.

#### Set `from_tag_column` parameter

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

### `to_uri_column` (string)

The column name in the database to store the callee's SIP address (URI).

Default value is to_uri.

#### Set `to_uri_column` parameter

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

### `to_tag_column` (string)

The column name in the database to store the To header tag from the 200 OK response to the INVITE request, if present.

Default value is to_tag.

#### Set `to_tag_column` parameter

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

### `from_cseq_column` (string)

The column name in the database to store the Cseq from caller side.

Default value is caller_cseq.

#### Set `from_cseq_column` parameter

    ...
    modparam("dialog", "from_cseq_column", "from_cseq")
    ...

### `to_cseq_column` (string)

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

Default value is callee_cseq.

#### Set `to_cseq_column` parameter

    ...
    modparam("dialog", "to_cseq_column", "to_cseq")
    ...

### `from_route_column` (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 `from_route_column` parameter

    ...
    modparam("dialog", "from_route_column", "rroute_from")
    ...

### `to_route_column` (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 `to_route_column` parameter

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

### `from_contact_column` (string)

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

Default value is caller_contact.

#### Set `from_contact_column` parameter

    ...
    modparam("dialog", "from_contact_column", "from_contact_uri")
    ...

### `to_contact_column` (string)

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

Default value is callee_contact.

#### Set `to_contact_column` parameter

    ...
    modparam("dialog", "to_contact_column", "to_contact_uri")
    ...

### `from_sock_column` (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 `from_sock_column` parameter

    ...
    modparam("dialog", "from_sock_column", "socket_from")
    ...

### `to_sock_column` (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 `to_sock_column` parameter

    ...
    modparam("dialog", "to_sock_column", "socket_to")
    ...

### `h_id_column` (string)

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

Default value is hash_id.

#### Set `h_id_column` parameter

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

### `h_entry_column` (string)

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

Default value is hash_entry.

#### Set `h_entry_column` parameter

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

### `state_column` (string)

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

Default value is state.

#### Set `state_column` parameter

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

### `start_time_column` (string)

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

Default value is start_time.

#### Set `start_time_column` parameter

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

### `timeout_column` (string)

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

Default value is timeout.

#### Set `timeout_column` parameter

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

### `sflags_column` (string)

The column name in the database to store the dialog script flags.

Default value is sflags.

#### Set `sflags_column` parameter

    ...
    modparam("dialog", "sflags_column", "s_flags")
    ...

### `toroute_name_column` (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 `toroute_name_column` parameter

    ...
    modparam("dialog", "toroute_name_column", "timeout_route")
    ...

### `vars_table_name` (string)

If you want to store the dialog variables ($dlg_var(name)) for a dialog in a database a table name must be specified.

Default value is dialog_vars.

#### Set `vars_table_name` parameter

    ...
    modparam("dialog", "vars_table_name", "my_dialog_vars")
    ...

### `vars_h_id_column` (string)

The column name in the database to store the dialog's hash id information (as a reference to the dialog table).

Default value is hash_id.

#### Set `vars_h_id_column` parameter

    ...
    modparam("dialog", "vars_h_id_column", "vars_h_id_name")
    ...

### `vars_h_entry_column` (string)

The column name in the database to store the dialog's hash entry information (as a reference to the dialog table).

Default value is hash_entry.

#### Set `vars_h_entry_column` parameter

    ...
    modparam("dialog", "vars_h_entry_column", "vars_h_entry_name")
    ...

### `vars_key_column` (string)

The column name in the database to store the names (keys) of a dialog variable.

Default value is dialog_key.

#### Set `vars_key_column` parameter

    ...
    modparam("dialog", "vars_key_column", "vars_key_name")
    ...

### `vars_value_column` (string)

The column name in the database to store the values of a dialog variable.

Default value is dialog_value.

#### Set `vars_value_column` parameter

    ...
    modparam("dialog", "vars_value_column", "vars_value_name")
    ...

### `profiles_with_value` (string)

List of names for profiles with values, separated with semi-colon ";".

Default value is empty.

#### Set `profiles_with_value` parameter

    ...
    modparam("dialog", "profiles_with_value", "caller ; my_profile")
    ...

### `profiles_no_value` (string)

List of names for profiles without values, separated with semi-colon ";".

Default value is empty.

#### Set `profiles_no_value` parameter

    ...
    modparam("dialog", "profiles_no_value", "inbound ; outbound")
    ...

### `bridge_controller` (string)

SIP address to be used in From header when initiating a call bridge.

Default value is sip:controller@kamailio.org.

#### Set `bridge_controller` parameter

    ...
    modparam("dialog", "bridge_controller", "sip:ctd@kamailio.org")
    ...

### `bridge_contact` (string)

SIP address to be used in Contact header when doing a call bridge.

Default value is sip:controller@kamailio.org:5060.

#### Set `bridge_contact` parameter

    ...
    modparam("dialog", "bridge_contact", "sip:ctd@127.0.0.1:5060")
    ...

### `initial_cbs_inscript` (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 `initial_cbs_inscript` parameter

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

### `send_bye` (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 `send_bye` parameter

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

### `dlg_filter_mode` (int)

Set dialog fitering mode, which can specify what dialogs are processed. Its value can be a combination (the sum) of following flags:

- 1 - do not send keepalives and do not execute timeout function if dialog is not local (if the associated bind address is not a local socket).

Default value is 0.

#### Set `dlg_filter_mode` parameter

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

### `wait_ack` (int)

If set to 1, dialog will be kept 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 `wait_ack` parameter

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

### `ka_timer` (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 `ka_timer` parameter

    ...
    modparam("dialog", "ka_timer", 10)
    ...

### `ka_interval` (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 `ka_interval` parameter

    ...
    modparam("dialog", "ka_interval", 300)
    ...

### `ka_failed_limit` (int)

The number of failed keep-alive requests that is accepted before generating a dialog timeout.

Default value is 1.

#### Set `ka_failed_limit` parameter

    ...
    modparam("dialog", "ka_failed_limit", 5)
    ...

### `timeout_noreset` (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 `timeout_noreset` parameter

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

### `timer_procs` (int)

If set to 1, the dialog module will start a separate dialog timer process to execute dialog timeout tasks. The default is to use the core timer process.

Default value is 0 (use core timer process).

#### Set `timer_procs` parameter

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

### `enable_dmq` (int)

If set to 1, the dialog will be synced via dmq. For now, only very basic dialog info is shared, just enough to have synced profiles. Notably, it is not possible to send in-dialog requests on any but the original proxy instance.

Default value is 0.

#### Set `enable_dmq` parameter

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

### `track_cseq_updates` (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 `track_cseq_updates` parameter

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

### `lreq_callee_headers` (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 `lreq_callee_headers` parameter

    ...
    modparam("dialog", "lreq_callee_headers", "TH: dlh\r\n")
    ...

### `event_callback` (str)

The name of the function in the kemi configuration file (embedded scripting language such as Lua, Python, ...) to be executed instead of event_route[...] blocks.

The function receives a string parameter with the name of the event, the values are: 'dialog:start', 'dialog:end', 'dialog:failed'. It is also executed if '$dlg_ctx(timeout_route)' is set, the callback function being executed with the variable value as parameter.

Default value is 'empty' (no function is executed for events).

#### Set `event_callback` parameter

    ...
    modparam("dialog", "event_callback", "ksr_dialog_event")
    ...
    -- event callback function implemented in Lua
    function ksr_dialog_event(evname)
    	KSR.info("===== dialog module triggered event: " .. evname .. "\n");
    	return 1;
    end
    ...

### `h_id_start` (int)

Set the offset to be used for generating dialog internal hash id. If set to -1, the h_id_start is set to the value of the server_id global parameter.

Default value is 0.

#### Set `h_id_start` parameter

    ...
    modparam("dialog", "h_id_start", 5)
    ...

### `h_id_step` (int)

Set the step to increment the dialog internal hash id.

If the value is greater than 1, the internal hash id is generated with the rule: h_id_start + N * h_id_step. The first value of N is randomly selected at startup, then incremented by 1 for each new dialog. Setting h_id_start and h_id_step to non-default values should be done when using dlg_db_load_callid(...) or dlg_db_load_extra() to load dialog records generated by another &kamailio; instance. Pay attention to ensure that those &kamailio; instances are not going to generate overlapping dialog hash id values by using different h_id_start and the same h_id_step (h_id_step has to be greater than the maximum value of h_id_start).

Default value is 1.

#### Set `h_id_step` parameter

    ...
    modparam("dialog", "h_id_step", 10)
    ...

### `keep_proxy_rr` (string)

Whether to keep the record-route header added by the proxy. When enabled, it will keep this proxy's record-route header from the reply. The result is that generated requests like the BYE from the dlg_end_dlg mi function will pass through the proxy (looped).

Valid values are:

- 0 - Don't keep any proxy Record-Route headers

- 1 - Keep Record-route headers for the callee leg

- 2 - Keep Record-route headers for the caller leg

- 3 - Keep Record-route headers for both legs

Default value is 0.

#### Set `dlg_keep_proxy_rr` parameter

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

### `bye_early_code` (int)

This parameter defines the reply-code being used for dialogs being terminated in early stage (e.g. before 200 OK/ACK).

Default value is 480.

#### Set `bye_early_code` parameter

    ...
    modparam("dialog", "bye_early_code", 503)
    ...

### `bye_early_reason` (string)

This parameter defines the reply-reason being used for dialogs being terminated in early stage (e.g. before 200 OK/ACK).

Default value is Temporarily Unavailable.

#### Set `bye_early_reason` parameter

    ...
    modparam("dialog", "bye_early_reason", "Call terminated")
    ...

### `dlg_ctxiuid_mode` (int)

Set dialog context iuid mode, which can specify additional cases when the internal unique id should be set:

- 1 - set it when processing CANCEL requests.

Default value is 0.

#### Set `dlg_ctxiuid_mode` parameter

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

### `debug_variables` (int)

Activate additional debugging for printing internal lists for dialog variables. This output is only visible at debug log level and should only be used for debugging. By default it is deactivated.

Default value is 0.

#### Set `debug_variables` parameter

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

### `dlg_mode` (int)

Control how dialog state management is done. If set to 0, the the management is done with tm module callbacks; if set to 1, tm callbacks are not used, states have to be set from config.

Default value is 0.

#### Set `dlg_mode` parameter

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

## Functions

### `set_dlg_profile(profile[, value])`

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.

#### `set_dlg_profile` usage

    ...
    set_dlg_profile("inbound_call");
    set_dlg_profile("caller","$fu");
    ...

### `unset_dlg_profile(profile[, value])`

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.

#### `unset_dlg_profile` usage

    ...
    unset_dlg_profile("inbound_call");
    unset_dlg_profile("caller","$fu");
    ...

### `is_in_profile(profile[, value])`

Checks if the current dialog belongs to a profile. If the profile is defined with values, then the check is also matching with the specific value provided as parameter.

Note that if the profile is not defined with support for 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 be matched during the check. Pseudo-variables are supported.

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

#### `is_in_profile` usage

    ...
    if (is_in_profile("inbound_call")) {
    	log("this request belongs to an inbound call\n");
    }
    ...
    if (is_in_profile("caller","XX")) {
    	log("this request belongs to a call of user XX\n");
    }
    ...

### `get_profile_size(profile[, value], size)`

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

#### `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");
    ...

### `dlg_isflagset(flag)`

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.

#### `dlg_isflagset` usage

    ...
    if(dlg_isflagset("1"))
    {
        ...
    }
    ...

### `dlg_setflag(flag)`

Set a 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.

#### `dlg_setflag` usage

    ...
    dlg_setflag("1");
    ...

### `dlg_resetflag(flag)`

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.

#### `dlg_resetflag` usage

    ...
    dlg_resetflag("1");
    ...

### `dlg_bye(side)`

Send BYE to parties of a dialog or - if in early stage - a CANCEL to the B-Party and a SIP response to the A-Party (as defined in bye_early_code / bye_early_reason).

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.

#### `dlg_bye` usage

    ...
    dlg_bye("all");
    ...

### `dlg_refer(side, address)`

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.

#### `dlg_refer` usage

    ...
    dlg_refer("caller", "sip:announcement@kamailio.org");
    ...

### `dlg_refer_did(h_entry, h_id, side, address)`

Refer the 'side' of the identified dialog to a new SIP 'address'.

Meaning of the parameters is as follows:

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

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

- side - which side of the dialog to REFER. It can be: 'caller' or 'callee'.

- address - SIP address to refer to.

The parameters can contain variables.

This function can be used from ANY_ROUTE.

#### `dlg_refer_did` usage

    ...
    dlg_refer_did("246","468", "caller", "sip:announcement@kamailio.org");
    ...

### `dlg_refer_dcid(callid, side, address)`

Refer the 'side' of the first matching dialog by call-id to a new SIP 'address'.

Meaning of the parameters is as follows:

- callid - call-id of the dialog

- side - which side of the dialog to REFER. It can be: 'caller' or 'callee'.

- address - SIP address to refer to.

The parameters can contain variables.

This function can be used from ANY_ROUTE.

#### `dlg_refer_cid` usage

    ...
    dlg_refer_cid("abcd-efgh-ijkl", "caller", "sip:announcement@kamailio.org");
    ...

### `dlg_manage()`

Process current SIP request with dialog module.

This function can be used from REQUEST_ROUTE.

#### `dlg_manage` usage

    ...
    modparam("dialog", "default_timeout", 100)
    ...
    request_route {
    ...
        if(is_method("INVITE") && !has_totag())
        {
            $dlg_ctx(timeout_route) = "DLGTIMEOUT";
            $dlg_ctx(timeout_bye) = 1;
        }
        dlg_manage();
    ...
    }
    ...

### `dlg_bridge(from, to, op)`

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.

#### `dlg_bridge` usage

    ...
    dlg_bridge("sip:user@kamailio.org", "sip:annoucement@kamailio.org",
       "sip:kamailio.org:5080");
    ...

### `dlg_get(callid, ftag, ttag)`

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 (it can be empty string to match a dialog during call setup (eg., match for CANCEL)).

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

#### `dlg_get` usage

    ...
    if(dlg_get("abcdef", "123", "456"))
    {
    	dlg_bye("all");
    }
    ...

### `dlg_get_var(callid, ftag, ttag, name, dst)`

Get dlg_var of another dialog value 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. Use "" value to indicate early dialog.

- name - key name of the $dlg_var.

- dst - pv to store the value of $dlg_var(name).

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

#### `dlg_get_var` usage

    ...
    if(dlg_get_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
    {
    	xdbg("$$dlg_var(test):$var(tmp)\n");
    }
    ...

### `dlg_set_var(callid, ftag, ttag, name, value)`

Set dlg_var of another dialog value 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. Use "" value to indicate early dialog.

- name - key name of the $dlg_var.

- value - string value to store at $dlg_var(name).

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

#### `dlg_set_var` usage

    ...
    if(dlg_set_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
    {
    	xdbg("set $$dlg_var(test):$var(tmp)\n");
    }
    # you can set vars in early dialog too
    if(dlg_set_var("$var(ci)", "$var(ft)", "", "test", "$var(tmp)"))
    {
    	xdbg("set $$dlg_var(test):$var(tmp)\n");
    }
    ...

### `is_known_dlg()`

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.

#### `is_known_dlg()` usage

    ...
    if(!uri == myself) {
    	if(is_known_dlg()) {
    		xlog("Request $rm from $ci is in-dialog\n");
    	}
    }
    ...

### `dlg_set_timeout(timeout [, h_entry, h_id])`

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 value if the internal dialog identifier.

This function can be used from ANY_ROUTE.

#### `dlg_set_timeout` usage

    ...
    if(dlg_set_timeout("180", "123", "456"))
    {
        ...
    }
    ...

### `dlg_set_timeout_by_profile(profile, [value], timeout)`

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.

#### `dlg_set_timeout_by_profile` 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");
    ...

### `dlg_set_property(attr)`

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.

#### `dlg_set_property` usage

    ...
    dlg_set_property("ka-src");
    dlg_set_property("ka-dst");
    dlg_set_property("timeout-noreset");
    ...

### `dlg_remote_profile(cmd, profile, value, uid, expires)`

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.

#### `dlg_remote_profile` usage

    ...
    $var(exp) = 3600 + $Ts;
    dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)");
    ...

### `dlg_set_ruri()`

This function sets the R-URI with the corresponding endpoint address stored in dialog structure (i.e., its Contact field).

This function can be used from ANY_ROUTE.

#### `dlg_set_ruri()` usage

    ...
    if(has_totag() and is_present_hf("Route") and uri==myself ) {
    	if(dlg_set_ruri()) {
    		xlog("Request URI changed from [$ou] to dlg value: [$ru]\n");
    	}
    }
    ...

### `dlg_db_load_callid(cival)`

Load dialog record from database matching on Call-Id provided as parameter.

This function can be used from ANY_ROUTE.

#### `dlg_db_load_callid()` usage

    ...
    if(has_totag()) {
        if(!is_known_dlg()) {
            dlg_db_load_callid("$ci");
    	    if(!is_known_dlg()) {
                xlog("no dialog found with callid: $ci\n");
            }
        }
    }
    ...

### `dlg_db_load_extra()`

Load all dialog records from database that are not in memory of the current &kamailio; instance.

This function can be used from ANY_ROUTE.

#### `dlg_db_load_extra()` usage

    ...
    if(has_totag()) {
        if(!is_known_dlg()) {
            dlg_db_load_extra();
    	    if(!is_known_dlg()) {
                xlog("no dialog found with callid: $ci\n");
            }
        }
    }
    ...

### `dlg_reset_property(attr)`

Reset 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

This function can be used from ANY_ROUTE.

#### `dlg_reset_property` usage

    ...
    dlg_reset_property("ka-src");
    dlg_reset_property("ka-dst");
    dlg_reset_property("timeout-noreset");
    ...

### `dlg_req_within(side, method, [headers], [content_type, content])`

Sends an in-dialog SIP Request with method to a party of a dialog indicated by the side parameter.

Meaning of the parameters is as follows:

- side - where to send the request. It can be: 'caller', 'callee', or 'all' (send to both sides).

- method - Method of the request

- headers (optional) - additional headers to be added to the request.

- content_type (optional) - Content-Type of the request body - will be added as Content-Type Header.

- content (optional) - Content to be sent as body.

This function can be used from ANY_ROUTE.

#### `dlg_req_within` usage

    ...
    	# Send a simple request:
    	dlg_req_within("all", "OPTIONS");
    ...
    	# Send a simple request with extra headers:
    	dlg_req_within("caller", "OPTIONS", "X-Info: Bandwidth granted\r\nX-Info-2: Go ahead\r\n");
    ...
    	# Send a simple request with body:
    	dlg_req_within("caller", "UPDATE", "application/sdp", "...some SDP...");
    ...
    	# Send a simple request with extra headers and body:
    	dlg_req_within("callee", "INFO", "X-Info: Bandwidth granted\r\n", "application/sdp", "...some SDP...");
    ...

### `dlg_set_state(newstate)`

Set the state for dialog matching current message.

Meaning of the parameters is as follows:

- newstate - the new state. It can be:

  - 'unconfirmed'
  - 'early'
  - 'answered'
  - 'confirmed'
  - 'deleted'

This function can be used from ANY_ROUTE.

#### `dlg_set_state` usage

    ...
    dlg_set_state("early");
    ...

## Statistics

### `active_dialogs`

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

### `early_dialogs`

Returns the number of early dialogs.

### `processed_dialogs`

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

### `expired_dialogs`

Returns the total number of expired dialogs from the startup.

### `failed_dialogs`

Returns the number of failed dialogs.

## RPC Commands

### dlg.list

Lists the description of all dialogs (active calls).

Name: dlg.list

RPC Command Format:

    ...
    &kamctl; rpc dlg.list
    ...

### dlg.list_ctx

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:

    ...
    &kamctl; rpc dlg.list_ctx
    ...

### dlg.list_match

Lists the details of matching dialogs. The parameters specify the matching key, operator, value and optionally a limit of matched dialogs.

Name: dlg.list_match

Parameters:

- mkey - matching key. It can be: 'ruri' - match against R-URI of the dialog; 'furi' - match against From header URI of the dialog; 'turi' - match against the To header URI of the dialog; 'callid' - match against Call-Id value; 'start_ts' - match against start timestamp.

- mop - matching operator. It can be: 'eq' - match using string comparison; 're' - match using regular expression; 'sw' - match using starts-with (prefix) comparison; 'gt' - match using integer greater comparison; 'lt' - match using integer lesser comparison. Integer comparison can be used only with 'start_ts' key.

- mval - matching value.

- limit (optional) - limit of matched dialogs.

RPC Command Format:

    ...
    &kamctl; rpc dlg.list_match furi eq sip:alice@test.com 2
    ...
    &kamctl; rpc dlg.list_match furi sw sip:alice@
    ...
    &kamctl; rpc dlg.list_match start_ts gt s:1641550904
    ...

### dlg.list_match_ctx

Similar to dlg.list_match, but including in the attributes associated with the dialog context from modules sitting on top of the dialog module.

Name: dlg.list_match_ctx

RPC Command Format:

    ...
    &kamctl; rpc dlg.list_match_ctx furi sw sip:alice@
    ...

### dlg.dump_file

Dump all dialogs in a json file. (much faster than dlg.list)

Name: dlg.dump_file

Parameters:

- file name output file name

RPC Command Format:

    ...
    &kamctl; rpc dlg.dump_file "/tmp/dlg.json"
    ...

### dlg.dlg_list

Lists the description of one dialog. The dialog identifiers are to be passed as parameter (callid and optionally 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:

    ...
    &kamctl; rpc dlg.dlg_list abcdrssfrs122444@192.168.1.1 AAdfeEFF33
    ...
    &kamctl; rpc dlg.dlg_list abcdrssfrs122444@192.168.1.1
    ...

### dlg.dlg_list_ctx

The same as the dlg.list_list 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:

    ...
    &kamctl; rpc dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33
    ...
    &kamctl; rpc dlg.list_ctx abcdrssfrs122444@192.168.1.1
    ...

### dlg.terminate_dlg

Terminates an ongoing dialog by sending BYE in both directions, matching the dialog on call-id, from tag and to tag.

Name: dlg.terminate_dlg

Parameters:

- callid - callid of dialog to be terminated

- from_tag - from tag of the dialog to terminated

- to_tag - to tag of the dialog to terminated

The command works only for confirmed dialogs.

RPC Command Format:

    		kamctl rpc dlg.terminate_dlg callid12345 fromtag123 totag123

### 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 obtained via the dlg_list RPC command.

RPC Command Format:

    ...
    &kamctl; rpc dlg.end_dlg 342 56
    ...

### dlg.set_state

Set state for the dialog matching the dialog on Call-ID, From-Tag and To-Tag.

Name: dlg.kill_active_dlg

Parameters:

- callid - Call-ID of active dialog to kill

- from_tag - From-Tag of active dialog to kill

- to_tag - To-tag of active dialog to kill

- state - The value for new state

At this moment, the command targets the need to change from active dialogs (state 4) to terminated state (5), although it allows setting other state value. Be careful using with it, it can cause side effects and the terminated dialog is wiped out silently. Dialog ending functions are not executed, such as accounting end-of-call events, dialog-end events, module-generated BYE requests, etc. After executing the command, dialog remains in memory until execution of the recurring function in charge of removing old dialogs (a "dialog in delete state is too old" will then be logged).

RPC Command Format:

    ...
    &kamctl; rpc dlg.set_state callid12345 fromtag123 totag123 5
    ...

### dlg.profile_get_size

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:

    ...
    &kamctl; rpc dlg.dlg.profile_get_size inbound_calls
    ...

### dlg.profile_list

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:

    ...
    &kamctl; rpc dlg.profile_list inbound_calls
    ...

### dlg.bridge_dlg

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. If its value is set to '.' (dot), then it is ignored (like it would not have been provided).

- body (optional) - SDP body for initial INVITE. If its value is set to '.' (dot), then it is ignored (like it would not have been provided). If body is not set via RPC command parameter, then an internal generated SDP with G711a and G711u is used. If its value is set to '' (empty string) or '_' (underline), then the INVITE is sent without an SDP body.

RPC Command Format:

    ...
    &kamctl; rpc dlg.bridge_dlg _from_ _to_ _op_
    ...

### dlg.stats_active

Get stats about active dialogs by scanning internal list of dialogs (not relying on core stats framework).

Name: dlg.stats_active

Parameters:

- local_only (optional) - if not 0 then filter out non local dialogs (the receiving socket is not found locally, from C code point of view, the bind_addr info is not set).

Returned fields

- starting - initial INVITE has been processed, no ringing or 1xx has been received.

- connecting - initial INVITE was forwarded and rining or 1xx has been received.

- answering - initial INVITE received 200 OK, but ACK was not handled yet.

- ongoing - ongoing active dialog, after the ACK was processed.

- all - all active dialogs, respectively the sum of the above values.

RPC Command Format:

    ...
    &kamctl; rpc dlg.stats_active
    ...

### dlg.is_alive

Check whether a dialog matching the parameter is in confirmed state (answered and alive).

Name: dlg.is_alive

Parameters:

- callid - callid of dialog

- from_tag - from tag of the dialog

- to_tag - to tag of the dialog

This command will return error if dialog is not found or not confirmed state (answered).

RPC Command Format:

    ...
    &kamctl; rpc dlg.is_alive callid123 fromtag123 totag123
    ...

### dlg.briefing

Lists fewer attributes for dialog records in memory. The dialog hash entry and id are added always, the rest of them are a matter of 'attrs' parameter.

Name: dlg.briefing

Parameters:

- attrs - (optional) a list of characters (flags) representing the fields to be added to the response. If it is missing, its default value is 'ftcFT' (note the characters are case sensitive).

  The characters can be:

  - f - From URI

  - t - To URI

  - c - Call-ID

  - F - From tag

  - T - To tag

  - I - Init time

  - S - Start time

  - E - End time

  - s - State

RPC Command Example:

    ...
    kamctl rpc dlg.briefing
    ...
    kamctl rpc dlg.briefing "ft"
    ...

## Exported Variables

### `$DLG_count`

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

### `$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.

### `$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.

### `$dlg(...)`

Access to dialog attributes.

### `$dlg_ctx(...)`

Access to dialog context attributes.

### `$dlg_var(key)`

This is a read/write variable that can be used to store custom values associated to a dialog (e.g. the URI of a billing-server, an assigned emergency-server). The value has to be a string. This pseudo-variable will be available for subsequential requests only after loose_route() or dlg_manage().

Note: "NULL" is returned, if there is no dialog for this request.

Note: dialog variables set before the dialog is created for the initial INVITE can be associated to the dialog only when the dialog is created by the same Kamailio process. They are lost if the variables are set in a process that calls an asynchronous function that resumes the processing in another process, which then creates the dialog.

## Event Routes

### event_route[dialog:start]

Executed when 200 OK reply for INVITE is processed.

### event_route[dialog:end]

Executed when the BYE for the call is processed or the dialog timed out.

### event_route[dialog:failed]

Executed when dialog is not completed (300 or greater reply code to INVITE).