[sr-dev] git:master: dialog_ng: include dialog function dlg_get in dialog_ng

Richard Good richard.good at smilecoms.com
Mon Jul 1 11:50:54 CEST 2013


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

Author: Richard Good <richard.good at smilecoms.com>
Committer: Richard Good <richard.good at smilecoms.com>
Date:   Mon Jul  1 11:47:50 2013 +0200

dialog_ng: include dialog function dlg_get in dialog_ng
	- In first iteration of dialog_ng module the dialog function dlg_get was not included
	- This function is now included; it searches and sets current dialog based on Call-ID, From-Tag and To-Tag

---

 modules/dialog_ng/dialog.c                |   70 +++++++++++++++++++++++++++++
 modules/dialog_ng/doc/dialog_ng_admin.xml |   46 ++++++++++++++++---
 2 files changed, 108 insertions(+), 8 deletions(-)

diff --git a/modules/dialog_ng/dialog.c b/modules/dialog_ng/dialog.c
index 4042cbf..bcec0e5 100644
--- a/modules/dialog_ng/dialog.c
+++ b/modules/dialog_ng/dialog.c
@@ -69,6 +69,7 @@ pv_spec_t timeout_avp;
 static int fixup_profile(void** param, int param_no);
 static int fixup_get_profile2(void** param, int param_no);
 static int fixup_get_profile3(void** param, int param_no);
+static int fixup_dlg_bridge(void** param, int param_no);
 static int fixup_dlg_terminate(void** param, int param_no);
 static int w_set_dlg_profile(struct sip_msg*, char*, char*);
 static int w_unset_dlg_profile(struct sip_msg*, char*, char*);
@@ -79,6 +80,7 @@ static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2);
 static int w_dlg_resetflag(struct sip_msg *msg, char *flag, str *s2);
 static int w_dlg_setflag(struct sip_msg *msg, char *flag, char *s2);
 static int w_dlg_terminate(struct sip_msg*, char*, char*);
+static int w_dlg_get(struct sip_msg*, char*, char*, char*);
 static int w_is_known_dlg(struct sip_msg *);
 
 static cmd_export_t cmds[] = {
@@ -108,6 +110,7 @@ static cmd_export_t cmds[] = {
         0, REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE},
     {"dlg_terminate", (cmd_function) w_dlg_terminate, 2, fixup_dlg_terminate,
         0, REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE},
+   {"dlg_get", (cmd_function)w_dlg_get, 3, fixup_dlg_bridge, 0, ANY_ROUTE },
     {"is_known_dlg", (cmd_function) w_is_known_dlg, 0, NULL,
         0, REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE | BRANCH_ROUTE},
     {"load_dlg", (cmd_function) load_dlg, 0, 0, 0, 0},
@@ -244,6 +247,73 @@ static int fixup_dlg_terminate(void** param, int param_no) {
     return 0;
 }
 
+static int fixup_dlg_bridge(void** param, int param_no)
+{
+	if (param_no>=1 && param_no<=3) {
+		return fixup_spve_null(param, 1);
+	} else {
+		LM_ERR("called with parameter idx %d\n", param_no);
+		return E_BUG;
+	}
+	return 0;
+}
+
+static int w_dlg_get(struct sip_msg *msg, char *ci, char *ft, char *tt)
+{
+	struct dlg_cell *dlg = NULL;
+	str sc = {0,0};
+	str sf = {0,0};
+	str st = {0,0};
+	unsigned int dir = 0;
+
+	if(ci==0 || ft==0 || tt==0)
+	{
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+
+	if(fixup_get_svalue(msg, (gparam_p)ci, &sc)!=0)
+	{
+		LM_ERR("unable to get Call-ID\n");
+		return -1;
+	}
+	if(sc.s==NULL || sc.len == 0)
+	{
+		LM_ERR("invalid Call-ID parameter\n");
+		return -1;
+	}
+	if(fixup_get_svalue(msg, (gparam_p)ft, &sf)!=0)
+	{
+		LM_ERR("unable to get From tag\n");
+		return -1;
+	}
+	if(sf.s==NULL || sf.len == 0)
+	{
+		LM_ERR("invalid From tag parameter\n");
+		return -1;
+	}
+	if(fixup_get_svalue(msg, (gparam_p)tt, &st)!=0)
+	{
+		LM_ERR("unable to get To Tag\n");
+		return -1;
+	}
+	if(st.s==NULL || st.len == 0)
+	{
+		LM_ERR("invalid To tag parameter\n");
+		return -1;
+	}
+
+	dlg = get_dlg(&sc, &sf, &st, &dir);
+	if(dlg==NULL)
+		return -1;
+
+        unref_dlg(dlg, 1);
+        set_current_dialog(msg, dlg);
+        _dlg_ctx.dlg = dlg;
+        _dlg_ctx.dir = dir;
+	return 1;
+}
+
 int load_dlg(struct dlg_binds *dlgb) {
 
     dlgb->register_dlgcb = register_dlgcb;
diff --git a/modules/dialog_ng/doc/dialog_ng_admin.xml b/modules/dialog_ng/doc/dialog_ng_admin.xml
index 2b9047e..c6353e2 100644
--- a/modules/dialog_ng/doc/dialog_ng_admin.xml
+++ b/modules/dialog_ng/doc/dialog_ng_admin.xml
@@ -839,14 +839,44 @@ dlg_terminate("all", "Insufficient QoS");
         </section>
 
         <section>
-            <title>
-                <function moreinfo="none">dlg_get(callid, ftag, ttag)</function>
-            </title>
-            <para>
-                    This function is currently not supported by the dialog_ng module.
-                    To be incorporated in the future.
-            </para>
-        </section>
+		<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.
+			</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>
             <title>




More information about the sr-dev mailing list