Index: /pjproject/trunk/pjnath/src/pjnath/ice_session.c
===================================================================
--- /pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 4364)
+++ /pjproject/trunk/pjnath/src/pjnath/ice_session.c	(revision 4365)
@@ -719,4 +719,5 @@
     pj_ice_sess_cand *lcand;
     pj_status_t status = PJ_SUCCESS;
+    char address[PJ_INET6_ADDRSTRLEN];
 
     PJ_ASSERT_RETURN(ice && comp_id && 
@@ -738,11 +739,12 @@
     pj_strdup(ice->pool, &lcand->foundation, foundation);
     lcand->prio = CALC_CAND_PRIO(ice, type, local_pref, lcand->comp_id);
-    pj_memcpy(&lcand->addr, addr, addr_len);
-    pj_memcpy(&lcand->base_addr, base_addr, addr_len);
+    pj_sockaddr_cp(&lcand->addr, addr);
+    pj_sockaddr_cp(&lcand->base_addr, base_addr);
     if (rel_addr == NULL)
 	rel_addr = base_addr;
     pj_memcpy(&lcand->rel_addr, rel_addr, addr_len);
 
-    pj_ansi_strcpy(ice->tmp.txt, pj_inet_ntoa(lcand->addr.ipv4.sin_addr));
+    pj_ansi_strcpy(ice->tmp.txt, pj_sockaddr_print(&lcand->addr, address,
+                                                   sizeof(address), 0));
     LOG4((ice->obj_name, 
 	 "Candidate %d added: comp_id=%d, type=%s, foundation=%.*s, "
@@ -754,7 +756,7 @@
 	 lcand->foundation.ptr,
 	 ice->tmp.txt, 
-	 (int)pj_ntohs(lcand->addr.ipv4.sin_port),
-	 pj_inet_ntoa(lcand->base_addr.ipv4.sin_addr),
-	 (int)pj_htons(lcand->base_addr.ipv4.sin_port),
+	  pj_sockaddr_get_port(&lcand->addr),
+	  pj_sockaddr_print(&lcand->base_addr, address, sizeof(address), 0),
+	  pj_sockaddr_get_port(&lcand->base_addr),
 	 lcand->prio, lcand->prio));
 
@@ -893,23 +895,22 @@
     const pj_ice_sess_cand *lcand = check->lcand;
     const pj_ice_sess_cand *rcand = check->rcand;
-    char laddr[PJ_INET6_ADDRSTRLEN];
+    char laddr[PJ_INET6_ADDRSTRLEN], raddr[PJ_INET6_ADDRSTRLEN];
     int len;
 
     PJ_CHECK_STACK();
 
-    pj_ansi_strcpy(laddr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr));
-
-    if (lcand->addr.addr.sa_family == pj_AF_INET()) {
-	len = pj_ansi_snprintf(buffer, bufsize,
-			       "%d: [%d] %s:%d-->%s:%d",
-			       (int)GET_CHECK_ID(clist, check),
-			       check->lcand->comp_id,
-			       laddr, (int)pj_ntohs(lcand->addr.ipv4.sin_port),
-			       pj_inet_ntoa(rcand->addr.ipv4.sin_addr),
-			       (int)pj_ntohs(rcand->addr.ipv4.sin_port));
-    } else {
-	len = pj_ansi_snprintf(buffer, bufsize, "IPv6->IPv6");
-    }
-
+    pj_ansi_strcpy(laddr, pj_sockaddr_print(&lcand->addr, laddr,
+                                            sizeof(laddr), 0));
+
+    len = pj_ansi_snprintf(buffer, bufsize,
+			   "%d: [%d] %s:%d-->%s:%d",
+			   (int)GET_CHECK_ID(clist, check),
+			   check->lcand->comp_id,
+			   pj_sockaddr_print(&lcand->addr, laddr,
+			                     sizeof(laddr), 0),
+			   pj_sockaddr_get_port(&lcand->addr),
+			   pj_sockaddr_print(&rcand->addr, raddr,
+			                     sizeof(raddr), 0),
+			   pj_sockaddr_get_port(&rcand->addr));
 
     if (len < 0)
@@ -1015,30 +1016,4 @@
 }
 
