From 402653b9f341a05da6f1b7e0229fa90c183f3427 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 18 Apr 2013 19:43:36 -0700 Subject: [PATCH] portability updates add check if ipv6/sockaddr_in6 is availavble or not add check for poll.h and only include when available add includes for AROS --- configure.ac | 20 ++++++++++++++++++++ lib/discovery.c | 10 ++++++++-- lib/iscsi-command.c | 13 +++++++++++-- lib/logging.c | 15 ++++++++++++--- lib/login.c | 14 ++++++++++++-- lib/md5.c | 7 +++++++ lib/pdu.c | 12 +++++++++++- lib/scsi-lowlevel.c | 16 +++++++++++++++- lib/socket.c | 29 +++++++++++++++++++++++++---- lib/sync.c | 9 +++++++-- lib/task_mgmt.c | 15 ++++++++++++--- src/iscsi-inq.c | 8 +++++++- src/iscsi-ls.c | 8 +++++++- 13 files changed, 154 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 7995d06..20122de 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,26 @@ if test x"$libiscsi_cv_NEED_SYS_FILIO_H" = x"yes"; then AC_DEFINE(NEED_SYS_FILIO_H,1,[Whether we need sys/filio.h]) fi +# check for arpa/inet.h +dnl Check for arpa/inet.h +AC_CHECK_HEADERS([arpa/inet.h]) + +# check for poll.h +dnl Check for poll.h +AC_CHECK_HEADERS([poll.h]) + + +AC_CACHE_CHECK([for sockaddr_in6 support],libiscsi_cv_HAVE_SOCKADDR_IN6,[ +AC_TRY_COMPILE([#include +#include +#include ], +[struct sockaddr_in6 sock; int len = sizeof(sock);], +libiscsi_cv_HAVE_SOCKADDR_IN6=yes,libiscsi_cv_HAVE_SOCKADDR_IN6=no)]) +if test x"$libiscsi_cv_HAVE_SOCKADDR_IN6" = x"yes"; then + AC_DEFINE(HAVE_SOCKADDR_IN6,1,[Whether we have IPv6 support]) +fi + + AC_MSG_CHECKING(whether libpopt is available) ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" diff --git a/lib/discovery.c b/lib/discovery.c index 1ddf8ef..52b7762 100644 --- a/lib/discovery.c +++ b/lib/discovery.c @@ -14,9 +14,15 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#if defined(WIN32) -#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H #include #endif diff --git a/lib/iscsi-command.c b/lib/iscsi-command.c index e52612d..0fdd143 100644 --- a/lib/iscsi-command.c +++ b/lib/iscsi-command.c @@ -14,11 +14,20 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif #if defined(WIN32) #include -#else -#include #endif #include diff --git a/lib/logging.c b/lib/logging.c index e7e7e19..6a7c6d6 100644 --- a/lib/logging.c +++ b/lib/logging.c @@ -14,15 +14,24 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#if defined(WIN32) -#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_UNISTD_H #include #endif #include #include -#include #include "iscsi.h" #include "iscsi-private.h" #include "scsi-lowlevel.h" diff --git a/lib/login.c b/lib/login.c index a3004f5..12eea24 100644 --- a/lib/login.c +++ b/lib/login.c @@ -19,10 +19,20 @@ #define _GNU_SOURCE #endif +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + #if defined(WIN32) #include -#else -#include #endif #include diff --git a/lib/md5.c b/lib/md5.c index c3072a4..daab76c 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -19,6 +19,13 @@ * - Ian Jackson . * Still in the public domain. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif #include "md5.h" diff --git a/lib/pdu.c b/lib/pdu.c index b5e57fe..f53490a 100644 --- a/lib/pdu.c +++ b/lib/pdu.c @@ -14,12 +14,22 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif #if defined(WIN32) #include #else #include -#include #endif #include diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index b49e873..10448a4 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -21,12 +21,26 @@ * 3, unmarshall data-in into a real structure * 4, marshall a real structure into a data-out blob */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef AROS +#include "aros/aros_compat.h" +#endif #if defined(WIN32) #include #else #include -#include #endif #include diff --git a/lib/socket.c b/lib/socket.c index 54d6234..71e1021 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -14,6 +14,29 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_POLL_H +#include +#endif + +#ifdef AROS +#include "aros/aros_compat.h" +#endif #if defined(WIN32) #include @@ -21,15 +44,11 @@ #define ioctl ioctlsocket #define close closesocket #else -#include "config.h" #include -#include #include -#include #include #include #include -#include #include #endif @@ -217,6 +236,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, ((struct sockaddr_in *)(ai->ai_addr))->sin_len = socksize; #endif break; +#ifdef HAVE_SOCKADDR_IN6 case AF_INET6: socksize = sizeof(struct sockaddr_in6); ((struct sockaddr_in6 *)(ai->ai_addr))->sin6_port = htons(port); @@ -224,6 +244,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, ((struct sockaddr_in6 *)(ai->ai_addr))->sin6_len = socksize; #endif break; +#endif default: iscsi_set_error(iscsi, "Unknown address family :%d. " "Only IPv4/IPv6 supported so far.", diff --git a/lib/sync.c b/lib/sync.c index 5fc3a80..7a8e09b 100644 --- a/lib/sync.c +++ b/lib/sync.c @@ -14,12 +14,17 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_POLL_H +#include +#endif #if defined(WIN32) #include #include "win32/win32_compat.h" -#else -#include #endif #include diff --git a/lib/task_mgmt.c b/lib/task_mgmt.c index 784fe6c..007a37c 100644 --- a/lib/task_mgmt.c +++ b/lib/task_mgmt.c @@ -14,14 +14,23 @@ You should have received a copy of the GNU Lesser General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#if defined(WIN32) -#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_UNISTD_H #include #endif #include -#include #include "iscsi.h" #include "iscsi-private.h" #include "scsi-lowlevel.h" diff --git a/src/iscsi-inq.c b/src/iscsi-inq.c index d694dad..1e1c4ba 100644 --- a/src/iscsi-inq.c +++ b/src/iscsi-inq.c @@ -14,12 +14,18 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_POLL_H +#include +#endif #include #include #include #include -#include #include #include "iscsi.h" #include "scsi-lowlevel.h" diff --git a/src/iscsi-ls.c b/src/iscsi-ls.c index 3ffc9bc..8894ca4 100644 --- a/src/iscsi-ls.c +++ b/src/iscsi-ls.c @@ -14,12 +14,18 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_POLL_H +#include +#endif #include #include #include #include -#include #include #include "iscsi.h" #include "scsi-lowlevel.h"