Index: pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c	(revision 3553)
+++ pjproject/trunk/pjnath/src/pjnath-test/turn_sock_test.c	(revision 5350)
@@ -103,4 +103,5 @@
     pj_stun_auth_cred cred;
     pj_status_t status;
+    pj_bool_t use_ipv6 = cfg->srv.flags & SERVER_IPV6;
 
     /* Create client */
@@ -114,6 +115,11 @@
     turn_sock_cb.on_rx_data = &turn_on_rx_data;
     turn_sock_cb.on_state = &turn_on_state;
-    status = pj_turn_sock_create(sess->stun_cfg, pj_AF_INET(), PJ_TURN_TP_UDP,
-				 &turn_sock_cb, 0, sess, &sess->turn_sock);
+    status = pj_turn_sock_create(sess->stun_cfg,
+				 GET_AF(use_ipv6),
+				 PJ_TURN_TP_UDP, 
+				 &turn_sock_cb, 
+				 0, 
+				 sess, 
+				 &sess->turn_sock);
     if (status != PJ_SUCCESS) {
 	destroy_session(sess);
@@ -122,6 +128,6 @@
 
     /* Create test server */
-    status = create_test_server(sess->stun_cfg, cfg->srv.flags,
-				SRV_DOMAIN, &sess->test_srv);
+    status = create_test_server(sess->stun_cfg, cfg->srv.flags, SRV_DOMAIN, 
+				&sess->test_srv);
     if (status != PJ_SUCCESS) {
 	destroy_session(sess);
@@ -140,5 +146,5 @@
 
     } else {
-	pj_str_t dns_srv = pj_str("127.0.0.1");
+	pj_str_t dns_srv = use_ipv6?pj_str("::1") : pj_str("127.0.0.1");
 	pj_uint16_t dns_srv_port = (pj_uint16_t) DNS_SERVER_PORT;
 	status = pj_dns_resolver_set_ns(sess->resolver, 1, &dns_srv, &dns_srv_port);
@@ -171,5 +177,5 @@
     } else {
 	/* Explicitly specify server address */
-	pj_str_t host = pj_str("127.0.0.1");
+	pj_str_t host = use_ipv6?pj_str("::1") : pj_str("127.0.0.1");
 	status = pj_turn_sock_alloc(sess->turn_sock, &host, TURN_SERVER_PORT,
 				    NULL, &cred, &alloc_param);
@@ -251,11 +257,19 @@
 /////////////////////////////////////////////////////////////////////
 
-static int state_progression_test(pj_stun_config  *stun_cfg)
+static void set_server_flag(struct test_session_cfg *test_cfg, 
+			    pj_bool_t use_ipv6)
+{
+    test_cfg->srv.flags &= ~(SERVER_IPV4+SERVER_IPV6);
+    test_cfg->srv.flags |= (use_ipv6)?SERVER_IPV6:SERVER_IPV4;
+}
+
+static int state_progression_test(pj_stun_config  *stun_cfg, 
+				  pj_bool_t use_ipv6)
 {
     struct test_session_cfg test_cfg = 
     {
-	{   /* Client cfg */
-	    /* DNS SRV */   /* Destroy on state */
-	    PJ_TRUE,	    0xFFFF
+	{   /* Client cfg */			
+	    PJ_TRUE,	    /* DNS SRV */       
+	    0xFFFF	    /* Destroy on state */
 	},
 	{   /* Server cfg */
@@ -267,8 +281,9 @@
     struct test_session *sess;
     unsigned i;
-    int rc;
-
-    PJ_LOG(3,("", "  state progression tests"));
-
+    int rc = 0;
+
+    PJ_LOG(3,("", "  state progression tests - (%s)",use_ipv6?"IPv6":"IPv4"));
+    
+    set_server_flag(&test_cfg, use_ipv6);
     for (i=0; i<=1; ++i) {
 	enum { TIMEOUT = 60 };
@@ -373,5 +388,8 @@
     }
 
-    return 0;
+    if (use_ipv6)
+	rc = state_progression_test(stun_cfg, 0);
+
+    return rc;
 }
 
@@ -381,11 +399,12 @@
 static int destroy_test(pj_stun_config  *stun_cfg,
 			pj_bool_t with_dns_srv,
-			pj_bool_t in_callback)
+			pj_bool_t in_callback,
+			pj_bool_t use_ipv6)
 {
     struct test_session_cfg test_cfg = 
     {
-	{   /* Client cfg */
-	    /* DNS SRV */   /* Destroy on state */
-	    PJ_TRUE,	    0xFFFF
+	{   /* Client cfg */	    
+	    PJ_TRUE,	    /* DNS SRV */   
+	    0xFFFF	    /* Destroy on state */
 	},
 	{   /* Server cfg */
@@ -405,4 +424,5 @@
 
     test_cfg.client.enable_dns_srv = with_dns_srv;
+    set_server_flag(&test_cfg, use_ipv6);    
 
     for (target_state=PJ_TURN_STATE_RESOLVING; target_state<=PJ_TURN_STATE_READY; ++target_state) {
@@ -496,5 +516,5 @@
     }
 
-    rc = state_progression_test(&stun_cfg);
+    rc = state_progression_test(&stun_cfg, USE_IPV6);
     if (rc != 0) 
 	goto on_return;
@@ -503,5 +523,5 @@
 	int j;
 	for (j=0; j<=1; ++j) {
-	    rc = destroy_test(&stun_cfg, i, j);
+	    rc = destroy_test(&stun_cfg, i, j, USE_IPV6);
 	    if (rc != 0)
 		goto on_return;
