diff --git a/libs/openzap/configure.ac b/libs/openzap/configure.ac index 2931a4f262..ec7e935dfb 100644 --- a/libs/openzap/configure.ac +++ b/libs/openzap/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([openzap],[pre-alpha],[bugs@freeswitch.prg]) +AC_INIT([openzap],[pre-alpha],[bugs@freeswitch.org]) AC_CONFIG_SRCDIR([src/libteletone_detect.c]) # Checks for programs. @@ -26,7 +26,7 @@ AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compile done ]) ]) -AC_ARG_ENABLE(enable_64, [ --enable-64 Enable 64bit compilation]) +AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="$enableval"], [enable_64="no"]) AX_COMPILER_VENDOR @@ -46,11 +46,32 @@ sun) esac AC_CHECK_HEADERS([netinet/sctp.h netdb.h]) -AC_CHECK_FUNCS([gethostbyname_r]) +AC_CHECK_FUNC([gethostbyname_r], + [], [AC_CHECK_LIB([nsl], [gethostbyname_r])] +) +if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes" ; then + +AC_MSG_CHECKING([whether gethostbyname_r requires five arguments]) + +ac_cv_func_gethostbyname_r_five_args="no" + +AC_TRY_COMPILE([#include ], + [char *name; + struct hostent *he, *res; + char buffer[2048]; + int buflen = 2048; + (void)gethostbyname_r(name, he, buffer, buflen, &res)], + [ac_cv_func_gethostbyname_r_five_args="yes" + AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])] +) + + AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args]) + AC_DEFINE([HAVE_GETHOSTBYNAME_R],[1],[threadsafe gethostbyname]) +fi # Enable debugging AC_ARG_ENABLE(debug, -[AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enable_debug"],[enable_debug="yes"]) +[AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enableval"],[enable_debug="yes"]) if test "${enable_debug}" = "yes"; then AC_DEFINE([DEBUG],[],[Enable extra debugging.]) diff --git a/libs/openzap/src/ss7_boost_client.c b/libs/openzap/src/ss7_boost_client.c index 75d274cfaf..f12f1018a8 100644 --- a/libs/openzap/src/ss7_boost_client.c +++ b/libs/openzap/src/ss7_boost_client.c @@ -74,7 +74,7 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca int rc; struct hostent *result, *local_result; char buf[512], local_buf[512]; - int err = 0; + int err = 0, local_err = 0; memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp)); memset(&mcon->local_hp, 0, sizeof(mcon->local_hp)); @@ -91,9 +91,15 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca int flag; flag = 1; +#ifdef HAVE_GETHOSTBYNAME_R_FIVE + gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &err); + gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_err); + if (!err && !local_err) { +#else gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err); - gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &err); + gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &local_err); if (result && local_result) { +#endif mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype; memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length); mcon->remote_addr.sin_port = htons(port);