[sr-dev] git:master:5b2ad5c7: keepalive : added keepalive.add rpc command

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


Module: kamailio
Branch: master
Commit: 5b2ad5c7c3fbdadb856b32b1cf8ad8ecb913ba63
URL: https://github.com/kamailio/kamailio/commit/5b2ad5c7c3fbdadb856b32b1cf8ad8ecb913ba63

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

keepalive : added keepalive.add rpc command

added keepalive.add rpc command

---

Modified: src/modules/keepalive/keepalive_rpc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5b2ad5c7c3fbdadb856b32b1cf8ad8ecb913ba63.diff
Patch: https://github.com/kamailio/kamailio/commit/5b2ad5c7c3fbdadb856b32b1cf8ad8ecb913ba63.patch

---

diff --git a/src/modules/keepalive/keepalive_rpc.c b/src/modules/keepalive/keepalive_rpc.c
index 8efe0fb117..88de7bae04 100644
--- a/src/modules/keepalive/keepalive_rpc.c
+++ b/src/modules/keepalive/keepalive_rpc.c
@@ -42,10 +42,14 @@
 #include "api.h"
 
 static const char *keepalive_rpc_list_doc[2];
+static const char *keepalive_rpc_add_doc[2];
+
 static void keepalive_rpc_list(rpc_t *rpc, void *ctx);
+static void keepalive_rpc_add(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},
 	{0, 0, 0, 0}
 };
 
@@ -87,3 +91,35 @@ static void keepalive_rpc_list(rpc_t *rpc, void *ctx)
 
 	return;
 }
+
+static void keepalive_rpc_add(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 adds [%.*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_add_dest(&sip_adress,&table_name,0,0,0) < 0 ){
+		LM_ERR("couldn't add data to list \n"  );
+		rpc->fault(ctx, 500, "couldn't add data to list");
+		return;
+	}
+
+	return;
+}
+static const char *keepalive_rpc_add_doc[2] = {
+		"adds new destination to keepalive memory. usage keepalive.add sip:username at domain listname", 0};




More information about the sr-dev mailing list