]> git.gsnw.org Git - fping.git/commitdiff
Add IBM i PASE detection develop
authorGerman Service Network <support@gsnw.de>
Fri, 13 Mar 2026 17:00:37 +0000 (18:00 +0100)
committerSebastian <176771227+gsnw-sebast@users.noreply.github.com>
Fri, 27 Mar 2026 10:28:43 +0000 (11:28 +0100)
CHANGELOG.md
configure.ac
src/fping.c
src/output.c

index 480b645615866d9903cc45868c2ec81bcd02d97c..9a8239a563592560db8fb7e7a3a32502c312d0e6 100644 (file)
@@ -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)
index 27454a907bb71932048b3a5d9604bbc5a57aa990..b17f3bb95d76460958d1da24973f1cbf4df50662 100644 (file)
@@ -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 <sys/types.h>
+#include <netinet/in.h>
+#include <sys/socket.h>])
+
 dnl --disable-ipv4
 AC_ARG_ENABLE([ipv4],
   AS_HELP_STRING([--disable-ipv4], [Disable support for pinging IPv4 hosts]))
index 7c875387bd82136e848a64d27fa4578a67c8fd5c..efb4c4fa088e975ac91b2706dbe6a4893dae8fae 100644 (file)
@@ -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));
             }
index b2640c824436b111895b016fdda80e1294bdaedf..c0de11229e09ec302c5013e6e048180b25141bcc 100644 (file)
@@ -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) {