Module: kamailio Branch: master Commit: cc0b27a26081a0716edcea03d86ff63296b1fdab URL: https://github.com/kamailio/kamailio/commit/cc0b27a26081a0716edcea03d86ff632...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-08-28T20:55:39+02:00
sl: added kemi callbacks for event routes
- new parameters * event_callback_fl_ack - name of callback function for filtered-ack * event_callback_lres_sent - name of callback function for local-response
---
Modified: src/modules/sl/sl.c Modified: src/modules/sl/sl_funcs.c
---
Diff: https://github.com/kamailio/kamailio/commit/cc0b27a26081a0716edcea03d86ff632... Patch: https://github.com/kamailio/kamailio/commit/cc0b27a26081a0716edcea03d86ff632...
---
diff --git a/src/modules/sl/sl.c b/src/modules/sl/sl.c index 10361b12e1..930a576b78 100644 --- a/src/modules/sl/sl.c +++ b/src/modules/sl/sl.c @@ -66,6 +66,9 @@ static str default_reason = STR_STATIC_INIT("Internal Server Error"); static int sl_bind_tm = 1; static struct tm_binds tmb;
+str _sl_event_callback_fl_ack = STR_NULL; +str _sl_event_callback_lres_sent = STR_NULL; + static int w_sl_send_reply(struct sip_msg* msg, char* str1, char* str2); static int w_send_reply(struct sip_msg* msg, char* str1, char* str2); static int w_sl_reply_error(struct sip_msg* msg, char* str1, char* str2); @@ -117,6 +120,8 @@ static param_export_t params[] = { {"default_reason", PARAM_STR, &default_reason}, {"bind_tm", PARAM_INT, &sl_bind_tm}, {"rich_redirect", PARAM_INT, &sl_rich_redirect}, + {"event_callback_fl_ack", PARAM_STR, &_sl_event_callback_fl_ack}, + {"event_callback_lres_sent", PARAM_STR, &_sl_event_callback_lres_sent},
{0, 0, 0} }; diff --git a/src/modules/sl/sl_funcs.c b/src/modules/sl/sl_funcs.c index 7cdce0cda2..83cf15bb5d 100644 --- a/src/modules/sl/sl_funcs.c +++ b/src/modules/sl/sl_funcs.c @@ -37,6 +37,7 @@ #include "../../core/route.h" #include "../../core/receive.h" #include "../../core/onsend.h" +#include "../../core/kemi.h" #include "sl_stats.h" #include "sl_funcs.h" #include "sl.h" @@ -58,6 +59,9 @@ static int _sl_evrt_local_response = -1; /* default disabled */ /* send path and flags in 3xx class reply */ int sl_rich_redirect = 0;
+extern str _sl_event_callback_fl_ack; +extern str _sl_event_callback_lres_sent; + /*! * lookup sl event routes */ @@ -131,6 +135,9 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
int backup_rt; struct run_act_ctx ctx; + run_act_ctx_t *bctx; + sr_kemi_eng_t *keng = NULL; + str evname = str_init("sl:local-response"); struct sip_msg pmsg;
if (msg->first_line.u.request.method_value==METHOD_ACK) @@ -206,7 +213,8 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag) ret = msg_send(&dst, buf.s, buf.len); mhomed=backup_mhomed;
- if (unlikely(_sl_evrt_local_response >= 0)) + keng = sr_kemi_eng_get(); + if (_sl_evrt_local_response >= 0 || keng!=NULL) { if (likely(build_sip_msg_from_buf(&pmsg, buf.s, buf.len, inc_msg_no()) == 0)) @@ -279,7 +287,16 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag) backup_rt = get_route_type(); set_route_type(LOCAL_ROUTE); init_run_actions_ctx(&ctx); - run_top_route(event_rt.rlist[_sl_evrt_local_response], &pmsg, 0); + + if(_sl_evrt_local_response>=0) { + run_top_route(event_rt.rlist[_sl_evrt_local_response], &pmsg, 0); + } else if (keng!=NULL) { + bctx = sr_kemi_act_ctx_get(); + sr_kemi_act_ctx_set(&ctx); + sr_kemi_route(keng, msg, EVENT_ROUTE, + &_sl_event_callback_lres_sent, &evname); + sr_kemi_act_ctx_set(bctx); + } set_route_type(backup_rt); p_onsend=0;
@@ -390,6 +407,10 @@ int sl_reply_error(struct sip_msg *msg ) int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar ) { str *tag_str; + run_act_ctx_t ctx; + run_act_ctx_t *bctx; + sr_kemi_eng_t *keng = NULL; + str evname = str_init("sl:filtered-ack");
if (msg->first_line.u.request.method_value!=METHOD_ACK) goto pass_it; @@ -419,9 +440,17 @@ int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar ) LM_DBG("SL local ACK found -> dropping it!\n" ); update_sl_filtered_acks(); sl_run_callbacks(SLCB_ACK_FILTERED, msg, 0, 0, 0, 0); + keng = sr_kemi_eng_get(); if(unlikely(_sl_filtered_ack_route>=0)) { run_top_route(event_rt.rlist[_sl_filtered_ack_route], msg, 0); + } else if(keng!=NULL) { + init_run_actions_ctx(&ctx); + bctx = sr_kemi_act_ctx_get(); + sr_kemi_act_ctx_set(&ctx); + sr_kemi_route(keng, msg, EVENT_ROUTE, + &_sl_event_callback_fl_ack, &evname); + sr_kemi_act_ctx_set(bctx); } return 0; }