summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2016-08-02 08:35:28 +0000
committerLiong Sauw Ming <ming@teluu.com>2016-08-02 08:35:28 +0000
commit0d94951e856b6f963b75f888eb7aa7428075a6d0 (patch)
tree100520779dd0790fd5d91b08be4723f4f70447e2
parent7e0cba1c76f7086cd636c16f8ff324cb77ebfdef (diff)
Re #1945 (misc): Set IPv6 sockets to be IPv6 only
Auto-detect in configure script if this option is supported, and if yes, Set IPv6 sockets to be IPv6 only. Thanks to Alexander Traud for the patch. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5403 74dad513-b988-da41-8d7b-12977e46ad98
-rwxr-xr-xaconfigure39
-rw-r--r--aconfigure.ac9
-rw-r--r--pjlib/include/pj/compat/os_auto.h.in1
-rw-r--r--pjlib/src/pj/sock_bsd.c6
4 files changed, 42 insertions, 13 deletions
diff --git a/aconfigure b/aconfigure
index 78601ca3..23c8386d 100755
--- a/aconfigure
+++ b/aconfigure
@@ -751,7 +751,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -874,7 +873,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1127,15 +1125,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1273,7 +1262,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1426,7 +1415,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -5606,6 +5594,31 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if IPV6_V6ONLY is available" >&5
+$as_echo_n "checking if IPV6_V6ONLY is available... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/socket.h>
+ #include <netinet/in.h>
+int
+main ()
+{
+int opt = IPV6_V6ONLY;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ $as_echo "#define PJ_SOCK_HAS_IPV6_V6ONLY 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+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
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if SO_ERROR is available" >&5
$as_echo_n "checking if SO_ERROR is available... " >&6; }
case $target in
diff --git a/aconfigure.ac b/aconfigure.ac
index 3c80efac..4ea4d498 100644
--- a/aconfigure.ac
+++ b/aconfigure.ac
@@ -343,6 +343,15 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
+dnl # Determine if IPV6_V6ONLY is available
+AC_MSG_CHECKING([if IPV6_V6ONLY is available])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>
+ #include <netinet/in.h>]],
+ [int opt = IPV6_V6ONLY;])],
+ [AC_DEFINE(PJ_SOCK_HAS_IPV6_V6ONLY,1)
+ AC_MSG_RESULT(yes)],
+ AC_MSG_RESULT(no))
+
dnl # Determine if SO_ERROR is available
AC_MSG_CHECKING([if SO_ERROR is available])
case $target in
diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in
index c8e73b20..7eb89562 100644
--- a/pjlib/include/pj/compat/os_auto.h.in
+++ b/pjlib/include/pj/compat/os_auto.h.in
@@ -83,6 +83,7 @@
#undef PJ_HAS_WINSOCK2_H
#undef PJ_HAS_WS2TCPIP_H
+#undef PJ_SOCK_HAS_IPV6_V6ONLY
#undef PJ_SOCK_HAS_INET_ATON
#undef PJ_SOCK_HAS_INET_PTON
#undef PJ_SOCK_HAS_INET_NTOP
diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c
index 1688668b..dc015d84 100644
--- a/pjlib/src/pj/sock_bsd.c
+++ b/pjlib/src/pj/sock_bsd.c
@@ -539,6 +539,12 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af,
pj_sock_setsockopt(*sock, pj_SOL_SOCKET(), pj_SO_NOSIGPIPE(),
&val, sizeof(val));
}
+#if defined(PJ_SOCK_HAS_IPV6_V6ONLY) && PJ_SOCK_HAS_IPV6_V6ONLY != 0
+ if (af == PJ_AF_INET6) {
+ pj_sock_setsockopt(*sock, PJ_SOL_IPV6, IPV6_V6ONLY,
+ &val, sizeof(val));
+ }
+#endif
#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \
PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT!=0
if (type == pj_SOCK_DGRAM()) {