Module: sip-router
Branch: master
Commit: 5ef20abd1fdb45f5398eecedc81af3fad13024a3
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5ef20ab…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Mar 31 09:29:06 2014 +0200
evapi: added evapi_close() function
- close client connection from cfg file
---
modules/evapi/evapi_dispatch.c | 19 ++++++++++++++++++-
modules/evapi/evapi_dispatch.h | 2 +-
modules/evapi/evapi_mod.c | 22 ++++++++++++++++++++--
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/modules/evapi/evapi_dispatch.c b/modules/evapi/evapi_dispatch.c
index 72add89..a13742d 100644
--- a/modules/evapi/evapi_dispatch.c
+++ b/modules/evapi/evapi_dispatch.c
@@ -129,7 +129,7 @@ int evapi_run_cfg_route(evapi_env_t *evenv, int rt)
/**
*
*/
-int evapi_cfg_close_connection(int cidx)
+int evapi_close_connection(int cidx)
{
if(cidx<0 || cidx>=EVAPI_MAX_CLIENTS)
return -1;
@@ -146,6 +146,23 @@ int evapi_cfg_close_connection(int cidx)
/**
*
*/
+int evapi_cfg_close(sip_msg_t *msg)
+{
+ evapi_env_t *evenv;
+
+ if(msg==NULL)
+ return -1;
+
+ evenv = (evapi_env_t*)msg->date;
+
+ if(evenv==NULL || evenv->conidx<0 || evenv->conidx>=EVAPI_MAX_CLIENTS)
+ return -1;
+ return evapi_close_connection(evenv->conidx);
+}
+
+/**
+ *
+ */
int evapi_init_notify_sockets(void)
{
if (socketpair(PF_UNIX, SOCK_STREAM, 0, _evapi_notify_sockets) < 0) {
diff --git a/modules/evapi/evapi_dispatch.h b/modules/evapi/evapi_dispatch.h
index ff49946..568576f 100644
--- a/modules/evapi/evapi_dispatch.h
+++ b/modules/evapi/evapi_dispatch.h
@@ -48,6 +48,6 @@ int pv_set_evapi(sip_msg_t *msg, pv_param_t *param, int op,
#define evapi_set_msg_env(_msg, _evenv) do { _msg->date=(hdr_field_t*)_evenv; }
while(0)
#define evapi_get_msg_env(_msg) ((evapi_env_t*)_msg->date)
-int evapi_cfg_close_connection(int cidx);
+int evapi_cfg_close(sip_msg_t *msg);
#endif
diff --git a/modules/evapi/evapi_mod.c b/modules/evapi/evapi_mod.c
index 3cef3ca..94c1fff 100644
--- a/modules/evapi/evapi_mod.c
+++ b/modules/evapi/evapi_mod.c
@@ -55,8 +55,9 @@ static int mod_init(void);
static int child_init(int);
static void mod_destroy(void);
-static int w_evapi_relay(struct sip_msg* msg, char* evdata, char* p2);
-static int w_evapi_async_relay(struct sip_msg* msg, char* evdata, char* p2);
+static int w_evapi_relay(sip_msg_t* msg, char* evdata, char* p2);
+static int w_evapi_async_relay(sip_msg_t* msg, char* evdata, char* p2);
+static int w_evapi_close(sip_msg_t* msg, char* p1, char* p2);
static int fixup_evapi_relay(void** param, int param_no);
static cmd_export_t cmds[]={
@@ -64,6 +65,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE},
{"evapi_async_relay", (cmd_function)w_evapi_async_relay, 1,
fixup_evapi_relay,
0, REQUEST_ROUTE},
+ {"evapi_close", (cmd_function)w_evapi_close, 1, NULL,
+ 0, ANY_ROUTE},
{0, 0, 0, 0, 0, 0}
};
@@ -291,7 +294,22 @@ static int w_evapi_async_relay(sip_msg_t *msg, char *evdata, char
*p2)
return 1;
}
+/**
+ *
+ */
static int fixup_evapi_relay(void** param, int param_no)
{
return fixup_spve_null(param, param_no);
}
+
+/**
+ *
+ */
+static int w_evapi_close(sip_msg_t* msg, char* p1, char* p2)
+{
+ int ret;
+ ret = evapi_cfg_close(msg);
+ if(ret>=0)
+ return ret+1;
+ return ret;
+}