<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>
<!-- Module User's Guide -->

<chapter>

	<title>&adminguide;</title>

	<section>
	<title>Overview</title>
	<para>
	Kamailio can behave as a stateful proxy through the TM module.  However,
	"stateful" in this context refers to <emphasis>transaction</emphasis>
	state, not dialog state.  Certain applications may benefit from an
	awareness of "calls" in the proxy, not just SIP transactions.
	</para>
	<para>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.
	</para>
	<para>
	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.
	</para>
	<para>
	This module also provides an API foundation on which to build
	more complex dialog-oriented functionality in other &kamailio; modules.
	</para>
	</section>

	<section>
	<title>How it works</title>
	<para>
	To create the dialog associated with an initial INVITE request, execute
	the function <quote>dlg_manage()</quote> or set the flag specified by
	parameter <quote>dlg_flag</quote> (<xref linkend="dialog.p.flag"/>)
	before creating the corresponding transaction.
	</para>
	<para>
	The dialog is automatically destroyed when a <quote>BYE</quote> is
	received. In case of no <quote>BYE</quote>, the dialog lifetime is
	controlled via the default timeout (see <quote>default_timeout</quote>
	- <xref linkend="dialog.p.default_timeout"/>) and custom timeout (see
	<quote>timeout_avp</quote> - <xref linkend="dialog.p.timeout_avp"/>). The
	dialog timeout is reset each time a sequential request is processed.
	</para>
	</section>
	<section>
	<title>Dialog states</title>
	<para>
	Dialogs have states that are shown in the RPC interface as well as stored
	in the database.
	</para>
	<itemizedlist>
		<listitem>
			<para><emphasis>1</emphasis> : Unconfirmed dialog</para>
		</listitem>
		<listitem>
			<para><emphasis>2</emphasis> : Early dialog (ringing)</para>
		</listitem>
		<listitem>
			<para><emphasis>3</emphasis> : Confirmed dialog (waiting for ACK)</para>
		</listitem>
		<listitem>
			<para><emphasis>4</emphasis> : Confirmed dialog (active call)</para>
		</listitem>
		<listitem>
			<para><emphasis>5</emphasis> : Deleted dialog</para>
		</listitem>
	</itemizedlist>
	<para>The early and deleted dialog states are not updated in database storage.
	</para>
	</section>

	<section>
	<title>Dialog profiling</title>
	<para>
	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.).
	</para>
	<para>
	There are two types of profiles:
	<itemizedlist>
		<listitem>
		<para>
			<emphasis>with no value</emphasis> - 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.
		</para>
		</listitem>
		<listitem>
		<para>
			<emphasis>with value</emphasis> - 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.
		</para>
		</listitem>
	</itemizedlist>
	</para>
	<para>
	A dialog can be added to multiple profiles at the same time.
	</para>
	<para>
	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.
	</para>
	</section>

	<section>
	<title>Dependencies</title>
	<section>
		<title>&kamailio; Modules</title>
		<para>
		The following modules must be loaded before this module:
			<itemizedlist>
			<listitem>
			<para>
				<emphasis>TM</emphasis> - Transaction module
			</para>
			</listitem>
			<listitem>
			<para>
				<emphasis>RR</emphasis> - Record-Route module
			</para>
			</listitem>
			<listitem>
			<para>
				<emphasis>PV</emphasis> - Pseudovariables module
			</para>
			</listitem>
			</itemizedlist>
		</para>
	</section>


	<section>
		<title>External Libraries or Applications</title>
		<para>
		The following libraries or applications must be installed before
		running &kamailio; with this module loaded:
			<itemizedlist>
			<listitem>
			<para>
				<emphasis>None</emphasis>.
			</para>
			</listitem>
			</itemizedlist>
		</para>
	</section>
	</section>


	<section>
	<title>Parameters</title>
	<section id="dialog.p.enable_stats">
		<title><varname>enable_stats</varname> (integer)</title>
		<para>
		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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>1 (enabled)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>enable_stats</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "enable_stats", 0)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.hash_size">
		<title><varname>hash_size</varname> (integer)</title>
		<para>
		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.
		</para>
		<para>
		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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>4096</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>hash_size</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "hash_size", 1024)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.rr_param">
		<title><varname>rr_param</varname> (string)</title>
		<para>
		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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>did</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>rr_param</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "rr_param", "xyz")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.flag">
		<title><varname>dlg_flag</varname> (integer)</title>
		<para>
		Flag to be used for marking if a dialog should be constructed for the
		current request (this makes sense only for initial requests).
		</para>
		<para>
		Note: it is not needed to set this parameter and its corresponding flag
		for initial request in case the <quote>dlg_manage()</quote> function
		is used. In other words, using <quote>dlg_manage()</quote> alone is
		enough.
		</para>
		<para>
		<emphasis>
			Default value is <quote>none</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>dlg_flag</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "dlg_flag", 4)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.timeout_avp">
		<title><varname>timeout_avp</varname> (string)</title>
		<para>
		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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>none</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>timeout_avp</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "timeout_avp", "$avp(i:10)")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.default_timeout">
		<title><varname>default_timeout</varname> (integer)</title>
		<para>
		The default dialog timeout (in seconds), in the absence of a custom
		value provided in an AVP.
		</para>
		<para>
		<emphasis>
			Default value is <quote>43200 (12 hours)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>default_timeout</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "default_timeout", 21600)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.early_timeout">
		<title><varname>early_timeout</varname> (integer)</title>
		<para>
		The timeout (in seconds) after which the dialogs in unconfirmed or early
		state (no final response received) are destroyed.
		</para>
		<para>
		<emphasis>
			Default value is <quote>300 (5 minutes)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>early_timeout</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "early_timeout", 180)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.noack_timeout">
		<title><varname>noack_timeout</varname> (integer)</title>
		<para>
		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).
		</para>
		<para>
		<emphasis>
			Default value is <quote>60 (1 minute)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>noack_timeout</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "noack_timeout", 90)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.end_timeout">
		<title><varname>end_timeout</varname> (integer)</title>
		<para>
		The timeout (in seconds) after which the dialogs in terminated state
		are destroyed.
		</para>
		<para>
		<emphasis>
			Default value is <quote>300 (5 minutes)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>end_timeout</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "end_timeout", 180)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.dlg_extra_hdrs">
		<title><varname>dlg_extra_hdrs</varname> (string)</title>
		<para>
		A string containing the extra headers (full format, with EOH)
		to be added to requests generated locally by the module (like BYEs).
		</para>
		<para>
		<emphasis>
			Default value is <quote>NULL</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>dlf_extra_hdrs</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "dlg_extra_hdrs", "Hint: credit expired\r\n")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.dlg_match_mode">
		<title><varname>dlg_match_mode</varname> (integer)</title>
		<para>
		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).
		</para>
		<para>
		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).
		</para>
		<para>
		The supported modes are:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>0 - DID_ONLY</emphasis> - the match is done
				exclusively based on DID;
			</para></listitem>
			<listitem><para>
				<emphasis>1 - DID_FALLBACK</emphasis> - the match is first
				tried based on DID and if not present, it will fall back to
				SIP matching;
			</para></listitem>
			<listitem><para>
				<emphasis>2 - DID_NONE</emphasis> - the match is done
				exclusively based on SIP elements; no DID information is added
				in RR.
			</para></listitem>
		</itemizedlist>
		<para>
		<emphasis>
			Default value is <quote>0 (DID_ONLY)</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>dlg_match_mode</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "dlg_match_mode", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.detect_spirals">
		<title><varname>detect_spirals</varname> (integer)</title>
		<para>
			Whether spirals (i.e., messages routed through the proxy multiple times)
			should be detected.
		</para>
		<para>
			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.
		</para>
		<para>
			Default value is 1.
		</para>
		<example>
			<title>Set <varname>detect_spirals</varname> parameter</title>
			<programlisting format="linespecific">
