Bläddra i källkod

Extension to the API: lookup_terminate_dlg(unsigned int, unsigned int, str hdrs)
- Terminate a dialog using the API by providing h_entry and h_id (similar to the MI-Function)

Carsten Bock 12 år sedan
förälder
incheckning
25240becdd

+ 1 - 0
modules/dialog_ng/dialog.c

@@ -321,6 +321,7 @@ int load_dlg(struct dlg_binds *dlgb) {
     dlgb->set_dlg_var = api_set_dlg_variable;
     dlgb->get_dlg_var = api_get_dlg_variable;
     dlgb->terminate_dlg = w_api_terminate_dlg;
+    dlgb->lookup_terminate_dlg = w_api_lookup_terminate_dlg;
     dlgb->get_dlg_expires = api_get_dlg_expires;
     dlgb->get_dlg = dlg_get_msg_dialog;
 

+ 18 - 0
modules/dialog_ng/dlg_req_within.c

@@ -519,3 +519,21 @@ int dlg_bye_all(struct dlg_cell *dlg, str *hdrs) {
 
 }
 
+
+/* Wrapper for terminating dialog from API - from other modules */
+int w_api_lookup_terminate_dlg(unsigned int h_entry, unsigned int h_id, str *hdrs) {
+    struct dlg_cell *dlg;
+
+    dlg = lookup_dlg(h_entry, h_id); //increments ref count!
+
+    if (!dlg) {
+        LM_ERR("Asked to tear down non existent dialog\n");
+        return -1;
+    }
+
+    unref_dlg(dlg, 1);
+
+    return dlg_terminate(dlg, NULL, NULL/*reason*/, 2, hdrs);
+
+}
+

+ 1 - 0
modules/dialog_ng/dlg_req_within.h

@@ -53,6 +53,7 @@ int free_tm_dlg(dlg_t *td);
 int dlg_bye(struct dlg_cell *dlg, str *hdrs, int side);
 int dlg_bye_all(struct dlg_cell *dlg, str *hdrs);
 int w_api_terminate_dlg(str *call_id, str *from_tag, str *to_tag, str *hdrs, str* reason);
+int w_api_lookup_terminate_dlg(unsigned int h_entry, unsigned int h_id, str *hdrs);
 int dlg_terminate(struct dlg_cell *dlg, struct sip_msg* msg, str *reason, int side, str *extra_headers);
 
 #endif

+ 2 - 2
modules/dialog_ng/doc/dialog_ng.xml

@@ -27,7 +27,7 @@
                 <firstname>Carsten</firstname>
                 <surname>Bock</surname>
                 <affiliation>
-                    <orgname>ng-voice.com</orgname>
+                    <orgname>ng-voice GmbH</orgname>
                 </affiliation>
                 <address>
                     <email>[email protected]</email>
@@ -88,7 +88,7 @@
             <holder>Voice Sistem SRL</holder>
         </copyright>
         <copyright>
-            <year>2011</year>
+            <year>2011-2013</year>
             <holder>Carsten Bock, http://www.ng-voice.com</holder>
         </copyright>
     </bookinfo>

+ 29 - 0
modules/dialog_ng/doc/dialog_ng_devel.xml

@@ -200,6 +200,35 @@
                 </listitem>
             </itemizedlist>
         </section>
+
+        <section>
+            <title>
+                <function moreinfo="none">lookup_terminate_dlg (unsigned int h_entry, unsigned int h_id, hdrs)</function>
+            </title>
+            <para>
+		Terminate a Dialog identified by h_entry and h_id (similar to dlg_end_dlg command via XMLRPC).
+            </para>
+            <para>Meaning of parameters is as follows:</para>
+            <itemizedlist>
+                <listitem>
+                    <para>
+                        <emphasis>unsigned int h_entry</emphasis> - Number of the table, where to find the dialog
+                    </para>
+                </listitem>
+                <listitem>
+                    <para>
+                        <emphasis>unsigned int h_id</emphasis> - Number of the entry in the table, where to find the dialog
+			terminate.
+                    </para>
+                </listitem>
+                <listitem>
+                    <para>
+                        <emphasis>str* hdrs</emphasis> - string containg extra headers (full format) 
+			to be added to the BYE requests of the dialog.
+                    </para>
+                </listitem>
+            </itemizedlist>
+        </section>
         
         <section>
             <title>