Index: pjproject/trunk/build.symbian/pjnath.mmp
===================================================================
--- pjproject/trunk/build.symbian/pjnath.mmp	(revision 1912)
+++ pjproject/trunk/build.symbian/pjnath.mmp	(revision 1913)
@@ -39,4 +39,6 @@
 SOURCE	stun_session.c
 SOURCE	stun_transaction.c
+SOURCE	turn_session.c
+SOURCE	turn_sock.c
 
 //
Index: pjproject/trunk/pjnath/build/Makefile
===================================================================
--- pjproject/trunk/pjnath/build/Makefile	(revision 1912)
+++ pjproject/trunk/pjnath/build/Makefile	(revision 1913)
@@ -33,5 +33,5 @@
 		errno.o ice_session.o ice_strans.o nat_detect.o stun_auth.o \
 		stun_msg.o stun_msg_dump.o stun_session.o stun_transaction.o \
-		turn_session.o turn_udp.o
+		turn_session.o turn_sock.o
 export PJNATH_CFLAGS += $(_CFLAGS)
 
Index: pjproject/trunk/pjnath/build/pjnath.dsp
===================================================================
--- pjproject/trunk/pjnath/build/pjnath.dsp	(revision 1912)
+++ pjproject/trunk/pjnath/build/pjnath.dsp	(revision 1913)
@@ -130,5 +130,5 @@
 # Begin Source File
 
-SOURCE=..\src\pjnath\turn_udp.c
+SOURCE=..\src\pjnath\turn_sock.c
 # End Source File
 # End Group
@@ -186,5 +186,5 @@
 # Begin Source File
 
-SOURCE=..\include\pjnath\turn_udp.h
+SOURCE=..\include\pjnath\turn_sock.h
 # End Source File
 # Begin Source File
Index: pjproject/trunk/pjnath/build/pjnath.vcproj
===================================================================
--- pjproject/trunk/pjnath/build/pjnath.vcproj	(revision 1912)
+++ pjproject/trunk/pjnath/build/pjnath.vcproj	(revision 1913)
@@ -325,5 +325,5 @@
 			</File>
 			<File
-				RelativePath="..\src\pjnath\turn_udp.c"
+				RelativePath="..\src\pjnath\turn_sock.c"
 				>
 			</File>
@@ -386,5 +386,5 @@
 			</File>
 			<File
-				RelativePath="..\include\pjnath\turn_udp.h"
+				RelativePath="..\include\pjnath\turn_sock.h"
 				>
 			</File>
Index: pjproject/trunk/pjnath/build/pjturn_srv.dsp
===================================================================
--- pjproject/trunk/pjnath/build/pjturn_srv.dsp	(revision 1912)
+++ pjproject/trunk/pjnath/build/pjturn_srv.dsp	(revision 1913)
@@ -96,4 +96,8 @@
 # Begin Source File
 
+SOURCE="..\src\pjturn-srv\listener_tcp.c"
+# End Source File
+# Begin Source File
+
 SOURCE="..\src\pjturn-srv\listener_udp.c"
 # End Source File
Index: pjproject/trunk/pjnath/build/wince-evc4/pjnath_wince.vcp
===================================================================
--- pjproject/trunk/pjnath/build/wince-evc4/pjnath_wince.vcp	(revision 1912)
+++ pjproject/trunk/pjnath/build/wince-evc4/pjnath_wince.vcp	(revision 1913)
@@ -586,21 +586,27 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
 	"..\..\..\pjlib\include\pj\compat\string.h"\
 	"..\..\..\pjlib\include\pj\config.h"\
@@ -1255,21 +1261,27 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
 	"..\..\..\pjlib\include\pj\compat\string.h"\
 	"..\..\..\pjlib\include\pj\config.h"\
@@ -1978,21 +1990,28 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\socket.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
 	"..\..\..\pjlib\include\pj\compat\string.h"\
 	"..\..\..\pjlib\include\pj\config.h"\
@@ -3449,4 +3468,5 @@
 DEP_CPP_STUN_=\
 	"..\..\..\pjlib-util\include\pjlib-util\hmac_sha1.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\md5.h"\
 	"..\..\..\pjlib-util\include\pjlib-util\sha1.h"\
 	"..\..\..\pjlib\include\pj\addr_resolv.h"\
@@ -3454,21 +3474,27 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
 	"..\..\..\pjlib\include\pj\compat\string.h"\
 	"..\..\..\pjlib\include\pj\config.h"\
@@ -4139,5 +4165,5 @@
 	"..\..\..\pjlib-util\include\pjlib-util\crc32.h"\
 	"..\..\..\pjlib-util\include\pjlib-util\hmac_sha1.h"\
-	"..\..\..\pjlib-util\include\pjlib-util\md5.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\sha1.h"\
 	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
 	"..\..\..\pjlib\include\pj\addr_resolv.h"\
@@ -4145,21 +4171,27 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
 	"..\..\..\pjlib\include\pj\compat\string.h"\
 	"..\..\..\pjlib\include\pj\config.h"\
@@ -4820,67 +4852,4 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
-	"..\..\..\pjlib\include\pj\compat\string.h"\
-	"..\..\..\pjlib\include\pj\config.h"\
-	"..\..\..\pjlib\include\pj\config_site.h"\
-	"..\..\..\pjlib\include\pj\config_site_sample.h"\
-	"..\..\..\pjlib\include\pj\ctype.h"\
-	"..\..\..\pjlib\include\pj\errno.h"\
-	"..\..\..\pjlib\include\pj\except.h"\
-	"..\..\..\pjlib\include\pj\fifobuf.h"\
-	"..\..\..\pjlib\include\pj\file_access.h"\
-	"..\..\..\pjlib\include\pj\file_io.h"\
-	"..\..\..\pjlib\include\pj\guid.h"\
-	"..\..\..\pjlib\include\pj\hash.h"\
-	"..\..\..\pjlib\include\pj\ioqueue.h"\
-	"..\..\..\pjlib\include\pj\ip_helper.h"\
-	"..\..\..\pjlib\include\pj\list.h"\
-	"..\..\..\pjlib\include\pj\list_i.h"\
-	"..\..\..\pjlib\include\pj\lock.h"\
-	"..\..\..\pjlib\include\pj\log.h"\
-	"..\..\..\pjlib\include\pj\os.h"\
-	"..\..\..\pjlib\include\pj\pool.h"\
-	"..\..\..\pjlib\include\pj\pool_alt.h"\
-	"..\..\..\pjlib\include\pj\pool_buf.h"\
-	"..\..\..\pjlib\include\pj\pool_i.h"\
-	"..\..\..\pjlib\include\pj\rand.h"\
-	"..\..\..\pjlib\include\pj\rbtree.h"\
-	"..\..\..\pjlib\include\pj\sock.h"\
-	"..\..\..\pjlib\include\pj\sock_select.h"\
-	"..\..\..\pjlib\include\pj\string.h"\
-	"..\..\..\pjlib\include\pj\string_i.h"\
-	"..\..\..\pjlib\include\pj\timer.h"\
-	"..\..\..\pjlib\include\pj\types.h"\
-	"..\..\..\pjlib\include\pj\unicode.h"\
-	"..\..\..\pjlib\include\pjlib.h"\
-	"..\..\include\pjnath\config.h"\
-	"..\..\include\pjnath\errno.h"\
-	"..\..\include\pjnath\stun_msg.h"\
-	"..\..\include\pjnath\types.h"\
-	
-
-!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
-
-DEP_CPP_STUN_MS=\
-	"..\..\..\pjlib\include\pj\addr_resolv.h"\
-	"..\..\..\pjlib\include\pj\array.h"\
-	"..\..\..\pjlib\include\pj\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
 	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
@@ -4945,4 +4914,73 @@
 	
 
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_STUN_MS=\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
 !ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Release"
 
@@ -5481,55 +5519,62 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
-	"..\..\..\pjlib\include\pj\compat\string.h"\
-	"..\..\..\pjlib\include\pj\config.h"\
-	"..\..\..\pjlib\include\pj\config_site.h"\
-	"..\..\..\pjlib\include\pj\config_site_sample.h"\
-	"..\..\..\pjlib\include\pj\ctype.h"\
-	"..\..\..\pjlib\include\pj\errno.h"\
-	"..\..\..\pjlib\include\pj\except.h"\
-	"..\..\..\pjlib\include\pj\fifobuf.h"\
-	"..\..\..\pjlib\include\pj\file_access.h"\
-	"..\..\..\pjlib\include\pj\file_io.h"\
-	"..\..\..\pjlib\include\pj\guid.h"\
-	"..\..\..\pjlib\include\pj\hash.h"\
-	"..\..\..\pjlib\include\pj\ioqueue.h"\
-	"..\..\..\pjlib\include\pj\ip_helper.h"\
-	"..\..\..\pjlib\include\pj\list.h"\
-	"..\..\..\pjlib\include\pj\list_i.h"\
-	"..\..\..\pjlib\include\pj\lock.h"\
-	"..\..\..\pjlib\include\pj\log.h"\
-	"..\..\..\pjlib\include\pj\os.h"\
-	"..\..\..\pjlib\include\pj\pool.h"\
-	"..\..\..\pjlib\include\pj\pool_alt.h"\
-	"..\..\..\pjlib\include\pj\pool_buf.h"\
-	"..\..\..\pjlib\include\pj\pool_i.h"\
-	"..\..\..\pjlib\include\pj\rand.h"\
-	"..\..\..\pjlib\include\pj\rbtree.h"\
-	"..\..\..\pjlib\include\pj\sock.h"\
-	"..\..\..\pjlib\include\pj\sock_select.h"\
-	"..\..\..\pjlib\include\pj\string.h"\
-	"..\..\..\pjlib\include\pj\string_i.h"\
-	"..\..\..\pjlib\include\pj\timer.h"\
-	"..\..\..\pjlib\include\pj\types.h"\
-	"..\..\..\pjlib\include\pj\unicode.h"\
-	"..\..\..\pjlib\include\pjlib.h"\
-	"..\..\include\pjnath\config.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
 	"..\..\include\pjnath\stun_auth.h"\
 	"..\..\include\pjnath\stun_config.h"\
@@ -6156,69 +6201,4 @@
 	"..\..\..\pjlib\include\pj\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
-	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
-	"..\..\..\pjlib\include\pj\compat\ctype.h"\
-	"..\..\..\pjlib\include\pj\compat\errno.h"\
-	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
-	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
-	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
-	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
-	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
-	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
-	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
-	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
-	"..\..\..\pjlib\include\pj\compat\size_t.h"\
-	"..\..\..\pjlib\include\pj\compat\string.h"\
-	"..\..\..\pjlib\include\pj\config.h"\
-	"..\..\..\pjlib\include\pj\config_site.h"\
-	"..\..\..\pjlib\include\pj\config_site_sample.h"\
-	"..\..\..\pjlib\include\pj\ctype.h"\
-	"..\..\..\pjlib\include\pj\errno.h"\
-	"..\..\..\pjlib\include\pj\except.h"\
-	"..\..\..\pjlib\include\pj\fifobuf.h"\
-	"..\..\..\pjlib\include\pj\file_access.h"\
-	"..\..\..\pjlib\include\pj\file_io.h"\
-	"..\..\..\pjlib\include\pj\guid.h"\
-	"..\..\..\pjlib\include\pj\hash.h"\
-	"..\..\..\pjlib\include\pj\ioqueue.h"\
-	"..\..\..\pjlib\include\pj\ip_helper.h"\
-	"..\..\..\pjlib\include\pj\list.h"\
-	"..\..\..\pjlib\include\pj\list_i.h"\
-	"..\..\..\pjlib\include\pj\lock.h"\
-	"..\..\..\pjlib\include\pj\log.h"\
-	"..\..\..\pjlib\include\pj\os.h"\
-	"..\..\..\pjlib\include\pj\pool.h"\
-	"..\..\..\pjlib\include\pj\pool_alt.h"\
-	"..\..\..\pjlib\include\pj\pool_buf.h"\
-	"..\..\..\pjlib\include\pj\pool_i.h"\
-	"..\..\..\pjlib\include\pj\rand.h"\
-	"..\..\..\pjlib\include\pj\rbtree.h"\
-	"..\..\..\pjlib\include\pj\sock.h"\
-	"..\..\..\pjlib\include\pj\sock_select.h"\
-	"..\..\..\pjlib\include\pj\string.h"\
-	"..\..\..\pjlib\include\pj\string_i.h"\
-	"..\..\..\pjlib\include\pj\timer.h"\
-	"..\..\..\pjlib\include\pj\types.h"\
-	"..\..\..\pjlib\include\pj\unicode.h"\
-	"..\..\..\pjlib\include\pjlib.h"\
-	"..\..\include\pjnath\config.h"\
-	"..\..\include\pjnath\errno.h"\
-	"..\..\include\pjnath\stun_config.h"\
-	"..\..\include\pjnath\stun_msg.h"\
-	"..\..\include\pjnath\stun_transaction.h"\
-	"..\..\include\pjnath\types.h"\
-	
-
-!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
-
-DEP_CPP_STUN_T=\
-	"..\..\..\pjlib\include\pj\addr_resolv.h"\
-	"..\..\..\pjlib\include\pj\array.h"\
-	"..\..\..\pjlib\include\pj\assert.h"\
-	"..\..\..\pjlib\include\pj\compat\assert.h"\
 	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
 	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
@@ -6285,4 +6265,75 @@
 	
 
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_STUN_T=\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
 !ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Release"
 
@@ -6542,4 +6593,1588 @@
 	"..\..\include\pjnath\stun_msg.h"\
 	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\pjnath\turn_session.c
+
+!IF  "$(CFG)" == "pjnath_wince - Win32 (WCE emulator) Release"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE emulator) Debug"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE x86) Release"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE x86) Debug"
+
+DEP_CPP_TURN_=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\srv_resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\errno.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\pjnath\turn_sock.c
+
+!IF  "$(CFG)" == "pjnath_wince - Win32 (WCE emulator) Release"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE emulator) Debug"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4I) Release"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4I) Debug"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Release"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4) Debug"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Release"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE ARMV4T) Debug"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE x86) Release"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
+	"..\..\include\pjnath\types.h"\
+	
+
+!ELSEIF  "$(CFG)" == "pjnath_wince - Win32 (WCE x86) Debug"
+
+DEP_CPP_TURN_S=\
+	"..\..\..\pjlib-util\include\pjlib-util\config.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\dns.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\resolver.h"\
+	"..\..\..\pjlib-util\include\pjlib-util\types.h"\
+	"..\..\..\pjlib\include\pj\addr_resolv.h"\
+	"..\..\..\pjlib\include\pj\array.h"\
+	"..\..\..\pjlib\include\pj\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\assert.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_armcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_codew.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_gcce.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_msvc.h"\
+	"..\..\..\pjlib\include\pj\compat\cc_mwcc.h"\
+	"..\..\..\pjlib\include\pj\compat\ctype.h"\
+	"..\..\..\pjlib\include\pj\compat\errno.h"\
+	"..\..\..\pjlib\include\pj\compat\high_precision.h"\
+	"..\..\..\pjlib\include\pj\compat\m_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_auto.h"\
+	"..\..\..\pjlib\include\pj\compat\os_darwinos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux.h"\
+	"..\..\..\pjlib\include\pj\compat\os_linux_kernel.h"\
+	"..\..\..\pjlib\include\pj\compat\os_palmos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_rtems.h"\
+	"..\..\..\pjlib\include\pj\compat\os_sunos.h"\
+	"..\..\..\pjlib\include\pj\compat\os_symbian.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32.h"\
+	"..\..\..\pjlib\include\pj\compat\os_win32_wince.h"\
+	"..\..\..\pjlib\include\pj\compat\setjmp.h"\
+	"..\..\..\pjlib\include\pj\compat\size_t.h"\
+	"..\..\..\pjlib\include\pj\compat\stdarg.h"\
+	"..\..\..\pjlib\include\pj\compat\string.h"\
+	"..\..\..\pjlib\include\pj\config.h"\
+	"..\..\..\pjlib\include\pj\config_site.h"\
+	"..\..\..\pjlib\include\pj\config_site_sample.h"\
+	"..\..\..\pjlib\include\pj\ctype.h"\
+	"..\..\..\pjlib\include\pj\errno.h"\
+	"..\..\..\pjlib\include\pj\except.h"\
+	"..\..\..\pjlib\include\pj\fifobuf.h"\
+	"..\..\..\pjlib\include\pj\file_access.h"\
+	"..\..\..\pjlib\include\pj\file_io.h"\
+	"..\..\..\pjlib\include\pj\guid.h"\
+	"..\..\..\pjlib\include\pj\hash.h"\
+	"..\..\..\pjlib\include\pj\ioqueue.h"\
+	"..\..\..\pjlib\include\pj\ip_helper.h"\
+	"..\..\..\pjlib\include\pj\list.h"\
+	"..\..\..\pjlib\include\pj\list_i.h"\
+	"..\..\..\pjlib\include\pj\lock.h"\
+	"..\..\..\pjlib\include\pj\log.h"\
+	"..\..\..\pjlib\include\pj\os.h"\
+	"..\..\..\pjlib\include\pj\pool.h"\
+	"..\..\..\pjlib\include\pj\pool_alt.h"\
+	"..\..\..\pjlib\include\pj\pool_buf.h"\
+	"..\..\..\pjlib\include\pj\pool_i.h"\
+	"..\..\..\pjlib\include\pj\rand.h"\
+	"..\..\..\pjlib\include\pj\rbtree.h"\
+	"..\..\..\pjlib\include\pj\sock.h"\
+	"..\..\..\pjlib\include\pj\sock_select.h"\
+	"..\..\..\pjlib\include\pj\string.h"\
+	"..\..\..\pjlib\include\pj\string_i.h"\
+	"..\..\..\pjlib\include\pj\timer.h"\
+	"..\..\..\pjlib\include\pj\types.h"\
+	"..\..\..\pjlib\include\pj\unicode.h"\
+	"..\..\..\pjlib\include\pjlib.h"\
+	"..\..\include\pjnath\config.h"\
+	"..\..\include\pjnath\stun_auth.h"\
+	"..\..\include\pjnath\stun_config.h"\
+	"..\..\include\pjnath\stun_msg.h"\
+	"..\..\include\pjnath\stun_session.h"\
+	"..\..\include\pjnath\stun_transaction.h"\
+	"..\..\include\pjnath\turn_session.h"\
+	"..\..\include\pjnath\turn_sock.h"\
 	"..\..\include\pjnath\types.h"\
 	
@@ -6595,4 +8230,12 @@
 
 SOURCE=..\..\include\pjnath\stun_transaction.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\pjnath\turn_session.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\pjnath\turn_sock.h
 # End Source File
 # Begin Source File
Index: pjproject/trunk/pjnath/include/pjnath.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath.h	(revision 1912)
+++ pjproject/trunk/pjnath/include/pjnath.h	(revision 1913)
@@ -29,5 +29,5 @@
 #include <pjnath/stun_transaction.h>
 #include <pjnath/turn_session.h>
-#include <pjnath/turn_udp.h>
+#include <pjnath/turn_sock.h>
 #include <pjnath/types.h>
 
Index: pjproject/trunk/pjnath/include/pjnath/stun_session.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/stun_session.h	(revision 1912)
+++ pjproject/trunk/pjnath/include/pjnath/stun_session.h	(revision 1913)
@@ -65,4 +65,13 @@
      *
      * @param sess	    The STUN session.
+     * @param token	    The token associated with this outgoing message
+     *			    and was set by the application. This token was 
+     *			    set by application in pj_stun_session_send_msg()
+     *			    for outgoing messages that are initiated by the
+     *			    application, or in pj_stun_session_on_rx_pkt()
+     *			    if this message is a response that was internally
+     *			    generated by the STUN session (for example, an
+     *			    401/Unauthorized response). Application may use
+     *			    this facility for any purposes.
      * @param pkt	    Packet to be sent.
      * @param pkt_size	    Size of the packet to be sent.
