[sr-dev] git:master: rr:force_send_socket parameter is added.

Miklos Tirpak miklos at iptel.org
Tue May 26 16:38:19 CEST 2009


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

Author: Miklos Tirpak <miklos at iptel.org>
Committer: Miklos Tirpak <miklos at iptel.org>
Date:   Tue May 26 16:36:00 2009 +0200

rr:force_send_socket parameter is added.

When force_send_socket is set to 1 (default),
the module forces the outgoing socket if two
Route headers are present in the request pointing to SER.

---

 modules_s/rr/loose.c  |   24 ++++++++++++++++++++++++
 modules_s/rr/rr_mod.c |    2 ++
 modules_s/rr/rr_mod.h |    1 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/modules_s/rr/loose.c b/modules_s/rr/loose.c
index da1e7df..d2c73f4 100644
--- a/modules_s/rr/loose.c
+++ b/modules_s/rr/loose.c
@@ -31,6 +31,7 @@
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
  * 2006-01-09 store user part of Route URI in AVP (if required) (mma)
+ * 2009-05-26 Force the send socket if two RR headers were added (Miklos)
  */
 
 
@@ -45,6 +46,7 @@
 #include "../../parser/parse_from.h"
 #include "../../mem/mem.h"
 #include "../../dset.h"
+#include "../../socket_info.h"
 #include "loose.h"
 #include "rr_mod.h"
 #include "avp_cookie.h"
@@ -850,6 +852,7 @@ static inline int after_loose(struct sip_msg* _m, struct sip_uri* _pru, int _rou
 #endif
 	str* uri;
 	str avp_cookie;
+	struct sip_uri parsed_uri;
 
 	hdr = _m->route;
 	rt = (rr_t*)hdr->parsed;
@@ -891,6 +894,27 @@ static inline int after_loose(struct sip_msg* _m, struct sip_uri* _pru, int _rou
 		} else rt = rt->next;
 
 		if (enable_double_rr && is_2rr(&(_pru->params))) {
+			if (rr_force_send_socket) {
+				if (parse_uri(rt->nameaddr.uri.s, rt->nameaddr.uri.len,
+						&parsed_uri) < 0
+				) {
+					LOG(L_ERR, "after_loose: Error while parsing the second route header\n");
+					return RR_ERROR;
+				}
+				_m->force_send_socket = grep_sock_info(&parsed_uri.host,
+								parsed_uri.port_no,
+								parsed_uri.proto);
+				if (_m->force_send_socket == 0)
+					LOG(L_WARN, "after_loose: send socket cannot be set"
+						" based on the second route header\n");
+					/* Do not return error because there is still a chance
+					 * that the outgoing socket will be correct, especially
+					 * if mhomed is turned on. It can happen that the Route HF
+					 * contains a domain name as opposed to ip address therefore
+					 * the outgoing socket cannot be determined (easily) from the URI.
+					 * (Miklos)
+					 */
+			}
 			if (!rt->next) {
 				     /* No next route in the same header, remove the whole header
 				      * field immediately
diff --git a/modules_s/rr/rr_mod.c b/modules_s/rr/rr_mod.c
index 337993b..49f5d69 100644
--- a/modules_s/rr/rr_mod.c
+++ b/modules_s/rr/rr_mod.c
@@ -65,6 +65,7 @@ str next_route_avp = STR_NULL; /* AVP identification where next route (if exists
 static str crc_secret_str = STR_NULL;
 avp_ident_t user_part_avp_ident;
 avp_ident_t next_route_avp_ident;
+int rr_force_send_socket = 1; /* Force the send socket if 2 RR was added */
 
 fparam_t* fparam_username = NULL;
 
@@ -109,6 +110,7 @@ static param_export_t params[] ={
 	{"cookie_secret",    PARAM_STR,    &crc_secret_str  },
 	{"user_part_avp",    PARAM_STR,    &user_part_avp   },
 	{"next_route_avp",   PARAM_STR,    &next_route_avp  },
+	{"force_send_socket", PARAM_INT,    &rr_force_send_socket  },
 	{0, 0, 0 }
 };
 
diff --git a/modules_s/rr/rr_mod.h b/modules_s/rr/rr_mod.h
index 0935727..93d7065 100644
--- a/modules_s/rr/rr_mod.h
+++ b/modules_s/rr/rr_mod.h
@@ -46,6 +46,7 @@ extern avp_ident_t next_route_avp_ident;
 extern int append_fromtag;
 extern int enable_double_rr;
 extern int enable_full_lr;
+extern int rr_force_send_socket;
 
 extern domain_get_did_t dm_get_did;
 extern fparam_t* fparam_username;




More information about the sr-dev mailing list