From: German Service Network Date: Fri, 13 Mar 2026 17:00:37 +0000 (+0100) Subject: Add IBM i PASE detection X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=fping.git Add IBM i PASE detection --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 480b645..9a8239a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Next function declarations to a separate file (#454, thanks @gsnw-sebast) - Avoid crash with option `-0` (#457, thanks @auerswal) - Move option parsing to a separate file fping.c and fping.h (#458, thanks @gsnw-sebast) +- Add IBM i PASE detection (#466, thanks @acerbis and @gsnw-sebast) - ci: Update autoconf to version 2.73 (#467, thanks @gsnw-sebast) fping 5.5 (2025-12-31) diff --git a/configure.ac b/configure.ac index 27454a9..b17f3bb 100644 --- a/configure.ac +++ b/configure.ac @@ -23,6 +23,31 @@ case "${target}" in ;; esac +dnl Detect IBM i PASE environment +AC_MSG_CHECKING([for IBM i PASE environment]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[ +#if !defined(__PASE__) +#error not PASE +#endif + ]])], + [ + AC_MSG_RESULT([yes]) + AC_MSG_NOTICE([IBM i PASE detected: applying required CPPFLAGS and library paths]) + CPPFLAGS="-I/QOpenSys/pkgs/include -D_SIGSET_T -DHAVE_STDLIB_H $CPPFLAGS" + LDFLAGS="-L/QOpenSys/pkgs/lib $LDFLAGS" + ], + [AC_MSG_RESULT([no])] +) + +dnl Check for IP_RECVTOS (missing on PASE/IBM i and some BSDs). +AC_CHECK_DECL([IP_RECVTOS], + [AC_DEFINE([HAVE_IP_RECVTOS], [1], [IP_RECVTOS socket option is available])], + [], + [#include +#include +#include ]) + dnl --disable-ipv4 AC_ARG_ENABLE([ipv4], AS_HELP_STRING([--disable-ipv4], [Disable support for pinging IPv4 hosts])) diff --git a/src/fping.c b/src/fping.c index 7c87538..efb4c4f 100644 --- a/src/fping.c +++ b/src/fping.c @@ -568,7 +568,7 @@ int main(int argc, char **argv) opt_ping_data_size = ICMP_TIMESTAMP_DATA_SIZE; } else if (strstr(optparse_state.optlongname, "print-tos") != NULL) { opt_print_tos_on = 1; -#if defined(IP_RECVTOS) +#if defined(HAVE_IP_RECVTOS) if (socket4 >= 0 && (socktype4 == SOCK_DGRAM)) { if (setsockopt(socket4, IPPROTO_IP, IP_RECVTOS, &sock_opt_on, sizeof(sock_opt_on))) { perror("setsockopt IP_RECVTOS"); @@ -2114,9 +2114,11 @@ packet_received: *reply_timestamp = timeval_ns(&reply_timestamp_tv); } #endif +#if defined(HAVE_IP_RECVTOS) if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TOS) { memcpy(ip_header_tos, CMSG_DATA(cmsg), sizeof(*ip_header_tos)); } +#endif if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) { memcpy(ip_header_ttl, CMSG_DATA(cmsg), sizeof(*ip_header_ttl)); } diff --git a/src/output.c b/src/output.c index b2640c8..c0de112 100644 --- a/src/output.c +++ b/src/output.c @@ -1,3 +1,4 @@ +#include "config.h" #include "output.h" #include "fping.h" #include "flags.h" @@ -232,6 +233,7 @@ void print_recv_ext(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t ms_since_midnight_utc(recv_time)); } +#if defined(HAVE_IP_RECVTOS) if(opt_print_tos_on) { if(ip_header_res->tos != -1) { printf(" (TOS %d)", ip_header_res->tos); @@ -240,6 +242,7 @@ void print_recv_ext(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int64_t printf(" (TOS unknown)"); } } +#endif if (opt_print_ttl_on) { if(ip_header_res->ttl != -1) { @@ -278,6 +281,7 @@ void print_recv_ext_json(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int printf("\"localreceive\": %u}", ms_since_midnight_utc(recv_time)); } +#if defined(HAVE_IP_RECVTOS) if(opt_print_tos_on) { if(ip_header_res->tos != -1) { printf(", \"tos\": %d", ip_header_res->tos); @@ -286,6 +290,7 @@ void print_recv_ext_json(IP_HEADER_RESULT *ip_header_res, int64_t recv_time, int printf(", \"tos\": -1"); } } +#endif if (opt_print_ttl_on) { if(ip_header_res->ttl != -1) {