-enum 
-{ 
-    SOCKADDR_EQUAL = 0, 
-    SOCKADDR_NOT_EQUAL = 1 
-};
-
-/* Utility: compare sockaddr.
- * Returns 0 if equal.
- */
-static int sockaddr_cmp(const pj_sockaddr *a1, const pj_sockaddr *a2)
-{
-    if (a1->addr.sa_family != a2->addr.sa_family)
-	return SOCKADDR_NOT_EQUAL;
-
-    if (a1->addr.sa_family == pj_AF_INET()) {
-	return !(a1->ipv4.sin_addr.s_addr == a2->ipv4.sin_addr.s_addr &&
-		 a1->ipv4.sin_port == a2->ipv4.sin_port);
-    } else if (a1->addr.sa_family == pj_AF_INET6()) {
-	return pj_memcmp(&a1->ipv6, &a2->ipv6, sizeof(a1->ipv6));
-    } else {
-	pj_assert(!"Invalid address family!");
-	return SOCKADDR_NOT_EQUAL;
-    }
-}
-
-
 /* Prune checklist, this must have been done after the checklist
  * is sorted.
@@ -1072,5 +1047,5 @@
 		    continue;
 
-		if (sockaddr_cmp(&srflx->base_addr, &host->addr) == 0) {
+		if (pj_sockaddr_cmp(&srflx->base_addr, &host->addr) == 0) {
 		    /* Replace this SRFLX with its BASE */
 		    clist->checks[i].lcand = host;
