[sr-dev] git:3.3: register(k): pack contact info based on header for searching existing ul records

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 1 21:57:03 CEST 2012


Module: sip-router
Branch: 3.3
Commit: 153baccb8bbbcf08b6485f1cfc75a2b809bdafca
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=153baccb8bbbcf08b6485f1cfc75a2b809bdafca

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Jul 30 12:57:09 2012 +0200

register(k): pack contact info based on header for searching existing ul records

- not using the contact header resulted in omitting instance and reg-id
  parameters, not following gruu/ob extensions, ending in duplicate
  records for same +sip.instance
- reported by José Luis Millán
(cherry picked from commit efa3099252ca5d200bef6ce71df33f33b55f9941)

---

 modules_k/registrar/save.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/modules_k/registrar/save.c b/modules_k/registrar/save.c
index 8f18ea7..9b0607a 100644
--- a/modules_k/registrar/save.c
+++ b/modules_k/registrar/save.c
@@ -302,6 +302,10 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c,
 	}
 
 	if(_c!=0) {
+		/* hook uri address - should be more than 'sip:' chars */
+		if(_c->uri.s!=NULL && _c->uri.len>4)
+			ci.c = &_c->uri;
+
 		/* Calculate q value of the contact */
 		if (calc_contact_q(_c->q, &ci.q) < 0) {
 			rerrno = R_INV_Q;
@@ -651,6 +655,12 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
 		/* calculate expires */
 		calc_contact_expires(_m, _c->expires, &expires);
 
+		/* pack the contact info */
+		if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
+			LM_ERR("failed to pack contact specific info\n");
+			goto error;
+		}
+
 		/* search for the contact*/
 		ret = ul.get_ucontact_by_instance( _r, &_c->uri, ci, &c);
 		if (ret==-1) {
@@ -668,12 +678,6 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
 			if (expires==0)
 				continue;
 
-			/* pack the contact_info */
-			if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
-				LM_ERR("failed to extract contact info\n");
-				goto error;
-			}
-
 			if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) {
 				rerrno = R_UL_INS_C;
 				LM_ERR("failed to insert contact\n");
@@ -710,12 +714,6 @@ static inline int update_contacts(struct sip_msg* _m, urecord_t* _r,
 				rc = 3;
 			} else {
 				/* do update */
-				/* pack the contact specific info */
-				if ( (ci=pack_ci( 0, _c, expires, 0))==0 ) {
-					LM_ERR("failed to pack contact specific info\n");
-					goto error;
-				}
-
 				if(_mode)
 				{
 					ptr=_r->contacts;




More information about the sr-dev mailing list