- Timestamp:
- Dec 11, 2015 4:59:56 AM (9 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/ssl_sock.h
r5087 r5214 865 865 866 866 /** 867 * Duplicate pj_ssl_sock_param. 868 * 869 * @param pool Pool to allocate memory. 870 * @param dst Destination parameter. 871 * @param src Source parameter. 872 */ 873 PJ_DECL(void) pj_ssl_sock_param_copy(pj_pool_t *pool, 874 pj_ssl_sock_param *dst, 875 const pj_ssl_sock_param *src); 876 877 878 /** 867 879 * Create secure socket instance. 868 880 * … … 1116 1128 1117 1129 /** 1130 * Same as #pj_ssl_sock_start_accept(), but application can provide 1131 * a secure socket parameter, which will be used to create a new secure 1132 * socket reported in \a on_accept_complete() callback when there is 1133 * an incoming connection. 1134 * 1135 * @param ssock The secure socket. 1136 * @param pool Pool used to allocate some internal data for the 1137 * operation. 1138 * @param localaddr Local address to bind on. 1139 * @param addr_len Length of buffer containing local address. 1140 * @param newsock_param Secure socket parameter for new accepted sockets. 1141 * 1142 * @return PJ_SUCCESS if the operation has been successful, 1143 * or the appropriate error code on failure. 1144 */ 1145 PJ_DECL(pj_status_t) 1146 pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock, 1147 pj_pool_t *pool, 1148 const pj_sockaddr_t *local_addr, 1149 int addr_len, 1150 const pj_ssl_sock_param *newsock_param); 1151 1152 1153 /** 1118 1154 * Starts asynchronous socket connect() operation and SSL/TLS handshaking 1119 1155 * for this socket. Once the connection is done (either successfully or not), -
pjproject/trunk/pjlib/src/pj/ssl_sock_common.c
r4860 r5214 20 20 #include <pj/assert.h> 21 21 #include <pj/errno.h> 22 #include <pj/pool.h> 22 23 #include <pj/string.h> 23 24 … … 46 47 /* Security config */ 47 48 param->proto = PJ_SSL_SOCK_PROTO_DEFAULT; 49 } 50 51 52 /* 53 * Duplicate SSL socket parameter. 54 */ 55 PJ_DEF(void) pj_ssl_sock_param_copy( pj_pool_t *pool, 56 pj_ssl_sock_param *dst, 57 const pj_ssl_sock_param *src) 58 { 59 /* Init secure socket param */ 60 pj_memcpy(dst, src, sizeof(*dst)); 61 if (src->ciphers_num > 0) { 62 unsigned i; 63 dst->ciphers = (pj_ssl_cipher*) 64 pj_pool_calloc(pool, src->ciphers_num, 65 sizeof(pj_ssl_cipher)); 66 for (i = 0; i < src->ciphers_num; ++i) 67 dst->ciphers[i] = src->ciphers[i]; 68 } 69 70 if (src->server_name.slen) { 71 /* Server name must be null-terminated */ 72 pj_strdup_with_null(pool, &dst->server_name, &src->server_name); 73 } 48 74 } 49 75 -
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5087 r5214 142 142 pj_ssl_sock_t *parent; 143 143 pj_ssl_sock_param param; 144 pj_ssl_sock_param newsock_param; 144 145 pj_ssl_cert_t *cert; 145 146 … … 1758 1759 pj_status_t status; 1759 1760 1760 PJ_UNUSED_ARG(src_addr_len);1761 1762 1761 /* Create new SSL socket instance */ 1763 status = pj_ssl_sock_create(ssock_parent->pool, &ssock_parent->param,1764 1762 status = pj_ssl_sock_create(ssock_parent->pool, 1763 &ssock_parent->newsock_param, &ssock); 1765 1764 if (status != PJ_SUCCESS) 1766 1765 goto on_return; … … 2184 2183 2185 2184 /* Init secure socket param */ 2186 ssock->param = *param;2185 pj_ssl_sock_param_copy(pool, &ssock->param, param); 2187 2186 ssock->param.read_buffer_size = ((ssock->param.read_buffer_size+7)>>3)<<3; 2188 if (param->ciphers_num > 0) {2189 unsigned i;2190 ssock->param.ciphers = (pj_ssl_cipher*)2191 pj_pool_calloc(pool, param->ciphers_num,2192 sizeof(pj_ssl_cipher));2193 for (i = 0; i < param->ciphers_num; ++i)2194 ssock->param.ciphers[i] = param->ciphers[i];2195 }2196 2197 /* Server name must be null-terminated */2198 pj_strdup_with_null(pool, &ssock->param.server_name,2199 ¶m->server_name);2200 2187 2201 2188 /* Finally */ … … 2618 2605 int addr_len) 2619 2606 { 2607 return pj_ssl_sock_start_accept2(ssock, pool, localaddr, addr_len, 2608 &ssock->param); 2609 } 2610 2611 2612 /** 2613 * Same as #pj_ssl_sock_start_accept(), but application provides parameter 2614 * for new accepted secure sockets. 2615 */ 2616 PJ_DEF(pj_status_t) 2617 pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock, 2618 pj_pool_t *pool, 2619 const pj_sockaddr_t *localaddr, 2620 int addr_len, 2621 const pj_ssl_sock_param *newsock_param) 2622 { 2620 2623 pj_activesock_cb asock_cb; 2621 2624 pj_activesock_cfg asock_cfg; … … 2623 2626 2624 2627 PJ_ASSERT_RETURN(ssock && pool && localaddr && addr_len, PJ_EINVAL); 2628 2629 /* Verify new socket parameters */ 2630 if (newsock_param->grp_lock != ssock->param.grp_lock || 2631 newsock_param->sock_af != ssock->param.sock_af || 2632 newsock_param->sock_type != ssock->param.sock_type) 2633 { 2634 return PJ_EINVAL; 2635 } 2625 2636 2626 2637 /* Create socket */ … … 2692 2703 2693 2704 /* Start accepting */ 2705 pj_ssl_sock_param_copy(pool, &ssock->newsock_param, newsock_param); 2694 2706 status = pj_activesock_start_accept(ssock->asock, pool); 2695 2707 if (status != PJ_SUCCESS) -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r5212 r5214 315 315 pj_uint32_t sip_ssl_proto; 316 316 struct tls_listener *listener; 317 pj_ssl_sock_param ssock_param ;317 pj_ssl_sock_param ssock_param, newsock_param; 318 318 pj_sockaddr *listener_addr; 319 319 pj_bool_t has_listener; … … 472 472 has_listener = PJ_FALSE; 473 473 474 status = pj_ssl_sock_start_accept(listener->ssock, pool, 474 pj_memcpy(&newsock_param, &ssock_param, sizeof(newsock_param)); 475 newsock_param.async_cnt = 1; 476 newsock_param.cb.on_data_read = &on_data_read; 477 newsock_param.cb.on_data_sent = &on_data_sent; 478 status = pj_ssl_sock_start_accept2(listener->ssock, pool, 475 479 (pj_sockaddr_t*)listener_addr, 476 pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr)); 480 pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr), 481 &newsock_param); 477 482 if (status == PJ_SUCCESS || status == PJ_EPENDING) { 478 483 pj_ssl_sock_info info;
Note: See TracChangeset
for help on using the changeset viewer.