diff --git a/CHANGES b/CHANGES index 7303704..0749542 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,11 @@ Corrections: configure now checks for the variant. Thanks to Robert Zybeck for reporting this issue. +Porting: + Again porting Socat to AIX (7.1) - Fixed configure and compile issues: + Adapted include requirements for IPv6 + Guarded MSG_DONTWAIT + ####################### V 1.7.4.2: Corrections: diff --git a/configure.ac b/configure.ac index afbc534..a1c1564 100644 --- a/configure.ac +++ b/configure.ac @@ -143,9 +143,12 @@ AC_CACHE_VAL(sc_cv_getprotobynumber_r, [AC_TRY_COMPILE([#include #include ],[getprotobynumber_r(1,NULL,NULL,1024);], [sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris], - # there is a 3 arg variant in AIX, but its doc is limited - [sc_cv_getprotobynumber_r=] -)])]) + [AC_TRY_COMPILE([#include + #include ],[getprotobynumber_r(1,NULL,NULL);], + [sc_cv_getprotobynumber_r=3; tmp_bynum_variant=AIX], + + [sc_cv_getprotobynumber_r=] +)])])]) if test "$sc_cv_getprotobynumber_r"; then AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r) fi @@ -259,6 +262,9 @@ if test "$WITH_IP6"; then [AC_INCLUDES_DEFAULT #ifdef HAVE_NETINET_IN_H # include + #endif + #ifdef HAVE_NETINET_IP_H + # include #endif]) AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD and Lion, used for IPV6_* diff --git a/error.c b/error.c index 1cff8d1..3135fd5 100644 --- a/error.c +++ b/error.c @@ -120,6 +120,10 @@ static int diag_sock_pair(void) { } diag_sock_send = handlersocks[1]; diag_sock_recv = handlersocks[0]; +#if !defined(MSG_DONTWAIT) + fcntl(diag_sock_send, F_SETFL, O_NONBLOCK); + fcntl(diag_sock_recv, F_SETFL, O_NONBLOCK); +#endif return 0; } @@ -278,7 +282,11 @@ void msg(int level, const char *format, ...) { diag_dgram.exitcode = diagopts.exitstatus; vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap); if (diag_in_handler && !diag_immediate_msg) { - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, MSG_DONTWAIT + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, + 0 /* for canonical reasons */ +#ifdef MSG_DONTWAIT + |MSG_DONTWAIT +#endif #ifdef MSG_NOSIGNAL |MSG_NOSIGNAL #endif @@ -380,7 +388,12 @@ static void _msg(int level, const char *buff, const char *syslp) { void diag_flush(void) { struct diag_dgram recv_dgram; char exitmsg[20]; - while (recv(diag_sock_recv, &recv_dgram, sizeof(recv_dgram)-1, MSG_DONTWAIT) > 0) { + while (recv(diag_sock_recv, &recv_dgram, sizeof(recv_dgram)-1, + 0 /* for canonical reasons */ +#ifdef MSG_DONTWAIT + |MSG_DONTWAIT +#endif + ) > 0) { recv_dgram.text[TEXTLEN-1] = '\0'; switch (recv_dgram.op) { case DIAG_OP_EXIT: @@ -443,7 +456,11 @@ void diag_exit(int status) { if (diag_in_handler && !diag_immediate_exit) { diag_dgram.op = DIAG_OP_EXIT; diag_dgram.exitcode = status; - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, MSG_DONTWAIT + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, + 0 /* for canonical reasons */ +#ifdef MSG_DONTWAIT + |MSG_DONTWAIT +#endif #ifdef MSG_NOSIGNAL |MSG_NOSIGNAL #endif diff --git a/fdname.c b/fdname.c index ee1d5ce..b076c3b 100644 --- a/fdname.c +++ b/fdname.c @@ -212,7 +212,7 @@ int sockname(int fd, FILE *outfile, char style) { struct protoent protoent, *protoentp; #endif #define PROTONAMEMAX 1024 - char protoname[PROTONAMEMAX]; + char protoname[PROTONAMEMAX] = ""; #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) int proto; #endif @@ -263,6 +263,15 @@ int sockname(int fd, FILE *outfile, char style) { #elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */ protoentp = getprotobynumber(proto); strncpy(protoname, protoentp->p_name, sizeof(protoname)); +#elif HAVE_GETPROTOBYNUMBER_R==3 /* AIX */ + { + struct protoent_data proto_data; + rc = getprotobynumber_r(proto, &protoent, &proto_data); + if (rc == 0) { + strncpy(protoname, protoent.p_name, sizeof(protoname)); + endprotoent_r(&proto_data); + } + } #else switch (proto) { case IPPROTO_TCP: strcpy(protoname, "tcp"); break; diff --git a/socat.c b/socat.c index 9e02129..728fa88 100644 --- a/socat.c +++ b/socat.c @@ -1222,7 +1222,7 @@ int gettimestamp(char *timestamp) { #if HAVE_STRFTIME bytes = strftime(timestamp, 20, "%Y/%m/%d %H:%M:%S", localtime(&nowt)); #if HAVE_CLOCK_GETTIME - bytes += sprintf(timestamp+19, "."F_tv_usec" ", now.tv_nsec/1000); + bytes += sprintf(timestamp+19, "."F_tv_nsec" ", now.tv_nsec/1000); #elif HAVE_PROTOTYPE_LIB_gettimeofday bytes += sprintf(timestamp+19, "."F_tv_usec" ", now.tv_usec); #else diff --git a/xioconfig.h b/xioconfig.h index 5d4df2d..e339d3a 100644 --- a/xioconfig.h +++ b/xioconfig.h @@ -39,11 +39,13 @@ # define WITH_IP4 1 #endif +#if 0 #if WITH_IP6 # if !defined(HAVE_NETINET_IP6_H) # undef WITH_IP6 # endif #endif +#endif #if !WITH_IP4 && !WITH_IP6 # if WITH_TCP || WITH_UDP || WITH_RAWIP