Hi,

That is a great catch, thank you for finding and reporting this. See the attach patch that should address the problem. Could you please give it a try to see if it really solves the problem ?

Best Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 13.05.2016 22:30, Ravitez Ravi wrote:
Hi All,
        Good Day,
Here's the problem i'm facing and would be a great help if you could comment.
        Thank you.

is_myself() does not check for SIPS port if connection type is TLS
*Configuration :*
- Opensips V1.11.5 running in secure mode on port 5061
- Avaya trying to communicate with Opensips server.
- Opensips server ip 192.168.1.11
- Avaya ip : 192.168.1.20


*Steps :*
- Avaya sends INVITE to Opensips with route header
Route: <sip:192.168.1.11;transport=tls;lr;phase=terminating>
- Opensips tries to process it but fails.
*DBG:rr:is_preloaded: is_preloaded: Yes*
*DBG:core:grep_sock_info: checking if host==us: 14==14 && [192.168.1.11] == [192.168.1.11]*
*DBG:core:grep_sock_info: checking if port 5061 matches port 5060*
*DBG:core:check_self: host != me*
*DBG:rr:after_loose: Topmost URI is NOT myself*
....
....
....
SIP/2.0 403 Preload Route denied
*Code Snippet :*
/*
 * Check if URI is myself
 */
#ifdef ENABLE_USER_CHECK
static inline int is_myself(str *_user, str* _host, unsigned short _port)
#else
static inline int is_myself(str* _host, unsigned short _port)
#endif
{
int ret;

*ret = check_self(_host, _port ? _port : SIP_PORT, 0);/* match all protos*/*
if (ret < 0) return 0;

*Should is_myself() check for connection type and then decide to either use SIP or SIPS port.*
*
*
*
*
*
*
Regards,
Ravitez.D


_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

diff --git a/modules/rr/loose.c b/modules/rr/loose.c
index 28d4b05..beb2c4f 100644
--- a/modules/rr/loose.c
+++ b/modules/rr/loose.c
@@ -224,14 +224,24 @@ static inline int is_2rr(str* _params)
  * Check if URI is myself
  */
 #ifdef ENABLE_USER_CHECK
-static inline int is_myself(str *_user, str* _host, unsigned short _port)
+static inline int is_myself(str *_user, struct sip_uri* _uri)
 #else
-static inline int is_myself(str* _host, unsigned short _port)
+static inline int is_myself(struct sip_uri* _uri)
 #endif
 {
 	int ret;
+	unsigned short port;
 
-	ret = check_self(_host, _port ? _port : SIP_PORT, 0);/* match all protos*/
+	if ((port=_uri->port_no)==0) {
+		if (_uri->proto!=PROTO_NONE) {
+			port = protos[_uri->proto].default_port;
+		} else if (_uri->type==SIPS_URI_T || _uri->type==TELS_URI_T) {
+			port = protos[PROTO_TLS].default_port;
+		} else {
+			port = protos[PROTO_UDP].default_port;
+		}
+	}
+	ret = check_self(&_uri->host, port, 0);/* match all protos*/
 	if (ret < 0) return 0;
 
 #ifdef ENABLE_USER_CHECK
@@ -509,9 +519,9 @@ static inline int after_strict(struct sip_msg* _m)
 
 	if ( enable_double_rr && is_2rr(&puri.params) &&
 #ifdef ENABLE_USER_CHECK
-	is_myself(&puri.user, &puri.host, puri.port_no)
+	is_myself(&puri.user, &puri)
 #else
-	is_myself(&puri.host, puri.port_no)
+	is_myself(&puri)
 #endif
 	) {
 		/* double route may occure due different IP and port, so force as
@@ -718,10 +728,10 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
 
 	/* IF the URI was added by me, remove it */
 #ifdef ENABLE_USER_CHECK
-	ret=is_myself(&puri.user, &puri.host, puri.port_no);
+	ret=is_myself(&puri.user, &puri);
 	if (ret>0)
 #else
-	if (is_myself(&puri.host, puri.port_no))
+	if (is_myself(&puri))
 #endif
 	{
 		LM_DBG("Topmost route URI: '%.*s' is me\n",
@@ -899,10 +909,9 @@ int loose_route(struct sip_msg* _m)
 		return after_loose(_m, 1);
 	} else {
 #ifdef ENABLE_USER_CHECK
-		if (is_myself(&_m->parsed_uri.user, &_m->parsed_uri.host,
-		_m->parsed_uri.port_no) && !(_m->parsed_uri.gr.s && _m->parsed_uri.gr.len)) {
+		if (is_myself(&_m->parsed_uri.user, &_m->parsed_uri) && !(_m->parsed_uri.gr.s && _m->parsed_uri.gr.len)) {
 #else
-		if (is_myself(&_m->parsed_uri.host, _m->parsed_uri.port_no) && !(_m->parsed_uri.gr.s && _m->parsed_uri.gr.len)) {
+		if (is_myself(&_m->parsed_uri) && !(_m->parsed_uri.gr.s && _m->parsed_uri.gr.len)) {
 #endif
 			return after_strict(_m);
 		} else {
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to