diff options
Diffstat (limited to 'third-party/pjproject/patches')
6 files changed, 524 insertions, 0 deletions
diff --git a/third-party/pjproject/patches/0001-2.4.5-fix-for-tls-async-ops.patch b/third-party/pjproject/patches/0001-2.4.5-fix-for-tls-async-ops.patch new file mode 100644 index 000000000..33fc8ea4e --- /dev/null +++ b/third-party/pjproject/patches/0001-2.4.5-fix-for-tls-async-ops.patch @@ -0,0 +1,224 @@ +diff --git a/pjlib/include/pj/ssl_sock.h b/pjlib/include/pj/ssl_sock.h +index 1682bda..a69af32 100644 +--- a/pjlib/include/pj/ssl_sock.h ++++ b/pjlib/include/pj/ssl_sock.h +@@ -864,6 +864,18 @@ PJ_DECL(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param); + + + /** ++ * Duplicate pj_ssl_sock_param. ++ * ++ * @param pool Pool to allocate memory. ++ * @param dst Destination parameter. ++ * @param src Source parameter. ++ */ ++PJ_DECL(void) pj_ssl_sock_param_copy(pj_pool_t *pool, ++ pj_ssl_sock_param *dst, ++ const pj_ssl_sock_param *src); ++ ++ ++/** + * Create secure socket instance. + * + * @param pool The pool for allocating secure socket instance. +@@ -1115,6 +1127,30 @@ PJ_DECL(pj_status_t) pj_ssl_sock_start_accept(pj_ssl_sock_t *ssock, + + + /** ++ * Same as #pj_ssl_sock_start_accept(), but application can provide ++ * a secure socket parameter, which will be used to create a new secure ++ * socket reported in \a on_accept_complete() callback when there is ++ * an incoming connection. ++ * ++ * @param ssock The secure socket. ++ * @param pool Pool used to allocate some internal data for the ++ * operation. ++ * @param localaddr Local address to bind on. ++ * @param addr_len Length of buffer containing local address. ++ * @param newsock_param Secure socket parameter for new accepted sockets. ++ * ++ * @return PJ_SUCCESS if the operation has been successful, ++ * or the appropriate error code on failure. ++ */ ++PJ_DECL(pj_status_t) ++pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock, ++ pj_pool_t *pool, ++ const pj_sockaddr_t *local_addr, ++ int addr_len, ++ const pj_ssl_sock_param *newsock_param); ++ ++ ++/** + * Starts asynchronous socket connect() operation and SSL/TLS handshaking + * for this socket. Once the connection is done (either successfully or not), + * the \a on_connect_complete() callback will be called. +diff --git a/pjlib/src/pj/ssl_sock_common.c b/pjlib/src/pj/ssl_sock_common.c +index 913efee..717ab1d 100644 +--- a/pjlib/src/pj/ssl_sock_common.c ++++ b/pjlib/src/pj/ssl_sock_common.c +@@ -19,6 +19,7 @@ + #include <pj/ssl_sock.h> + #include <pj/assert.h> + #include <pj/errno.h> ++#include <pj/pool.h> + #include <pj/string.h> + + /* +@@ -48,6 +49,31 @@ PJ_DEF(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param) + } + + ++/* ++ * Duplicate SSL socket parameter. ++ */ ++PJ_DEF(void) pj_ssl_sock_param_copy( pj_pool_t *pool, ++ pj_ssl_sock_param *dst, ++ const pj_ssl_sock_param *src) ++{ ++ /* Init secure socket param */ ++ pj_memcpy(dst, src, sizeof(*dst)); ++ if (src->ciphers_num > 0) { ++ unsigned i; ++ dst->ciphers = (pj_ssl_cipher*) ++ pj_pool_calloc(pool, src->ciphers_num, ++ sizeof(pj_ssl_cipher)); ++ for (i = 0; i < src->ciphers_num; ++i) ++ dst->ciphers[i] = src->ciphers[i]; ++ } ++ ++ if (src->server_name.slen) { ++ /* Server name must be null-terminated */ ++ pj_strdup_with_null(pool, &dst->server_name, &src->server_name); ++ } ++} ++ ++ + PJ_DEF(pj_status_t) pj_ssl_cert_get_verify_status_strings( + pj_uint32_t verify_status, + const char *error_strings[], +diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c +index 40a5a1e..6a701b7 100644 +--- a/pjlib/src/pj/ssl_sock_ossl.c ++++ b/pjlib/src/pj/ssl_sock_ossl.c +@@ -141,6 +141,7 @@ struct pj_ssl_sock_t + pj_pool_t *pool; + pj_ssl_sock_t *parent; + pj_ssl_sock_param param; ++ pj_ssl_sock_param newsock_param; + pj_ssl_cert_t *cert; + + pj_ssl_cert_info local_cert_info; +@@ -1757,11 +1758,9 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock, + unsigned i; + pj_status_t status; + +- PJ_UNUSED_ARG(src_addr_len); +- + /* Create new SSL socket instance */ +- status = pj_ssl_sock_create(ssock_parent->pool, &ssock_parent->param, +- &ssock); ++ status = pj_ssl_sock_create(ssock_parent->pool, ++ &ssock_parent->newsock_param, &ssock); + if (status != PJ_SUCCESS) + goto on_return; + +@@ -2183,20 +2182,8 @@ PJ_DEF(pj_status_t) pj_ssl_sock_create (pj_pool_t *pool, + return status; + + /* Init secure socket param */ +- ssock->param = *param; ++ pj_ssl_sock_param_copy(pool, &ssock->param, param); + ssock->param.read_buffer_size = ((ssock->param.read_buffer_size+7)>>3)<<3; +- if (param->ciphers_num > 0) { +- unsigned i; +- ssock->param.ciphers = (pj_ssl_cipher*) +- pj_pool_calloc(pool, param->ciphers_num, +- sizeof(pj_ssl_cipher)); +- for (i = 0; i < param->ciphers_num; ++i) +- ssock->param.ciphers[i] = param->ciphers[i]; +- } +- +- /* Server name must be null-terminated */ +- pj_strdup_with_null(pool, &ssock->param.server_name, +- ¶m->server_name); + + /* Finally */ + *p_ssock = ssock; +@@ -2617,12 +2604,36 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_accept (pj_ssl_sock_t *ssock, + const pj_sockaddr_t *localaddr, + int addr_len) + { ++ return pj_ssl_sock_start_accept2(ssock, pool, localaddr, addr_len, ++ &ssock->param); ++} ++ ++ ++/** ++ * Same as #pj_ssl_sock_start_accept(), but application provides parameter ++ * for new accepted secure sockets. ++ */ ++PJ_DEF(pj_status_t) ++pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock, ++ pj_pool_t *pool, ++ const pj_sockaddr_t *localaddr, ++ int addr_len, ++ const pj_ssl_sock_param *newsock_param) ++{ + pj_activesock_cb asock_cb; + pj_activesock_cfg asock_cfg; + pj_status_t status; + + PJ_ASSERT_RETURN(ssock && pool && localaddr && addr_len, PJ_EINVAL); + ++ /* Verify new socket parameters */ ++ if (newsock_param->grp_lock != ssock->param.grp_lock || ++ newsock_param->sock_af != ssock->param.sock_af || ++ newsock_param->sock_type != ssock->param.sock_type) ++ { ++ return PJ_EINVAL; ++ } ++ + /* Create socket */ + status = pj_sock_socket(ssock->param.sock_af, ssock->param.sock_type, 0, + &ssock->sock); +@@ -2691,6 +2702,7 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_accept (pj_ssl_sock_t *ssock, + goto on_error; + + /* Start accepting */ ++ pj_ssl_sock_param_copy(pool, &ssock->newsock_param, newsock_param); + status = pj_activesock_start_accept(ssock->asock, pool); + if (status != PJ_SUCCESS) + goto on_error; +diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c +index a9e95fb..91d99a7 100644 +--- a/pjsip/src/pjsip/sip_transport_tls.c ++++ b/pjsip/src/pjsip/sip_transport_tls.c +@@ -314,7 +314,7 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_start2( pjsip_endpoint *endpt, + int af, sip_ssl_method; + pj_uint32_t sip_ssl_proto; + struct tls_listener *listener; +- pj_ssl_sock_param ssock_param; ++ pj_ssl_sock_param ssock_param, newsock_param; + pj_sockaddr *listener_addr; + pj_bool_t has_listener; + pj_status_t status; +@@ -473,9 +473,14 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_start2( pjsip_endpoint *endpt, + */ + has_listener = PJ_FALSE; + +- status = pj_ssl_sock_start_accept(listener->ssock, pool, ++ pj_memcpy(&newsock_param, &ssock_param, sizeof(newsock_param)); ++ newsock_param.async_cnt = 1; ++ newsock_param.cb.on_data_read = &on_data_read; ++ newsock_param.cb.on_data_sent = &on_data_sent; ++ status = pj_ssl_sock_start_accept2(listener->ssock, pool, + (pj_sockaddr_t*)listener_addr, +- pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr)); ++ pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr), ++ &newsock_param); + if (status == PJ_SUCCESS || status == PJ_EPENDING) { + pj_ssl_sock_info info; + has_listener = PJ_TRUE; +-- +cgit v0.11.2 + diff --git a/third-party/pjproject/patches/0001-Bump-tcp-tls-and-transaction-log-levels-from-1-to-3.patch b/third-party/pjproject/patches/0001-Bump-tcp-tls-and-transaction-log-levels-from-1-to-3.patch new file mode 100644 index 000000000..9873abf0e --- /dev/null +++ b/third-party/pjproject/patches/0001-Bump-tcp-tls-and-transaction-log-levels-from-1-to-3.patch @@ -0,0 +1,70 @@ +From a147b72df1ec150c1d733e882225db86142fb339 Mon Sep 17 00:00:00 2001 +From: George Joseph <george.joseph@fairview5.com> +Date: Sun, 21 Feb 2016 10:01:53 -0700 +Subject: [PATCH] Bump tcp/tls and transaction log levels from 1 to 3 + +sip_transport_tcp, sip_transport_tls and sip_transaction are printing messages +at log level 1 or 2 for things that are transient, recoverable, possibly +expected, or are handled with return codes. A good example of this is if we're +trying to send an OPTIONS message to a TCP client that has disappeared. Both +sip_transport_tcp and sip_transaction are printing "connection refused" +messages because the remote client isn't listening. This is generally expected +behavior and it should be up to the app caller to determine if an error message +is warranted. +--- + pjsip/src/pjsip/sip_transaction.c | 4 ++-- + pjsip/src/pjsip/sip_transport_tcp.c | 2 +- + pjsip/src/pjsip/sip_transport_tls.c | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c +index 46bd971..1b4fdb7 100644 +--- a/pjsip/src/pjsip/sip_transaction.c ++++ b/pjsip/src/pjsip/sip_transaction.c +@@ -1898,7 +1898,7 @@ static void send_msg_callback( pjsip_send_state *send_state, + + err =pj_strerror((pj_status_t)-sent, errmsg, sizeof(errmsg)); + +- PJ_LOG(2,(tsx->obj_name, ++ PJ_LOG(3,(tsx->obj_name, + "Failed to send %s! err=%d (%s)", + pjsip_tx_data_get_info(send_state->tdata), -sent, + errmsg)); +@@ -1938,7 +1938,7 @@ static void send_msg_callback( pjsip_send_state *send_state, + } + + } else { +- PJ_PERROR(2,(tsx->obj_name, (pj_status_t)-sent, ++ PJ_PERROR(3,(tsx->obj_name, (pj_status_t)-sent, + "Temporary failure in sending %s, " + "will try next server", + pjsip_tx_data_get_info(send_state->tdata))); +diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c +index 222cb13..1bbb324 100644 +--- a/pjsip/src/pjsip/sip_transport_tcp.c ++++ b/pjsip/src/pjsip/sip_transport_tcp.c +@@ -164,7 +164,7 @@ static void tcp_perror(const char *sender, const char *title, + + pj_strerror(status, errmsg, sizeof(errmsg)); + +- PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status)); ++ PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status)); + } + + +diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c +index 617d7f5..a83ac32 100644 +--- a/pjsip/src/pjsip/sip_transport_tls.c ++++ b/pjsip/src/pjsip/sip_transport_tls.c +@@ -170,7 +170,7 @@ static void tls_perror(const char *sender, const char *title, + + pj_strerror(status, errmsg, sizeof(errmsg)); + +- PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status)); ++ PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status)); + } + + +-- +2.5.0 + diff --git a/third-party/pjproject/patches/0001-ioqueue-Enable-epoll-in-aconfigure.ac.patch b/third-party/pjproject/patches/0001-ioqueue-Enable-epoll-in-aconfigure.ac.patch new file mode 100644 index 000000000..36b6c651f --- /dev/null +++ b/third-party/pjproject/patches/0001-ioqueue-Enable-epoll-in-aconfigure.ac.patch @@ -0,0 +1,80 @@ +From b5c0bc905911f75e08987e6833075481fe16dab2 Mon Sep 17 00:00:00 2001 +From: George Joseph <george.joseph@fairview5.com> +Date: Mon, 22 Feb 2016 13:05:59 -0700 +Subject: [PATCH] ioqueue: Enable epoll in aconfigure.ac + +Although the --enable-epoll option was being accepted, the result +was always forced to select. This patch updates aconfigure.ac +to properly set the value of ac_linux_poll if --enable-epoll is +specified. +--- + README.txt | 1 + + aconfigure | 11 +++++++---- + aconfigure.ac | 7 +++++-- + pjlib/include/pj/compat/os_auto.h.in | 3 +++ + 4 files changed, 16 insertions(+), 6 deletions(-) + +diff --git a/README.txt b/README.txt +index bc45da8..48415fd 100644 +--- a/README.txt ++++ b/README.txt +@@ -463,6 +463,7 @@ Using Default Settings + $ ./configure --help + ... + Optional Features: ++ --enable-epoll Use epoll on Linux instead of select + --disable-floating-point Disable floating point where possible + --disable-sound Exclude sound (i.e. use null sound) + --disable-small-filter Exclude small filter in resampling +diff --git a/aconfigure.ac b/aconfigure.ac +index 2f71abb..3e88124 100644 +--- a/aconfigure.ac ++++ b/aconfigure.ac +@@ -410,6 +410,7 @@ dnl ###################### + dnl # ioqueue selection + dnl # + AC_SUBST(ac_os_objs) ++AC_SUBST(ac_linux_poll) + AC_MSG_CHECKING([ioqueue backend]) + AC_ARG_ENABLE(epoll, + AC_HELP_STRING([--enable-epoll], +@@ -417,10 +418,13 @@ AC_ARG_ENABLE(epoll, + [ + ac_os_objs=ioqueue_epoll.o + AC_MSG_RESULT([/dev/epoll]) ++ AC_DEFINE(PJ_HAS_LINUX_EPOLL,1) ++ ac_linux_poll=epoll + ], + [ + ac_os_objs=ioqueue_select.o +- AC_MSG_RESULT([select()]) ++ AC_MSG_RESULT([select()]) ++ ac_linux_poll=select + ]) + + AC_SUBST(ac_shared_libraries) +@@ -1879,7 +1883,6 @@ esac + + + AC_SUBST(target) +-AC_SUBST(ac_linux_poll,select) + AC_SUBST(ac_host,unix) + AC_SUBST(ac_main_obj) + case $target in +diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in +index 77980d3..c8e73b2 100644 +--- a/pjlib/include/pj/compat/os_auto.h.in ++++ b/pjlib/include/pj/compat/os_auto.h.in +@@ -128,6 +128,9 @@ + */ + #undef PJ_SELECT_NEEDS_NFDS + ++/* Was Linux epoll support enabled */ ++#undef PJ_HAS_LINUX_EPOLL ++ + /* Is errno a good way to retrieve OS errors? + */ + #undef PJ_HAS_ERRNO_VAR +-- +2.5.0 + diff --git a/third-party/pjproject/patches/0001-sip_transport-Search-for-transport-even-if-listener-.patch b/third-party/pjproject/patches/0001-sip_transport-Search-for-transport-even-if-listener-.patch new file mode 100644 index 000000000..001912cfe --- /dev/null +++ b/third-party/pjproject/patches/0001-sip_transport-Search-for-transport-even-if-listener-.patch @@ -0,0 +1,114 @@ +From 552194179eb6deae8326eb0fef446e69240ea41b Mon Sep 17 00:00:00 2001 +From: George Joseph <george.joseph@fairview5.com> +Date: Fri, 19 Feb 2016 17:05:53 -0700 +Subject: [PATCH] sip_transport: Search for transport even if listener was + specified. + +If a listener was specified when calling pjsip_tpmgr_acquire_transport2, +a new transport was always created instead of using an existing one. This +caused several issues mostly related to the remote end not expecting a new +connection. I.E. A TCP client who registered to a server is not going to +be listening for connections coming back from the server and refuses the +connection. + +Now when pjsip_tpmgr_acquire_transport2 is called with a listener, the +registry is still searched for an existing transport and the listener +is used as a factory only if no existing transport can be found. +--- + pjsip/src/pjsip/sip_transport.c | 68 ++++++++++++++++++++--------------------- + 1 file changed, 34 insertions(+), 34 deletions(-) + +diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c +index 0410324..620b9c0 100644 +--- a/pjsip/src/pjsip/sip_transport.c ++++ b/pjsip/src/pjsip/sip_transport.c +@@ -1999,29 +1999,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr, + + TRACE_((THIS_FILE, "Transport %s acquired", seltp->obj_name)); + return PJ_SUCCESS; +- +- +- } else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && +- sel->u.listener) +- { +- /* Application has requested that a specific listener is to +- * be used. In this case, skip transport hash table lookup. +- */ +- +- /* Verify that the listener type matches the destination type */ +- if (sel->u.listener->type != type) { +- pj_lock_release(mgr->lock); +- return PJSIP_ETPNOTSUITABLE; +- } +- +- /* We'll use this listener to create transport */ +- factory = sel->u.listener; +- + } else { + + /* + * This is the "normal" flow, where application doesn't specify +- * specific transport/listener to be used to send message to. ++ * specific transport to be used to send message to. + * In this case, lookup the transport from the hash table. + */ + pjsip_transport_key key; +@@ -2081,22 +2063,40 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr, + return PJ_SUCCESS; + } + +- /* +- * Transport not found! +- * Find factory that can create such transport. +- */ +- factory = mgr->factory_list.next; +- while (factory != &mgr->factory_list) { +- if (factory->type == type) +- break; +- factory = factory->next; +- } ++ if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && ++ sel->u.listener) ++ { ++ /* Application has requested that a specific listener is to ++ * be used. ++ */ ++ ++ /* Verify that the listener type matches the destination type */ ++ if (sel->u.listener->type != type) { ++ pj_lock_release(mgr->lock); ++ return PJSIP_ETPNOTSUITABLE; ++ } + +- if (factory == &mgr->factory_list) { +- /* No factory can create the transport! */ +- pj_lock_release(mgr->lock); +- TRACE_((THIS_FILE, "No suitable factory was found either")); +- return PJSIP_EUNSUPTRANSPORT; ++ /* We'll use this listener to create transport */ ++ factory = sel->u.listener; ++ ++ } else { ++ /* ++ * Transport not found! ++ * Find factory that can create such transport. ++ */ ++ factory = mgr->factory_list.next; ++ while (factory != &mgr->factory_list) { ++ if (factory->type == type) ++ break; ++ factory = factory->next; ++ } ++ ++ if (factory == &mgr->factory_list) { ++ /* No factory can create the transport! */ ++ pj_lock_release(mgr->lock); ++ TRACE_((THIS_FILE, "No suitable factory was found either")); ++ return PJSIP_EUNSUPTRANSPORT; ++ } + } + } + +-- +2.5.0 + diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h new file mode 100644 index 000000000..544c1e85e --- /dev/null +++ b/third-party/pjproject/patches/config_site.h @@ -0,0 +1,34 @@ +/* + * Asterisk config_site.h + */ + +#include <sys/select.h> + +#define PJ_HAS_IPV6 1 +#define NDEBUG 1 +#define PJ_MAX_HOSTNAME (256) +#define PJSIP_MAX_URL_SIZE (512) +#ifdef PJ_HAS_LINUX_EPOLL +#define PJ_IOQUEUE_MAX_HANDLES (5000) +#else +#define PJ_IOQUEUE_MAX_HANDLES (FD_SETSIZE) +#endif +#define PJ_IOQUEUE_HAS_SAFE_UNREG 1 +#define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL (16) + +#define PJ_SCANNER_USE_BITWISE 0 +#define PJ_OS_HAS_CHECK_STACK 0 +#define PJ_LOG_MAX_LEVEL 3 +#define PJ_ENABLE_EXTRA_CHECK 0 +#define PJSIP_MAX_TSX_COUNT ((64*1024)-1) +#define PJSIP_MAX_DIALOG_COUNT ((64*1024)-1) +#define PJSIP_UDP_SO_SNDBUF_SIZE (512*1024) +#define PJSIP_UDP_SO_RCVBUF_SIZE (512*1024) +#define PJ_DEBUG 0 +#define PJSIP_SAFE_MODULE 0 +#define PJ_HAS_STRICMP_ALNUM 0 +#define PJ_HASH_USE_OWN_TOLOWER 1 +#define PJSIP_UNESCAPE_IN_PLACE 1 + +#undef PJ_TODO +#define PJ_TODO(x) diff --git a/third-party/pjproject/patches/user.mak b/third-party/pjproject/patches/user.mak new file mode 100644 index 000000000..31579d19c --- /dev/null +++ b/third-party/pjproject/patches/user.mak @@ -0,0 +1,2 @@ + +CFLAGS += -fPIC -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-unused-function -Wno-strict-aliasing |