Module: kamailio Branch: master Commit: 844c680fbe6740f5eef9bee83ebefa36934142d7 URL: https://github.com/kamailio/kamailio/commit/844c680fbe6740f5eef9bee83ebefa36...
Author: Yasin CANER caner_yaso@hotmail.com Committer: Yasin CANER caner_yaso@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/844c680fbe6740f5eef9bee83ebefa36... Patch: https://github.com/kamailio/kamailio/commit/844c680fbe6740f5eef9bee83ebefa36...
---
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@domain listname", 0}; + "adds new destination to keepalive memory. usage: keepalive.add sip:username@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@domain listname", 0};