...
modparam("dialog", "detect_spirals", 1)
...
			</programlisting>
		</example>
	</section>

	<section id="dialog.p.db_url">
		<title><varname>db_url</varname> (string)</title>
		<para>
		In order to store information about dialogs in a database,
		a database URL must be specified.
		</para>
		<para>
		<emphasis>
			Default value is <quote>&defaultdb;</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>db_url</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "db_url", "&exampledb;")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.db_mode">
		<title><varname>db_mode</varname> (integer)</title>
		<para>
		Mode of synchronisation of dialog information from memory to an
		underlying database (if desired):
		</para>
		<para>
		The supported modes are:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>0 - NO_DB</emphasis> - the memory content is not
				flushed into DB;
			</para></listitem>
			<listitem><para>
				<emphasis>1 - REALTIME</emphasis> - any dialog information
				changes will be reflected into the database immediately.
			</para></listitem>
			<listitem><para>
				<emphasis>2 - DELAYED</emphasis> - the dialog information
				changes will be flushed into DB periodically, based on a
				timer routine.
			</para></listitem>
			<listitem><para>
				<emphasis>3 - SHUTDOWN</emphasis> - the dialog information
				will be flushed into DB only at shutdown - no runtime updates.
			</para></listitem>
		</itemizedlist>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>db_mode</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "db_mode", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.update_period">
		<title><varname>db_update_period</varname> (integer)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>60</quote> seconds.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>db_update_period</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "db_update_period", 120)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.db_fetch_rows">
		<title><varname>db_fetch_rows</varname> (integer)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>200</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>db_fetch_rows</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "db_fetch_rows", 500)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.db_skip_load">
		<title><varname>db_skip_load</varname> (integer)</title>
		<para>
			Set db_skip_load to 1, to skip the loading of dialog data
			from the database.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote> ( not skipped ).
		</emphasis>
		</para>
		<example>
		<title>Set <varname>db_skip_load</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "db_skip_load", 1)
...
</programlisting>
		</example>
	</section>



	<section id="dialog.p.table_name">
		<title><varname>table_name</varname> (string)</title>
		<para>
		Database table name used for storing dialog information.
		</para>
		<para>
		<emphasis>
			Default value is <quote>dialog</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>table_name</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "table_name", "my_dialog")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.call_id_column">
		<title><varname>call_id_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog call-id.
		</para>
		<para>
		<emphasis>
			Default value is <quote>callid</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>call_id_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "call_id_column", "callid_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_uri_column">
		<title><varname>from_uri_column</varname> (string)</title>
		<para>
			The column name in the database to store the caller's
			SIP address (URI).
		</para>
		<para>
		<emphasis>
			Default value is <quote>from_uri</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_uri_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_uri_column", "from_uri_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_tag_column">
		<title><varname>from_tag_column</varname> (string)</title>
		<para>
			The column name in the database to store the From header tag from
			the INVITE request.
		</para>
		<para>
		<emphasis>
			Default value is <quote>from_tag</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_tag_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_tag_column", "from_tag_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.to_uri_column">
		<title><varname>to_uri_column</varname> (string)</title>
		<para>
			The column name in the database to store the callee's SIP address (URI).
		</para>
		<para>
		<emphasis>
			Default value is <quote>to_uri</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_uri_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_uri_column", "to_uri_c_name")
...
</programlisting>
		</example>
	</section>


	<section id="dialog.p.to_tag_column">
		<title><varname>to_tag_column</varname> (string)</title>
		<para>
			The column name in the database to store the To header tag from
			the 200 OK response to the INVITE request, if present.
		</para>
		<para>
		<emphasis>
			Default value is <quote>to_tag</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_tag_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_tag_column", "to_tag_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_cseq_column">
		<title><varname>from_cseq_column</varname> (string)</title>
		<para>
			The column name in the database to store the Cseq from caller
			side.
		</para>
		<para>
		<emphasis>
			Default value is <quote>caller_cseq</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_cseq_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_cseq_column", "from_cseq")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.to_cseq_column">
		<title><varname>to_cseq_column</varname> (string)</title>
		<para>
			The column name in the database to store the cseq from callee
			side.
		</para>
		<para>
		<emphasis>
			Default value is <quote>callee_cseq</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_cseq_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_cseq_column", "to_cseq")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_route_column">
		<title><varname>from_route_column</varname> (string)</title>
		<para>
			The column name in the database to store the route records from
			caller side (proxy to caller).
		</para>
		<para>
		<emphasis>
			Default value is <quote>caller_route_set</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_route_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_route_column", "rroute_from")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.to_route_column">
		<title><varname>to_route_column</varname> (string)</title>
		<para>
			The column name in the database to store the route records from
			callee side (proxy to callee).
		</para>
		<para>
		<emphasis>
			Default value is <quote>callee_route_set</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_route_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_route_column", "rroute_to")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_contact_column">
		<title><varname>from_contact_column</varname> (string)</title>
		<para>
			The column name in the database to store the caller's contact
			uri.
		</para>
		<para>
		<emphasis>
			Default value is <quote>caller_contact</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_contact_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_contact_column", "from_contact_uri")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.to_contact_column">
		<title><varname>to_contact_column</varname> (string)</title>
		<para>
			The column name in the database to store the callee's contact
			uri.
		</para>
		<para>
		<emphasis>
			Default value is <quote>callee_contact</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_contact_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_contact_column", "to_contact_uri")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.from_sock_column">
		<title><varname>from_sock_column</varname> (string)</title>
		<para>
			The column name in the database to store the information about
			the local interface receiving the traffic from caller.
		</para>
		<para>
		<emphasis>
			Default value is <quote>caller_sock</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>from_sock_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "from_sock_column", "socket_from")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.to_sock_column">
		<title><varname>to_sock_column</varname> (string)</title>
		<para>
			The column name in the database to store information about the
			local interface receiving the traffic from callee.
		</para>
		<para>
		<emphasis>
			Default value is <quote>callee_sock</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>to_sock_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "to_sock_column", "socket_to")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.h_id_column">
		<title><varname>h_id_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialogs'
			hash id information.
		</para>
		<para>
		<emphasis>
			Default value is <quote>hash_id</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>h_id_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "h_id_column", "hash_id_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.h_entry_column">
		<title><varname>h_entry_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog's hash
			entry information.
		</para>
		<para>
		<emphasis>
			Default value is <quote>hash_entry</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>h_entry_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "h_entry_column", "h_entry_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.state_column">
		<title><varname>state_column</varname> (string)</title>
		<para>
			The column name in the database to store the
			dialog's state information.
		</para>
		<para>
		<emphasis>
			Default value is <quote>state</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>state_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "state_column", "state_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.start_time_column">
		<title><varname>start_time_column</varname> (string)</title>
		<para>
			The column name in the database to store the
			dialog's start time information.
		</para>
		<para>
		<emphasis>
			Default value is <quote>start_time</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>start_time_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "start_time_column", "start_time_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.timeout_column">
		<title><varname>timeout_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog's timeout.
		</para>
		<para>
		<emphasis>
			Default value is <quote>timeout</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>timeout_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "timeout_column", "timeout_c_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.sflags_column">
		<title><varname>sflags_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog script flags.
		</para>
		<para>
		<emphasis>
			Default value is <quote>sflags</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>sflags_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "sflags_column", "s_flags")