@@ -74,4 +83,5 @@
      */
     pj_status_t (*on_send_msg)(pj_stun_session *sess,
+			       void *token,
 			       const void *pkt,
 			       pj_size_t pkt_size,
@@ -80,5 +90,8 @@
 
     /** 
-     * Callback to be called on incoming STUN request message. In the 
+     * Callback to be called on incoming STUN request message. This function
+     * is called when application calls pj_stun_session_on_rx_pkt() and when
+     * the STUN session has detected that the incoming STUN message is a
+     * STUN request message. In the 
      * callback processing, application MUST create a response by calling
      * pj_stun_session_create_response() function and send the response
@@ -90,4 +103,6 @@
      * @param pkt_len	    Length of the STUN packet.
      * @param rdata	    Data containing incoming request message.
+     * @param token	    The token that was set by the application when
+     *			    calling pj_stun_session_on_rx_pkt() function.
      * @param src_addr	    Source address of the packet.
      * @param src_addr_len  Length of the source address.
@@ -101,4 +116,5 @@
 				 unsigned pkt_len,
 				 const pj_stun_rx_data *rdata,
+				 void *token,
 				 const pj_sockaddr_t *src_addr,
 				 unsigned src_addr_len);
@@ -106,5 +122,9 @@
     /**
      * Callback to be called when response is received or the transaction 
-     * has timed out.
+     * has timed out. This callback is called either when application calls
+     * pj_stun_session_on_rx_pkt() with the packet containing a STUN
+     * response for the client transaction, or when the internal timer of
+     * the STUN client transaction has timed-out before a STUN response is
+     * received.
      *
      * @param sess	    The STUN session.
@@ -116,4 +136,8 @@
      *			    response may contain non-NULL value if the 
      *			    response contains STUN ERROR-CODE attribute.
+     * @param token	    The token that was set by the application  when
+     *			    calling pj_stun_session_send_msg() function.
+     *			    Please not that this token IS NOT the token
+     *			    that was given in pj_stun_session_on_rx_pkt().
      * @param tdata	    The original STUN request.
      * @param response	    The response message, on successful transaction,
@@ -128,4 +152,5 @@
     void (*on_request_complete)(pj_stun_session *sess,
 			        pj_status_t status,
+				void *token,
 			        pj_stun_tx_data *tdata,
 			        const pj_stun_msg *response,
@@ -135,5 +160,21 @@
 
     /**
-     * Type of callback to be called on incoming STUN indication.
+     * Callback to be called on incoming STUN request message. This function
+     * is called when application calls pj_stun_session_on_rx_pkt() and when
+     * the STUN session has detected that the incoming STUN message is a
+     * STUN indication message.
+     *
+     * @param sess	    The STUN session.
+     * @param pkt	    Pointer to the original STUN packet.
+     * @param pkt_len	    Length of the STUN packet.
+     * @param msg	    The parsed STUN indication.
+     * @param token	    The token that was set by the application when
+     *			    calling pj_stun_session_on_rx_pkt() function.
+     * @param src_addr	    Source address of the packet.
+     * @param src_addr_len  Length of the source address.
+     *
+     * @return		    The return value of this callback will be
+     *			    returned back to pj_stun_session_on_rx_pkt()
+     *			    function.
      */
     pj_status_t (*on_rx_indication)(pj_stun_session *sess,
@@ -141,4 +182,5 @@
 				    unsigned pkt_len,
 				    const pj_stun_msg *msg,
+				    void *token,
 				    const pj_sockaddr_t *src_addr,
 				    unsigned src_addr_len);
@@ -178,7 +220,8 @@
     pj_stun_msg		*msg;		/**< The STUN message.		    */
 
-    void		*user_data;	/**< Arbitrary application data.    */
+    void		*token;		/**< The token.			    */
 
     pj_stun_client_tsx	*client_tsx;	/**< Client STUN transaction.	    */
+    pj_bool_t		 retransmit;	/**< Retransmit request?	    */
     pj_uint32_t		 msg_magic;	/**< Message magic.		    */
     pj_uint8_t		 msg_key[12];	/**< Message/transaction key.	    */
@@ -369,5 +412,19 @@
  *
  * @param sess	    The STUN session instance.
- * @param cache_res If PJ_TRUE then response will be cached.
+ * @param token	    Optional token which will be given back to application in
+ *		    \a on_send_msg() callback and \a on_request_complete()
+ *		    callback, if the message is a STUN request message. 
+ *		    Internally this function will put the token in the 
+ *		    \a token field of pj_stun_tx_data, hence it will
+ *		    overwrite any value that the application puts there.
+ * @param cache_res If the message is a response message for an incoming
+ *		    request, specify PJ_TRUE to instruct the STUN session
+ *		    to cache this response for subsequent incoming request
+ *		    retransmission. Otherwise this parameter will be ignored
+ *		    for non-response message.
+ * @param retransmit If the message is a request message, specify whether the
+ *		    request should be retransmitted. Normally application will
+ *		    specify TRUE if the underlying transport is UDP and FALSE
+ *		    if the underlying transport is TCP or TLS.
  * @param dst_addr  The destination socket address.
  * @param addr_len  Length of destination address.
@@ -378,5 +435,7 @@
  */
 PJ_DECL(pj_status_t) pj_stun_session_send_msg(pj_stun_session *sess,
+					      void *token,
 					      pj_bool_t cache_res,
+					      pj_bool_t retransmit,
 					      const pj_sockaddr_t *dst_addr,
 					      unsigned addr_len,
@@ -384,5 +443,8 @@
 
 /**
- * Create and send STUN response message.
+ * This is a utility function to create and send response for an incoming
+ * STUN request. Internally this function calls pj_stun_session_create_res()
+ * and pj_stun_session_send_msg(). It is provided here as a matter of
+ * convenience.
  *
  * @param sess	    The STUN session instance.
@@ -396,4 +458,10 @@
  *		    \a err_code is non-zero, then default error message will
  *		    be used.
+ * @param token	    Optional token which will be given back to application in
+ *		    \a on_send_msg() callback and \a on_request_complete()
+ *		    callback, if the message is a STUN request message. 
+ *		    Internally this function will put the token in the 
+ *		    \a token field of pj_stun_tx_data, hence it will
+ *		    overwrite any value that the application puts there.
  * @param cache	    Specify whether session should cache this response for
  *		    future request retransmission. If TRUE, subsequent request
@@ -410,4 +478,5 @@
 					     unsigned code, 
 					     const char *err_msg,
+					     void *token,
 					     pj_bool_t cache, 
 					     const pj_sockaddr_t *dst_addr, 
@@ -469,5 +538,12 @@
  *			STUN message (useful if packet is received via a
  *			stream oriented protocol).
- * @param src_addr	The source address of the packet.
+ * @param token		Optional token which will be given back to application
+ *			in the \a on_rx_request(), \a on_rx_indication() and 
+ *			\a on_send_msg() callbacks. The token can be used to 
+ *			associate processing or incoming request or indication
+ *			with some context.
+ * @param src_addr	The source address of the packet, which will also
+ *			be given back to application callbacks, along with
+ *			source address length.
  * @param src_addr_len	Length of the source address.
  *
@@ -478,4 +554,5 @@
 					       pj_size_t pkt_size,
 					       unsigned options,
+					       void *token,
 					       unsigned *parsed_len,
 					       const pj_sockaddr_t *src_addr,
Index: pjproject/trunk/pjnath/include/pjnath/turn_session.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/turn_session.h	(revision 1912)
+++ pjproject/trunk/pjnath/include/pjnath/turn_session.h	(revision 1913)
@@ -56,10 +56,27 @@
 
 
-/** TURN transport types */
+/** 
+ * TURN transport types, which will be used both to specify the connection 
+ * type for reaching TURN server and the type of allocation transport to be 
+ * requested to server (the REQUESTED-TRANSPORT attribute).
+ */
 typedef enum pj_turn_tp_type
 {
-    PJ_TURN_TP_UDP = 17,    /**< UDP.	*/
-    PJ_TURN_TP_TCP = 6,	    /**< TCP.	*/
-    PJ_TURN_TP_TLS = 256    /**< TLS.	*/
+    /**
+     * UDP transport, which value corresponds to IANA protocol number.
+     */
+    PJ_TURN_TP_UDP = 17,
+
+    /**
+     * TCP transport, which value corresponds to IANA protocol number.
+     */
+    PJ_TURN_TP_TCP = 6,
+
+    /**
+     * TLS transport. The TLS transport will only be used as the connection
+     * type to reach the server and never as the allocation transport type.
+     */
+    PJ_TURN_TP_TLS = 255
+
 } pj_turn_tp_type;
 
@@ -219,4 +236,16 @@
 } pj_turn_session_info;
 
+
+/**
+ * Create default pj_turn_alloc_param.
+ */
+PJ_DECL(void) pj_turn_alloc_param_default(pj_turn_alloc_param *prm);
+
+/**
+ * Duplicate pj_turn_alloc_param.
+ */
+PJ_DECL(void) pj_turn_alloc_param_copy(pj_pool_t *pool, 
+				       pj_turn_alloc_param *dst,
+				       const pj_turn_alloc_param *src);
 
 /**
@@ -240,5 +269,11 @@
 
 /**
- * Destroy TURN client session.
+ * Shutdown TURN client session.
+ */
+PJ_DECL(pj_status_t) pj_turn_session_shutdown(pj_turn_session *sess);
+
+
+/**
+ * Forcefully destroy the TURN session.
  */
 PJ_DECL(pj_status_t) pj_turn_session_destroy(pj_turn_session *sess);
Index: pjproject/trunk/pjnath/include/pjnath/turn_sock.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/turn_sock.h	(revision 1913)
+++ pjproject/trunk/pjnath/include/pjnath/turn_sock.h	(revision 1913)
@@ -0,0 +1,142 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJNATH_turn_sock_H__
+#define __PJNATH_turn_sock_H__
+
+/**
+ * @file turn_sock.h
+ * @brief TURN relay using UDP client as transport protocol
+ */
+#include <pjnath/turn_session.h>
+
+
+PJ_BEGIN_DECL
+
+
+/* **************************************************************************/
+/**
+ * @defgroup PJNATH_TURN_UDP TURN TCP client
+ * @brief TURN relay using TCP client as transport protocol
+ * @ingroup PJNATH_STUN
+ * @{
+ */
+
+
+/** 
+ * Opaque declaration for TURN TCP client.
+ */
+typedef struct pj_turn_sock pj_turn_sock;
+
+
+typedef struct pj_turn_sock_cb
+{
+    /**
+     * Notification when incoming data has been received, either through
+     * Data indication or ChannelData message from the TURN server.
+     *
+     * This callback is mandatory.
+     */
+    void (*on_rx_data)(pj_turn_sock *turn_sock,
+		       const pj_uint8_t *pkt,
+		       unsigned pkt_len,
+		       const pj_sockaddr_t *peer_addr,
+		       unsigned addr_len);
+
+    /**
+     * Notification when TURN session state has changed. Application should
+     * implement this callback to know that the TURN session is no longer
+     * available.
+     */
+    void (*on_state)(pj_turn_sock *turn_sock, pj_turn_state_t old_state,
+		     pj_turn_state_t new_state);
+
+} pj_turn_sock_cb;
+
+
+/**
+ * Create.
+ */
+PJ_DECL(pj_status_t) pj_turn_sock_create(pj_stun_config *cfg,
+					 int af,
+					 pj_turn_tp_type conn_type,
+					 const pj_turn_sock_cb *cb,
+					 unsigned options,
+					 void *user_data,
+					 pj_turn_sock **p_turn_sock);
+
+/**
+ * Destroy.
+ */
+PJ_DECL(void) pj_turn_sock_destroy(pj_turn_sock *turn_sock);
+
+/**
+ * Set user data.
+ */
+PJ_DECL(pj_status_t) pj_turn_sock_set_user_data(pj_turn_sock *turn_sock,
+					       void *user_data);
+
+/**
+ * Get user data.
+ */
+PJ_DECL(void*) pj_turn_sock_get_user_data(pj_turn_sock *turn_sock);
+
+
+/**
+ * Get info.
+ */
+PJ_DECL(pj_status_t) pj_turn_sock_get_info(pj_turn_sock *turn_sock,
+					  pj_turn_session_info *info);
+
+/**
+ * Initialize.
+ */
+PJ_DECL(pj_status_t) pj_turn_sock_init(pj_turn_sock *turn_sock,
+				       const pj_str_t *domain,
+				       int default_port,
+				       pj_dns_resolver *resolver,
+				       const pj_stun_auth_cred *cred,
+				       const pj_turn_alloc_param *param);
+
+/**
+ * Send packet.
+ */ 
+PJ_DECL(pj_status_t) pj_turn_sock_sendto(pj_turn_sock *turn_sock,
+					const pj_uint8_t *pkt,
+					unsigned pkt_len,
+					const pj_sockaddr_t *addr,
+					unsigned addr_len);
+
+/**
+ * Bind a peer address to a channel number.
+ */
+PJ_DECL(pj_status_t) pj_turn_sock_bind_channel(pj_turn_sock *turn_sock,
+					      const pj_sockaddr_t *peer,
+					      unsigned addr_len);
+
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+
+#endif	/* __PJNATH_turn_sock_H__ */
+
Index: pjproject/trunk/pjnath/include/pjnath/turn_udp.h
===================================================================
--- pjproject/trunk/pjnath/include/pjnath/turn_udp.h	(revision 1912)
+++ 	(revision )
@@ -1,141 +1,0 @@
-/* $Id$ */
-/* 
- * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-#ifndef __PJNATH_TURN_UDP_H__
-#define __PJNATH_TURN_UDP_H__
-
-/**
- * @file turn_udp.h
- * @brief TURN relay using UDP client as transport protocol
- */
-#include <pjnath/turn_session.h>
-
-
-PJ_BEGIN_DECL
-
-
-/* **************************************************************************/
-/**
- * @defgroup PJNATH_TURN_UDP TURN UDP client
- * @brief TURN relay using UDP client as transport protocol
- * @ingroup PJNATH_STUN
- * @{
- */
-
-
-/** 
- * Opaque declaration for TURN UDP client.
- */
-typedef struct pj_turn_udp pj_turn_udp;
-
-
-typedef struct pj_turn_udp_cb
-{
-    /**
-     * Notification when incoming data has been received, either through
-     * Data indication or ChannelData message from the TURN server.
-     *
-     * This callback is mandatory.
-     */
-    void (*on_rx_data)(pj_turn_udp *udp_rel,
-		       const pj_uint8_t *pkt,
-		       unsigned pkt_len,
-		       const pj_sockaddr_t *peer_addr,
-		       unsigned addr_len);
-
-    /**
-     * Notification when TURN session state has changed. Application should
-     * implement this callback to know that the TURN session is no longer
-     * available.
-     */
-    void (*on_state)(pj_turn_udp *udp_rel, pj_turn_state_t old_state,
-		     pj_turn_state_t new_state);
-
-} pj_turn_udp_cb;
-
-
-/**
- * Create.
- */
-PJ_DECL(pj_status_t) pj_turn_udp_create(pj_stun_config *cfg,
-					int af,
-					const pj_turn_udp_cb *cb,
-					unsigned options,
-					void *user_data,
-					pj_turn_udp **p_udp_rel);
-
-/**
- * Destroy.
- */
-PJ_DECL(void) pj_turn_udp_destroy(pj_turn_udp *udp_rel);
-
-/**
- * Set user data.
- */
-PJ_DECL(pj_status_t) pj_turn_udp_set_user_data(pj_turn_udp *udp_rel,
-					       void *user_data);
-
-/**
- * Get user data.
- */
-PJ_DECL(void*) pj_turn_udp_get_user_data(pj_turn_udp *udp_rel);
-
-
-/**
- * Get info.
- */
-PJ_DECL(pj_status_t) pj_turn_udp_get_info(pj_turn_udp *udp_rel,
-					  pj_turn_session_info *info);
-
-/**
- * Initialize.
- */
-PJ_DECL(pj_status_t) pj_turn_udp_init(pj_turn_udp *udp_rel,
-				      const pj_str_t *domain,
-				      int default_port,
-				      pj_dns_resolver *resolver,
-				      const pj_stun_auth_cred *cred,
-				      const pj_turn_alloc_param *param);
-
-/**
- * Send packet.
- */ 
-PJ_DECL(pj_status_t) pj_turn_udp_sendto(pj_turn_udp *udp_rel,
-					const pj_uint8_t *pkt,
-					unsigned pkt_len,
-					const pj_sockaddr_t *addr,
-					unsigned addr_len);
-
-/**
- * Bind a peer address to a channel number.
- */
-PJ_DECL(pj_status_t) pj_turn_udp_bind_channel(pj_turn_udp *udp_rel,
-					      const pj_sockaddr_t *peer,
-					      unsigned addr_len);
-
-
-/**
- * @}
- */
-
-
-PJ_END_DECL
-
-
-#endif	/* __PJNATH_TURN_UDP_H__ */
-
Index: pjproject/trunk/pjnath/src/pjnath/ice_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 1913)
@@ -114,4 +114,5 @@
 /* These are the callbacks registered to the STUN sessions */
 static pj_status_t on_stun_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -122,8 +123,10 @@
 				      unsigned pkt_len,
 				      const pj_stun_rx_data *rdata,
+				      void *token,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len);
 static void on_stun_request_complete(pj_stun_session *stun_sess,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -134,4 +137,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len);
@@ -1393,5 +1397,4 @@
     rd->clist = clist;
     rd->ckid = check_id;
-    check->tdata->user_data = (void*) rd;
 
     /* Add PRIORITY */
@@ -1425,6 +1428,6 @@
 
     /* Initiate STUN transaction to send the request */
