mirror of https://github.com/sipwise/kamailio.git
Change-Id: I0d28912430c510c3124a2822571f20cbe242893emr11.4
parent
4af71051b0
commit
73245bcbac
@ -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
|
@ -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");
|
@ -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;
|
@ -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…
Reference in new issue