...
</programlisting>
		</example>
	</section>
	<section id="dialog.p.toroute_name_column">
		<title><varname>toroute_name_column</varname> (string)</title>
		<para>
			The column name in the database to store the index of the
			route to be executed at timeout.
		</para>
		<para>
		<emphasis>
			Default value is <quote>toroute_name</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>toroute_name_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "toroute_name_column", "timeout_route")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.vars_table_name">
		<title><varname>vars_table_name</varname> (string)</title>
		<para>
		If you want to store the dialog variables (<quote>$dlg_var(name)</quote>)
		for a dialog in a database a table name must be specified.
		</para>
		<para>
		<emphasis>
			Default value is <quote>dialog_vars</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>vars_table_name</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "vars_table_name", "my_dialog_vars")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.vars_h_id_column">
		<title><varname>vars_h_id_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog's
			hash id information (as a reference to the dialog table).
		</para>
		<para>
		<emphasis>
			Default value is <quote>hash_id</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>vars_h_id_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "vars_h_id_column", "vars_h_id_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.vars_h_entry_column">
		<title><varname>vars_h_entry_column</varname> (string)</title>
		<para>
			The column name in the database to store the dialog's
			hash entry information (as a reference to the dialog table).
		</para>
		<para>
		<emphasis>
			Default value is <quote>hash_entry</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>vars_h_entry_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "vars_h_entry_column", "vars_h_entry_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.vars_key_column">
		<title><varname>vars_key_column</varname> (string)</title>
		<para>
			The column name in the database to store the names (keys) of a dialog
			variable.
		</para>
		<para>
		<emphasis>
			Default value is <quote>dialog_key</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>vars_key_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "vars_key_column", "vars_key_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.vars_value_column">
		<title><varname>vars_value_column</varname> (string)</title>
		<para>
			The column name in the database to store the values of a
			dialog variable.
		</para>
		<para>
		<emphasis>
			Default value is <quote>dialog_value</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>vars_value_column</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "vars_value_column", "vars_value_name")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.profiles_with_value">
		<title><varname>profiles_with_value</varname> (string)</title>
		<para>
			List of names for profiles with values, separated
			with semi-colon ";".
		</para>
		<para>
		<emphasis>
			Default value is <quote>empty</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>profiles_with_value</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "profiles_with_value", "caller ; my_profile")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.profiles_no_value">
		<title><varname>profiles_no_value</varname> (string)</title>
		<para>
			List of names for profiles without values, separated
			with semi-colon ";".
		</para>
		<para>
		<emphasis>
			Default value is <quote>empty</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>profiles_no_value</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "profiles_no_value", "inbound ; outbound")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.bridge_controller">
		<title><varname>bridge_controller</varname> (string)</title>
		<para>
			SIP address to be used in From header when initiating a call bridge.
		</para>
		<para>
		<emphasis>
			Default value is <quote>sip:controller@kamailio.org</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>bridge_controller</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "bridge_controller", "sip:ctd@kamailio.org")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.bridge_contact">
		<title><varname>bridge_contact</varname> (string)</title>
		<para>
			SIP address to be used in Contact header when doing a call bridge.
		</para>
		<para>
		<emphasis>
			Default value is <quote>sip:controller@kamailio.org:5060</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>bridge_contact</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "bridge_contact", "sip:ctd@127.0.0.1:5060")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.initial_cbs_inscript">
		<title><varname>initial_cbs_inscript</varname> (int)</title>
		<para>
            	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.
		</para>
		<para>
		The supported values are:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>0 - POST-SCRIPT</emphasis> - execute initial
				callbacks after the script completes;
			</para></listitem>
			<listitem><para>
				<emphasis>1 - IN-SCRIPT</emphasis> - execute initial
                		callbacks during script execution, i.e., right after
                		dlg_manage() is called;
			</para></listitem>
		</itemizedlist>
		<para>
		<emphasis>
			Default value is <quote>1</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>initial_cbs_inscript</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "initial_cbs_inscript", 0)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.send_bye">
		<title><varname>send_bye</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>send_bye</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "send_bye", 1)
...
</programlisting>
		</example>
	</section>
	<section id="dialog.p.dlg_filter_mode">
		<title><varname>dlg_filter_mode</varname> (int)</title>
		<para>
			Set dialog fitering mode, which can specify what dialogs are processed.
			Its value can be a combination (the sum) of following flags:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>1</emphasis> - 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).
			</para></listitem>
		</itemizedlist>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>dlg_filter_mode</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "dlg_filter_mode", 1)
