Module: kamailio
Branch: master
Commit: 98f05b7b0de4b328a71e1ff5eca175ad690a4888
URL:
https://github.com/kamailio/kamailio/commit/98f05b7b0de4b328a71e1ff5eca175a…
Author: Ivaylo Markov <imarkov(a)zoiper.com>
Committer: Ivaylo Markov <imarkov(a)zoiper.com>
Date: 2018-08-18T18:01:36+03:00
registrar: add event_callback parameter
This allows usage of the `usrloc:contact-expired` event route with
KEMI routing configurations.
---
Modified: src/modules/registrar/registrar.c
Modified: src/modules/registrar/regpv.c
---
Diff:
https://github.com/kamailio/kamailio/commit/98f05b7b0de4b328a71e1ff5eca175a…
Patch:
https://github.com/kamailio/kamailio/commit/98f05b7b0de4b328a71e1ff5eca175a…
---
diff --git a/src/modules/registrar/registrar.c b/src/modules/registrar/registrar.c
index 35ea204e0c..4f6e71a344 100644
--- a/src/modules/registrar/registrar.c
+++ b/src/modules/registrar/registrar.c
@@ -126,6 +126,9 @@ str sock_hdr_name = {0,0};
/* where to go for event route ("usrloc:contact-expired") */
int reg_expire_event_rt = -1; /* default disabled */
+str reg_event_callback = STR_NULL;
+
+sr_kemi_eng_t *keng = NULL;
#define RCV_NAME "received"
str rcv_param = str_init(RCV_NAME);
@@ -228,6 +231,7 @@ static param_export_t params[] = {
{"regid_mode", INT_PARAM, ®_regid_mode },
{"flow_timer", INT_PARAM, ®_flow_timer },
{"contact_max_size", INT_PARAM, &contact_max_size },
+ {"event_callback", PARAM_STR, ®_event_callback },
{0, 0, 0}
};
@@ -339,12 +343,19 @@ static int mod_init(void)
return -1;
}
- if(ul.register_ulcb != NULL)
- {
- reg_expire_event_rt = route_lookup(&event_rt, "usrloc:contact-expired");
- if (reg_expire_event_rt>=0 && event_rt.rlist[reg_expire_event_rt]==0)
- reg_expire_event_rt=-1; /* disable */
- if (reg_expire_event_rt>=0) {
+ if(ul.register_ulcb != NULL) {
+ if (reg_event_callback.s==NULL || reg_event_callback.len<=0 ) {
+ reg_expire_event_rt = route_lookup(&event_rt,
"usrloc:contact-expired");
+ if (reg_expire_event_rt>=0 && event_rt.rlist[reg_expire_event_rt]==0)
+ reg_expire_event_rt=-1; /* disable */
+ } else {
+ keng = sr_kemi_eng_get();
+ if(keng==NULL) {
+ LM_DBG("event callback (%s) set, but no cfg engine\n",
+ reg_event_callback.s);
+ }
+ }
+ if (reg_expire_event_rt>=0 || (reg_event_callback.s!=NULL && keng !=NULL))
{
set_child_rpc_sip_mode();
if(ul.register_ulcb(UL_CONTACT_EXPIRE, reg_ul_expired_contact, 0)< 0)
{
diff --git a/src/modules/registrar/regpv.c b/src/modules/registrar/regpv.c
index b6fad8856f..fdb5fa40fb 100644
--- a/src/modules/registrar/regpv.c
+++ b/src/modules/registrar/regpv.c
@@ -34,11 +34,14 @@
#include "../../core/route.h"
#include "../../core/action.h"
#include "../../core/fmsg.h"
+#include "../../core/kemi.h"
#include "../usrloc/usrloc.h"
#include "registrar.h"
#include "common.h"
#include "regpv.h"
+extern str reg_event_callback;
+
typedef struct _regpv_profile {
str pname;
str domain;
@@ -629,8 +632,9 @@ void reg_ul_expired_contact(ucontact_t* ptr, int type, void* param)
int olen;
int ilen;
char *p;
+ sr_kemi_eng_t *keng = NULL;
- if(reg_expire_event_rt<0)
+ if(reg_expire_event_rt<0 && reg_event_callback.s==NULL)
return;
if (faked_msg_init() < 0)
@@ -733,11 +737,22 @@ void reg_ul_expired_contact(ucontact_t* ptr, int type, void* param)
backup_rt = get_route_type();
set_route_type(REQUEST_ROUTE);
init_run_actions_ctx(&ctx);
- run_top_route(event_rt.rlist[reg_expire_event_rt], fmsg, 0);
+
+ if (reg_expire_event_rt >= 0) {
+ run_top_route(event_rt.rlist[reg_expire_event_rt], fmsg, 0);
+ } else {
+ keng = sr_kemi_eng_get();
+ if (keng!=NULL) {
+ str evname = str_init("usrloc:contact-expired");
+ if(keng->froute(fmsg, EVENT_ROUTE,
+ ®_event_callback, &evname)<0) {
+ LM_ERR("error running event route kemi callback\n");
+ }
+ }
+ }
set_route_type(backup_rt);
return;
error:
regpv_free_profile(rpp);
- return;
-}
+ return; }