[sr-dev] git:master:844c680f: keepalive : added keepalive.del rpc command

Yasin CANER caner_yaso at hotmail.com
Mon Jan 6 18:23:24 CET 2020


Module: kamailio
Branch: master
Commit: 844c680fbe6740f5eef9bee83ebefa36934142d7
URL: https://github.com/kamailio/kamailio/commit/844c680fbe6740f5eef9bee83ebefa36934142d7

Author: Yasin CANER <caner_yaso at hotmail.com>
Committer: Yasin CANER <caner_yaso at hotmail.com>
Date: 2019-12-16T06:38:05-05:00

keepalive : added keepalive.del rpc command

added keepalive.del rpc command

---

Modified: src/modules/keepalive/keepalive_rpc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/844c680fbe6740f5eef9bee83ebefa36934142d7.diff
Patch: https://github.com/kamailio/kamailio/commit/844c680fbe6740f5eef9bee83ebefa36934142d7.patch

---

diff --git a/src/modules/keepalive/keepalive_rpc.c b/src/modules/keepalive/keepalive_rpc.c
index 88de7bae04..a873effdd6 100644
--- a/src/modules/keepalive/keepalive_rpc.c
+++ b/src/modules/keepalive/keepalive_rpc.c
@@ -43,13 +43,19 @@
 
 static const char *keepalive_rpc_list_doc[2];
 static const char *keepalive_rpc_add_doc[2];
+static const char *keepalive_rpc_del_doc[2];
+
 
 static void keepalive_rpc_list(rpc_t *rpc, void *ctx);
 static void keepalive_rpc_add(rpc_t *rpc, void *ctx);
+static void keepalive_rpc_del(rpc_t *rpc, void *ctx);
+
 
 rpc_export_t keepalive_rpc_cmds[] = {
 	{"keepalive.list", keepalive_rpc_list, keepalive_rpc_list_doc, 0},
 	{"keepalive.add", keepalive_rpc_add, keepalive_rpc_add_doc, 0},
+	{"keepalive.del", keepalive_rpc_del, keepalive_rpc_del_doc, 0},
+
 	{0, 0, 0, 0}
 };
 
@@ -122,4 +128,37 @@ static void keepalive_rpc_add(rpc_t *rpc, void *ctx)
 	return;
 }
 static const char *keepalive_rpc_add_doc[2] = {
-		"adds new destination to keepalive memory. usage keepalive.add sip:username at domain listname", 0};
+		"adds new destination to keepalive memory. usage: keepalive.add sip:username at domain listname", 0};
+
+static void keepalive_rpc_del(rpc_t *rpc, void *ctx)
+{
+	str sip_adress = {0,0};
+	str table_name ={0,0};
+	int ret = 0;
+
+	ret = rpc->scan(ctx, "SS",&sip_adress,&table_name);
+
+	if (ret < 2) {
+		LM_ERR("not enough parameters - read so far: %d\n", ret);
+		rpc->fault(ctx, 500, "Not enough parameters or wrong format");
+		return;
+	}
+
+	LM_DBG(" keepalive deletes [%.*s]\n", sip_adress.len , sip_adress.s);
+
+	if(sip_adress.len < 1 || table_name.len < 1){
+		LM_ERR("parameter is len less than 1  \n");
+		rpc->fault(ctx, 500, "parameter is len less than 1");
+		return;
+	}
+
+	if(ka_del_destination(&sip_adress,&table_name) < 0 ){
+		LM_ERR("couldn't delete data from list \n"  );
+		rpc->fault(ctx, 500, "couldn't delete data from list");
+		return;
+	}
+
+	return;
+}
+static const char *keepalive_rpc_del_doc[2] = {
+		"deletes destination from keepalive memory. usage: keepalive.del sip:username at domain listname", 0};




More information about the sr-dev mailing list