...
</programlisting>
		</example>
	</section>
	<section id="dialog.p.wait_ack">
		<title><varname>wait_ack</varname> (int)</title>
		<para>
			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).
		</para>
		<para>
		<emphasis>
			Default value is <quote>1</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>wait_ack</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "wait_ack", 0)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.ka_timer">
		<title><varname>ka_timer</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote> (no keep alive).
		</emphasis>
		</para>
		<example>
		<title>Set <varname>ka_timer</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "ka_timer", 10)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.ka_interval">
		<title><varname>ka_interval</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote> (no keep alive). The lowest
			settable interval is 30 seconds.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>ka_interval</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "ka_interval", 300)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.ka_failed_limit">
		<title><varname>ka_failed_limit</varname> (int)</title>
		<para>
			The number of failed keep-alive requests that is accepted
			before generating a dialog timeout.
		</para>
		<para>
		<emphasis>
			Default value is <quote>1</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>ka_failed_limit</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "ka_failed_limit", 5)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.timeout_noreset">
		<title><varname>timeout_noreset</varname> (int)</title>
		<para>
           		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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>timeout_noreset</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "timeout_noreset", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.timer_procs">
		<title><varname>timer_procs</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote> (use core timer process).
		</emphasis>
		</para>
		<example>
		<title>Set <varname>timer_procs</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "timer_procs", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.enable_dmq">
		<title><varname>enable_dmq</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>enable_dmq</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "enable_dmq", 1)
...
</programlisting>
	</example>
    </section>

	<section id="dialog.p.track_cseq_updates">
		<title><varname>track_cseq_updates</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote> (disabled).
		</emphasis>
		</para>
		<example>
		<title>Set <varname>track_cseq_updates</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "track_cseq_updates", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.lreq_callee_headers">
		<title><varname>lreq_callee_headers</varname> (string)</title>
		<para>
			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).
		</para>
		<para>
		<emphasis>
			Default value is <quote>null</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>lreq_callee_headers</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "lreq_callee_headers", "TH: dlh\r\n")
...
</programlisting>
		</example>
	</section>
	<section id="dialog.p.event_callback">
		<title><varname>event_callback</varname> (str)</title>
		<para>
			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.
		</para>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is 'empty' (no function is executed for events).
		</emphasis>
		</para>
		<example>
		<title>Set <varname>event_callback</varname> parameter</title>
		<programlisting format="linespecific">
...
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
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.h_id_start">
		<title><varname>h_id_start</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>h_id_start</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "h_id_start", 5)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.h_id_step">
		<title><varname>h_id_step</varname> (int)</title>
		<para>
			Set the step to increment the dialog internal hash id.
		</para>
		<para>
			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).
		</para>
		<para>
		<emphasis>
			Default value is <quote>1</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>h_id_step</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "h_id_step", 10)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.keep_proxy_rr">
		<title><varname>keep_proxy_rr</varname> (string)</title>
		<para>
			Whether to keep the record-route header added by the proxy.
			When enabled, it will keep this proxy&apos;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).
		</para>
		<para>
			Valid values are:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>0</emphasis> - Don&apos;t keep any proxy Record-Route headers
			</para></listitem>
			<listitem><para>
				<emphasis>1</emphasis> - Keep Record-route headers for the callee leg
			</para></listitem>
			<listitem><para>
				<emphasis>2</emphasis> - Keep Record-route headers for the caller leg
			</para></listitem>
			<listitem><para>
				<emphasis>3</emphasis> - Keep Record-route headers for both legs
			</para></listitem>
		</itemizedlist>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		<example>
		<title>Set <varname>dlg_keep_proxy_rr</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "keep_proxy_rr", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.bye_early_code">
		<title><varname>bye_early_code</varname> (int)</title>
		<para>
			This parameter defines the reply-code being used for
			dialogs being terminated in early stage (e.g. before
			200 OK/ACK).
		</para>
		<emphasis>
			Default value is <quote>480</quote>.
		</emphasis>
		<example>
		<title>Set <varname>bye_early_code</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "bye_early_code", 503)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.bye_early_reason">
		<title><varname>bye_early_reason</varname> (string)</title>
		<para>
			This parameter defines the reply-reason being used for
			dialogs being terminated in early stage (e.g. before
			200 OK/ACK).
		</para>
		<emphasis>
			Default value is <quote>Temporarily Unavailable</quote>.
		</emphasis>
		<example>
		<title>Set <varname>bye_early_reason</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "bye_early_reason", "Call terminated")
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.dlg_ctxiuid_mode">
		<title><varname>dlg_ctxiuid_mode</varname> (int)</title>
		<para>
			Set dialog context iuid mode, which can specify additional cases
			when the internal unique id should be set:
		</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>1</emphasis> - set it when processing CANCEL requests.
			</para></listitem>
		</itemizedlist>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>dlg_ctxiuid_mode</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "dlg_ctxiuid_mode", 1)
...
</programlisting>
		</example>
	</section>

	<section id="dialog.p.debug_variables">
		<title><varname>debug_variables</varname> (int)</title>
		<para>
			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.
		</para>
		<para>
		<emphasis>
			Default value is <quote>0</quote>.
		</emphasis>
		</para>
		<example>
		<title>Set <varname>debug_variables</varname> parameter</title>
		<programlisting format="linespecific">
...
modparam("dialog", "debug_variables", 1)
...
</programlisting>
		</example>
	</section>

	</section>

	<section>
	<title>Functions</title>
	<section id="dialog.f.set_dlg_profile">
		<title>
		<function moreinfo="none">set_dlg_profile(profile[, value])</function>
		</title>
		<para>
		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.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>profile</emphasis> - name of the profile to be
			added to;
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> (optional) - string value to
			define the membership of the dialog in the profile.  Note that the
			profile must support values.  Pseudo-variables are supported.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
			REPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>set_dlg_profile</function> usage</title>
		<programlisting format="linespecific">
...
set_dlg_profile("inbound_call");
set_dlg_profile("caller","$fu");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.unset_dlg_profile">
		<title>
		<function moreinfo="none">unset_dlg_profile(profile[, value])</function>
		</title>
		<para>
		Removes the current dialog from a profile.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>profile</emphasis> - name of the profile to be
			removed from;
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> (optional) - string value to
			define the belonging of the dialog to the profile - note that the
			profile must support values.
			Pseudo-variables are supported.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>unset_dlg_profile</function> usage</title>
		<programlisting format="linespecific">
...
unset_dlg_profile("inbound_call");
unset_dlg_profile("caller","$fu");
...
</programlisting>
		</example>
	</section>


	<section id="dialog.f.is_in_profile">
		<title>
		<function moreinfo="none">is_in_profile(profile[, value])</function>
		</title>
		<para>
		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.
		</para>
		<para>
		Note that if the profile is not defined with support for values, the
		value parameter will be silently discarded.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>profile</emphasis> - name of the profile to be
			checked against;
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> (optional) - string value to
			be matched during the check. Pseudo-variables are supported.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
		REPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>is_in_profile</function> usage</title>
		<programlisting format="linespecific">
