Skip to content

Commit

Permalink
Merge pull request #1825 from ycaner06/patch-11
Browse files Browse the repository at this point in the history
ims_isc : fixed P-associated-uri header constructing
  • Loading branch information
miconda committed Feb 1, 2019
2 parents 4d775fa + a704f7d commit 18835e0
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions src/modules/ims_isc/third_party_reg.c
Expand Up @@ -3,23 +3,23 @@
*
* Copyright (C) 2012 Smile Communications, jason.penton@smilecoms.com
* Copyright (C) 2012 Smile Communications, richard.good@smilecoms.com
*
*
* The initial version of this code was written by Dragos Vingarzan
* (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
* Fruanhofer Institute. It was and still is maintained in a separate
* branch of the original SER. We are therefore migrating it to
* Kamailio/SR and look forward to maintaining it from here on out.
* 2011/2012 Smile Communications, Pty. Ltd.
* ported/maintained/improved by
* ported/maintained/improved by
* Jason Penton (jason(dot)penton(at)smilecoms.com and
* Richard Good (richard(dot)good(at)smilecoms.com) as part of an
* Richard Good (richard(dot)good(at)smilecoms.com) as part of an
* effort to add full IMS support to Kamailio/SR using a new and
* improved architecture
*
*
* NB: Alot of this code was originally part of OpenIMSCore,
* FhG Fokus.
* FhG Fokus.
* Copyright (C) 2004-2006 FhG Fokus
* Thanks for great work! This is an effort to
* Thanks for great work! This is an effort to
* break apart the various CSCF functions into logically separate
* components. We hope this will drive wider use. We also feel
* that in this way the architecture is more complete and thereby easier
Expand All @@ -37,10 +37,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*
*/

#include "third_party_reg.h"
Expand Down Expand Up @@ -135,7 +135,7 @@ static inline unsigned int calc_associateduri_buf_len(ims_subscription* s) {

int build_p_associated_uri(ims_subscription* s) {
char *p;
int i, j, cnt = 0;
int i, j, cnt = 0,cnttel = 0;;
ims_public_identity* id;

LM_DBG("Building P-Associated-URI\n");
Expand Down Expand Up @@ -169,16 +169,28 @@ int build_p_associated_uri(ims_subscription* s) {
for (i = 0; i < s->service_profiles_cnt; i++)
for (j = 0; j < s->service_profiles[i].public_identities_cnt; j++) {
id = &(s->service_profiles[i].public_identities[j]);
if (!id->barring && (strncmp(id->public_identity.s,"tel",3) == 0) ) {
if (cnt == 0)
if (!id->barring && !(strncmp(id->public_identity.s,"tel",3) == 0) ) {
if (cnt == 0 && cnttel == 0){
*p++ = '<';
else {
} else if(cnttel != 0 && cnt == 0){
memcpy(p, ", <", 3);
p += 3;
} else {
memcpy(p, ">, <", 4);
p += 4;
}
memcpy(p, id->public_identity.s, id->public_identity.len);
p += id->public_identity.len;
cnt++;
}else if(!id->barring && strncmp(id->public_identity.s,"tel",3) == 0){

if(cnttel != 0 || cnt != 0){
memcpy(p, ", ", 2);
p += 2;
}
memcpy(p, id->public_identity.s, id->public_identity.len);
p += id->public_identity.len;
cnttel++;
}
}
if (cnt)
Expand All @@ -197,7 +209,7 @@ int build_p_associated_uri(ims_subscription* s) {
/**
* Handle third party registration
* @param msg - the SIP REGISTER message
* @param m - the isc_match that matched with info about where to forward it
* @param m - the isc_match that matched with info about where to forward it
* @param mark - the isc_mark that should be used to mark the message
* @returns #ISC_RETURN_TRUE if allowed, #ISC_RETURN_FALSE if not
*/
Expand All @@ -211,7 +223,7 @@ int isc_third_party_reg(struct sip_msg *msg, isc_match *m, isc_mark *mark, udoma
str pani = {0, 0};
str cv = {0, 0};
str s = {0, 0};

impurecord_t *p;

struct hdr_field *hdr;
Expand All @@ -224,9 +236,9 @@ int isc_third_party_reg(struct sip_msg *msg, isc_match *m, isc_mark *mark, udoma

/* Get To header*/
to = cscf_get_public_identity(msg);

if (cscf_get_originating_user(msg, &s)) {

isc_ulb.lock_udomain(d, &s);
if ( isc_ulb.get_impurecord(d,&s,&p) != 0) {
isc_ulb.unlock_udomain(d, &s);
Expand Down Expand Up @@ -351,7 +363,7 @@ int r_send_third_party_reg(r_third_party_registration *r, int expires) {
+ r->from.len /*adding our own address to path*/;
}
str pauri = {0,0};

if (p_associated_uri.data_len > 0)
{
pauri.s = p_associated_uri.buf;
Expand Down Expand Up @@ -403,11 +415,11 @@ int r_send_third_party_reg(r_third_party_registration *r, int expires) {
}

if (r->cv.len) {
STR_APPEND(h, p_charging_vector_s);
STR_APPEND(h, r->cv);
STR_APPEND(h, p_charging_vector_e);
STR_APPEND(h, p_charging_vector_s);
STR_APPEND(h, r->cv);
STR_APPEND(h, p_charging_vector_e);
}

if (p_associated_uri.data_len > 0) {
STR_APPEND(h, pauri);
}
Expand Down Expand Up @@ -436,11 +448,15 @@ int r_send_third_party_reg(r_third_party_registration *r, int expires) {
}
if (h.s)
pkg_free(h.s);
if (b.s)
pkg_free(b.s);
return 1;

error:
if (h.s)
pkg_free(h.s);
if (b.s)
pkg_free(b.s);
return 0;
}

Expand All @@ -464,4 +480,3 @@ void r_third_party_reg_response(struct cell *t, int type, struct tmcb_params *ps
LM_DBG("r_third_party_reg_response: code %d\n", ps->code);
}
}

0 comments on commit 18835e0

Please sign in to comment.