Index: pjproject/trunk/pjnath/src/pjnath-test/server.c
===================================================================
--- pjproject/trunk/pjnath/src/pjnath-test/server.c	(revision 5170)
+++ pjproject/trunk/pjnath/src/pjnath-test/server.c	(revision 5350)
@@ -54,8 +54,9 @@
     char strbuf[100];
     pj_status_t status;
+    pj_bool_t use_ipv6 = flags & SERVER_IPV6;
 
     PJ_ASSERT_RETURN(stun_cfg && domain && p_test_srv, PJ_EINVAL);
 
-    status = pj_gethostip(pj_AF_INET(), &hostip);
+    status = pj_gethostip(GET_AF(use_ipv6), &hostip);
     if (status != PJ_SUCCESS)
 	return status;
@@ -75,5 +76,5 @@
     if (flags & CREATE_DNS_SERVER) {
 	status = pj_dns_server_create(mem, test_srv->stun_cfg->ioqueue,
-				      pj_AF_INET(), DNS_SERVER_PORT,
+				      GET_AF(use_ipv6), DNS_SERVER_PORT,
 				      0, &test_srv->dns_server);
 	if (status != PJ_SUCCESS) {
@@ -86,9 +87,15 @@
 	    pj_dns_parsed_rr rr;
 	    pj_str_t res_name;
-	    pj_in_addr ip_addr;
 
 	    pj_strdup2(pool, &res_name, domain);
-	    ip_addr = hostip.ipv4.sin_addr;
-	    pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr);
+
+	    if (use_ipv6) {
+		pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				    &hostip.ipv6.sin6_addr);
+	    } else {		
+		pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				 &hostip.ipv4.sin_addr);
+	    }
+	    
 	    pj_dns_server_add_rec(test_srv->dns_server, 1, &rr);
 	}
@@ -103,5 +110,6 @@
 	stun_sock_cb.on_data_recvfrom = &stun_on_data_recvfrom;
 
-	pj_sockaddr_in_init(&bound_addr.ipv4, NULL, STUN_SERVER_PORT);
+	pj_sockaddr_init(GET_AF(use_ipv6), &bound_addr, 
+			 NULL, STUN_SERVER_PORT);
 
 	status = pj_activesock_create_udp(pool, &bound_addr, NULL, 
@@ -124,5 +132,4 @@
 	    pj_str_t res_name, target;
 	    pj_dns_parsed_rr rr;
-	    pj_in_addr ip_addr;
 
 	    /* Add DNS entries:
@@ -141,6 +148,11 @@
 
 	    res_name = target;
-	    ip_addr = hostip.ipv4.sin_addr;
-	    pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr);
+	    if (use_ipv6) {		
+		pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				    &hostip.ipv6.sin6_addr);
+	    } else {		
+		pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				 &hostip.ipv4.sin_addr);
+	    }
 	    pj_dns_server_add_rec(test_srv->dns_server, 1, &rr);
 	}
@@ -155,5 +167,5 @@
 	turn_sock_cb.on_data_recvfrom = &turn_on_data_recvfrom;
 
-	pj_sockaddr_in_init(&bound_addr.ipv4, NULL, TURN_SERVER_PORT);
+	pj_sockaddr_init(GET_AF(use_ipv6), &bound_addr, NULL, TURN_SERVER_PORT);
 
 	status = pj_activesock_create_udp(pool, &bound_addr, NULL, 
@@ -176,5 +188,4 @@
 	    pj_str_t res_name, target;
 	    pj_dns_parsed_rr rr;
-	    pj_in_addr ip_addr;
 
 	    /* Add DNS entries:
@@ -193,6 +204,12 @@
 
 	    res_name = target;
-	    ip_addr = hostip.ipv4.sin_addr;
-	    pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, &ip_addr);
+	    
+	    if (use_ipv6) {		
+		pj_dns_init_aaaa_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				    &hostip.ipv6.sin6_addr);
+	    } else {		
+		pj_dns_init_a_rr(&rr, &res_name, PJ_DNS_CLASS_IN, 60, 
+				 &hostip.ipv4.sin_addr);
+	    }
 	    pj_dns_server_add_rec(test_srv->dns_server, 1, &rr);
 	}
@@ -345,4 +362,5 @@
     unsigned i;
     pj_ssize_t len;
+    pj_bool_t use_ipv6 = PJ_FALSE;
 
     if (status != PJ_SUCCESS)
@@ -352,4 +370,5 @@
 
     test_srv = (test_server*) pj_activesock_get_user_data(asock);
+    use_ipv6 = test_srv->flags & SERVER_IPV6;
     pool = pj_pool_create(test_srv->stun_cfg->pf, NULL, 512, 512, NULL);
 
@@ -481,7 +500,7 @@
 	alloc->pool = pj_pool_create(test_srv->stun_cfg->pf, "alloc", 512, 512, NULL);
 
-	/* Create relay socket */
-	pj_sockaddr_in_init(&alloc->alloc_addr.ipv4, NULL, 0);
-	pj_gethostip(pj_AF_INET(), &alloc->alloc_addr);
+	/* Create relay socket */	
+	pj_sockaddr_init(GET_AF(use_ipv6), &alloc->alloc_addr, NULL, 0);
+	pj_gethostip(GET_AF(use_ipv6), &alloc->alloc_addr);
 
 	status = pj_activesock_create_udp(alloc->pool, &alloc->alloc_addr, NULL, 
@@ -698,4 +717,6 @@
     unsigned i;
 
+    PJ_UNUSED_ARG(addr_len);
+
     if (status != PJ_SUCCESS)
 	return PJ_TRUE;
@@ -708,8 +729,5 @@
     /* Check that this peer has a permission */
     for (i=0; i<alloc->perm_cnt; ++i) {
-	if (pj_sockaddr_get_len(&alloc->perm[i]) == (unsigned)addr_len &&
-	    pj_memcmp(pj_sockaddr_get_addr(&alloc->perm[i]),
-		      pj_sockaddr_get_addr(src_addr),
-		      addr_len) == 0)
+	if (pj_sockaddr_cmp(&alloc->perm[i], src_addr) == 0)
 	{
 	    break;