...
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");
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.get_profile_size">
		<title>
		<function moreinfo="none">get_profile_size(profile[, value], size)</function>
		</title>
		<para>
		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.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>profile</emphasis> - name of the profile to get
			the size for;
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> (optional) - string value to
			further restrict the check. Pseudo-variables are supported;
			</para>
		</listitem>
		<listitem>
			<para><emphasis>size</emphasis> - an AVP or script variable to
			return the profile size in.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
			REPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>get_profile_size</function> usage</title>
		<programlisting format="linespecific">
...
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");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_isflagset">
		<title>
		<function moreinfo="none">dlg_isflagset(flag)</function>
		</title>
		<para>
		Check if the dialog flag is set or not.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>flag</emphasis> - index of the flag - can be
				pseudo-variable.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_isflagset</function> usage</title>
		<programlisting format="linespecific">
...
if(dlg_isflagset("1"))
{
    ...
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_setflag">
		<title>
		<function moreinfo="none">dlg_setflag(flag)</function>
		</title>
		<para>
		Set a dialog flag.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>flag</emphasis> - index of the flag - can be
				pseudo-variable.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_setflag</function> usage</title>
		<programlisting format="linespecific">
...
dlg_setflag("1");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_resetflag">
		<title>
		<function moreinfo="none">dlg_resetflag(flag)</function>
		</title>
		<para>
		Reset the dialog flag.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>flag</emphasis> - index of the flag - can be
				pseudo-variable.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_resetflag</function> usage</title>
		<programlisting format="linespecific">
...
dlg_resetflag("1");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_bye">
		<title>
		<function moreinfo="none">dlg_bye(side)</function>
		</title>
		<para>
		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).
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>side</emphasis> - where to send the BYE. It can be:
				'caller', 'callee', or 'all' (send to both sides).
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_bye</function> usage</title>
		<programlisting format="linespecific">
...
dlg_bye("all");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_refer">
		<title>
		<function moreinfo="none">dlg_refer(side, address)</function>
		</title>
		<para>
		Refer the 'side' to a new SIP 'address'.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>side</emphasis> - which side of the dialog to REFER. It can be:
				'caller' or 'callee'.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>address</emphasis> - SIP address to refer to.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_refer</function> usage</title>
		<programlisting format="linespecific">
...
dlg_refer("caller", "sip:announcement@kamailio.org");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_manage">
		<title>
		<function moreinfo="none">dlg_manage()</function>
		</title>
		<para>
		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.
		</para>
		<para>
		This function can be used from REQUEST_ROUTE.
		</para>
		<example>
		<title><function>dlg_manage</function> usage</title>
		<programlisting format="linespecific">
...
modparam("dialog", "default_timeout", 100)
...
request_route {
...
    if(is_method("INVITE") &amp;&amp; !has_totag())
    {
        $dlg_ctx(timeout_route) = "DLGTIMEOUT";
        $dlg_ctx(timeout_bye) = 1;
    }
    dlg_manage();
...
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_bridge">
		<title>
		<function moreinfo="none">dlg_bridge(from, to, op)</function>
		</title>
		<para>
		Bridge 'from' SIP address to 'to' SIP address via outbound proxy 'op'.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>from</emphasis> - SIP address of first side to call.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>to</emphasis> - SIP address to refer <quote>from</quote> to.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>op</emphasis> - outbound proxy SIP address.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_bridge</function> usage</title>
		<programlisting format="linespecific">
...
dlg_bridge("sip:user@kamailio.org", "sip:annoucement@kamailio.org",
   "sip:kamailio.org:5080");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_get">
		<title>
		<function moreinfo="none">dlg_get(callid, ftag, ttag)</function>
		</title>
		<para>
			Search and set current dialog based on Call-ID, From-Tag and To-Tag
			parameters.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>callid</emphasis> - SIP call-id.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ftag</emphasis> - SIP From tag.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ttag</emphasis> - SIP To tag (it can be empty string
			to match a dialog during call setup (eg., match for CANCEL)).
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_get</function> usage</title>
		<programlisting format="linespecific">
...
if(dlg_get("abcdef", "123", "456"))
{
	dlg_bye("all");
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_get_var">
		<title>
		<function moreinfo="none">dlg_get_var(callid, ftag, ttag, name, dst)</function>
		</title>
		<para>
			Get dlg_var of another dialog value based on Call-ID, From-Tag and To-Tag
			parameters.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>callid</emphasis> - SIP call-id.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ftag</emphasis> - SIP From tag.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ttag</emphasis> - SIP To tag. Use "" value to indicate early dialog.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>name</emphasis> - key name of the $dlg_var.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>dst</emphasis> - pv to store the value of $dlg_var(name).
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_get_var</function> usage</title>
		<programlisting format="linespecific">
...
if(dlg_get_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
{
	xdbg("$$dlg_var(test):$var(tmp)\n");
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_set_var">
		<title>
		<function moreinfo="none">dlg_set_var(callid, ftag, ttag, name, value)</function>
		</title>
		<para>
			Set dlg_var of another dialog value based on Call-ID, From-Tag and To-Tag
			parameters.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>callid</emphasis> - SIP call-id.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ftag</emphasis> - SIP From tag.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>ttag</emphasis> - SIP To tag. Use "" value to indicate early dialog.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>name</emphasis> - key name of the $dlg_var.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> - string value to store at $dlg_var(name).
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from BRANCH_ROUTE,
			REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>dlg_set_var</function> usage</title>
		<programlisting format="linespecific">
...
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");
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.is_known_dlg">
		<title>
		<function moreinfo="none">is_known_dlg()</function>
		</title>
		<para>
		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.
		</para>
		<para>
		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.
		</para>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE,
			REPLY_ROUTE and FAILURE_ROUTE.
		</para>
		<example>
		<title><function>is_known_dlg()</function> usage</title>
		<programlisting format="linespecific">
...
if(!uri == myself) {
	if(is_known_dlg()) {
		xlog("Request $rm from $ci is in-dialog\n");
	}
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_set_timeout">
		<title>
		<function moreinfo="none">dlg_set_timeout(timeout [, h_entry, h_id])</function>
		</title>
		<para>
			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.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>timeout</emphasis> - the interval in seconds after
				which the dialog will time out.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>h_entry</emphasis> - h_entry value of the iternal
				dialog identifier.
			</para>
		</listitem>
		<listitem>
			<para><emphasis>h_id</emphasis> - h_id value if the internal dialog
				identifier.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_set_timeout</function> usage</title>
		<programlisting format="linespecific">
...
if(dlg_set_timeout("180", "123", "456"))
{
    ...
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_set_timeout_by_profile">
		<title>
		<function moreinfo="none">dlg_set_timeout_by_profile(profile, [value], timeout)</function>
		</title>
		<para>
			Like <emphasis>dlg_set_timeout()</emphasis>, but
			simultaneously sets the timeout of all dialogs in
			a given profile.  Can be constrained by profile value.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>profile</emphasis> - The dialog profile across which to apply the timeout.
			</para>
			<para><emphasis>value</emphasis> (optional) - The profile value to use when applying the dialog timeout.
			</para>
			<para><emphasis>timeout</emphasis> - the interval in seconds after
				which the dialog will time out.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_set_timeout_by_profile</function> usage</title>
		<programlisting format="linespecific">
...
# 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");
...
</programlisting>
		</example>
	</section>


	<section id="dialog.f.dlg_set_property">
		<title>
		<function moreinfo="none">dlg_set_property(attr)</function>
		</title>
		<para>
			Set a dialog property - an attribute that enable/disable
			various behaviours (e.g., sending keep alive requests).
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>attr</emphasis> - name of property. It can be:
				<itemizedlist>
					<listitem>
						'ka-src' - send keep alive OPTION requests to caller
					</listitem>
					<listitem>
						'ka-dst' - send keep alive OPTION requests to callee
					</listitem>
					<listitem>
						'timeout-noreset' - don't reset timeout on in-dialog messages reception
					</listitem>
				</itemizedlist>
			</para>
		</listitem>
		</itemizedlist>
		<para>
			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.
		</para>
		<para>
            		If 'timeout-noreset' is set, dialog timeout won't be reset upon reception
            		of in-dialog messages (default behavior).
		</para>
		<para>
			This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_set_property</function> usage</title>
		<programlisting format="linespecific">
...
dlg_set_property("ka-src");
dlg_set_property("ka-dst");
dlg_set_property("timeout-noreset");
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_remote_profile">
		<title>
		<function moreinfo="none">dlg_remote_profile(cmd, profile, value, uid, expires)</function>
		</title>
		<para>
			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.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para>
				<emphasis>cmd</emphasis> - the operations to do: add - add an item in
				profile; rm - remove an item from profile
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>profile</emphasis> - name of profile
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>value</emphasis> - value for profile (if no value is needed
				for that profile, use an empty string.
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>expires</emphasis> - absolute time (unix timestamp) when this
				profile item should be removed automatically (time based),
				if still in the profile
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_remote_profile</function> usage</title>
		<programlisting format="linespecific">
...
$var(exp) = 3600 + $Ts;
dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)");
...
</programlisting>
		</example>
	</section>
	<section id="dialog.f.dlg_set_ruri">
		<title>
		<function moreinfo="none">dlg_set_ruri()</function>
		</title>
		<para>
		This function sets the R-URI with the corresponding endpoint address
		stored in dialog structure (i.e., its Contact field).
		</para>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_set_ruri()</function> usage</title>
		<programlisting format="linespecific">
...
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");
	}
}
...
</programlisting>
		</example>
	</section>
	<section id="dialog.f.dlg_db_load_callid">
		<title>
		<function moreinfo="none">dlg_db_load_callid(cival)</function>
		</title>
		<para>
		Load dialog record from database matching on Call-Id provided
		as parameter.
		</para>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_db_load_callid()</function> usage</title>
		<programlisting format="linespecific">
...
if(has_totag()) {
    if(!is_known_dlg()) {
        dlg_db_load_callid("$ci");
	    if(!is_known_dlg()) {
            xlog("no dialog found with callid: $ci\n");
        }
    }
}
...
</programlisting>
		</example>
	</section>
	<section id="dialog.f.dlg_db_load_extra">
		<title>
		<function moreinfo="none">dlg_db_load_extra()</function>
		</title>
		<para>
		Load all dialog records from database that are not in memory of the
		current &kamailio; instance.
		</para>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_db_load_extra()</function> usage</title>
		<programlisting format="linespecific">
...
if(has_totag()) {
    if(!is_known_dlg()) {
        dlg_db_load_extra();
	    if(!is_known_dlg()) {
            xlog("no dialog found with callid: $ci\n");
        }
    }
}
...
</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_reset_property">
		<title>
		<function moreinfo="none">dlg_reset_property(attr)</function>
		</title>
		<para>
			Reset a dialog property - an attribute that enable/disable
			various behaviours (e.g., sending keep alive requests).
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>attr</emphasis> - name of property. It can be:
				<itemizedlist>
					<listitem>
						'ka-src' - send keep alive OPTION requests to caller
					</listitem>
					<listitem>
						'ka-dst' - send keep alive OPTION requests to callee
					</listitem>
					<listitem>
						'timeout-noreset' - don't reset timeout on in-dialog messages reception
					</listitem>
				</itemizedlist>
			</para>
		</listitem>
		</itemizedlist>
		<para>
			This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_reset_property</function> usage</title>
		<programlisting format="linespecific">
...
dlg_reset_property("ka-src");
dlg_reset_property("ka-dst");
dlg_reset_property("timeout-noreset");
...

</programlisting>
		</example>
	</section>

	<section id="dialog.f.dlg_req_within">
		<title>
		<function moreinfo="none">dlg_req_within(side, method, [headers], [content_type, content])</function>
		</title>
		<para>
		Sends an in-dialog SIP Request with method to a party of a dialog indicated by the side parameter.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para>
				<emphasis>side</emphasis> - where to send the request. It can be:
				'caller', 'callee', or 'all' (send to both sides).
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>method</emphasis> - Method of the request
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>headers</emphasis> (optional) - additional headers to be added to the request.
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>content_type</emphasis> (optional) - Content-Type of the request body - will
				be added as Content-Type Header.
			</para>
		</listitem>
		<listitem>
			<para>
				<emphasis>content</emphasis> (optional) - Content to be sent as body.
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from ANY_ROUTE.
		</para>
		<example>
		<title><function>dlg_req_within</function> usage</title>
		<programlisting format="linespecific">
...
	# 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...");
...
		</programlisting>
		</example>
	</section>

	</section>


	<section>
	<title>Statistics</title>
		<section>
			<title><varname>active_dialogs</varname></title>
			<para>
			Returns the number of current active dialogs (may be confirmed or
			not).
			</para>
		</section>
		<section>
			<title><varname>early_dialogs</varname></title>
			<para>
			Returns the number of early dialogs.
			</para>
		</section>		<section>
			<title><varname>processed_dialogs</varname></title>
			<para>
			Returns the total number of processed dialogs (terminated,
			expired or active) from the startup.
			</para>
		</section>
		<section>
			<title><varname>expired_dialogs</varname></title>
			<para>
			Returns the total number of expired dialogs from the startup.
			</para>
		</section>
		<section>
			<title><varname>failed_dialogs</varname></title>
			<para>
			Returns the number of failed dialogs.
			</para>
		</section>
	</section>


	<section>
	<title>RPC Commands</title>
		<section id="dlg.r.list">
		<title>dlg.list</title>
		<para>Lists the description of all dialogs (active calls). </para>
		<para>Name: <emphasis>dlg.list</emphasis></para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.list
...
		</programlisting>
		</section>

		<section id="dlg.r.list_ctx">
		<title>dlg.list_ctx</title>
		<para>
		The same as the <quote>dlg_list</quote> but including in the dialog
		description the associated context from modules sitting on top of
		the dialog module.
		</para>
		<para>Name: <emphasis>dlg.list_ctx</emphasis></para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.list_ctx
...
		</programlisting>
		</section>

		<section id="dlg.r.list_match">
		<title>dlg.list_match</title>
		<para>
		Lists the details of matching dialogs. The paramters specify the matching
		key, operator, value and optionally a limit of matched dialogs.
		</para>
		<para>Name: <emphasis>dlg.list_match</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>mkey</emphasis> - 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.
			</para></listitem>
			<listitem><para>
				<emphasis>mop</emphasis> - 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.
			</para></listitem>
			<listitem><para>
				<emphasis>mval</emphasis> - matching value.
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.list_match furi eq sip:alice@test.com 2
...
&kamcmd; dlg.list_match furi sw sip:alice@
...
&kamcmd; dlg.list_match start_ts gt s:1641550904
...
		</programlisting>
		</section>

		<section id="dlg.r.list_match_ctx">
		<title>dlg.list_match_ctx</title>
		<para>
		Similar to <quote>dlg.list_match</quote>, but including in the
		attributes associated with the dialog context from modules sitting on
		top of the dialog module.
		</para>
		<para>Name: <emphasis>dlg.list_match_ctx</emphasis></para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.list_match_ctx furi sw sip:alice@
...
		</programlisting>
		</section>

		<section id="dlg.r.dump_file">
		<title>dlg.dump_file</title>
		<para>Dump all dialogs in a json file. (much faster than dlg.list)</para>
		<para>Name: <emphasis>dlg.dump_file</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>file name</emphasis> output file name
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.dump_file "/tmp/dlg.json"
...
		</programlisting>
		</section>

		<section id="dlg.r.dlg_list">
		<title>dlg.dlg_list</title>
		<para>
		Lists the description of one dialog.  The dialog identifiers are to be passed
		as parameter (callid and optionally fromtag).
		</para>
		<para>Name: <emphasis>dlg.dlg_list</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>callid</emphasis> callid of the dialog to be listed.
			</para></listitem>
			<listitem><para>
				<emphasis>from_tag</emphasis> from tag (as per initial request)
				of the dialog to be listed.
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.dlg_list abcdrssfrs122444@192.168.1.1 AAdfeEFF33
...
&kamcmd; dlg.dlg_list abcdrssfrs122444@192.168.1.1
...
		</programlisting>
		</section>
		<section id="dlg.r.dlg_list_ctx">
		<title>dlg.dlg_list_ctx</title>
		<para>
		The same as the <quote>dlg.list_list</quote> but including in the dialog
		description the associated context from modules sitting on top of
		the dialog module.
		</para>
		<para>Name: <emphasis>dlg.dlg_list_ctx</emphasis></para>
		<para>Parameters: <emphasis>see <quote>dlg_list</quote></emphasis>
		</para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33
...
&kamcmd; dlg.list_ctx abcdrssfrs122444@192.168.1.1
...
		</programlisting>
		</section>
		<section id="dlg.r.terminate_dlg">
		<title>dlg.terminate_dlg</title>
		<para>
		Terminates an ongoing dialog by sending BYE in both directions,
		matching the dialog on call-id, from tag and to tag.
		</para>
		<para>Name: <emphasis>dlg.terminate_dlg</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>callid</emphasis> - callid of dialog to be terminated
			</para></listitem>
			<listitem><para>
				<emphasis>from_tag</emphasis> -  from tag of the dialog to terminated
			</para></listitem>
			<listitem><para>
				<emphasis>to_tag</emphasis> -  to tag of the dialog to terminated
			</para></listitem>
		</itemizedlist>
		<para>
		The command works only for confirmed dialogs.
		</para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
		kamcmd dlg.terminate_dlg callid12345 fromtag123 totag123
		</programlisting>
		</section>
		<section>
			<title>dlg.end_dlg</title>
			<para>
			Terminates an ongoing dialog by sending BYE in both directions.
			</para>
		<para>Name: <emphasis>dlg.end_dlg</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>h_entry</emphasis> - hash entry of the dialog in the
				internal dialog table
			</para></listitem>
			<listitem><para>
				<emphasis>h_id</emphasis> - hash id of the dialog on the hash
				entry
			</para></listitem>
			<listitem><para>
				<emphasis>extra_hdrs</emphasis> - (optional) string containg
				extra headers (full format) to be added to the BYE requests.
			</para></listitem>
		</itemizedlist>
		<para>
		The values for the h_entry and h_id can be obtained via the dlg_list
		RPC command.
		</para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.end_dlg 342 56
...
		</programlisting>
		</section>
		<section>
			<title>dlg.set_state</title>
			<para>
			Set state for the dialog matching the dialog on Call-ID, From-Tag and To-Tag.
			</para>
		<para>Name: <emphasis>dlg.kill_active_dlg</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>callid</emphasis> - Call-ID of active dialog to kill
			</para></listitem>
			<listitem><para>
				<emphasis>from_tag</emphasis> - From-Tag of active dialog to kill
			</para></listitem>
			<listitem><para>
				<emphasis>to_tag</emphasis> - To-tag of active dialog to kill
			</para></listitem>
			<listitem><para>
				<emphasis>state</emphasis> - The value for new state
			</para></listitem>
		</itemizedlist>
		<para>
		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).
		</para>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.set_state callid12345 fromtag123 totag123 5
...
		</programlisting>
		</section>
		<section id="dlg.r.profile_get_size">
		<title>dlg.profile_get_size</title>
		<para>
		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.
		</para>
		<para>Name: <emphasis>dlg.profile_get_size</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>profile</emphasis> - name of the profile to get the
				value for.
			</para></listitem>
			<listitem><para>
				<emphasis>value</emphasis> (optional)- string value to
				further restrict the check;
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.dlg.profile_get_size inbound_calls
...
		</programlisting>
		</section>

		<section id="dlg.r.profile_list">
		<title>dlg.profile_list</title>
		<para>
		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.
		</para>
		<para>Name: <emphasis>dlg.profile_list</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>profile</emphasis> - name of the profile to list the
				dialog for.
			</para></listitem>
			<listitem><para>
				<emphasis>value</emphasis> (optional)- string value to
				further restrict the check;
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.profile_list inbound_calls
...
		</programlisting>
		</section>

		<section id="dlg.r.bridge_dlg">
		<title>dlg.bridge_dlg</title>
		<para>
			Bridge two SIP addresses into a call using INVITE(hold)-REFER-BYE
			mechanism.
		</para>
		<para>Name: <emphasis>dlg.bridge_dlg</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>from</emphasis> - SIP address to initiate the call
			</para></listitem>
			<listitem><para>
				<emphasis>to</emphasis> - SIP address to refer 'from' to
			</para></listitem>
			<listitem><para>
				<emphasis>op</emphasis> (optional) - outbound proxy SIP address.
				If its value is set to '.' (dot), then it is ignored (like it
				would not have been provided).
			</para></listitem>
			<listitem><para>
				<emphasis>body</emphasis> (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.
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.bridge_dlg _from_ _to_ _op_
...
		</programlisting>
		</section>

		<section id="dlg.r.stats_active">
		<title>dlg.stats_active</title>
		<para>
			Get stats about active dialogs by scanning internal list of dialogs
			(not relying on core stats framework).
		</para>
		<para>Name: <emphasis>dlg.stats_active</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>local_only</emphasis> (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).
			</para></listitem>
		</itemizedlist>
		<para>Returned fields</para>
		<itemizedlist>
			<listitem><para>
				<emphasis>starting</emphasis> - initial INVITE has been processed,
				no ringing or 1xx has been received.
			</para></listitem>
			<listitem><para>
				<emphasis>connecting</emphasis> - initial INVITE was forwarded
				and rining or 1xx has been received.
			</para></listitem>
			<listitem><para>
				<emphasis>answering</emphasis> - initial INVITE received 200 OK,
				but ACK was not handled yet.
			</para></listitem>
			<listitem><para>
				<emphasis>ongoing</emphasis> - ongoing active dialog, after the
				ACK was processed.
			</para></listitem>
			<listitem><para>
				<emphasis>all</emphasis> - all active dialogs, respectively the
				sum of the above values.
			</para></listitem>
		</itemizedlist>
		<para>RPC Command Format:</para>
		<programlisting  format="linespecific">
...
&kamcmd; dlg.stats_active
...
		</programlisting>
		</section>
		<section id="dlg.r.is_alive">
			<title>dlg.is_alive</title>
			<para>
				Check whether a dialog matching the parameter is in confirmed
				state (answered and alive).
			</para>
			<para>Name: <emphasis>dlg.is_alive</emphasis></para>
			<para>Parameters:</para>
			<itemizedlist>
				<listitem><para>
					<emphasis>callid</emphasis> - callid of dialog
				</para></listitem>
				<listitem><para>
					<emphasis>from_tag</emphasis> - from tag of the dialog
				</para></listitem>
				<listitem><para>
					<emphasis>to_tag</emphasis> - to tag of the dialog
				</para></listitem>
			</itemizedlist>
			<para>
				This command will return error if dialog is not found or not
				confirmed state (answered).
			</para>
			<para>RPC Command Format:</para>
			<programlisting format="linespecific">
...
&kamcmd; dlg.is_alive callid123 fromtag123 totag123
...
			</programlisting>
		</section>
		<section id="dlg.r.briefing">
		<title>dlg.briefing</title>
		<para>
		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.
		</para>
		<para>Name: <emphasis>dlg.briefing</emphasis></para>
		<para>Parameters:</para>
		<itemizedlist>
			<listitem><para>
			<emphasis>attrs</emphasis> - (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).
			</para>
			<para>
				The characters can be:
				<itemizedlist>
				<listitem><para>
					<emphasis>f</emphasis> - From URI
				</para></listitem>
				<listitem><para>
					<emphasis>t</emphasis> - To URI
				</para></listitem>
				<listitem><para>
					<emphasis>c</emphasis> - Call-ID
				</para></listitem>
				<listitem><para>
					<emphasis>F</emphasis> - From tag
				</para></listitem>
				<listitem><para>
					<emphasis>T</emphasis> - To tag
				</para></listitem>
				<listitem><para>
					<emphasis>I</emphasis> - Init time
				</para></listitem>
				<listitem><para>
					<emphasis>S</emphasis> - Start time
				</para></listitem>
				<listitem><para>
					<emphasis>E</emphasis> - End time
				</para></listitem>
				<listitem><para>
					<emphasis>s</emphasis> - State
				</para></listitem>
				</itemizedlist>
			</para>
			</listitem>
		</itemizedlist>
		<para>RPC Command Example:</para>
		<programlisting  format="linespecific">
...
kamctl rpc dlg.briefing
...
kamctl rpc dlg.briefing "ft"
...
		</programlisting>
		</section>

	</section>

	<section>
	<title>Exported Variables</title>

		<section>
			<title><varname>$DLG_count</varname></title>
			<para>
			Returns the number of current active dialogs (may be confirmed or
			not).
			</para>
		</section>

		<section>
			<title><varname>$DLG_status</varname></title>
			<para>
			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().
			</para>
			<para>
			Value may be:
			</para>
			<itemizedlist>
				<listitem><para>
					<emphasis>NULL</emphasis> - Dialog not found.
				</para></listitem>
				<listitem><para>
					<emphasis>3</emphasis> - Confirmed by a final reply but
					no ACK received yet.
				</para></listitem>
				<listitem><para>
					<emphasis>4</emphasis> - Confirmed by a final reply and
					ACK received.
				</para></listitem>
				<listitem><para>
					<emphasis>5</emphasis> - Dialog ended.
				</para></listitem>
			</itemizedlist>
		</section>

		<section>
			<title><varname>$DLG_lifetime</varname></title>
			<para>
			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().
			</para>
			<para>
			NULL will be returned if there is no dialog for the request.
			</para>
		</section>
		<section>
			<title><varname>$dlg(...)</varname></title>
			<para>Access to dialog attributes.</para>
		</section>
		<section>
			<title><varname>$dlg_ctx(...)</varname></title>
			<para>Access to dialog context attributes.</para>
		</section>

		<section>
			<title><varname>$dlg_var(key)</varname></title>
			<para>
			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().
			</para>
			<para>
			Note: You will receive "NULL", if there is no dialog for this
			request.
			</para>
		</section>

	</section>

	<section>
	<title>Event Routes</title>
		<section>
			<title>event_route[dialog:start]</title>
			<para>
			Executed when 200 OK reply for INVITE is processed.
			</para>
		</section>
		<section>
			<title>event_route[dialog:end]</title>
			<para>
			Executed when the BYE for the call is processed
			or the dialog timed out.
			</para>
		</section>
		<section>
			<title>event_route[dialog:failed]</title>
			<para>
			Executed when dialog is not completed (300 or greater reply code
			to INVITE).
			</para>
		</section>
	</section>

</chapter>
