From 7a3ed712706883afc5118e2d09a9334e6c382b2e Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Tue, 22 Nov 2011 11:24:35 +0100 Subject: [PATCH] port to Cygwin - struct pktinfo.ipi_spec_dst --- CHANGES | 4 ++++ config.h.in | 5 ++++- configure.in | 17 ++++++++++++++++- xio-ip.c | 13 ++++++++++--- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 30490fb..c112e88 100644 --- a/CHANGES +++ b/CHANGES @@ -57,6 +57,10 @@ porting: Cedril Priscal ported socat to Android (using Googles cross compiler). The port includes the socat_buildscript_for_android.sh script + added check for component ipi_spec_dst in struct in_pktinfo so + compilation does not fail on Cygwin (thanks to Peter Wagemans for + reporting this problem) + ####################### V 1.7.1.3: security: diff --git a/config.h.in b/config.h.in index a9d0f18..3a59824 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,5 @@ /* source: config.h.in */ -/* Copyright Gerhard Rieger 2001-2009 */ +/* Copyright Gerhard Rieger 2001-2011 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __config_h_included @@ -364,6 +364,9 @@ /* define if you have struct in_pktinfo */ #undef HAVE_STRUCT_IN_PKTINFO +/* define if your struct in_pktinfo has component ipi_spec_dst */ +#undef HAVE_PKTINFO_IPI_SPEC_DST + /* define if your struct ip has ip_hl; otherwise assume ip_vhl */ #undef HAVE_STRUCT_IP_IP_HL diff --git a/configure.in b/configure.in index de9b791..65b1597 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ nl source: configure.in -dnl Copyright Gerhard Rieger 2001-2009 +dnl Copyright Gerhard Rieger 2001-2011 dnl Published under the GNU General Public License V.2, see file COPYING dnl Process this file with autoconf to produce a configure script. @@ -1161,6 +1161,21 @@ if test $sc_cv_struct_in_pktinfo = yes; then fi AC_MSG_RESULT($sc_cv_struct_in_pktinfo) +if test $sc_cv_struct_in_pktinfo = 'yes'; then + dnl check for component ipi_spec_dst in struct in_pktinfo + AC_MSG_CHECKING(for ipi_spec_dst in struct in_pktinfo) + AC_CACHE_VAL(sc_cv_pktinfo_ipi_spec_dst, + [AC_TRY_COMPILE([#include + #include + #include ],[struct in_pktinfo s; s.ipi_spec_dst], + [sc_cv_pktinfo_ipi_spec_dst=yes], + [sc_cv_pktinfo_ipi_spec_dst=no])]) + if test $sc_cv_pktinfo_ipi_spec_dst = yes; then + AC_DEFINE(HAVE_PKTINFO_IPI_SPEC_DST) + fi + AC_MSG_RESULT($sc_cv_pktinfo_ipi_spec_dst) +fi + dnl check for ip_hl in struct ip AC_MSG_CHECKING(for struct ip.ip_hl) AC_CACHE_VAL(sc_cv_struct_ip_ip_hl, diff --git a/xio-ip.c b/xio-ip.c index 812b948..dad647d 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -1,5 +1,5 @@ /* source: xio-ip.c */ -/* Copyright Gerhard Rieger 2001-2009 */ +/* Copyright Gerhard Rieger 2001-2011 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for IP related functions */ @@ -477,8 +477,15 @@ int xiolog_ancillary_ip(struct cmsghdr *cmsg, int *num, "IP_LOCADDR", '\0', "IP_DSTADDR"); snprintf(valbuff, vallen, "%s%c%s%c%s", xiogetifname(pktinfo->ipi_ifindex, scratch1, -1), '\0', - inet4addr_info(ntohl(pktinfo->ipi_spec_dst.s_addr), scratch2, sizeof(scratch2)), '\0', - inet4addr_info(ntohl(pktinfo->ipi_addr.s_addr), scratch3, sizeof(scratch3))); +#if HAVE_PKTINFO_IPI_SPEC_DST + inet4addr_info(ntohl(pktinfo->ipi_spec_dst.s_addr), + scratch2, sizeof(scratch2)), +#else + "", +#endif + '\0', + inet4addr_info(ntohl(pktinfo->ipi_addr.s_addr), + scratch3, sizeof(scratch3))); } return STAT_OK; #endif /* defined(IP_PKTINFO) && HAVE_STRUCT_IN_PKTINFO */