remove already applied patches and refresh the rest

Change-Id: I0d28912430c510c3124a2822571f20cbe242893e
mr11.4
Victor Seva 2 years ago
parent 4af71051b0
commit 73245bcbac

@ -7,7 +7,7 @@ Subject: fix_export
1 file changed, 2 insertions(+)
diff --git a/src/Makefile b/src/Makefile
index f2fa93c..b111153 100644
index c2ce846..f1e1e0b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -139,6 +139,8 @@ endif

@ -7,10 +7,10 @@ Subject: no_INSTALL_file
1 file changed, 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index b5f7192..f2fa93c 100644
index 46847d0..c2ce846 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -861,8 +861,6 @@ install-modules-all: install-every-module install-every-module-doc
@@ -858,8 +858,6 @@ install-modules-all: install-every-module install-every-module-doc
install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc

@ -7,7 +7,7 @@ Subject: no_lib64_on_64_bits
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/src/Makefile.defs b/src/Makefile.defs
index 99eae5c..e0f3a0b 100644
index da88735..be5e1a0 100644
--- a/src/Makefile.defs
+++ b/src/Makefile.defs
@@ -458,15 +458,7 @@ endif

@ -31,24 +31,11 @@ sipwise/sca-fix-on-hold-detection-when-upstream-flow.patch
sipwise/sca-debug.patch
sipwise/sca-fix-notify-after-bye.patch
sipwise/sca-add-pai_avp-parameter.patch
## upstream 5.6
## upstream 5.7
#
## upstream master
upstream/dialog-dlg_get_var-ci-ft-tt-key-dst_var.patch
upstream/dialog-dlg_set_var-callid-ft-tt-key-value.patch
upstream/dialog-reworked-kemi-export-for-dlg_get_var.patch
upstream/dialog-fix-ki_dlg_get_var-introduced-previously.patch
upstream/dialog-dlg_get_var-assure-return-null-on-error.patch
upstream/dialog-w_dlg_get_var-fix-incompatible-pointer.patch
sipwise/dialog-dlg_get_var-changes-in-API.patch
upstream/presence-No-autocommit-rollback-if-no-active-watcher.patch
upstream/app_lua-fix-crash-on-exausted-memory-scenario.patch
#
### relevant for upstream
sipwise/Makefile-support-parallelism-on-install-modules-doc-.patch
sipwise/pua_dialoginfo-refresh_pubruri_avps_flag.patch
sipwise/pua_dialoginfo-use-lock-when-use_puburi_avps-is-set.patch
sipwise/pua_dialoginfo-local_identity_dlg_var.patch
sipwise/pua_dialoginfo-use-dlg_api.get_dlg_varval.patch
sipwise/dialplan-don-t-stop-loading-rules-on-error.patch
sipwise/cfgt-skip_unknown.patch
sipwise/cfgt-skip_duplicate_dump.patch
@ -60,13 +47,7 @@ sipwise/kamctl-TMPDIR-config.patch
sipwise/lcr-stopper_mode-parameter.patch
sipwise/lcr-stats.patch
sipwise/dialog-support-profile_get_size-for-all-profiles.patch
sipwise/dialog-dlg_set_var-support-empty-totag-param.patch
sipwise/dialog-dlg_get_var-support-empty-totag-param.patch
### active development
upstream/tm-new-inter-module-API-function-t_find.patch
upstream/pv_headers-use-tm.t_find-API.patch
upstream/tm-added-t_unset-intermodule-API-function.patch
upstream/pv_headers-use-t_unset-based-on-vref-instead-of-rese.patch
sipwise/pv_headers-rework-pvh_remove_header_param-take-two.patch
#
### Don't just put stuff in any order

@ -1,28 +0,0 @@
From: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Tue, 31 Jan 2023 19:38:37 +0100
Subject: [PATCH] Makefile: support parallelism on install-modules-doc rule
---
src/Makefile | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index f10a178..e343caa 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -473,13 +473,10 @@ install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
if [ -f $(1)/"$$$$r"/README ]; then \
$$(call try_err,\
- $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
+ $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
$$(call try_err,\
$(INSTALL_DOC) $(1)/"$$$$r"/README \
- $(doc_prefix)/$(doc_dir)$(1)/README ); \
- $$(call try_err,\
- mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
- $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
+ $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
fi ; \
fi ; \
done; true

@ -13,10 +13,10 @@ Subject: add_lcr_rate_module
create mode 100644 src/modules/lcr_rate/lcr_rate_mod.c
diff --git a/src/Makefile.groups b/src/Makefile.groups
index e2d72c5..4837390 100644
index 7c426dd..69246a4 100644
--- a/src/Makefile.groups
+++ b/src/Makefile.groups
@@ -109,6 +109,9 @@ mod_list_sctp=sctp
@@ -112,6 +112,9 @@ mod_list_sctp=sctp
# - modules depending on openssl library
mod_list_autheph=auth_ephemeral
@ -26,10 +26,10 @@ index e2d72c5..4837390 100644
# - modules related to SIMPLE presence extensions
mod_list_presence=presence presence_conference presence_dialoginfo \
presence_mwi presence_profile presence_reginfo \
@@ -280,8 +283,8 @@ mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_lwsc) \
@@ -284,8 +287,8 @@ mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_stirshaken) \
$(mod_list_tlsa) \
$(mod_list_tls_wolfssl) \
- $(mod_list_rtp_media_server)
-
+ $(mod_list_rtp_media_server) \
@ -37,7 +37,7 @@ index e2d72c5..4837390 100644
### --- Groups defined for source code compilation ###
@@ -338,6 +341,8 @@ module_group_cassandra=$(module_group_cassandra_driver) $(module_group_db)
@@ -342,6 +345,8 @@ module_group_cassandra=$(module_group_cassandra_driver) $(module_group_db)
module_group_ignore= $(sort $(filter-out $(module_group_default), $(mod_list_all)))
@ -47,7 +47,7 @@ index e2d72c5..4837390 100644
### --- Groups defined for pacKaging ###
diff --git a/src/core/mod_fix.c b/src/core/mod_fix.c
index 925048d..25d6f5a 100644
index e9cf314..3e75e75 100644
--- a/src/core/mod_fix.c
+++ b/src/core/mod_fix.c
@@ -605,6 +605,7 @@ int fixup_free_igp_spve(void** param, int param_no)
@ -67,10 +67,10 @@ index 925048d..25d6f5a 100644
}
diff --git a/src/core/mod_fix.h b/src/core/mod_fix.h
index 8c2c766..82afdc7 100644
index 043b1e3..e2006df 100644
--- a/src/core/mod_fix.h
+++ b/src/core/mod_fix.h
@@ -136,6 +136,8 @@ int fixup_spve_uint(void** param, int param_no);
@@ -138,6 +138,8 @@ int fixup_spve_uint(void** param, int param_no);
int fixup_free_spve_uint(void** param, int param_no);
int fixup_spve_str(void** param, int param_no);
int fixup_free_spve_str(void** param, int param_no);

@ -17,7 +17,7 @@ Subject: add_pcem_module
create mode 100644 src/modules/pcem/pcem_mod.h
diff --git a/src/Makefile.groups b/src/Makefile.groups
index bd111ca..e2d72c5 100644
index e70dedb..7c426dd 100644
--- a/src/Makefile.groups
+++ b/src/Makefile.groups
@@ -30,8 +30,8 @@ mod_list_db=acc alias_db auth_db avpops cfg_db db_text db_flatstore \

@ -22,10 +22,10 @@ Subject: add_presence_dfks_module
create mode 100644 src/modules/presence_dfks/presence_dfks.h
diff --git a/src/Makefile.groups b/src/Makefile.groups
index 6b9e3b5..b357a3f 100644
index 640e3fd..0a8d500 100644
--- a/src/Makefile.groups
+++ b/src/Makefile.groups
@@ -118,7 +118,7 @@ mod_list_presence=presence presence_conference presence_dialoginfo \
@@ -121,7 +121,7 @@ mod_list_presence=presence presence_conference presence_dialoginfo \
presence_xml \
pua pua_bla pua_dialoginfo pua_reginfo \
pua_rpc pua_usrloc pua_xmpp \

