Module: sip-router Branch: master Commit: 25240becdd83801a788b65f52eada5dd63665e8c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=25240bec...
Author: Carsten Bock carsten@ng-voice.com Committer: Carsten Bock carsten@ng-voice.com Date: Tue Aug 6 22:48:39 2013 +0200
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)
---
modules/dialog_ng/dialog.c | 1 + modules/dialog_ng/dlg_req_within.c | 18 ++++++++++++++++++ modules/dialog_ng/dlg_req_within.h | 1 + modules/dialog_ng/doc/dialog_ng.xml | 4 ++-- modules/dialog_ng/doc/dialog_ng_devel.xml | 29 +++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/modules/dialog_ng/dialog.c b/modules/dialog_ng/dialog.c index bcec0e5..4e1b547 100644 --- a/modules/dialog_ng/dialog.c +++ b/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;
diff --git a/modules/dialog_ng/dlg_req_within.c b/modules/dialog_ng/dlg_req_within.c index 9a2d598..2d366eb 100644 --- a/modules/dialog_ng/dlg_req_within.c +++ b/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); + +} + diff --git a/modules/dialog_ng/dlg_req_within.h b/modules/dialog_ng/dlg_req_within.h index 34316a5..43d11a7 100644 --- a/modules/dialog_ng/dlg_req_within.h +++ b/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 diff --git a/modules/dialog_ng/doc/dialog_ng.xml b/modules/dialog_ng/doc/dialog_ng.xml index 7835c66..820538f 100644 --- a/modules/dialog_ng/doc/dialog_ng.xml +++ b/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>carsten@ng-voice.com</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> diff --git a/modules/dialog_ng/doc/dialog_ng_devel.xml b/modules/dialog_ng/doc/dialog_ng_devel.xml index 148edd1..d6102b3 100644 --- a/modules/dialog_ng/doc/dialog_ng_devel.xml +++ b/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>