From d05d9ed21ba40822fb236a8031dcca578217cccf Mon Sep 17 00:00:00 2001 From: Alexandra Titoc Date: Mon, 9 Sep 2024 14:37:31 +0300 Subject: [PATCH] evi: Remove event_route module and integrate its functionality in core file --- {modules/event_route => evi}/event_route.c | 290 +++++++++--------- {modules/event_route => evi}/event_route.h | 41 ++- evi/evi_core.c | 47 +++ modules/event_route/Makefile | 10 - modules/event_route/README | 240 --------------- modules/event_route/doc/contributors.xml | 196 ------------ modules/event_route/doc/event_route.xml | 30 -- modules/event_route/doc/event_route_admin.xml | 137 --------- modules/event_route/doc/event_route_faq.xml | 80 ----- modules/event_route/route_send.c | 167 ---------- modules/event_route/route_send.h | 42 --- route.c | 16 +- sr_module.c | 3 +- 13 files changed, 230 insertions(+), 1069 deletions(-) rename {modules/event_route => evi}/event_route.c (58%) rename {modules/event_route => evi}/event_route.h (50%) delete mode 100644 modules/event_route/Makefile delete mode 100644 modules/event_route/README delete mode 100644 modules/event_route/doc/contributors.xml delete mode 100644 modules/event_route/doc/event_route.xml delete mode 100644 modules/event_route/doc/event_route_admin.xml delete mode 100644 modules/event_route/doc/event_route_faq.xml delete mode 100644 modules/event_route/route_send.c delete mode 100644 modules/event_route/route_send.h diff --git a/modules/event_route/event_route.c b/evi/event_route.c similarity index 58% rename from modules/event_route/event_route.c rename to evi/event_route.c index b79e519f752..73f6866775b 100644 --- a/modules/event_route/event_route.c +++ b/evi/event_route.c @@ -23,161 +23,21 @@ * 2012-12-xx created (razvancrainea) */ -#include "../../sr_module.h" -#include "../../evi/evi_transport.h" -#include "../../evi/evi_modules.h" -#include "../../ut.h" +#include "evi_modules.h" +#include "../ut.h" #include "event_route.h" -#include "route_send.h" #include #include #include +#include "../ipc.h" -/* default PVAR names */ - -/** - * module functions - */ -static int mod_init(void); -static int child_init(int rank); -/** - * exported functions - */ -static evi_reply_sock* scriptroute_parse(str socket); -static void scriptroute_free(evi_reply_sock *sock); -static int scriptroute_raise(struct sip_msg *msg, str* ev_name, - evi_reply_sock *sock, evi_params_t *params, evi_async_ctx_t *async_ctx); -static int scriptroute_match(evi_reply_sock *sock1, evi_reply_sock *sock2); -static str scriptroute_print(evi_reply_sock *sock); +/* default PVAR names */ #define SR_SOCK_ROUTE(_s) ((struct script_route_ref *)(_s->params)) -/** - * * module process - * */ -static const proc_export_t procs[] = { - {0,0,0,0,0,0} -}; -/** - * module exported functions - */ -static const cmd_export_t cmds[]={ - {0,0,{{0,0,0}},0} -}; - -/** - * module exports - */ -struct module_exports exports= { - "event_route", /* module name */ - MOD_TYPE_DEFAULT,/* class of this module */ - MODULE_VERSION, - DEFAULT_DLFLAGS, /* dlopen flags */ - 0, /* load function */ - NULL, /* OpenSIPS module dependencies */ - cmds, /* exported functions */ - 0, /* exported async functions */ - 0, /* exported parameters */ - 0, /* exported statistics */ - 0, /* exported MI functions */ - 0, /* exported pseudo-variables */ - 0, /* exported transformations */ - procs, /* extra processes */ - 0, /* module pre-initialization function */ - mod_init, /* module initialization function */ - 0, /* response handling function */ - 0, /* destroy function */ - child_init, /* per-child init function */ - 0 /* reload confirm function */ -}; - - -/** - * exported functions for core event interface - */ -static const evi_export_t trans_export_scriptroute = { - SCRIPTROUTE_NAME_STR, /* transport module name */ - scriptroute_raise, /* raise function */ - scriptroute_parse, /* parse function */ - scriptroute_match, /* sockets match function */ - scriptroute_free, /* no free function */ - scriptroute_print, /* socket print function */ - SCRIPTROUTE_FLAG /* flags */ -}; - -/** - * init module function - */ -static int mod_init(void) -{ - LM_NOTICE("initializing module ...\n"); - - if (register_event_mod(&trans_export_scriptroute)) { - LM_ERR("cannot register transport functions for SCRIPTROUTE\n"); - return -1; - } - - return 0; -} - - -static int child_init(int rank) -{ - char buffer[EV_SCRIPTROUTE_MAX_SOCK]; - str sock_name; - str event_name; - int idx; - - /* - * Only the first process registers the subscribers - * - * We do this in child init because here we are sure that all - * the events were subscribed - */ - if (rank != 1) - return 0; - - /* init the socket buffer */ - sock_name.s = buffer; - memcpy(buffer, SCRIPTROUTE_NAME, sizeof(SCRIPTROUTE_NAME) - 1); - buffer[sizeof(SCRIPTROUTE_NAME) - 1] = COLON_C; - - /* subscribe the route events - idx starts at 1 */ - for (idx = 1; sroutes->event[idx].a && sroutes->event[idx].name; idx++) { - /* build the socket */ - event_name.s = sroutes->event[idx].name; - event_name.len = strlen(sroutes->event[idx].name); - - /* first check if the event exists */ - if (evi_get_id(&event_name) == EVI_ERROR) { - LM_ERR("Event %s not registered\n", event_name.s); - return -1; - } - LM_DBG("Registering event %s\n", sroutes->event[idx].name); - - if (sizeof(SCRIPTROUTE_NAME)+event_name.len > EV_SCRIPTROUTE_MAX_SOCK) { - LM_ERR("socket name too big %d (max: %d)\n", - (int)(sizeof(SCRIPTROUTE_NAME) + event_name.len), - EV_SCRIPTROUTE_MAX_SOCK); - return -1; - } - memcpy(buffer + sizeof(SCRIPTROUTE_NAME), event_name.s, event_name.len); - sock_name.len = event_name.len + sizeof(SCRIPTROUTE_NAME); - - /* register the subscriber - does not expire */ - if (evi_event_subscribe(event_name, sock_name, 0, 0) < 0) { - LM_ERR("cannot subscribe to event %s\n", event_name.s); - return -1; - } - } - - return 0; -} - - /* returns 0 if sockets match */ -static int scriptroute_match(evi_reply_sock *sock1, evi_reply_sock *sock2) +int scriptroute_match(evi_reply_sock *sock1, evi_reply_sock *sock2) { if (!sock1 || !sock2) return 0; @@ -188,7 +48,7 @@ static int scriptroute_match(evi_reply_sock *sock1, evi_reply_sock *sock2) } -static evi_reply_sock* scriptroute_parse(str socket) +evi_reply_sock* scriptroute_parse(str socket) { evi_reply_sock *sock = NULL; struct script_route_ref *ref; @@ -231,14 +91,14 @@ static evi_reply_sock* scriptroute_parse(str socket) return sock; } -static void scriptroute_free(evi_reply_sock *sock) +void scriptroute_free(evi_reply_sock *sock) { /* free the script route reference */ if (sock && sock->params) shm_free(sock->params); } -static str scriptroute_print(evi_reply_sock *sock) +str scriptroute_print(evi_reply_sock *sock) { /* return only the route's name */ return sock->address; @@ -348,7 +208,7 @@ void route_run(struct script_route route, struct sip_msg* msg, route_params_pop_level(); } -static int scriptroute_raise(struct sip_msg *msg, str* ev_name, +int scriptroute_raise(struct sip_msg *msg, str* ev_name, evi_reply_sock *sock, evi_params_t *params, evi_async_ctx_t *async_ctx) { route_send_t *buf = NULL; @@ -378,3 +238,135 @@ static int scriptroute_raise(struct sip_msg *msg, str* ev_name, return 0; } + +#define IS_ERR(_err) (errno == _err) + +int route_build_buffer(str *event_name, evi_reply_sock *sock, + evi_params_t *params, route_send_t **msg) +{ + struct { + route_send_t rt; + evi_param_t eps[0]; + } *buf; + evi_param_p param, buf_param; + int len, params_len=0; + unsigned int param_no = 0; + char *s; + + len = sizeof(*buf) + event_name->len; + if (params) { + for (param = params->first; param; param = param->next) { + if (param->flags & EVI_INT_VAL) { + param_no++; + params_len += param->name.len; + } else if (param->flags & EVI_STR_VAL) { + param_no++; + params_len += param->name.len + param->val.s.len; + } else { + LM_DBG("FIXME: handle param=[%p] name=[%.*s] flags=%X\n", + param, param->name.len, param->name.s, param->flags); + } + } + } + + len += param_no*sizeof(evi_param_t) + params_len; + buf = shm_malloc(len); + if (!buf) { + LM_ERR("oom\n"); + return -1; + } + memset(buf, 0, len); + + /* Stick the event name at the end */ + buf->rt.event.s = (char*)(buf) + len - event_name->len; + buf->rt.event.len = event_name->len; + memcpy(buf->rt.event.s, event_name->s, event_name->len); + + if (params && param_no) { + buf_param = &buf->eps[0]; + buf->rt.params.first = buf_param; + s = (char*)(&buf->eps[param_no]); + for (param = params->first; param; param = param->next) { + if (param->flags & EVI_INT_VAL) { + buf_param->flags = EVI_INT_VAL; + memcpy(s, param->name.s, param->name.len); + buf_param->name.s = s; + buf_param->name.len = param->name.len; + s += param->name.len; + buf_param->val.n = param->val.n; + buf_param->next = buf_param + 1; + buf_param++; + } else if (param->flags & EVI_STR_VAL) { + buf_param->flags = EVI_STR_VAL; + memcpy(s, param->name.s, param->name.len); + buf_param->name.s = s; + buf_param->name.len = param->name.len; + s += param->name.len; + memcpy(s, param->val.s.s, param->val.s.len); + buf_param->val.s.s = s; + buf_param->val.s.len = param->val.s.len; + s += param->val.s.len; + buf_param->next = buf_param + 1; + buf_param++; + } else { + LM_DBG("FIXME: handle param=[%p] name=[%.*s] flags=%X\n", + param, param->name.len, param->name.s, param->flags); + } + } + buf_param--; + buf_param->next = NULL; + buf->rt.params.last = buf_param; + } + + *msg = &buf->rt; + return 0; +} + +#if 0 +void route_params_push_level(void *params, void *extra, param_getf_t getf); +void route_params_pop_level(void); +int route_params_run(struct sip_msg *msg, pv_param_t *ip, pv_value_t *res); +#endif + +static void route_received(int sender, void *param) +{ + struct sip_msg* req; + route_send_t *route_s = (route_send_t *)param; + + /* suppress the E_CORE_LOG event for new logs while handling + * the event itself */ + suppress_proc_log_event(); + + if (!ref_script_route_check_and_update(route_s->ev_route)){ + LM_ERR("event route [%.s] no longer available in script\n", + route_s->ev_route->name.s); + goto cleanup; + } + + req = get_dummy_sip_msg(); + if(req == NULL) { + LM_ERR("cannot create new dummy sip request\n"); + goto cleanup; + } + + route_run(sroutes->event[route_s->ev_route->idx], req, + &route_s->params, &route_s->event); + + release_dummy_sip_msg(req); + + /* remove all added AVP - here we use all the time the default AVP list */ + reset_avps( ); + +cleanup: + if (route_s->ev_route) + shm_free(route_s->ev_route); + shm_free(route_s); + + reset_proc_log_event(); +} + + +int route_send(route_send_t *route_s) +{ + return ipc_dispatch_rpc( route_received, (void *)route_s); +} diff --git a/modules/event_route/event_route.h b/evi/event_route.h similarity index 50% rename from modules/event_route/event_route.h rename to evi/event_route.h index b395b039a43..32e4fe64d11 100644 --- a/modules/event_route/event_route.h +++ b/evi/event_route.h @@ -23,10 +23,10 @@ * 2012-12-xx created (razvancrainea) */ - #ifndef _EV_ROUTE_H_ #define _EV_ROUTE_H_ +#define ROUTE_SEND_RETRY 3 /* transport protocol name */ #define SCRIPTROUTE_NAME "route" @@ -41,4 +41,41 @@ /* maximum length of the socket */ #define EV_SCRIPTROUTE_MAX_SOCK 256 -#endif + +#include "../sr_module.h" +#include "evi_transport.h" + +evi_reply_sock* scriptroute_parse(str socket); +void scriptroute_free(evi_reply_sock *sock); +int scriptroute_raise(struct sip_msg *msg, str* ev_name, + evi_reply_sock *sock, evi_params_t *params, evi_async_ctx_t *async_ctx); +int scriptroute_match(evi_reply_sock *sock1, evi_reply_sock *sock2); +str scriptroute_print(evi_reply_sock *sock); + +/** + * exported functions for core event interface + */ +static const evi_export_t trans_export_scriptroute = { + SCRIPTROUTE_NAME_STR, /* transport module name */ + scriptroute_raise, /* raise function */ + scriptroute_parse, /* parse function */ + scriptroute_match, /* sockets match function */ + scriptroute_free, /* no free function */ + scriptroute_print, /* socket print function */ + SCRIPTROUTE_FLAG /* flags */ +}; + +typedef struct _route_send { + struct script_route_ref *ev_route; + str event; + evi_params_t params; +} route_send_t; + +int route_build_buffer(str *event_name, evi_reply_sock *sock, + evi_params_t *params, route_send_t **msg); + +int route_send(route_send_t *route_s); +void route_run(struct script_route route, struct sip_msg* msg, + evi_params_t *params, str *event); + +#endif \ No newline at end of file diff --git a/evi/evi_core.c b/evi/evi_core.c index bab3fb8c02e..909de2dbbcc 100644 --- a/evi/evi_core.c +++ b/evi/evi_core.c @@ -26,6 +26,8 @@ #include "evi_modules.h" #include "evi_core.h" #include "../ut.h" +#include "evi_transport.h" +#include "event_route.h" /* static events exported by the core */ static str evi_core_table[] = { @@ -42,11 +44,56 @@ static str evi_core_table[] = { int evi_register_core(void) { + char buffer[EV_SCRIPTROUTE_MAX_SOCK]; + str sock_name; + str event_name; + int idx; + int i, size = sizeof(evi_core_table) / sizeof(str); for (i = 0; i < size; i++) { if (EVI_ERROR == evi_publish_event(evi_core_table[i])) + + return -1; + } + + if (register_event_mod(&trans_export_scriptroute)) { + LM_ERR("cannot register transport functions for SCRIPTROUTE\n"); + return -1; + } + + /* init the socket buffer */ + sock_name.s = buffer; + memcpy(buffer, SCRIPTROUTE_NAME, sizeof(SCRIPTROUTE_NAME) - 1); + buffer[sizeof(SCRIPTROUTE_NAME) - 1] = COLON_C; + + /* subscribe the route events - idx starts at 1 */ + for (idx = 1; sroutes->event[idx].a && sroutes->event[idx].name; idx++) { + /* build the socket */ + event_name.s = sroutes->event[idx].name; + event_name.len = strlen(sroutes->event[idx].name); + + /* first check if the event exists */ + if (evi_get_id(&event_name)<=EVI_ERROR && evi_publish_event(event_name)<=EVI_ERROR) { + LM_ERR("Event %s not registered\n", event_name.s); + return -1; + } + LM_DBG("Registering event %s\n", sroutes->event[idx].name); + + if (sizeof(SCRIPTROUTE_NAME)+event_name.len > EV_SCRIPTROUTE_MAX_SOCK) { + LM_ERR("socket name too big %d (max: %d)\n", + (int)(sizeof(SCRIPTROUTE_NAME) + event_name.len), + EV_SCRIPTROUTE_MAX_SOCK); + return -1; + } + memcpy(buffer + sizeof(SCRIPTROUTE_NAME), event_name.s, event_name.len); + sock_name.len = event_name.len + sizeof(SCRIPTROUTE_NAME); + + /* register the subscriber - does not expire */ + if (evi_event_subscribe(event_name, sock_name, 0, 0) < 0) { + LM_ERR("cannot subscribe to event %s\n", event_name.s); return -1; + } } return 0; } diff --git a/modules/event_route/Makefile b/modules/event_route/Makefile deleted file mode 100644 index 89cfd7cc525..00000000000 --- a/modules/event_route/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $Id: Makefile 5901 2009-07-21 07:45:05Z bogdan_iancu $ -# -# WARNING: do not run this directly, it should be run by the master Makefile - -include ../../Makefile.defs -auto_gen= -NAME=event_route.so - -include ../../Makefile.modules - diff --git a/modules/event_route/README b/modules/event_route/README deleted file mode 100644 index c933447e7d5..00000000000 --- a/modules/event_route/README +++ /dev/null @@ -1,240 +0,0 @@ -event_route Module - __________________________________________________________ - - Table of Contents - - 1. Admin Guide - - 1.1. Overview - 1.2. ROUTE events parameters - 1.3. EVENT_ROUTE usage - 1.4. EVENT_ROUTE socket syntax - 1.5. Dependencies - - 1.5.1. OpenSIPS Modules - 1.5.2. External Libraries or Applications - - 1.6. Exported Parameters - 1.7. Exported Functions - - 2. Frequently Asked Questions - 3. Contributors - - 3.1. By Commit Statistics - 3.2. By Commit Activity - - 4. Documentation - - 4.1. Contributors - - List of Tables - - 3.1. Top contributors by DevScore^(1), authored commits^(2) and - lines added/removed^(3) - - 3.2. Most recently active contributors^(1) to this module - - List of Examples - - 1.1. EVENT_ROUTE usage - -Chapter 1. Admin Guide - -1.1. Overview - - This module provides a simple way for capturing and handling - directly in the OpenSIPS script of different events triggered - through the OpenSIPS Event Interface - - If you want to capture and handle a certian event, you need to - define a dedicated route (event_route) into the OpenSIPS - script, route having as name the name/code of the desired - event. The route is triggered (and executed) by the module when - the corresponding event is raised by the OpenSIPS - - NOTE that the triggered event_route is run asyncronus (and in a - different process) in regards to the code or process that - generated the actual event. - - NOTE that inside the event_route you should NOT rely on - anything more than the content provide by the event itself (see - below variable). DO NOT assume to have access to any other - variable or context, not even to a SIP message. - -1.2. ROUTE events parameters - - In order to retrieve the parameters of an event, the - $param(name) variable has to be used. It's name can be the - parameter's name, or, if an integer is specified, its index - inside the parameter's list. - - Example: -xlog("first parameters is $param(1)\n"); -xlog("Pike Blocking IP is $param(ip)\n"); - - NOTE: An event may be triggered within a different event, - leading to nested processing. This function will retrieve the - parameters of the currently processed event. - - The event name can contain any non-quoted string character, but - it is recommended to follow the syntax: - E_MODULE_NAME_EXTRA_NAME - -1.3. EVENT_ROUTE usage - - In order to handle the E_PIKE_BLOCKED event, the following - snippet can be used: - - Example 1.1. EVENT_ROUTE usage - event_route[E_PIKE_BLOCKED] { - xlog("IP $param(ip) has been blocked\n"); - } - -1.4. EVENT_ROUTE socket syntax - - As the OpenSIPS Event Interface requires, the event_route - module uses a specific socket syntax: - - 'route:' event_name - - Example: - - route:E_PIKE_BLOCKED - -1.5. Dependencies - -1.5.1. OpenSIPS Modules - - The following modules must be loaded before this module: - * No dependencies on other OpenSIPS modules. - -1.5.2. External Libraries or Applications - - The following libraries or applications must be installed - before running OpenSIPS with this module loaded: - * none - -1.6. Exported Parameters - - The module does not export parameters to be used in - configuration script. - -1.7. Exported Functions - - The function does not export any function. - -Chapter 2. Frequently Asked Questions - - 2.1. - - Can I declare more routes for handling the same event? - - No, only a single event_route can be used for a particular - event. - - 2.2. - - What happened with the “fetch_event_params()” function? - - This function has been dropped starting with OpenSIPS 3.0. Its - functionality has been replaced by the “$param(name)” variable. - - 2.3. - - Where can I find more about OpenSIPS? - - Take a look at https://opensips.org/. - - 2.4. - - Where can I post a question about this module? - - First at all check if your question was already answered on one - of our mailing lists: - * User Mailing List - - http://lists.opensips.org/cgi-bin/mailman/listinfo/users - * Developer Mailing List - - http://lists.opensips.org/cgi-bin/mailman/listinfo/devel - - E-mails regarding any stable OpenSIPS release should be sent to - and e-mails regarding development - versions should be sent to . - - If you want to keep the mail private, send it to - . - - 2.5. - - How can I report a bug? - - Please follow the guidelines provided at: - https://github.com/OpenSIPS/opensips/issues. - -Chapter 3. Contributors - -3.1. By Commit Statistics - - Table 3.1. Top contributors by DevScore^(1), authored - commits^(2) and lines added/removed^(3) - Name DevScore Commits Lines ++ Lines -- - 1. Razvan Crainea (@razvancrainea) 40 25 993 317 - 2. Bogdan-Andrei Iancu (@bogdan-iancu) 18 9 142 400 - 3. Liviu Chircu (@liviuchircu) 13 11 27 47 - 4. Ionut Ionita (@ionutrazvanionita) 8 5 138 51 - 5. Vlad Patrascu (@rvlad-patrascu) 7 5 14 5 - 6. Ovidiu Sas (@ovidiusas) 7 2 384 9 - 7. Maksym Sobolyev (@sobomax) 5 3 18 16 - 8. Ionel Cerghit (@ionel-cerghit) 3 1 5 6 - 9. Peter Lemenkov (@lemenkov) 3 1 1 1 - 10. Vlad Paiu (@vladpaiu) 2 1 1 0 - - All remaining contributors: Walter Doekes (@wdoekes). - - (1) DevScore = author_commits + author_lines_added / - (project_lines_added / project_commits) + author_lines_deleted - / (project_lines_deleted / project_commits) - - (2) including any documentation-related commits, excluding - merge commits. Regarding imported patches/code, we do our best - to count the work on behalf of the proper owner, as per the - "fix_authors" and "mod_renames" arrays in - opensips/doc/build-contrib.sh. If you identify any - patches/commits which do not get properly attributed to you, - please submit a pull request which extends "fix_authors" and/or - "mod_renames". - - (3) ignoring whitespace edits, renamed files and auto-generated - files - -3.2. By Commit Activity - - Table 3.2. Most recently active contributors^(1) to this module - Name Commit Activity - 1. Razvan Crainea (@razvancrainea) Dec 2012 - Apr 2024 - 2. Vlad Patrascu (@rvlad-patrascu) May 2017 - Jun 2023 - 3. Bogdan-Andrei Iancu (@bogdan-iancu) Oct 2014 - May 2023 - 4. Liviu Chircu (@liviuchircu) Mar 2014 - Mar 2023 - 5. Maksym Sobolyev (@sobomax) Feb 2021 - Feb 2023 - 6. Peter Lemenkov (@lemenkov) Jun 2018 - Jun 2018 - 7. Vlad Paiu (@vladpaiu) Jun 2016 - Jun 2016 - 8. Ionel Cerghit (@ionel-cerghit) Jun 2015 - Jun 2015 - 9. Ionut Ionita (@ionutrazvanionita) Oct 2014 - Oct 2014 - 10. Ovidiu Sas (@ovidiusas) Jul 2014 - Jul 2014 - - All remaining contributors: Walter Doekes (@wdoekes). - - (1) including any documentation-related commits, excluding - merge commits - -Chapter 4. Documentation - -4.1. Contributors - - Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei - Iancu (@bogdan-iancu), Peter Lemenkov (@lemenkov), Liviu Chircu - (@liviuchircu), Ionut Ionita (@ionutrazvanionita), Ovidiu Sas - (@ovidiusas). - - Documentation Copyrights: - - Copyright © 2012 www.opensips-solutions.com diff --git a/modules/event_route/doc/contributors.xml b/modules/event_route/doc/contributors.xml deleted file mode 100644 index ab9f9224fbf..00000000000 --- a/modules/event_route/doc/contributors.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - &contributors; - -
- By Commit Statistics - - Top contributors by DevScore<superscript>(1)</superscript>, authored commits<superscript>(2)</superscript> and lines added/removed<superscript>(3)</superscript> - - - - - Name - DevScore - Commits - Lines ++ - Lines -- - - - - - 1. - Razvan Crainea (@razvancrainea) - 40 - 25 - 993 - 317 - - - 2. - Bogdan-Andrei Iancu (@bogdan-iancu) - 18 - 9 - 142 - 400 - - - 3. - Liviu Chircu (@liviuchircu) - 13 - 11 - 27 - 47 - - - 4. - Ionut Ionita (@ionutrazvanionita) - 8 - 5 - 138 - 51 - - - 5. - Vlad Patrascu (@rvlad-patrascu) - 7 - 5 - 14 - 5 - - - 6. - Ovidiu Sas (@ovidiusas) - 7 - 2 - 384 - 9 - - - 7. - Maksym Sobolyev (@sobomax) - 5 - 3 - 18 - 16 - - - 8. - Ionel Cerghit (@ionel-cerghit) - 3 - 1 - 5 - 6 - - - 9. - Peter Lemenkov (@lemenkov) - 3 - 1 - 1 - 1 - - - 10. - Vlad Paiu (@vladpaiu) - 2 - 1 - 1 - 0 - - - -
-All remaining contributors: Walter Doekes (@wdoekes). - - (1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits) - - - (2) including any documentation-related commits, excluding merge commits. Regarding imported patches/code, we do our best to count the work on behalf of the proper owner, as per the "fix_authors" and "mod_renames" arrays in opensips/doc/build-contrib.sh. If you identify any patches/commits which do not get properly attributed to you, please submit a pull request which extends "fix_authors" and/or "mod_renames". - - - (3) ignoring whitespace edits, renamed files and auto-generated files - -
- -
- By Commit Activity - - Most recently active contributors<superscript>(1)</superscript> to this module - - - - - Name - Commit Activity - - - - - 1. - Razvan Crainea (@razvancrainea) - Dec 2012 - Apr 2024 - - - 2. - Vlad Patrascu (@rvlad-patrascu) - May 2017 - Jun 2023 - - - 3. - Bogdan-Andrei Iancu (@bogdan-iancu) - Oct 2014 - May 2023 - - - 4. - Liviu Chircu (@liviuchircu) - Mar 2014 - Mar 2023 - - - 5. - Maksym Sobolyev (@sobomax) - Feb 2021 - Feb 2023 - - - 6. - Peter Lemenkov (@lemenkov) - Jun 2018 - Jun 2018 - - - 7. - Vlad Paiu (@vladpaiu) - Jun 2016 - Jun 2016 - - - 8. - Ionel Cerghit (@ionel-cerghit) - Jun 2015 - Jun 2015 - - - 9. - Ionut Ionita (@ionutrazvanionita) - Oct 2014 - Oct 2014 - - - 10. - Ovidiu Sas (@ovidiusas) - Jul 2014 - Jul 2014 - - - -
-All remaining contributors: Walter Doekes (@wdoekes). - - (1) including any documentation-related commits, excluding merge commits - -
- -
- - Documentation -
- Contributors - Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Peter Lemenkov (@lemenkov), Liviu Chircu (@liviuchircu), Ionut Ionita (@ionutrazvanionita), Ovidiu Sas (@ovidiusas). -
- -
diff --git a/modules/event_route/doc/event_route.xml b/modules/event_route/doc/event_route.xml deleted file mode 100644 index f54864b43eb..00000000000 --- a/modules/event_route/doc/event_route.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -%docentities; - -]> - - - - event_route Module - &osipsname; - - - - &admin; - &faq; - &contrib; - - &docCopyrights; - ©right; 2012 &osipssol; - - diff --git a/modules/event_route/doc/event_route_admin.xml b/modules/event_route/doc/event_route_admin.xml deleted file mode 100644 index 5c4052c626f..00000000000 --- a/modules/event_route/doc/event_route_admin.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - &adminguide; - -
- Overview - - This module provides a simple way for capturing and handling - directly in the &osips; script of different events triggered through - the &osips; Event Interface - - - If you want to capture and handle a certian event, you need to - define a dedicated route (event_route) into the - &osips; script, route having as name the name/code of the - desired event. The route is triggered (and executed) by - the module when the corresponding event is raised by the &osips; - - - NOTE that the triggered event_route is - run asyncronus (and in a different process) in regards to the code or - process that generated the actual event. - - - NOTE that inside the event_route you should - NOT rely on anything more than the content provide by the event itself - (see below variable). DO NOT assume to have access to any other - variable or context, not even to a SIP message. - - -
- -
- ROUTE events parameters - - - In order to retrieve the parameters of an event, the - $param(name) variable has to be used. It's - name can be the parameter's name, or, if an integer is specified, its - index inside the parameter's list. - - - Example: - -xlog("first parameters is $param(1)\n"); -xlog("Pike Blocking IP is $param(ip)\n"); - - - NOTE: An event may be triggered within a different event, leading - to nested processing. This function will retrieve the parameters of the currently processed - event. - - The event name can contain any non-quoted string character, but - it is recommended to follow the syntax: - E_MODULE_NAME_EXTRA_NAME - -
- -
- EVENT_ROUTE usage - - In order to handle the E_PIKE_BLOCKED event, - the following snippet can be used: - - - - EVENT_ROUTE usage - - event_route[E_PIKE_BLOCKED] { - xlog("IP $param(ip) has been blocked\n"); - } - - - - -
- -
- EVENT_ROUTE socket syntax - - As the &osips; Event Interface requires, the event_route - module uses a specific socket syntax: - 'route:' event_name - - - Example: - - route:E_PIKE_BLOCKED - - -
- -
- Dependencies -
- &osips; Modules - - The following modules must be loaded before this module: - - - - No dependencies on other &osips; modules. - - - - -
-
- External Libraries or Applications - - The following libraries or applications must be installed before - running &osips; with this module loaded: - - - - none - - - - -
-
- -
- Exported Parameters - The module does not export parameters to be used in configuration script. -
- -
- Exported Functions - The function does not export any function. -
- -
- diff --git a/modules/event_route/doc/event_route_faq.xml b/modules/event_route/doc/event_route_faq.xml deleted file mode 100644 index 9d44c69e9d5..00000000000 --- a/modules/event_route/doc/event_route_faq.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - &faqguide; - - - - Can I declare more routes for handling the same event? - - - - No, only a single event_route can be used for a - particular event. - - - - - - What happened with the fetch_event_params() function? - - - - This function has been dropped starting with &osips; 3.0. Its functionality - has been replaced by the $param(name) variable. - - - - - - Where can I find more about OpenSIPS? - - - - Take a look at &osipshomelink;. - - - - - - Where can I post a question about this module? - - - - First at all check if your question was already answered on one of - our mailing lists: - - - - User Mailing List - &osipsuserslink; - - - Developer Mailing List - &osipsdevlink; - - - - E-mails regarding any stable &osips; release should be sent to - &osipsusersmail; and e-mails regarding development versions - should be sent to &osipsdevmail;. - - - If you want to keep the mail private, send it to - &osipshelpmail;. - - - - - - How can I report a bug? - - - - Please follow the guidelines provided at: - &osipsbugslink;. - - - - - - diff --git a/modules/event_route/route_send.c b/modules/event_route/route_send.c deleted file mode 100644 index 8f5b1d314fc..00000000000 --- a/modules/event_route/route_send.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2014 VoIP Embedded, Inc. - * - * This file is part of opensips, a free SIP server. - * - * opensips is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * opensips is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA - */ - -#include -#include -#include -#include - -#include "../../evi/evi_transport.h" -#include "../../mem/mem.h" -#include "../../mem/shm_mem.h" -#include "../../ipc.h" -#include "../../ut.h" -#include "route_send.h" -#include "event_route.h" - -#define IS_ERR(_err) (errno == _err) - -int route_build_buffer(str *event_name, evi_reply_sock *sock, - evi_params_t *params, route_send_t **msg) -{ - struct { - route_send_t rt; - evi_param_t eps[0]; - } *buf; - evi_param_p param, buf_param; - int len, params_len=0; - unsigned int param_no = 0; - char *s; - - len = sizeof(*buf) + event_name->len; - if (params) { - for (param = params->first; param; param = param->next) { - if (param->flags & EVI_INT_VAL) { - param_no++; - params_len += param->name.len; - } else if (param->flags & EVI_STR_VAL) { - param_no++; - params_len += param->name.len + param->val.s.len; - } else { - LM_DBG("FIXME: handle param=[%p] name=[%.*s] flags=%X\n", - param, param->name.len, param->name.s, param->flags); - } - } - } - - len += param_no*sizeof(evi_param_t) + params_len; - buf = shm_malloc(len); - if (!buf) { - LM_ERR("oom\n"); - return -1; - } - memset(buf, 0, len); - - /* Stick the event name at the end */ - buf->rt.event.s = (char*)(buf) + len - event_name->len; - buf->rt.event.len = event_name->len; - memcpy(buf->rt.event.s, event_name->s, event_name->len); - - if (params && param_no) { - buf_param = &buf->eps[0]; - buf->rt.params.first = buf_param; - s = (char*)(&buf->eps[param_no]); - for (param = params->first; param; param = param->next) { - if (param->flags & EVI_INT_VAL) { - buf_param->flags = EVI_INT_VAL; - memcpy(s, param->name.s, param->name.len); - buf_param->name.s = s; - buf_param->name.len = param->name.len; - s += param->name.len; - buf_param->val.n = param->val.n; - buf_param->next = buf_param + 1; - buf_param++; - } else if (param->flags & EVI_STR_VAL) { - buf_param->flags = EVI_STR_VAL; - memcpy(s, param->name.s, param->name.len); - buf_param->name.s = s; - buf_param->name.len = param->name.len; - s += param->name.len; - memcpy(s, param->val.s.s, param->val.s.len); - buf_param->val.s.s = s; - buf_param->val.s.len = param->val.s.len; - s += param->val.s.len; - buf_param->next = buf_param + 1; - buf_param++; - } else { - LM_DBG("FIXME: handle param=[%p] name=[%.*s] flags=%X\n", - param, param->name.len, param->name.s, param->flags); - } - } - buf_param--; - buf_param->next = NULL; - buf->rt.params.last = buf_param; - } - - *msg = &buf->rt; - return 0; -} - -#if 0 -void route_params_push_level(void *params, void *extra, param_getf_t getf); -void route_params_pop_level(void); -int route_params_run(struct sip_msg *msg, pv_param_t *ip, pv_value_t *res); -#endif - -static void route_received(int sender, void *param) -{ - struct sip_msg* req; - route_send_t *route_s = (route_send_t *)param; - - /* suppress the E_CORE_LOG event for new logs while handling - * the event itself */ - suppress_proc_log_event(); - - if (!ref_script_route_check_and_update(route_s->ev_route)){ - LM_ERR("event route [%.s] no longer available in script\n", - route_s->ev_route->name.s); - goto cleanup; - } - - req = get_dummy_sip_msg(); - if(req == NULL) { - LM_ERR("cannot create new dummy sip request\n"); - goto cleanup; - } - - route_run(sroutes->event[route_s->ev_route->idx], req, - &route_s->params, &route_s->event); - - release_dummy_sip_msg(req); - - /* remove all added AVP - here we use all the time the default AVP list */ - reset_avps( ); - -cleanup: - if (route_s->ev_route) - shm_free(route_s->ev_route); - shm_free(route_s); - - reset_proc_log_event(); -} - - -int route_send(route_send_t *route_s) -{ - return ipc_dispatch_rpc( route_received, (void *)route_s); -} - - - diff --git a/modules/event_route/route_send.h b/modules/event_route/route_send.h deleted file mode 100644 index ce3f51c48f8..00000000000 --- a/modules/event_route/route_send.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2014 VoIP Embedded, Inc. - * - * This file is part of opensips, a free SIP server. - * - * opensips is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * opensips is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA - * - */ - - -#ifndef _ROUTE_SEND_H_ -#define _ROUTE_SEND_H_ - - -#define ROUTE_SEND_RETRY 3 - -typedef struct _route_send { - struct script_route_ref *ev_route; - str event; - evi_params_t params; -} route_send_t; - -int route_build_buffer(str *event_name, evi_reply_sock *sock, - evi_params_t *params, route_send_t **msg); - -int route_send(route_send_t *route_s); -void route_run(struct script_route route, struct sip_msg* msg, - evi_params_t *params, str *event); - -#endif diff --git a/route.c b/route.c index 6baa061ffb5..c338d99c2c9 100644 --- a/route.c +++ b/route.c @@ -1633,7 +1633,7 @@ void push(struct action* a, struct action** head) */ int fix_rls(void) { - int i, ret, check_evr = 1; + int i, ret; for(i=0;irequest[i].a){ @@ -1694,20 +1694,6 @@ int fix_rls(void) if(sroutes->event[i].a == NULL) break; - if (check_evr && !module_loaded("event_route")) { - LM_ERR("event_route used but 'event_route' module not loaded!\n"); - return E_CFG; - } - check_evr = 0; - - /* if neither mod_init() nor function fixups have registered - * this event name yet, do it on the spot! */ - init_str(&st, sroutes->event[i].name); - if (evi_get_id(&st)<=EVI_ERROR && evi_publish_event(st)<=EVI_ERROR) { - LM_ERR("failed to publish event %s\n", sroutes->event[i].name); - return E_UNSPEC; - } - if ((ret=fix_actions(sroutes->event[i].a))!=0){ return ret; } diff --git a/sr_module.c b/sr_module.c index 2984a2f12a9..c7437cce8ac 100644 --- a/sr_module.c +++ b/sr_module.c @@ -408,7 +408,8 @@ static struct { char *name; unsigned int flags; } module_warnings[] = { - { "rabbitmq", "'rabbitmq' module has been dropped - please use 'event_rabbitmq' instead!", MOD_WARN_EXIT } + { "rabbitmq", "'rabbitmq' module has been dropped - please use 'event_rabbitmq' instead!", MOD_WARN_EXIT }, + { "event_route", "'event_route' module has been integrated in core file. You no longer need to load the module.", MOD_WARN_SKIP } }; /* returns 0 on success , <0 on error */