From 677a65fcbb093864d199feef60b41f56fe532ba9 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Mon, 14 Mar 2016 10:59:10 -0300 Subject: [PATCH] build: Add configure check for proto field of PJSIP TLS transport setting. Older versions of PJSIP do not have the proto field on the TLS transport setting structure. This change adds a configure check so even if it is not present we will still be able to build. Change-Id: Ibf3f47befb91ed1b8194bf63888baa6fee05aba9 --- configure | 81 ++++++++++++++++++++++++++++-- configure.ac | 9 ++++ include/asterisk/autoconfig.h.in | 3 ++ res/res_pjsip/config_transport.c | 2 + third-party/pjproject/configure.m4 | 1 + 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/configure b/configure index fbafe12744..f2f0f78972 100755 --- a/configure +++ b/configure @@ -911,6 +911,10 @@ PBX_POPT POPT_DIR POPT_INCLUDE POPT_LIB +PBX_PJSIP_TLS_TRANSPORT_PROTO +PJSIP_TLS_TRANSPORT_PROTO_DIR +PJSIP_TLS_TRANSPORT_PROTO_INCLUDE +PJSIP_TLS_TRANSPORT_PROTO_LIB PBX_PJSIP_EXTERNAL_RESOLVER PJSIP_EXTERNAL_RESOLVER_DIR PJSIP_EXTERNAL_RESOLVER_INCLUDE @@ -10537,6 +10541,18 @@ PBX_PJSIP_EXTERNAL_RESOLVER=0 +PJSIP_TLS_TRANSPORT_PROTO_DESCRIP="PJSIP TLS Transport proto field support" +PJSIP_TLS_TRANSPORT_PROTO_OPTION=pjsip +PJSIP_TLS_TRANSPORT_PROTO_DIR=${PJPROJECT_DIR} + +PBX_PJSIP_TLS_TRANSPORT_PROTO=0 + + + + + + + POPT_DESCRIP="popt" POPT_OPTION="popt" @@ -13586,7 +13602,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -13632,7 +13648,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -13656,7 +13672,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -13701,7 +13717,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -13725,7 +13741,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -24435,6 +24451,9 @@ rm -f conftest* PJSIP_EXTERNAL_RESOLVER_INCLUDE="$PJPROJECT_INCLUDE" +$as_echo "#define HAVE_PJSIP_TLS_TRANSPORT_PROTO 1" >>confdefs.h + + else if test "x${PBX_PJPROJECT}" != "x1" -a "${USE_PJPROJECT}" != "no"; then @@ -25098,6 +25117,58 @@ _ACEOF fi + + saved_cppflags="${CPPFLAGS}" + saved_libs="${LIBS}" + CPPFLAGS="${CPPFLAGS} ${PJPROJECT_CFLAGS}" + LIBS="${LIBS} ${PJPROJECT_LIB}" + + if test "x${PBX_PJSIP_TLS_TRANSPORT_PROTO}" != "x1" -a "${USE_PJSIP_TLS_TRANSPORT_PROTO}" != "no"; then + if test "x" != "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for " >&5 +$as_echo_n "checking for ... " >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if \"struct pjsip_tls_setting setting; int proto; proto = setting.proto;\" compiles using pjsip.h" >&5 +$as_echo_n "checking if \"struct pjsip_tls_setting setting; int proto; proto = setting.proto;\" compiles using pjsip.h... " >&6; } + fi + saved_cppflags="${CPPFLAGS}" + if test "x${PJSIP_TLS_TRANSPORT_PROTO_DIR}" != "x"; then + PJSIP_TLS_TRANSPORT_PROTO_INCLUDE="-I${PJSIP_TLS_TRANSPORT_PROTO_DIR}/include" + fi + CPPFLAGS="${CPPFLAGS} ${PJSIP_TLS_TRANSPORT_PROTO_INCLUDE}" + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #include +int +main () +{ + struct pjsip_tls_setting setting; int proto; proto = setting.proto;; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + PBX_PJSIP_TLS_TRANSPORT_PROTO=1 + +$as_echo "#define HAVE_PJSIP_TLS_TRANSPORT_PROTO 1" >>confdefs.h + + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CPPFLAGS="${saved_cppflags}" + fi + + LIBS="${saved_libs}" + CPPFLAGS="${saved_cppflags}" fi fi diff --git a/configure.ac b/configure.ac index 7ea531a510..d0a1dec7e6 100644 --- a/configure.ac +++ b/configure.ac @@ -486,6 +486,7 @@ AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_REPLACE_MEDIA_STREAM], [PJSIP Media Stream Rep AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_GET_DEST_INFO], [pjsip_get_dest_info support], [PJPROJECT], [pjsip]) AST_EXT_LIB_SETUP_OPTIONAL([PJ_SSL_CERT_LOAD_FROM_FILES2], [pj_ssl_cert_load_from_files2 support], [PJPROJECT], [pjsip]) AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_EXTERNAL_RESOLVER], [PJSIP External Resolver Support], [PJPROJECT], [pjsip]) +AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_TLS_TRANSPORT_PROTO], [PJSIP TLS Transport proto field support], [PJPROJECT], [pjsip]) AST_EXT_LIB_SETUP([POPT], [popt], [popt]) AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio]) @@ -2186,6 +2187,14 @@ if test "$USE_PJPROJECT" != "no" ; then AST_EXT_LIB_CHECK([PJSIP_GET_DEST_INFO], [pjsip], [pjsip_get_dest_info], [pjsip.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS]) AST_EXT_LIB_CHECK([PJ_SSL_CERT_LOAD_FROM_FILES2], [pj], [pjsip/include/pjsip/sip_util.h], [pjlib.h], [$PJPROJECT_LIB], [$PJPROJECT_CFLAGS]) AST_EXT_LIB_CHECK([PJSIP_EXTERNAL_RESOLVER], [pjsip], [pjsip_endpt_set_ext_resolver], [pjsip.h], [$PJPROJECT_LIBS], [$PJPROJECT_CFLAGS]) + + saved_cppflags="${CPPFLAGS}" + saved_libs="${LIBS}" + CPPFLAGS="${CPPFLAGS} ${PJPROJECT_CFLAGS}" + LIBS="${LIBS} ${PJPROJECT_LIB}" + AST_C_COMPILE_CHECK([PJSIP_TLS_TRANSPORT_PROTO], [struct pjsip_tls_setting setting; int proto; proto = setting.proto;], [pjsip.h]) + LIBS="${saved_libs}" + CPPFLAGS="${saved_cppflags}" fi fi diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index cb983425a9..80780986ae 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -596,6 +596,9 @@ /* Define if your system has the PJSIP_REPLACE_MEDIA_STREAM headers. */ #undef HAVE_PJSIP_REPLACE_MEDIA_STREAM +/* Define if your system has the PJSIP_TLS_TRANSPORT_PROTO headers. */ +#undef HAVE_PJSIP_TLS_TRANSPORT_PROTO + /* Define if your system has pj_ssl_cert_load_from_files2 declared. */ #undef HAVE_PJ_SSL_CERT_LOAD_FROM_FILES2 diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c index db579bf2f6..d2c087487a 100644 --- a/res/res_pjsip/config_transport.c +++ b/res/res_pjsip/config_transport.c @@ -422,7 +422,9 @@ static int has_state_changed(struct ast_sip_transport_state *a, struct ast_sip_t if (a->tls.method != b->tls.method || a->tls.ciphers_num != b->tls.ciphers_num +#ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO || a->tls.proto != b->tls.proto +#endif || a->tls.verify_client != b->tls.verify_client || a->tls.verify_server != b->tls.verify_server || a->tls.require_client_cert != b->tls.require_client_cert) { diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4 index 3351527ebb..7432227740 100644 --- a/third-party/pjproject/configure.m4 +++ b/third-party/pjproject/configure.m4 @@ -43,4 +43,5 @@ AC_DEFUN([PJPROJECT_CONFIGURE], PJPROJECT_SYMBOL_CHECK([PJSIP_GET_DEST_INFO], [pjsip_get_dest_info], [pjsip.h]) PJPROJECT_SYMBOL_CHECK([PJ_SSL_CERT_LOAD_FROM_FILES2], [pj_ssl_cert_load_from_files2], [pjlib.h]) PJPROJECT_SYMBOL_CHECK([PJSIP_EXTERNAL_RESOLVER], [pjsip_endpt_set_ext_resolver], [pjsip.h]) + AC_DEFINE([HAVE_PJSIP_TLS_TRANSPORT_PROTO], 1, [Define if your system has PJSIP_TLS_TRANSPORT_PROTO]) ])