Browse code

core: use port 5061 for checking self when uri has transport tls

- 5060 was used, failing to match myself condition

Daniel-Constantin Mierla authored on 15/05/2014 10:48:04
Showing 2 changed files
... ...
@@ -84,6 +84,8 @@ inline static struct socket_info* get_send_socket(struct sip_msg* msg,
84 84
 }
85 85
 
86 86
 
87
+#define GET_URI_PORT(uri) ((uri)->port_no?(uri)->port_no:(((uri)->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT))
88
+
87 89
 struct socket_info* get_out_socket(union sockaddr_union* to, int proto);
88 90
 typedef int (*check_self_f)(str* host, unsigned short port,
89 91
 		unsigned short proto);
... ...
@@ -1886,8 +1886,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
1886 1886
 			if (e->r_type==MYSELF_ST){
1887 1887
 				if (parse_sip_msg_uri(msg)<0) ret=-1;
1888 1888
 				else ret=check_self_op(e->op, &msg->parsed_uri.host,
1889
-						       msg->parsed_uri.port_no?
1890
-						       msg->parsed_uri.port_no:SIP_PORT);
1889
+								GET_URI_PORT(&msg->parsed_uri));
1891 1890
 			}else{
1892 1891
 				ret=comp_str(e->op, &msg->new_uri,
1893 1892
 								e->r_type, &e->r, msg, h);
... ...
@@ -1896,8 +1895,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
1896 1896
 			if (e->r_type==MYSELF_ST){
1897 1897
 				if (parse_sip_msg_uri(msg)<0) ret=-1;
1898 1898
 				else ret=check_self_op(e->op, &msg->parsed_uri.host,
1899
-						       msg->parsed_uri.port_no?
1900
-						       msg->parsed_uri.port_no:SIP_PORT);
1899
+								GET_URI_PORT(&msg->parsed_uri));
1901 1900
 			}else{
1902 1901
 				ret=comp_str(e->op, &msg->first_line.u.request.uri,
1903 1902
 								e->r_type, &e->r, msg, h);
... ...
@@ -1917,8 +1915,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
1917 1917
 				LOG(L_ERR, "ERROR: eval_elem: bad uri in From:\n");
1918 1918
 				goto error;
1919 1919
 			}
1920
-			ret=check_self_op(e->op, &uri.host,
1921
-					  uri.port_no?uri.port_no:SIP_PORT);
1920
+			ret=check_self_op(e->op, &uri.host, GET_URI_PORT(&uri));
1922 1921
 		}else{
1923 1922
 			ret=comp_str(e->op, &get_from(msg)->uri,
1924 1923
 							e->r_type, &e->r, msg, h);
... ...
@@ -1939,8 +1936,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
1939 1939
 				LOG(L_ERR, "ERROR: eval_elem: bad uri in To:\n");
1940 1940
 				goto error;
1941 1941
 			}
1942
-			ret=check_self_op(e->op, &uri.host,
1943
-					  uri.port_no?uri.port_no:SIP_PORT);
1942
+			ret=check_self_op(e->op, &uri.host, GET_URI_PORT(&uri));
1944 1943
 		}else{
1945 1944
 			ret=comp_str(e->op, &get_to(msg)->uri,
1946 1945
 							e->r_type, &e->r, msg, h);