Changeset 3000
- Timestamp:
- Nov 9, 2009 1:40:26 PM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r2998 r3000 2090 2090 status = pj_sock_getsockname(ssock->sock, &ssock->local_addr, 2091 2091 &ssock->addr_len); 2092 if (status != PJ_SUCCESS) 2093 pj_sockaddr_cp(&ssock->local_addr, localaddr); 2092 /* Note that we may not get an IP address here. This can 2093 * happen for example on Windows, where getsockname() 2094 * would return 0.0.0.0 if socket has just started the 2095 * async connect. In this case, just leave the local 2096 * address with 0.0.0.0 for now; it will be updated 2097 * once the socket is established. 2098 */ 2094 2099 2095 2100 /* Set remote address */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r2998 r3000 528 528 529 529 tls->base.addr_len = sizeof(pj_sockaddr_in); 530 pj_memcpy(&tls->base.local_addr, local, sizeof(pj_sockaddr_in)); 531 sockaddr_to_host_port(pool, &tls->base.local_name, local); 530 531 /* Set initial local address */ 532 if (!pj_sockaddr_has_addr(local)) { 533 pj_sockaddr_cp(&tls->base.local_addr, 534 &listener->factory.local_addr); 535 } else { 536 pj_sockaddr_cp(&tls->base.local_addr, local); 537 } 538 539 sockaddr_to_host_port(pool, &tls->base.local_name, 540 (pj_sockaddr_in*)&tls->base.local_addr); 532 541 sockaddr_to_host_port(pool, &tls->base.remote_name, remote); 533 542 … … 857 866 pj_ssl_sock_info info; 858 867 859 /* Update (again) local address, just in case local address currently860 * set isdifferent now that asynchronous connect() is started.868 /* Update local address, just in case local address currently set is 869 * different now that asynchronous connect() is started. 861 870 */ 862 871 … … 864 873 status = pj_ssl_sock_get_info(tls->ssock, &info); 865 874 if (status == PJ_SUCCESS) { 866 pj_sockaddr_in *tp_addr = (pj_sockaddr_in*)&tls->base.local_addr; 867 868 pj_assert(pj_sockaddr_get_len((pj_sockaddr_t*)&info.local_addr) <= 869 sizeof(local_addr)); 870 pj_sockaddr_cp((pj_sockaddr_t*)&local_addr, (pj_sockaddr_t*)&info.local_addr); 871 872 /* Some systems (like old Win32 perhaps) may not set local address 873 * properly before socket is fully connected. 874 */ 875 if (tp_addr->sin_addr.s_addr != local_addr.sin_addr.s_addr && 876 local_addr.sin_addr.s_addr != 0) 875 pj_uint16_t new_port; 876 877 new_port = pj_sockaddr_get_port((pj_sockaddr_t*)&info.local_addr); 878 879 if (pj_sockaddr_has_addr((pj_sockaddr_t*)&info.local_addr)) { 880 /* Update sockaddr */ 881 pj_sockaddr_cp((pj_sockaddr_t*)&tls->base.local_addr, 882 (pj_sockaddr_t*)&info.local_addr); 883 } else if (new_port && new_port != pj_sockaddr_get_port( 884 (pj_sockaddr_t*)&tls->base.local_addr)) 877 885 { 878 tp_addr->sin_addr.s_addr = local_addr.sin_addr.s_addr; 879 tp_addr->sin_port = local_addr.sin_port; 880 sockaddr_to_host_port(tls->base.pool, &tls->base.local_name, 881 &local_addr); 886 /* Update port only */ 887 pj_sockaddr_set_port((pj_sockaddr_t*)&tls->base.local_addr, 888 new_port); 882 889 } 890 891 sockaddr_to_host_port(tls->base.pool, &tls->base.local_name, 892 (pj_sockaddr_in*)&tls->base.local_addr); 883 893 } 884 894 885 895 PJ_LOG(4,(tls->base.obj_name, 886 896 "TLS transport %.*s:%d is connecting to %.*s:%d...",
Note: See TracChangeset
for help on using the changeset viewer.