Module: kamailio Branch: master Commit: a6fc13d6f353e81420277a6caa85861d6db97304 URL: https://github.com/kamailio/kamailio/commit/a6fc13d6f353e81420277a6caa85861d...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2016-04-14T13:15:15+02:00
core: kemi - implementation of a drop() alternative
- it doesn't stop the embedded interpreter, but it can trigger the drop() effects (e.g., dropping a branch)
---
Modified: kemi.c Modified: kemi.h
---
Diff: https://github.com/kamailio/kamailio/commit/a6fc13d6f353e81420277a6caa85861d... Patch: https://github.com/kamailio/kamailio/commit/a6fc13d6f353e81420277a6caa85861d...
---
diff --git a/kemi.c b/kemi.c index 0fb8662..1616c3d 100644 --- a/kemi.c +++ b/kemi.c @@ -67,6 +67,27 @@ sr_kemi_module_t* sr_kemi_modules_get(void) /** * */ +static run_act_ctx_t *_sr_kemi_act_ctx = NULL; + +/** + * + */ +void sr_kemi_act_ctx_set(run_act_ctx_t *ctx) +{ + _sr_kemi_act_ctx = ctx; +} + +/** + * + */ +run_act_ctx_t* sr_kemi_act_ctx_get(void) +{ + return _sr_kemi_act_ctx; +} + +/** + * + */ static int lua_sr_kemi_dbg(sip_msg_t *msg, str *txt) { if(txt!=NULL && txt->s!=NULL) @@ -97,6 +118,17 @@ static int lua_sr_kemi_info(sip_msg_t *msg, str *txt) /** * */ +static int lua_sr_kemi_drop(sip_msg_t *msg) +{ + if(_sr_kemi_act_ctx==NULL) + return 0; + _sr_kemi_act_ctx->run_flags |= EXIT_R_F|DROP_R_F; + return 0; +} + +/** + * + */ static sr_kemi_t _sr_kemi_core[] = { { str_init(""), str_init("dbg"), SR_KEMIP_NONE, lua_sr_kemi_dbg, @@ -113,6 +145,11 @@ static sr_kemi_t _sr_kemi_core[] = { { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, + { str_init(""), str_init("drop"), + SR_KEMIP_NONE, lua_sr_kemi_drop, + { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } }; diff --git a/kemi.h b/kemi.h index ede9456..3c9e0e1 100644 --- a/kemi.h +++ b/kemi.h @@ -24,6 +24,7 @@
#include "str.h" #include "parser/msg_parser.h" +#include "action.h"
#define SR_KEMIP_NONE (0) /* no type */ #define SR_KEMIP_INT (1<<0) /* type integer */ @@ -107,4 +108,7 @@ int sr_kemi_cbname_list_init(void); int sr_kemi_cbname_lookup_name(str *name); str* sr_kemi_cbname_lookup_idx(int idx);
+void sr_kemi_act_ctx_set(run_act_ctx_t *ctx); +run_act_ctx_t* sr_kemi_act_ctx_get(void); + #endif