AIX: Fixed configure and compile issues

This commit is contained in:
Gerhard Rieger 2022-01-02 13:08:29 +01:00
parent ffa09eac00
commit 967e2b24b5
6 changed files with 47 additions and 8 deletions

View file

@ -10,6 +10,11 @@ Corrections:
configure now checks for the variant. configure now checks for the variant.
Thanks to Robert Zybeck for reporting this issue. 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: ####################### V 1.7.4.2:
Corrections: Corrections:

View file

@ -143,9 +143,12 @@ AC_CACHE_VAL(sc_cv_getprotobynumber_r,
[AC_TRY_COMPILE([#include <stddef.h> [AC_TRY_COMPILE([#include <stddef.h>
#include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024);], #include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024);],
[sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris], [sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris],
# there is a 3 arg variant in AIX, but its doc is limited [AC_TRY_COMPILE([#include <stddef.h>
#include <netdb.h>],[getprotobynumber_r(1,NULL,NULL);],
[sc_cv_getprotobynumber_r=3; tmp_bynum_variant=AIX],
[sc_cv_getprotobynumber_r=] [sc_cv_getprotobynumber_r=]
)])]) )])])])
if test "$sc_cv_getprotobynumber_r"; then if test "$sc_cv_getprotobynumber_r"; then
AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r) AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r)
fi fi
@ -259,6 +262,9 @@ if test "$WITH_IP6"; then
[AC_INCLUDES_DEFAULT [AC_INCLUDES_DEFAULT
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IP_H
# include <netinet/ip.h>
#endif]) #endif])
AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD and Lion, used for IPV6_* AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD and Lion, used for IPV6_*

23
error.c
View file

@ -120,6 +120,10 @@ static int diag_sock_pair(void) {
} }
diag_sock_send = handlersocks[1]; diag_sock_send = handlersocks[1];
diag_sock_recv = handlersocks[0]; 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; return 0;
} }
@ -278,7 +282,11 @@ void msg(int level, const char *format, ...) {
diag_dgram.exitcode = diagopts.exitstatus; diag_dgram.exitcode = diagopts.exitstatus;
vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap); vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap);
if (diag_in_handler && !diag_immediate_msg) { 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 #ifdef MSG_NOSIGNAL
|MSG_NOSIGNAL |MSG_NOSIGNAL
#endif #endif
@ -380,7 +388,12 @@ static void _msg(int level, const char *buff, const char *syslp) {
void diag_flush(void) { void diag_flush(void) {
struct diag_dgram recv_dgram; struct diag_dgram recv_dgram;
char exitmsg[20]; 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'; recv_dgram.text[TEXTLEN-1] = '\0';
switch (recv_dgram.op) { switch (recv_dgram.op) {
case DIAG_OP_EXIT: case DIAG_OP_EXIT:
@ -443,7 +456,11 @@ void diag_exit(int status) {
if (diag_in_handler && !diag_immediate_exit) { if (diag_in_handler && !diag_immediate_exit) {
diag_dgram.op = DIAG_OP_EXIT; diag_dgram.op = DIAG_OP_EXIT;
diag_dgram.exitcode = status; 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 #ifdef MSG_NOSIGNAL
|MSG_NOSIGNAL |MSG_NOSIGNAL
#endif #endif

View file

@ -212,7 +212,7 @@ int sockname(int fd, FILE *outfile, char style) {
struct protoent protoent, *protoentp; struct protoent protoent, *protoentp;
#endif #endif
#define PROTONAMEMAX 1024 #define PROTONAMEMAX 1024
char protoname[PROTONAMEMAX]; char protoname[PROTONAMEMAX] = "";
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
int proto; int proto;
#endif #endif
@ -263,6 +263,15 @@ int sockname(int fd, FILE *outfile, char style) {
#elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */ #elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */
protoentp = getprotobynumber(proto); protoentp = getprotobynumber(proto);
strncpy(protoname, protoentp->p_name, sizeof(protoname)); 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 #else
switch (proto) { switch (proto) {
case IPPROTO_TCP: strcpy(protoname, "tcp"); break; case IPPROTO_TCP: strcpy(protoname, "tcp"); break;

View file

@ -1222,7 +1222,7 @@ int gettimestamp(char *timestamp) {
#if HAVE_STRFTIME #if HAVE_STRFTIME
bytes = strftime(timestamp, 20, "%Y/%m/%d %H:%M:%S", localtime(&nowt)); bytes = strftime(timestamp, 20, "%Y/%m/%d %H:%M:%S", localtime(&nowt));
#if HAVE_CLOCK_GETTIME #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 #elif HAVE_PROTOTYPE_LIB_gettimeofday
bytes += sprintf(timestamp+19, "."F_tv_usec" ", now.tv_usec); bytes += sprintf(timestamp+19, "."F_tv_usec" ", now.tv_usec);
#else #else

View file

@ -39,11 +39,13 @@
# define WITH_IP4 1 # define WITH_IP4 1
#endif #endif
#if 0
#if WITH_IP6 #if WITH_IP6
# if !defined(HAVE_NETINET_IP6_H) # if !defined(HAVE_NETINET_IP6_H)
# undef WITH_IP6 # undef WITH_IP6
# endif # endif
#endif #endif
#endif
#if !WITH_IP4 && !WITH_IP6 #if !WITH_IP4 && !WITH_IP6
# if WITH_TCP || WITH_UDP || WITH_RAWIP # if WITH_TCP || WITH_UDP || WITH_RAWIP