Index: phapi/phapi.c
===================================================================
--- phapi/phapi.c	(revision 429)
+++ phapi/phapi.c	(revision 430)
@@ -328,4 +328,12 @@
 
 }
+
+static RtpTransport *
+ph_create_rtp_tunnel(struct tunnel_info *t, const char* ip, int port)
+{
+	rtp_set_tunnel_server(t->tunnel_server, t->tunnel_port);
+	return rtp_socks_transport_new(ip, port);
+}
+
 #endif
 
@@ -1097,12 +1105,4 @@
 }
 
-static RtpTransport *
-ph_create_rtp_tunnel(struct tunnel_info *t, const char* ip, int port)
-{
-	rtp_set_tunnel_server(t->tunnel_server, t->tunnel_port);
-	return rtp_socks_transport_new(ip, port);
-
-}
-
 ph_prepare_stream_ports(phcall_t *ca)
 {
@@ -4252,7 +4252,10 @@
 {
 #if ENABLE_SOCKS
-	struct tunnel_info *tun;
-
 	if (phcfg.use_tunnel & PH_TUNNEL_USE) {
+		struct tunnel_info *tun;	
+		tun = ph_select_tunnel(sip_tunnel_set, sip_tunnel_count);
+		if (tun)
+			eXosip_set_tunnel(tun->tunnel_proto, tun->tunnel_server, tun->tunnel_port);;
+
 		sip_tunnel_count = ph_parse_tunnel_list(sip_tunnel_set, phcfg.sip_tunnel_uris, TUNNEL_MAX);
 	}
@@ -4715,22 +4718,7 @@
 	ph_media_init(phcfg.plugin_path); //init ortp/ms2 payloads list, init ms2 and ortp
 
-	if (phcfg.use_tunnel) {
-
-		// ph_setup_tunnel();
-
-	}
-
 	i = eXosip_init();
 	if (i)
 		return -1;
-
-	if (phcfg.use_tunnel & PH_TUNNEL_USE) {
-		struct tunnel_info *tun;
-
-		tun = ph_select_tunnel(sip_tunnel_set, sip_tunnel_count);
-		if (tun)
-			eXosip_set_tunnel(tun->tunnel_proto, tun->tunnel_server, tun->tunnel_port);;
-	}
-
 	
 	ph_nat_init();
