core: use port 5061 for checking self when uri has transport tls
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 15 May 2014 10:48:04 +0000 (12:48 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 15 May 2014 10:48:04 +0000 (12:48 +0200)
- 5060 was used, failing to match myself condition

forward.h
route.c

index 4680a8e..f377546 100644 (file)
--- a/forward.h
+++ b/forward.h
@@ -84,6 +84,8 @@ inline static struct socket_info* get_send_socket(struct sip_msg* msg,
 }
 
 
+#define GET_URI_PORT(uri) ((uri)->port_no?(uri)->port_no:(((uri)->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT))
+
 struct socket_info* get_out_socket(union sockaddr_union* to, int proto);
 typedef int (*check_self_f)(str* host, unsigned short port,
                unsigned short proto);
diff --git a/route.c b/route.c
index 1c5897c..2a3e1b9 100644 (file)
--- a/route.c
+++ b/route.c
@@ -1886,8 +1886,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
                        if (e->r_type==MYSELF_ST){
                                if (parse_sip_msg_uri(msg)<0) ret=-1;
                                else ret=check_self_op(e->op, &msg->parsed_uri.host,
-                                                      msg->parsed_uri.port_no?
-                                                      msg->parsed_uri.port_no:SIP_PORT);
+                                                               GET_URI_PORT(&msg->parsed_uri));
                        }else{
                                ret=comp_str(e->op, &msg->new_uri,
                                                                e->r_type, &e->r, msg, h);
@@ -1896,8 +1895,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
                        if (e->r_type==MYSELF_ST){
                                if (parse_sip_msg_uri(msg)<0) ret=-1;
                                else ret=check_self_op(e->op, &msg->parsed_uri.host,
-                                                      msg->parsed_uri.port_no?
-                                                      msg->parsed_uri.port_no:SIP_PORT);
+                                                               GET_URI_PORT(&msg->parsed_uri));
                        }else{
                                ret=comp_str(e->op, &msg->first_line.u.request.uri,
                                                                e->r_type, &e->r, msg, h);
@@ -1917,8 +1915,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
                                LOG(L_ERR, "ERROR: eval_elem: bad uri in From:\n");
                                goto error;
                        }
-                       ret=check_self_op(e->op, &uri.host,
-                                         uri.port_no?uri.port_no:SIP_PORT);
+                       ret=check_self_op(e->op, &uri.host, GET_URI_PORT(&uri));
                }else{
                        ret=comp_str(e->op, &get_from(msg)->uri,
                                                        e->r_type, &e->r, msg, h);
@@ -1939,8 +1936,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
                                LOG(L_ERR, "ERROR: eval_elem: bad uri in To:\n");
                                goto error;
                        }
-                       ret=check_self_op(e->op, &uri.host,
-                                         uri.port_no?uri.port_no:SIP_PORT);
+                       ret=check_self_op(e->op, &uri.host, GET_URI_PORT(&uri));
                }else{
                        ret=comp_str(e->op, &get_to(msg)->uri,
                                                        e->r_type, &e->r, msg, h);