From 2945ba448c6365728b49c10ba98824be357f85b3 Mon Sep 17 00:00:00 2001 From: lazedo Date: Thu, 31 Oct 2019 14:41:53 +0000 Subject: [PATCH] dispatcher: add state to mode in ds_list_exists adds Bit 3 to allow the check of active/inactive entries in ds_list --- src/modules/dispatcher/dispatch.c | 4 +++- src/modules/dispatcher/dispatch.h | 1 + src/modules/dispatcher/doc/dispatcher_admin.xml | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c index 18b713ce02e..75b3b56f3a5 100644 --- a/src/modules/dispatcher/dispatch.c +++ b/src/modules/dispatcher/dispatch.c @@ -2998,7 +2998,9 @@ int ds_is_addr_from_set(sip_msg_t *_m, struct ip_addr *pipaddr, && ((mode & DS_MATCH_NOPORT) || node->dlist[j].port == 0 || tport == node->dlist[j].port) && ((mode & DS_MATCH_NOPROTO) - || tproto == node->dlist[j].proto)) { + || tproto == node->dlist[j].proto) + && (((mode & DS_MATCH_ACTIVE) && !ds_skip_dst(node->dlist[j].flags)) + || !(mode & DS_MATCH_ACTIVE))) { if(export_set_pv && ds_setid_pvname.s != 0) { memset(&val, 0, sizeof(pv_value_t)); val.flags = PV_VAL_INT | PV_TYPE_INT; diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h index 3a6a5aedc6a..e4a54944aa0 100644 --- a/src/modules/dispatcher/dispatch.h +++ b/src/modules/dispatcher/dispatch.h @@ -57,6 +57,7 @@ #define DS_MATCH_ALL 0 #define DS_MATCH_NOPORT 1 #define DS_MATCH_NOPROTO 2 +#define DS_MATCH_ACTIVE 4 #define DS_SETOP_DSTURI 0 #define DS_SETOP_RURI 1 diff --git a/src/modules/dispatcher/doc/dispatcher_admin.xml b/src/modules/dispatcher/doc/dispatcher_admin.xml index 11881bbed58..94e70627056 100644 --- a/src/modules/dispatcher/doc/dispatcher_admin.xml +++ b/src/modules/dispatcher/doc/dispatcher_admin.xml @@ -1569,8 +1569,10 @@ if(ds_list_exists("10")) { mode - (optional) - a bitmask to specify how the matching should be done. If is 0, all ip, port and - proto are matched. If bit one is set, then port is ignored. - If bit two is set, then protocol is ignored. The parameter + proto are matched and active status is ignored. + If bit one is set, then port is ignored. + If bit two is set, then protocol is ignored. + If bit three is set, then state must be active. The parameter can be an integer or a variable holding an integer value. It must be provided if the uri parameter is provided.