[sr-dev] git:master: Only update received info, if a contact is "new" contact. In case of multiple registration for one AoR, each registration will have a different contact.

admin at sip-router.org admin at sip-router.org
Sun Aug 18 17:49:11 CEST 2013


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

Author: Carsten Bock <carsten at ng-voice.com>
Committer: Carsten Bock <carsten at ng-voice.com>
Date:   Sun Aug 18 17:47:08 2013 +0200

Only update received info, if a contact is "new" contact. In case of multiple registration for one AoR, each registration will have a different contact.

---

 modules/ims_registrar_pcscf/save.c |   50 ++++++++++++++++++++----------------
 modules/ims_usrloc_pcscf/udomain.c |    2 +-
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/modules/ims_registrar_pcscf/save.c b/modules/ims_registrar_pcscf/save.c
index 5ace6e5..676f949 100644
--- a/modules/ims_registrar_pcscf/save.c
+++ b/modules/ims_registrar_pcscf/save.c
@@ -141,32 +141,38 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
 				ci.num_service_routes = service_route_cnt;
 				ci.reg_state = PCONTACT_REGISTERED;
 
-				// Received Info: First try AVP, otherwise simply take the source of the request:
-				memset(&val, 0, sizeof(int_str));
-				if (rcv_avp_name.n!=0 && search_first_avp(rcv_avp_type, rcv_avp_name, &val, 0) && val.s.len > 0) {
-					if (val.s.len>RECEIVED_MAX_SIZE) {
-						LM_ERR("received too long\n");
-						goto error;
-					}
-					if (parse_uri(val.s.s, val.s.len, &parsed_received) < 0) {
-						LM_DBG("Error parsing Received URI <%.*s>\n", val.s.len, val.s.s);
-						continue;
-					}
-					ci.received_host = parsed_received.host;
-					ci.received_port = parsed_received.port_no;
-					ci.received_proto = parsed_received.proto;
-				} else {
-					ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, sizeof(srcip));
-					ci.received_host.s = srcip;
-					ci.received_port = req->rcv.src_port;
-					ci.received_proto = req->rcv.proto;
-				}
-				// Set to default, if not set:
-				if (ci.received_port == 0) ci.received_port = 5060;
+				ci.received_host.len = 0;
+				ci.received_host.s = 0;
+				ci.received_port = 0;
+				ci.received_proto = 0;
 
 				ul.lock_udomain(_d, &c->uri);
 				if (ul.get_pcontact(_d, &c->uri, &pcontact) != 0) { //need to insert new contact
 					LM_DBG("Adding pcontact: <%.*s>, expires: %d which is in %d seconds\n", c->uri.len, c->uri.s, expires, expires-local_time_now);
+
+					// Received Info: First try AVP, otherwise simply take the source of the request:
+					memset(&val, 0, sizeof(int_str));
+					if (rcv_avp_name.n!=0 && search_first_avp(rcv_avp_type, rcv_avp_name, &val, 0) && val.s.len > 0) {
+						if (val.s.len>RECEIVED_MAX_SIZE) {
+							LM_ERR("received too long\n");
+							goto error;
+						}
+						if (parse_uri(val.s.s, val.s.len, &parsed_received) < 0) {
+							LM_DBG("Error parsing Received URI <%.*s>\n", val.s.len, val.s.s);
+							continue;
+						}
+						ci.received_host = parsed_received.host;
+						ci.received_port = parsed_received.port_no;
+						ci.received_proto = parsed_received.proto;
+					} else {
+						ci.received_host.len = ip_addr2sbuf(&req->rcv.src_ip, srcip, sizeof(srcip));
+						ci.received_host.s = srcip;
+						ci.received_port = req->rcv.src_port;
+						ci.received_proto = req->rcv.proto;
+					}
+					// Set to default, if not set:
+					if (ci.received_port == 0) ci.received_port = 5060;
+
 					if (ul.insert_pcontact(_d, &c->uri, &ci, &pcontact) != 0) {
 						LM_ERR("Failed inserting new pcontact\n");
 					} else {
diff --git a/modules/ims_usrloc_pcscf/udomain.c b/modules/ims_usrloc_pcscf/udomain.c
index ef15bea..8c0d370 100644
--- a/modules/ims_usrloc_pcscf/udomain.c
+++ b/modules/ims_usrloc_pcscf/udomain.c
@@ -376,7 +376,7 @@ int update_pcontact(struct udomain* _d, struct pcontact_info* _ci, struct pconta
 		}
 	}
 
-	// update received info:
+	// update received info (if info is available):
 	if (_ci->received_host.len > 0) {
 		if (_c->received_host.s)
 			shm_free(_c->received_host.s);




More information about the sr-dev mailing list