From e8660637ccc3bf2aae163fa7c26216843ae98180 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sat, 19 Aug 2023 22:12:26 +0200 Subject: [PATCH 01/19] Fallback to SO_TIMESTAMP if SO_TIMESTAMPNS is not available --- src/fping.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fping.c b/src/fping.c index 9bda407..5d23f46 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1007,13 +1007,17 @@ int main(int argc, char **argv) int opt = 1; if (socket4 >= 0) { if (setsockopt(socket4, SOL_SOCKET, SO_TIMESTAMPNS, &opt, sizeof(opt))) { - perror("setting SO_TIMESTAMPNS option"); + if (setsockopt(socket4, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) { + perror("setting SO_TIMESTAMPNS and SO_TIMESTAMP option"); + } } } #ifdef IPV6 if (socket6 >= 0) { if (setsockopt(socket6, SOL_SOCKET, SO_TIMESTAMPNS, &opt, sizeof(opt))) { - perror("setting SO_TIMESTAMPNS option (IPv6)"); + if (setsockopt(socket6, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) { + perror("setting SO_TIMESTAMPNS and SO_TIMESTAMP option (IPv6)"); + } } } #endif From 9d7731e7a016641a093712b0a32f17c8eef39620 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sun, 28 May 2023 21:03:22 +0200 Subject: [PATCH 02/19] OpenBSD is not affected by the "broken alpha headers" bug, too. --- src/fping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fping.c b/src/fping.c index 5d23f46..f4dcdcd 100644 --- a/src/fping.c +++ b/src/fping.c @@ -2090,7 +2090,7 @@ int decode_icmp_ipv4( if (!using_sock_dgram4) { struct ip *ip = (struct ip *)reply_buf; -#if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) && !defined(__NetBSD__) +#if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) && !defined(__NetBSD__) && !defined(__OpenBSD__) /* The alpha headers are decidedly broken. * Using an ANSI compiler, it provides ip_vhl instead of ip_hl and * ip_v. So, to get ip_hl, we mask off the bottom four bits. From e597c48d775cfd7a6bb18721380f37c48de54bbe Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sun, 24 Jul 2022 10:54:38 +0200 Subject: [PATCH 03/19] Fixing build warning long int on seqmap.c line 84 --- src/seqmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/seqmap.c b/src/seqmap.c index a1ecdef..4a4e38a 100644 --- a/src/seqmap.c +++ b/src/seqmap.c @@ -41,6 +41,7 @@ #include "options.h" #include "fping.h" +#include #include #include @@ -81,7 +82,7 @@ unsigned int seqmap_add(unsigned int host_nr, unsigned int ping_count, int64_t t * 0, so will be seen as expired */ next_value = &seqmap_map[seqmap_next_id]; if (timestamp - next_value->ping_ts < SEQMAP_TIMEOUT_IN_NS) { - fprintf(stderr, "fping error: not enough sequence numbers available! (expire_timeout=%ld, host_nr=%d, ping_count=%d, seqmap_next_id=%d)\n", + fprintf(stderr, "fping error: not enough sequence numbers available! (expire_timeout=%" PRId64 ", host_nr=%d, ping_count=%d, seqmap_next_id=%d)\n", SEQMAP_TIMEOUT_IN_NS, host_nr, ping_count, seqmap_next_id); exit(4); } From d45438c72308a49a6f21b7fd76e01c8e31496dc4 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sat, 30 Jul 2022 12:39:54 +0200 Subject: [PATCH 04/19] fping: add option to exit immeditely once N hosts have been found --- doc/fping.pod | 5 +++++ src/fping.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/fping.pod b/doc/fping.pod index 7702df1..619e5ef 100644 --- a/doc/fping.pod +++ b/doc/fping.pod @@ -232,6 +232,11 @@ Print B version information. Given a list of hosts, this mode checks if number of reachable hosts is >= N and exits true in that case. +=item B<-X>, B<--fast-reachable>=I + +Given a list of hosts, this mode immediately exits true once N alive hosts +have been found. + =back =head1 EXAMPLES diff --git a/src/fping.c b/src/fping.c index f4dcdcd..1e5af89 100644 --- a/src/fping.c +++ b/src/fping.c @@ -353,7 +353,7 @@ int generate_flag = 0; /* flag for IP list generation */ int verbose_flag, quiet_flag, stats_flag, unreachable_flag, alive_flag; int elapsed_flag, version_flag, count_flag, loop_flag, netdata_flag; int per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag, rdns_flag; -int multif_flag, timeout_flag; +int multif_flag, timeout_flag, fast_reachable; int outage_flag = 0; int timestamp_flag = 0; int random_data_flag = 0; @@ -536,6 +536,7 @@ int main(int argc, char **argv) { "unreach", 'u', OPTPARSE_NONE }, { "version", 'v', OPTPARSE_NONE }, { "reachable", 'x', OPTPARSE_REQUIRED }, + { "fast-reachable", 'X', OPTPARSE_REQUIRED }, #if defined(DEBUG) || defined(_DEBUG) { NULL, 'z', OPTPARSE_REQUIRED }, #endif @@ -750,6 +751,12 @@ int main(int argc, char **argv) usage(1); break; + case 'X': + if (!(min_reachable = (unsigned int)atoi(optparse_state.optarg))) + usage(1); + fast_reachable = 1; + break; + case 'f': filename = optparse_state.optarg; break; @@ -2409,6 +2416,9 @@ int wait_for_reply(int64_t wait_time) /* print "is alive" */ if (h->num_recv == 1) { num_alive++; + if (fast_reachable && num_alive >= min_reachable) + finish_requested = 1; + if (verbose_flag || alive_flag) { printf("%s", h->host); @@ -2944,5 +2954,6 @@ void usage(int is_error) fprintf(out, " -u, --unreach show targets that are unreachable\n"); fprintf(out, " -v, --version show version\n"); fprintf(out, " -x, --reachable=N shows if >=N hosts are reachable or not\n"); + fprintf(out, " -X, --fast-reachable=N exits true immediately when N hosts are found\n"); exit(is_error); } From f94adaf29e8964bc3332a32669bc15f4d5300dee Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sun, 31 Jul 2022 08:53:57 +0200 Subject: [PATCH 05/19] Test for fping: add option to exit immediately once N hosts have been found --- ci/test-10-option-u-x.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ci/test-10-option-u-x.pl b/ci/test-10-option-u-x.pl index f4bb66c..72fc03e 100755 --- a/ci/test-10-option-u-x.pl +++ b/ci/test-10-option-u-x.pl @@ -1,9 +1,11 @@ #!/usr/bin/perl -w -use Test::Command tests => 12; +use Test::Command tests => 18; # -u show targets that are unreachable # -v show version +# -x shows if >=N hosts are reachable or not +# -X exits true immediately when N hosts are found # fping -u { @@ -36,3 +38,19 @@ $cmd->exit_is_num(1); $cmd->stdout_is_eq("Not enough hosts reachable (required: 2, reachable: 1)\n"); $cmd->stderr_is_eq(""); } + +# fping -X +{ +my $cmd = Test::Command->new(cmd => "fping -X 1 --generate 127.0.0.0/29"); +$cmd->exit_is_num(0); +$cmd->stdout_is_eq("Enough hosts reachable (required: 1, reachable: 1)\n"); +$cmd->stderr_is_eq(""); +} + +# fping -X +{ +my $cmd = Test::Command->new(cmd => "fping -X 2 --generate 8.8.0.0/29"); +$cmd->exit_is_num(1); +$cmd->stdout_is_eq("Not enough hosts reachable (required: 2, reachable: 0)\n"); +$cmd->stderr_is_eq(""); +} From c0fbccb977c523ba671afdf0f37de40d26351f77 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 29 Aug 2022 15:41:51 -0700 Subject: [PATCH 06/19] fping: Initialize msghdr struct in a portable way Initializing the structure assuming glibc layout results in compile errors on musl, therefore do partial intialization and then assigning the members individually. Signed-off-by: Khem Raj --- src/fping.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/fping.c b/src/fping.c index 1e5af89..fcb1c81 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1962,15 +1962,13 @@ int receive_packet(int64_t wait_time, reply_buf, reply_buf_len }; - struct msghdr recv_msghdr = { - reply_src_addr, - reply_src_addr_len, - &msg_iov, - 1, - &msg_control, - sizeof(msg_control), - 0 - }; + struct msghdr recv_msghdr = {0}; + recv_msghdr.msg_name = reply_src_addr; + recv_msghdr.msg_namelen = reply_src_addr_len; + recv_msghdr.msg_iov = &msg_iov; + recv_msghdr.msg_iovlen = 1; + recv_msghdr.msg_control = &msg_control; + recv_msghdr.msg_controllen = sizeof(msg_control); #if HAVE_SO_TIMESTAMPNS struct cmsghdr *cmsg; #endif From 86dedacbe72731724799c025b7d1d2a18d2f3e48 Mon Sep 17 00:00:00 2001 From: Vincent OLLIVIER Date: Sat, 26 Nov 2022 23:08:37 -0500 Subject: [PATCH 07/19] Updating documentation regarding root requirements since for --file parameter --- doc/fping.pod | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/fping.pod b/doc/fping.pod index 619e5ef..3d26e2d 100644 --- a/doc/fping.pod +++ b/doc/fping.pod @@ -97,10 +97,7 @@ Show elapsed (round-trip) time of packets. =item B<-f>, B<--file> -Read list of targets from a file. This option can only be used by the root -user. Regular users should pipe in the file via stdin: - - $ fping < targets_file +Read list of targets from a file. =item B<-g>, B<--generate> I From d95370cbb08973ff0a8dacd05f65244a22ca4eb7 Mon Sep 17 00:00:00 2001 From: ilyam8 Date: Wed, 1 Jun 2022 19:29:55 +0300 Subject: [PATCH 08/19] update netdata link --- doc/fping.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fping.pod b/doc/fping.pod index 3d26e2d..83dbaa3 100644 --- a/doc/fping.pod +++ b/doc/fping.pod @@ -151,7 +151,7 @@ to print hostnames in the output. =item B<-N>, B<--netdata> -Format output for netdata (-l -Q are required). See: L +Format output for netdata (-l -Q are required). See: L =item B<-o>, B<--outage> From 16108c4fa750e3cd9bf950239398ae4dc2cc29f0 Mon Sep 17 00:00:00 2001 From: ilyam8 Date: Wed, 1 Jun 2022 19:33:24 +0300 Subject: [PATCH 09/19] remove www --- doc/fping.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fping.pod b/doc/fping.pod index 83dbaa3..faa327b 100644 --- a/doc/fping.pod +++ b/doc/fping.pod @@ -151,7 +151,7 @@ to print hostnames in the output. =item B<-N>, B<--netdata> -Format output for netdata (-l -Q are required). See: L +Format output for netdata (-l -Q are required). See: L =item B<-o>, B<--outage> From a6c314516cb2dc8514ac77ba847b402c39440e89 Mon Sep 17 00:00:00 2001 From: ilyam8 Date: Tue, 12 Apr 2022 10:35:14 +0300 Subject: [PATCH 10/19] remove host from netdata chart titles --- src/fping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fping.c b/src/fping.c index fcb1c81..e02dab5 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1672,7 +1672,7 @@ void print_netdata(void) h = table[i]; if (!sent_charts) { - printf("CHART fping.%s_packets '' 'FPing Packets for host %s' packets '%s' fping.packets line 110020 %.0f\n", h->name, h->host, h->host, report_interval / 1e9); + printf("CHART fping.%s_packets '' 'FPing Packets' packets '%s' fping.packets line 110020 %.0f\n", h->name, h->host, report_interval / 1e9); printf("DIMENSION xmt sent absolute 1 1\n"); printf("DIMENSION rcv received absolute 1 1\n"); } @@ -1683,7 +1683,7 @@ void print_netdata(void) printf("END\n"); if (!sent_charts) { - printf("CHART fping.%s_quality '' 'FPing Quality for host %s' percentage '%s' fping.quality area 110010 %.0f\n", h->name, h->host, h->host, report_interval / 1e9); + printf("CHART fping.%s_quality '' 'FPing Quality' percentage '%s' fping.quality area 110010 %.0f\n", h->name, h->host, report_interval / 1e9); printf("DIMENSION returned '' absolute 1 1\n"); /* printf("DIMENSION lost '' absolute 1 1\n"); */ } @@ -1700,7 +1700,7 @@ void print_netdata(void) printf("END\n"); if (!sent_charts) { - printf("CHART fping.%s_latency '' 'FPing Latency for host %s' ms '%s' fping.latency area 110000 %.0f\n", h->name, h->host, h->host, report_interval / 1e9); + printf("CHART fping.%s_latency '' 'FPing Latency' ms '%s' fping.latency area 110000 %.0f\n", h->name, h->host, report_interval / 1e9); printf("DIMENSION min minimum absolute 1 1000000\n"); printf("DIMENSION max maximum absolute 1 1000000\n"); printf("DIMENSION avg average absolute 1 1000000\n"); From 59f32cefb2551c17be3c88b4ab544fe1f2e2a62c Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sun, 3 Sep 2023 09:30:06 +0200 Subject: [PATCH 11/19] Repair the faulty test 15 --- ci/test-15-netdata.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/test-15-netdata.pl b/ci/test-15-netdata.pl index da20636..83dc439 100755 --- a/ci/test-15-netdata.pl +++ b/ci/test-15-netdata.pl @@ -9,19 +9,19 @@ plan tests => 3; { my $cmd = Test::Command->new(cmd => "fping -c 2 -Q 1 -N 127.0.0.1"); $cmd->exit_is_num(0); -$cmd->stdout_like(qr{CHART fping\.127_0_0_1_packets '' 'FPing Packets for host 127\.0\.0\.1' packets '127.0.0.1' fping\.packets line 110020 1 +$cmd->stdout_like(qr{CHART fping\.127_0_0_1_packets '' 'FPing Packets' packets '127.0.0.1' fping\.packets line 110020 1 DIMENSION xmt sent absolute 1 1 DIMENSION rcv received absolute 1 1 BEGIN fping\.127_0_0_1_packets SET xmt = 1 SET rcv = 1 END -CHART fping\.127_0_0_1_quality '' 'FPing Quality for host 127\.0\.0\.1' percentage '127.0.0.1' fping\.quality area 110010 1 +CHART fping\.127_0_0_1_quality '' 'FPing Quality' percentage '127.0.0.1' fping\.quality area 110010 1 DIMENSION returned '' absolute 1 1 BEGIN fping\.127_0_0_1_quality SET returned = 100 END -CHART fping\.127_0_0_1_latency '' 'FPing Latency for host 127\.0\.0\.1' ms '127.0.0.1' fping\.latency area 110000 1 +CHART fping\.127_0_0_1_latency '' 'FPing Latency' ms '127.0.0.1' fping\.latency area 110000 1 DIMENSION min minimum absolute 1 1000000 DIMENSION max maximum absolute 1 1000000 DIMENSION avg average absolute 1 1000000 From 55ad83898f6abc4377dbf73a833fdb1874e25091 Mon Sep 17 00:00:00 2001 From: darless1 <3382617+darless1@users.noreply.github.com> Date: Tue, 6 Dec 2022 12:52:41 -0600 Subject: [PATCH 12/19] Dockerfile for fping --- .dockerignore | 30 ++++++++++++++++++++++++++++++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d4d2ab9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +.*.swp +*.tar.gz +*~ +src/*.gcno +src/*.gcda +src/*.gcov +src/tags +.deps +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +compile +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +src/*.o +src/fping +src/fping6 +stamp-h1 +doc/fping.8 +doc/fping6.8 +ci/build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbdda2b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:20.04 + +# Base +RUN apt-get update && apt-get install -y \ + build-essential \ + automake \ + m4 + +# Add source code +COPY ./ /app + +# Compile +WORKDIR /app +RUN autoreconf --install +RUN ./configure && make && make install +ENTRYPOINT ["fping"] \ No newline at end of file From e20939ebfe132b296334072c4edd2a9710f8f486 Mon Sep 17 00:00:00 2001 From: darless1 <3382617+darless1@users.noreply.github.com> Date: Tue, 6 Dec 2022 13:03:16 -0600 Subject: [PATCH 13/19] Move to contrib folder --- contrib/Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 contrib/Dockerfile diff --git a/contrib/Dockerfile b/contrib/Dockerfile new file mode 100644 index 0000000..dbdda2b --- /dev/null +++ b/contrib/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:20.04 + +# Base +RUN apt-get update && apt-get install -y \ + build-essential \ + automake \ + m4 + +# Add source code +COPY ./ /app + +# Compile +WORKDIR /app +RUN autoreconf --install +RUN ./configure && make && make install +ENTRYPOINT ["fping"] \ No newline at end of file From 8601d1ba709f97d8eb68d411791f34a56b0eb12c Mon Sep 17 00:00:00 2001 From: darless <3382617+darless@users.noreply.github.com> Date: Thu, 31 Aug 2023 10:28:21 -0500 Subject: [PATCH 14/19] Remove dockerfile from root --- Dockerfile | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index dbdda2b..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:20.04 - -# Base -RUN apt-get update && apt-get install -y \ - build-essential \ - automake \ - m4 - -# Add source code -COPY ./ /app - -# Compile -WORKDIR /app -RUN autoreconf --install -RUN ./configure && make && make install -ENTRYPOINT ["fping"] \ No newline at end of file From 88091f7c94080b4c5916cb9d25f89e20bb34e619 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sat, 30 Sep 2023 21:12:59 +0200 Subject: [PATCH 15/19] Checking obsolete macro AC_GNU_SOURCE as of autoconf-2.62 --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f70a4a7..8cede20 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,8 @@ dnl Minimum Autoconf version required. AC_PREREQ(2.59) AC_INIT([fping],[5.1]) -AC_GNU_SOURCE + +m4_ifdef([AC_AUTOCONF_VERSION],[AC_USE_SYSTEM_EXTENSIONS], [AC_GNU_SOURCE]) dnl --disable-ipv4 AC_ARG_ENABLE([ipv4], From b8e413f5ba0827dcbc737a26ec8e270ca674bc9f Mon Sep 17 00:00:00 2001 From: German Service Network Date: Wed, 1 Nov 2023 08:39:57 +0100 Subject: [PATCH 16/19] Checking obsolete macro AC_PROG_CC_STDC as of autoconf-2.70 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8cede20..f75efd5 100644 --- a/configure.ac +++ b/configure.ac @@ -60,7 +60,7 @@ dnl Checks for programs. AC_PROG_CC AM_PROG_CC_C_O -AC_PROG_CC_STDC +m4_version_prereq([2.70],,[AC_PROG_CC_STDC]) AC_PROG_CPP AC_PROG_INSTALL From 163fcdb1ed8ea7cd924ef420ecab13cadd311044 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Fri, 15 Sep 2023 21:41:42 +0200 Subject: [PATCH 17/19] Fix deprected github action ubuntu-18.04 to ubuntu-22.04 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c724ce..60deea1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-18.04, ubuntu-20.04] + os: [ubuntu-20.04, ubuntu-22.04] steps: - name: Checkout repository uses: actions/checkout@v2 From 7351afdd89beed0107b5d2defe4153312c3775ba Mon Sep 17 00:00:00 2001 From: German Service Network Date: Sun, 10 Sep 2023 10:33:33 +0200 Subject: [PATCH 18/19] Move the OS detection to configure.ac script to set the use of clock_realtime --- configure.ac | 17 +++++++++++++++++ src/fping.c | 11 ++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index f75efd5..fcc0787 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,22 @@ AC_INIT([fping],[5.1]) m4_ifdef([AC_AUTOCONF_VERSION],[AC_USE_SYSTEM_EXTENSIONS], [AC_GNU_SOURCE]) +# Detect Operatingsystem +AC_CANONICAL_HOST +only_clock_realtime=no + +case "${host_os}" in + darwin*) + only_clock_realtime=yes + ;; + *freebsd*) + only_clock_realtime=yes + ;; + *openbsd*) + only_clock_realtime=yes + ;; +esac + dnl --disable-ipv4 AC_ARG_ENABLE([ipv4], AS_HELP_STRING([--disable-ipv4], [Disable support for pinging IPv4 hosts])) @@ -44,6 +60,7 @@ dnl Test if --enable-timestamp is explicitely enabled and make an error if this AS_IF([test "x$enable_timestamp" = "xyes" -a "x$have_so_timestamp" = "xno"], [ AC_MSG_ERROR([--enable-timestamp not supported on this platform]) ]) +AS_IF([test "x$only_clock_realtime" = "xyes"], [AC_DEFINE(ONLY_CLOCK_REALTIME, [1], [ONLY_CLOCK_REALTIME is defined])]) AC_ARG_ENABLE([safe-limits], AS_HELP_STRING([--enable-safe-limits], [Restrict timing parameters (-i, -p) within "safe" limits])) diff --git a/src/fping.c b/src/fping.c index e02dab5..27711c8 100644 --- a/src/fping.c +++ b/src/fping.c @@ -116,15 +116,16 @@ extern int h_errno; /*** Constants ***/ -#if HAVE_SO_TIMESTAMPNS -#define CLOCKID CLOCK_REALTIME -#endif - /* CLOCK_MONTONIC starts under macOS, OpenBSD and FreeBSD with undefined positive point and can not be use * see github PR #217 + * The configure script detect the predefined operating systems an set CLOCK_REALTIME using over ONLY_CLOCK_REALTIME variable */ +#if HAVE_SO_TIMESTAMPNS || ONLY_CLOCK_REALTIME +#define CLOCKID CLOCK_REALTIME +#endif + #if !defined(CLOCKID) -#if defined(CLOCK_MONOTONIC) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) +#if defined(CLOCK_MONOTONIC) #define CLOCKID CLOCK_MONOTONIC #else #define CLOCKID CLOCK_REALTIME From a3f4c573bfd1ddfc71d2fa672f51c41047473a53 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Fri, 15 Sep 2023 21:20:14 +0200 Subject: [PATCH 19/19] Change obsolete macro from AC_CANONICAL_SYSTEM to AC_CANONICAL_TARGET --- configure.ac | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index fcc0787..cfe702f 100644 --- a/configure.ac +++ b/configure.ac @@ -8,11 +8,11 @@ AC_INIT([fping],[5.1]) m4_ifdef([AC_AUTOCONF_VERSION],[AC_USE_SYSTEM_EXTENSIONS], [AC_GNU_SOURCE]) # Detect Operatingsystem -AC_CANONICAL_HOST +AC_CANONICAL_TARGET only_clock_realtime=no -case "${host_os}" in - darwin*) +case "${target}" in + *darwin*) only_clock_realtime=yes ;; *freebsd*) @@ -67,7 +67,6 @@ AC_ARG_ENABLE([safe-limits], AS_IF([test "x$enable_safe_limits" = "xyes"], [ AC_DEFINE(FPING_SAFE_LIMITS, [1], [safe limits should be enforced])]) -AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AM_MAINTAINER_MODE