Module: kamailio
Branch: master
Commit: d091de55146e90c2d15e67b746a369976aa7c24a
URL:
https://github.com/kamailio/kamailio/commit/d091de55146e90c2d15e67b746a3699…
Author: Surendra Tiwari <surendratiwari3(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-12-05T10:58:18+01:00
dialog: added rpc command dlg.is_alive
- adjusted from GH #1740
---
Modified: src/modules/dialog/dialog.c
Modified: src/modules/dialog/doc/dialog.xml
Modified: src/modules/dialog/doc/dialog_admin.xml
---
Diff:
https://github.com/kamailio/kamailio/commit/d091de55146e90c2d15e67b746a3699…
Patch:
https://github.com/kamailio/kamailio/commit/d091de55146e90c2d15e67b746a3699…
---
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index bf2ba96488..5b35693883 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -2215,8 +2215,11 @@ static const char *rpc_profile_print_dlgs_doc[2] = {
"Lists all the dialogs belonging to a profile", 0
};
static const char *rpc_dlg_bridge_doc[2] = {
- "Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE mechanism:\
- to, from, [outbound SIP proxy]", 0
+ "Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE mechanism:"
+ " to, from, [outbound SIP proxy]", 0
+};
+static const char *rpc_dlg_is_alive_doc[2] = {
+ "Check whether dialog is alive or not", 0
};
@@ -2272,6 +2275,40 @@ static void rpc_dlg_terminate_dlg(rpc_t *rpc,void *c){
}
}
+static void rpc_dlg_is_alive(rpc_t *rpc, void *c)
+{
+ str callid = {NULL, 0};
+ str ftag = {NULL, 0};
+ str ttag = {NULL, 0};
+
+ dlg_cell_t *dlg = NULL;
+ unsigned int dir = 0;
+ unsigned int state = 0;
+
+ if (rpc->scan(c, ".S.S.S", &callid, &ftag, &ttag) < 3) {
+ LM_DBG("Unable to read expected parameters\n");
+ rpc->fault(c, 400, "Too few parameters (required callid, from-tag,
to-tag)");
+ return;
+ }
+
+ dlg = get_dlg(&callid, &ftag, &ttag, &dir);
+
+ if (dlg == NULL) {
+ LM_DBG("Couldnt find dialog with callid: '%.*s'\n", callid.len,
callid.s);
+ rpc->fault(c, 404, "Dialog not found");
+ return;
+ }
+ state = dlg->state;
+ dlg_release(dlg);
+ if (state != DLG_STATE_CONFIRMED) {
+ LM_DBG("Dialog with Call-ID '%.*s' is in state: %d (confirmed:
%d)\n",
+ callid.len, callid.s, state, DLG_STATE_CONFIRMED);
+ rpc->fault(c, 500, "Dialog not in confirmed state");
+ return;
+ } else {
+ rpc->add(c, "s", "Alive");
+ }
+}
static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) {
unsigned int h_entry, h_id;
@@ -2428,5 +2465,6 @@ static rpc_export_t rpc_methods[] = {
{"dlg.bridge_dlg", rpc_dlg_bridge, rpc_dlg_bridge_doc, 0},
{"dlg.terminate_dlg", rpc_dlg_terminate_dlg, rpc_dlg_terminate_dlg_doc, 0},
{"dlg.stats_active", rpc_dlg_stats_active, rpc_dlg_stats_active_doc, 0},
+ {"dlg.is_alive", rpc_dlg_is_alive, rpc_dlg_is_alive_doc, 0},
{0, 0, 0, 0}
};
diff --git a/src/modules/dialog/doc/dialog.xml b/src/modules/dialog/doc/dialog.xml
index 08935fd115..87bf8b6da6 100644
--- a/src/modules/dialog/doc/dialog.xml
+++ b/src/modules/dialog/doc/dialog.xml
@@ -53,6 +53,11 @@
<surname>Johansson</surname>
<email>oej(a)edvina.net</email>
</editor>
+ <editor>
+ <firstname>Surendra</firstname>
+ <surname>Tiwari</surname>
+ <email>surendratiwari3(a)gmail.com</email>
+ </editor>
</authorgroup>
<copyright>
<year>2006</year>
diff --git a/src/modules/dialog/doc/dialog_admin.xml
b/src/modules/dialog/doc/dialog_admin.xml
index 2240a72c85..35e22d3166 100644
--- a/src/modules/dialog/doc/dialog_admin.xml
+++ b/src/modules/dialog/doc/dialog_admin.xml
@@ -2640,6 +2640,36 @@ if(has_totag()) {
...
</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>
<section>