-    status = pj_stun_session_send_msg(comp->stun_sess, PJ_FALSE, 
-				      &rcand->addr, 
+    status = pj_stun_session_send_msg(comp->stun_sess, (void*)rd, PJ_FALSE, 
+				      PJ_TRUE, &rcand->addr, 
 				      sizeof(pj_sockaddr_in), check->tdata);
     if (status != PJ_SUCCESS) {
@@ -1645,4 +1648,5 @@
  */
 static pj_status_t on_stun_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -1652,4 +1656,7 @@
     stun_data *sd = (stun_data*) pj_stun_session_get_user_data(sess);
     pj_ice_sess *ice = sd->ice;
+
+    PJ_UNUSED_ARG(token);
+
     return (*ice->cb.on_tx_pkt)(ice, sd->comp_id, 
 				pkt, pkt_size, 
@@ -1661,4 +1668,5 @@
 static void on_stun_request_complete(pj_stun_session *stun_sess,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -1666,5 +1674,5 @@
 				     unsigned src_addr_len)
 {
-    struct req_data *rd = (struct req_data*) tdata->user_data;
+    struct req_data *rd = (struct req_data*) token;
     pj_ice_sess *ice;
     pj_ice_sess_check *check, *new_check;
@@ -1906,4 +1914,5 @@
 				      unsigned pkt_len,
 				      const pj_stun_rx_data *rdata,
+				      void *token,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len)
@@ -1921,15 +1930,12 @@
     PJ_UNUSED_ARG(pkt);
     PJ_UNUSED_ARG(pkt_len);
+    PJ_UNUSED_ARG(token);
 
     /* Reject any requests except Binding request */
     if (msg->hdr.type != PJ_STUN_BINDING_REQUEST) {
-	status = pj_stun_session_create_res(sess, rdata, 
-					    PJ_STUN_SC_BAD_REQUEST,
-					    NULL, &tdata);
-	if (status != PJ_SUCCESS)
-	    return status;
-
-	return pj_stun_session_send_msg(sess, PJ_TRUE, 
-					src_addr, src_addr_len, tdata);
+	pj_stun_session_respond(sess, rdata, PJ_STUN_SC_BAD_REQUEST, 
+				NULL, NULL, PJ_TRUE, 
+				src_addr, src_addr_len);
+	return PJ_SUCCESS;
     }
 
@@ -1995,11 +2001,7 @@
 	} else {
 	    /* Generate 487 response */
-	    status = pj_stun_session_create_res(sess, rdata, 
-					        PJ_STUN_SC_ROLE_CONFLICT,
-						NULL, &tdata);
-	    if (status == PJ_SUCCESS) {
-		pj_stun_session_send_msg(sess, PJ_TRUE, 
-				         src_addr, src_addr_len, tdata);
-	    }
+	    pj_stun_session_respond(sess, rdata, PJ_STUN_SC_ROLE_CONFLICT, 
+				    NULL, NULL, PJ_TRUE, 
+				    src_addr, src_addr_len);
 	    pj_mutex_unlock(ice->mutex);
 	    return PJ_SUCCESS;
@@ -2011,11 +2013,7 @@
 	if (pj_cmp_timestamp(&ice->tie_breaker, &role_attr->value) < 0) {
 	    /* Generate 487 response */
-	    status = pj_stun_session_create_res(sess, rdata, 
-					        PJ_STUN_SC_ROLE_CONFLICT,
-						NULL, &tdata);
-	    if (status == PJ_SUCCESS) {
-		pj_stun_session_send_msg(sess, PJ_TRUE, 
-				         src_addr, src_addr_len, tdata);
-	    }
+	    pj_stun_session_respond(sess, rdata, PJ_STUN_SC_ROLE_CONFLICT, 
+				    NULL, NULL, PJ_TRUE, 
+				    src_addr, src_addr_len);
 	    pj_mutex_unlock(ice->mutex);
 	    return PJ_SUCCESS;
@@ -2041,5 +2039,5 @@
 					   PJ_TRUE, src_addr, src_addr_len);
 
-    status = pj_stun_session_send_msg(sess, PJ_TRUE, 
+    status = pj_stun_session_send_msg(sess, NULL, PJ_TRUE, PJ_TRUE,
 				      src_addr, src_addr_len, tdata);
 
@@ -2287,4 +2285,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len)
@@ -2294,4 +2293,5 @@
     PJ_UNUSED_ARG(pkt_len);
     PJ_UNUSED_ARG(msg);
+    PJ_UNUSED_ARG(token);
     PJ_UNUSED_ARG(src_addr);
     PJ_UNUSED_ARG(src_addr_len);
@@ -2368,5 +2368,5 @@
     if (stun_status == PJ_SUCCESS) {
 	status = pj_stun_session_on_rx_pkt(comp->stun_sess, pkt, pkt_size,
-					   PJ_STUN_IS_DATAGRAM,
+					   PJ_STUN_IS_DATAGRAM, NULL,
 					   NULL, src_addr, src_addr_len);
 	if (status != PJ_SUCCESS) {
Index: pjproject/trunk/pjnath/src/pjnath/ice_strans.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 1913)
@@ -61,4 +61,5 @@
 /* STUN session callback */
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -67,4 +68,5 @@
 static void stun_on_request_complete(pj_stun_session *sess,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -491,5 +493,5 @@
 						   bytes_read, 
 						   PJ_STUN_IS_DATAGRAM, NULL,
-						   &comp->src_addr, 
+						   NULL, &comp->src_addr, 
 						   comp->src_addr_len);
 	    } else if (ice_st->ice) {
@@ -601,6 +603,4 @@
 	//tdata->user_data = NULL;
 
-	// We need this to support mapped address change
-	tdata->user_data = &comp->cand_list[j];
 	++comp->pending_cnt;
 
@@ -610,6 +610,6 @@
 		  pj_inet_ntoa(comp->local_addr.ipv4.sin_addr),
 		  pj_ntohs(comp->local_addr.ipv4.sin_port)));
-	status = pj_stun_session_send_msg(comp->stun_sess, PJ_FALSE, 
-					  &ice_st->stun_srv, 
+	status = pj_stun_session_send_msg(comp->stun_sess, &comp->cand_list[j],
+					  PJ_FALSE, PJ_TRUE, &ice_st->stun_srv,
 					  sizeof(pj_sockaddr_in), tdata);
 	if (status != PJ_SUCCESS) {
@@ -701,7 +701,6 @@
 	return status;
 
-    /* Attach alias instance to tdata */
+    /* Will be attached to tdata in send_msg() */
     cand = &comp->cand_list[comp->cand_cnt];
-    tdata->user_data = (void*)cand;
 
     /* Add pending count first, since stun_on_request_complete()
@@ -721,6 +720,6 @@
 
     /* Send STUN binding request */
-    status = pj_stun_session_send_msg(comp->stun_sess, PJ_FALSE, 
-				      &ice_st->stun_srv, 
+    status = pj_stun_session_send_msg(comp->stun_sess, (void*)cand, PJ_FALSE, 
+				      PJ_TRUE, &ice_st->stun_srv, 
 				      sizeof(pj_sockaddr_in), tdata);
     if (status != PJ_SUCCESS) {
@@ -1079,4 +1078,5 @@
  */
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t size,
@@ -1087,4 +1087,6 @@
     pj_ssize_t pkt_size;
     pj_status_t status;
+
+    PJ_UNUSED_ARG(token);
 
     comp = (pj_ice_strans_comp*) pj_stun_session_get_user_data(sess);
@@ -1103,4 +1105,5 @@
 static void stun_on_request_complete(pj_stun_session *sess,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -1116,6 +1119,8 @@
 
     comp = (pj_ice_strans_comp*) pj_stun_session_get_user_data(sess);
-    cand = (pj_ice_strans_cand*) tdata->user_data;
-
+    cand = (pj_ice_strans_cand*) token;
+
+    PJ_UNUSED_ARG(token);
+    PJ_UNUSED_ARG(tdata);
     PJ_UNUSED_ARG(src_addr);
     PJ_UNUSED_ARG(src_addr_len);
Index: pjproject/trunk/pjnath/src/pjnath/nat_detect.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjnath/nat_detect.c	(revision 1913)
@@ -114,4 +114,5 @@
 static void on_request_complete(pj_stun_session *sess,
 			        pj_status_t status,
+				void *token,
 			        pj_stun_tx_data *tdata,
 			        const pj_stun_msg *response,
@@ -119,4 +120,5 @@
 				unsigned src_addr_len);
 static pj_status_t on_send_msg(pj_stun_session *sess,
+			       void *token,
 			       const void *pkt,
 			       pj_size_t pkt_size,
@@ -415,5 +417,6 @@
 	pj_stun_session_on_rx_pkt(sess->stun_sess, sess->rx_pkt, bytes_read,
 				  PJ_STUN_IS_DATAGRAM|PJ_STUN_CHECK_PACKET, 
-				  NULL, &sess->src_addr, sess->src_addr_len);
+				  NULL, NULL, 
+				  &sess->src_addr, sess->src_addr_len);
     }
 
@@ -439,4 +442,5 @@
  */
 static pj_status_t on_send_msg(pj_stun_session *stun_sess,
+			       void *token,
 			       const void *pkt,
 			       pj_size_t pkt_size,
@@ -447,4 +451,6 @@
     pj_ssize_t pkt_len;
     pj_status_t status;
+
+    PJ_UNUSED_ARG(token);
 
     sess = (nat_detect_session*) pj_stun_session_get_user_data(stun_sess);
@@ -463,4 +469,5 @@
 static void on_request_complete(pj_stun_session *stun_sess,
 			        pj_status_t status,
+				void *token,
 			        pj_stun_tx_data *tdata,
 			        const pj_stun_msg *response,
@@ -475,4 +482,5 @@
     unsigned test_id;
 
+    PJ_UNUSED_ARG(token);
     PJ_UNUSED_ARG(tdata);
     PJ_UNUSED_ARG(src_addr);
@@ -813,6 +821,6 @@
 
     /* Send the request */
-    status = pj_stun_session_send_msg(sess->stun_sess, PJ_TRUE, 
-				      sess->cur_server, 
+    status = pj_stun_session_send_msg(sess->stun_sess, NULL, PJ_TRUE,
+				      PJ_TRUE, sess->cur_server, 
 				      sizeof(pj_sockaddr_in),
 				      sess->result[test_id].tdata);
Index: pjproject/trunk/pjnath/src/pjnath/stun_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/stun_session.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjnath/stun_session.c	(revision 1913)
@@ -350,5 +350,6 @@
 
 	/* Retry the request */
-	status = pj_stun_session_send_msg(sess, PJ_TRUE, src_addr, 
+	status = pj_stun_session_send_msg(sess, request->token, PJ_TRUE, 
+					  request->retransmit, src_addr, 
 					  src_addr_len, tdata);
 
@@ -378,7 +379,6 @@
 
     if (notify_user && sess->cb.on_request_complete) {
-	(*sess->cb.on_request_complete)(sess, status, tdata, 
-					response, 
-					src_addr, src_addr_len);
+	(*sess->cb.on_request_complete)(sess, status, tdata->token, tdata, 
+					response, src_addr, src_addr_len);
     }
 
@@ -398,6 +398,7 @@
     tdata = (pj_stun_tx_data*) pj_stun_client_tsx_get_data(tsx);
 
-    return tdata->sess->cb.on_send_msg(tdata->sess, stun_pkt, pkt_size,
-				       tdata->dst_addr, tdata->addr_len);
+    return tdata->sess->cb.on_send_msg(tdata->sess, tdata->token, stun_pkt, 
+				       pkt_size, tdata->dst_addr, 
+				       tdata->addr_len);
 }
 
@@ -731,5 +732,7 @@
 
 PJ_DEF(pj_status_t) pj_stun_session_send_msg( pj_stun_session *sess,
+					      void *token,
 					      pj_bool_t cache_res,
+					      pj_bool_t retransmit,
 					      const pj_sockaddr_t *server,
 					      unsigned addr_len,
@@ -743,4 +746,7 @@
     tdata->max_len = PJ_STUN_MAX_PKT_LEN;
     tdata->pkt = pj_pool_alloc(tdata->pool, tdata->max_len);
+
+    tdata->token = token;
+    tdata->retransmit = retransmit;
 
     /* Start locking the session now */
@@ -788,5 +794,5 @@
 
 	/* Send the request! */
-	status = pj_stun_client_tsx_send_msg(tdata->client_tsx, PJ_TRUE,
+	status = pj_stun_client_tsx_send_msg(tdata->client_tsx, retransmit,
 					     tdata->pkt, tdata->pkt_size);
 	if (status != PJ_SUCCESS && status != PJ_EPENDING) {
@@ -829,6 +835,6 @@
     
 	/* Otherwise for non-request message, send directly to transport. */
-	status = sess->cb.on_send_msg(sess, tdata->pkt, tdata->pkt_size,
-				      server, addr_len);
+	status = sess->cb.on_send_msg(sess, token, tdata->pkt, 
+				      tdata->pkt_size, server, addr_len);
 
 	if (status != PJ_SUCCESS && status != PJ_EPENDING) {
@@ -855,4 +861,5 @@
 					     unsigned code, 
 					     const char *errmsg,
+					     void *token,
 					     pj_bool_t cache, 
 					     const pj_sockaddr_t *dst_addr, 
@@ -869,5 +876,6 @@
 	return status;
 
-    return pj_stun_session_send_msg(sess, cache, dst_addr,  addr_len, tdata);
+    return pj_stun_session_send_msg(sess, token, cache, PJ_FALSE,
+				    dst_addr,  addr_len, tdata);
 }
 
@@ -888,6 +896,6 @@
 
     if (notify) {
-	(sess->cb.on_request_complete)(sess, notify_status, tdata, NULL,
-				       NULL, 0);
+	(sess->cb.on_request_complete)(sess, notify_status, tdata->token, 
+				       tdata, NULL, NULL, 0);
     }
 
@@ -921,5 +929,5 @@
 
 /* Send response */
-static pj_status_t send_response(pj_stun_session *sess, 
+static pj_status_t send_response(pj_stun_session *sess, void *token,
 				 pj_pool_t *pool, pj_stun_msg *response,
 				 const pj_stun_req_cred_info *auth_info,
@@ -954,5 +962,6 @@
 
     /* Send packet */
-    status = sess->cb.on_send_msg(sess, out_pkt, out_len, addr, addr_len);
+    status = sess->cb.on_send_msg(sess, token, out_pkt, out_len, 
+				  addr, addr_len);
 
     return status;
@@ -961,4 +970,5 @@
 /* Authenticate incoming message */
 static pj_status_t authenticate_req(pj_stun_session *sess,
+				    void *token,
 				    const pj_uint8_t *pkt,
 				    unsigned pkt_len,
@@ -982,6 +992,6 @@
     if (status != PJ_SUCCESS && response != NULL) {
 	PJ_LOG(5,(SNAME(sess), "Message authentication failed"));
-	send_response(sess, tmp_pool, response, &rdata->info, PJ_FALSE, 
-		      src_addr, src_addr_len);
+	send_response(sess, token, tmp_pool, response, &rdata->info, 
+		      PJ_FALSE, src_addr, src_addr_len);
     }
 
@@ -1071,6 +1081,6 @@
 		 "Request retransmission, sending cached response"));
 
-	send_response(sess, tmp_pool, t->msg, &t->auth_info, PJ_TRUE, 
-		      src_addr, src_addr_len);
+	send_response(sess, t->token, tmp_pool, t->msg, &t->auth_info, 
+		      PJ_TRUE, src_addr, src_addr_len);
 	return PJ_SUCCESS;
     }
@@ -1082,4 +1092,5 @@
 static pj_status_t on_incoming_request(pj_stun_session *sess,
 				       unsigned options,
+				       void *token,
 				       pj_pool_t *tmp_pool,
 				       const pj_uint8_t *in_pkt,
@@ -1103,6 +1114,7 @@
      */
     if ((options & PJ_STUN_NO_AUTHENTICATE) == 0) {
-	status = authenticate_req(sess, (const pj_uint8_t*) in_pkt, in_pkt_len,
-				  &rdata, tmp_pool, src_addr, src_addr_len);
+	status = authenticate_req(sess, token, (const pj_uint8_t*) in_pkt, 
+				  in_pkt_len,&rdata, tmp_pool, src_addr, 
+				  src_addr_len);
 	if (status != PJ_SUCCESS) {
 	    return status;
@@ -1113,5 +1125,5 @@
     if (sess->cb.on_rx_request) {
 	status = (*sess->cb.on_rx_request)(sess, in_pkt, in_pkt_len, &rdata,
-					   src_addr, src_addr_len);
+					   token, src_addr, src_addr_len);
     } else {
 	pj_str_t err_text;
@@ -1123,5 +1135,5 @@
 					     &err_text, &response);
 	if (status == PJ_SUCCESS && response) {
-	    status = send_response(sess, tmp_pool, response, 
+	    status = send_response(sess, token, tmp_pool, response, 
 				   NULL, PJ_FALSE, src_addr, src_addr_len);
 	}
@@ -1134,4 +1146,5 @@
 /* Handle incoming indication */
 static pj_status_t on_incoming_indication(pj_stun_session *sess,
+					  void *token,
 					  pj_pool_t *tmp_pool,
 					  const pj_uint8_t *in_pkt,
@@ -1146,5 +1159,5 @@
     if (sess->cb.on_rx_indication) {
 	return (*sess->cb.on_rx_indication)(sess, in_pkt, in_pkt_len, msg,
-					    src_addr, src_addr_len);
+					    token, src_addr, src_addr_len);
     } else {
 	return PJ_SUCCESS;
@@ -1157,4 +1170,5 @@
 					      pj_size_t pkt_size,
 					      unsigned options,
+					      void *token,
 					      unsigned *parsed_len,
 					      const pj_sockaddr_t *src_addr,
@@ -1181,5 +1195,5 @@
 	LOG_ERR_(sess, "STUN msg_decode() error", status);
 	if (response) {
-	    send_response(sess, tmp_pool, response, NULL,
+	    send_response(sess, token, tmp_pool, response, NULL,
 			  PJ_FALSE, src_addr, src_addr_len);
 	}
@@ -1218,5 +1232,5 @@
     } else if (PJ_STUN_IS_REQUEST(msg->hdr.type)) {
 
-	status = on_incoming_request(sess, options, tmp_pool, 
+	status = on_incoming_request(sess, options, token, tmp_pool, 
 				     (const pj_uint8_t*) packet, pkt_size, 
 				     msg, src_addr, src_addr_len);
@@ -1224,5 +1238,5 @@
     } else if (PJ_STUN_IS_INDICATION(msg->hdr.type)) {
 
-	status = on_incoming_indication(sess, tmp_pool, 
+	status = on_incoming_indication(sess, token, tmp_pool, 
 					(const pj_uint8_t*) packet, pkt_size,
 					msg, src_addr, src_addr_len);
Index: pjproject/trunk/pjnath/src/pjnath/turn_session.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/turn_session.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjnath/turn_session.c	(revision 1913)
@@ -111,9 +111,9 @@
  */
 static void sess_shutdown(pj_turn_session *sess,
-			  pj_bool_t notify,
 			  pj_status_t status);
 static void do_destroy(pj_turn_session *sess);
 static void send_refresh(pj_turn_session *sess, int lifetime);
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -122,4 +122,5 @@
 static void stun_on_request_complete(pj_stun_session *sess,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -130,4 +131,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len);
@@ -145,5 +147,24 @@
 
 
-/**
+/*
+ * Create default pj_turn_alloc_param.
+ */
+PJ_DEF(void) pj_turn_alloc_param_default(pj_turn_alloc_param *prm)
+{
+    pj_bzero(prm, sizeof(*prm));
+}
+
+/*
+ * Duplicate pj_turn_alloc_param.
+ */
+PJ_DEF(void) pj_turn_alloc_param_copy( pj_pool_t *pool, 
+				       pj_turn_alloc_param *dst,
+				       const pj_turn_alloc_param *src)
+{
+    PJ_UNUSED_ARG(pool);
+    pj_memcpy(dst, src, sizeof(*dst));
+}
+
+/*
  * Get TURN state name.
  */
@@ -286,4 +307,7 @@
     pj_turn_state_t old_state = sess->state;
 
+    if (state==sess->state)
+	return;
+
     PJ_LOG(4,(sess->obj_name, "State changed %s --> %s",
 	      state_names[old_state], state_names[state]));
@@ -299,10 +323,7 @@
  */
 static void sess_shutdown(pj_turn_session *sess,
-			  pj_bool_t notify,
 			  pj_status_t status)
 {
     pj_bool_t can_destroy = PJ_TRUE;
-
-    PJ_UNUSED_ARG(notify);
 
     PJ_LOG(4,(sess->obj_name, "Request to shutdown in state %s, cause:%d",
@@ -361,5 +382,5 @@
  * Public API to destroy TURN client session.
  */
-PJ_DEF(pj_status_t) pj_turn_session_destroy(pj_turn_session *sess)
+PJ_DEF(pj_status_t) pj_turn_session_shutdown(pj_turn_session *sess)
 {
     PJ_ASSERT_RETURN(sess, PJ_EINVAL);
@@ -367,8 +388,19 @@
     pj_lock_acquire(sess->lock);
 
-    sess_shutdown(sess, PJ_FALSE, PJ_SUCCESS);
+    sess_shutdown(sess, PJ_SUCCESS);
 
     pj_lock_release(sess->lock);
 
+    return PJ_SUCCESS;
+}
+
+
+/**
+ * Forcefully destroy the TURN session.
+ */
+PJ_DEF(pj_status_t) pj_turn_session_destroy( pj_turn_session *sess)
+{
+    set_state(sess, PJ_TURN_STATE_DEALLOCATED);
+    sess_shutdown(sess, PJ_SUCCESS);
     return PJ_SUCCESS;
 }
@@ -465,5 +497,9 @@
 	}
 
+	PJ_LOG(5,(sess->obj_name, "Resolving %.*s%.*s with DNS SRV",
+		  (int)res_name.slen, res_name.ptr,
+		  (int)domain->slen, domain->ptr));
 	set_state(sess, PJ_TURN_STATE_RESOLVING);
+
 	status = pj_dns_srv_resolve(domain, &res_name, default_port, 
 				    sess->pool, resolver, opt, sess, 
@@ -488,4 +524,7 @@
 	ai = (pj_addrinfo*)
 	     pj_pool_calloc(sess->pool, cnt, sizeof(pj_addrinfo));
+
+	PJ_LOG(5,(sess->obj_name, "Resolving %.*s with DNS A",
+		  (int)domain->slen, domain->ptr));
 
 	status = pj_getaddrinfo(sess->af, domain, &cnt, ai);
@@ -539,8 +578,10 @@
 {
     pj_stun_tx_data *tdata;
+    pj_bool_t retransmit;
     pj_status_t status;
 
     PJ_ASSERT_RETURN(sess, PJ_EINVAL);
-    PJ_ASSERT_RETURN(sess->state>PJ_TURN_STATE_NULL && sess->state<=PJ_TURN_STATE_RESOLVED, 
+    PJ_ASSERT_RETURN(sess->state>PJ_TURN_STATE_NULL && 
+		     sess->state<=PJ_TURN_STATE_RESOLVED, 
 		     PJ_EINVALIDOP);
 
@@ -548,6 +589,6 @@
 
     if (sess->state < PJ_TURN_STATE_RESOLVED) {
-	if (param && param != &sess->alloc_param)
-	    pj_memcpy(&sess->alloc_param, param, sizeof(*param));
+	if (param && param != &sess->alloc_param) 
+	    pj_turn_alloc_param_copy(sess->pool, &sess->alloc_param, param);
 	sess->pending_alloc = PJ_TRUE;
 
@@ -595,5 +636,7 @@
     /* Send request */
     set_state(sess, PJ_TURN_STATE_ALLOCATING);
-    status = pj_stun_session_send_msg(sess->stun, PJ_FALSE, sess->srv_addr,
+    retransmit = (sess->tp_type == PJ_TURN_TP_UDP);
+    status = pj_stun_session_send_msg(sess->stun, NULL, PJ_FALSE, 
+				      retransmit, sess->srv_addr,
 				      pj_sockaddr_get_len(sess->srv_addr), 
 				      tdata);
@@ -637,5 +680,7 @@
     }
 
-    status = pj_stun_session_send_msg(sess->stun, PJ_FALSE, sess->srv_addr,
+    status = pj_stun_session_send_msg(sess->stun, NULL, PJ_FALSE, 
+				      (sess->tp_type==PJ_TURN_TP_UDP),
+				      sess->srv_addr,
 				      pj_sockaddr_get_len(sess->srv_addr), 
 				      tdata);
@@ -648,5 +693,5 @@
     if (lifetime == 0) {
 	set_state(sess, PJ_TURN_STATE_DEALLOCATED);
-	sess_shutdown(sess, PJ_FALSE, status);
+	sess_shutdown(sess, status);
     }
 }
@@ -725,5 +770,6 @@
 
 	/* Send the indication */
-	status = pj_stun_session_send_msg(sess->stun, PJ_FALSE, sess->srv_addr,
+	status = pj_stun_session_send_msg(sess->stun, NULL, PJ_FALSE, 
+					  PJ_FALSE, sess->srv_addr,
 					  pj_sockaddr_get_len(sess->srv_addr),
 					  tdata);
@@ -763,9 +809,4 @@
     peer = lookup_peer_by_addr(sess, peer_adr, addr_len, PJ_TRUE, PJ_FALSE);
     pj_assert(peer);
-
-    /* Associate peer data structure with tdata for future reference
-     * when we receive the ChannelBind response.
-     */
-    tdata->user_data = peer;
 
     if (peer->ch_id != PJ_TURN_INVALID_CHANNEL) {
@@ -788,6 +829,10 @@
 				  peer_adr, addr_len);
 
-    /* Send the request */
-    status = pj_stun_session_send_msg(sess->stun, PJ_FALSE, sess->srv_addr,
+    /* Send the request, associate peer data structure with tdata 
+     * for future reference when we receive the ChannelBind response.
+     */
+    status = pj_stun_session_send_msg(sess->stun, peer, PJ_FALSE, 
+				      (sess->tp_type==PJ_TURN_TP_UDP),
+				      sess->srv_addr,
 				      pj_sockaddr_get_len(sess->srv_addr),
 				      tdata);
@@ -829,5 +874,5 @@
 	    options |= PJ_STUN_IS_DATAGRAM;
 	status=pj_stun_session_on_rx_pkt(sess->stun, pkt, pkt_len,
-					 options, NULL,
+					 options, NULL, NULL,
 					 sess->srv_addr,
 					 pj_sockaddr_get_len(sess->srv_addr));
@@ -883,4 +928,5 @@
  */
 static pj_status_t stun_on_send_msg(pj_stun_session *stun,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -889,4 +935,6 @@
 {
     pj_turn_session *sess;
+
+    PJ_UNUSED_ARG(token);
 
     sess = (pj_turn_session*) pj_stun_session_get_user_data(stun);
@@ -928,5 +976,5 @@
 
 	    set_state(sess, PJ_TURN_STATE_DEALLOCATED);
-	    sess_shutdown(sess, PJ_TRUE, status);
+	    sess_shutdown(sess, status);
 	    return;
 	}
@@ -937,5 +985,5 @@
 	if (method==PJ_STUN_REFRESH_METHOD) {
 	    set_state(sess, PJ_TURN_STATE_DEALLOCATED);
-	    sess_shutdown(sess, PJ_TRUE, status);
+	    sess_shutdown(sess, status);
 	    return;
 	}
@@ -976,7 +1024,6 @@
     /* If LIFETIME is zero, this is a deallocation */
     if (lf_attr->value == 0) {
-	pj_bool_t notify = sess->state < PJ_TURN_STATE_DEALLOCATING;
 	set_state(sess, PJ_TURN_STATE_DEALLOCATED);
-	sess_shutdown(sess, notify, PJ_SUCCESS);
+	sess_shutdown(sess, PJ_SUCCESS);
 	return;
     }
@@ -1069,4 +1116,5 @@
 static void stun_on_request_complete(pj_stun_session *stun,
 				     pj_status_t status,
+				     void *token,
 				     pj_stun_tx_data *tdata,
 				     const pj_stun_msg *response,
@@ -1146,5 +1194,5 @@
 	{
 	    /* Successful ChannelBind response */
-	    struct peer *peer = (struct peer*)tdata->user_data;
+	    struct peer *peer = (struct peer*)token;
 
 	    pj_assert(peer->ch_id != PJ_TURN_INVALID_CHANNEL);
@@ -1192,4 +1240,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len)
@@ -1199,4 +1248,5 @@
     pj_stun_data_attr *data_attr;
 
+    PJ_UNUSED_ARG(token);
     PJ_UNUSED_ARG(pkt);
     PJ_UNUSED_ARG(pkt_len);
@@ -1254,5 +1304,5 @@
     /* Check failure */
     if (status != PJ_SUCCESS) {
-	sess_shutdown(sess, PJ_TRUE, status);
+	sess_shutdown(sess, status);
 	return;
     }
@@ -1263,5 +1313,5 @@
 
 	for (j=0; j<rec->entry[i].server.addr_count && cnt<MAX_SRV_CNT; ++j) {
-	    pj_sockaddr_in *addr = &sess->srv_addr[cnt].ipv4;
+	    pj_sockaddr_in *addr = &sess->srv_addr_list[cnt].ipv4;
 
 	    addr->sin_family = sess->af;
@@ -1275,5 +1325,5 @@
 
     /* Set current server */
-    sess->srv_addr = &sess->srv_addr[0];
+    sess->srv_addr = &sess->srv_addr_list[0];
 
     /* Set state to PJ_TURN_STATE_RESOLVED */
@@ -1415,7 +1465,8 @@
 
 		/* Send the indication */
-		pj_stun_session_send_msg(sess->stun, PJ_FALSE, sess->srv_addr,
-					pj_sockaddr_get_len(sess->srv_addr),
-					tdata);
+		pj_stun_session_send_msg(sess->stun, NULL, PJ_FALSE, 
+					 PJ_FALSE, sess->srv_addr,
+					 pj_sockaddr_get_len(sess->srv_addr),
+					 tdata);
 	    }
 	}
Index: pjproject/trunk/pjnath/src/pjnath/turn_sock.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/turn_sock.c	(revision 1913)
+++ pjproject/trunk/pjnath/src/pjnath/turn_sock.c	(revision 1913)
@@ -0,0 +1,654 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include <pjnath/turn_sock.h>
+#include <pj/assert.h>
+#include <pj/errno.h>
+#include <pj/lock.h>
+#include <pj/log.h>
+#include <pj/pool.h>
+#include <pj/ioqueue.h>
+
+enum
+{
+    TIMER_NONE,
+    TIMER_DESTROY
+};
+
+#define INIT	0x1FFFFFFF
+
+struct pj_turn_sock
+{
+    pj_pool_t		*pool;
+    const char		*obj_name;
+    pj_turn_session	*sess;
+    pj_turn_sock_cb	 cb;
+    void		*user_data;
+
+    pj_lock_t		*lock;
+
+    pj_turn_alloc_param	 alloc_param;
+    pj_stun_config	 cfg;
+
+    pj_bool_t		 destroy_request;
+    pj_timer_entry	 timer;
+
+    int			 af;
+    pj_turn_tp_type	 conn_type;
+    pj_sock_t		 sock;
+    pj_ioqueue_key_t	*key;
+    pj_ioqueue_op_key_t	 read_key;
+    pj_ioqueue_op_key_t	 send_key;
+    pj_uint8_t		 pkt[PJ_TURN_MAX_PKT_LEN];
+};
+
+
+/*
+ * Callback prototypes.
+ */
+static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
+				    const pj_uint8_t *pkt,
+				    unsigned pkt_len,
+				    const pj_sockaddr_t *dst_addr,
+				    unsigned dst_addr_len);
+static void turn_on_channel_bound(pj_turn_session *sess,
+				  const pj_sockaddr_t *peer_addr,
+				  unsigned addr_len,
+				  unsigned ch_num);
+static void turn_on_rx_data(pj_turn_session *sess,
+			    const pj_uint8_t *pkt,
+			    unsigned pkt_len,
+			    const pj_sockaddr_t *peer_addr,
+			    unsigned addr_len);
+static void turn_on_state(pj_turn_session *sess, 
+			  pj_turn_state_t old_state,
+			  pj_turn_state_t new_state);
+static void on_read_complete(pj_ioqueue_key_t *key, 
+                             pj_ioqueue_op_key_t *op_key, 
+                             pj_ssize_t bytes_read);
+static void on_connect_complete(pj_ioqueue_key_t *key, 
+                                pj_status_t status);
+
+
+static void destroy(pj_turn_sock *turn_sock);
+static void timer_cb(pj_timer_heap_t *th, pj_timer_entry *e);
+
+
+/*
+ * Create.
+ */
+PJ_DEF(pj_status_t) pj_turn_sock_create(pj_stun_config *cfg,
+					int af,
+					pj_turn_tp_type conn_type,
+					const pj_turn_sock_cb *cb,
+					unsigned options,
+					void *user_data,
+					pj_turn_sock **p_turn_sock)
+{
+    pj_turn_sock *turn_sock;
+    pj_turn_session_cb sess_cb;
+    pj_pool_t *pool;
+    const char *name_tmpl;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(cfg && p_turn_sock, PJ_EINVAL);
+    PJ_ASSERT_RETURN(af==pj_AF_INET() || af==pj_AF_INET6(), PJ_EINVAL);
+    PJ_ASSERT_RETURN(options==0, PJ_EINVAL);
+
+    switch (conn_type) {
+    case PJ_TURN_TP_UDP:
+	name_tmpl = "udprel%p";
+	break;
+    case PJ_TURN_TP_TCP:
+	name_tmpl = "tcprel%p";
+	break;
+    default:
+	PJ_ASSERT_RETURN(!"Invalid TURN conn_type", PJ_EINVAL);
+	name_tmpl = "tcprel%p";
+	break;
+    }
+
+    /* Create and init basic data structure */
+    pool = pj_pool_create(cfg->pf, name_tmpl, 1000, 1000, NULL);
+    turn_sock = PJ_POOL_ZALLOC_T(pool, pj_turn_sock);
+    turn_sock->pool = pool;
+    turn_sock->obj_name = pool->obj_name;
+    turn_sock->user_data = user_data;
+    turn_sock->af = af;
+    turn_sock->conn_type = conn_type;
+
+    /* Copy STUN config (this contains ioqueue, timer heap, etc.) */
+    pj_memcpy(&turn_sock->cfg, cfg, sizeof(*cfg));
+
+    /* Set callback */
+    if (cb) {
+	pj_memcpy(&turn_sock->cb, cb, sizeof(*cb));
+    }
+
+    /* Create lock */
+    status = pj_lock_create_recursive_mutex(pool, turn_sock->obj_name, 
+					    &turn_sock->lock);
+    if (status != PJ_SUCCESS) {
+	destroy(turn_sock);
+	return status;
+    }
+
+    /* Init timer */
+    pj_timer_entry_init(&turn_sock->timer, TIMER_NONE, turn_sock, &timer_cb);
+
+    /* Init TURN session */
+    pj_bzero(&sess_cb, sizeof(sess_cb));
+    sess_cb.on_send_pkt = &turn_on_send_pkt;
+    sess_cb.on_channel_bound = &turn_on_channel_bound;
+    sess_cb.on_rx_data = &turn_on_rx_data;
+    sess_cb.on_state = &turn_on_state;
+    status = pj_turn_session_create(cfg, pool->obj_name, af, conn_type,
+				    &sess_cb, turn_sock, 0, &turn_sock->sess);
+    if (status != PJ_SUCCESS) {
+	destroy(turn_sock);
+	return status;
+    }
+
+    /* Note: socket and ioqueue will be created later once the TURN server
+     * has been resolved.
+     */
+
+    *p_turn_sock = turn_sock;
+    return PJ_SUCCESS;
+}
+
+/*
+ * Destroy.
+ */
+static void destroy(pj_turn_sock *turn_sock)
+{
+    if (turn_sock->lock) {
+	pj_lock_acquire(turn_sock->lock);
+    }
+
+    if (turn_sock->sess) {
+	pj_turn_session_set_user_data(turn_sock->sess, NULL);
+	pj_turn_session_shutdown(turn_sock->sess);
+	turn_sock->sess = NULL;
+    }
+
+    if (turn_sock->key) {
+	pj_ioqueue_unregister(turn_sock->key);
+	turn_sock->key = NULL;
+	turn_sock->sock = 0;
+    } else if (turn_sock->sock) {
+	pj_sock_close(turn_sock->sock);
+	turn_sock->sock = 0;
+    }
+
+    if (turn_sock->lock) {
+	pj_lock_release(turn_sock->lock);
+	pj_lock_destroy(turn_sock->lock);
+	turn_sock->lock = NULL;
+    }
+
+    if (turn_sock->pool) {
+	pj_pool_t *pool = turn_sock->pool;
+	turn_sock->pool = NULL;
+	pj_pool_release(pool);
+    }
+}
+
+
+PJ_DEF(void) pj_turn_sock_destroy(pj_turn_sock *turn_sock)
+{
+    pj_lock_acquire(turn_sock->lock);
+    turn_sock->destroy_request = PJ_TRUE;
+
+    if (turn_sock->sess) {
+	pj_turn_session_shutdown(turn_sock->sess);
+	/* This will ultimately call our state callback, and when
+	 * session state is DESTROYING we will schedule a timer to
+	 * destroy ourselves.
+	 */
+	pj_lock_release(turn_sock->lock);
+    } else {
+	pj_lock_release(turn_sock->lock);
+	destroy(turn_sock);
+    }
+
+}
+
+
+/* Timer callback */
+static void timer_cb(pj_timer_heap_t *th, pj_timer_entry *e)
+{
+    pj_turn_sock *turn_sock = (pj_turn_sock*)e->user_data;
+    int eid = e->id;
+
+    PJ_UNUSED_ARG(th);
+
+    e->id = TIMER_NONE;
+
+    switch (eid) {
+    case TIMER_DESTROY:
+	PJ_LOG(5,(turn_sock->obj_name, "Destroying TURN"));
+	destroy(turn_sock);
+	break;
+    default:
+	pj_assert(!"Invalid timer id");
+	break;
+    }
+}
+
+
+/* Display error */
+static void show_err(pj_turn_sock *turn_sock, const char *title,
+		     pj_status_t status)
+{
+    char errmsg[PJ_ERR_MSG_SIZE];
+
+    if (status != PJ_SUCCESS) {
+	pj_strerror(status, errmsg, sizeof(errmsg));
+	PJ_LOG(4,(turn_sock->obj_name, "%s: %s", title, errmsg));
+    } else {
+	PJ_LOG(4,(turn_sock->obj_name, "%s", title, errmsg));
+    }
+}
+
+/* On error, terminate session */
+static void sess_fail(pj_turn_sock *turn_sock, const char *title,
+		      pj_status_t status)
+{
+    show_err(turn_sock, title, status);
+    pj_turn_session_destroy(turn_sock->sess);
+}
+
+/*
+ * Set user data.
+ */
+PJ_DEF(pj_status_t) pj_turn_sock_set_user_data( pj_turn_sock *turn_sock,
+					       void *user_data)
+{
+    turn_sock->user_data = user_data;
+    return PJ_SUCCESS;
+}
+
+/*
+ * Get user data.
+ */
+PJ_DEF(void*) pj_turn_sock_get_user_data(pj_turn_sock *turn_sock)
+{
+    return turn_sock->user_data;
+}
+
+/**
+ * Get info.
+ */
+PJ_DEF(pj_status_t) pj_turn_sock_get_info(pj_turn_sock *turn_sock,
+					 pj_turn_session_info *info)
+{
+    PJ_ASSERT_RETURN(turn_sock && info, PJ_EINVAL);
+
+    if (turn_sock->sess) {
+	return pj_turn_session_get_info(turn_sock->sess, info);
+    } else {
+	pj_bzero(info, sizeof(*info));
+	info->state = PJ_TURN_STATE_NULL;
+	return PJ_SUCCESS;
+    }
+}
+
+/*
+ * Initialize.
+ */
+PJ_DEF(pj_status_t) pj_turn_sock_init(pj_turn_sock *turn_sock,
+				      const pj_str_t *domain,
+				      int default_port,
+				      pj_dns_resolver *resolver,
+				      const pj_stun_auth_cred *cred,
+				      const pj_turn_alloc_param *param)
+{
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(turn_sock && domain, PJ_EINVAL);
+    PJ_ASSERT_RETURN(turn_sock->sess, PJ_EINVALIDOP);
+
+    /* Copy alloc param. We will call session_alloc() only after the 
+     * server address has been resolved.
+     */
+    if (param) {
+	pj_turn_alloc_param_copy(turn_sock->pool, &turn_sock->alloc_param, param);
+    } else {
+	pj_turn_alloc_param_default(&turn_sock->alloc_param);
+    }
+
+    /* Set credental */
+    if (cred) {
+	status = pj_turn_session_set_cred(turn_sock->sess, cred);
+	if (status != PJ_SUCCESS) {
+	    sess_fail(turn_sock, "Error setting credential", status);
+	    return status;
+	}
+    }
+
+    /* Resolve server */
+    status = pj_turn_session_set_server(turn_sock->sess, domain, default_port,
+					resolver);
+    if (status != PJ_SUCCESS) {
+	sess_fail(turn_sock, "Error setting TURN server", status);
+	return status;
+    }
+
+    /* Done for now. The next work will be done when session state moved
+     * to RESOLVED state.
+     */
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * Send packet.
+ */ 
+PJ_DEF(pj_status_t) pj_turn_sock_sendto( pj_turn_sock *turn_sock,
+					const pj_uint8_t *pkt,
+					unsigned pkt_len,
+					const pj_sockaddr_t *addr,
+					unsigned addr_len)
+{
+    PJ_ASSERT_RETURN(turn_sock && addr && addr_len, PJ_EINVAL);
+
+    if (turn_sock->sess == NULL)
+	return PJ_EINVALIDOP;
+
+    return pj_turn_session_sendto(turn_sock->sess, pkt, pkt_len, 
+				  addr, addr_len);
+}
+
+/*
+ * Bind a peer address to a channel number.
+ */
+PJ_DEF(pj_status_t) pj_turn_sock_bind_channel( pj_turn_sock *turn_sock,
+					      const pj_sockaddr_t *peer,
+					      unsigned addr_len)
+{
+    PJ_ASSERT_RETURN(turn_sock && peer && addr_len, PJ_EINVAL);
+    PJ_ASSERT_RETURN(turn_sock->sess != NULL, PJ_EINVALIDOP);
+
+    return pj_turn_session_bind_channel(turn_sock->sess, peer, addr_len);
+}
+
+
+/*
+ * Notification when outgoing TCP socket has been connected.
+ */
+static void on_connect_complete(pj_ioqueue_key_t *key, 
+                                pj_status_t status)
+{
+    pj_turn_sock *turn_sock;
+
+    turn_sock = (pj_turn_sock*) pj_ioqueue_get_user_data(key);
+
+    if (status != PJ_SUCCESS) {
+	sess_fail(turn_sock, "TCP connect() error", status);
+	return;
+    }
+
+    if (turn_sock->conn_type != PJ_TURN_TP_UDP) {
+	PJ_LOG(5,(turn_sock->obj_name, "TCP connected"));
+    }
+
+    /* Kick start pending read operation */
+    pj_ioqueue_op_key_init(&turn_sock->read_key, sizeof(turn_sock->read_key));
+    on_read_complete(turn_sock->key, &turn_sock->read_key, INIT);
+
+    /* Init send_key */
+    pj_ioqueue_op_key_init(&turn_sock->send_key, sizeof(turn_sock->send_key));
+
+    /* Send Allocate request */
+    status = pj_turn_session_alloc(turn_sock->sess, &turn_sock->alloc_param);
+    if (status != PJ_SUCCESS) {
+	sess_fail(turn_sock, "Error sending ALLOCATE", status);
+	return;
+    }
+}
+
+/*
+ * Notification from ioqueue when incoming UDP packet is received.
+ */
+static void on_read_complete(pj_ioqueue_key_t *key, 
+                             pj_ioqueue_op_key_t *op_key, 
+                             pj_ssize_t bytes_read)
+{
+    enum { MAX_RETRY = 10 };
+    pj_turn_sock *turn_sock;
+    int retry = 0;
+    pj_status_t status;
+
+    turn_sock = (pj_turn_sock*) pj_ioqueue_get_user_data(key);
+    pj_lock_acquire(turn_sock->lock);
+
+    do {
+	if (bytes_read == INIT) {
+	    /* Special instruction to initialize pending read() */
+	} else if (bytes_read > 0 && turn_sock->sess) {
+	    /* Report incoming packet to TURN session */
+	    pj_turn_session_on_rx_pkt(turn_sock->sess, turn_sock->pkt, 
+				      bytes_read, 
+				      turn_sock->conn_type == PJ_TURN_TP_UDP);
+	} else if (bytes_read <= 0 && turn_sock->conn_type != PJ_TURN_TP_UDP) {
+	    sess_fail(turn_sock, "TCP connection closed", -bytes_read);
+	    goto on_return;
+	}
+
+	/* Read next packet */
+	bytes_read = sizeof(turn_sock->pkt);
+	status = pj_ioqueue_recv(turn_sock->key, op_key,
+				 turn_sock->pkt, &bytes_read, 0);
+
+	if (status != PJ_EPENDING && status != PJ_SUCCESS) {
+	    char errmsg[PJ_ERR_MSG_SIZE];
+
+	    pj_strerror(status, errmsg, sizeof(errmsg));
+	    sess_fail(turn_sock, "Socket recv() error", status);
+	    goto on_return;
+	}
+
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     ++retry < MAX_RETRY);
+
+on_return:
+    pj_lock_release(turn_sock->lock);
+}
+
+
+/*
+ * Callback from TURN session to send outgoing packet.
+ */
+static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
+				    const pj_uint8_t *pkt,
+				    unsigned pkt_len,
+				    const pj_sockaddr_t *dst_addr,
+				    unsigned dst_addr_len)
+{
+    pj_turn_sock *turn_sock = (pj_turn_sock*) 
+			   pj_turn_session_get_user_data(sess);
+    pj_ssize_t len = pkt_len;
+    pj_status_t status;
+
+    if (turn_sock == NULL) {
+	/* We've been destroyed */
+	pj_assert(!"We should shutdown gracefully");
+	return PJ_EINVALIDOP;
+    }
+
+    PJ_UNUSED_ARG(dst_addr);
+    PJ_UNUSED_ARG(dst_addr_len);
+
+    status = pj_ioqueue_send(turn_sock->key, &turn_sock->send_key, 
+			     pkt, &len, 0);
+    if (status != PJ_SUCCESS && status != PJ_EPENDING) {
+	show_err(turn_sock, "socket send()", status);
+    }
+
+    return status;
+}
+
+
+/*
+ * Callback from TURN session when a channel is successfully bound.
+ */
+static void turn_on_channel_bound(pj_turn_session *sess,
+				  const pj_sockaddr_t *peer_addr,
+				  unsigned addr_len,
+				  unsigned ch_num)
+{
+    PJ_UNUSED_ARG(sess);
+    PJ_UNUSED_ARG(peer_addr);
+    PJ_UNUSED_ARG(addr_len);
+    PJ_UNUSED_ARG(ch_num);
+}
+
+
+/*
+ * Callback from TURN session upon incoming data.
+ */
+static void turn_on_rx_data(pj_turn_session *sess,
+			    const pj_uint8_t *pkt,
+			    unsigned pkt_len,
+			    const pj_sockaddr_t *peer_addr,
+			    unsigned addr_len)
+{
+    pj_turn_sock *turn_sock = (pj_turn_sock*) 
+			   pj_turn_session_get_user_data(sess);
+    if (turn_sock == NULL) {
+	/* We've been destroyed */
+	return;
+    }
+
+    if (turn_sock->cb.on_rx_data) {
+	(*turn_sock->cb.on_rx_data)(turn_sock, pkt, pkt_len, 
+				  peer_addr, addr_len);
+    }
+}
+
+
+/*
+ * Callback from TURN session when state has changed
+ */
+static void turn_on_state(pj_turn_session *sess, 
+			  pj_turn_state_t old_state,
+			  pj_turn_state_t new_state)
+{
+    pj_turn_sock *turn_sock = (pj_turn_sock*) 
+			   pj_turn_session_get_user_data(sess);
+    pj_status_t status;
+
+    if (turn_sock == NULL) {
+	/* We've been destroyed */
+	return;
+    }
+
+    if (new_state == PJ_TURN_STATE_RESOLVED) {
+	/*
+	 * Once server has been resolved, initiate outgoing TCP
+	 * connection to the server.
+	 */
+	pj_turn_session_info info;
+	char addrtxt[PJ_INET6_ADDRSTRLEN+8];
+	int sock_type;
+	pj_ioqueue_callback ioq_cb;
+
+	/* Close existing connection, if any. This happens when
+	 * we're switching to alternate TURN server when either TCP
+	 * connection or ALLOCATE request failed.
+	 */
+	if (turn_sock->key) {
+	    pj_ioqueue_unregister(turn_sock->key);
+	    turn_sock->key = NULL;
+	    turn_sock->sock = 0;
+	} else if (turn_sock->sock) {
+	    pj_sock_close(turn_sock->sock);
+	    turn_sock->sock = 0;
+	}
+
+	/* Get server address from session info */
+	pj_turn_session_get_info(sess, &info);
+
+	if (turn_sock->conn_type == PJ_TURN_TP_UDP)
+	    sock_type = pj_SOCK_DGRAM();
+	else
+	    sock_type = pj_SOCK_STREAM();
+
+	/* Init socket */
+	status = pj_sock_socket(turn_sock->af, sock_type, 0, 
+				&turn_sock->sock);
+	if (status != PJ_SUCCESS) {
+	    pj_turn_sock_destroy(turn_sock);
+	    return;
+	}
+
+	/* Register to ioqeuue */
+	pj_bzero(&ioq_cb, sizeof(ioq_cb));
+	ioq_cb.on_read_complete = &on_read_complete;
+	ioq_cb.on_connect_complete = &on_connect_complete;
+	status = pj_ioqueue_register_sock(turn_sock->pool, turn_sock->cfg.ioqueue, 
+					  turn_sock->sock, turn_sock, 
+					  &ioq_cb, &turn_sock->key);
+	if (status != PJ_SUCCESS) {
+	    pj_turn_sock_destroy(turn_sock);
+	    return;
+	}
+
+	PJ_LOG(5,(turn_sock->pool->obj_name,
+		  "Connecting to %s", 
+		  pj_sockaddr_print(&info.server, addrtxt, 
+				    sizeof(addrtxt), 3)));
+
+	/* Initiate non-blocking connect */
+	status = pj_ioqueue_connect(turn_sock->key, &info.server,
+				    pj_sockaddr_get_len(&info.server));
+	if (status == PJ_SUCCESS) {
+	    on_connect_complete(turn_sock->key, PJ_SUCCESS);
+	} else if (status != PJ_EPENDING) {
+	    pj_turn_sock_destroy(turn_sock);
+	    return;
+	}
+
+	/* Done for now. Subsequent work will be done in 
+	 * on_connect_complete() callback.
+	 */
+    }
+
+    if (turn_sock->cb.on_state) {
+	(*turn_sock->cb.on_state)(turn_sock, old_state, new_state);
+    }
+
+    if (new_state >= PJ_TURN_STATE_DESTROYING && turn_sock->sess) {
+	pj_time_val delay = {0, 0};
+
+	turn_sock->sess = NULL;
+	pj_turn_session_set_user_data(sess, NULL);
+
+	if (turn_sock->timer.id) {
+	    pj_timer_heap_cancel(turn_sock->cfg.timer_heap, &turn_sock->timer);
+	    turn_sock->timer.id = 0;
+	}
+
+	turn_sock->timer.id = TIMER_DESTROY;
+	pj_timer_heap_schedule(turn_sock->cfg.timer_heap, &turn_sock->timer, 
+			       &delay);
+    }
+}
+
+
Index: pjproject/trunk/pjnath/src/pjnath/turn_udp.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath/turn_udp.c	(revision 1912)
+++ 	(revision )
@@ -1,500 +1,0 @@
-/* $Id$ */
-/* 
- * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-#include <pjnath/turn_udp.h>
-#include <pj/assert.h>
-#include <pj/errno.h>
-#include <pj/lock.h>
-#include <pj/log.h>
-#include <pj/pool.h>
-#include <pj/ioqueue.h>
-
-enum
-{
-    TIMER_NONE,
-    TIMER_DESTROY
-};
-
-struct pj_turn_udp
-{
-    pj_pool_t		*pool;
-    pj_turn_session	*sess;
-    pj_turn_udp_cb	 cb;
-    void		*user_data;
-
-    pj_lock_t		*lock;
-
-    pj_bool_t		 destroy_request;
-    pj_timer_heap_t	*timer_heap;
-    pj_timer_entry	 timer;
-
-    pj_sock_t		 sock;
-    pj_ioqueue_key_t	*key;
-    pj_ioqueue_op_key_t	 read_key;
-    pj_uint8_t		 pkt[PJ_TURN_MAX_PKT_LEN];
-    pj_sockaddr		 src_addr;
-    int			 src_addr_len;
-};
-
-
-/*
- * Callback prototypes.
- */
-static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
-				    const pj_uint8_t *pkt,
-				    unsigned pkt_len,
-				    const pj_sockaddr_t *dst_addr,
-				    unsigned dst_addr_len);
-static void turn_on_channel_bound(pj_turn_session *sess,
-				  const pj_sockaddr_t *peer_addr,
-				  unsigned addr_len,
-				  unsigned ch_num);
-static void turn_on_rx_data(pj_turn_session *sess,
-			    const pj_uint8_t *pkt,
-			    unsigned pkt_len,
-			    const pj_sockaddr_t *peer_addr,
-			    unsigned addr_len);
-static void turn_on_state(pj_turn_session *sess, 
-			  pj_turn_state_t old_state,
-			  pj_turn_state_t new_state);
-static void on_read_complete(pj_ioqueue_key_t *key, 
-                             pj_ioqueue_op_key_t *op_key, 
-                             pj_ssize_t bytes_read);
-
-
-static void destroy(pj_turn_udp *udp_rel);
-static void timer_cb(pj_timer_heap_t *th, pj_timer_entry *e);
-
-
-/*
- * Create.
- */
-PJ_DEF(pj_status_t) pj_turn_udp_create( pj_stun_config *cfg,
-					int af,
-					const pj_turn_udp_cb *cb,
-					unsigned options,
-					void *user_data,
-					pj_turn_udp **p_udp_rel)
-{
-    pj_turn_udp *udp_rel;
-    pj_turn_session_cb sess_cb;
-    pj_ioqueue_callback ioq_cb;
-    pj_pool_t *pool;
-    pj_status_t status;
-
-    PJ_ASSERT_RETURN(cfg && p_udp_rel, PJ_EINVAL);
-    PJ_ASSERT_RETURN(options==0, PJ_EINVAL);
-
-    /* Create and init basic data structure */
-    pool = pj_pool_create(cfg->pf, "udprel%p", 1000, 1000, NULL);
-    udp_rel = PJ_POOL_ZALLOC_T(pool, pj_turn_udp);
-    udp_rel->pool = pool;
-    udp_rel->user_data = user_data;
-
-    if (cb) {
-	pj_memcpy(&udp_rel->cb, cb, sizeof(*cb));
-    }
-
-    /* Create lock */
-    status = pj_lock_create_recursive_mutex(pool, pool->obj_name, 
-					    &udp_rel->lock);
-    if (status != PJ_SUCCESS) {
-	destroy(udp_rel);
-	return status;
-    }
-
-    /* Init timer */
-    udp_rel->timer_heap = cfg->timer_heap;
-    pj_timer_entry_init(&udp_rel->timer, TIMER_NONE, udp_rel, &timer_cb);
-
-    /* Init socket */
-    status = pj_sock_socket(af, pj_SOCK_DGRAM(), 0, &udp_rel->sock);
-    if (status != PJ_SUCCESS) {
-	destroy(udp_rel);
-	return status;
-    }
-
-    /* Bind to any */
-    pj_sockaddr_init(af, &udp_rel->src_addr, NULL, 0);
-    status = pj_sock_bind(udp_rel->sock, &udp_rel->src_addr, 
-			  pj_sockaddr_get_len(&udp_rel->src_addr));
-    if (status != PJ_SUCCESS) {
-	destroy(udp_rel);
-	return status;
-    }
-
-    /* Register to ioqeuue */
-    pj_bzero(&ioq_cb, sizeof(ioq_cb));
-    ioq_cb.on_read_complete = &on_read_complete;
-    status = pj_ioqueue_register_sock(udp_rel->pool, cfg->ioqueue, 
-				      udp_rel->sock, udp_rel, 
-				      &ioq_cb, &udp_rel->key);
-    if (status != PJ_SUCCESS) {
-	destroy(udp_rel);
-	return status;
-    }
-
-    /* Init TURN session */
-    pj_bzero(&sess_cb, sizeof(sess_cb));
-    sess_cb.on_send_pkt = &turn_on_send_pkt;
-    sess_cb.on_channel_bound = &turn_on_channel_bound;
-    sess_cb.on_rx_data = &turn_on_rx_data;
-    sess_cb.on_state = &turn_on_state;
-    status = pj_turn_session_create(cfg, "turn%p", af, PJ_TURN_TP_UDP,
-				    &sess_cb, udp_rel, 0, &udp_rel->sess);
-    if (status != PJ_SUCCESS) {
-	destroy(udp_rel);
-	return status;
-    }
-
-    /* Kick start pending read operation */
-    pj_ioqueue_op_key_init(&udp_rel->read_key, sizeof(udp_rel->read_key));
-    on_read_complete(udp_rel->key, &udp_rel->read_key, 0);
-
-    *p_udp_rel = udp_rel;
-    return PJ_SUCCESS;
-}
-
-/*
- * Destroy.
- */
-static void destroy(pj_turn_udp *udp_rel)
-{
-    if (udp_rel->lock) {
-	pj_lock_acquire(udp_rel->lock);
-    }
-
-    if (udp_rel->sess) {
-	pj_turn_session_set_user_data(udp_rel->sess, NULL);
-	pj_turn_session_destroy(udp_rel->sess);
-	udp_rel->sess = NULL;
-    }
-
-    if (udp_rel->key) {
-	pj_ioqueue_unregister(udp_rel->key);
-	udp_rel->key = NULL;
-	udp_rel->sock = 0;
-    } else if (udp_rel->sock) {
-	pj_sock_close(udp_rel->sock);
-	udp_rel->sock = 0;
-    }
-
-    if (udp_rel->lock) {
-	pj_lock_release(udp_rel->lock);
-	pj_lock_destroy(udp_rel->lock);
-	udp_rel->lock = NULL;
-    }
-
-    if (udp_rel->pool) {
-	pj_pool_t *pool = udp_rel->pool;
-	udp_rel->pool = NULL;
-	pj_pool_release(pool);
-    }
-}
-
-PJ_DEF(void) pj_turn_udp_destroy(pj_turn_udp *udp_rel)
-{
-    pj_lock_acquire(udp_rel->lock);
-    udp_rel->destroy_request = PJ_TRUE;
-
-    if (udp_rel->sess) {
-	pj_turn_session_destroy(udp_rel->sess);
-	/* This will ultimately call our state callback, and when
-	 * session state is DESTROYING we will schedule a timer to
-	 * destroy ourselves.
-	 */
-	pj_lock_release(udp_rel->lock);
-    } else {
-	pj_lock_release(udp_rel->lock);
-	destroy(udp_rel);
-    }
-
-}
-
-/* Timer callback */
-static void timer_cb(pj_timer_heap_t *th, pj_timer_entry *e)
-{
-    pj_turn_udp *udp_rel = (pj_turn_udp*)e->user_data;
-    int eid = e->id;
-
-    PJ_UNUSED_ARG(th);
-
-    e->id = TIMER_NONE;
-
-    switch (eid) {
-    case TIMER_DESTROY:
-	destroy(udp_rel);
-	break;
-    default:
-	pj_assert(!"Invalid timer id");
-	break;
-    }
-}
-
-
-/*
- * Set user data.
- */
-PJ_DEF(pj_status_t) pj_turn_udp_set_user_data( pj_turn_udp *udp_rel,
-					       void *user_data)
-{
-    udp_rel->user_data = user_data;
-    return PJ_SUCCESS;
-}
-
-/*
- * Get user data.
- */
-PJ_DEF(void*) pj_turn_udp_get_user_data(pj_turn_udp *udp_rel)
-{
-    return udp_rel->user_data;
-}
-
-/**
- * Get info.
- */
-PJ_DEF(pj_status_t) pj_turn_udp_get_info(pj_turn_udp *udp_rel,
-					 pj_turn_session_info *info)
-{
-    PJ_ASSERT_RETURN(udp_rel && info, PJ_EINVAL);
-
-    if (udp_rel->sess) {
-	return pj_turn_session_get_info(udp_rel->sess, info);
-    } else {
-	pj_bzero(info, sizeof(*info));
-	info->state = PJ_TURN_STATE_NULL;
-	return PJ_SUCCESS;
-    }
-}
-
-/*
- * Initialize.
- */
-PJ_DEF(pj_status_t) pj_turn_udp_init( pj_turn_udp *udp_rel,
-				      const pj_str_t *domain,
-				      int default_port,
-				      pj_dns_resolver *resolver,
-				      const pj_stun_auth_cred *cred,
-				      const pj_turn_alloc_param *param)
-{
-    pj_status_t status;
-
-    PJ_ASSERT_RETURN(udp_rel && domain, PJ_EINVAL);
-    PJ_ASSERT_RETURN(udp_rel->sess, PJ_EINVALIDOP);
-
-    status = pj_turn_session_set_server(udp_rel->sess, domain, default_port,
-					resolver);
-    if (status != PJ_SUCCESS)
-	return status;
-
-    if (cred) {
-	status = pj_turn_session_set_cred(udp_rel->sess, cred);
-	if (status != PJ_SUCCESS)
-	    return status;
-    }
-
-    status = pj_turn_session_alloc(udp_rel->sess, param);
-    if (status != PJ_SUCCESS)
-	return status;
-
-    return PJ_SUCCESS;
-}
-
-/*
- * Send packet.
- */ 
-PJ_DEF(pj_status_t) pj_turn_udp_sendto( pj_turn_udp *udp_rel,
-					const pj_uint8_t *pkt,
-					unsigned pkt_len,
-					const pj_sockaddr_t *addr,
-					unsigned addr_len)
-{
-    PJ_ASSERT_RETURN(udp_rel && addr && addr_len, PJ_EINVAL);
-
-    if (udp_rel->sess == NULL)
-	return PJ_EINVALIDOP;
-
-    return pj_turn_session_sendto(udp_rel->sess, pkt, pkt_len, 
-				  addr, addr_len);
-}
-
-/*
- * Bind a peer address to a channel number.
- */
-PJ_DEF(pj_status_t) pj_turn_udp_bind_channel( pj_turn_udp *udp_rel,
-					      const pj_sockaddr_t *peer,
-					      unsigned addr_len)
-{
-    PJ_ASSERT_RETURN(udp_rel && peer && addr_len, PJ_EINVAL);
-    PJ_ASSERT_RETURN(udp_rel->sess != NULL, PJ_EINVALIDOP);
-
-    return pj_turn_session_bind_channel(udp_rel->sess, peer, addr_len);
-}
-
-
-/*
- * Notification from ioqueue when incoming UDP packet is received.
- */
-static void on_read_complete(pj_ioqueue_key_t *key, 
-                             pj_ioqueue_op_key_t *op_key, 
-                             pj_ssize_t bytes_read)
-{
-    enum { MAX_RETRY = 10 };
-    pj_turn_udp *udp_rel;
-    int retry = 0;
-    pj_status_t status;
-
-    udp_rel = (pj_turn_udp*) pj_ioqueue_get_user_data(key);
-    pj_lock_acquire(udp_rel->lock);
-
-    do {
-	/* Report incoming packet to TURN session */
-	if (bytes_read > 0 && udp_rel->sess) {
-	    pj_turn_session_on_rx_pkt(udp_rel->sess, udp_rel->pkt, 
-				      bytes_read, PJ_TRUE);
-	}
-
-	/* Read next packet */
-	bytes_read = sizeof(udp_rel->pkt);
-	udp_rel->src_addr_len = sizeof(udp_rel->src_addr);
-	status = pj_ioqueue_recvfrom(udp_rel->key, op_key,
-				     udp_rel->pkt, &bytes_read, 0,
-				     &udp_rel->src_addr, 
-				     &udp_rel->src_addr_len);
-
-	if (status != PJ_EPENDING && status != PJ_SUCCESS) {
-	    char errmsg[PJ_ERR_MSG_SIZE];
-
-	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(4,(udp_rel->pool->obj_name,
-		      "ioqueue recvfrom error: %s", errmsg));
-
-	    bytes_read = -status;
-	}
-
-    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
-	     ++retry < MAX_RETRY);
-
-    pj_lock_release(udp_rel->lock);
-}
-
-
-/*
- * Callback from TURN session to send outgoing packet.
- */
-static pj_status_t turn_on_send_pkt(pj_turn_session *sess,
-				    const pj_uint8_t *pkt,
-				    unsigned pkt_len,
-				    const pj_sockaddr_t *dst_addr,
-				    unsigned dst_addr_len)
-{
-    pj_turn_udp *udp_rel = (pj_turn_udp*) 
-			   pj_turn_session_get_user_data(sess);
-    pj_ssize_t len = pkt_len;
-
-    if (udp_rel == NULL) {
-	/* We've been destroyed */
-	pj_assert(!"We should shutdown gracefully");
-	return PJ_EINVALIDOP;
-    }
-
-    return pj_sock_sendto(udp_rel->sock, pkt, &len, 0,
-			  dst_addr, dst_addr_len);
-}
-
-
-/*
- * Callback from TURN session when a channel is successfully bound.
- */
-static void turn_on_channel_bound(pj_turn_session *sess,
-				  const pj_sockaddr_t *peer_addr,
-				  unsigned addr_len,
-				  unsigned ch_num)
-{
-    PJ_UNUSED_ARG(sess);
-    PJ_UNUSED_ARG(peer_addr);
-    PJ_UNUSED_ARG(addr_len);
-    PJ_UNUSED_ARG(ch_num);
-}
-
-
-/*
- * Callback from TURN session upon incoming data.
- */
-static void turn_on_rx_data(pj_turn_session *sess,
-			    const pj_uint8_t *pkt,
-			    unsigned pkt_len,
-			    const pj_sockaddr_t *peer_addr,
-			    unsigned addr_len)
-{
-    pj_turn_udp *udp_rel = (pj_turn_udp*) 
-			   pj_turn_session_get_user_data(sess);
-    if (udp_rel == NULL) {
-	/* We've been destroyed */
-	return;
-    }
-
-    if (udp_rel->cb.on_rx_data) {
-	(*udp_rel->cb.on_rx_data)(udp_rel, pkt, pkt_len, 
-				  peer_addr, addr_len);
-    }
-}
-
-
-/*
- * Callback from TURN session when state has changed
- */
-static void turn_on_state(pj_turn_session *sess, 
-			  pj_turn_state_t old_state,
-			  pj_turn_state_t new_state)
-{
-    pj_turn_udp *udp_rel = (pj_turn_udp*) 
-			   pj_turn_session_get_user_data(sess);
-    if (udp_rel == NULL) {
-	/* We've been destroyed */
-	return;
-    }
-
-    if (udp_rel->cb.on_state) {
-	(*udp_rel->cb.on_state)(udp_rel, old_state, new_state);
-    }
-
-    if (new_state >= PJ_TURN_STATE_DESTROYING && udp_rel->sess) {
-
-	udp_rel->sess = NULL;
-	// Always destroy the session regardless whether application
-	// has called pj_turn_udp_destroy() or not. This is to handle
-	// the case when Allocate request fails.
-	//if (udp_rel->destroy_request) {
-	if (1) {
-	    pj_time_val delay = {0, 0};
-
-	    pj_turn_session_set_user_data(sess, NULL);
-
-	    if (udp_rel->timer.id != TIMER_NONE) {
-		pj_timer_heap_cancel(udp_rel->timer_heap, &udp_rel->timer);
-	    }
-
-	    udp_rel->timer.id = TIMER_DESTROY;
-	    pj_timer_heap_schedule(udp_rel->timer_heap, &udp_rel->timer, 
-				   &delay);
-	}
-    }
-}
-
-
Index: pjproject/trunk/pjnath/src/pjturn-client/client_main.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-client/client_main.c	(revision 1913)
@@ -49,5 +49,5 @@
     pj_bool_t		 quit;
 
-    pj_turn_udp		*udp_rel;
+    pj_turn_sock	*relay;
     pj_sockaddr		 relay_addr;
 
@@ -57,20 +57,21 @@
 static struct options
 {
-    char    *srv_addr;
-    char    *srv_port;
-    char    *realm;
-    char    *user_name;
-    char    *password;
-    pj_bool_t use_fingerprint;
+    pj_bool_t	 use_tcp;
+    char	*srv_addr;
+    char	*srv_port;
+    char	*realm;
+    char	*user_name;
+    char	*password;
+    pj_bool_t	 use_fingerprint;
 } o;
 
 
 static int worker_thread(void *unused);
-static void turn_on_rx_data(pj_turn_udp *udp_rel,
+static void turn_on_rx_data(pj_turn_sock *relay,
 			    const pj_uint8_t *pkt,
 			    unsigned pkt_len,
 			    const pj_sockaddr_t *peer_addr,
 			    unsigned addr_len);
-static void turn_on_state(pj_turn_udp *udp_rel, pj_turn_state_t old_state,
+static void turn_on_state(pj_turn_sock *relay, pj_turn_state_t old_state,
 			  pj_turn_state_t new_state);
 
@@ -156,7 +157,7 @@
 	g.thread = NULL;
     }
-    if (g.udp_rel) {
-	pj_turn_udp_destroy(g.udp_rel);
-	g.udp_rel = NULL;
+    if (g.relay) {
+	pj_turn_sock_destroy(g.relay);
+	g.relay = NULL;
     }
     for (i=0; i<PJ_ARRAY_SIZE(g.peer); ++i) {
@@ -243,10 +244,10 @@
 static pj_status_t create_relay(void)
 {
-    pj_turn_udp_cb rel_cb;
+    pj_turn_sock_cb rel_cb;
     pj_stun_auth_cred cred;
     pj_str_t srv;
     pj_status_t status;
 
-    if (g.udp_rel) {
+    if (g.relay) {
 	PJ_LOG(1,(THIS_FILE, "Relay already created"));
 	return -1;
@@ -256,6 +257,8 @@
     rel_cb.on_rx_data = &turn_on_rx_data;
     rel_cb.on_state = &turn_on_state;
-    CHECK( pj_turn_udp_create(&g.stun_config, pj_AF_INET(), &rel_cb, 0,
-			      NULL, &g.udp_rel) );
+    CHECK( pj_turn_sock_create(&g.stun_config, pj_AF_INET(), 
+			       (o.use_tcp? PJ_TURN_TP_TCP : PJ_TURN_TP_UDP),
+			       &rel_cb, 0,
+			       NULL, &g.relay) );
 
     if (o.user_name) {
@@ -272,5 +275,5 @@
 
     srv = pj_str(o.srv_addr);
-    CHECK( pj_turn_udp_init(g.udp_rel,				 /* the relay */
+    CHECK( pj_turn_sock_init(g.relay,				 /* the relay */
 			    &srv,				 /* srv addr */
 			    (o.srv_port?atoi(o.srv_port):PJ_STUN_PORT),/* def port */
@@ -285,11 +288,11 @@
 static void destroy_relay(void)
 {
-    if (g.udp_rel) {
-	pj_turn_udp_destroy(g.udp_rel);
-    }
-}
-
-
-static void turn_on_rx_data(pj_turn_udp *udp_rel,
+    if (g.relay) {
+	pj_turn_sock_destroy(g.relay);
+    }
+}
+
+
+static void turn_on_rx_data(pj_turn_sock *relay,
 			    const pj_uint8_t *pkt,
 			    unsigned pkt_len,
@@ -306,5 +309,5 @@
 
 
-static void turn_on_state(pj_turn_udp *udp_rel, pj_turn_state_t old_state,
+static void turn_on_state(pj_turn_sock *relay, pj_turn_state_t old_state,
 			  pj_turn_state_t new_state)
 {
@@ -314,9 +317,9 @@
     if (new_state == PJ_TURN_STATE_READY) {
 	pj_turn_session_info info;
-	pj_turn_udp_get_info(udp_rel, &info);
+	pj_turn_sock_get_info(relay, &info);
 	pj_memcpy(&g.relay_addr, &info.relay_addr, sizeof(pj_sockaddr));
-    } else if (new_state > PJ_TURN_STATE_READY && g.udp_rel) {
+    } else if (new_state > PJ_TURN_STATE_READY && g.relay) {
 	PJ_LOG(3,(THIS_FILE, "Relay shutting down.."));
-	g.udp_rel = NULL;
+	g.relay = NULL;
     }
 }
@@ -327,6 +330,6 @@
     char client_state[20], relay_addr[80], peer0_addr[80], peer1_addr[80];
 
-    if (g.udp_rel) {
-	pj_turn_udp_get_info(g.udp_rel, &info);
+    if (g.relay) {
+	pj_turn_sock_get_info(g.relay, &info);
 	strcpy(client_state, pj_turn_state_name(info.state));
 	if (info.state >= PJ_TURN_STATE_READY)
@@ -358,5 +361,5 @@
 	  peer1_addr);
     puts("+-----------------------------------+                                |");
-    puts("| q  Quit        d  Dump            | 1  Send data to relay adderss  |");
+    puts("| q  Quit                  d  Dump  | 1  Send data to relay adderss  |");
     puts("+-----------------------------------+--------------------------------+");
     printf(">>> ");
@@ -385,5 +388,5 @@
 	    break;
 	case 's':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -395,5 +398,5 @@
 
 	    strcpy(input, "Hello from client");
-	    status = pj_turn_udp_sendto(g.udp_rel, (const pj_uint8_t*)input, 
+	    status = pj_turn_sock_sendto(g.relay, (const pj_uint8_t*)input, 
 					strlen(input)+1, 
 					&peer->addr, 
@@ -403,5 +406,5 @@
 	    break;
 	case 'b':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -412,11 +415,14 @@
 		peer = &g.peer[1];
 
-	    status = pj_turn_udp_bind_channel(g.udp_rel, &peer->addr,
+	    status = pj_turn_sock_bind_channel(g.relay, &peer->addr,
 					      pj_sockaddr_get_len(&peer->addr));
 	    if (status != PJ_SUCCESS)
 		my_perror("turn_udp_bind_channel() failed", status);
 	    break;
+	case 'd':
+	    pj_pool_factory_dump(&g.cp.factory, PJ_TRUE);
+	    break;
 	case 'x':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("Error: no relay");
 		continue;
@@ -426,5 +432,5 @@
 	case '0':
 	case '1':
-	    if (g.udp_rel == NULL) {
+	    if (g.relay == NULL) {
 		puts("No relay");
 		break;
@@ -451,8 +457,9 @@
     puts("");
     puts("and OPTIONS:");
-    puts(" --realm, -r       Set realm of the credential");
-    puts(" --username, -u    Set username of the credential");
-    puts(" --password, -p    Set password of the credential");
-    puts(" --fingerprint, -F Use fingerprint for outgoing requests");
+    puts(" --tcp, -T             Use TCP to connect to TURN server");
+    puts(" --realm, -r REALM     Set realm of the credential to REALM");
+    puts(" --username, -u UID    Set username of the credential to UID");
+    puts(" --password, -p PASSWD Set password of the credential to PASSWD");
+    puts(" --fingerprint, -F     Use fingerprint for outgoing requests");
     puts(" --help, -h");
 }
@@ -465,5 +472,5 @@
 	{ "password",	1, 0, 'p'},
 	{ "fingerprint",0, 0, 'F'},
-	{ "data",	1, 0, 'D'},
+	{ "tcp",        0, 0, 'T'},
 	{ "help",	0, 0, 'h'}
     };
@@ -472,5 +479,5 @@
     pj_status_t status;
 
-    while((c=pj_getopt_long(argc,argv, "r:u:p:N:hF", long_options, &opt_id))!=-1) {
+    while((c=pj_getopt_long(argc,argv, "r:u:p:N:hFT", long_options, &opt_id))!=-1) {
 	switch (c) {
 	case 'r':
@@ -488,4 +495,7 @@
 	case 'F':
 	    o.use_fingerprint = PJ_TRUE;
+	    break;
+	case 'T':
+	    o.use_tcp = PJ_TRUE;
 	    break;
 
Index: pjproject/trunk/pjnath/src/pjturn-srv/allocation.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/allocation.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-srv/allocation.c	(revision 1913)
@@ -66,4 +66,5 @@
                             pj_ssize_t bytes_read);
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -74,4 +75,5 @@
 				      unsigned pkt_len,
 				      const pj_stun_rx_data *rdata,
+				      void *token,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len);
@@ -80,4 +82,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len);
@@ -124,5 +127,5 @@
 	pj_stun_session_respond(sess, rdata, 
 				PJ_STUN_SC_ALLOCATION_QUOTA_REACHED,
-			        "Invalid bandwidth", PJ_TRUE,
+			        "Invalid bandwidth", NULL, PJ_TRUE,
 				src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_ALLOCATION_QUOTA_REACHED);
@@ -135,5 +138,5 @@
 	pj_stun_session_respond(sess, rdata, PJ_STUN_SC_BAD_REQUEST,
 			        "Missing REQUESTED-TRANSPORT attribute", 
-				PJ_TRUE, src_addr, src_addr_len);
+				NULL, PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
     }
@@ -144,5 +147,5 @@
     if (cfg->tp_type != PJ_TURN_TP_UDP) {
 	pj_stun_session_respond(sess, rdata, PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO,
-				NULL, PJ_TRUE, src_addr, src_addr_len);
+				NULL, NULL, PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO);
     }
@@ -156,6 +159,6 @@
 	pj_stun_session_respond(sess, rdata, 
 				PJ_STUN_SC_BAD_REQUEST,
-				"RESERVATION-TOKEN is not supported", PJ_TRUE, 
-				src_addr, src_addr_len);
+				"RESERVATION-TOKEN is not supported", NULL, 
+				PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
     }
@@ -168,6 +171,6 @@
 	pj_stun_session_respond(sess, rdata, 
 				PJ_STUN_SC_BAD_REQUEST,
-				"REQUESTED-PROPS is not supported", PJ_TRUE, 
-				src_addr, src_addr_len);
+				"REQUESTED-PROPS is not supported", 
+				NULL, PJ_TRUE, src_addr, src_addr_len);
 	return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
     }
@@ -180,6 +183,6 @@
 	if (cfg->lifetime < MIN_LIFETIME) {
 	    pj_stun_session_respond(sess, rdata, PJ_STUN_SC_BAD_REQUEST,
-				    "LIFETIME too short", PJ_TRUE, 
-				    src_addr, src_addr_len);
+				    "LIFETIME too short", NULL, 
+				    PJ_TRUE, src_addr, src_addr_len);
 	    return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_BAD_REQUEST);
 	}
@@ -197,4 +200,5 @@
 static pj_status_t send_allocate_response(pj_turn_allocation *alloc,
 					  pj_stun_session *srv_sess,
+					  pj_turn_transport *transport,
 					  const pj_stun_rx_data *rdata)
 {
@@ -233,6 +237,6 @@
     
     /* Send the response */
-    return pj_stun_session_send_msg(srv_sess, PJ_TRUE,
-				    &alloc->hkey.clt_addr, 
+    return pj_stun_session_send_msg(srv_sess, transport, PJ_TRUE,
+				    PJ_FALSE, &alloc->hkey.clt_addr, 
 				    pj_sockaddr_get_len(&alloc->hkey.clt_addr),
 				    tdata);
@@ -284,5 +288,5 @@
  * Create new allocation.
  */
-PJ_DEF(pj_status_t) pj_turn_allocation_create(pj_turn_listener *listener,
+PJ_DEF(pj_status_t) pj_turn_allocation_create(pj_turn_transport *transport,
 					      const pj_sockaddr_t *src_addr,
 					      unsigned src_addr_len,
@@ -291,5 +295,5 @@
 					      pj_turn_allocation **p_alloc)
 {
-    pj_turn_srv *srv = listener->server;
+    pj_turn_srv *srv = transport->listener->server;
     const pj_stun_msg *msg = rdata->msg;
     pj_pool_t *pool;
@@ -311,11 +315,14 @@
     alloc->pool = pool;
     alloc->obj_name = pool->obj_name;
-    alloc->listener = listener;
-    alloc->clt_sock = PJ_INVALID_SOCKET;
     alloc->relay.tp.sock = PJ_INVALID_SOCKET;
+    alloc->server = transport->listener->server;
 
     alloc->bandwidth = req.bandwidth;
 
-    alloc->hkey.tp_type = listener->tp_type;
+    /* Set transport */
+    alloc->transport = transport;
+    pj_turn_transport_add_ref(transport, alloc);
+
+    alloc->hkey.tp_type = transport->listener->tp_type;
     pj_memcpy(&alloc->hkey.clt_addr, src_addr, src_addr_len);
 
@@ -333,5 +340,6 @@
 
     /* Print info */
-    pj_ansi_strcpy(alloc->info, pj_turn_tp_type_name(listener->tp_type));
+    pj_ansi_strcpy(alloc->info, 
+		   pj_turn_tp_type_name(transport->listener->tp_type));
     alloc->info[3] = ':';
     pj_sockaddr_print(src_addr, alloc->info+4, sizeof(alloc->info)-4, 3);
@@ -371,5 +379,5 @@
 
     /* Respond to ALLOCATE request */
-    status = send_allocate_response(alloc, srv_sess, rdata);
+    status = send_allocate_response(alloc, srv_sess, transport, rdata);
     if (status != PJ_SUCCESS)
 	goto on_error;
@@ -389,5 +397,5 @@
     pj_strerror(status, str_tmp, sizeof(str_tmp));
     pj_stun_session_respond(srv_sess, rdata, PJ_STUN_SC_BAD_REQUEST, str_tmp, 
-			    PJ_TRUE, src_addr, src_addr_len);
+			    transport, PJ_TRUE, src_addr, src_addr_len);
 
     /* Cleanup */
@@ -401,5 +409,5 @@
 {
     if (relay->timer.id) {
-	pj_timer_heap_cancel(relay->allocation->listener->server->core.timer_heap, 
+	pj_timer_heap_cancel(relay->allocation->server->core.timer_heap, 
 			     &relay->timer);
 	relay->timer.id = PJ_FALSE;
@@ -428,5 +436,5 @@
 
     /* Unregister this allocation */
-    pj_turn_srv_unregister_allocation(alloc->listener->server, alloc);
+    pj_turn_srv_unregister_allocation(alloc->server, alloc);
 
     /* Destroy relay */
@@ -436,4 +444,10 @@
     if (alloc->lock) {
 	pj_lock_acquire(alloc->lock);
+    }
+
+    /* Unreference transport */
+    if (alloc->transport) {
+	pj_turn_transport_dec_ref(alloc->transport, alloc);
+	alloc->transport = NULL;
     }
 
@@ -466,4 +480,18 @@
 
 
+/*
+ * Handle transport closure.
+ */
+PJ_DEF(void) pj_turn_allocation_on_transport_closed( pj_turn_allocation *alloc,
+						     pj_turn_transport *tp)
+{
+    PJ_LOG(5,(alloc->obj_name, "Transport %s unexpectedly closed, destroying "
+	      "allocation %s", tp->info, alloc->info));
+    pj_turn_transport_dec_ref(tp, alloc);
+    alloc->transport = NULL;
+    destroy_allocation(alloc);
+}
+
+
 /* Initiate shutdown sequence for this allocation and start destroy timer.
  * Once allocation is marked as shutting down, any packets will be 
@@ -477,5 +505,5 @@
     if (alloc->relay.timer.id == TIMER_ID_TIMEOUT) {
 	/* Cancel existing shutdown timer */
-	pj_timer_heap_cancel(alloc->listener->server->core.timer_heap,
+	pj_timer_heap_cancel(alloc->server->core.timer_heap,
 			     &alloc->relay.timer);
 	alloc->relay.timer.id = TIMER_ID_NONE;
@@ -499,5 +527,5 @@
     /* Schedule destroy timer */
     alloc->relay.timer.id = TIMER_ID_DESTROY;
-    pj_timer_heap_schedule(alloc->listener->server->core.timer_heap,
+    pj_timer_heap_schedule(alloc->server->core.timer_heap,
 			   &alloc->relay.timer, &destroy_delay);
 }
@@ -515,5 +543,5 @@
     pj_assert(alloc->relay.timer.id != TIMER_ID_DESTROY);
     if (alloc->relay.timer.id != 0) {
-	pj_timer_heap_cancel(alloc->listener->server->core.timer_heap,
+	pj_timer_heap_cancel(alloc->server->core.timer_heap, 
 			     &alloc->relay.timer);
 	alloc->relay.timer.id = TIMER_ID_NONE;
@@ -524,5 +552,5 @@
 
     alloc->relay.timer.id = TIMER_ID_TIMEOUT;
-    status = pj_timer_heap_schedule(alloc->listener->server->core.timer_heap,
+    status = pj_timer_heap_schedule(alloc->server->core.timer_heap, 
 				    &alloc->relay.timer, &delay);
     if (status != PJ_SUCCESS) {
@@ -590,5 +618,5 @@
     
     /* TODO: get the requested address family from somewhere */
-    af = alloc->listener->addr.addr.sa_family;
+    af = alloc->transport->listener->addr.addr.sa_family;
 
     /* Save realm */
@@ -687,5 +715,6 @@
     }
     if (!pj_sockaddr_has_addr(&relay->hkey.addr)) {
-	pj_sockaddr_copy_addr(&relay->hkey.addr, &alloc->listener->addr);
+	pj_sockaddr_copy_addr(&relay->hkey.addr, 
+			      &alloc->transport->listener->addr);
     }
     if (!pj_sockaddr_has_addr(&relay->hkey.addr)) {
@@ -725,6 +754,6 @@
     pj_status_t status;
 
-    status = pj_stun_session_respond(alloc->sess, rdata, code, errmsg, cache,
-				     &alloc->hkey.clt_addr,
+    status = pj_stun_session_respond(alloc->sess, rdata, code, errmsg, NULL, 
+				     cache, &alloc->hkey.clt_addr,
 				     pj_sockaddr_get_len(&alloc->hkey.clt_addr.addr));
     if (status != PJ_SUCCESS) {
@@ -770,6 +799,6 @@
     }
 
-    status = pj_stun_session_send_msg(alloc->sess, PJ_TRUE, 
-				      &alloc->hkey.clt_addr,  
+    status = pj_stun_session_send_msg(alloc->sess, NULL, PJ_TRUE, 
+				      PJ_FALSE, &alloc->hkey.clt_addr,  
 				      pj_sockaddr_get_len(&alloc->hkey.clt_addr), 
 				      tdata);
@@ -791,11 +820,4 @@
     pj_memcpy(&perm->hkey.peer_addr, peer_addr, addr_len);
     
-    if (alloc->listener->tp_type == PJ_TURN_TP_UDP) {
-	perm->sock = alloc->listener->sock;
-    } else {
-	pj_assert(!"TCP is not supported yet");
-	return NULL;
-    }
-
     perm->allocation = alloc;
     perm->channel = PJ_TURN_INVALID_CHANNEL;
@@ -901,11 +923,26 @@
 	 */
 	unsigned options = PJ_STUN_CHECK_PACKET;
-	if (pkt->listener->tp_type == PJ_TURN_TP_UDP)
+	unsigned parsed_len = 0;
+
+	if (pkt->transport->listener->tp_type == PJ_TURN_TP_UDP)
 	    options |= PJ_STUN_IS_DATAGRAM;
 
 	status = pj_stun_session_on_rx_pkt(alloc->sess, pkt->pkt, pkt->len,
-					   options, NULL,
+					   options, NULL, &parsed_len,
 					   &pkt->src.clt_addr, 
 					   pkt->src_addr_len);
+
+	if (pkt->transport->listener->tp_type == PJ_TURN_TP_UDP) {
+	    pkt->len = 0;
+	} else if (parsed_len > 0) {
+	    if (parsed_len == pkt->len) {
+		pkt->len = 0;
+	    } else {
+		pj_memmove(pkt->pkt, pkt->pkt+parsed_len,
+			   pkt->len - parsed_len);
+		pkt->len -= parsed_len;
+	    }
+	}
+
 	if (status != PJ_SUCCESS) {
 	    alloc_err(alloc, "Error handling STUN packet", status);
@@ -924,5 +961,5 @@
 
 	/* For UDP check the packet length */
-	if (alloc->listener->tp_type == PJ_TURN_TP_UDP) {
+	if (alloc->transport->listener->tp_type == PJ_TURN_TP_UDP) {
 	    if (pkt->len < pj_ntohs(cd->length)+sizeof(*cd)) {
 		PJ_LOG(4,(alloc->obj_name, 
@@ -1004,8 +1041,8 @@
 
 	/* Send to client */
-	pj_turn_listener_sendto(alloc->listener, rel->tp.tx_pkt,
-			       len+sizeof(pj_turn_channel_data), 0,
-			       &alloc->hkey.clt_addr,
-			       pj_sockaddr_get_len(&alloc->hkey.clt_addr));
+	alloc->transport->sendto(alloc->transport, rel->tp.tx_pkt,
+			         len+sizeof(pj_turn_channel_data), 0,
+			         &alloc->hkey.clt_addr,
+			         pj_sockaddr_get_len(&alloc->hkey.clt_addr));
     } else {
 	/* Send Data Indication */
@@ -1027,6 +1064,6 @@
 				    (const pj_uint8_t*)pkt, len);
 
-	pj_stun_session_send_msg(alloc->sess, PJ_FALSE, 
-				 &alloc->hkey.clt_addr, 
+	pj_stun_session_send_msg(alloc->sess, NULL, PJ_FALSE, 
+				 PJ_FALSE, &alloc->hkey.clt_addr, 
 				 pj_sockaddr_get_len(&alloc->hkey.clt_addr), 
 				 tdata);
@@ -1077,4 +1114,5 @@
  */
 static pj_status_t stun_on_send_msg(pj_stun_session *sess,
+				    void *token,
 				    const void *pkt,
 				    pj_size_t pkt_size,
@@ -1084,8 +1122,10 @@
     pj_turn_allocation *alloc;
 
+    PJ_UNUSED_ARG(token);
+
     alloc = (pj_turn_allocation*) pj_stun_session_get_user_data(sess);
 
-    return pj_turn_listener_sendto(alloc->listener, pkt, pkt_size, 0,
-				  dst_addr, addr_len);
+    return alloc->transport->sendto(alloc->transport, pkt, pkt_size, 0,
+				    dst_addr, addr_len);
 }
 
@@ -1099,4 +1139,5 @@
 				      unsigned pkt_len,
 				      const pj_stun_rx_data *rdata,
+				      void *token,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len)
@@ -1107,4 +1148,5 @@
     PJ_UNUSED_ARG(pkt);
     PJ_UNUSED_ARG(pkt_len);
+    PJ_UNUSED_ARG(token);
     PJ_UNUSED_ARG(src_addr);
     PJ_UNUSED_ARG(src_addr_len);
@@ -1275,4 +1317,5 @@
 					 unsigned pkt_len,
 					 const pj_stun_msg *msg,
+					 void *token,
 					 const pj_sockaddr_t *src_addr,
 					 unsigned src_addr_len)
@@ -1282,7 +1325,9 @@
     pj_turn_allocation *alloc;
     pj_turn_permission *perm;
+    pj_ssize_t len;
 
     PJ_UNUSED_ARG(pkt);
     PJ_UNUSED_ARG(pkt_len);
+    PJ_UNUSED_ARG(token);
     PJ_UNUSED_ARG(src_addr);
     PJ_UNUSED_ARG(src_addr_len);
@@ -1321,13 +1366,9 @@
 	return PJ_SUCCESS;
 
-    /* Relay the data to client */
-    if (alloc->hkey.tp_type == PJ_TURN_TP_UDP) {
-	pj_ssize_t len = data_attr->length;
-	pj_sock_sendto(alloc->listener->sock, data_attr->data, 
-		       &len, 0, &peer_attr->sockaddr,
-		       pj_sockaddr_get_len(&peer_attr->sockaddr));
-    } else {
-	pj_assert(!"TCP is not supported");
-    }
+    /* Relay the data to peer */
+    len = data_attr->length;
+    pj_sock_sendto(alloc->relay.tp.sock, data_attr->data, 
+		   &len, 0, &peer_attr->sockaddr,
+		   pj_sockaddr_get_len(&peer_attr->sockaddr));
 
     return PJ_SUCCESS;
Index: pjproject/trunk/pjnath/src/pjturn-srv/listener_tcp.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/listener_tcp.c	(revision 1913)
+++ pjproject/trunk/pjnath/src/pjturn-srv/listener_tcp.c	(revision 1913)
@@ -0,0 +1,480 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include "turn.h"
+#include <pj/compat/socket.h>
+
+struct accept_op
+{
+    pj_ioqueue_op_key_t	op_key;
+    pj_sock_t		sock;
+    pj_sockaddr		src_addr;
+    int			src_addr_len;
+};
+
+struct tcp_listener
+{
+    pj_turn_listener	     base;
+    pj_ioqueue_key_t	    *key;
+    unsigned		     accept_cnt;
+    struct accept_op	    *accept_op;	/* Array of accept_op's	*/
+};
+
+
+static void lis_on_accept_complete(pj_ioqueue_key_t *key, 
+				   pj_ioqueue_op_key_t *op_key, 
+				   pj_sock_t sock, 
+				   pj_status_t status);
+static pj_status_t lis_destroy(pj_turn_listener *listener);
+static void transport_create(pj_sock_t sock, pj_turn_listener *lis,
+			     pj_sockaddr_t *src_addr, int src_addr_len);
+
+static void show_err(const char *sender, const char *title, 
+		     pj_status_t status)
+{
+    char errmsg[PJ_ERR_MSG_SIZE];
+
+    pj_strerror(status, errmsg, sizeof(errmsg));
+    PJ_LOG(4,(sender, "%s: %s", title, errmsg));
+}
+
+
+/*
+ * Create a new listener on the specified port.
+ */
+PJ_DEF(pj_status_t) pj_turn_listener_create_tcp(pj_turn_srv *srv,
+					        int af,
+					        const pj_str_t *bound_addr,
+					        unsigned port,
+						unsigned concurrency_cnt,
+						unsigned flags,
+						pj_turn_listener **p_listener)
+{
+    pj_pool_t *pool;
+    struct tcp_listener *tcp_lis;
+    pj_ioqueue_callback ioqueue_cb;
+    unsigned i;
+    pj_status_t status;
+
+    /* Create structure */
+    pool = pj_pool_create(srv->core.pf, "tcpl%p", 1000, 1000, NULL);
+    tcp_lis = PJ_POOL_ZALLOC_T(pool, struct tcp_listener);
+    tcp_lis->base.pool = pool;
+    tcp_lis->base.obj_name = pool->obj_name;
+    tcp_lis->base.server = srv;
+    tcp_lis->base.tp_type = PJ_TURN_TP_TCP;
+    tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    //tcp_lis->base.sendto = &tcp_sendto;
+    tcp_lis->base.destroy = &lis_destroy;
+    tcp_lis->accept_cnt = concurrency_cnt;
+    tcp_lis->base.flags = flags;
+
+    /* Create socket */
+    status = pj_sock_socket(af, pj_SOCK_STREAM(), 0, &tcp_lis->base.sock);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Init bind address */
+    status = pj_sockaddr_init(af, &tcp_lis->base.addr, bound_addr, 
+			      (pj_uint16_t)port);
+    if (status != PJ_SUCCESS) 
+	goto on_error;
+    
+    /* Create info */
+    pj_ansi_strcpy(tcp_lis->base.info, "TCP:");
+    pj_sockaddr_print(&tcp_lis->base.addr, tcp_lis->base.info+4, 
+		      sizeof(tcp_lis->base.info)-4, 3);
+
+    /* Bind socket */
+    status = pj_sock_bind(tcp_lis->base.sock, &tcp_lis->base.addr, 
+			  pj_sockaddr_get_len(&tcp_lis->base.addr));
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Listen() */
+    status = pj_sock_listen(tcp_lis->base.sock, 5);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Register to ioqueue */
+    pj_bzero(&ioqueue_cb, sizeof(ioqueue_cb));
+    ioqueue_cb.on_accept_complete = &lis_on_accept_complete;
+    status = pj_ioqueue_register_sock(pool, srv->core.ioqueue, tcp_lis->base.sock,
+				      tcp_lis, &ioqueue_cb, &tcp_lis->key);
+
+    /* Create op keys */
+    tcp_lis->accept_op = (struct accept_op*)pj_pool_calloc(pool, concurrency_cnt,
+						    sizeof(struct accept_op));
+
+    /* Create each accept_op and kick off read operation */
+    for (i=0; i<concurrency_cnt; ++i) {
+	lis_on_accept_complete(tcp_lis->key, &tcp_lis->accept_op[i].op_key, 
+			       PJ_INVALID_SOCKET, PJ_EPENDING);
+    }
+
+    /* Done */
+    PJ_LOG(4,(tcp_lis->base.obj_name, "Listener %s created", 
+	   tcp_lis->base.info));
+
+    *p_listener = &tcp_lis->base;
+    return PJ_SUCCESS;
+
+
+on_error:
+    lis_destroy(&tcp_lis->base);
+    return status;
+}
+
+
+/*
+ * Destroy listener.
+ */
+static pj_status_t lis_destroy(pj_turn_listener *listener)
+{
+    struct tcp_listener *tcp_lis = (struct tcp_listener *)listener;
+    unsigned i;
+
+    if (tcp_lis->key) {
+	pj_ioqueue_unregister(tcp_lis->key);
+	tcp_lis->key = NULL;
+	tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    } else if (tcp_lis->base.sock != PJ_INVALID_SOCKET) {
+	pj_sock_close(tcp_lis->base.sock);
+	tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    }
+
+    for (i=0; i<tcp_lis->accept_cnt; ++i) {
+	/* Nothing to do */
+    }
+
+    if (tcp_lis->base.pool) {
+	pj_pool_t *pool = tcp_lis->base.pool;
+
+	PJ_LOG(4,(tcp_lis->base.obj_name, "Listener %s destroyed", 
+		  tcp_lis->base.info));
+
+	tcp_lis->base.pool = NULL;
+	pj_pool_release(pool);
+    }
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Callback on new TCP connection.
+ */
+static void lis_on_accept_complete(pj_ioqueue_key_t *key, 
+				   pj_ioqueue_op_key_t *op_key, 
+				   pj_sock_t sock, 
+				   pj_status_t status)
+{
+    struct tcp_listener *tcp_lis;
+    struct accept_op *accept_op = (struct accept_op*) op_key;
+
+    tcp_lis = (struct tcp_listener*) pj_ioqueue_get_user_data(key);
+
+    PJ_UNUSED_ARG(sock);
+
+    do {
+	/* Report new connection. */
+	if (status == PJ_SUCCESS) {
+	    char addr[PJ_INET6_ADDRSTRLEN+8];
+	    PJ_LOG(5,(tcp_lis->base.obj_name, "Incoming TCP from %s",
+		      pj_sockaddr_print(&accept_op->src_addr, addr,
+					sizeof(addr), 3)));
+	    transport_create(accept_op->sock, &tcp_lis->base,
+			     &accept_op->src_addr, accept_op->src_addr_len);
+	} else if (status != PJ_EPENDING) {
+	    show_err(tcp_lis->base.obj_name, "accept()", status);
+	}
+
+	/* Prepare next accept() */
+	accept_op->src_addr_len = sizeof(accept_op->src_addr);
+	status = pj_ioqueue_accept(key, op_key, &accept_op->sock,
+				   NULL,
+				   &accept_op->src_addr,
+				   &accept_op->src_addr_len);
+
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
+}
+
+
+/****************************************************************************/
+/*
+ * Transport
+ */
+enum
+{
+    TIMER_NONE,
+    TIMER_DESTROY
+};
+
+/* The delay in seconds to be applied before TCP transport is destroyed when 
+ * no allocation is referencing it. This also means the initial time to wait
+ * after the initial TCP connection establishment to receive a valid STUN
+ * message in the transport.
+ */
+#define SHUTDOWN_DELAY  10
+
+struct recv_op
+{
+    pj_ioqueue_op_key_t	op_key;
+    pj_turn_pkt		pkt;
+};
+
+struct tcp_transport
+{
+    pj_turn_transport	 base;
+    pj_pool_t		*pool;
+    pj_timer_entry	 timer;
+
+    pj_turn_allocation	*alloc;
+    int			 ref_cnt;
+
+    pj_sock_t		 sock;
+    pj_ioqueue_key_t	*key;
+    struct recv_op	 recv_op;
+    pj_ioqueue_op_key_t	 send_op;
+};
+
+
+static void tcp_on_read_complete(pj_ioqueue_key_t *key, 
+				 pj_ioqueue_op_key_t *op_key, 
+				 pj_ssize_t bytes_read);
+
+static pj_status_t tcp_sendto(pj_turn_transport *tp,
+			      const void *packet,
+			      pj_size_t size,
+			      unsigned flag,
+			      const pj_sockaddr_t *addr,
+			      int addr_len);
+static void tcp_destroy(struct tcp_transport *tcp);
+static void tcp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
+static void tcp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
+static void timer_callback(pj_timer_heap_t *timer_heap,
+			   pj_timer_entry *entry);
+
+static void transport_create(pj_sock_t sock, pj_turn_listener *lis,
+			     pj_sockaddr_t *src_addr, int src_addr_len)
+{
+    pj_pool_t *pool;
+    struct tcp_transport *tcp;
+    pj_ioqueue_callback cb;
+    pj_status_t status;
+
+    pool = pj_pool_create(lis->server->core.pf, "tcp%p", 1000, 1000, NULL);
+
+    tcp = PJ_POOL_ZALLOC_T(pool, struct tcp_transport);
+    tcp->base.obj_name = pool->obj_name;
+    tcp->base.listener = lis;
+    tcp->base.info = lis->info;
+    tcp->base.sendto = &tcp_sendto;
+    tcp->base.add_ref = &tcp_add_ref;
+    tcp->base.dec_ref = &tcp_dec_ref;
+    tcp->pool = pool;
+    tcp->sock = sock;
+
+    pj_timer_entry_init(&tcp->timer, TIMER_NONE, tcp, &timer_callback);
+
+    /* Register to ioqueue */
+    pj_bzero(&cb, sizeof(cb));
+    cb.on_read_complete = &tcp_on_read_complete;
+    status = pj_ioqueue_register_sock(pool, lis->server->core.ioqueue, sock,
+				      tcp, &cb, &tcp->key);
+    if (status != PJ_SUCCESS) {
+	tcp_destroy(tcp);
+	return;
+    }
+
+    /* Init pkt */
+    tcp->recv_op.pkt.pool = pj_pool_create(lis->server->core.pf, "tcpkt%p", 
+					   1000, 1000, NULL);
+    tcp->recv_op.pkt.transport = &tcp->base;
+    tcp->recv_op.pkt.src.tp_type = PJ_TURN_TP_TCP;
+    tcp->recv_op.pkt.src_addr_len = src_addr_len;
+    pj_memcpy(&tcp->recv_op.pkt.src.clt_addr, src_addr, src_addr_len);
+
+    tcp_on_read_complete(tcp->key, &tcp->recv_op.op_key, -PJ_EPENDING);
+    /* Should not access transport from now, it may have been destroyed */
+}
+
+
+static void tcp_destroy(struct tcp_transport *tcp)
+{
+    if (tcp->key) {
+	pj_ioqueue_unregister(tcp->key);
+	tcp->key = NULL;
+	tcp->sock = 0;
+    } else if (tcp->sock) {
+	pj_sock_close(tcp->sock);
+	tcp->sock = 0;
+    }
+
+    if (tcp->pool) {
+	pj_pool_release(tcp->pool);
+    }
+}
+
+
+static void timer_callback(pj_timer_heap_t *timer_heap,
+			   pj_timer_entry *entry)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) entry->user_data;
+
+    PJ_UNUSED_ARG(timer_heap);
+
+    tcp_destroy(tcp);
+}
+
+
+static void tcp_on_read_complete(pj_ioqueue_key_t *key, 
+				 pj_ioqueue_op_key_t *op_key, 
+				 pj_ssize_t bytes_read)
+{
+    struct tcp_transport *tcp;
+    struct recv_op *recv_op = (struct recv_op*) op_key;
+    pj_status_t status;
+
+    tcp = (struct tcp_transport*) pj_ioqueue_get_user_data(key);
+
+    do {
+	/* Report to server or allocation, if we have allocation */
+	if (bytes_read > 0) {
+
+	    recv_op->pkt.len = bytes_read;
+	    pj_gettimeofday(&recv_op->pkt.rx_time);
+
+	    tcp_add_ref(&tcp->base, NULL);
+
+	    if (tcp->alloc) {
+		pj_turn_allocation_on_rx_client_pkt(tcp->alloc, &recv_op->pkt);
+	    } else {
+		pj_turn_srv_on_rx_pkt(tcp->base.listener->server, &recv_op->pkt);
+	    }
+
+	    pj_assert(tcp->ref_cnt > 0);
+	    tcp_dec_ref(&tcp->base, NULL);
+
+	} else if (bytes_read != -PJ_EPENDING) {
+	    /* TCP connection closed/error. Notify client and then destroy 
+	     * ourselves.
+	     * Note: the -PJ_EPENDING is the value passed during init.
+	     */
+	    ++tcp->ref_cnt;
+
+	    if (tcp->alloc) {
+		if (bytes_read != 0) {
+		    show_err(tcp->base.obj_name, "TCP socket error", 
+			     -bytes_read);
+		} else {
+		    PJ_LOG(5,(tcp->base.obj_name, "TCP socket closed"));
+		}
+		pj_turn_allocation_on_transport_closed(tcp->alloc, &tcp->base);
+		tcp->alloc = NULL;
+	    }
+
+	    pj_assert(tcp->ref_cnt > 0);
+	    if (--tcp->ref_cnt == 0) {
+		tcp_destroy(tcp);
+		return;
+	    }
+	}
+
+	/* Reset pool */
+	pj_pool_reset(recv_op->pkt.pool);
+
+	/* If packet is full discard it */
+	if (recv_op->pkt.len == sizeof(recv_op->pkt.pkt)) {
+	    PJ_LOG(4,(tcp->base.obj_name, "Buffer discarded"));
+	    recv_op->pkt.len = 0;
+	}
+
+	/* Read next packet */
+	bytes_read = sizeof(recv_op->pkt.pkt) - recv_op->pkt.len;
+	status = pj_ioqueue_recv(tcp->key, op_key,
+				 recv_op->pkt.pkt + recv_op->pkt.len, 
+				 &bytes_read, 0);
+
+	if (status != PJ_EPENDING && status != PJ_SUCCESS)
+	    bytes_read = -status;
+
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
+
+}
+
+
+static pj_status_t tcp_sendto(pj_turn_transport *tp,
+			      const void *packet,
+			      pj_size_t size,
+			      unsigned flag,
+			      const pj_sockaddr_t *addr,
+			      int addr_len)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+    pj_ssize_t length = size;
+
+    PJ_UNUSED_ARG(addr);
+    PJ_UNUSED_ARG(addr_len);
+
+    return pj_ioqueue_send(tcp->key, &tcp->send_op, packet, &length, flag);
+}
+
+
+static void tcp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+
+    ++tcp->ref_cnt;
+
+    if (tcp->alloc == NULL && alloc) {
+	tcp->alloc = alloc;
+    }
+
+    /* Cancel shutdown timer if it's running */
+    if (tcp->timer.id != TIMER_NONE) {
+	pj_timer_heap_cancel(tcp->base.listener->server->core.timer_heap,
+			     &tcp->timer);
+	tcp->timer.id = TIMER_NONE;
+    }
+}
+
+
+static void tcp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+
+    --tcp->ref_cnt;
+
+    if (alloc && alloc == tcp->alloc) {
+	tcp->alloc = NULL;
+    }
+
+    if (tcp->ref_cnt == 0 && tcp->timer.id == TIMER_NONE) {
+	pj_time_val delay = { SHUTDOWN_DELAY, 0 };
+	tcp->timer.id = TIMER_DESTROY;
+	pj_timer_heap_schedule(tcp->base.listener->server->core.timer_heap,
+			       &tcp->timer, &delay);
+    }
+}
+
Index: pjproject/trunk/pjnath/src/pjturn-srv/listener_udp.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/listener_udp.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-srv/listener_udp.c	(revision 1913)
@@ -18,4 +18,5 @@
  */
 #include "turn.h"
+#include <pj/compat/socket.h>
 
 struct read_op
@@ -28,11 +29,19 @@
 {
     pj_turn_listener	     base;
+
     pj_ioqueue_key_t	    *key;
     unsigned		     read_cnt;
     struct read_op	    **read_op;	/* Array of read_op's	*/
+
+    pj_turn_transport	     tp;	/* Transport instance */
 };
 
 
-static pj_status_t udp_sendto(pj_turn_listener *listener,
+static pj_status_t udp_destroy(pj_turn_listener *udp);
+static void on_read_complete(pj_ioqueue_key_t *key, 
+			     pj_ioqueue_op_key_t *op_key, 
+			     pj_ssize_t bytes_read);
+
+static pj_status_t udp_sendto(pj_turn_transport *tp,
 			      const void *packet,
 			      pj_size_t size,
@@ -40,8 +49,8 @@
 			      const pj_sockaddr_t *addr,
 			      int addr_len);
-static pj_status_t udp_destroy(pj_turn_listener *udp);
-static void on_read_complete(pj_ioqueue_key_t *key, 
-			     pj_ioqueue_op_key_t *op_key, 
-			     pj_ssize_t bytes_read);
+static void udp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
+static void udp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
 
 
@@ -71,8 +80,14 @@
     udp->base.tp_type = PJ_TURN_TP_UDP;
     udp->base.sock = PJ_INVALID_SOCKET;
-    udp->base.sendto = &udp_sendto;
     udp->base.destroy = &udp_destroy;
     udp->read_cnt = concurrency_cnt;
     udp->base.flags = flags;
+
+    udp->tp.obj_name = udp->base.obj_name;
+    udp->tp.info = udp->base.info;
+    udp->tp.listener = &udp->base;
+    udp->tp.sendto = &udp_sendto;
+    udp->tp.add_ref = &udp_add_ref;
+    udp->tp.dec_ref = &udp_dec_ref;
 
     /* Create socket */
@@ -173,5 +188,5 @@
  * Callback to send packet.
  */
-static pj_status_t udp_sendto(pj_turn_listener *listener,
+static pj_status_t udp_sendto(pj_turn_transport *tp,
 			      const void *packet,
 			      pj_size_t size,
@@ -181,6 +196,24 @@
 {
     pj_ssize_t len = size;
-    return pj_sock_sendto(listener->sock, packet, &len, flag, addr, addr_len);
-}
+    return pj_sock_sendto(tp->listener->sock, packet, &len, flag, addr, addr_len);
+}
+
+
+static void udp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    /* Do nothing */
+    PJ_UNUSED_ARG(tp);
+    PJ_UNUSED_ARG(alloc);
+}
+
+static void udp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    /* Do nothing */
+    PJ_UNUSED_ARG(tp);
+    PJ_UNUSED_ARG(alloc);
+}
+
 
 /*
@@ -212,5 +245,5 @@
 	pj_pool_reset(rpool);
 	read_op->pkt.pool = rpool;
-	read_op->pkt.listener = &udp->base;
+	read_op->pkt.transport = &udp->tp;
 	read_op->pkt.src.tp_type = udp->base.tp_type;
 
@@ -228,5 +261,6 @@
 	    bytes_read = -status;
 
-    } while (status != PJ_EPENDING && status != PJ_ECANCELLED);
-}
-
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
+}
+
Index: pjproject/trunk/pjnath/src/pjturn-srv/main.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/main.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-srv/main.c	(revision 1913)
@@ -141,4 +141,9 @@
 					 PJ_STUN_PORT, 1, 0, &listener);
     if (status != PJ_SUCCESS)
+	return err("Error creating UDP listener", status);
+
+    status = pj_turn_listener_create_tcp(srv, pj_AF_INET(), NULL, 
+					 PJ_STUN_PORT, 1, 0, &listener);
+    if (status != PJ_SUCCESS)
 	return err("Error creating listener", status);
 
Index: pjproject/trunk/pjnath/src/pjturn-srv/server.c
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-srv/server.c	(revision 1913)
@@ -29,9 +29,10 @@
 #define MAX_LISTENERS		16
 #define MAX_THREADS		2
-#define MAX_NET_EVENTS		10
+#define MAX_NET_EVENTS		1000
 
 /* Prototypes */
 static int server_thread_proc(void *arg);
 static pj_status_t on_tx_stun_msg( pj_stun_session *sess,
+				   void *token,
 				   const void *pkt,
 				   pj_size_t pkt_size,
@@ -42,4 +43,5 @@
 				      unsigned pkt_len,
 				      const pj_stun_rx_data *rdata,
+				      void *user_data,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len);
@@ -78,4 +80,5 @@
 {
     pj_pool_t *pool;
+    pj_stun_session_cb sess_cb;
     pj_turn_srv *srv;
     unsigned i;
@@ -125,9 +128,4 @@
 					sizeof(srv->core.listener[0]));
 
-    /* Array of STUN sessions, one for each listener */
-    srv->core.stun_sess = (pj_stun_session**)
-			  pj_pool_calloc(pool, MAX_LISTENERS,
-					 (sizeof(srv->core.stun_sess[0])));
-
     /* Create hash tables */
     srv->tables.alloc = pj_hash_create(pool, MAX_CLIENTS);
@@ -150,4 +148,20 @@
     srv->core.cred.data.dyn_cred.get_password = &pj_turn_get_password;
     srv->core.cred.data.dyn_cred.verify_nonce = &pj_turn_verify_nonce;
+
+    /* Create STUN session to handle new allocation */
+    pj_bzero(&sess_cb, sizeof(sess_cb));
+    sess_cb.on_rx_request = &on_rx_stun_request;
+    sess_cb.on_send_msg = &on_tx_stun_msg;
+
+    status = pj_stun_session_create(&srv->core.stun_cfg, srv->obj_name,
+				    &sess_cb, PJ_FALSE, &srv->core.stun_sess);
+    if (status != PJ_SUCCESS) {
+	goto on_error;
+    }
+
+    pj_stun_session_set_user_data(srv->core.stun_sess, srv);
+    pj_stun_session_set_credential(srv->core.stun_sess, PJ_STUN_AUTH_LONG_TERM,
+				   &srv->core.cred);
+
 
     /* Array of worker threads */
@@ -241,5 +255,5 @@
 
     while (!srv->core.quit) {
-	pj_time_val timeout_max = {0, 500};
+	pj_time_val timeout_max = {0, 100};
 	srv_handle_events(srv, &timeout_max);
     }
@@ -278,5 +292,5 @@
     }
     
-    /* Destroy all listeners and STUN sessions associated with them. */
+    /* Destroy all listeners. */
     for (i=0; i<srv->core.lis_cnt; ++i) {
 	if (srv->core.listener[i]) {
@@ -284,8 +298,10 @@
 	    srv->core.listener[i] = NULL;
 	}
-	if (srv->core.stun_sess[i]) {
-	    pj_stun_session_destroy(srv->core.stun_sess[i]);
-	    srv->core.stun_sess[i] = NULL;
-	}
+    }
+
+    /* Destroy STUN session */
+    if (srv->core.stun_sess) {
+	pj_stun_session_destroy(srv->core.stun_sess);
+	srv->core.stun_sess = NULL;
     }
 
@@ -342,8 +358,5 @@
 					     pj_turn_listener *lis)
 {
-    pj_stun_session_cb sess_cb;
     unsigned index;
-    pj_stun_session *sess;
-    pj_status_t status;
 
     PJ_ASSERT_RETURN(srv && lis, PJ_EINVAL);
@@ -354,22 +367,4 @@
     srv->core.listener[index] = lis;
     lis->server = srv;
-
-    /* Create STUN session to handle new allocation */
-    pj_bzero(&sess_cb, sizeof(sess_cb));
-    sess_cb.on_rx_request = &on_rx_stun_request;
-    sess_cb.on_send_msg = &on_tx_stun_msg;
-
-    status = pj_stun_session_create(&srv->core.stun_cfg, lis->obj_name, 
-				    &sess_cb, PJ_FALSE, &sess);
-    if (status != PJ_SUCCESS) {
-	srv->core.listener[index] = NULL;
-	return status;
-    }
-
-    pj_stun_session_set_user_data(sess, lis);
-    pj_stun_session_set_credential(sess, PJ_STUN_AUTH_LONG_TERM, 
-				   &srv->core.cred);
-
-    srv->core.stun_sess[index] = sess;
     lis->id = index;
     srv->core.lis_cnt++;
@@ -379,19 +374,4 @@
 
     return PJ_SUCCESS;
-}
-
-
-/*
- * Send packet with this listener.
- */
-PJ_DEF(pj_status_t) pj_turn_listener_sendto(pj_turn_listener *listener,
-					    const void *packet,
-					    pj_size_t size,
-					    unsigned flag,
-					    const pj_sockaddr_t *addr,
-					    int addr_len)
-{
-    pj_assert(listener->id != PJ_TURN_INVALID_LIS_ID);
-    return listener->sendto(listener, packet, size, flag, addr, addr_len);
 }
 
@@ -412,8 +392,4 @@
 	    srv->core.lis_cnt--;
 	    listener->id = PJ_TURN_INVALID_LIS_ID;
-	    if (srv->core.stun_sess[i]) {
-		pj_stun_session_destroy(srv->core.stun_sess[i]);
-		srv->core.stun_sess[i] = NULL;
-	    }
 	    break;
 	}
@@ -423,4 +399,24 @@
     /* Destroy */
     return listener->destroy(listener);
+}
+
+
+/**
+ * Add a reference to a transport.
+ */
+PJ_DEF(void) pj_turn_transport_add_ref( pj_turn_transport *transport,
+					pj_turn_allocation *alloc)
+{
+    transport->add_ref(transport, alloc);
+}
+
+
+/**
+ * Decrement transport reference counter.
+ */
+PJ_DEF(void) pj_turn_transport_dec_ref( pj_turn_transport *transport,
+					pj_turn_allocation *alloc)
+{
+    transport->dec_ref(transport, alloc);
 }
 
@@ -467,17 +463,18 @@
  */
 static pj_status_t on_tx_stun_msg( pj_stun_session *sess,
-				   const void *pkt,
-				   pj_size_t pkt_size,
+				   void *token,
+				   const void *pdu,
+				   pj_size_t pdu_size,
 				   const pj_sockaddr_t *dst_addr,
 				   unsigned addr_len)
 {
-    pj_turn_listener *listener;
+    pj_turn_transport *transport = (pj_turn_transport*) token;
     
-    listener = (pj_turn_listener*) pj_stun_session_get_user_data(sess);
-
-    PJ_ASSERT_RETURN(listener!=NULL, PJ_EINVALIDOP);
-
-    return pj_turn_listener_sendto(listener, pkt, pkt_size, 0, 
-				   dst_addr, addr_len);
+    PJ_ASSERT_RETURN(transport!=NULL, PJ_EINVALIDOP);
+
+    PJ_UNUSED_ARG(sess);
+
+    return transport->sendto(transport, pdu, pdu_size, 0, 
+			     dst_addr, addr_len);
 }
 
@@ -485,4 +482,5 @@
 /* Respond to STUN request */
 static pj_status_t stun_respond(pj_stun_session *sess, 
+				pj_turn_transport *transport,
 				const pj_stun_rx_data *rdata,
 				unsigned code, 
@@ -504,5 +502,6 @@
 
     /* Send the response */
-    return pj_stun_session_send_msg(sess, cache, dst_addr,  addr_len, tdata);
+    return pj_stun_session_send_msg(sess, transport, cache, PJ_FALSE, 
+				    dst_addr,  addr_len, tdata);
 }
 
@@ -510,14 +509,15 @@
 /* Callback from our own STUN session when incoming request arrives.
  * This function is triggered by pj_stun_session_on_rx_pkt() call in
-  * pj_turn_srv_on_rx_pkt() function below.
+ * pj_turn_srv_on_rx_pkt() function below.
  */
 static pj_status_t on_rx_stun_request(pj_stun_session *sess,
-				      const pj_uint8_t *pkt,
-				      unsigned pkt_len,
+				      const pj_uint8_t *pdu,
+				      unsigned pdu_len,
 				      const pj_stun_rx_data *rdata,
+				      void *token,
 				      const pj_sockaddr_t *src_addr,
 				      unsigned src_addr_len)
 {
-    pj_turn_listener *listener;
+    pj_turn_transport *transport;
     const pj_stun_msg *msg = rdata->msg;
     pj_turn_srv *srv;
@@ -525,13 +525,13 @@
     pj_status_t status;
 
-    PJ_UNUSED_ARG(pkt);
-    PJ_UNUSED_ARG(pkt_len);
-
-    listener = (pj_turn_listener*) pj_stun_session_get_user_data(sess);
-    srv = listener->server;
+    PJ_UNUSED_ARG(pdu);
+    PJ_UNUSED_ARG(pdu_len);
+
+    transport = (pj_turn_transport*) token;
+    srv = transport->listener->server;
 
     /* Respond any requests other than ALLOCATE with 437 response */
     if (msg->hdr.type != PJ_STUN_ALLOCATE_REQUEST) {
-	stun_respond(sess, rdata, PJ_STUN_SC_ALLOCATION_MISMATCH,
+	stun_respond(sess, transport, rdata, PJ_STUN_SC_ALLOCATION_MISMATCH,
 		     NULL, PJ_FALSE, src_addr, src_addr_len);
 	return PJ_SUCCESS;
@@ -541,5 +541,5 @@
      * in this function.
      */
-    status = pj_turn_allocation_create(listener, src_addr, src_addr_len,
+    status = pj_turn_allocation_create(transport, src_addr, src_addr_len,
 				       rdata, sess, &alloc);
     if (status != PJ_SUCCESS) {
@@ -577,26 +577,41 @@
     } else {
 	/* Otherwise this is a new client */
-	unsigned options, lis_id;
+	unsigned options;
+	unsigned parsed_len;
 	pj_status_t status;
 
 	/* Check that this is a STUN message */
 	options = PJ_STUN_CHECK_PACKET;
-	if (pkt->listener->tp_type == PJ_TURN_TP_UDP)
+	if (pkt->transport->listener->tp_type == PJ_TURN_TP_UDP)
 	    options |= PJ_STUN_IS_DATAGRAM;
 
 	status = pj_stun_msg_check(pkt->pkt, pkt->len, options);
 	if (status != PJ_SUCCESS) {
-	    char errmsg[PJ_ERR_MSG_SIZE];
-	    char ip[PJ_INET6_ADDRSTRLEN+10];
-
-	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(5,(srv->obj_name, 
-		      "Non STUN packet from %s is dropped: %s",
-		      pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
-		      errmsg));
+	    /* If the first byte are not STUN, drop the packet. First byte
+	     * of STUN message is always 0x00 or 0x01. Otherwise wait for
+	     * more data as the data might have come from TCP.
+	     *
+	     * Also drop packet if it's unreasonably too big, as this might
+	     * indicate invalid data that's building up in the buffer.
+	     *
+	     * Or if packet is a datagram.
+	     */
+	    if ((*pkt->pkt != 0x00 && *pkt->pkt != 0x01) ||
+		pkt->len > 1600 ||
+		(options & PJ_STUN_IS_DATAGRAM)) 
+	    {
+		char errmsg[PJ_ERR_MSG_SIZE];
+		char ip[PJ_INET6_ADDRSTRLEN+10];
+
+		pkt->len = 0;
+
+		pj_strerror(status, errmsg, sizeof(errmsg));
+		PJ_LOG(5,(srv->obj_name, 
+			  "Non-STUN packet from %s is dropped: %s",
+			  pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
+			  errmsg));
+	    }
 	    return;
 	}
-
-	lis_id = pkt->listener->id;
 
 	/* Hand over processing to STUN session. This will trigger
@@ -605,7 +620,8 @@
 	 */
 	options &= ~PJ_STUN_CHECK_PACKET;
-	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess[lis_id], 
-					   pkt->pkt, pkt->len, options, NULL,
-					   &pkt->src.clt_addr, 
+	parsed_len = 0;
+	status = pj_stun_session_on_rx_pkt(srv->core.stun_sess, pkt->pkt, 
+					   pkt->len, options, pkt->transport,
+					   &parsed_len, &pkt->src.clt_addr, 
 					   pkt->src_addr_len);
 	if (status != PJ_SUCCESS) {
@@ -618,8 +634,19 @@
 		      pj_sockaddr_print(&pkt->src.clt_addr, ip, sizeof(ip), 3),
 		      errmsg));
-	    return;
-	}
-    }
-}
-
-
+	}
+
+	if (pkt->transport->listener->tp_type == PJ_TURN_TP_UDP) {
+	    pkt->len = 0;
+	} else if (parsed_len > 0) {
+	    if (parsed_len == pkt->len) {
+		pkt->len = 0;
+	    } else {
+		pj_memmove(pkt->pkt, pkt->pkt+parsed_len,
+			   pkt->len - parsed_len);
+		pkt->len -= parsed_len;
+	    }
+	}
+    }
+}
+
+
Index: pjproject/trunk/pjnath/src/pjturn-srv/turn.h
===================================================================
--- pjproject/trunk/pjnath/src/pjturn-srv/turn.h	(revision 1912)
+++ pjproject/trunk/pjnath/src/pjturn-srv/turn.h	(revision 1913)
@@ -23,8 +23,9 @@
 #include <pjnath.h>
 
-typedef struct pj_turn_relay_res	    pj_turn_relay_res;
+typedef struct pj_turn_relay_res    pj_turn_relay_res;
 typedef struct pj_turn_listener	    pj_turn_listener;
-typedef struct pj_turn_permission    pj_turn_permission;
-typedef struct pj_turn_allocation    pj_turn_allocation;
+typedef struct pj_turn_transport    pj_turn_transport;
+typedef struct pj_turn_permission   pj_turn_permission;
+typedef struct pj_turn_allocation   pj_turn_allocation;
 typedef struct pj_turn_srv	    pj_turn_srv;
 typedef struct pj_turn_pkt	    pj_turn_pkt;
@@ -133,9 +134,9 @@
     pj_lock_t		*lock;
 
-    /** TURN listener. */
-    pj_turn_listener	*listener;
-
-    /** Client socket, if connection to client is using TCP. */
-    pj_sock_t		clt_sock;
+    /** Server instance. */
+    pj_turn_srv		*server;
+
+    /** Transport to send/receive packets to/from client. */
+    pj_turn_transport	*transport;
 
     /** The relay resource for this allocation. */
@@ -181,9 +182,4 @@
     /** Hash table key */
     pj_turn_permission_key hkey;
-
-    /** Transport socket. If TCP is used, the value will be the actual
-     *  TCP socket. If UDP is used, the value will be the relay address
-     */
-    pj_sock_t		sock;
 
     /** TURN allocation that owns this permission/channel */
@@ -202,10 +198,10 @@
  * Create new allocation.
  */
-PJ_DECL(pj_status_t) pj_turn_allocation_create(pj_turn_listener *listener,
-					      const pj_sockaddr_t *src_addr,
-					      unsigned src_addr_len,
-					      const pj_stun_rx_data *rdata,
-					      pj_stun_session *srv_sess,
-					      pj_turn_allocation **p_alloc);
+PJ_DECL(pj_status_t) pj_turn_allocation_create(pj_turn_transport *transport,
+					       const pj_sockaddr_t *src_addr,
+					       unsigned src_addr_len,
+					       const pj_stun_rx_data *rdata,
+					       pj_stun_session *srv_sess,
+					       pj_turn_allocation **p_alloc);
 /**
  * Destroy allocation.
@@ -218,5 +214,11 @@
  */
 PJ_DECL(void) pj_turn_allocation_on_rx_client_pkt(pj_turn_allocation *alloc,
-						 pj_turn_pkt *pkt);
+						  pj_turn_pkt *pkt);
+
+/**
+ * Handle transport closure.
+ */
+PJ_DECL(void) pj_turn_allocation_on_transport_closed(pj_turn_allocation *alloc,
+						     pj_turn_transport *tp);
 
 /****************************************************************************/
@@ -258,6 +260,26 @@
     unsigned		flags;
 
+    /** Destroy handler */
+    pj_status_t		(*destroy)(pj_turn_listener*);
+};
+
+
+/**
+ * This structure describes TURN transport socket which is used to send and
+ * receive packets towards client.
+ */
+struct pj_turn_transport
+{
+    /** Object name/identification */
+    char		*obj_name;
+
+    /** Slightly longer info about this listener */
+    char		*info;
+
+    /** Listener instance */
+    pj_turn_listener	*listener;
+
     /** Sendto handler */
-    pj_status_t		(*sendto)(pj_turn_listener *listener,
+    pj_status_t		(*sendto)(pj_turn_transport *tp,
 				  const void *packet,
 				  pj_size_t size,
@@ -266,6 +288,12 @@
 				  int addr_len);
 
-    /** Destroy handler */
-    pj_status_t		(*destroy)(pj_turn_listener*);
+    /** Addref handler */
+    void		(*add_ref)(pj_turn_transport *tp,
+				   pj_turn_allocation *alloc);
+
+    /** Decref handler */
+    void		(*dec_ref)(pj_turn_transport *tp,
+				   pj_turn_allocation *alloc);
+
 };
 
@@ -279,6 +307,6 @@
     pj_pool_t		    *pool;
 
-    /** Listener that owns this. */
-    pj_turn_listener	    *listener;
+    /** Transport where the packet was received. */
+    pj_turn_transport	    *transport;
 
     /** Packet buffer (must be 32bit aligned). */
@@ -300,23 +328,24 @@
 
 /**
- * Create a new listener on the specified port.
+ * Create a UDP listener on the specified port.
  */
 PJ_DECL(pj_status_t) pj_turn_listener_create_udp(pj_turn_srv *srv,
-						int af,
-					        const pj_str_t *bound_addr,
-					        unsigned port,
-						unsigned concurrency_cnt,
-						unsigned flags,
-						pj_turn_listener **p_listener);
-
-/**
- * Send packet with this listener.
- */
-PJ_DECL(pj_status_t) pj_turn_listener_sendto(pj_turn_listener *listener,
-					    const void *packet,
-					    pj_size_t size,
-					    unsigned flag,
-					    const pj_sockaddr_t *addr,
-					    int addr_len);
+						 int af,
+					         const pj_str_t *bound_addr,
+					         unsigned port,
+						 unsigned concurrency_cnt,
+						 unsigned flags,
+						 pj_turn_listener **p_lis);
+
+/**
+ * Create a TCP listener on the specified port.
+ */
+PJ_DECL(pj_status_t) pj_turn_listener_create_tcp(pj_turn_srv *srv,
+						 int af,
+					         const pj_str_t *bound_addr,
+					         unsigned port,
+						 unsigned concurrency_cnt,
+						 unsigned flags,
+						 pj_turn_listener **p_lis);
 
 /**
@@ -324,4 +353,19 @@
  */
 PJ_DECL(pj_status_t) pj_turn_listener_destroy(pj_turn_listener *listener);
+
+
+/**
+ * Add a reference to a transport.
+ */
+PJ_DECL(void) pj_turn_transport_add_ref(pj_turn_transport *transport,
+					pj_turn_allocation *alloc);
+
+
+/**
+ * Decrement transport reference counter.
+ */
+PJ_DECL(void) pj_turn_transport_dec_ref(pj_turn_transport *transport,
+					pj_turn_allocation *alloc);
+
 
 
@@ -361,6 +405,6 @@
 	pj_turn_listener **listener;
 
-	/** Array of STUN sessions, one for each listeners. */
-	pj_stun_session	**stun_sess;
+	/** STUN session to handle initial Allocate request. */
+	pj_stun_session	*stun_sess;
 
 	/** Number of worker threads. */
@@ -457,5 +501,5 @@
  */
 PJ_DECL(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv, 
-				   pj_turn_pkt *pkt);
+				    pj_turn_pkt *pkt);
 
 
