Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3155858
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
34 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/configure.ac b/configure.ac
index c2aa47bd..7ff89978 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,618 +1,617 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# bootstrap / init
AC_PREREQ([2.61])
AC_INIT([corosync],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[discuss@lists.corosync.org])
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([-Wno-portability])
LT_PREREQ([2.2.6])
LT_INIT
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([lib/cpg.c])
AC_CONFIG_HEADER([include/corosync/config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
AC_LANG([C])
dnl Fix default variables - "prefix" variable if not specified
if test "$prefix" = "NONE"; then
prefix="/usr"
dnl Fix "localstatedir" variable if not specified
if test "$localstatedir" = "\${prefix}/var"; then
localstatedir="/var"
fi
dnl Fix "sysconfdir" variable if not specified
if test "$sysconfdir" = "\${prefix}/etc"; then
sysconfdir="/etc"
fi
dnl Fix "libdir" variable if not specified
if test "$libdir" = "\${exec_prefix}/lib"; then
if test -e /usr/lib64; then
libdir="/usr/lib64"
else
libdir="/usr/lib"
fi
fi
fi
if test "$srcdir" = "."; then
AC_MSG_NOTICE([building in place srcdir:$srcdir])
AC_DEFINE([BUILDING_IN_PLACE], 1, [building in place])
else
AC_MSG_NOTICE([building out of tree srcdir:$srcdir])
fi
# Checks for programs.
# check stolen from gnulib/m4/gnu-make.m4
if ! ${MAKE-make} --version /cannot/make/this >/dev/null 2>&1; then
AC_MSG_ERROR([you don't seem to have GNU make; it is required])
fi
sinclude(coroysync-default.m4)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_SED
AC_PROG_LIBTOOL
AC_CHECK_PROGS([GROFF], [groff])
AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
AC_CHECK_PROGS([AUGTOOL], [augtool])
AC_CHECK_PROGS([DOT], [dot])
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AC_CHECK_PROGS([AWK], [awk])
AC_CHECK_PROGS([SED], [sed])
AC_PATH_PROG([BASHPATH], [bash])
# Checks for compiler characteristics.
AC_PROG_GCC_TRADITIONAL
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdint.h \
stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h \
sys/time.h syslog.h unistd.h sys/types.h getopt.h malloc.h \
- sys/sockio.h utmpx.h ifaddrs.h stddef.h sys/file.h \
- net/if_var.h netinet/in_var.h netinet/in.h])
+ utmpx.h ifaddrs.h stddef.h sys/file.h])
AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
[AC_DEFINE_UNQUOTED([HAVE_SOCK_SIN_LEN], [1], [sockaddr_in needs sin_len])],
[], [[#include <netinet/in.h>]])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
[AC_DEFINE_UNQUOTED([HAVE_SOCK_SIN6_LEN], [1], [sockaddr_in6 needs sin6_len])],
[], [[#include <netinet/in.h>]])
# Checks for typedefs.
AC_TYPE_UID_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_SIGNAL
# Checks for libraries.
PKG_CHECK_MODULES([nss],[nss])
PKG_CHECK_MODULES([LIBQB], [libqb])
AC_CHECK_LIB([qb], [qb_log_thread_priority_set], \
have_qb_log_thread_priority_set="yes", \
have_qb_log_thread_priority_set="no")
if test "x${have_qb_log_thread_priority_set}" = xyes; then
AC_DEFINE_UNQUOTED([HAVE_QB_LOG_THREAD_PRIORITY_SET], 1, [have qb_log_thread_priority_set])
fi
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([socket], [socket])
AC_CHECK_LIB([nsl], [t_open])
AC_CHECK_LIB([rt], [sched_getscheduler])
# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([alarm alphasort atexit bzero dup2 endgrent endpwent fcntl \
getcwd getpeerucred getpeereid gettimeofday inet_ntoa memmove \
memset mkdir scandir select socket strcasecmp strchr strdup \
strerror strrchr strspn strstr pthread_setschedparam \
sched_get_priority_max sched_setscheduler getifaddrs \
clock_gettime ftruncate gethostname localtime_r munmap strtol])
AC_CONFIG_FILES([Makefile
exec/Makefile
include/Makefile
init/Makefile
lib/Makefile
common_lib/Makefile
man/Makefile
pkgconfig/Makefile
test/Makefile
cts/Makefile
cts/agents/Makefile
cts/CTSvars.py
tools/Makefile
conf/Makefile
qdevices/Makefile
Doxyfile])
### Local business
dnl ===============================================
dnl Functions / global M4 variables
dnl ===============================================
dnl Global list of LIB names
m4_define([local_soname_list], [])dnl
dnl Upcase parameter
m4_define([local_upcase], [translit([$*], [a-z], [A-Z])])dnl
dnl M4 macro for include lib/lib$1.soname and subst that
m4_define([LIB_SONAME_IMPORT],[dnl
m4_define([local_libname], local_upcase($1)[_SONAME])dnl
m4_define([local_soname], translit(m4_sinclude(lib/lib$1.verso), [
], []))dnl
local_libname="local_soname"dnl
m4_define([local_soname_list], m4_defn([local_soname_list])[,]local_libname[,]local_upcase($1))dnl
AC_SUBST(local_libname)dnl
])dnl
dnl M4 macro for print padspaces (used in LIB_MSG_RESULT). It takes 2 arguments, length of string to pad and desired
dnl (padded) length
m4_define([m4_printpadspace],[ifelse(m4_eval([$2 - $1 < 1]),[1],,[ ][m4_printpadspace([$1],m4_eval([$2 - 1]))])])dnl
dnl Show AC_MSG_RESULT for specific libraries
m4_define([LIB_MSG_RESULT], [ifelse([$#], [1], ,[dnl
AC_MSG_RESULT([ $2 Library SONAME m4_printpadspace(len($2),8) = ${$1}])
LIB_MSG_RESULT(m4_shift(m4_shift($@)))dnl
])])dnl
# ===============================================
# Helpers
# ===============================================
## helper for CC stuff
cc_supports_flag() {
BACKUP="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $@"
AC_MSG_CHECKING([whether $CC supports "$@"])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
[RC=0; AC_MSG_RESULT([yes])],
[RC=1; AC_MSG_RESULT([no])])
CPPFLAGS="$BACKUP"
return $RC
}
## cleanup
AC_MSG_NOTICE(Sanitizing prefix: ${prefix})
case $prefix in
NONE) prefix=/usr/local;;
esac
AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix})
case $exec_prefix in
dnl For consistency with Corosync, map NONE->$prefix
NONE) exec_prefix=$prefix;;
prefix) exec_prefix=$prefix;;
esac
## local defines
PACKAGE_FEATURES=""
LINT_FLAGS="-weak -unrecog +posixlib +ignoresigns -fcnuse \
-badflag -D__gnuc_va_list=va_list -D__attribute\(x\)="
# default libraries SONAME
SOMAJOR="5"
SOMINOR="0"
SOMICRO="0"
SONAME="${SOMAJOR}.${SOMINOR}.${SOMICRO}"
# specific libraries SONAME
LIB_SONAME_IMPORT([cfg])
LIB_SONAME_IMPORT([cpg])
LIB_SONAME_IMPORT([quorum])
LIB_SONAME_IMPORT([sam])
LIB_SONAME_IMPORT([votequorum])
LIB_SONAME_IMPORT([cmap])
# local options
AC_ARG_ENABLE([ansi],
[ --enable-ansi : force to build with ANSI standards. ],
[ default="no" ])
AC_ARG_ENABLE([fatal-warnings],
[ --enable-fatal-warnings : enable fatal warnings. ],
[ default="no" ])
AC_ARG_ENABLE([debug],
[ --enable-debug : enable debug build. ],
[ default="no" ])
AC_ARG_ENABLE([user-flags],
[ --enable-user-flags : rely on user environment. ],
[ default="no" ])
AC_ARG_ENABLE([coverage],
[ --enable-coverage : coverage analysis of the codebase. ],
[ default="no" ])
AC_ARG_ENABLE([small-memory-footprint],
[ --enable-small-memory-footprint : Use small message queues and small messages sizes. ],
[ default="no" ])
AC_ARG_ENABLE([dbus],
[ --enable-dbus : dbus events. ],,
[ enable_dbus="no" ])
AC_ARG_ENABLE([testagents],
[ --enable-testagents : Install Test Agents. ],,
[ default="no" ])
AC_ARG_ENABLE([rdma],
[ --enable-rdma : Infiniband RDMA transport support ],,
[ enable_rdma="no" ])
AM_CONDITIONAL(BUILD_RDMA, test x$enable_rdma = xyes)
AC_ARG_ENABLE([monitoring],
[ --enable-monitoring : resource monitoring ],,
[ default="no" ])
AM_CONDITIONAL(BUILD_MONITORING, test x$enable_monitoring = xyes)
AC_ARG_ENABLE([watchdog],
[ --enable-watchdog : Watchdog support ],,
[ default="no" ])
AM_CONDITIONAL(BUILD_WATCHDOG, test x$enable_watchdog = xyes)
AC_ARG_ENABLE([augeas],
[ --enable-augeas : Install the augeas lens for corosync.conf ],,
[ enable_augeas="no" ])
AM_CONDITIONAL(INSTALL_AUGEAS, test x$enable_augeas = xyes)
AC_ARG_ENABLE([systemd],
[ --enable-systemd : Install systemd service files],,
[ enable_systemd="no" ])
AM_CONDITIONAL(INSTALL_SYSTEMD, test x$enable_systemd = xyes)
AC_ARG_WITH([initddir],
[ --with-initddir=DIR : path to init script directory. ],
[ INITDDIR="$withval" ],
[ INITDDIR="$sysconfdir/init.d" ])
AC_ARG_WITH([systemddir],
[ --with-systemddir=DIR : path to systemd unit files directory. ],
[ SYSTEMDDIR="$withval" ],
[ SYSTEMDDIR="/lib/systemd/system" ])
AC_ARG_WITH([initwrappersdir],
[ --with-initwrappersdir=DIR : path to init wrappers files directory. ],
[ INITWRAPPERSDIR="$withval" ],
[ INITWRAPPERSDIR="$datarootdir/corosync" ])
AC_ARG_ENABLE([snmp],
[ --enable-snmp : SNMP protocol support ],
[ default="no" ])
AC_ARG_ENABLE([xmlconf],
[ --enable-xmlconf : XML configuration support ],,
[ enable_xmlconf="no" ])
AM_CONDITIONAL(INSTALL_XMLCONF, test x$enable_xmlconf = xyes)
AC_ARG_ENABLE([qdevices],
[ --enable-qdevices : Quorum devices support ],,
[ enable_qdevices="no" ])
AM_CONDITIONAL(BUILD_QDEVICES, test x$enable_qdevices = xyes)
# OS detection
# THIS SECTION MUST DIE!
case "$host_os" in
darwin*)
# this is unused. needs verification
DARWIN_OPTS="-dynamiclib -bind_at_load \
-current_version ${SONAME} \
-compatibility_version ${SONAME} -install_name \$(libdir)/\$(@)"
;;
*bsd*)
AC_DEFINE_UNQUOTED([COROSYNC_BSD], [1],
[Compiling for BSD platform])
;;
*solaris*)
AC_DEFINE_UNQUOTED([COROSYNC_SOLARIS], [1],
[Compiling for Solaris platform])
AC_DEFINE_UNQUOTED([TS_CLASS], [1],
[Prevent being scheduled RR])
;;
esac
# *FLAGS handling goes here
ENV_CFLAGS="$CFLAGS"
ENV_CPPFLAGS="$CPPFLAGS"
ENV_LDFLAGS="$LDFLAGS"
# debug build stuff
if test "x${enable_debug}" = xyes; then
AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
OPT_CFLAGS="-O0"
PACKAGE_FEATURES="$PACKAGE_FEATURES debug"
else
OPT_CFLAGS="-O3"
fi
# gdb flags
if test "x${GCC}" = xyes; then
GDB_FLAGS="-ggdb3"
else
GDB_FLAGS="-g"
fi
# Look for dbus-1
if test "x${enable_dbus}" = xyes; then
PKG_CHECK_MODULES([DBUS],[dbus-1])
AC_DEFINE_UNQUOTED([HAVE_DBUS], 1, [have dbus])
PACKAGE_FEATURES="$PACKAGE_FEATURES dbus"
fi
if test "x${enable_testagents}" = xyes; then
AC_DEFINE_UNQUOTED([HAVE_TESTAGENTS], 1, [have testagents])
PACKAGE_FEATURES="$PACKAGE_FEATURES testagents"
fi
if test "x${enable_rdma}" = xyes; then
PKG_CHECK_MODULES([rdmacm],[rdmacm])
PKG_CHECK_MODULES([ibverbs],[ibverbs])
AC_DEFINE_UNQUOTED([HAVE_RDMA], 1, [have rdmacm])
PACKAGE_FEATURES="$PACKAGE_FEATURES rdma"
fi
if test "x${enable_monitoring}" = xyes; then
PKG_CHECK_MODULES([statgrab], [libstatgrab])
AC_DEFINE_UNQUOTED([HAVE_MONITORING], 1, [have resource monitoring])
PACKAGE_FEATURES="$PACKAGE_FEATURES monitoring"
fi
if test "x${enable_watchdog}" = xyes; then
AC_CHECK_HEADER([linux/watchdog.h], [], [AC_MSG_ERROR([watchdog requires linux/watchdog.h])])
AC_CHECK_HEADER([linux/reboot.h], [], [AC_MSG_ERROR([watchdog requires linux/reboot.h])])
AC_DEFINE_UNQUOTED([HAVE_WATCHDOG], 1, [have watchdog])
PACKAGE_FEATURES="$PACKAGE_FEATURES watchdog"
fi
if test "x${enable_augeas}" = xyes; then
PACKAGE_FEATURES="$PACKAGE_FEATURES augeas"
fi
if test "x${enable_systemd}" = xyes; then
PACKAGE_FEATURES="$PACKAGE_FEATURES systemd"
fi
if test "x${enable_xmlconf}" = xyes; then
PACKAGE_FEATURES="$PACKAGE_FEATURES xmlconf"
fi
if test "x${enable_qdevices}" = xyes; then
PACKAGE_FEATURES="$PACKAGE_FEATURES qdevices"
fi
do_snmp=0
if test "x${enable_snmp}" = xyes; then
AC_PATH_PROGS([SNMPCONFIG], [net-snmp-config])
if test "x${SNMPCONFIG}" != "x"; then
AC_MSG_CHECKING([for snmp includes])
SNMP_PREFIX=`$SNMPCONFIG --prefix`
SNMP_INCLUDES="-I$SNMP_PREFIX/include"
AC_MSG_RESULT([$SNMP_INCLUDES])
AC_MSG_CHECKING([for snmp libraries])
SNMP_LIBS=`$SNMPCONFIG --libs`
AC_MSG_RESULT([$SNMP_LIBS])
AC_SUBST([SNMP_LIBS])
saveCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $SNMP_INCLUDES"
AC_CHECK_HEADERS([net-snmp/net-snmp-config.h])
CFLAGS="$saveCFLAGS"
if test "x${ac_cv_header_net_snmp_net_snmp_config_h}" != "xyes"; then
AC_MSG_ERROR([Unable to use net-snmp/net-snmp-config.h])
fi
savedLibs=$LIBS
LIBS="$LIBS $SNMP_LIBS"
AC_CHECK_FUNCS([netsnmp_transport_open_client])
if test $ac_cv_func_netsnmp_transport_open_client != yes; then
AC_CHECK_FUNCS([netsnmp_tdomain_transport])
if test $ac_cv_func_netsnmp_tdomain_transport != yes; then
AC_MSG_ERROR([No usable SNMP client transport implementation found])
fi
else
AC_DEFINE_UNQUOTED([NETSNMPV54], $NETSNMP_NEW_SUPPORT, [have net-snmp5.4 over])
fi
LIBS=$savedLibs
do_snmp=1
PACKAGE_FEATURES="$PACKAGE_FEATURES snmp"
AC_DEFINE_UNQUOTED([ENABLE_SNMP], $do_snmp, [Build in support for sending SNMP traps])
else
AC_MSG_ERROR([You need the net_snmp development package to continue.])
fi
fi
AM_CONDITIONAL(BUILD_SNMP, test "${do_snmp}" = "1")
# extra warnings
EXTRA_WARNINGS=""
WARNLIST="
all
shadow
missing-prototypes
missing-declarations
strict-prototypes
declaration-after-statement
pointer-arith
write-strings
cast-align
bad-function-cast
missing-format-attribute
format=2
format-security
format-nonliteral
no-long-long
unsigned-char
gnu89-inline
no-strict-aliasing
"
for j in $WARNLIST; do
if cc_supports_flag -W$j; then
EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";
fi
done
if test "x${enable_coverage}" = xyes && \
cc_supports_flag -ftest-coverage && \
cc_supports_flag -fprofile-arcs ; then
AC_MSG_NOTICE([Enabling Coverage (enable -O0 by default)])
OPT_CFLAGS="-O0"
COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
PACKAGE_FEATURES="$PACKAGE_FEATURES coverage"
else
COVERAGE_CFLAGS=""
COVERAGE_LDFLAGS=""
fi
if test "x${enable_small_memory_footprint}" = xyes ; then
AC_DEFINE_UNQUOTED([HAVE_SMALL_MEMORY_FOOTPRINT], 1, [have small_memory_footprint])
PACKAGE_FEATURES="$PACKAGE_FEATURES small-memory-footprint"
fi
if test "x${enable_ansi}" = xyes && \
cc_supports_flag -std=iso9899:199409 ; then
AC_MSG_NOTICE([Enabling ANSI Compatibility])
ANSI_CPPFLAGS="-ansi -DANSI_ONLY"
PACKAGE_FEATURES="$PACKAGE_FEATURES ansi"
else
ANSI_CPPFLAGS=""
fi
if test "x${enable_fatal_warnings}" = xyes && \
cc_supports_flag -Werror ; then
AC_MSG_NOTICE([Enabling Fatal Warnings (-Werror)])
WERROR_CFLAGS="-Werror"
PACKAGE_FEATURES="$PACKAGE_FEATURES fatal-warnings"
else
WERROR_CFLAGS=""
fi
# don't add addtional cflags
if test "x${enable_user_flags}" = xyes; then
OPT_CFLAGS=""
GDB_FLAGS=""
EXTRA_WARNINGS=""
fi
# final build of *FLAGS
CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS \
$COVERAGE_CFLAGS $EXTRA_WARNINGS \
$WERROR_CFLAGS $NSS_CFLAGS $LIBQB_CFLAGS \
$SNMP_INCLUDES"
CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS"
LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS"
# substitute what we need:
AC_SUBST([BASHPATH])
AC_SUBST([INITDDIR])
AC_SUBST([SYSTEMDDIR])
INITWRAPPERSDIR=$(eval echo ${INITWRAPPERSDIR})
AC_SUBST([INITWRAPPERSDIR])
AC_SUBST([SOMAJOR])
AC_SUBST([SOMINOR])
AC_SUBST([SOMICRO])
AC_SUBST([SONAME])
AM_CONDITIONAL(INSTALL_TESTAGENTS, test -n "${enable_testagents}")
AM_CONDITIONAL(INSTALL_MIB, test "${do_snmp}" = "1")
AM_CONDITIONAL(INSTALL_DBUSCONF, test "${enable_dbus}" = "1")
AM_CONDITIONAL(AUGTOOL, test -n "${AUGTOOL}")
AC_SUBST([NSS_LDFLAGS])
AM_CONDITIONAL(BUILD_HTML_DOCS, test -n "${GROFF}")
AC_SUBST([LINT_FLAGS])
AC_DEFINE_UNQUOTED([LOCALSTATEDIR], "$(eval echo ${localstatedir})", [localstate directory])
COROSYSCONFDIR=${sysconfdir}/corosync
AC_SUBST([COROSYSCONFDIR])
AC_DEFINE_UNQUOTED([COROSYSCONFDIR], "$(eval echo ${COROSYSCONFDIR})", [corosync config directory])
AC_DEFINE_UNQUOTED([PACKAGE_FEATURES], "${PACKAGE_FEATURES}", [corosync built-in features])
AC_OUTPUT
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE configuration:])
AC_MSG_RESULT([ Version = ${VERSION}])
AC_MSG_RESULT([ Prefix = ${prefix}])
AC_MSG_RESULT([ Executables = ${sbindir}])
AC_MSG_RESULT([ Man pages = ${mandir}])
AC_MSG_RESULT([ Doc dir = ${docdir}])
AC_MSG_RESULT([ Libraries = ${libdir}])
AC_MSG_RESULT([ Header files = ${includedir}])
AC_MSG_RESULT([ Arch-independent files = ${datadir}])
AC_MSG_RESULT([ State information = ${localstatedir}])
AC_MSG_RESULT([ System configuration = ${sysconfdir}])
AC_MSG_RESULT([ System init.d directory = ${INITDDIR}])
AC_MSG_RESULT([ System systemd directory = ${SYSTEMDDIR}])
AC_MSG_RESULT([ System init wraps dir = ${INITWRAPPERSDIR}])
AC_MSG_RESULT([ corosync config dir = ${COROSYSCONFDIR}])
AC_MSG_RESULT([ Features =${PACKAGE_FEATURES}])
AC_MSG_RESULT([])
AC_MSG_RESULT([$PACKAGE build info:])
AC_MSG_RESULT([ Library SONAME = ${SONAME}])
LIB_MSG_RESULT(m4_shift(local_soname_list))dnl
AC_MSG_RESULT([ Default optimization = ${OPT_CFLAGS}])
AC_MSG_RESULT([ Default debug options = ${GDB_CFLAGS}])
AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}])
AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}])
AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}])
AC_MSG_RESULT([ Env. defined LDFLAGS = ${ENV_LDFLAGS}])
AC_MSG_RESULT([ ANSI defined CPPFLAGS = ${ANSI_CPPFLAGS}])
AC_MSG_RESULT([ Coverage CFLAGS = ${COVERAGE_CFLAGS}])
AC_MSG_RESULT([ Coverage LDFLAGS = ${COVERAGE_LDFLAGS}])
AC_MSG_RESULT([ Fatal War. CFLAGS = ${WERROR_CFLAGS}])
AC_MSG_RESULT([ Final CFLAGS = ${CFLAGS}])
AC_MSG_RESULT([ Final CPPFLAGS = ${CPPFLAGS}])
AC_MSG_RESULT([ Final LDFLAGS = ${LDFLAGS}])
diff --git a/exec/totemip.c b/exec/totemip.c
index e0c73174..a641febf 100644
--- a/exec/totemip.c
+++ b/exec/totemip.c
@@ -1,606 +1,486 @@
/*
* Copyright (c) 2005-2011 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Patrick Caulfield (pcaulfie@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/* IPv4/6 abstraction */
#include <config.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
-#ifdef HAVE_SYS_SOCKIO_H
-#include <sys/sockio.h>
-#endif
-#ifdef HAVE_NET_IF_VAR_H
-#include <net/if_var.h>
-#endif
-#ifdef HAVE_NETINET_IN_VAR_H
-#include <netinet/in_var.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
-#endif
#include <corosync/totem/totemip.h>
#include <corosync/swab.h>
#define LOCALHOST_IPV4 "127.0.0.1"
#define LOCALHOST_IPV6 "::1"
#define NETLINK_BUFSIZE 16384
#ifdef SO_NOSIGPIPE
void totemip_nosigpipe(int s)
{
int on = 1;
setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (void *)&on, sizeof(on));
}
#endif
/* Compare two addresses */
int totemip_equal(const struct totem_ip_address *addr1,
const struct totem_ip_address *addr2)
{
int addrlen = 0;
if (addr1->family != addr2->family)
return 0;
if (addr1->family == AF_INET) {
addrlen = sizeof(struct in_addr);
}
if (addr1->family == AF_INET6) {
addrlen = sizeof(struct in6_addr);
}
assert(addrlen);
if (memcmp(addr1->addr, addr2->addr, addrlen) == 0)
return 1;
else
return 0;
}
/* Copy a totem_ip_address */
void totemip_copy(struct totem_ip_address *addr1,
const struct totem_ip_address *addr2)
{
memcpy(addr1, addr2, sizeof(struct totem_ip_address));
}
void totemip_copy_endian_convert(struct totem_ip_address *addr1,
const struct totem_ip_address *addr2)
{
addr1->nodeid = swab32(addr2->nodeid);
addr1->family = swab16(addr2->family);
memcpy(addr1->addr, addr2->addr, TOTEMIP_ADDRLEN);
}
/*
* Multicast address range is 224.0.0.0 to 239.255.255.255 this
* translates to the first 4 bits == 1110 (0xE).
* http://en.wikipedia.org/wiki/Multicast_address
*/
int32_t totemip_is_mcast(struct totem_ip_address *ip_addr)
{
uint32_t addr = 0;
memcpy (&addr, ip_addr->addr, sizeof (uint32_t));
if (ip_addr->family == AF_INET) {
addr = ntohl(addr);
if ((addr >> 28) != 0xE) {
return -1;
}
}
return 0;
}
/* For sorting etc. params are void * for qsort's benefit */
int totemip_compare(const void *a, const void *b)
{
int i;
const struct totem_ip_address *totemip_a = (const struct totem_ip_address *)a;
const struct totem_ip_address *totemip_b = (const struct totem_ip_address *)b;
struct in_addr ipv4_a1;
struct in_addr ipv4_a2;
struct in6_addr ipv6_a1;
struct in6_addr ipv6_a2;
unsigned short family;
/*
* Use memcpy to align since totem_ip_address is unaligned on various archs
*/
memcpy (&family, &totemip_a->family, sizeof (unsigned short));
if (family == AF_INET) {
memcpy (&ipv4_a1, totemip_a->addr, sizeof (struct in_addr));
memcpy (&ipv4_a2, totemip_b->addr, sizeof (struct in_addr));
if (ipv4_a1.s_addr == ipv4_a2.s_addr) {
return (0);
}
if (htonl(ipv4_a1.s_addr) < htonl(ipv4_a2.s_addr)) {
return -1;
} else {
return +1;
}
} else
if (family == AF_INET6) {
/*
* We can only compare 8 bits at time for portability reasons
*/
memcpy (&ipv6_a1, totemip_a->addr, sizeof (struct in6_addr));
memcpy (&ipv6_a2, totemip_b->addr, sizeof (struct in6_addr));
for (i = 0; i < 16; i++) {
int res = ipv6_a1.s6_addr[i] -
ipv6_a2.s6_addr[i];
if (res) {
return res;
}
}
return 0;
} else {
/*
* Family not set, should be!
*/
assert (0);
}
return 0;
}
/* Build a localhost totem_ip_address */
int totemip_localhost(int family, struct totem_ip_address *localhost)
{
const char *addr_text;
memset (localhost, 0, sizeof (struct totem_ip_address));
if (family == AF_INET) {
addr_text = LOCALHOST_IPV4;
if (inet_pton(family, addr_text, (char *)&localhost->nodeid) <= 0) {
return -1;
}
} else {
addr_text = LOCALHOST_IPV6;
}
if (inet_pton(family, addr_text, (char *)localhost->addr) <= 0)
return -1;
localhost->family = family;
return 0;
}
int totemip_localhost_check(const struct totem_ip_address *addr)
{
struct totem_ip_address localhost;
if (totemip_localhost(addr->family, &localhost))
return 0;
return totemip_equal(addr, &localhost);
}
const char *totemip_print(const struct totem_ip_address *addr)
{
static char buf[INET6_ADDRSTRLEN];
return (inet_ntop(addr->family, addr->addr, buf, sizeof(buf)));
}
/* Make a totem_ip_address into a usable sockaddr_storage */
int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr,
uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
{
int ret = -1;
if (ip_addr->family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
memset(sin, 0, sizeof(struct sockaddr_in));
#ifdef HAVE_SOCK_SIN_LEN
sin->sin_len = sizeof(struct sockaddr_in);
#endif
sin->sin_family = ip_addr->family;
sin->sin_port = ntohs(port);
memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr));
*addrlen = sizeof(struct sockaddr_in);
ret = 0;
}
if (ip_addr->family == AF_INET6) {
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
memset(sin, 0, sizeof(struct sockaddr_in6));
#ifdef HAVE_SOCK_SIN6_LEN
sin->sin6_len = sizeof(struct sockaddr_in6);
#endif
sin->sin6_family = ip_addr->family;
sin->sin6_port = ntohs(port);
sin->sin6_scope_id = 2;
memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr));
*addrlen = sizeof(struct sockaddr_in6);
ret = 0;
}
return ret;
}
/* Converts an address string string into a totem_ip_address.
family can be AF_INET, AF_INET6 or 0 ("for "don't care")
*/
int totemip_parse(struct totem_ip_address *totemip, const char *addr, int family)
{
struct addrinfo *ainfo;
struct addrinfo ahints;
struct sockaddr_in *sa;
struct sockaddr_in6 *sa6;
int ret;
memset(&ahints, 0, sizeof(ahints));
ahints.ai_socktype = SOCK_DGRAM;
ahints.ai_protocol = IPPROTO_UDP;
ahints.ai_family = family;
/* Lookup the nodename address */
ret = getaddrinfo(addr, NULL, &ahints, &ainfo);
if (ret)
return -1;
sa = (struct sockaddr_in *)ainfo->ai_addr;
sa6 = (struct sockaddr_in6 *)ainfo->ai_addr;
totemip->family = ainfo->ai_family;
if (ainfo->ai_family == AF_INET)
memcpy(totemip->addr, &sa->sin_addr, sizeof(struct in_addr));
else
memcpy(totemip->addr, &sa6->sin6_addr, sizeof(struct in6_addr));
freeaddrinfo(ainfo);
return 0;
}
/* Make a sockaddr_* into a totem_ip_address */
int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
struct totem_ip_address *ip_addr)
{
int ret = -1;
ip_addr->family = saddr->ss_family;
ip_addr->nodeid = 0;
if (saddr->ss_family == AF_INET) {
const struct sockaddr_in *sin = (const struct sockaddr_in *)saddr;
memcpy(ip_addr->addr, &sin->sin_addr, sizeof(struct in_addr));
ret = 0;
}
if (saddr->ss_family == AF_INET6) {
const struct sockaddr_in6 *sin
= (const struct sockaddr_in6 *)saddr;
memcpy(ip_addr->addr, &sin->sin6_addr, sizeof(struct in6_addr));
ret = 0;
}
return ret;
}
-#if defined(HAVE_GETIFADDRS)
int totemip_getifaddrs(struct list_head *addrs)
{
struct ifaddrs *ifap, *ifa;
struct totem_ip_if_address *if_addr;
if (getifaddrs(&ifap) != 0)
return (-1);
list_init(addrs);
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL || ifa->ifa_netmask == NULL)
continue ;
if ((ifa->ifa_addr->sa_family != AF_INET && ifa->ifa_addr->sa_family != AF_INET6) ||
(ifa->ifa_netmask->sa_family != AF_INET && ifa->ifa_netmask->sa_family != AF_INET6))
continue ;
if_addr = malloc(sizeof(struct totem_ip_if_address));
if (if_addr == NULL) {
goto error_free_ifaddrs;
}
list_init(&if_addr->list);
memset(if_addr, 0, sizeof(struct totem_ip_if_address));
if_addr->interface_up = ifa->ifa_flags & IFF_UP;
if_addr->interface_num = if_nametoindex(ifa->ifa_name);
if_addr->name = strdup(ifa->ifa_name);
if (if_addr->name == NULL) {
goto error_free_addr;
}
if (totemip_sockaddr_to_totemip_convert((const struct sockaddr_storage *)ifa->ifa_addr,
&if_addr->ip_addr) == -1) {
goto error_free_addr_name;
}
if (totemip_sockaddr_to_totemip_convert((const struct sockaddr_storage *)ifa->ifa_netmask,
&if_addr->mask_addr) == -1) {
goto error_free_addr_name;
}
list_add_tail(&if_addr->list, addrs);
}
freeifaddrs(ifap);
return (0);
error_free_addr_name:
free(if_addr->name);
error_free_addr:
free(if_addr);
error_free_ifaddrs:
totemip_freeifaddrs(addrs);
freeifaddrs(ifap);
return (-1);
}
-#elif defined(SOLARIS)
-/*
- * On Solaris, man if_tcp describes this method
- */
-int totemip_getifaddrs(struct list_head *addrs)
-{
- int id_fd;
- int numreqs;
- int res;
- struct lifconf lifconf;
- struct lifreq *lifreq;
- int i, j;
- struct totem_ip_if_address *if_addr;
- short family;
-
- list_init(addrs);
-
- for (family = 0; family < 2; family++) {
- numreqs = 0;
- res = -1;
-
- lifconf.lifc_family = (family == 0 ? AF_INET : AF_INET6);
- id_fd = socket (lifconf.lifc_family, SOCK_STREAM, 0);
- lifconf.lifc_flags = 0;
- lifconf.lifc_buf = NULL;
- lifconf.lifc_len = 0;
- do {
- numreqs += 32;
- lifconf.lifc_len = sizeof (struct lifreq) * numreqs;
- lifconf.lifc_buf = (void *)realloc(lifconf.lifc_buf, lifconf.lifc_len);
- res = ioctl (id_fd, SIOCGLIFCONF, &lifconf);
- if (res < 0) {
- close (id_fd);
- }
- } while (res >= 0 && lifconf.lifc_len == sizeof (struct lifconf) * numreqs);
-
- if (res < 0)
- continue ;
-
- lifreq = (struct lifreq *)lifconf.lifc_buf;
- for (i = 0; i < lifconf.lifc_len / sizeof (struct lifreq); i++) {
- if (ioctl(id_fd, SIOCGLIFADDR, &lifreq[i]) < 0)
- continue ;
-
- if (lifreq[i].lifr_addr.ss_family != AF_INET && lifreq[i].lifr_addr.ss_family != AF_INET6)
- continue ;
-
- if_addr = malloc(sizeof(struct totem_ip_if_address));
- if (if_addr == NULL) {
- goto error_free_ifaddrs;
- }
-
- memset(if_addr, 0, sizeof(struct totem_ip_if_address));
-
- if_addr->name = strdup(lifreq[i].lifr_name);
- if (if_addr->name == NULL) {
- goto error_free_addr;
- }
-
- if (totemip_sockaddr_to_totemip_convert(&lifreq[i].lifr_addr, &if_addr->ip_addr) == -1) {
- goto error_free_addr_name;
- }
-
- if (ioctl(id_fd, SIOCGLIFSUBNET, &lifreq[i]) < 0)
- continue ;
-
- /*
- * lifreq doesn't contain mask address. But It length of prefix in bits,
- * so we can generate mask.
- */
- memset(&if_addr->mask_addr, 0, sizeof(if_addr->mask_addr));
- if_addr->mask_addr.family = if_addr->ip_addr.family;
- for (j = 0; j < lifreq[i].lifr_addrlen; j++) {
- if_addr->mask_addr.addr[j / 8] |= 1 << (7 - (j % 8));
- }
- if (ioctl(id_fd, SIOCGLIFFLAGS, &lifreq[i]) >= 0) {
- if_addr->interface_up = lifreq[i].lifr_flags & IFF_UP;
- }
- if (ioctl(id_fd, SIOCGLIFINDEX, &lifreq[i]) >= 0) {
- if_addr->interface_num = lifreq[i].lifr_index;
- }
-
- list_add_tail(&if_addr->list, addrs);
- }
-
- free (lifconf.lifc_buf);
- close (id_fd);
- }
-
- return (0);
-
-error_free_addr_name:
- free(if_addr->name);
-
-error_free_addr:
- free(if_addr);
-
-error_free_ifaddrs:
- totemip_freeifaddrs(addrs);
- free (lifconf.lifc_buf);
- close (id_fd);
-
- return (-1);
-}
-#endif /* HAVE_GETIFADDRS */
void totemip_freeifaddrs(struct list_head *addrs)
{
struct totem_ip_if_address *if_addr;
struct list_head *list;
for (list = addrs->next; list != addrs;) {
if_addr = list_entry(list, struct totem_ip_if_address, list);
list = list->next;
free(if_addr->name);
list_del(&if_addr->list);
free(if_addr);
}
list_init(addrs);
}
int totemip_iface_check(struct totem_ip_address *bindnet,
struct totem_ip_address *boundto,
int *interface_up,
int *interface_num,
int mask_high_bit)
{
struct list_head addrs;
struct list_head *list;
struct totem_ip_if_address *if_addr;
struct totem_ip_address bn_netaddr, if_netaddr;
socklen_t addr_len;
socklen_t si;
int res = -1;
int exact_match_found = 0;
int net_match_found = 0;
*interface_up = 0;
*interface_num = 0;
if (totemip_getifaddrs(&addrs) == -1) {
return (-1);
}
for (list = addrs.next; list != &addrs; list = list->next) {
if_addr = list_entry(list, struct totem_ip_if_address, list);
if (bindnet->family != if_addr->ip_addr.family)
continue ;
addr_len = 0;
switch (bindnet->family) {
case AF_INET:
addr_len = sizeof(struct in_addr);
break;
case AF_INET6:
addr_len = sizeof(struct in6_addr);
break;
}
if (addr_len == 0)
continue ;
totemip_copy(&bn_netaddr, bindnet);
totemip_copy(&if_netaddr, &if_addr->ip_addr);
if (totemip_equal(&bn_netaddr, &if_netaddr)) {
exact_match_found = 1;
}
for (si = 0; si < addr_len; si++) {
bn_netaddr.addr[si] = bn_netaddr.addr[si] & if_addr->mask_addr.addr[si];
if_netaddr.addr[si] = if_netaddr.addr[si] & if_addr->mask_addr.addr[si];
}
if (exact_match_found || (!net_match_found && totemip_equal(&bn_netaddr, &if_netaddr))) {
totemip_copy(boundto, &if_addr->ip_addr);
boundto->nodeid = bindnet->nodeid;
*interface_up = if_addr->interface_up;
*interface_num = if_addr->interface_num;
if (boundto->family == AF_INET && boundto->nodeid == 0) {
unsigned int nodeid = 0;
memcpy (&nodeid, boundto->addr, sizeof (int));
#if __BYTE_ORDER == __BIG_ENDIAN
nodeid = swab32 (nodeid);
#endif
if (mask_high_bit) {
nodeid &= 0x7FFFFFFF;
}
boundto->nodeid = nodeid;
}
net_match_found = 1;
res = 0;
if (exact_match_found) {
goto finished;
}
}
}
finished:
totemip_freeifaddrs(&addrs);
return (res);
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Feb 27, 1:50 AM (22 h, 52 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1466016
Default Alt Text
(34 KB)
Attached To
Mode
rC Corosync
Attached
Detach File
Event Timeline
Log In to Comment