[sr-dev] git:master: ims_registrar_pcscf: Fallback to IP/Port/ Proto search is now configurable; fallback to ip-search will be done, if no contact-header present (and the fallback is enabled).

Carsten Bock carsten at ng-voice.com
Mon Dec 16 11:14:05 CET 2013


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

Author: Carsten Bock <carsten at ng-voice.com>
Committer: Carsten Bock <carsten at ng-voice.com>
Date:   Mon Dec 16 11:08:29 2013 +0100

ims_registrar_pcscf: Fallback to IP/Port/Proto search is now configurable; fallback to ip-search will be done, if no contact-header present (and the fallback is enabled).

Thanks to Camille Oudot & Hugh Waite for the improvement requests!

---

 modules/ims_registrar_pcscf/reg_mod.c        |    4 ++
 modules/ims_registrar_pcscf/reg_mod.h        |    1 +
 modules/ims_registrar_pcscf/service_routes.c |   46 +++++++++++++-------------
 3 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/modules/ims_registrar_pcscf/reg_mod.c b/modules/ims_registrar_pcscf/reg_mod.c
index b2ffe8e..8442e54 100644
--- a/modules/ims_registrar_pcscf/reg_mod.c
+++ b/modules/ims_registrar_pcscf/reg_mod.c
@@ -79,6 +79,8 @@ char * pcscf_uri = "sip:pcscf.ims.smilecoms.com:4060";
 str pcscf_uri_str;
 unsigned int pending_reg_expires = 30;			/**!< parameter for expiry time of a pending registration before receiving confirmation from SCSCF */
 
+int is_registered_fallback2ip = 0;
+
 char* rcv_avp_param = 0;
 unsigned short rcv_avp_type = 0;
 int_str rcv_avp_name;
@@ -141,6 +143,8 @@ static param_export_t params[] = {
 
 	{"received_avp",       STR_PARAM, &rcv_avp_param       					},
 
+	{"is_registered_fallback2ip",	INT_PARAM, &pending_reg_expires					},
+
 
 //	{"ims_mode",           INT_PARAM, &registrar_ims_mode                  	}, /* 0-PCSCF ; 1-SCSCF */
 //	{"subscription_max_expires",INT_PARAM, &subscription_max_expires       	},
diff --git a/modules/ims_registrar_pcscf/reg_mod.h b/modules/ims_registrar_pcscf/reg_mod.h
index 71aa17d..d59d7f1 100644
--- a/modules/ims_registrar_pcscf/reg_mod.h
+++ b/modules/ims_registrar_pcscf/reg_mod.h
@@ -57,6 +57,7 @@
 
 extern unsigned short rcv_avp_type;
 extern int_str rcv_avp_name;
+extern int is_registered_fallback2ip;
 
 #endif /* REG_MOD_H */
 
diff --git a/modules/ims_registrar_pcscf/service_routes.c b/modules/ims_registrar_pcscf/service_routes.c
index 80393bc..937d152 100644
--- a/modules/ims_registrar_pcscf/service_routes.c
+++ b/modules/ims_registrar_pcscf/service_routes.c
@@ -123,33 +123,33 @@ pcontact_t * getContactP(struct sip_msg* _m, udomain_t* _d) {
 
 		b = cscf_parse_contacts(_m);
 
-		if (!b || !b->contacts) {
-			LM_DBG("No contacts found\n");
-			return NULL;
-		}
-
-		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)) {
-					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);
-					// Then check the length:
-					if (c->received_host.len == received_host.len) {
-						LM_DBG("Received host %.*s (search %.*s)\n",
-							c->received_host.len, c->received_host.s,
-							received_host.len, received_host.s);
-
-						// Finally really compare the "received_host"
-						if (!memcmp(c->received_host.s, received_host.s, received_host.len))
-							break;
-						c = NULL;
+		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)) {
+						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);
+						// Then check the length:
+						if (c->received_host.len == received_host.len) {
+							LM_DBG("Received host %.*s (search %.*s)\n",
+								c->received_host.len, c->received_host.s,
+								received_host.len, received_host.s);
+
+							// Finally really compare the "received_host"
+							if (!memcmp(c->received_host.s, received_host.s, received_host.len))
+								break;
+							c = NULL;
+						}
 					}
 				}
 			}
+		} else {
+			LM_WARN("No contact-header found\n");
 		}
-		if (c == NULL) {
-			LM_WARN("Contact not found based on Contact, trying IP/Port/Proto\n");
+
+		if ((c == NULL) && (is_registered_fallback2ip > 0)) {
+			LM_WARN("Contact not found based on Contact-header, trying IP/Port/Proto\n");
 			received_host.len = ip_addr2sbuf(&_m->rcv.src_ip, srcip, sizeof(srcip));
 			received_host.s = srcip;
 			if (ul.get_pcontact_by_src(_d, &received_host, _m->rcv.src_port, _m->rcv.proto, &c) == 1)




More information about the sr-dev mailing list