Module: sip-router Branch: master Commit: 242bbdd184426c7cde9f77ab74a5b8c03690687a URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=242bbdd1...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Thu Mar 1 17:56:03 2012 +0000
modules_k/tmx: Added C API to enable other modules to bind to tmx
- Exported t_suspend() for use in app_lua
---
modules_k/tmx/api.h | 28 ++++++++++++++++++++++++++++ modules_k/tmx/tmx_mod.c | 14 ++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/modules_k/tmx/api.h b/modules_k/tmx/api.h new file mode 100644 index 0000000..83c38f6 --- /dev/null +++ b/modules_k/tmx/api.h @@ -0,0 +1,28 @@ +#ifndef _TMX_API_H_ +#define _TMX_API_H_ + +typedef int (*tmx_t_suspend_f)(struct sip_msg*, char*, char*); +typedef struct tmx_api { + tmx_t_suspend_f t_suspend; +} tmx_api_t; + +typedef int (*bind_tmx_f)(tmx_api_t* api); + +static inline int load_tmx_api(tmx_api_t *api) +{ + bind_tmx_f bindtmx; + + bindtmx = (bind_tmx_f)find_export("bind_tmx", 1, 0); + if(bindtmx == 0) { + LM_ERR("cannot find bind_tmx\n"); + return -1; + } + if(bindtmx(api)<0) + { + LM_ERR("cannot bind tmx api\n"); + return -1; + } + return 0; +} + +#endif diff --git a/modules_k/tmx/tmx_mod.c b/modules_k/tmx/tmx_mod.c index ba19538..22d86b3 100644 --- a/modules_k/tmx/tmx_mod.c +++ b/modules_k/tmx/tmx_mod.c @@ -33,6 +33,7 @@
#include "t_var.h" #include "t_mi.h" +#include "api.h"
MODULE_VERSION
@@ -63,6 +64,8 @@ static int w_t_suspend(struct sip_msg* msg, char*, char*); static int w_t_continue(struct sip_msg* msg, char *idx, char *lbl, char *rtn); static int fixup_t_continue(void** param, int param_no);
+static int bind_tmx(tmx_api_t* api); + /* statistic variables */ stat_var *tm_rcv_rpls; stat_var *tm_rld_rpls; @@ -158,6 +161,8 @@ static cmd_export_t cmds[]={ 0, ANY_ROUTE }, {"t_continue", (cmd_function)w_t_continue, 3, fixup_t_continue, 0, ANY_ROUTE }, + {"bind_tmx", (cmd_function)bind_tmx, 1, + 0, 0, ANY_ROUTE }, {0,0,0,0,0,0} };
@@ -559,6 +564,15 @@ static int fixup_t_continue(void** param, int param_no) return 0; }
+static int bind_tmx(tmx_api_t* api) +{ + if (!api) + return -1; + + api->t_suspend = w_t_suspend; + return 0; +} + #ifdef STATISTICS
/*** tm stats ***/