[Opalvoip-svn] SF.net SVN: opalvoip: [18789] ptlib/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <cso...@us...> - 2007-11-04 11:05:33
|
Revision: 18789 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=18789&view=rev Author: csoutheren Date: 2007-11-04 03:05:34 -0800 (Sun, 04 Nov 2007) Log Message: ----------- Use inet_ntop when available Use PCriticalSection on inet_ntoa Modified Paths: -------------- ptlib/trunk/configure ptlib/trunk/configure.ac ptlib/trunk/include/ptbuildopts.h.in ptlib/trunk/src/ptlib/common/sockets.cxx Modified: ptlib/trunk/configure =================================================================== --- ptlib/trunk/configure 2007-11-04 10:10:22 UTC (rev 18788) +++ ptlib/trunk/configure 2007-11-04 11:05:34 UTC (rev 18789) @@ -7874,11 +7874,72 @@ fi HAS_IPV6= +HAS_INET_NTOP= if test "$enable_ipv6" = "no" ; then { echo "$as_me:$LINENO: IPV6 disabled" >&5 echo "$as_me: IPV6 disabled" >&6;} + echo "$as_me:$LINENO: checking for inet_ntop" >&5 +echo $ECHO_N "checking for inet_ntop... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> + #include <netinet/in.h> + #include <arpa/inet.h> +int +main () +{ +int af; void * src; char * dst; socklen_t len; inet_ntop(af, src, dst, len); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + HAS_INET_NTOP=yes else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +HAS_INET_NTOP=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + if test $HAS_INET_NTOP = no ; then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + else + cat >>confdefs.h <<\_ACEOF +#define P_HAS_INET_NTOP 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + fi +else echo "$as_me:$LINENO: checking for IPv6 support" >&5 echo $ECHO_N "checking for IPv6 support... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF Modified: ptlib/trunk/configure.ac =================================================================== --- ptlib/trunk/configure.ac 2007-11-04 10:10:22 UTC (rev 18788) +++ ptlib/trunk/configure.ac 2007-11-04 11:05:34 UTC (rev 18789) @@ -1582,9 +1582,21 @@ fi HAS_IPV6= +HAS_INET_NTOP= if test "$enable_ipv6" = "no" ; then AC_MSG_NOTICE(IPV6 disabled) + AC_MSG_CHECKING(for inet_ntop) + AC_TRY_COMPILE([#include <sys/types.h> + #include <netinet/in.h> + #include <arpa/inet.h>], + [int af; void * src; char * dst; socklen_t len; inet_ntop(af, src, dst, len);], HAS_INET_NTOP=yes, HAS_INET_NTOP=no) + if test $HAS_INET_NTOP = no ; then + AC_MSG_RESULT(no) + else + AC_DEFINE(P_HAS_INET_NTOP, 1) + AC_MSG_RESULT(yes) + fi else AC_MSG_CHECKING(for IPv6 support) AC_TRY_COMPILE([#include <sys/types.h> Modified: ptlib/trunk/include/ptbuildopts.h.in =================================================================== --- ptlib/trunk/include/ptbuildopts.h.in 2007-11-04 10:10:22 UTC (rev 18788) +++ ptlib/trunk/include/ptbuildopts.h.in 2007-11-04 11:05:34 UTC (rev 18789) @@ -772,6 +772,7 @@ #undef PMEMORY_CHECK #undef P_HAS_RECVMSG #undef P_HAS_UPAD128_T +#undef P_HAS_INET_NTOP #endif // _PT_BUILDOPTS_H Modified: ptlib/trunk/src/ptlib/common/sockets.cxx =================================================================== --- ptlib/trunk/src/ptlib/common/sockets.cxx 2007-11-04 10:10:22 UTC (rev 18788) +++ ptlib/trunk/src/ptlib/common/sockets.cxx 2007-11-04 11:05:34 UTC (rev 18789) @@ -2520,14 +2520,24 @@ str.MakeMinimumSize(); return str; } -#endif -#ifdef P_VXWORKS + +#elif defined(P_VXWORKS) char ipStorage[INET_ADDR_LEN]; inet_ntoa_b(v.four, ipStorage); return ipStorage; -#else // P_VXWORKS + +#elif defined(P_HAS_INET_NTOP) + static PCriticalSection m; return inet_ntoa(v.four); -#endif // P_VXWORKS + +#else + + PString str; + if (inet_ntop(AF_INET, sa, str.GetPointer(INET_ADDRSTRLEN), INET_ADDRSTRLEN) == NULL) + return PString::Empty() + return str; + +#endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |