[sr-dev] git:master:72b15ef9: dialog: new rpc function to terminate by sip ids

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 1 09:58:59 CEST 2016


Module: kamailio
Branch: master
Commit: 72b15ef953bf76f2b4ed9d44886ec6040b04a8b6
URL: https://github.com/kamailio/kamailio/commit/72b15ef953bf76f2b4ed9d44886ec6040b04a8b6

Author: Yasin CANER <yasin.caner at netgsm.com.tr>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-04-01T09:52:55+02:00

dialog: new rpc function to terminate by sip ids

- end established dialog by matching callid, from and to tags

---

Modified: modules/dialog/dialog.c

---

Diff:  https://github.com/kamailio/kamailio/commit/72b15ef953bf76f2b4ed9d44886ec6040b04a8b6.diff
Patch: https://github.com/kamailio/kamailio/commit/72b15ef953bf76f2b4ed9d44886ec6040b04a8b6.patch

---

diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index 553715d..db6c3ff 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,47 @@ 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);
+        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 +1856,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.terminate_dlg", rpc_dlg_terminate_dlg, rpc_dlg_terminate_dlg_doc, 0},
 	{0, 0, 0, 0}
 };




More information about the sr-dev mailing list