[sr-dev] git:master: modules/ims_registrar_pcscf: when search for contacts also include possible security ports

Jason Penton jason.penton at gmail.com
Mon Mar 17 15:11:58 CET 2014


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

Author: Jason Penton <jason.penton at gmail.com>
Committer: Jason Penton <jason.penton at gmail.com>
Date:   Fri Mar 14 15:41:27 2014 +0200

modules/ims_registrar_pcscf: when search for contacts also include possible security ports
	- with IPSEC, the received port could be different from the initial registration
	which occurs after security has been negotiated

---

 modules/ims_registrar_pcscf/service_routes.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/modules/ims_registrar_pcscf/service_routes.c b/modules/ims_registrar_pcscf/service_routes.c
index cafed54..8238f3b 100644
--- a/modules/ims_registrar_pcscf/service_routes.c
+++ b/modules/ims_registrar_pcscf/service_routes.c
@@ -117,6 +117,7 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 	str received_host = {0, 0};
 	contact_t *ct;
 	char srcip[50];	
+	int security_server_port = -1;
 
 	if (_m->id != current_msg_id) {
 		current_msg_id = _m->id;
@@ -127,7 +128,27 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 		if (b && b->contacts) {
 			for (ct = b->contacts; ct; ct = ct->next) {
 				if (ul.get_pcontact(_d, &ct->uri, &c) == 0) {
-					if ((c->reg_state == PCONTACT_REGISTERED) && (c->received_port == _m->rcv.src_port) && (c->received_proto == _m->rcv.proto)) {
+					if (c->security) {
+						switch (c->security->type) {
+						case SECURITY_IPSEC:
+							security_server_port = c->security->data.ipsec->port_uc;
+							break;
+						case SECURITY_TLS:
+						case SECURITY_NONE:
+							break;
+						}
+					} else if (c->security_temp) {
+						switch (c->security->type) {
+						case SECURITY_IPSEC:
+							security_server_port = c->security->data.ipsec->port_uc;
+							break;
+						case SECURITY_TLS:
+						case SECURITY_NONE:
+							break;
+						}
+					}
+
+					if ((c->reg_state == PCONTACT_REGISTERED) && ((c->received_port == _m->rcv.src_port) || (security_server_port == _m->rcv.src_port)) && (c->received_proto == _m->rcv.proto)) {
 						received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
 						received_host.s = srcip;
 						LM_DBG("Received host len %d (search %d)\n", c->received_host.len, received_host.len);




More information about the sr-dev mailing list