From 18f617d6b6c4b13c568d3cccdfd527e022bacac5 Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Mon, 28 Mar 2016 16:50:25 +0300 Subject: [PATCH 1/7] dialog module : new rpc function for terminate adding new rpc function to terminate a dialog with callid, to tag and from tag --- modules/dialog/dialog.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index 553715d380e..8df8a614326 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -1698,6 +1698,9 @@ static const char *rpc_print_dlg_ctx_doc[2] = { static const char *rpc_end_dlg_entry_id_doc[2] = { "End a given dialog based on [h_entry] [h_id]", 0 }; +static const char *rpc_dlg_terminate_dlg_doc[2] = { + "End a given dialog based on callid", 0 +}; static const char *rpc_profile_get_size_doc[2] = { "Returns the number of dialogs belonging to a profile", 0 }; @@ -1722,6 +1725,46 @@ static void rpc_print_dlg(rpc_t *rpc, void *c) { static void rpc_print_dlg_ctx(rpc_t *rpc, void *c) { internal_rpc_print_single_dlg(rpc, c, 1); } +static void rpc_dlg_terminate_dlg(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; + int ret=0; + dir = 0; + + + if(rpc->scan(c, ".S.S.S", &callid,&ftag,&ttag)<3) + { + LM_ERR("Unable to read the parameters dlg_terminate_dlg \n" ); + rpc->fault(c, 400, "Need a Callid ,from tag ,to tag"); + return; + } + + dlg=get_dlg(&callid,&ftag,&ttag,&dir); + + if(dlg==NULL){ + LM_ERR("Couldnt find callid in dialog '%.*s' \n",callid.len, callid.s); + rpc->fault(c, 500, "Couldnt find callid in dialog"); + return; + } + + LM_DBG("Dialog is found with callid for terminate rpc '%.*s' \n",callid.len, callid.s); + + ret=dlg_bye_all(dlg,NULL); + + LM_DBG("Dialog bye return code %d \n",ret); + + if(ret>=0){ + LM_WARN("Dialog is terminated callid: '%.*s' \n",callid.len, callid.s); + rpc->fault(c, 200, "Dialog terminated"); + dlg_release(dlg); + } +} + + static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) { unsigned int h_entry, h_id; dlg_cell_t * dlg = NULL; @@ -1812,5 +1855,6 @@ static rpc_export_t rpc_methods[] = { {"dlg.profile_get_size", rpc_profile_get_size, rpc_profile_get_size_doc, 0}, {"dlg.profile_list", rpc_profile_print_dlgs, rpc_profile_print_dlgs_doc, RET_ARRAY}, {"dlg.bridge_dlg", rpc_dlg_bridge, rpc_dlg_bridge_doc, 0}, + {"dlg.dlg_terminate_dlg", rpc_dlg_terminate_dlg, rpc_dlg_terminate_dlg_doc, 0}, {0, 0, 0, 0} }; From e606561f2d937cf4bc68bcca992642c9b974dbbc Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Tue, 29 Mar 2016 09:04:16 +0300 Subject: [PATCH 2/7] dialog module : rpc terminate dialog doc added termiinate_dlg rpc function doc is added. kamcmd command is written insted of serctl --- modules/dialog/doc/dialog_admin.xml | 46 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/modules/dialog/doc/dialog_admin.xml b/modules/dialog/doc/dialog_admin.xml index 50dffa7974a..5227c4654ec 100644 --- a/modules/dialog/doc/dialog_admin.xml +++ b/modules/dialog/doc/dialog_admin.xml @@ -2304,7 +2304,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); Name: dlg.list RPC Command Format: - serctl dlg_list + kamcmd dlg_list @@ -2318,7 +2318,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); Name: dlg.list_ctx RPC Command Format: - serctl dlg.list_ctx + kamcmd dlg.list_ctx @@ -2341,10 +2341,9 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.list abcdrssfrs122444@192.168.1.1 AAdfeEFF33 + kamcmd dlg.list abcdrssfrs122444@192.168.1.1 AAdfeEFF33 -
<varname>dlg.dlg_list_ctx</varname> @@ -2357,10 +2356,36 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33 + kamcmd dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33 + +
+
+ <varname>dlg.dlg_terminate_dlg</varname> + + Terminates an ongoing dialog by sending BYE in both directions. + + Name: dlg.dlg_terminate_dlg + Parameters: + + + callid - callid of dialog to be terminated + + + from_tag - from tag of the dialog to terminated + + + totag - to tag of the dialog to terminated + + + + Works only for confirmed dialogs + RPC command. + + RPC Command Format: + + kamcmd dlg.dlg_terminate_dlg callid12345callid asfromtag123 astotag123
-
<varname>dlg.end_dlg</varname> @@ -2388,10 +2413,9 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.end_dlg 342 56 + kamcmd dlg.end_dlg 342 56
-
<varname>dlg.profile_get_size</varname> @@ -2416,7 +2440,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.dlg.profile_get_size inbound_calls + kamcmd dlg.dlg.profile_get_size inbound_calls
@@ -2444,7 +2468,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.profile_list inbound_calls + kamcmd dlg.profile_list inbound_calls @@ -2469,7 +2493,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - serctl dlg.list from to op + kamcmd dlg.list from to op From 7cac43a290f33f28c13807a6cb64dd3162cdfc8d Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Tue, 29 Mar 2016 10:29:29 +0300 Subject: [PATCH 3/7] domain module : added rpc return code added rpc return code --- modules/domain/domain_mod.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/domain/domain_mod.c b/modules/domain/domain_mod.c index 45697fd3d2b..dc5d08ed450 100644 --- a/modules/domain/domain_mod.c +++ b/modules/domain/domain_mod.c @@ -288,6 +288,7 @@ static void domain_rpc_reload(rpc_t* rpc, void* ctx) rpc->fault(ctx, 400, "Reload of domain tables failed"); } lock_release(reload_lock); + rpc->fault(ctx, 200, "domain table is reloaded"); } From f09e62aa2e70baffdba1d19f4b1c743b1118e0bb Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Tue, 29 Mar 2016 12:25:55 +0300 Subject: [PATCH 4/7] dialog module: fixed response fixed xml response as xml specification --- modules/dialog/dialog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index 8df8a614326..dbcd789f22d 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -1759,7 +1759,9 @@ static void rpc_dlg_terminate_dlg(rpc_t *rpc,void *c){ if(ret>=0){ LM_WARN("Dialog is terminated callid: '%.*s' \n",callid.len, callid.s); - rpc->fault(c, 200, "Dialog terminated"); + rpc->add(c, "d", 200); + rpc->add(c, "s", "OK"); + rpc->send(c); dlg_release(dlg); } } From 9ae73dda743895e221f9e3accc0a35daed8e11dc Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Tue, 29 Mar 2016 12:27:31 +0300 Subject: [PATCH 5/7] domain module : fixed response fixed xml response as xml specification --- modules/domain/domain_mod.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/domain/domain_mod.c b/modules/domain/domain_mod.c index dc5d08ed450..b333dc0fe51 100644 --- a/modules/domain/domain_mod.c +++ b/modules/domain/domain_mod.c @@ -288,7 +288,10 @@ static void domain_rpc_reload(rpc_t* rpc, void* ctx) rpc->fault(ctx, 400, "Reload of domain tables failed"); } lock_release(reload_lock); - rpc->fault(ctx, 200, "domain table is reloaded"); + rpc->add(c, "d", 200); + rpc->add(c, "s", "OK"); + rpc->send(c); + } From f4d33dd54375e1d7df40b22754a748e607ddefb2 Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Wed, 30 Mar 2016 08:52:38 +0300 Subject: [PATCH 6/7] dialog module: fixes travis error --- modules/dialog/dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index dbcd789f22d..b15a4b7eb81 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -1759,10 +1759,10 @@ static void rpc_dlg_terminate_dlg(rpc_t *rpc,void *c){ if(ret>=0){ LM_WARN("Dialog is terminated callid: '%.*s' \n",callid.len, callid.s); + dlg_release(dlg); rpc->add(c, "d", 200); rpc->add(c, "s", "OK"); rpc->send(c); - dlg_release(dlg); } } From c26fb114d7ea844a6eeedda54d206bac5eec7746 Mon Sep 17 00:00:00 2001 From: Yasin CANER Date: Wed, 30 Mar 2016 10:28:03 +0300 Subject: [PATCH 7/7] domain module : fixed typo --- modules/domain/domain_mod.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/domain/domain_mod.c b/modules/domain/domain_mod.c index b333dc0fe51..c3b71d0180a 100644 --- a/modules/domain/domain_mod.c +++ b/modules/domain/domain_mod.c @@ -288,9 +288,9 @@ static void domain_rpc_reload(rpc_t* rpc, void* ctx) rpc->fault(ctx, 400, "Reload of domain tables failed"); } lock_release(reload_lock); - rpc->add(c, "d", 200); - rpc->add(c, "s", "OK"); - rpc->send(c); + rpc->add(ctx, "d", 200); + rpc->add(ctx, "s", "OK"); + rpc->send(ctx); }