Emeric Vigier | 2f62582 | 2012-08-06 11:09:52 -0400 | [diff] [blame] | 1 | dnl Copyright (C) 2001-2005 Open Source Telecom Corporation. |
| 2 | dnl Copyright (C) 2006-2010 David Sugar, Tycho Softworks. |
| 3 | dnl |
| 4 | dnl This program is free software; you can redistribute it and/or modify |
| 5 | dnl it under the terms of the GNU General Public License as published by |
| 6 | dnl the Free Software Foundation; either version 2 of the License, or |
| 7 | dnl (at your option) any later version. |
| 8 | dnl |
| 9 | dnl This program is distributed in the hope that it will be useful, |
| 10 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | dnl GNU General Public License for more details. |
| 13 | dnl |
| 14 | dnl You should have received a copy of the GNU General Public License |
| 15 | dnl along with this program; if not, write to the Free Software |
| 16 | dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | dnl |
| 18 | dnl As a special exception to the GNU General Public License, if you |
| 19 | dnl distribute this file as part of a program that contains a configuration |
| 20 | dnl script generated by Autoconf, you may include it under the same |
| 21 | dnl distribution terms that you use for the rest of that program. |
| 22 | |
| 23 | AC_DEFUN([OST_SYS_SOCKET],[ |
| 24 | AC_REQUIRE([OST_CC_SYSTIME]) |
| 25 | AC_REQUIRE([OST_CC_TYPES]) |
| 26 | ost_cv_inet_sockets=no |
| 27 | ost_cv_unix_sockets=no |
| 28 | ost_cv_lib_socket="c" |
| 29 | ost_cv_ipv6=yes |
| 30 | ost_cv_nat=yes |
| 31 | ost_cv_nat_detected=no |
| 32 | SOCKET_LIBS="" |
| 33 | AC_CHECK_HEADERS(net/if.h) |
| 34 | AC_CHECK_HEADERS(sys/socket.h,[ |
| 35 | AC_CHECK_HEADERS(select.h sys/select.h netinet/in_systm.h netinet/ip.h) |
| 36 | AC_CHECK_HEADERS(netinet/inet.h netinet/in.h) |
| 37 | AC_CHECK_HEADERS(arpa/inet.h, ost_cv_inet_sockets=yes) |
| 38 | AC_CHECK_HEADERS(sys/sockio.h) |
| 39 | AC_CHECK_HEADERS(sys/un.h, ost_cv_unix_sockets=yes) |
| 40 | ],[ |
| 41 | AC_CHECK_HEADERS(winsock2.h winsock.h,[ |
| 42 | ost_cv_lib_socket="wsock32" |
| 43 | SOCKET_LIBS="-lwsock32 -liberty -lws2_32" |
| 44 | ost_cv_inet_sockets=yes |
| 45 | ]) |
| 46 | ]) |
| 47 | AC_CHECK_LIB(socket, socket, [ |
| 48 | ost_cv_lib_socket="socket" |
| 49 | SOCKET_LIBS="-lsocket" |
| 50 | ]) |
| 51 | |
| 52 | if test $ost_cv_inet_sockets = yes ; then |
| 53 | AC_CHECK_LIB(${ost_cv_lib_socket}, getaddrinfo,[ |
| 54 | AC_DEFINE(HAVE_GETADDRINFO, [1], [getaddrinfo interface support]) |
| 55 | ]) |
| 56 | AC_ARG_WITH(ipv6, [ --without-ipv6 Disable ipv6], |
| 57 | ost_cv_ipv6=no,[ |
| 58 | AC_CHECK_HEADERS(netinet6/in6.h linux/in6.h) |
| 59 | AC_CHECK_LIB(${ost_cv_lib_socket}, inet_pton,[ |
| 60 | AC_DEFINE(HAVE_INET_PTON, [1], [ipv6 support])]) |
| 61 | AC_CHECK_LIB(${ost_cv_lib_socket}, gethostbyname2,[ |
| 62 | AC_DEFINE(HAVE_GETHOSTBYNAME2, [1], [ipv6 host lookup])]) |
| 63 | ]) |
| 64 | AC_CHECK_HEADERS(sys/libcsys.h) |
| 65 | AC_DEFINE(HAVE_INET_SOCKETS, [1], [inet sockets]) |
| 66 | AC_CHECK_LIB(${ost_cv_lib_socket}, inet_aton,[ |
| 67 | AC_DEFINE(HAVE_INET_ATON, [1], [has inet_aton])]) |
| 68 | AC_CACHE_CHECK([for socklen_t defined], ost_cv_socklen_t, [ |
| 69 | ost_cv_socklen_t='no' |
| 70 | AC_EGREP_HEADER(socklen_t, sys/socket.h, |
| 71 | ost_cv_socklen_t='yes',[ |
| 72 | AC_EGREP_HEADER(socklen_t, cygwin/socket.h, |
| 73 | ost_cv_socklen_t='yes')]) |
| 74 | ]) |
| 75 | if test $ost_cv_socklen_t = yes ; then |
| 76 | AC_DEFINE(HAVE_SOCKLEN_T, [1], [has socklen_t type]) |
| 77 | fi |
| 78 | |
| 79 | AC_ARG_WITH([nat], |
| 80 | [AC_HELP_STRING([--without-nat],[ Disable NAT class interface (pf, ipf or netfilter), default is enabled.])], |
| 81 | [ost_cv_nat=no] |
| 82 | ) |
| 83 | |
| 84 | if test "$ost_cv_nat" = "yes" ; then |
| 85 | |
| 86 | AC_CHECK_HEADERS([errno.h limits.h sys/types.h sys/socket.h sys/ioctl.h unistd.h]) |
| 87 | AC_CHECK_HEADERS([net/if.h],,, |
| 88 | [#ifdef HAVE_SYS_SOCKET_H |
| 89 | #include <sys/socket.h> |
| 90 | #endif]) |
| 91 | |
| 92 | if test "$ost_cv_nat_detected" = "no" ; then |
| 93 | AC_CHECK_HEADERS([linux/netfilter_ipv4.h linux/netfilter_ipv6.h],,, |
| 94 | [#ifdef HAVE_LIMITS_H |
| 95 | #include <limits.h> |
| 96 | #endif]) |
| 97 | if test "$ac_cv_header_linux_netfilter_ipv4_h" = "yes" && |
| 98 | [ test "$ac_cv_header_linux_netfilter_ipv6_h" = "yes" && |
| 99 | test "$ost_cv_ipv6" = "yes" || |
| 100 | test "$ost_cv_ipv6" = "no" ] ; then |
| 101 | AC_DEFINE(HAVE_NAT_NETFILTER, [1], [NetFilter NAT support]) |
| 102 | ost_cv_nat_detected="yes" |
| 103 | fi |
| 104 | fi |
| 105 | |
| 106 | if test "$ost_cv_nat_detected" = "no" ; then |
| 107 | ip_filter_compat="no" |
| 108 | AC_CHECK_HEADERS([netinet/ip_compat.h ip_compat.h netinet/ip_fil_compat.h ip_fil_compat.h], |
| 109 | [ip_filter_compat=$ac_header |
| 110 | break],, |
| 111 | [#ifdef HAVE_SYS_TYPES_H |
| 112 | #include <sys/types.h> |
| 113 | #endif |
| 114 | #ifdef HAVE_SYS_SOCKET_H |
| 115 | #include <sys/socket.h> |
| 116 | #endif |
| 117 | #ifdef HAVE_NETINET_IN_H |
| 118 | #include <netinet/in.h> |
| 119 | #endif]) |
| 120 | if test "$ip_filter_compat" != "no" ; then |
| 121 | ip_filter_fil="no" |
| 122 | AC_CHECK_HEADERS([netinet/ip_fil.h ip_fil.h], |
| 123 | [ip_filter_fil=$ac_header |
| 124 | break],, |
| 125 | [#ifdef HAVE_SYS_TYPES_H |
| 126 | #include <sys/types.h> |
| 127 | #endif |
| 128 | #ifdef HAVE_SYS_SOCKET_H |
| 129 | #include <sys/socket.h> |
| 130 | #endif |
| 131 | #ifdef HAVE_NETINET_IN_H |
| 132 | #include <netinet/in.h> |
| 133 | #endif |
| 134 | #include <$ip_filter_compat>]) |
| 135 | ip_filter_nat="no" |
| 136 | AC_CHECK_HEADERS([netinet/ip_nat.h ip_nat.h], |
| 137 | [ip_filter_nat=$ac_header |
| 138 | break],, |
| 139 | [#ifdef HAVE_SYS_TYPES_H |
| 140 | #include <sys/types.h> |
| 141 | #endif |
| 142 | #ifdef HAVE_SYS_SOCKET_H |
| 143 | #include <sys/socket.h> |
| 144 | #endif |
| 145 | #ifdef HAVE_NETINET_IN_H |
| 146 | #include <netinet/in.h> |
| 147 | #endif |
| 148 | #include <$ip_filter_compat> |
| 149 | #include <$ip_filter_fil> |
| 150 | #ifdef HAVE_NET_IF_H |
| 151 | #include <net/if.h> |
| 152 | #endif]) |
| 153 | if test "$ip_filter_fil" != "no" && |
| 154 | test "$ip_filter_nat" != "no" ; then |
| 155 | AC_DEFINE(HAVE_NAT_IPF, [1], [IPF NAT support]) |
| 156 | ost_cv_nat_detected="yes" |
| 157 | fi |
| 158 | fi |
| 159 | fi |
| 160 | |
| 161 | if test "$ost_cv_nat_detected" = "no" ; then |
| 162 | AC_CHECK_HEADERS([net/pfvar.h],,, |
| 163 | [#ifdef HAVE_SYS_TYPES_H |
| 164 | #include <sys/types.h> |
| 165 | #endif |
| 166 | #ifdef HAVE_SYS_SOCKET_H |
| 167 | #include <sys/socket.h> |
| 168 | #endif |
| 169 | #ifdef HAVE_NET_IF_H |
| 170 | #include <net/if.h> |
| 171 | #endif |
| 172 | #ifdef HAVE_NETINET_IN_H |
| 173 | #include <netinet/in.h> |
| 174 | #endif]) |
| 175 | if test "$ac_cv_header_net_pfvar.h" = "yes" ; then |
| 176 | AC_DEFINE(HAVE_NAT_PF, [1], [PF NAT support]) |
| 177 | ost_cv_nat_detected="yes" |
| 178 | fi |
| 179 | fi |
| 180 | |
| 181 | if test "$ost_cv_nat_detected" = "yes"; then |
| 182 | AC_DEFINE(CCXX_NAT, [1], [NAT support]) |
| 183 | else |
| 184 | AC_MSG_WARN([-------------------------------------------------------]) |
| 185 | AC_MSG_WARN([Could not autodetect NAT engine - pf, ipf or netfilter.]) |
| 186 | AC_MSG_WARN([NAT engine c++ class interface support was disabled. ]) |
| 187 | AC_MSG_WARN([This is not necessarilly a problem. If you do not plan ]) |
| 188 | AC_MSG_WARN([to use or don't know what this is, than it is safe to ]) |
| 189 | AC_MSG_WARN([assume that you don't need it. ]) |
| 190 | AC_MSG_WARN([-------------------------------------------------------]) |
| 191 | ost_cv_nat="no" |
| 192 | fi |
| 193 | fi |
| 194 | fi |
| 195 | |
| 196 | if test $ost_cv_unix_sockets = yes ; then |
| 197 | AC_DEFINE(HAVE_UNIX_SOCKETS, [1], [has unix domain sockets]) |
| 198 | fi |
| 199 | THREAD_LIBS="$SOCKET_LIBS $THREAD_LIBS" |
| 200 | AC_SUBST(SOCKET_LIBS) |
| 201 | AH_BOTTOM([ |
| 202 | |
| 203 | #ifdef HAVE_SYS_LIBCSYS_H |
| 204 | #include <sys/libcsys.h> |
| 205 | #endif |
| 206 | |
| 207 | #ifdef HAVE_WINSOCK2_H |
| 208 | #include <winsock2.h> |
| 209 | #else |
| 210 | #ifdef HAVE_WINSOCK_H |
| 211 | #include <winsock.h> |
| 212 | #else |
| 213 | #ifdef HAVE_SYS_SOCKET_H |
| 214 | #include <sys/socket.h> |
| 215 | #ifdef HAVE_SELECT_H |
| 216 | #include <select.h> |
| 217 | #else |
| 218 | #ifdef HAVE_SYS_SELECT_H |
| 219 | #include <sys/select.h> |
| 220 | #endif |
| 221 | #endif |
| 222 | |
| 223 | #ifdef HAVE_NETINET_IN_H |
| 224 | #if defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED) |
| 225 | #undef _XOPEN_SOURCE_EXTENDED |
| 226 | #endif |
| 227 | #include <netinet/in.h> |
| 228 | #ifdef __hpux |
| 229 | #define _XOPEN_SOURCE_EXTENDED |
| 230 | #endif |
| 231 | #endif |
| 232 | #ifdef HAVE_ARPA_INET_H |
| 233 | #include <arpa/inet.h> |
| 234 | #include <netdb.h> |
| 235 | #endif |
| 236 | |
| 237 | #ifdef HAVE_NETINET6_IN6_H |
| 238 | #include <netinet6/in6.h> |
| 239 | #endif |
| 240 | |
| 241 | #ifdef HAVE_LINIX_IN6_H |
| 242 | #include <linux/in6.h> |
| 243 | #endif |
| 244 | |
| 245 | #ifdef HAVE_NETINET_IN_SYSTM_H |
| 246 | #include <netinet/in_systm.h> |
| 247 | #endif |
| 248 | #ifdef HAVE_NETINET_IP_H |
| 249 | #include <netinet/ip.h> |
| 250 | #endif |
| 251 | #ifdef HAVE_SYS_UN_H |
| 252 | #include <sys/un.h> |
| 253 | #endif |
| 254 | #endif |
| 255 | #endif |
| 256 | #endif |
| 257 | |
| 258 | #ifndef HAVE_INET_ATON |
| 259 | #define inet_aton(cp, addr) (((*(unsigned long int *)(addr)) = inet_addr(cp)) != -1) |
| 260 | #endif |
| 261 | |
| 262 | #ifndef SUN_LEN |
| 263 | #ifdef SCM_RIGHTS |
| 264 | #define HAVE_UN_LEN |
| 265 | #endif |
| 266 | #ifdef __linux__ |
| 267 | #define HAVE_UN_LEN |
| 268 | #endif |
| 269 | #ifdef HAVE_UN_LEN |
| 270 | #define SUN_LEN(ptr) sizeof(sockaddr_un.sun_len) + sizeof(sockaddr_un.sun_family) + sizeof(sockaddr_un.sun_path) + 1 |
| 271 | #else |
| 272 | #define SUN_LEN(ptr) ((size_t)((struct sockaddr_un *)0)->sun_path) + strlen((ptr)->sun_path)) |
| 273 | #endif |
| 274 | #endif |
| 275 | |
| 276 | #ifndef _OSF_SOURCE |
| 277 | #ifndef HAVE_SOCKLEN_T |
| 278 | #if defined(i386) && defined(__svr4__) |
| 279 | #define HAVE_SOCKLEN_U |
| 280 | #else |
| 281 | #if defined(__CYGWIN32__) |
| 282 | #define socklen_t int |
| 283 | #else |
| 284 | typedef int socklen_t; |
| 285 | #endif |
| 286 | #endif |
| 287 | |
| 288 | #ifdef HAVE_SOCKLEN_U |
| 289 | #if !defined(__CYGWIN32__) && !defined(__MINGW32__) |
| 290 | typedef unsigned socklen_t; |
| 291 | #else |
| 292 | typedef int socklen_t; |
| 293 | #endif |
| 294 | #endif |
| 295 | #endif |
| 296 | #endif |
| 297 | |
| 298 | #ifdef __hpux |
| 299 | #ifdef mutable |
| 300 | #undef mutable |
| 301 | #endif |
| 302 | #endif |
| 303 | |
| 304 | #if defined(AF_INET6) && defined(HAVE_INET_PTON) |
| 305 | #define CCXX_IPV6 |
| 306 | #endif |
| 307 | |
| 308 | #define CCXX_MULTIFAMILY_IP |
| 309 | |
| 310 | ]) |
| 311 | ]) |
| 312 | |