[sr-dev] git:master: dialog(k): new function to set dialog timeout by internal id

Daniel-Constantin Mierla miconda at gmail.com
Thu Feb 23 00:17:54 CET 2012


Module: sip-router
Branch: master
Commit: 3beef50c69d60fcb372d555a561d8e2258ff5734
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3beef50c69d60fcb372d555a561d8e2258ff5734

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Feb 22 22:17:29 2012 +0100

dialog(k): new function to set dialog timeout by internal id

- dlg_set_timeout(timeout [, h_entry, h_id])

---

 modules_k/dialog/README               |   27 +++++++++++++++++
 modules_k/dialog/dialog.c             |   53 +++++++++++++++++++++++++++++++++
 modules_k/dialog/doc/dialog_admin.xml |   44 +++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 0 deletions(-)

diff --git a/modules_k/dialog/README b/modules_k/dialog/README
index 36f0187..e29ac45 100644
--- a/modules_k/dialog/README
+++ b/modules_k/dialog/README
@@ -102,6 +102,7 @@ Alex Balashov
               6.11. dlg_bridge(from, to, op)
               6.12. dlg_get(callid, ftag, ttag)
               6.13. is_known_dlg()
+              6.14. dlg_set_timeout(timeout [, h_entry, h_id])
 
         7. Statistics
 
@@ -217,6 +218,7 @@ Alex Balashov
    1.56. dlg_bridge usage
    1.57. dlg_get usage
    1.58. is_known_dlg() usage
+   1.59. dlg_set_timeout usage
 
 Chapter 1. Admin Guide
 
@@ -293,6 +295,7 @@ Chapter 1. Admin Guide
         6.11. dlg_bridge(from, to, op)
         6.12. dlg_get(callid, ftag, ttag)
         6.13. is_known_dlg()
+        6.14. dlg_set_timeout(timeout [, h_entry, h_id])
 
    7. Statistics
 
@@ -1063,6 +1066,7 @@ modparam("dialog", "wait_ack", 0)
    6.11. dlg_bridge(from, to, op)
    6.12. dlg_get(callid, ftag, ttag)
    6.13. is_known_dlg()
+   6.14. dlg_set_timeout(timeout [, h_entry, h_id])
 
 6.1. set_dlg_profile(profile,[value])
 
@@ -1329,6 +1333,29 @@ if(!uri == myself) {
 }
 ...
 
+6.14. dlg_set_timeout(timeout [, h_entry, h_id])
+
+   Set the dialog timeout. Dialog timeout will be updated if it was
+   already set. If h_entry and h_id parameters are not provided, the
+   dialog will be searched based on (callid, fromtag, totag) of currently
+   processed SIP message.
+
+   Meaning of the parameters is as follows:
+     * timeout - the interval in seconds after which the dialog will time
+       out.
+     * h_entry - h_entry value of the iternal dialog identifier.
+     * h_id - h_id valye if the internal dialog identifier.
+
+   This function can be used from ANY_ROUTE.
+
+   Example 1.59. dlg_set_timeout usage
+...
+if(dlg_set_timeout("180", "123", "456"))
+{
+    ...
+}
+...
+
 7. Statistics
 
    7.1. active_dialogs
diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c
index a919b62..b89eb9b 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -155,6 +155,7 @@ static int w_dlg_manage(struct sip_msg*, char*, char*);
 static int w_dlg_bye(struct sip_msg*, char*, char*);
 static int w_dlg_refer(struct sip_msg*, char*, char*);
 static int w_dlg_bridge(struct sip_msg*, char*, char*, char*);
+static int w_dlg_set_timeout(struct sip_msg*, char*, char*, char*);
 static int fixup_dlg_bye(void** param, int param_no);
 static int fixup_dlg_refer(void** param, int param_no);
 static int fixup_dlg_bridge(void** param, int param_no);
@@ -196,6 +197,10 @@ static cmd_export_t cmds[]={
 			0, ANY_ROUTE },
 	{"is_known_dlg", (cmd_function)w_is_known_dlg,        0, NULL,
 			0, ANY_ROUTE },
+	{"dlg_set_timeout", (cmd_function)w_dlg_set_timeout,  1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"dlg_set_timeout", (cmd_function)w_dlg_set_timeout,  3,fixup_igp_all,
+			0, ANY_ROUTE },
 	{"load_dlg",  (cmd_function)load_dlg,   0, 0, 0, 0},
 	{0,0,0,0,0,0}
 };
@@ -1068,6 +1073,54 @@ static int w_dlg_bridge(struct sip_msg *msg, char *from, char *to, char *op)
 	return 1;
 }
 
+/**
+ *
+ */
+static int w_dlg_set_timeout(struct sip_msg *msg, char *pto, char *phe, char *phi)
+{
+	int to = 0;
+	unsigned int he = 0;
+	unsigned int hi = 0;
+	dlg_cell_t *dlg = NULL;
+
+	if(fixup_get_ivalue(msg, (gparam_p)pto, &to)!=0)
+	{
+		LM_ERR("no timeout value\n");
+		return -1;
+	}
+	if(phe!=NULL)
+	{
+		if(fixup_get_ivalue(msg, (gparam_p)phe, (int*)&he)!=0)
+		{
+			LM_ERR("no hash entry value value\n");
+			return -1;
+		}
+		if(fixup_get_ivalue(msg, (gparam_p)phi, (int*)&hi)!=0)
+		{
+			LM_ERR("no hash id value value\n");
+			return -1;
+		}
+		dlg = dlg_lookup(he, hi);
+	} else {
+		dlg = dlg_get_msg_dialog(msg);
+	}
+
+	if(dlg==NULL)
+	{
+		LM_DBG("no dialog found\n");
+		return -1;
+	}
+
+	if(update_dlg_timer(&dlg->tl, to)<0) {
+		LM_ERR("failed to update dialog lifetime\n");
+		dlg_release(dlg);
+		return -1;
+	}
+	dlg->lifetime = to;
+	dlg->dflags |= DLG_FLAG_CHANGED;
+	dlg_release(dlg);
+	return 1;
+}
 
 static int fixup_dlg_bye(void** param, int param_no)
 {
diff --git a/modules_k/dialog/doc/dialog_admin.xml b/modules_k/dialog/doc/dialog_admin.xml
index b5898c2..714c0fb 100644
--- a/modules_k/dialog/doc/dialog_admin.xml
+++ b/modules_k/dialog/doc/dialog_admin.xml
@@ -1633,6 +1633,50 @@ if(!uri == myself) {
 		</example>
 	</section>
 
+	<section>
+		<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 valye 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>
 
 




More information about the sr-dev mailing list