mirror of https://github.com/sipwise/kamailio.git
* support refreshing info after dlg_manage() is called via a new flag Find the callee is been resolved way after in our config * control local identity value via dlg_var Change-Id: I6c9781626944c427693a30ed0e67d32cc582a714changes/39/37739/12
parent
1df27e5bd0
commit
284dcffe14
@ -0,0 +1,88 @@
|
||||
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 | 20 ++++++++++++++++++++
|
||||
src/modules/pua_dialoginfo/pua_dialoginfo.c | 17 +++++++++++++++++
|
||||
2 files changed, 37 insertions(+)
|
||||
|
||||
diff --git a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
|
||||
index 3054a77..fc0efd6 100644
|
||||
--- a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
|
||||
+++ b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
|
||||
@@ -535,6 +535,26 @@ modparam("pua_dialoginfo", "callee_trying", 1)
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
||||
+
|
||||
+ <section>
|
||||
+ <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>
|
||||
|
||||
<section>
|
||||
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
index 2e25386..c70ea02 100644
|
||||
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
@@ -82,6 +82,7 @@ int_str pubruri_callee_avp_name;
|
||||
|
||||
static str caller_dlg_var = {0, 0}; /* pubruri_caller */
|
||||
static str callee_dlg_var = {0, 0}; /* pubruri_callee */
|
||||
+static str local_identity_dlg_var = STR_NULL;
|
||||
|
||||
/* Module parameter variables */
|
||||
int include_callid = DEF_INCLUDE_CALLID;
|
||||
@@ -124,6 +125,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 },
|
||||
@@ -300,6 +302,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_var(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)
|
||||
{
|
||||
@@ -328,6 +341,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:
|
||||
@ -0,0 +1,167 @@
|
||||
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 eda5562..3054a77 100644
|
||||
--- a/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
|
||||
+++ b/src/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml
|
||||
@@ -414,7 +414,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> (int)</title>
|
||||
<para>
|
||||
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c b/src/modules/pua_dialoginfo/pua_dialoginfo.c
|
||||
index f393249..2e25386 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 "../dialog/dlg_load.h"
|
||||
#include "../dialog/dlg_hash.h"
|
||||
#include "../pua/pua_bind.h"
|
||||
@@ -58,6 +59,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
|
||||
@@ -90,6 +92,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;
|
||||
@@ -116,6 +119,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 },
|
||||
@@ -244,6 +248,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);
|
||||
+ 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);
|
||||
+ 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)
|
||||
{
|
||||
@@ -266,6 +322,12 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
|
||||
uri = dlginfo->to_uri;
|
||||
}
|
||||
|
||||
+ 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:
|
||||
@@ -784,6 +846,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;
|
||||
Loading…
Reference in new issue