Module: kamailio Branch: master Commit: a769c4904be32161a8fde4678c9bd09aa76def49 URL: https://github.com/kamailio/kamailio/commit/a769c4904be32161a8fde4678c9bd09aa76def49
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2025-11-17T13:16:34+01:00 dispatcher: use defined values for event_callback_mode - change the codition for executing event routes to cover the cases --- Modified: src/modules/dispatcher/dispatch.c Modified: src/modules/dispatcher/dispatch.h Modified: src/modules/dispatcher/dispatcher.c --- Diff: https://github.com/kamailio/kamailio/commit/a769c4904be32161a8fde4678c9bd09aa76def49.diff Patch: https://github.com/kamailio/kamailio/commit/a769c4904be32161a8fde4678c9bd09aa76def49.patch --- diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c index 627f1a621d4..5ec4d6b7140 100644 --- a/src/modules/dispatcher/dispatch.c +++ b/src/modules/dispatcher/dispatch.c @@ -3439,6 +3439,8 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, str *iuid, ds_set_t *idx = NULL; str *fmatch; str *vmatch; + int was_down = 0; + int is_down = 0; if(_ds_list == NULL || _ds_list_nr <= 0) { LM_ERR("the list is null\n"); @@ -3530,25 +3532,24 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, str *iuid, } - if((mode & DS_STATE_MODE_FUNC) == 0) { - int was_down = ds_skip_dst(old_state); - int is_down = ds_skip_dst(idx->dlist[i].flags); - - if(ds_event_callback_mode == 0) { - - if(!was_down && is_down) { - ds_run_route(msg, address, "dispatcher:dst-down", rctx); - } else if(was_down && !is_down) { - ds_run_route(msg, address, "dispatcher:dst-up", rctx); - } - } else if(ds_event_callback_mode == 2) { - + if((ds_event_callback_mode == DS_EVRTMODE_RUNTIME) + || (ds_event_callback_mode == DS_EVRTMODE_INIT) + || ((mode & DS_STATE_MODE_FUNC) == 0)) { + was_down = ds_skip_dst(old_state); + is_down = ds_skip_dst(idx->dlist[i].flags); + if(ds_event_callback_mode == DS_EVRTMODE_INIT) { if((!was_down && is_down) || (old_state == 0 && is_down)) { ds_run_route(msg, address, "dispatcher:dst-down", rctx); } else if((was_down && !is_down) || (old_state == 0 && !is_down)) { ds_run_route(msg, address, "dispatcher:dst-up", rctx); } + } else { + if(!was_down && is_down) { + ds_run_route(msg, address, "dispatcher:dst-down", rctx); + } else if(was_down && !is_down) { + ds_run_route(msg, address, "dispatcher:dst-up", rctx); + } } } diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h index bffcf6a51ef..2005f3437ca 100644 --- a/src/modules/dispatcher/dispatch.h +++ b/src/modules/dispatcher/dispatch.h @@ -88,6 +88,10 @@ #define DS_STATE_MODE_SET 1 #define DS_STATE_MODE_FUNC (1<<1) +#define DS_EVRTMODE_RUNTIME 0 +#define DS_EVRTMODE_OPTIONS 1 +#define DS_EVRTMODE_INIT 2 + /* clang-format on */ typedef struct ds_rctx { diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c index b186988e853..b61622c0bfd 100644 --- a/src/modules/dispatcher/dispatcher.c +++ b/src/modules/dispatcher/dispatcher.c @@ -149,7 +149,7 @@ str ds_attrs_pvname = STR_NULL; pv_spec_t ds_attrs_pv; str ds_event_callback = STR_NULL; -int ds_event_callback_mode = 0; +int ds_event_callback_mode = DS_EVRTMODE_RUNTIME; str ds_db_extra_attrs = STR_NULL; param_t *ds_db_extra_attrs_list = NULL; _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
