Module: kamailio
Branch: master
Commit: cfb20d3ca3bc87199664b34754b15526d49bbff7
URL:
https://github.com/kamailio/kamailio/commit/cfb20d3ca3bc87199664b34754b1552…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-11-22T11:16:18+01:00
core: added event_route[core:modinit-before]
- executed by core once before the module-init callbacks are run
---
Modified: src/core/events.c
Modified: src/core/events.h
Modified: src/main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/cfb20d3ca3bc87199664b34754b1552…
Patch:
https://github.com/kamailio/kamailio/commit/cfb20d3ca3bc87199664b34754b1552…
---
diff --git a/src/core/events.c b/src/core/events.c
index 6f108914ba1..4274bce58e0 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -26,6 +26,7 @@
#include "dprint.h"
#include "mem/mem.h"
#include "route.h"
+#include "fmsg.h"
#include "events.h"
static sr_event_cb_t _sr_events_list;
@@ -77,6 +78,36 @@ void sr_core_ert_run(sip_msg_t *msg, int e)
}
}
+/**
+ *
+ */
+int sr_core_ert_run_xname(char *evname)
+{
+ struct run_act_ctx ctx;
+ int rtb;
+ int ridx;
+ sip_msg_t *fmsg;
+
+ fmsg = faked_msg_get_next_clear();
+ if(fmsg == NULL) {
+ LM_ERR("cannot create a fake message\n");
+ return -1;
+ }
+ ridx = route_lookup(&event_rt, evname);
+ if(ridx <= 0 || event_rt.rlist[ridx] == NULL) {
+ LM_DBG("event_route[%s] not defined - skipping\n", evname);
+ return 0;
+ }
+
+ rtb = get_route_type();
+ set_route_type(REQUEST_ROUTE);
+ init_run_actions_ctx(&ctx);
+ run_top_route(event_rt.rlist[ridx], fmsg, &ctx);
+ set_route_type(rtb);
+
+ return 0;
+}
+
/**
*
*/
diff --git a/src/core/events.h b/src/core/events.h
index 083acdcec81..cf1ec91d554 100644
--- a/src/core/events.h
+++ b/src/core/events.h
@@ -89,6 +89,7 @@ int sr_event_enabled(int type);
void sr_core_ert_init(void);
void sr_core_ert_run(sip_msg_t *msg, int e);
+int sr_core_ert_run_xname(char *evname);
typedef void (*sr_corecb_void_f)(void);
typedef struct sr_corecb
diff --git a/src/main.c b/src/main.c
index 1b9e599fe5c..6aacc523db8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3333,6 +3333,8 @@ int main(int argc, char **argv)
#endif /* USE_TLS */
#endif /* USE_TCP */
+ sr_core_ert_run_xname("core:modinit-before");
+
if(init_modules() != 0) {
fprintf(stderr, "ERROR: error while initializing modules\n");
goto error;