chan_pjsip: Add configure check for 'pjsip_get_dest_info' function.
authorJoshua Colp <jcolp@digium.com>
Tue, 13 Jan 2015 12:09:45 +0000 (12:09 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 13 Jan 2015 12:09:45 +0000 (12:09 +0000)
The 'pjsip_get_dest_info' function is used to determine if the signaling transport
of the dialog is secure or not. This function was added in PJSIP 2.3 and does not
exist in earlier versions.

This configure check allows Asterisk to build and run with older versions at the
loss of the 'secure' argument for the PJSIP CHANNEL dialplan function. Usage of
this argument will require upgrading to PJSIP 2.3.

ASTERISK-24665 #close
Reported by: Mark Michelson

Review: https://reviewboard.asterisk.org/r/4329/
........

Merged revisions 430546 from http://svn.asterisk.org/svn/asterisk/branches/13

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430547 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/pjsip/dialplan_functions.c
configure
configure.ac
include/asterisk/autoconfig.h.in

index 704f6a4..91044a6 100644 (file)
@@ -592,11 +592,16 @@ static int channel_read_pjsip(struct ast_channel *chan, const char *type, const
        dlg = channel->session->inv_session->dlg;
 
        if (!strcmp(type, "secure")) {
+#ifdef HAVE_PJSIP_GET_DEST_INFO
                pjsip_host_info dest;
                pj_pool_t *pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "secure-check", 128, 128);
                pjsip_get_dest_info(dlg->target, NULL, pool, &dest);
                snprintf(buf, buflen, "%d", dest.flag & PJSIP_TRANSPORT_SECURE ? 1 : 0);
                pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
+#else
+               ast_log(LOG_WARNING, "Asterisk has been built against a version of pjproject which does not have the required functionality to support the 'secure' argument. Please upgrade to version 2.3 or later.\n");
+               return -1;
+#endif
        } else if (!strcmp(type, "target_uri")) {
                pjsip_uri_print(PJSIP_URI_IN_REQ_URI, dlg->target, buf, buflen);
                buf_copy = ast_strdupa(buf);
index eb40744..afe59dc 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 425966 .
+# From configure.ac Revision: 426235 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69 for asterisk trunk.
 #
@@ -902,6 +902,10 @@ PBX_PORTAUDIO
 PORTAUDIO_DIR
 PORTAUDIO_INCLUDE
 PORTAUDIO_LIB
+PBX_PJSIP_GET_DEST_INFO
+PJSIP_GET_DEST_INFO_DIR
+PJSIP_GET_DEST_INFO_INCLUDE
+PJSIP_GET_DEST_INFO_LIB
 PBX_PJSIP_REPLACE_MEDIA_STREAM
 PJSIP_REPLACE_MEDIA_STREAM_DIR
 PJSIP_REPLACE_MEDIA_STREAM_INCLUDE
@@ -10270,6 +10274,18 @@ PBX_PJSIP_REPLACE_MEDIA_STREAM=0
 
 
 
+PJSIP_GET_DEST_INFO_DESCRIP="pjsip_get_dest_info support"
+PJSIP_GET_DEST_INFO_OPTION=pjsip
+PJSIP_GET_DEST_INFO_DIR=${PJPROJECT_DIR}
+
+PBX_PJSIP_GET_DEST_INFO=0
+
+
+
+
+
+
+
     PORTAUDIO_DESCRIP="PortAudio"
     PORTAUDIO_OPTION="portaudio"
     PBX_PORTAUDIO=0
@@ -23985,6 +24001,111 @@ LIBS="${saved_libs}"
 CPPFLAGS="${saved_cppflags}"
 
 
+if test "x${PBX_PJSIP_GET_DEST_INFO}" != "x1" -a "${USE_PJSIP_GET_DEST_INFO}" != "no"; then
+   pbxlibdir=""
+   # if --with-PJSIP_GET_DEST_INFO=DIR has been specified, use it.
+   if test "x${PJSIP_GET_DEST_INFO_DIR}" != "x"; then
+      if test -d ${PJSIP_GET_DEST_INFO_DIR}/lib; then
+         pbxlibdir="-L${PJSIP_GET_DEST_INFO_DIR}/lib"
+      else
+         pbxlibdir="-L${PJSIP_GET_DEST_INFO_DIR}"
+      fi
+   fi
+   pbxfuncname="pjsip_get_dest_info"
+   if test "x${pbxfuncname}" = "x" ; then   # empty lib, assume only headers
+      AST_PJSIP_GET_DEST_INFO_FOUND=yes
+   else
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} $PJPROJECT_CFLAGS"
+      as_ac_Lib=`$as_echo "ac_cv_lib_pjsip_${pbxfuncname}" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lpjsip" >&5
+$as_echo_n "checking for ${pbxfuncname} in -lpjsip... " >&6; }
+if eval \${$as_ac_Lib+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpjsip ${pbxlibdir} $PJPROJECT_LIBS $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ${pbxfuncname} ();
+int
+main ()
+{
+return ${pbxfuncname} ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$as_ac_Lib=yes"
+else
+  eval "$as_ac_Lib=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+eval ac_res=\$$as_ac_Lib
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
+  AST_PJSIP_GET_DEST_INFO_FOUND=yes
+else
+  AST_PJSIP_GET_DEST_INFO_FOUND=no
+fi
+
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+   fi
+
+   # now check for the header.
+   if test "${AST_PJSIP_GET_DEST_INFO_FOUND}" = "yes"; then
+      PJSIP_GET_DEST_INFO_LIB="${pbxlibdir} -lpjsip $PJPROJECT_LIBS"
+      # if --with-PJSIP_GET_DEST_INFO=DIR has been specified, use it.
+      if test "x${PJSIP_GET_DEST_INFO_DIR}" != "x"; then
+         PJSIP_GET_DEST_INFO_INCLUDE="-I${PJSIP_GET_DEST_INFO_DIR}/include"
+      fi
+      PJSIP_GET_DEST_INFO_INCLUDE="${PJSIP_GET_DEST_INFO_INCLUDE} $PJPROJECT_CFLAGS"
+      if test "xpjsip.h" = "x" ; then  # no header, assume found
+         PJSIP_GET_DEST_INFO_HEADER_FOUND="1"
+      else                             # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${PJSIP_GET_DEST_INFO_INCLUDE}"
+         ac_fn_c_check_header_mongrel "$LINENO" "pjsip.h" "ac_cv_header_pjsip_h" "$ac_includes_default"
+if test "x$ac_cv_header_pjsip_h" = xyes; then :
+  PJSIP_GET_DEST_INFO_HEADER_FOUND=1
+else
+  PJSIP_GET_DEST_INFO_HEADER_FOUND=0
+fi
+
+
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+      fi
+      if test "x${PJSIP_GET_DEST_INFO_HEADER_FOUND}" = "x0" ; then
+         PJSIP_GET_DEST_INFO_LIB=""
+         PJSIP_GET_DEST_INFO_INCLUDE=""
+      else
+         if test "x${pbxfuncname}" = "x" ; then                # only checking headers -> no library
+            PJSIP_GET_DEST_INFO_LIB=""
+         fi
+         PBX_PJSIP_GET_DEST_INFO=1
+         cat >>confdefs.h <<_ACEOF
+#define HAVE_PJSIP_GET_DEST_INFO 1
+_ACEOF
+
+      fi
+   fi
+fi
+
+
+
+
 if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then
    pbxlibdir=""
    # if --with-POPT=DIR has been specified, use it.
index 0b45e45..efbc84a 100644 (file)
@@ -456,6 +456,7 @@ AST_EXT_LIB_SETUP([PJPROJECT], [PJPROJECT], [pjproject])
 AST_EXT_LIB_SETUP([POPT], [popt], [popt])
 AST_EXT_LIB_SETUP_OPTIONAL([PJ_TRANSACTION_GRP_LOCK], [PJSIP Transaction Group Lock Support], [PJPROJECT], [pjsip])
 AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_REPLACE_MEDIA_STREAM], [PJSIP Media Stream Replacement Support], [PJPROJECT], [pjsip])
+AST_EXT_LIB_SETUP_OPTIONAL([PJSIP_GET_DEST_INFO], [pjsip_get_dest_info support], [PJPROJECT], [pjsip])
 AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
 AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
 AST_EXT_LIB_SETUP_OPTIONAL([PRI_SETUP_ACK_INBAND], [ISDN PRI progress inband ie in SETUP ACK], [PRI], [pri])
@@ -2071,6 +2072,8 @@ AST_C_COMPILE_CHECK([PJSIP_REPLACE_MEDIA_STREAM], [pjmedia_mod_offer_flag flag =
 LIBS="${saved_libs}"
 CPPFLAGS="${saved_cppflags}"
 
+AST_EXT_LIB_CHECK([PJSIP_GET_DEST_INFO], [pjsip], [pjsip_get_dest_info], [pjsip.h], [$PJPROJECT_LIBS], [$PJPROJECT_CFLAGS])
+
 AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
 
 AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
index 2752613..f9046b4 100644 (file)
 /* Define if your system has the PJPROJECT libraries. */
 #undef HAVE_PJPROJECT
 
+/* Define to 1 if PJPROJECT has the pjsip_get_dest_info support feature. */
+#undef HAVE_PJSIP_GET_DEST_INFO
+
 /* Define if your system has the PJSIP_REPLACE_MEDIA_STREAM headers. */
 #undef HAVE_PJSIP_REPLACE_MEDIA_STREAM