@ -11,10 +11,10 @@ Subject: add_tcap_module
create mode 100644 src/modules/tcap/tcap_mod.c
diff --git a/src/Makefile.groups b/src/Makefile.groups
index 4837390..6b9e3b5 100644
index 69246a4..640e3fd 100644
--- a/src/Makefile.groups
+++ b/src/Makefile.groups
@@ -214,6 +214,9 @@ mod_list_erlang=erlang
@@ -217,6 +217,9 @@ mod_list_erlang=erlang
# - modules depending on systemd library
mod_list_systemd=log_systemd systemdops
@ -24,7 +24,7 @@ index 4837390..6b9e3b5 100644
# - modules depending on libnsq (+libev libevbuffsock liblcurl libjson-c) library
mod_list_nsq=nsq
@@ -344,6 +347,9 @@ module_group_ignore= $(sort $(filter-out $(module_group_default), $(mod_list_all
@@ -348,6 +351,9 @@ module_group_ignore= $(sort $(filter-out $(module_group_default), $(mod_list_all
# pkg lcrrate module
module_group_klcrrate=$(mod_list_lcrrate)

@ -1,21 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Tue, 13 Dec 2022 11:38:00 +0100
Subject: dialog: dlg_get_var changes in API
---
src/modules/dialog/dialog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 6545444..25f3ca1 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1536,7 +1536,7 @@ static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str
dlg = get_dlg(sc, sf, st, &dir);
if(dlg==NULL)
return val;
- val = get_dlg_variable(dlg, key);
+ val = get_dlg_varref(dlg, key);
dlg_release(dlg);
return val;
}

@ -1,34 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Wed, 12 Apr 2023 10:39:55 +0200
Subject: dialog: dlg_get_var() support early dialogs
to_tag can be empty
---
src/modules/dialog/dialog.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 8f4c806..4dec95a 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1528,7 +1528,7 @@ static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str
LM_ERR("invalid From tag parameter\n");
return val;
}
- if(st==NULL || st->s==NULL || st->len == 0) {
+ if(st==NULL) {
LM_ERR("invalid To tag parameter\n");
return val;
}
@@ -1598,11 +1598,6 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
LM_ERR("unable to get To Tag\n");
goto error;
}
- if(st.s==NULL || st.len == 0)
- {
- LM_ERR("invalid To tag parameter\n");
- goto error;
- }
if(fixup_get_svalue(msg, (gparam_p)key, &k)!=0)
{
LM_ERR("unable to get key name\n");

@ -1,35 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Fri, 4 Nov 2022 11:23:59 +0100
Subject: MT#55631 dialog: dlg_set_var() support empty totag parameter
* support setting vars for non established dialogs
---
src/modules/dialog/dialog.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index aedf8a7..8f4c806 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1663,7 +1663,7 @@ static int ki_dlg_set_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key, s
LM_ERR("invalid From tag parameter\n");
return -1;
}
- if(st==NULL || st->s==NULL || st->len == 0) {
+ if(st==NULL) {
LM_ERR("invalid To tag parameter\n");
return -1;
}
@@ -1707,11 +1707,7 @@ static int w_dlg_set_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
LM_ERR("unable to get To Tag\n");
return -1;
}
- if(st.s==NULL || st.len == 0)
- {
- LM_ERR("invalid To tag parameter\n");
- return -1;
- }
+
if(fixup_get_svalue(msg, (gparam_p)key, &k)!=0)
{
LM_ERR("unable to get key name\n");

@ -10,10 +10,10 @@ Subject: dialog: support profile_get_size for all profiles
4 files changed, 70 insertions(+)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 25f3ca1..aedf8a7 100644
index 947c403..b76f1da 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -2758,6 +2758,33 @@ static void internal_rpc_profile_get_size(rpc_t *rpc, void *c, str *profile_name
@@ -3011,6 +3011,33 @@ static void internal_rpc_profile_get_size(rpc_t *rpc, void *c, str *profile_name
return;
}
@ -47,7 +47,7 @@ index 25f3ca1..aedf8a7 100644
/*!
* \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface
* \see rpc_profile_print_dlgs
@@ -2850,6 +2877,9 @@ static const char *rpc_dlg_set_state_doc[3] = {
@@ -3103,6 +3130,9 @@ static const char *rpc_dlg_set_state_doc[3] = {
static const char *rpc_profile_get_size_doc[2] = {
"Returns the number of dialogs belonging to a profile", 0
};
@ -57,7 +57,7 @@ index 25f3ca1..aedf8a7 100644
static const char *rpc_profile_print_dlgs_doc[2] = {
"Lists all the dialogs belonging to a profile", 0
};
@@ -3055,6 +3085,10 @@ static void rpc_profile_get_size(rpc_t *rpc, void *c) {
@@ -3308,6 +3338,10 @@ static void rpc_profile_get_size(rpc_t *rpc, void *c) {
}
return;
}
@ -68,7 +68,7 @@ index 25f3ca1..aedf8a7 100644
static void rpc_profile_print_dlgs(rpc_t *rpc, void *c) {
str profile_name = {NULL,0};
str value = {NULL,0};
@@ -3472,6 +3506,7 @@ static rpc_export_t rpc_methods[] = {
@@ -3725,6 +3759,7 @@ static rpc_export_t rpc_methods[] = {
{"dlg.dlg_list_ctx", rpc_print_dlg_ctx, rpc_print_dlg_ctx_doc, 0},
{"dlg.end_dlg", rpc_end_dlg_entry_id, rpc_end_dlg_entry_id_doc, 0},
{"dlg.profile_get_size", rpc_profile_get_size, rpc_profile_get_size_doc, 0},
@ -112,10 +112,10 @@ index 3dc7be8..7a4f8b0 100644
/*!
* \brief Search a dialog profile in the global list
diff --git a/src/modules/dialog/doc/dialog_admin.xml b/src/modules/dialog/doc/dialog_admin.xml
index 23ca1fb..13b0f8f 100644
index 6350e2d..5894829 100644
--- a/src/modules/dialog/doc/dialog_admin.xml
+++ b/src/modules/dialog/doc/dialog_admin.xml
@@ -2856,6 +2856,28 @@ dlg_reset_property("timeout-noreset");
@@ -3013,6 +3013,28 @@ dlg_reset_property("timeout-noreset");
</programlisting>
</section>

@ -8,10 +8,10 @@ Subject: do-not-install-default-config
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index b111153..f10a178 100644
index f1e1e0b..f0435b8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -652,7 +652,7 @@ sunpkg:
@@ -649,7 +649,7 @@ sunpkg:
.PHONY: install
install: mk_params="compile_for_install=yes"

@ -13,11 +13,11 @@ Subject: kamctl: TMPDIR config
5 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index b4b8617..ee1b9f3 100755
index 214cd21..7a49826 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -73,6 +73,10 @@ if [ -z "$MYLIBDIR" ] ; then
fi
@@ -77,6 +77,10 @@ if [ -z "$STARTUP_CONFIG_FILE" ]; then
STARTUP_CONFIG_FILE="kamailio.cfg"
fi
+if [ -z "$TMPDIR" ]; then
@ -27,7 +27,7 @@ index b4b8617..ee1b9f3 100755
##### ------------------------------------------------ #####
### load base functions
#
@@ -2936,7 +2940,7 @@ kamailio_trap() {
@@ -2940,7 +2944,7 @@ kamailio_trap() {
exit
fi
DATE=`/bin/date +%Y%m%d_%H%M%S`
@ -36,7 +36,7 @@ index b4b8617..ee1b9f3 100755
minfo "Trap file: $LOG_FILE"
ctl_cmd_run core.psx > $LOG_FILE
echo -n "Trapping Kamailio with gdb: "
@@ -2963,7 +2967,7 @@ kamailio_pstrap() {
@@ -2967,7 +2971,7 @@ kamailio_pstrap() {
exit
fi
DATE=`/bin/date +%Y%m%d_%H%M%S`
@ -46,7 +46,7 @@ index b4b8617..ee1b9f3 100755
ps axw | grep kamailio | grep -v grep | grep -v kamctl | sort > $LOG_FILE
echo "" >> $LOG_FILE
diff --git a/utils/kamctl/kamctl.rpcfifo b/utils/kamctl/kamctl.rpcfifo
index c8e5329..a538a3c 100644
index f7408b5..478864a 100644
--- a/utils/kamctl/kamctl.rpcfifo
+++ b/utils/kamctl/kamctl.rpcfifo
@@ -30,6 +30,10 @@ if [ -z "$RPCFIFOPATH" ]; then
@ -79,7 +79,7 @@ index c8e5329..a538a3c 100644
fi
PARAMEVAL="no"
@@ -183,7 +188,7 @@ CTLCMDPRINT=rpc_cmd_print
@@ -189,7 +194,7 @@ CTLCMDPRINT=rpc_cmd_print
rpc_kamailio_monitor() {
name=kamailio_receiver_$$
@ -88,7 +88,7 @@ index c8e5329..a538a3c 100644
# delete existing fifo file with same name
if test -p $path; then
rm -f $path
@@ -199,7 +204,8 @@ rpc_kamailio_monitor() {
@@ -205,7 +210,8 @@ rpc_kamailio_monitor() {
merr "monitor - error opening read fifo $path"
exit 1
fi
@ -99,7 +99,7 @@ index c8e5329..a538a3c 100644
trap "rm $path; clear; echo monitor ^C-ed; exit 1" 2
attempt=0
diff --git a/utils/kamctl/kamdbctl b/utils/kamctl/kamdbctl
index 60c20f2..50cd70c 100755
index 4f3f407..7c18523 100755
--- a/utils/kamctl/kamdbctl
+++ b/utils/kamctl/kamdbctl
@@ -303,7 +303,7 @@ case $1 in

@ -9,18 +9,18 @@ Subject: lcr: add stats per gw
3 files changed, 833 insertions(+), 7 deletions(-)
diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c
index fa5cac5..8d0b0cc 100644
index 3d49365..1300ffb 100644
--- a/src/modules/lcr/lcr_mod.c
+++ b/src/modules/lcr/lcr_mod.c
@@ -66,6 +66,7 @@
#include "../../core/mod_fix.h"
@@ -65,6 +65,7 @@
#include "../../core/pvar.h"
#include "../../core/rand/kam_rand.h"
#include "../../core/kemi.h"
+#include "../../core/script_cb.h"
#include "hash.h"
#include "lcr_rpc.h"
#include "../../core/rpc_lookup.h"
@@ -209,6 +210,9 @@ str mtree_param = {"lcr", 3};
@@ -208,6 +209,9 @@ str mtree_param = {"lcr", 3};
#define DEF_LCR_STOPPER_MODE 0
unsigned int stopper_mode_param = DEF_LCR_STOPPER_MODE;
@ -30,7 +30,7 @@ index fa5cac5..8d0b0cc 100644
/*
* Other module types and variables
*/
@@ -250,6 +254,9 @@ unsigned int ping_rc_count = 0;
@@ -249,6 +253,9 @@ unsigned int ping_rc_count = 0;
/* Mtree API var */
mtree_api_t mtree_api;
@ -40,7 +40,7 @@ index fa5cac5..8d0b0cc 100644
/*
* Functions that are defined later
*/
@@ -272,6 +279,10 @@ static int to_gw_1(struct sip_msg *_m, char *_s1, char *_s2);
@@ -271,6 +278,10 @@ static int to_gw_1(struct sip_msg *_m, char *_s1, char *_s2);
static int to_gw_3(struct sip_msg *_m, char *_s1, char *_s2, char *_s3);
static int to_any_gw_0(struct sip_msg *_m, char *_s1, char *_s2);
static int to_any_gw_2(struct sip_msg *_m, char *_s1, char *_s2);
@ -51,7 +51,7 @@ index fa5cac5..8d0b0cc 100644
/* clang-format off */
/*
@@ -362,6 +373,7 @@ static param_export_t params[] = {
@@ -361,6 +372,7 @@ static param_export_t params[] = {
{"ping_from", PARAM_STR, &ping_from_param},
{"ping_socket", PARAM_STR, &ping_socket_param},
{"stopper_mode", PARAM_INT, &stopper_mode_param},
@ -59,7 +59,7 @@ index fa5cac5..8d0b0cc 100644
{0, 0, 0}
};
@@ -427,6 +439,180 @@ static void lcr_db_close(void)
@@ -426,6 +438,180 @@ static void lcr_db_close(void)
}
}
@ -240,7 +240,7 @@ index fa5cac5..8d0b0cc 100644
/*
* Module initialization function that is called before the main process forks
@@ -439,6 +625,28 @@ static int mod_init(void)
@@ -438,6 +624,28 @@ static int mod_init(void)
unsigned int i;
char *at, *past, *sep;
@ -269,7 +269,7 @@ index fa5cac5..8d0b0cc 100644
/* Register RPC commands */
if(rpc_register_array(lcr_rpc) != 0) {
LM_ERR("failed to register RPC commands\n");
@@ -1014,6 +1222,10 @@ static int insert_gw(struct gw_info *gws, unsigned int i, unsigned int gw_id,
@@ -1013,6 +1221,10 @@ static int insert_gw(struct gw_info *gws, unsigned int i, unsigned int gw_id,
append_str(at, transport, transport_len);
}
gws[i].uri_len = at - &(gws[i].uri[0]);
@ -280,7 +280,7 @@ index fa5cac5..8d0b0cc 100644
LM_DBG("inserted gw <%u, %.*s, %.*s> at index %u\n", gw_id, gw_name_len,
gw_name, gws[i].uri_len, gws[i].uri, i);
return 1;
@@ -2282,6 +2494,65 @@ done:
@@ -2281,6 +2493,65 @@ done:
return j;
}
@ -346,7 +346,7 @@ index fa5cac5..8d0b0cc 100644
/*
* Load info of matching GWs into gw_uri_avps
@@ -3267,8 +3538,8 @@ static int from_any_gw_0(struct sip_msg *_m, char *_s1, char *_s2)
@@ -3279,8 +3550,8 @@ static int from_any_gw_0(struct sip_msg *_m, char *_s1, char *_s2)
* Checks if request comes from ip address of a gateway taking source
* IP address, transport protocol and source port from parameters.
*/
@ -357,7 +357,7 @@ index fa5cac5..8d0b0cc 100644
{
unsigned int i;
struct ip_addr *ip, src_addr;
@@ -3701,3 +3972,55 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
@@ -3713,3 +3984,55 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
sr_kemi_modules_add(sr_kemi_lcr_exports);
return 0;
}

@ -10,10 +10,10 @@ but will sort them first before stopping
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/modules/lcr/lcr_mod.c b/src/modules/lcr/lcr_mod.c
index 2e33df0..fa5cac5 100644
index be945fb..3d49365 100644
--- a/src/modules/lcr/lcr_mod.c
+++ b/src/modules/lcr/lcr_mod.c
@@ -205,6 +205,10 @@ static unsigned int priority_ordering_param = 0;
@@ -204,6 +204,10 @@ static unsigned int priority_ordering_param = 0;
/* mtree tree name */
str mtree_param = {"lcr", 3};
@ -24,7 +24,7 @@ index 2e33df0..fa5cac5 100644
/*
* Other module types and variables
*/
@@ -357,6 +361,7 @@ static param_export_t params[] = {
@@ -356,6 +360,7 @@ static param_export_t params[] = {
{"ping_valid_reply_codes", PARAM_STR, &ping_valid_reply_codes_param},
{"ping_from", PARAM_STR, &ping_from_param},
{"ping_socket", PARAM_STR, &ping_socket_param},
@ -32,7 +32,7 @@ index 2e33df0..fa5cac5 100644
{0, 0, 0}
};
@@ -2227,6 +2232,8 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri,
@@ -2226,6 +2231,8 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri,
matched_gws[gw_index].priority = t->priority;
matched_gws[gw_index].weight = t->weight * (kam_rand() >> 8);
matched_gws[gw_index].duplicate = 0;
@ -41,7 +41,7 @@ index 2e33df0..fa5cac5 100644
LM_DBG("added matched_gws[%d]=[%u, %u, %u, %u]\n", gw_index,
t->gw_index, pl->prefix_len, t->priority,
matched_gws[gw_index].weight);
@@ -2234,8 +2241,10 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri,
@@ -2233,8 +2240,10 @@ int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, str *request_uri,
skip_gw:
t = t->next;
}
@ -53,7 +53,7 @@ index 2e33df0..fa5cac5 100644
next:
rule = rule->next;
@@ -2262,6 +2271,11 @@ done:
@@ -2261,6 +2270,11 @@ done:
if(matched_gws[i].duplicate == 1)
continue;
gw_indexes[j] = matched_gws[i].gw_index;
@ -65,7 +65,7 @@ index 2e33df0..fa5cac5 100644
j++;
}
@@ -2277,7 +2291,7 @@ static int ki_load_gws_furi(
@@ -2276,7 +2290,7 @@ static int ki_load_gws_furi(
{
str *request_uri;
int i, j;
@ -74,7 +74,7 @@ index 2e33df0..fa5cac5 100644
int_str val;
struct matched_gw_info matched_gws[MAX_NO_OF_GWS + 1];
struct rule_info **rules, *rule, *pl;
@@ -2392,6 +2406,8 @@ static int ki_load_gws_furi(
@@ -2396,6 +2410,8 @@ static int ki_load_gws_furi(
matched_gws[gw_index].priority = t->priority;
matched_gws[gw_index].weight = t->weight * (kam_rand() >> 8);
matched_gws[gw_index].duplicate = 0;
@ -83,7 +83,7 @@ index 2e33df0..fa5cac5 100644
LM_DBG("added matched_gws[%d]=[%u, %u, %u, %u]\n", gw_index,
t->gw_index, pl->prefix_len, t->priority,
matched_gws[gw_index].weight);
@@ -2400,8 +2416,10 @@ static int ki_load_gws_furi(
@@ -2404,8 +2420,10 @@ static int ki_load_gws_furi(
t = t->next;
}
/* Do not look further if this matching rule was stopper */
@ -95,7 +95,7 @@ index 2e33df0..fa5cac5 100644
next:
rule = rule->next;
@@ -2426,6 +2444,24 @@ done:
@@ -2430,6 +2448,24 @@ done:
}
}

@ -1,88 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Fri, 28 Feb 2020 11:39:24 +0100
Subject: pua_dialoginfo: local_identity_dlg_var
---
.../pua_dialoginfo/doc/pua_dialoginfo_admin.xml | 19 +++++++++++++++++++
src/modules/pua_dialoginfo/pua_dialoginfo.c | 17 +++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
index bdf9efa..eaedbc4 100644
--- a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
+++ b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
@@ -620,6 +620,25 @@ modparam("pua_dialoginfo", "publish_dialog_req_within", 0)
</example>
</section>
+ <section id="pua_dialoginfo.p.local_identity_dlg_var">
+ <title><varname>local_identity_dlg_var</varname> (str)</title>
+ <para>
+ PUBLISH-requests reporting dialog-information will use the value of
+ the dialog variable if exists
+ </para>
+ <para>
+ <emphasis>Default value is <quote>NULL</quote>.</emphasis>
+ </para>
+ <example>
+ <title>Set <varname>local_identity_dlg_var</varname> parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("pua_dialoginfo", "local_identity_dlg_var", "local_identity")
+...
+</programlisting>
+ </example>
+ </section>
+
<section id="pua_dialoginfo.p.attribute_display">
<title><varname>attribute_display</varname> (int)</title>
<para>
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
index 8848033..94efcef 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
@@ -87,6 +87,7 @@ static str caller_dlg_var = {0, 0}; /* pubruri_caller */
static str callee_dlg_var = {0, 0}; /* pubruri_callee */
static str caller_entity_when_publish_disabled = {0, 0}; /* pubruri_caller */
static str callee_entity_when_publish_disabled = {0, 0}; /* pubruri_callee */
+static str local_identity_dlg_var = STR_NULL;
/* Module parameter variables */
int include_callid = DEF_INCLUDE_CALLID;
@@ -132,6 +133,7 @@ static param_export_t params[]={
{"pubruri_callee_avp", PARAM_STRING, &pubruri_callee_avp },
{"pubruri_caller_dlg_var", PARAM_STR, &caller_dlg_var },
{"pubruri_callee_dlg_var", PARAM_STR, &callee_dlg_var },
+ {"local_identity_dlg_var", PARAM_STR, &local_identity_dlg_var },
{"callee_trying", INT_PARAM, &callee_trying },
{"disable_caller_publish_flag", INT_PARAM, &disable_caller_publish_flag },
{"disable_callee_publish_flag", INT_PARAM, &disable_callee_publish_flag },
@@ -312,6 +314,17 @@ void refresh_pubruri_avps(struct dlginfo_cell *dlginfo, str *uri)
}
}
+void refresh_local_identity(struct dlg_cell *dlg, str *uri) {
+ str *s = dlg_api.get_dlg_varref(dlg, &local_identity_dlg_var);
+
+ if(s != NULL) {
+ uri->s = s->s;
+ uri->len = s->len;
+ LM_DBG("Found local_identity in dialog '%.*s'\n",
+ uri->len, uri->s);
+ }
+}
+
static void
__dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
{
@@ -357,6 +370,10 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
refresh_pubruri_avps(dlginfo, &uri);
}
+ if(local_identity_dlg_var.len > 0) {
+ refresh_local_identity(dlg, &uri);
+ }
+
switch (type) {
case DLGCB_FAILED:
case DLGCB_TERMINATED:

@ -1,168 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Thu, 20 Feb 2020 18:50:14 +0100
Subject: pua_dialoginfo: refresh_pubruri_avps_flag
---
.../pua_dialoginfo/doc/pua_dialoginfo_admin.xml | 20 +++++-
src/modules/pua_dialoginfo/pua_dialoginfo.c | 75 ++++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
index cfc0fc7..bdf9efa 100644
--- a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
+++ b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
@@ -433,7 +433,25 @@ modparam("pua_dialoginfo", "use_pubruri_avps", 1)
</programlisting>
</example>
</section>
-
+
+ <section>
+ <title><varname>refresh_pubruri_avps_flag</varname> (int)</title>
+ <para>
+ If use_pubruri_avps is enabled, this message flag indicates whether to refresh R-Uri from avps before sending the PUBLISH requests.
+ </para>
+ <para>
+ <emphasis>Default value is <quote>-1</quote>.</emphasis>
+ </para>
+ <example>
+ <title>Set <varname>refresh_pubruri_avps_flag</varname> parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("pua_dialoginfo", "refresh_pubruri_avps_flag", 11)
+...
+</programlisting>
+ </example>
+ </section>
+
<section>
<title><varname>pubruri_caller_avp</varname> (str)</title>
<para>
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
index 1765734..9d9de31 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
@@ -41,6 +41,7 @@
#include "../../core/str_list.h"
#include "../../core/mem/mem.h"
#include "../../core/pt.h"
+#include "../../core/ut.h"
#include "../../core/utils/sruid.h"
#include "../dialog/dlg_load.h"
#include "../dialog/dlg_hash.h"
@@ -59,6 +60,7 @@ MODULE_VERSION
#define DEF_OVERRIDE_LIFETIME 0
#define DEF_SEND_PUBLISH_FLAG -1
#define DEF_USE_PUBRURI_AVPS 0
+#define DEF_REFRESH_PUBRURI_AVPS_FLAG -1
#define DEF_PUBRURI_CALLER_AVP 0
#define DEF_PUBRURI_CALLEE_AVP 0
#define DEF_CALLEE_TRYING 0
@@ -95,6 +97,7 @@ int caller_confirmed = DEF_CALLER_ALWAYS_CONFIRMED;
int include_req_uri = DEF_INCLUDE_REQ_URI;
int send_publish_flag = DEF_SEND_PUBLISH_FLAG;
int use_pubruri_avps = DEF_USE_PUBRURI_AVPS;
+int refresh_pubruri_avps_flag = DEF_REFRESH_PUBRURI_AVPS_FLAG;
int callee_trying = DEF_CALLEE_TRYING;
int disable_caller_publish_flag = DEF_DISABLE_CALLER_PUBLISH_FLAG;
int disable_callee_publish_flag = DEF_DISABLE_CALLEE_PUBLISH_FLAG;
@@ -124,6 +127,7 @@ static param_export_t params[]={
{"include_req_uri", INT_PARAM, &include_req_uri },
{"send_publish_flag", INT_PARAM, &send_publish_flag },
{"use_pubruri_avps", INT_PARAM, &use_pubruri_avps },
+ {"refresh_pubruri_avps_flag", INT_PARAM, &refresh_pubruri_avps_flag },
{"pubruri_caller_avp", PARAM_STRING, &pubruri_caller_avp },
{"pubruri_callee_avp", PARAM_STRING, &pubruri_callee_avp },
{"pubruri_caller_dlg_var", PARAM_STR, &caller_dlg_var },
@@ -256,6 +260,58 @@ __dialog_cbtest(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
}
#endif
+static struct str_list* get_str_list(unsigned short avp_flags, int_str avp_name);
+static int is_ruri_in_list(struct str_list *list, str *ruri);
+
+void refresh_pubruri_avps(struct dlginfo_cell *dlginfo, str *uri)
+{
+ struct str_list *pubruris = get_str_list(pubruri_caller_avp_type,
+ pubruri_caller_avp_name);
+ struct str_list *list, *next;
+ str target = STR_NULL;
+
+ if(pubruris) {
+ list = dlginfo->pubruris_caller;
+ while(list) {
+ if(is_ruri_in_list(pubruris, &list->s) == 0) {
+ LM_DBG("ruri:'%.*s' removed from pubruris_caller list\n",
+ list->s.len, list->s.s);
+ next = list->next; list->next = NULL;
+ dialog_publish_multi("terminated", list,
+ &(dlginfo->from_uri), uri, &(dlginfo->callid), 1,
+ 10, 0, 0, &(dlginfo->from_contact),
+ &target, send_publish_flag==-1?1:0, &(dlginfo->uuid));
+ list->next = next;
+ }
+ list = list->next;
+ }
+ free_str_list_all(dlginfo->pubruris_caller);
+ dlginfo->pubruris_caller = pubruris;
+ LM_DBG("refreshed pubruris_caller info from avp\n");
+ }
+ pubruris = get_str_list(pubruri_callee_avp_type,
+ pubruri_callee_avp_name);
+ if(pubruris) {
+ list = dlginfo->pubruris_callee;
+ while(list) {
+ if(is_ruri_in_list(pubruris, &list->s) == 0) {
+ LM_DBG("ruri:'%.*s' removed from pubruris_callee list\n",
+ list->s.len, list->s.s);
+ next = list->next; list->next = NULL;
+ dialog_publish_multi("terminated", list,
+ uri, &(dlginfo->from_uri), &(dlginfo->callid), 0,
+ 10, 0, 0, &target, &(dlginfo->from_contact),
+ send_publish_flag==-1?1:0, &(dlginfo->uuid));
+ list->next = next;
+ }
+ list = list->next;
+ }
+ free_str_list_all(dlginfo->pubruris_callee);
+ dlginfo->pubruris_callee = pubruris;
+ LM_DBG("refreshed pubruris_callee info from avp\n");
+ }
+}
+
static void
__dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
{
@@ -294,6 +350,12 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
uri=callee_entity_when_publish_disabled;
}
+ if(use_pubruri_avps && (refresh_pubruri_avps_flag > -1
+ || (request->flags & (1<<refresh_pubruri_avps_flag))))
+ {
+ refresh_pubruri_avps(dlginfo, &uri);
+ }
+
switch (type) {
case DLGCB_FAILED:
case DLGCB_TERMINATED:
@@ -892,6 +954,19 @@ void free_dlginfo_cell(void *param) {
}
+int is_ruri_in_list(struct str_list *list, str *ruri) {
+ struct str_list *pubruris = list;
+ LM_DBG("search:'%.*s'\n", ruri->len, ruri->s);
+ while(pubruris) {
+ LM_DBG("compare with:'%.*s'\n", pubruris->s.len, pubruris->s.s);
+ if(str_strcmp(&pubruris->s, ruri) == 0) {
+ return 1;
+ }
+ pubruris = pubruris->next;
+ }
+ return 0;
+}
+
void free_str_list_all(struct str_list * del_current) {
struct str_list* del_next;

@ -1,80 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Wed, 21 Dec 2022 12:14:57 +0100
Subject: pua_dialoginfo: use dlg_api.get_dlg_varval()
* rework creating str_list from dlg_var
---
src/modules/pua_dialoginfo/pua_dialoginfo.c | 36 ++++++++++++++---------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
index 94efcef..0fe87e3 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
@@ -574,8 +574,8 @@ struct str_list* get_str_list(unsigned short avp_flags, int_str avp_name) {
struct dlginfo_cell* get_dialog_data(struct dlg_cell *dlg, int type, int disable_caller_publish, int disable_callee_publish)
{
struct dlginfo_cell *dlginfo;
- int len;
- str* s=NULL;
+ int len, len_str_list;
+ str s = STR_NULL;
// generate new random uuid
if(sruid_next_safe(&_puadi_sruid) < 0) {
@@ -651,39 +651,39 @@ struct dlginfo_cell* get_dialog_data(struct dlg_cell *dlg, int type, int disable
} else {
if(caller_dlg_var.len>0
- && (s = dlg_api.get_dlg_varref(dlg, &caller_dlg_var))!=0) {
- dlginfo->pubruris_caller =
- (struct str_list*)shm_malloc(sizeof(struct str_list) + s->len + 1);
+ && dlg_api.get_dlg_varval(dlg, &caller_dlg_var, &s) == 0) {
+ len_str_list = sizeof(struct str_list) + s.len + 1;
+ dlginfo->pubruris_caller = (struct str_list*)shm_malloc(len_str_list);
if (dlginfo->pubruris_caller==0) {
SHM_MEM_ERROR;
free_dlginfo_cell(dlginfo);
return NULL;
}
- memset(dlginfo->pubruris_caller, 0, sizeof(struct str_list));
+ memset(dlginfo->pubruris_caller, 0, len_str_list);
dlginfo->pubruris_caller->s.s = (char*)dlginfo->pubruris_caller
- + sizeof(sizeof(struct str_list));
- memcpy(dlginfo->pubruris_caller->s.s, s->s, s->len);
- dlginfo->pubruris_caller->s.s[s->len] = '\0';
- dlginfo->pubruris_caller->s.len = s->len;
+ + (len_str_list - s.len - 1);
+ memcpy(dlginfo->pubruris_caller->s.s, s.s, s.len);
+ dlginfo->pubruris_caller->s.s[s.len] = '\0';
+ dlginfo->pubruris_caller->s.len = s.len;
LM_DBG("Found pubruris_caller in dialog '%.*s'\n",
dlginfo->pubruris_caller->s.len, dlginfo->pubruris_caller->s.s);
}
if(callee_dlg_var.len>0
- && (s = dlg_api.get_dlg_varref(dlg, &callee_dlg_var))!=0) {
- dlginfo->pubruris_callee =
- (struct str_list*)shm_malloc(sizeof(struct str_list) + s->len + 1);
+ && dlg_api.get_dlg_varval(dlg, &callee_dlg_var, &s) == 0) {
+ len_str_list = sizeof(struct str_list) + s.len + 1;
+ dlginfo->pubruris_callee = (struct str_list*)shm_malloc(len_str_list);
if (dlginfo->pubruris_callee==0) {
SHM_MEM_ERROR;
free_dlginfo_cell(dlginfo);
return NULL;
}
- memset(dlginfo->pubruris_callee, 0, sizeof(struct str_list));
+ memset(dlginfo->pubruris_callee, 0, len_str_list);
dlginfo->pubruris_callee->s.s = (char*)dlginfo->pubruris_callee
- + sizeof(sizeof(struct str_list));
- memcpy(dlginfo->pubruris_callee->s.s, s->s, s->len);
- dlginfo->pubruris_callee->s.s[s->len] = '\0';
- dlginfo->pubruris_callee->s.len = s->len;
+ + (len_str_list - s.len - 1);
+ memcpy(dlginfo->pubruris_callee->s.s, s.s, s.len);
+ dlginfo->pubruris_callee->s.s[s.len] = '\0';
+ dlginfo->pubruris_callee->s.len = s.len;
LM_DBG("Found pubruris_callee in dialog '%.*s'\n",
dlginfo->pubruris_callee->s.len, dlginfo->pubruris_callee->s.s);
}

@ -1,103 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Tue, 30 Jun 2020 09:27:58 +0200
Subject: pua_dialoginfo: use lock when use_puburi_avps is set
---
src/modules/pua_dialoginfo/pua_dialoginfo.c | 21 ++++++++++++++++++---
src/modules/pua_dialoginfo/pua_dialoginfo.h | 2 ++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
index 9d9de31..8848033 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
@@ -353,6 +353,7 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
if(use_pubruri_avps && (refresh_pubruri_avps_flag > -1
|| (request->flags & (1<<refresh_pubruri_avps_flag))))
{
+ lock_get(&dlginfo->lock);
refresh_pubruri_avps(dlginfo, &uri);
}
@@ -496,6 +497,12 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
send_publish_flag==-1?1:0,&(dlginfo->uuid));
}
}
+
+ if(use_pubruri_avps && (refresh_pubruri_avps_flag > -1
+ || (request->flags & (1<<refresh_pubruri_avps_flag))))
+ {
+ lock_release(&dlginfo->lock);
+ }
}
/*
@@ -577,6 +584,12 @@ struct dlginfo_cell* get_dialog_data(struct dlg_cell *dlg, int type, int disable
}
memset( dlginfo, 0, len);
+ if(use_pubruri_avps && lock_init(&dlginfo->lock) == 0) {
+ LM_ERR("cannot init the lock\n");
+ free_dlginfo_cell(dlginfo);
+ return NULL;
+ }
+
/* copy from dlg structure to dlginfo structure */
dlginfo->lifetime = override_lifetime ? override_lifetime : dlg->lifetime;
dlginfo->disable_caller_publish = disable_caller_publish;
@@ -764,20 +777,24 @@ __dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)
if ((!disable_caller_publish) && (disable_caller_publish_flag == -1 || !(request
&& (request->flags & (1<<disable_caller_publish_flag))))) {
+ if(use_pubruri_avps) lock_get(&dlginfo->lock);
dialog_publish_multi("Trying", dlginfo->pubruris_caller,
&identity_local,
&identity_remote,
&(dlg->callid), 1, dlginfo->lifetime,
0, 0, 0, 0, (send_publish_flag==-1)?1:0,&(dlginfo->uuid));
+ if(use_pubruri_avps) lock_release(&dlginfo->lock);
}
if (callee_trying && ((!disable_callee_publish) && (disable_callee_publish_flag == -1 || !(request
&& (request->flags & (1<<disable_callee_publish_flag)))))) {
+ if(use_pubruri_avps) lock_get(&dlginfo->lock);
dialog_publish_multi("Trying", dlginfo->pubruris_callee,
&identity_remote,
&identity_local,
&(dlg->callid), 0, dlginfo->lifetime,
0, 0, 0, 0, (send_publish_flag==-1)?1:0,&(dlginfo->uuid));
+ if(use_pubruri_avps) lock_release(&dlginfo->lock);
}
}
@@ -947,9 +964,7 @@ void free_dlginfo_cell(void *param) {
free_str_list_all(cell->pubruris_caller);
free_str_list_all(cell->pubruris_callee);
- /*if (cell->to_tag) {
- shm_free(cell->to_tag);
- }*/
+ if(use_pubruri_avps) lock_destroy(cell->lock);
shm_free(param);
}
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.h b/src/modules/pua_dialoginfo/pua_dialoginfo.h
index d86799a..0487553 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.h
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.h
@@ -23,6 +23,7 @@
#ifndef _PUA_DLGINFO_H
#define _PUA_DLGINFO_H
+#include "../../core/locking.h"
#include "../pua/pua_bind.h"
extern send_publish_t pua_send_publish;
@@ -35,6 +36,7 @@ void dialog_publish_multi(char *state, struct str_list* ruris, str *entity, str
* dlg_cell during the callback (as this could create a race condition
* if the dlg_cell gets meanwhile deleted) */
struct dlginfo_cell {
+ gen_lock_t lock;
str from_uri;
str to_uri;
str callid;

@ -12,7 +12,7 @@ Subject: pv_headers: rework pvh_remove_header_param, take two
4 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
index 246339f..5afe2dc 100644
index 7561b08..3e9e5a6 100644
--- a/src/modules/pv_headers/pv_headers.c
+++ b/src/modules/pv_headers/pv_headers.c
@@ -223,12 +223,15 @@ static int w_pvh_header_param_exists(
@ -103,7 +103,7 @@ index 918733c..09f70ba 100644
}
diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c
index 8b2acbf..50cac4f 100644
index 4f90808..6f63015 100644
--- a/src/modules/pv_headers/pvh_xavp.c
+++ b/src/modules/pv_headers/pvh_xavp.c
@@ -131,18 +131,18 @@ static sr_xavp_t *pvh_xavi_new_value(str *name, sr_xval_t *val)

@ -7,7 +7,7 @@ Subject: pv_trans_eval_uri
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index a2b546d..3264c7d 100644
index 636d846..1561a55 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -1594,8 +1594,8 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,

@ -97,7 +97,7 @@ index 3d08921..44b354e 100644
#endif // SCA_H
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index d01ab86..1517a35 100644
index e4c9b11..43153ee 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -1138,20 +1138,32 @@ static int sca_call_info_insert_asserted_identity(

@ -47,7 +47,7 @@ index 78ee5d8..dca2421 100644
}
}
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index 419df8c..2eb035e 100644
index abca7d4..6b02041 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -975,6 +975,8 @@ int sca_call_info_invite_request_handler(sip_msg_t *msg,

@ -7,7 +7,7 @@ Subject: sca-fallback-if-no-contact
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index 0617cea..d83fe48 100644
index 414536d..2ded7fc 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -1978,9 +1978,6 @@ int sca_call_info_update(

@ -7,7 +7,7 @@ Subject: sca-fix-notify-after-bye
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index 2eb035e..d01ab86 100644
index 6b02041..e4c9b11 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -714,7 +714,7 @@ static int sca_call_info_uri_update(str *aor, sca_call_info *call_info,

@ -7,7 +7,7 @@ Subject: sca-fix-on-hold-detection-when-upstream-flow
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index ed43fe2..419df8c 100644
index 27335d0..abca7d4 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -948,11 +948,13 @@ int sca_call_info_invite_request_handler(sip_msg_t *msg,

@ -7,7 +7,7 @@ Subject: sca-fix-pickup-when-upstream-flow
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index 8734d3a..ed43fe2 100644
index 0178da8..27335d0 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -947,6 +947,13 @@ int sca_call_info_invite_request_handler(sip_msg_t *msg,

@ -211,7 +211,7 @@ index bd94e14..6ce3112 100644
enum
{
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index c443f23..0617cea 100644
index 838feca..414536d 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -842,44 +842,46 @@ static int sca_call_info_is_line_seize_reinvite(sip_msg_t *msg,

@ -47,7 +47,7 @@ index 7a80847..3d08921 100644
};
typedef struct _sca_mod sca_mod;
diff --git a/src/modules/sca/sca_call_info.c b/src/modules/sca/sca_call_info.c
index d83fe48..8734d3a 100644
index 2ded7fc..0178da8 100644
--- a/src/modules/sca/sca_call_info.c
+++ b/src/modules/sca/sca_call_info.c
@@ -1362,6 +1362,7 @@ void sca_call_info_ack_from_handler(sip_msg_t *msg, str *from_aor, str *to_aor)

@ -1,34 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Fri, 24 Mar 2023 10:26:15 +0100
Subject: app_lua: fix crash on exausted memory scenario
---
src/modules/app_lua/app_lua_api.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/modules/app_lua/app_lua_api.c b/src/modules/app_lua/app_lua_api.c
index 0a1d135..1010fc5 100644
--- a/src/modules/app_lua/app_lua_api.c
+++ b/src/modules/app_lua/app_lua_api.c
@@ -912,6 +912,10 @@ void sr_kemi_lua_push_dict(lua_State *L, sr_kemi_dict_item_t *item) {
void
sr_kemi_lua_push_dict_item(lua_State *L, sr_kemi_dict_item_t *item)
{
+ if(!item) {
+ LM_CRIT("BUG: dict field empty\n");
+ return;
+ }
switch(item->vtype) {
case SR_KEMIP_NONE:
LM_CRIT("BUG: vtype is NONE\n");
@@ -951,6 +955,10 @@ sr_kemi_lua_push_dict_item(lua_State *L, sr_kemi_dict_item_t *item)
*/
int sr_kemi_lua_return_xval(lua_State* L, sr_kemi_t *ket, sr_kemi_xval_t *rx)
{
+ if(!rx) {
+ LM_CRIT("BUG: xval field empty\n");
+ return 0;
+ }
switch(rx->vtype) {
case SR_KEMIP_NONE:
return 0;

@ -1,86 +0,0 @@
From: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Fri, 27 May 2022 16:58:28 +0200
Subject: [PATCH] dialog: dlg_get_var assure return null on error
---
src/modules/dialog/dialog.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 628dc4d..61bf03b 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1573,53 +1573,62 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
str k = STR_NULL;
str *val = NULL;
pv_value_t dst_val;
- pv_spec_t* dst_pv;
+ pv_spec_t* dst_pv = (pv_spec_t *)pv;
if(ci==0 || ft==0 || tt==0)
{
LM_ERR("invalid parameters\n");
- return -1;
+ goto error;
}
if(fixup_get_svalue(msg, (gparam_p)ci, &sc)!=0)
{
LM_ERR("unable to get Call-ID\n");
- return -1;
+ goto error;
}
if(fixup_get_svalue(msg, (gparam_p)ft, &sf)!=0)
{
LM_ERR("unable to get From tag\n");
- return -1;
+ goto error;
}
if(fixup_get_svalue(msg, (gparam_p)tt, &st)!=0)
{
LM_ERR("unable to get To Tag\n");
- return -1;
+ goto error;
}
if(st.s==NULL || st.len == 0)
{
LM_ERR("invalid To tag parameter\n");
- return -1;
+ goto error;
}
if(fixup_get_svalue(msg, (gparam_p)key, &k)!=0)
{
LM_ERR("unable to get key name\n");
- return -1;
+ goto error;
}
- dst_pv = (pv_spec_t *)pv;
- val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
+ val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
if(val) {
memset(&dst_val, 0, sizeof(pv_value_t));
dst_val.flags |= PV_VAL_STR;
dst_val.rs.s = val->s;
dst_val.rs.len = val->len;
- if(pv_set_spec_value(msg, dst_pv, 0, &dst_val) != 0) return -1;
} else {
- if(pv_get_null(msg, NULL, &dst_val) != 0) return -1;
+ pv_get_null(msg, NULL, &dst_val);
+ }
+ if(pv_set_spec_value(msg, dst_pv, 0, &dst_val) != 0) {
+ LM_ERR("unable to set value to dst_pv\n");
+ if(val) goto error; else return -1;
}
return 1;
+
+error:
+ pv_get_null(msg, NULL, &dst_val);
+ if(pv_set_spec_value(msg, dst_pv, 0, &dst_val) != 0) {
+ LM_ERR("unable to set null value to dst_pv\n");
+ }
+ return -1;
}
static int fixup_dlg_get_var(void** param, int param_no)

@ -1,213 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Fri, 6 May 2022 13:30:01 +0200
Subject: [PATCH] dialog: dlg_get_var(ci, ft, tt, key, dst_var)
---
src/modules/dialog/dialog.c | 113 +++++++++++++++++++++++++++++++-
src/modules/dialog/doc/dialog_admin.xml | 48 ++++++++++++++
2 files changed, 160 insertions(+), 1 deletion(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 9f9f647..25584b5 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -194,7 +194,9 @@ static int w_is_known_dlg(struct sip_msg *);
static int w_dlg_set_ruri(sip_msg_t *, char *, char *);
static int w_dlg_db_load_callid(sip_msg_t *msg, char *ci, char *p2);
static int w_dlg_db_load_extra(sip_msg_t *msg, char *p1, char *p2);
-
+static int fixup_dlg_get_var(void** param, int param_no);
+static int fixup_dlg_get_var_free(void** param, int param_no);
+static int w_dlg_get_var(struct sip_msg*, char*, char*, char*, char*, char*);
static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname,
char *pval, char *puid, char *expires);
static int fixup_dlg_remote_profile(void** param, int param_no);
@@ -256,6 +258,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"dlg_db_load_extra", (cmd_function)w_dlg_db_load_extra, 0, 0,
0, ANY_ROUTE },
+ {"dlg_get_var",(cmd_function)w_dlg_get_var, 5, fixup_dlg_get_var,
+ fixup_dlg_get_var_free, ANY_ROUTE },
{"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0},
{0,0,0,0,0,0}
@@ -1505,6 +1509,108 @@ static int fixup_dlg_bridge(void** param, int param_no)
return 0;
}
+static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
+{
+ dlg_cell_t *dlg = NULL;
+ unsigned int dir = 0;
+ str *val = NULL;
+
+ if(sc==NULL || sc->s==NULL || sc->len == 0) {
+ LM_ERR("invalid Call-ID parameter\n");
+ return val;
+ }
+ if(sf==NULL || sf->s==NULL || sf->len == 0) {
+ LM_ERR("invalid From tag parameter\n");
+ return val;
+ }
+ if(st==NULL || st->s==NULL || st->len == 0) {
+ LM_ERR("invalid To tag parameter\n");
+ return val;
+ }
+
+ dlg = get_dlg(sc, sf, st, &dir);
+ if(dlg==NULL)
+ return val;
+ val = get_dlg_variable(dlg, key);
+ dlg_release(dlg);
+ return val;
+}
+
+static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key, char *pv)
+{
+ str sc = STR_NULL;
+ str sf = STR_NULL;
+ str st = STR_NULL;
+ str k = STR_NULL;
+ str *val = NULL;
+ pv_value_t dst_val;
+ pv_spec_t* dst_pv;
+
+ if(ci==0 || ft==0 || tt==0)
+ {
+ LM_ERR("invalid parameters\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)ci, &sc)!=0)
+ {
+ LM_ERR("unable to get Call-ID\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)ft, &sf)!=0)
+ {
+ LM_ERR("unable to get From tag\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)tt, &st)!=0)
+ {
+ LM_ERR("unable to get To Tag\n");
+ return -1;
+ }
+ if(st.s==NULL || st.len == 0)
+ {
+ LM_ERR("invalid To tag parameter\n");
+ return -1;
+ }
+ if(fixup_get_svalue(msg, (gparam_p)key, &k)!=0)
+ {
+ LM_ERR("unable to get key name\n");
+ return -1;
+ }
+ dst_pv = (pv_spec_t *)pv;
+ val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
+ if(val) {
+ memset(&dst_val, 0, sizeof(pv_value_t));
+ dst_val.flags |= PV_VAL_STR;
+ dst_val.rs.s = val->s;
+ dst_val.rs.len = val->len;
+ if(pv_set_spec_value(msg, dst_pv, 0, &dst_val) != 0) return -1;
+ } else {
+ if(pv_get_null(msg, NULL, &dst_val) != 0) return -1;
+ }
+ return 1;
+}
+
+static int fixup_dlg_get_var(void** param, int param_no)
+{
+ if(param_no>=1 && param_no<=4)
+ return fixup_spve_null(param, 1);
+ if(param_no==5)
+ return fixup_pvar_all(param, 1);
+ return 0;
+}
+
+static int fixup_dlg_get_var_free(void** param, int param_no)
+{
+ if (param_no <= 4)
+ return fixup_free_spve_null(param, 1);
+ if (param_no == 5)
+ return fixup_free_pvar_all(param, 1);
+ return -1;
+}
+
static int ki_dlg_get(sip_msg_t *msg, str *sc, str *sf, str *st)
{
dlg_cell_t *dlg = NULL;
@@ -2090,6 +2196,11 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("dialog"), str_init("dlg_get_var"),
+ SR_KEMIP_STR, ki_dlg_get_var,
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
+ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("dialog"), str_init("set_dlg_profile_static"),
SR_KEMIP_INT, ki_set_dlg_profile_static,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
diff --git a/src/modules/dialog/doc/dialog_admin.xml b/src/modules/dialog/doc/dialog_admin.xml
index 51faa16..9f20125 100644
--- a/src/modules/dialog/doc/dialog_admin.xml
+++ b/src/modules/dialog/doc/dialog_admin.xml
@@ -2103,6 +2103,54 @@ if(dlg_get("abcdef", "123", "456"))
</example>
</section>
+ <section id="dialog.f.dlg_get_var">
+ <title>
+ <function moreinfo="none">dlg_get_var(callid, ftag, ttag, name, dst)</function>
+ </title>
+ <para>
+ Get dlg_var of another dialog value based on Call-ID, From-Tag and To-Tag
+ parameters.
+ </para>
+ <para>Meaning of the parameters is as follows:</para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>callid</emphasis> - SIP call-id.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>ftag</emphasis> - SIP From tag.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>ttag</emphasis> - SIP To tag.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>name</emphasis> - key name of the $dlg_var.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>dst</emphasis> - pv to store the value of $dlg_var(name).
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ This function can be used from BRANCH_ROUTE,
+ REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
+ </para>
+ <example>
+ <title><function>dlg_get_var</function> usage</title>
+ <programlisting format="linespecific">
+...
+if(dlg_get_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
+{
+ xdbg("$$dlg_var(test):$var(tmp)\n");
+}
+...
+</programlisting>
+ </example>
+ </section>
+
<section id="dialog.f.is_known_dlg">
<title>
<function moreinfo="none">is_known_dlg()</function>

@ -1,200 +0,0 @@
From: Victor Seva <vseva@sipwise.com>
Date: Wed, 11 May 2022 15:50:14 +0200
Subject: [PATCH] dialog: dlg_set_var(callid, ft, tt, key, value)
---
src/modules/dialog/dialog.c | 100 ++++++++++++++++++++++++++++++++
src/modules/dialog/doc/dialog_admin.xml | 48 +++++++++++++++
2 files changed, 148 insertions(+)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 25584b5..fec9f5e 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -197,6 +197,9 @@ static int w_dlg_db_load_extra(sip_msg_t *msg, char *p1, char *p2);
static int fixup_dlg_get_var(void** param, int param_no);
static int fixup_dlg_get_var_free(void** param, int param_no);
static int w_dlg_get_var(struct sip_msg*, char*, char*, char*, char*, char*);
+static int fixup_dlg_set_var(void** param, int param_no);
+static int fixup_dlg_set_var_free(void** param, int param_no);
+static int w_dlg_set_var(struct sip_msg*, char*, char*, char*, char*, char*);
static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname,
char *pval, char *puid, char *expires);
static int fixup_dlg_remote_profile(void** param, int param_no);
@@ -260,6 +263,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"dlg_get_var",(cmd_function)w_dlg_get_var, 5, fixup_dlg_get_var,
fixup_dlg_get_var_free, ANY_ROUTE },
+ {"dlg_set_var",(cmd_function)w_dlg_set_var, 5, fixup_dlg_set_var,
+ fixup_dlg_set_var_free, ANY_ROUTE },
{"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0},
{0,0,0,0,0,0}
@@ -1611,6 +1616,96 @@ static int fixup_dlg_get_var_free(void** param, int param_no)
return -1;
}
+static int ki_dlg_set_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key, str *val)
+{
+ dlg_cell_t *dlg = NULL;
+ unsigned int dir = 0;
+ int ret = 1;
+
+ if(sc==NULL || sc->s==NULL || sc->len == 0) {
+ LM_ERR("invalid Call-ID parameter\n");
+ return -1;
+ }
+ if(sf==NULL || sf->s==NULL || sf->len == 0) {
+ LM_ERR("invalid From tag parameter\n");
+ return -1;
+ }
+ if(st==NULL || st->s==NULL || st->len == 0) {
+ LM_ERR("invalid To tag parameter\n");
+ return -1;
+ }
+
+ dlg = get_dlg(sc, sf, st, &dir);
+ if(dlg==NULL)
+ return -1;
+ if(set_dlg_variable(dlg, key, val) != 0) ret = -1;
+ dlg_release(dlg);
+ return ret;
+}
+
+static int w_dlg_set_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key, char *val)
+{
+ str sc = STR_NULL;
+ str sf = STR_NULL;
+ str st = STR_NULL;
+ str k = STR_NULL;
+ str v = STR_NULL;
+
+ if(ci==0 || ft==0 || tt==0)
+ {
+ LM_ERR("invalid parameters\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)ci, &sc)!=0)
+ {
+ LM_ERR("unable to get Call-ID\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)ft, &sf)!=0)
+ {
+ LM_ERR("unable to get From tag\n");
+ return -1;
+ }
+
+ if(fixup_get_svalue(msg, (gparam_p)tt, &st)!=0)
+ {
+ LM_ERR("unable to get To Tag\n");
+ return -1;
+ }
+ if(st.s==NULL || st.len == 0)
+ {
+ LM_ERR("invalid To tag parameter\n");
+ return -1;
+ }
+ if(fixup_get_svalue(msg, (gparam_p)key, &k)!=0)
+ {
+ LM_ERR("unable to get key name\n");
+ return -1;
+ }
+ if(fixup_get_svalue(msg, (gparam_p)val, &v)!=0)
+ {
+ LM_ERR("unable to get value\n");
+ return -1;
+ }
+ return ki_dlg_set_var(msg, &sc, &sf, &st, &k, &v);
+}
+
+static int fixup_dlg_set_var(void** param, int param_no)
+{
+ if(param_no>=1 && param_no<=5)
+ return fixup_spve_null(param, 1);
+ return 0;
+}
+
+static int fixup_dlg_set_var_free(void** param, int param_no)
+{
+ if (param_no <= 5)
+ return fixup_free_spve_null(param, 1);
+ return -1;
+}
+
static int ki_dlg_get(sip_msg_t *msg, str *sc, str *sf, str *st)
{
dlg_cell_t *dlg = NULL;
@@ -2201,6 +2296,11 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("dialog"), str_init("dlg_set_var"),
+ SR_KEMIP_INT, ki_dlg_set_var,
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
+ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE }
+ },
{ str_init("dialog"), str_init("set_dlg_profile_static"),
SR_KEMIP_INT, ki_set_dlg_profile_static,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
diff --git a/src/modules/dialog/doc/dialog_admin.xml b/src/modules/dialog/doc/dialog_admin.xml
index 9f20125..23ca1fb 100644
--- a/src/modules/dialog/doc/dialog_admin.xml
+++ b/src/modules/dialog/doc/dialog_admin.xml
@@ -2151,6 +2151,54 @@ if(dlg_get_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
</example>
</section>
+ <section id="dialog.f.dlg_set_var">
+ <title>
+ <function moreinfo="none">dlg_set_var(callid, ftag, ttag, name, value)</function>
+ </title>
+ <para>
+ Set dlg_var of another dialog value based on Call-ID, From-Tag and To-Tag
+ parameters.
+ </para>
+ <para>Meaning of the parameters is as follows:</para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>callid</emphasis> - SIP call-id.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>ftag</emphasis> - SIP From tag.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>ttag</emphasis> - SIP To tag.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>name</emphasis> - key name of the $dlg_var.
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>value</emphasis> - string value to store at $dlg_var(name).
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ This function can be used from BRANCH_ROUTE,
+ REQUEST_ROUTE, ONREPLY_ROUTE and FAILURE_ROUTE.
+ </para>
+ <example>
+ <title><function>dlg_set_var</function> usage</title>
+ <programlisting format="linespecific">
+...
+if(dlg_set_var("$var(ci)", "$var(ft)", "456", "test", "$var(tmp)"))
+{
+ xdbg("set $$dlg_var(test):$var(tmp)\n");
+}
+...
+</programlisting>
+ </example>
+ </section>
+
<section id="dialog.f.is_known_dlg">
<title>
<function moreinfo="none">is_known_dlg()</function>

@ -1,29 +0,0 @@
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Sat, 21 May 2022 08:21:49 +0200
Subject: [PATCH] dialog: fix ki_dlg_get_var() introduced previously
---
src/modules/dialog/dialog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 623db59..628dc4d 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1552,14 +1552,14 @@ static sr_kemi_xval_t *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st,
memset(&_sr_kemi_dialog_xval, 0, sizeof(sr_kemi_xval_t));
- val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
+ val = ki_dlg_get_var_helper(msg, sc, sf, st, key);
if(!val) {
sr_kemi_xval_null(&_sr_kemi_dialog_xval, SR_KEMI_XVAL_NULL_NONE);
return &_sr_kemi_dialog_xval;
}
_sr_kemi_dialog_xval.vtype = SR_KEMIP_STR;
- _sr_kemi_dialog_xval.v.s = *pval;
+ _sr_kemi_dialog_xval.v.s = *val;
return &_sr_kemi_dialog_xval;

@ -1,83 +0,0 @@
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Fri, 20 May 2022 16:07:56 +0200
Subject: [PATCH] dialog: reworked kemi export for dlg_get_var()
- return SR_KEMIP_XVAL type
---
src/modules/dialog/dialog.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index fec9f5e..623db59 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1514,7 +1514,7 @@ static int fixup_dlg_bridge(void** param, int param_no)
return 0;
}
-static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
+static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
{
dlg_cell_t *dlg = NULL;
unsigned int dir = 0;
@@ -1541,6 +1541,30 @@ static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
return val;
}
+/**
+ *
+ */
+static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
+
+static sr_kemi_xval_t *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
+{
+ str *val = NULL;
+
+ memset(&_sr_kemi_dialog_xval, 0, sizeof(sr_kemi_xval_t));
+
+ val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
+ if(!val) {
+ sr_kemi_xval_null(&_sr_kemi_dialog_xval, SR_KEMI_XVAL_NULL_NONE);
+ return &_sr_kemi_dialog_xval;
+ }
+
+ _sr_kemi_dialog_xval.vtype = SR_KEMIP_STR;
+ _sr_kemi_dialog_xval.v.s = *pval;
+
+ return &_sr_kemi_dialog_xval;
+
+}
+
static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key, char *pv)
{
str sc = STR_NULL;
@@ -1585,7 +1609,7 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
return -1;
}
dst_pv = (pv_spec_t *)pv;
- val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
+ val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
if(val) {
memset(&dst_val, 0, sizeof(pv_value_t));
dst_val.flags |= PV_VAL_STR;
@@ -2158,11 +2182,6 @@ static int ki_dlg_var_sets(sip_msg_t *msg, str *name, str *val)
return (ret==0)?1:ret;
}
-/**
- *
- */
-static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
-
/**
*
*/
@@ -2292,7 +2311,7 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("dialog"), str_init("dlg_get_var"),
- SR_KEMIP_STR, ki_dlg_get_var,
+ SR_KEMIP_XVAL, ki_dlg_get_var,
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
},

@ -1,40 +0,0 @@
From: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Fri, 27 May 2022 17:18:01 +0200
Subject: [PATCH] dialog: w_dlg_get_var, fix incompatible pointer
> CC (gcc) [M dialog.so] dialog.o
> dialog.c: In function 'w_dlg_get_var': dialog.c:1608:6: warning: assignment to 'str *' {aka 'struct _str *'} from incompatible pointer type 'sr_kemi_xval_t *' {aka 'struct sr_kemi_xval *'} [-Wincompatible-pointer-types]
> 1608 | val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
> | ^
---
src/modules/dialog/dialog.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index 61bf03b..6545444 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1571,7 +1571,7 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
str sf = STR_NULL;
str st = STR_NULL;
str k = STR_NULL;
- str *val = NULL;
+ sr_kemi_xval_t *val = NULL;
pv_value_t dst_val;
pv_spec_t* dst_pv = (pv_spec_t *)pv;
@@ -1609,11 +1609,11 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
goto error;
}
val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
- if(val) {
+ if(val && val->vtype == SR_KEMIP_STR) {
memset(&dst_val, 0, sizeof(pv_value_t));
dst_val.flags |= PV_VAL_STR;
- dst_val.rs.s = val->s;
- dst_val.rs.len = val->len;
+ dst_val.rs.s = val->v.s.s;
+ dst_val.rs.len = val->v.s.len;
} else {
pv_get_null(msg, NULL, &dst_val);
}

@ -1,68 +0,0 @@
From: Alessio Garzi <agarzi@sipwise.com>
Date: Thu, 7 Jul 2022 15:22:12 +0200
Subject: [PATCH] presence: No autocommit+rollback if no active watchers
- In case the active_watcher query returns no elements there
is a weird situation where kamailio first runs the select for
active_watcher then rollbacks.
This can happen a lot of times for each second since function
process_dialogs() runs repeatedly.
For this reason trying to avoid the rollback can result
in a quite good performance boost.
---
src/modules/presence/notify.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/modules/presence/notify.c b/src/modules/presence/notify.c
index cf52c21..4980dc4 100644
--- a/src/modules/presence/notify.c
+++ b/src/modules/presence/notify.c
@@ -2867,6 +2867,7 @@ int process_dialogs(int round, int presence_winfo)
str ev_sname, winfo = str_init("presence.winfo");
int now = (int)time(NULL);
int updated = 0;
+ int no_active_watchers = 0;
db_query_f query_fn = pa_dbf.query_lock ? pa_dbf.query_lock : pa_dbf.query;
query_cols[n_query_cols] = &str_updated_col;
@@ -2900,13 +2901,6 @@ int process_dialogs(int round, int presence_winfo)
goto error;
}
- if(pa_dbf.start_transaction) {
- if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
- LM_ERR("in start_transaction\n");
- goto error;
- }
- }
-
/* Step 1: Find active_watchers that require notification */
if(query_fn(pa_db, query_cols, query_ops, query_vals, result_cols,
n_query_cols, n_result_cols, 0, &dialog_list)
@@ -2920,7 +2914,17 @@ int process_dialogs(int round, int presence_winfo)
}
if(dialog_list->n <= 0)
+ {
+ no_active_watchers = 1;
goto done;
+ }
+
+ if(pa_dbf.start_transaction) {
+ if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
+ LM_ERR("in start_transaction\n");
+ goto error;
+ }
+ }
/* Step 2: Update the records so they are not notified again */
if(pa_dbf.update(pa_db, query_cols, query_ops, query_vals, update_cols,
@@ -3164,7 +3168,7 @@ error:
if(dialog)
pa_dbf.free_result(pa_db, dialog);
- if(pa_dbf.abort_transaction) {
+ if(no_active_watchers == 0 && pa_dbf.abort_transaction) {
if(pa_dbf.abort_transaction(pa_db) < 0)
LM_ERR("in abort_transaction\n");
}

@ -1,30 +0,0 @@
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue, 30 Aug 2022 10:58:39 +0200
Subject: [PATCH] pv_headers: use t_unset() based on vref instead of resetting
global t always
---
src/modules/pv_headers/pv_headers.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
index d713611..246339f 100644
--- a/src/modules/pv_headers/pv_headers.c
+++ b/src/modules/pv_headers/pv_headers.c
@@ -604,12 +604,12 @@ int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
xavi_set_list(backup_xavis);
LM_DBG("restored backup_xavis:%p\n", *backup_xavis);
}
- if(t && vref) {
- tmb.unref_cell(t);
+ if(t != NULL && t != T_UNDEFINED && vref != 0) {
+ /* t_find() above has the side effect of setting T and
+ REFerencing T => we must unref and unset it */
+ tmb.t_unset();
LM_DBG("T:%p unref\n", t);
}
- tmb.t_sett(T_UNDEFINED, T_BR_UNDEFINED);
- LM_DBG("reset tm\n");
return 1;
}

@ -1,54 +0,0 @@
From: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Sun, 28 Aug 2022 22:59:44 +0200
Subject: [PATCH] pv_headers: use tm.t_find API
---
src/modules/pv_headers/pv_headers.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/modules/pv_headers/pv_headers.c b/src/modules/pv_headers/pv_headers.c
index 3648335..d713611 100644
--- a/src/modules/pv_headers/pv_headers.c
+++ b/src/modules/pv_headers/pv_headers.c
@@ -571,6 +571,7 @@ int handle_msg_branch_cb(struct sip_msg *msg, unsigned int flags, void *cb)
int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
{
+ int vref = 0;
tm_cell_t *t = NULL;
sr_xavp_t **backup_xavis = NULL;
sr_xavp_t **list = NULL;
@@ -583,18 +584,12 @@ int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
LM_DBG("msg:%p previous branch:%d\n", msg, _branch);
print_cb_flags(flags);
- if(tmb.t_check(msg, &_branch) == -1) {
- LM_ERR("failed find UAC branch\n");
- } else {
- t = tmb.t_gett();
- if(t == NULL || t == T_UNDEFINED) {
- LM_DBG("cannot lookup the transaction\n");
- } else {
- LM_DBG("T:%p t_check-branch:%d xavi_list:%p branches:%d\n", t,
- _branch, &t->xavis_list, t->nr_of_outgoings);
- list = &t->xavis_list;
- backup_xavis = xavi_set_list(&t->xavis_list);
- }
+ t = tmb.t_find(msg, &_branch, &vref);
+ if(t != NULL && t != T_UNDEFINED) {
+ LM_DBG("T:%p t_check-branch:%d xavi_list:%p branches:%d\n", t,
+ _branch, &t->xavis_list, t->nr_of_outgoings);
+ list = &t->xavis_list;
+ backup_xavis = xavi_set_list(&t->xavis_list);
}
pvh_get_branch_index(msg, &_branch);
@@ -609,7 +604,7 @@ int handle_msg_reply_cb(struct sip_msg *msg, unsigned int flags, void *cb)
xavi_set_list(backup_xavis);
LM_DBG("restored backup_xavis:%p\n", *backup_xavis);
}
- if(t) {
+ if(t && vref) {
tmb.unref_cell(t);
LM_DBG("T:%p unref\n", t);
}

@ -1,76 +0,0 @@
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue, 30 Aug 2022 10:53:15 +0200
Subject: [PATCH] tm: added t_unset() intermodule API function
- reset global t and branch without releasing the transaction
- useful for cases when global t needs to be set in callbacks and then
reset before config execution is finished
---
src/modules/tm/t_lookup.c | 13 +++++++++++++
src/modules/tm/t_lookup.h | 3 +++
src/modules/tm/tm_load.c | 1 +
src/modules/tm/tm_load.h | 1 +
4 files changed, 18 insertions(+)
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
index 09063c1..4936c30 100644
--- a/src/modules/tm/t_lookup.c
+++ b/src/modules/tm/t_lookup.c
@@ -167,6 +167,19 @@ struct cell* t_find(struct sip_msg *msg, int *branch, int *vref)
return T;
}
+/**
+ * unref and reset T globals
+ */
+void t_unset(void)
+{
+ if(T == NULL || T == T_UNDEFINED) {
+ return;
+ }
+
+ UNREF( T );
+ set_t(T_UNDEFINED, T_BR_UNDEFINED);
+}
+
static inline int parse_dlg( struct sip_msg *msg )
{
if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
diff --git a/src/modules/tm/t_lookup.h b/src/modules/tm/t_lookup.h
index de65be8..c4b5404 100644
--- a/src/modules/tm/t_lookup.h
+++ b/src/modules/tm/t_lookup.h
@@ -71,6 +71,9 @@ struct cell *get_t(void);
typedef struct cell* (*tfind_f)(struct sip_msg*, int*, int*);
struct cell* t_find(struct sip_msg *msg, int *branch, int *vref);
+typedef void (*tunset_f)(void);
+void t_unset(void);
+
typedef int (*tgett_branch_f)(void);
int get_t_branch(void);
diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c
index c9f39b5..d5fc6e7 100644
--- a/src/modules/tm/tm_load.c
+++ b/src/modules/tm/tm_load.c
@@ -93,6 +93,7 @@ int load_tm( struct tm_binds *tmb)
tmb->print_dlg = print_dlg;
tmb->t_gett = get_t;
tmb->t_find = t_find;
+ tmb->t_unset = t_unset;
tmb->t_gett_branch = get_t_branch;
tmb->t_sett = set_t;
tmb->calculate_hooks = w_calculate_hooks;
diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h
index 1f97061..130d015 100644
--- a/src/modules/tm/tm_load.h
+++ b/src/modules/tm/tm_load.h
@@ -72,6 +72,7 @@ struct tm_binds {
print_dlg_f print_dlg;
tgett_f t_gett;
tfind_f t_find;
+ tunset_f t_unset;
tgett_branch_f t_gett_branch;
tsett_f t_sett;
calculate_hooks_f calculate_hooks;

@ -1,84 +0,0 @@
From: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu, 25 Aug 2022 14:51:23 +0200
Subject: [PATCH] tm: new inter-module API function t_find(...)
- combines get_t() with t_check_msg(...) to get the transaction,
returning also if it was referenced or not
---
src/modules/tm/t_lookup.c | 22 ++++++++++++++++++++++
src/modules/tm/t_lookup.h | 3 +++
src/modules/tm/tm_load.c | 1 +
src/modules/tm/tm_load.h | 1 +
4 files changed, 27 insertions(+)
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c
index bc3dd5e..09063c1 100644
--- a/src/modules/tm/t_lookup.c
+++ b/src/modules/tm/t_lookup.c
@@ -145,6 +145,28 @@ int get_t_branch()
return T_branch;
}
+/**
+ * return the transaction by combining get() and t_check_msg()
+ * - if T is not set, checks the transactions table for msg, and if found,
+ * sets T and *branch as well as *vref=1 to signal that T was ref'ed
+ */
+struct cell* t_find(struct sip_msg *msg, int *branch, int *vref)
+{
+ if(vref) {
+ *vref = 0;
+ }
+ if(T != NULL && T != T_UNDEFINED) {
+ return T;
+ }
+ t_check_msg(msg, branch);
+ if(T != NULL && T != T_UNDEFINED) {
+ if(vref) {
+ *vref = 1;
+ }
+ }
+ return T;
+}
+
static inline int parse_dlg( struct sip_msg *msg )
{
if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
diff --git a/src/modules/tm/t_lookup.h b/src/modules/tm/t_lookup.h
index 1f6596a..de65be8 100644
--- a/src/modules/tm/t_lookup.h
+++ b/src/modules/tm/t_lookup.h
@@ -68,6 +68,9 @@ int t_check_msg(struct sip_msg* , int *branch );
typedef struct cell * (*tgett_f)(void);
struct cell *get_t(void);
+typedef struct cell* (*tfind_f)(struct sip_msg*, int*, int*);
+struct cell* t_find(struct sip_msg *msg, int *branch, int *vref);
+
typedef int (*tgett_branch_f)(void);
int get_t_branch(void);
diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c
index 8635b90..c9f39b5 100644
--- a/src/modules/tm/tm_load.c
+++ b/src/modules/tm/tm_load.c
@@ -92,6 +92,7 @@ int load_tm( struct tm_binds *tmb)
tmb->free_dlg = free_dlg;
tmb->print_dlg = print_dlg;
tmb->t_gett = get_t;
+ tmb->t_find = t_find;
tmb->t_gett_branch = get_t_branch;
tmb->t_sett = set_t;
tmb->calculate_hooks = w_calculate_hooks;
diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h
index 4695a8f..1f97061 100644
--- a/src/modules/tm/tm_load.h
+++ b/src/modules/tm/tm_load.h
@@ -71,6 +71,7 @@ struct tm_binds {
free_dlg_f free_dlg;
print_dlg_f print_dlg;
tgett_f t_gett;
+ tfind_f t_find;
tgett_branch_f t_gett_branch;
tsett_f t_sett;
calculate_hooks_f calculate_hooks;
Loading…
Cancel
Save