@@ -1080,9 +1055,11 @@
 
 	    if (j==ice->lcand_cnt) {
+		char baddr[PJ_INET6_ADDRSTRLEN];
 		/* Host candidate not found this this srflx! */
 		LOG4((ice->obj_name, 
 		      "Base candidate %s:%d not found for srflx candidate %d",
-		      pj_inet_ntoa(srflx->base_addr.ipv4.sin_addr),
-		      pj_ntohs(srflx->base_addr.ipv4.sin_port),
+		      pj_sockaddr_print(&srflx->base_addr, baddr,
+		                        sizeof(baddr), 0),
+		      pj_sockaddr_get_port(&srflx->base_addr),
 		      GET_LCAND_ID(clist->checks[i].lcand)));
 		return PJNATH_EICENOHOSTCAND;
@@ -1112,5 +1089,5 @@
 		reason = "duplicate found";
 	    } else if ((rjcand == ricand) &&
-		       (sockaddr_cmp(&ljcand->base_addr, 
+		       (pj_sockaddr_cmp(&ljcand->base_addr, 
 				     &licand->base_addr)==0)) 
 	    {
@@ -1840,5 +1817,6 @@
     status = pj_stun_session_send_msg(comp->stun_sess, msg_data, PJ_FALSE, 
 				      PJ_TRUE, &rcand->addr, 
-				      sizeof(pj_sockaddr_in), check->tdata);
+				      pj_sockaddr_get_len(&rcand->addr),
+				      check->tdata);
     if (status != PJ_SUCCESS) {
 	check->tdata = NULL;
@@ -2293,5 +2271,6 @@
      * Request was sent from.
      */
-    if (sockaddr_cmp(&check->rcand->addr, (const pj_sockaddr*)src_addr) != 0) {
+    if (pj_sockaddr_cmp(&check->rcand->addr, (const pj_sockaddr*)src_addr)!=0)
+    {
 	status = PJNATH_EICEINSRCADDR;
 	LOG4((ice->obj_name, 
@@ -2344,5 +2323,5 @@
     pj_assert(lcand == NULL);
     for (i=0; i<ice->lcand_cnt; ++i) {
-	if (sockaddr_cmp(&xaddr->sockaddr, &ice->lcand[i].addr) == 0) {
+	if (pj_sockaddr_cmp(&xaddr->sockaddr, &ice->lcand[i].addr) == 0) {
 	    /* Match */
 	    lcand = &ice->lcand[i];
@@ -2380,5 +2359,6 @@
 				      &check->lcand->base_addr, 
 				      &check->lcand->base_addr,
-				      sizeof(pj_sockaddr_in), &cand_id);
+				      pj_sockaddr_get_len(&xaddr->sockaddr),
+				      &cand_id);
 	if (status != PJ_SUCCESS) {
 	    check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, 
@@ -2619,5 +2599,5 @@
     rcheck->transport_id = ((pj_ice_msg_data*)token)->transport_id;
     rcheck->src_addr_len = src_addr_len;
-    pj_memcpy(&rcheck->src_addr, src_addr, src_addr_len);
+    pj_sockaddr_cp(&rcheck->src_addr, src_addr);
     rcheck->use_candidate = (uc_attr != NULL);
     rcheck->priority = prio_attr->value;
@@ -2657,5 +2637,5 @@
      */
     for (i=0; i<ice->rcand_cnt; ++i) {
-	if (sockaddr_cmp(&rcheck->src_addr, &ice->rcand[i].addr)==0)
+	if (pj_sockaddr_cmp(&rcheck->src_addr, &ice->rcand[i].addr)==0)
 	    break;
     }
@@ -2667,4 +2647,5 @@
      */
     if (i == ice->rcand_cnt) {
+	char raddr[PJ_INET6_ADDRSTRLEN];
 	if (ice->rcand_cnt >= PJ_ICE_MAX_CAND) {
 	    LOG4((ice->obj_name, 
@@ -2678,5 +2659,5 @@
 	rcand->type = PJ_ICE_CAND_TYPE_PRFLX;
 	rcand->prio = rcheck->priority;
-	pj_memcpy(&rcand->addr, &rcheck->src_addr, rcheck->src_addr_len);
+	pj_sockaddr_cp(&rcand->addr, &rcheck->src_addr);
 
 	/* Foundation is random, unique from other foundation */
@@ -2687,7 +2668,7 @@
 
 	LOG4((ice->obj_name, 
-	     "Added new remote candidate from the request: %s:%d",
-	     pj_inet_ntoa(rcand->addr.ipv4.sin_addr),
-	     (int)pj_ntohs(rcand->addr.ipv4.sin_port)));
+	      "Added new remote candidate from the request: %s:%d",
+	      pj_sockaddr_print(&rcand->addr, raddr, sizeof(raddr), 0),
+	      pj_sockaddr_get_port(&rcand->addr)));
 
     } else {
@@ -2706,5 +2687,5 @@
 	pj_ice_sess_check *c = &ice->clist.checks[i];
 	if (/*c->lcand == lcand ||*/
-	    sockaddr_cmp(&c->lcand->base_addr, &lcand->base_addr)==0)
+	    pj_sockaddr_cmp(&c->lcand->base_addr, &lcand->base_addr)==0)
 	{
 	    lcand = c->lcand;
@@ -2955,5 +2936,5 @@
 				  data, data_len, 
 				  &addr, 
-				  sizeof(pj_sockaddr_in));
+				  pj_sockaddr_get_len(&addr));
 
 on_return:
Index: /pjproject/trunk/pjnath/src/pjnath/ice_strans.c
===================================================================
--- /pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 4364)
+++ /pjproject/trunk/pjnath/src/pjnath/ice_strans.c	(revision 4365)
@@ -1321,4 +1321,5 @@
     pj_ice_strans_comp *comp;
     pj_status_t status;
+    char daddr[PJ_INET6_ADDRSTRLEN];
 
     PJ_ASSERT_RETURN(comp_id && comp_id <= ice_st->comp_cnt, PJ_EINVAL);
@@ -1327,9 +1328,9 @@
 
     TRACE_PKT((comp->ice_st->obj_name, 
-	      "Component %d TX packet to %s:%d with transport %d",
-	      comp_id, 
-	      pj_inet_ntoa(((pj_sockaddr_in*)dst_addr)->sin_addr),
-	      (int)pj_ntohs(((pj_sockaddr_in*)dst_addr)->sin_port),
-	      transport_id));
+	       "Component %d TX packet to %s:%d with transport %d",
+	       comp_id, 
+	       pj_sockaddr_print(dst_addr, daddr, sizeof(addr), 0),
+	       pj_sockaddr_get_port(dst_addr),
+	       transport_id));
 
     if (transport_id == TP_TURN) {
