Index: /pjproject/trunk/pjnath/src/pjnath-test/ice_test.c
===================================================================
--- /pjproject/trunk/pjnath/src/pjnath-test/ice_test.c	(revision 5386)
+++ /pjproject/trunk/pjnath/src/pjnath-test/ice_test.c	(revision 5387)
@@ -125,4 +125,27 @@
 static void destroy_sess(struct test_sess *sess, unsigned wait_msec);
 
+#if USE_IPV6
+
+static pj_bool_t enable_ipv6_test()
+{
+    pj_sockaddr addr;
+    pj_bool_t retval = PJ_TRUE;
+    if (pj_gethostip(pj_AF_INET6(), &addr) == PJ_SUCCESS) {
+	const pj_in6_addr *a = &addr.ipv6.sin6_addr;
+	if (a->s6_addr[0] == 0xFE && (a->s6_addr[1] & 0xC0) == 0x80) {
+	    retval = PJ_FALSE;
+	    PJ_LOG(3,(THIS_FILE, INDENT "Skipping IPv6 test due to link-local "
+		     "address"));
+	}
+    } else {
+	retval = PJ_FALSE;
+	PJ_LOG(3,(THIS_FILE, INDENT "Skipping IPv6 test due to fail getting "
+		 "IPv6 address"));
+    }
+    return retval;
+}
+
+#endif
+
 static void set_stun_turn_cfg(struct ice_ept *ept, 
 				     pj_ice_strans_cfg *ice_cfg, 
@@ -788,45 +811,47 @@
 
 #if USE_IPV6
-    /* Test for IPV6. */
-    if (rc == PJ_SUCCESS) {
-	pj_bzero(&test_param, sizeof(test_param));
-	set_client_server_flag(SERVER_IPV6, CLIENT_IPV6, CLIENT_IPV6,
-			       &server_flag, &caller_cfg->client_flag,
-			       &callee_cfg->client_flag);
-
-	rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
-			   callee_cfg, &test_param);
-    }
-
-    /* Test for IPV4+IPV6. */
-    if (rc == PJ_SUCCESS) {
-	pj_bzero(&test_param, sizeof(test_param));
-	set_client_server_flag(SERVER_IPV4+SERVER_IPV6, 
-			       CLIENT_IPV4+CLIENT_IPV6,
-			       CLIENT_IPV4+CLIENT_IPV6, 
-			       &server_flag,
-			       &caller_cfg->client_flag, 
-			       &callee_cfg->client_flag);
-
-	rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
-			   callee_cfg, &test_param);
-    }
-
-    /* Test controller(IPV4) vs controlled(IPV6). */
-    if (rc == PJ_SUCCESS) {
-	pj_bzero(&test_param, sizeof(test_param));
-	set_client_server_flag(SERVER_IPV4+SERVER_IPV6, 
-			       CLIENT_IPV4,
-			       CLIENT_IPV6, 
-			       &server_flag,
-			       &caller_cfg->client_flag, 
-			       &callee_cfg->client_flag);
-	caller_cfg->expected.start_status = PJ_ENOTFOUND;
-	callee_cfg->expected.start_status = PJ_ENOTFOUND;
-
-	rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
-			   callee_cfg, &test_param);
-    }
-
+    if (enable_ipv6_test()) {
+
+	/* Test for IPV6. */
+	if (rc == PJ_SUCCESS) {
+	    pj_bzero(&test_param, sizeof(test_param));
+	    set_client_server_flag(SERVER_IPV6, CLIENT_IPV6, CLIENT_IPV6,
+				   &server_flag, &caller_cfg->client_flag,
+				   &callee_cfg->client_flag);
+
+	    rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
+			       callee_cfg, &test_param);
+	}
+
+	/* Test for IPV4+IPV6. */
+	if (rc == PJ_SUCCESS) {
+	    pj_bzero(&test_param, sizeof(test_param));
+	    set_client_server_flag(SERVER_IPV4+SERVER_IPV6,
+				   CLIENT_IPV4+CLIENT_IPV6,
+				   CLIENT_IPV4+CLIENT_IPV6,
+				   &server_flag,
+				   &caller_cfg->client_flag,
+				   &callee_cfg->client_flag);
+
+	    rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
+			       callee_cfg, &test_param);
+	}
+
+	/* Test controller(IPV4) vs controlled(IPV6). */
+	if (rc == PJ_SUCCESS) {
+	    pj_bzero(&test_param, sizeof(test_param));
+	    set_client_server_flag(SERVER_IPV4+SERVER_IPV6,
+				   CLIENT_IPV4,
+				   CLIENT_IPV6,
+				   &server_flag,
+				   &caller_cfg->client_flag,
+				   &callee_cfg->client_flag);
+	    caller_cfg->expected.start_status = PJ_ENOTFOUND;
+	    callee_cfg->expected.start_status = PJ_ENOTFOUND;
+
+	    rc = perform_test2(title, stun_cfg, server_flag, caller_cfg,
+			       callee_cfg, &test_param);
+	}
+    }
 #endif
     callee_cfg->expected.start_status = expected_callee_start_ice;
Index: /pjproject/trunk/pjnath/src/pjnath-test/server.c
===================================================================
--- /pjproject/trunk/pjnath/src/pjnath-test/server.c	(revision 5386)
+++ /pjproject/trunk/pjnath/src/pjnath-test/server.c	(revision 5387)
@@ -58,7 +58,15 @@
     PJ_ASSERT_RETURN(stun_cfg && domain && p_test_srv, PJ_EINVAL);
 
-    status = pj_gethostip(GET_AF(use_ipv6), &hostip);
-    if (status != PJ_SUCCESS)
-	return status;
+    if (use_ipv6) {
+	/* pj_gethostip() may return IPv6 link-local and will cause EINVAL
+	 * error, so let's just hardcode it.
+	 */
+	pj_sockaddr_init(pj_AF_INET6(), &hostip, NULL, 0);
+	hostip.ipv6.sin6_addr.s6_addr[15] = 1;
+    } else {
+	status = pj_gethostip(GET_AF(use_ipv6), &hostip);
+	if (status != PJ_SUCCESS)
+	    return status;
+    }
 
     pool = pj_pool_create(mem, THIS_FILE, 512, 512, NULL);
@@ -502,5 +510,19 @@
 	/* Create relay socket */	
 	pj_sockaddr_init(GET_AF(use_ipv6), &alloc->alloc_addr, NULL, 0);
-	pj_gethostip(GET_AF(use_ipv6), &alloc->alloc_addr);
+	if (use_ipv6) {
+	    /* pj_gethostip() may return IPv6 link-local and will cause EINVAL
+	     * error, so let's just hardcode it.
+	     */
+	    pj_sockaddr_init(pj_AF_INET6(), &alloc->alloc_addr, NULL, 0);
+	    alloc->alloc_addr.ipv6.sin6_addr.s6_addr[15] = 1;
+	} else {
+	    status = pj_gethostip(GET_AF(use_ipv6), &alloc->alloc_addr);
+	    if (status != PJ_SUCCESS) {
+		pj_pool_release(alloc->pool);
+		pj_stun_msg_create_response(pool, req, PJ_STUN_SC_SERVER_ERROR,
+					    NULL, &resp);
+		goto send_pkt;
+	    }
+	}
 
 	status = pj_activesock_create_udp(alloc->pool, &alloc->alloc_addr, NULL, 
