[asterisk-scf-commits] asterisk-scf/release/pjproject.git branch "veesix" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Nov 30 15:57:19 CST 2010


branch "veesix" has been updated
       via  377d617d20552414f9486593cee723c1781e7449 (commit)
      from  48aabcc9c79d5c33ae31c3fdc5880a85e5568e18 (commit)

Summary of changes:
 pjsip/src/pjsip/sip_transport_tcp.c |   15 +++++++--------
 pjsip/src/test/transport_tcp_test.c |    8 +++-----
 pjsip/src/test/transport_test.c     |    3 ++-
 3 files changed, 12 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit 377d617d20552414f9486593cee723c1781e7449
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Nov 30 16:00:00 2010 -0600

    Fixes to make the TCP tests pass.
    
    Here are the major points:
    1) Be sure to correctly use PJSIP_TRANSPORT_TCP and
       PJSIP_TRANSPORT_TCP6.
    2) Don't include square brackets in the host name. This
       helps multiple calls to pj_inet_pton and pj_getaddrinfo
       to succeed.
    3) Correct transport_test to not fail when an IPv6 transport
       is used.

diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c
index 1181f7f..35348a7 100644
--- a/pjsip/src/pjsip/sip_transport_tcp.c
+++ b/pjsip/src/pjsip/sip_transport_tcp.c
@@ -161,7 +161,7 @@ static void sockaddr_to_host_port( pj_pool_t *pool,
 				   const pj_sockaddr *addr )
 {
     host_port->host.ptr = (char*) pj_pool_alloc(pool, PJ_INET6_ADDRSTRLEN+4);
-    pj_sockaddr_print(addr, host_port->host.ptr, PJ_INET6_ADDRSTRLEN+4, 2);
+    pj_sockaddr_print(addr, host_port->host.ptr, PJ_INET6_ADDRSTRLEN+4, 0);
     host_port->host.slen = pj_ansi_strlen(host_port->host.ptr);
     host_port->port = pj_sockaddr_get_port(addr);
 }
@@ -266,10 +266,10 @@ PJ_DEF(pj_status_t) pjsip_tcp_transport_start3(
 
     listener = PJ_POOL_ZALLOC_T(pool, struct tcp_listener);
     listener->factory.pool = pool;
-    listener->factory.type = PJSIP_TRANSPORT_TCP;
+    listener->factory.type = cfg->af == pj_AF_INET6() ? PJSIP_TRANSPORT_TCP6 : PJSIP_TRANSPORT_TCP;
     listener->factory.type_name = "tcp";
     listener->factory.flag = 
-	pjsip_transport_get_flag_from_type(PJSIP_TRANSPORT_TCP);
+	pjsip_transport_get_flag_from_type(listener->factory.type);
     listener->qos_type = cfg->qos_type;
     pj_memcpy(&listener->qos_params, &cfg->qos_params,
 	      sizeof(cfg->qos_params));
@@ -581,15 +581,14 @@ static pj_status_t tcp_create( struct tcp_listener *listener,
 	goto on_error;
     }
 
-    tcp->base.key.type = PJSIP_TRANSPORT_TCP;
+    tcp->base.key.type = local->addr.sa_family == pj_AF_INET6() ? PJSIP_TRANSPORT_TCP6 : PJSIP_TRANSPORT_TCP;
     pj_memcpy(&tcp->base.key.rem_addr, remote, pj_sockaddr_get_len(remote));
     tcp->base.type_name = "tcp";
-    tcp->base.flag = pjsip_transport_get_flag_from_type(PJSIP_TRANSPORT_TCP);
+    tcp->base.flag = pjsip_transport_get_flag_from_type(tcp->base.key.type);
 
     tcp->base.info = (char*) pj_pool_alloc(pool, 64);
-    pj_ansi_snprintf(tcp->base.info, 64, "TCP to %s:%d",
-                     pj_inet_ntop2(remote->addr.sa_family, pj_sockaddr_get_addr(remote), remote_addr_str, sizeof(remote_addr_str)),
-                     (int)pj_sockaddr_get_port(remote));
+    pj_ansi_snprintf(tcp->base.info, 64, "TCP to %s", 
+                     pj_sockaddr_print(remote, remote_addr_str, sizeof(remote_addr_str), 1 | 2));
 
     tcp->base.addr_len = pj_sockaddr_get_len(local);
     pj_memcpy(&tcp->base.local_addr, local, pj_sockaddr_get_len(local));
diff --git a/pjsip/src/test/transport_tcp_test.c b/pjsip/src/test/transport_tcp_test.c
index 16844a8..2a814bb 100644
--- a/pjsip/src/test/transport_tcp_test.c
+++ b/pjsip/src/test/transport_tcp_test.c
@@ -56,13 +56,11 @@ int transport_tcp_test(void)
 	return -14;
     }
 
-    pj_ansi_sprintf(url, "sip:alice@%s:%d;transport=tcp",
-		    pj_inet_ntop2(rem_addr.addr.sa_family, &rem_addr, rem_addr_str, sizeof(rem_addr_str)),
-		    pj_sockaddr_get_port(&rem_addr));
-
+    pj_ansi_sprintf(url, "sip:alice@%s;transport=tcp",
+            pj_sockaddr_print(&rem_addr, rem_addr_str, sizeof(rem_addr_str), 1 | 2));
 
     /* Acquire one TCP transport. */
-    status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP, 
+    status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP6, 
 					   &rem_addr, pj_sockaddr_get_len(&rem_addr),
 					   NULL, &tcp);
     if (status != PJ_SUCCESS || tcp == NULL) {
diff --git a/pjsip/src/test/transport_test.c b/pjsip/src/test/transport_test.c
index b5fd9ba..72f9249 100644
--- a/pjsip/src/test/transport_test.c
+++ b/pjsip/src/test/transport_test.c
@@ -56,7 +56,8 @@ int generic_transport_test(pjsip_transport *tp)
     }
 
     /* Check length of address (for now we only check against sockaddr_in). */
-    if (tp->addr_len != sizeof(pj_sockaddr_in))
+    if ((tp->local_addr.addr.sa_family == pj_AF_INET() && tp->addr_len != sizeof(pj_sockaddr_in)) ||
+            (tp->local_addr.addr.sa_family == pj_AF_INET6() && tp->addr_len != sizeof(pj_sockaddr_in6)))
 	return -440;
 
     /* Check type. */

-----------------------------------------------------------------------


-- 
asterisk-scf/release/pjproject.git



More information about the asterisk-scf-commits mailing list