]> git.gsnw.org Git - fping.git/commitdiff
work around NetBSD's lack of IP_RECVTOS
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Wed, 7 Jan 2026 00:04:13 +0000 (01:04 +0100)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sun, 11 Jan 2026 07:20:26 +0000 (08:20 +0100)
NetBSD does not know the IP_RECVTOS socket option.  Thus
conditionally compile setting this option only when it is
defined.

This is the same change as used in the NetBSD package[1],
with thanks to "adam".

[1] https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/net/fping/patches/patch-src_fping.c?rev=1.5;content-type=text%2Fplain

src/fping.c

index ada52550b36ced9c2d24eb7f58d6bce11a8ae573..6147d4059f16e3128d6c77fbbea5717d946a19c6 100644 (file)
@@ -712,11 +712,13 @@ int main(int argc, char **argv)
                 ping_data_size = ICMP_TIMESTAMP_DATA_SIZE;
             } else if (strstr(optparse_state.optlongname, "print-tos") != NULL) {
                 print_tos_flag = 1;
+#if defined(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");
                     }
                 }
+#endif
 #if defined(IPV6) && defined(IPV6_RECVTCLASS)
                 if (socket6 >= 0) {
                     if (setsockopt(socket6, IPPROTO_IPV6, IPV6_RECVTCLASS, &sock_opt_on, sizeof(sock_opt_on))) {