mirror of https://github.com/sipwise/kamailio.git
Change-Id: I2c2a3e202392b2b98b308872d47c2c40989f1defchanges/92/2692/2
parent
a47aa4fc0e
commit
ef0516bb8b
@ -0,0 +1,162 @@
|
||||
From 7976aff5b9d49cd3d418b4668c02d5036297c646 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Thu, 17 Sep 2015 18:07:43 +0200
|
||||
Subject: [PATCH] registar: add contact and recieved values to xavp_rcd
|
||||
|
||||
set xavp_rcd at registered() too
|
||||
---
|
||||
modules/registrar/doc/registrar_admin.xml | 26 ++++++++++--
|
||||
modules/registrar/lookup.c | 69 ++++++++++++++++++++++---------
|
||||
2 files changed, 72 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/modules/registrar/doc/registrar_admin.xml b/modules/registrar/doc/registrar_admin.xml
|
||||
index f1c7063..8a9479d 100644
|
||||
--- a/modules/registrar/doc/registrar_admin.xml
|
||||
+++ b/modules/registrar/doc/registrar_admin.xml
|
||||
@@ -739,7 +739,7 @@ modparam("registrar", "xavp_cfg", "reg")
|
||||
<para>
|
||||
Defines the name of XAVP class to store details from the
|
||||
location records. The values are stored as inner XAVPs, like
|
||||
- $xavp(class=>attribute). Valid inner XAVP names:
|
||||
+ $xavp(class[0]=>attribute). Valid inner XAVP names:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
@@ -748,11 +748,31 @@ modparam("registrar", "xavp_cfg", "reg")
|
||||
id.
|
||||
</para>
|
||||
</listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ <emphasis>contact</emphasis> - the record's contact value.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ <emphasis>received</emphasis> - the record's received value.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
- For example. if this parameter is set to 'ulrcd', then the ruid
|
||||
- for contact records are set in $xavp(ulrcd=>ruid).
|
||||
+ For example. if this parameter is set to 'ulrcd', then values are set in:
|
||||
</para>
|
||||
+ <itemizedlist>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>ruid)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>contact)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>received)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ </itemizedlist>
|
||||
<para>
|
||||
<emphasis>
|
||||
Default value is NULL (disabled).
|
||||
diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
|
||||
index 6fb170b..b8cf92a 100644
|
||||
--- a/modules/registrar/lookup.c
|
||||
+++ b/modules/registrar/lookup.c
|
||||
@@ -93,6 +93,52 @@ int lookup_to_dset(struct sip_msg* _m, udomain_t* _d, str* _uri) {
|
||||
}
|
||||
|
||||
/*! \brief
|
||||
+ * add xavp with details of the record (ruid, ...)
|
||||
+ */
|
||||
+int xavp_rcd_helper(ucontact_t* ptr) {
|
||||
+ sr_xavp_t *xavp=NULL;
|
||||
+ sr_xavp_t *list=NULL;
|
||||
+ str xname_ruid = {"ruid", 4};
|
||||
+ str xname_received = { "received", 8};
|
||||
+ str xname_contact = { "contact", 7};
|
||||
+ sr_xval_t xval;
|
||||
+
|
||||
+ if(ptr==NULL) return -1;
|
||||
+
|
||||
+ if(reg_xavp_rcd.s!=NULL)
|
||||
+ {
|
||||
+ list = xavp_get(®_xavp_rcd, NULL);
|
||||
+ xavp = list;
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->ruid;
|
||||
+ xavp_add_value(&xname_ruid, &xval, &xavp);
|
||||
+
|
||||
+ if(ptr->received.len > 0)
|
||||
+ {
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->received;
|
||||
+ xavp_add_value(&xname_received, &xval, &xavp);
|
||||
+ }
|
||||
+
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->c;
|
||||
+ xavp_add_value(&xname_contact, &xval, &xavp);
|
||||
+
|
||||
+ if(list==NULL)
|
||||
+ {
|
||||
+ /* no reg_xavp_rcd xavp in root list - add it */
|
||||
+ xval.type = SR_XTYPE_XAVP;
|
||||
+ xval.v.xavp = xavp;
|
||||
+ xavp_add_value(®_xavp_rcd, &xval, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*! \brief
|
||||
* Lookup contact in the database and rewrite Request-URI
|
||||
* or not according to _mode value:
|
||||
* 0: rewrite
|
||||
@@ -115,9 +161,6 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d, str* _uri, int _mode)
|
||||
str inst = {0};
|
||||
unsigned int ahash = 0;
|
||||
sr_xavp_t *xavp=NULL;
|
||||
- sr_xavp_t *list=NULL;
|
||||
- str xname = {"ruid", 4};
|
||||
- sr_xval_t xval;
|
||||
sip_uri_t path_uri;
|
||||
str path_str;
|
||||
|
||||
@@ -238,23 +281,7 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d, str* _uri, int _mode)
|
||||
/* reset next hop address */
|
||||
reset_dst_uri(_m);
|
||||
|
||||
- /* add xavp with details of the record (ruid, ...) */
|
||||
- if(reg_xavp_rcd.s!=NULL)
|
||||
- {
|
||||
- list = xavp_get(®_xavp_rcd, NULL);
|
||||
- xavp = list;
|
||||
- memset(&xval, 0, sizeof(sr_xval_t));
|
||||
- xval.type = SR_XTYPE_STR;
|
||||
- xval.v.s = ptr->ruid;
|
||||
- xavp_add_value(&xname, &xval, &xavp);
|
||||
- if(list==NULL)
|
||||
- {
|
||||
- /* no reg_xavp_rcd xavp in root list - add it */
|
||||
- xval.type = SR_XTYPE_XAVP;
|
||||
- xval.v.xavp = xavp;
|
||||
- xavp_add_value(®_xavp_rcd, &xval, NULL);
|
||||
- }
|
||||
- }
|
||||
+ xavp_rcd_helper(ptr);
|
||||
|
||||
/* If a Path is present, use first path-uri in favour of
|
||||
* received-uri because in that case the last hop towards the uac
|
||||
@@ -713,6 +740,8 @@ int registered4(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag, in
|
||||
memcmp(match_contact.s, ptr->c.s, match_contact.len)))
|
||||
continue;
|
||||
|
||||
+ xavp_rcd_helper(ptr);
|
||||
+
|
||||
if(ptr->xavp!=NULL && match_action_flag == 1) {
|
||||
sr_xavp_t *xavp = xavp_clone_level_nodata(ptr->xavp);
|
||||
if(xavp_add(xavp, NULL)<0) {
|
||||
--
|
||||
2.5.1
|
||||
|
Loading…
Reference in new issue