From b2d618438a5c39e33a88f35437e66c4bc9903ec0 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sun, 12 Oct 2008 12:01:00 +0200 Subject: [PATCH] made it compile and run on SuSE5.2 --- compat.h | 4 ++++ config.h.in | 6 ++++++ configure.in | 38 ++++++++++++++++++++++++++++++-------- filan.c | 12 +++++++++++- sysutils.c | 26 +++++++++++++++++++------- sysutils.h | 2 +- xio-socket.c | 16 ++++++++++++++-- xio.h | 2 +- xioconfig.h | 4 ++++ xioopts.c | 6 +++++- 10 files changed, 95 insertions(+), 21 deletions(-) diff --git a/compat.h b/compat.h index afd3f3c..5f7c588 100644 --- a/compat.h +++ b/compat.h @@ -602,6 +602,10 @@ # define NETDB_INTERNAL h_NETDB_INTERNAL #endif +#ifndef INET_ADDRSTRLEN +# define INET_ADDRSTRLEN sizeof(struct sockaddr_in) +#endif + #if !HAVE_PROTOTYPE_HSTRERROR /* with MacOSX this is char * */ extern const char *hstrerror(int); diff --git a/config.h.in b/config.h.in index 46d12c6..ad1ed55 100644 --- a/config.h.in +++ b/config.h.in @@ -293,6 +293,12 @@ /* fdset may have component fds_bits or __fds_bits */ #undef HAVE_FDS_BITS +/* Define if you have the sa_family_t */ +#undef HAVE_TYPE_SA_FAMILY_T + +/* define if your struct sigaction has sa_sigaction */ +#undef HAVE_STRUCT_SIGACTION_SA_SIGACTION + /* Define if your struct termios has component c_ispeed */ #undef HAVE_TERMIOS_ISPEED diff --git a/configure.in b/configure.in index 61dd284..035fe21 100644 --- a/configure.in +++ b/configure.in @@ -220,7 +220,7 @@ AC_ARG_ENABLE(rawsocket, [ --disable-genericsocket disable generic socket suppo *) AC_DEFINE(WITH_GENERICSOCKET) AC_MSG_RESULT(yes);; esac], [AC_DEFINE(WITH_GENERICSOCKET) AC_MSG_RESULT(yes)]) -AC_MSG_CHECKING(whether to include raw network INTERFACE support) +AC_MSG_CHECKING(whether to include raw network interface support) AC_ARG_ENABLE(interface, [ --disable-interface disable network interface support], [case "$enableval" in no) AC_MSG_RESULT(no); WITH_INTERFACE= ;; @@ -231,13 +231,13 @@ if test "$WITH_INTERFACE"; then AC_CHECK_HEADER(netpacket/packet.h, AC_DEFINE(HAVE_NETPACKET_PACKET_H), [WITH_INTERFACE=; - AC_MSG_WARN([include file netpacket/packet.h not found, disabling INTERFACE])]) + AC_MSG_WARN([include file netpacket/packet.h not found, disabling interface])]) fi if test "$WITH_INTERFACE"; then AC_CHECK_HEADER(netinet/if_ether.h, AC_DEFINE(HAVE_NETINET_IF_ETHER_H), [WITH_INTERFACE=; - AC_MSG_WARN([include file netinet/if_ether.h not found, disabling INTERFACE])]) + AC_MSG_WARN([include file netinet/if_ether.h not found, disabling interface])]) fi if test "$WITH_INTERFACE"; then AC_DEFINE(WITH_INTERFACE) @@ -595,13 +595,14 @@ AC_ARG_ENABLE(tun, [ --disable-tun disable TUN/TAP support], esac], [AC_MSG_RESULT(yes); WITH_TUN=1 ]) +# +if ! test "$ac_cv_header_linux_if_tun_h" = 'yes'; then + AC_MSG_WARN(include file linux/if_tun.h not found, disabling TUN) + WITH_TUN= +fi # if test -n "$WITH_TUN"; then - if test `uname` != Linux; then - AC_MSG_NOTICE(only on Linux) - else - AC_DEFINE(WITH_TUN) - fi + AC_DEFINE(WITH_TUN) fi AC_MSG_CHECKING(whether to include system call tracing) @@ -826,6 +827,27 @@ AC_TRY_COMPILE([#include [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FDS_BITS)], [AC_MSG_RESULT(no);]) +AC_MSG_CHECKING(for sa_family_t) +AC_CACHE_VAL(sc_cv_type_sa_family_t, +[AC_TRY_COMPILE([#include +#include ],[sa_family_t s;], +[sc_cv_type_sa_family_t=yes], +[sc_cv_type_sa_family_t=no])]) +if test $sc_cv_type_sa_family_t = yes; then + AC_DEFINE(HAVE_TYPE_SA_FAMILY_T) +fi +AC_MSG_RESULT($sc_cv_type_sa_family_t) + +AC_MSG_CHECKING(for struct sigaction.sa_sigaction) +AC_CACHE_VAL(sc_cv_struct_sigaction_sa_sigaction, +[AC_TRY_COMPILE([#include ],[struct sigaction s;s.sa_sigaction=0;], +[sc_cv_struct_sigaction_sa_sigaction=yes], +[sc_cv_struct_sigaction_sa_sigaction=no])]) +if test $sc_cv_struct_sigaction_sa_sigaction = yes; then + AC_DEFINE(HAVE_STRUCT_SIGACTION_SA_SIGACTION) +fi +AC_MSG_RESULT($sc_cv_struct_sigaction_sa_sigaction) + ### struct termios .c_ispeed AC_MSG_CHECKING(for termios.c_ispeed) AC_CACHE_VAL(sc_cv_termios_ispeed, diff --git a/filan.c b/filan.c index 246c9d3..6461e47 100644 --- a/filan.c +++ b/filan.c @@ -129,7 +129,17 @@ int filan_fd(int fd, FILE *outfile) { { /* see if data is available */ struct pollfd ufds; ufds.fd = fd; - ufds.events = POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|POLLWRNORM|POLLWRBAND + ufds.events = POLLIN|POLLPRI|POLLOUT +#ifdef POLLRDNORM + |POLLRDNORM +#endif +#ifdef POLLRDBAND + |POLLRDBAND +#endif + |POLLWRNORM +#ifdef POLLWRBAND + |POLLWRBAND +#endif #ifdef POLLMSG |POLLMSG #endif diff --git a/sysutils.c b/sysutils.c index 8e762bd..6b31788 100644 --- a/sysutils.c +++ b/sysutils.c @@ -175,11 +175,20 @@ char *sockaddr_info(const struct sockaddr *sa, socklen_t salen, char *buff, size cp += n, blen -= n; if ((snprintf(cp, blen, "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - sau->soa.sa_data[0], sau->soa.sa_data[1], sau->soa.sa_data[2], - sau->soa.sa_data[3], sau->soa.sa_data[4], sau->soa.sa_data[5], - sau->soa.sa_data[6], sau->soa.sa_data[7], sau->soa.sa_data[8], - sau->soa.sa_data[9], sau->soa.sa_data[10], sau->soa.sa_data[11], - sau->soa.sa_data[12], sau->soa.sa_data[13])) < 0) { + ((unsigned char *)sau->soa.sa_data)[0], + ((unsigned char *)sau->soa.sa_data)[1], + ((unsigned char *)sau->soa.sa_data)[2], + ((unsigned char *)sau->soa.sa_data)[3], + ((unsigned char *)sau->soa.sa_data)[4], + ((unsigned char *)sau->soa.sa_data)[5], + ((unsigned char *)sau->soa.sa_data)[6], + ((unsigned char *)sau->soa.sa_data)[7], + ((unsigned char *)sau->soa.sa_data)[8], + ((unsigned char *)sau->soa.sa_data)[9], + ((unsigned char *)sau->soa.sa_data)[10], + ((unsigned char *)sau->soa.sa_data)[11], + ((unsigned char *)sau->soa.sa_data)[12], + ((unsigned char *)sau->soa.sa_data)[13])) < 0) { Warn("sockaddr_info(): buffer too short"); *buff = '\0'; return buff; @@ -262,6 +271,7 @@ const char *inet_ntop(int pf, const void *binaddr, return NULL; /* errno is valid */ } break; +#if WITH_IP6 case PF_INET6: if ((retlen = snprintf(addrtext, textlen, "%x:%x:%x:%x:%x:%x:%x:%x", @@ -278,6 +288,7 @@ const char *inet_ntop(int pf, const void *binaddr, return NULL; /* errno is valid */ } break; +#endif /* WITH_IP6 */ default: errno = EAFNOSUPPORT; return NULL; @@ -413,7 +424,8 @@ const char *hstrerror(int err) { /* this function behaves like poll(). It tries to do so even when the poll() system call is not available. */ -int xiopoll(struct pollfd fds[], nfds_t nfds, struct timeval *timeout) { +/* note: glibc 5.4 does not know nfds_t */ +int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout) { int i, n = 0; int result = 0; @@ -432,7 +444,7 @@ int xiopoll(struct pollfd fds[], nfds_t nfds, struct timeval *timeout) { if (fds[i].events & POLLOUT) { FD_SET(fds[i].fd, &writefds); n = MAX(n, fds[i].fd); } } - if (fds[i].fd > FD_SETSIZE) { break; /* use poll */ } + if (i < nfds) { break; /* use poll */ } result = Select(n+1, &readfds, &writefds, &exceptfds, timeout); if (result < 0) { return result; } diff --git a/sysutils.h b/sysutils.h index 3b30b96..5d72b26 100644 --- a/sysutils.h +++ b/sysutils.h @@ -74,7 +74,7 @@ extern int getusergroups(const char *user, gid_t *list, size_t *ngroups); extern const char *hstrerror(int err); #endif -extern int xiopoll(struct pollfd fds[], nfds_t nfds, struct timeval *timeout); +extern int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout); extern int parseport(const char *portname, int proto); diff --git a/xio-socket.c b/xio-socket.c index 94f3363..b385bea 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1104,14 +1104,22 @@ static pid_t xio_waitingfor; /* info from recv loop to signal handler: static bool xio_hashappened; /* info from signal handler to loop: child process has read ("consumed") the packet */ /* this is the signal handler for USR1 and CHLD */ -void xiosigaction_hasread(int signum, siginfo_t *siginfo, void *ucontext) { +void xiosigaction_hasread(int signum +#if HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined(SA_SIGINFO) + , siginfo_t *siginfo, void *ucontext +#endif + ) { pid_t pid; int _errno; int status = 0; bool wassig = false; +#if HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined(SA_SIGINFO) Debug5("xiosigaction_hasread(%d, {%d,%d,%d,"F_pid"}, )", signum, siginfo->si_signo, siginfo->si_errno, siginfo->si_code, siginfo->si_pid); +#else + Debug1("xiosigaction_hasread(%d)", signum); +#endif if (signum == SIGCHLD) { _errno = errno; do { @@ -1146,9 +1154,13 @@ void xiosigaction_hasread(int signum, siginfo_t *siginfo, void *ucontext) { } } while (1); } +#if HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined(SA_SIGINFO) if (xio_waitingfor == siginfo->si_pid) { xio_hashappened = true; } +#else + xio_hashappened = true; +#endif Debug("xiosigaction_hasread() ->"); return; } @@ -1262,7 +1274,7 @@ int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags, |SA_NOMASK #endif ; -#if 1 || HAVE_SIGACTION_SASIGACTION +#if HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined(SA_SIGINFO) act.sa_sigaction = xiosigaction_hasread; #else /* Linux 2.0(.33) does not have sigaction.sa_sigaction */ act.sa_handler = xiosighandler_hasread; diff --git a/xio.h b/xio.h index b09c8c3..8bc17ca 100644 --- a/xio.h +++ b/xio.h @@ -335,7 +335,7 @@ union integral { } u_ip_mreq; #endif #if WITH_IP4 - in_addr_t u_ip4addr; + struct in_addr u_ip4addr; #endif } ; diff --git a/xioconfig.h b/xioconfig.h index 7d03be8..03e4859 100644 --- a/xioconfig.h +++ b/xioconfig.h @@ -120,4 +120,8 @@ typedef unsigned int uint32_t; #endif +#ifndef HAVE_TYPE_SA_FAMILY_T + typedef uint16_t sa_family_t; +#endif + #endif /* !defined(__xioconfig_h_included) */ diff --git a/xioopts.c b/xioopts.c index a943182..5b94f24 100644 --- a/xioopts.c +++ b/xioopts.c @@ -1125,6 +1125,9 @@ const struct optname optionnames[] = { #endif IF_TUN ("promisc", &opt_iff_promisc) IF_READLINE("prompt", &opt_prompt) +#ifdef SO_PROTOTYPE + IF_SOCKET ("protocol", &opt_so_prototype) +#endif IF_SOCKET ("protocol-family", &opt_protocol_family) #ifdef SO_PROTOTYPE IF_SOCKET ("prototype", &opt_so_prototype) @@ -1430,6 +1433,7 @@ const struct optname optionnames[] = { IF_SOCKET ("sockopt-string", &opt_setsockopt_string) IF_SOCKS4 ("socksport", &opt_socksport) IF_SOCKS4 ("socksuser", &opt_socksuser) + IF_SOCKET ("socktype", &opt_so_type) IF_IPAPP ("sourceport", &opt_sourceport) IF_IPAPP ("sp", &opt_sourceport) IF_TERMIOS("start", &opt_vstart) @@ -2331,7 +2335,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts, 0, 0/*!!!*/) != STAT_OK) { opt->desc = ODESC_ERROR; continue; } - opt->value.u_ip4addr = sa.sin_addr.s_addr; + opt->value.u_ip4addr = sa.sin_addr; } break; #endif /* defined(WITH_IP4) */