New upstream version 3.16
Axel Beckert
7 years ago
0 | Unreleased | |
1 | * INCOMPATIBILITY WARNING: | |
2 | fping and fping6 are now unified into one binary. This means that for | |
3 | example doing 'fping www.google.com' is going to ping the IPv6 IP of | |
4 | www.google.com on IPv6-enabled hosts. If you need exact compatibility with | |
5 | old versions, you can: | |
6 | - compile fping with --disable-ipv6 (or use a wrapper, and call 'fping -4') | |
7 | - compile fping with --enable-ipv6 and rename it to fping6 (same as 'fping -6') | |
8 | ||
9 | * (feature) Unified 'fping' and 'fping6' into one binary | |
10 | * (feature) New option '-4' to force IPv4 | |
11 | * (feature) New option '-6' to force IPv6 | |
0 | 2017-02-09 David Schweikert <david@schweikert.ch> | |
1 | * Version 3.16 | |
12 | 2 | * (feature) Support kernel-timestamping of received packets (#46) |
13 | 3 | * (feature) Simplify restrictions: only -i >= 1 and -p >= 10 are enforced now |
14 | * (feature) --enable-ipv6 is now default (you can use --disable-ipv6 to disable IPv6 support) | |
15 | 4 | * (bugfix) Fix option -m to return all IPs of a hostname |
16 | 5 | * (bugfix) Fix option -H (ttl) for IPv6 |
17 | 6 | * (bugfix) Fix option -M (don't fragment) for IPv6 |
80 | 80 | subdir = . |
81 | 81 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
82 | 82 | $(top_srcdir)/configure $(am__configure_deps) \ |
83 | $(srcdir)/config.h.in COPYING ChangeLog INSTALL README TODO \ | |
84 | compile config.guess config.sub depcomp install-sh missing | |
83 | $(srcdir)/config.h.in COPYING ChangeLog INSTALL README compile \ | |
84 | config.guess config.sub install-sh missing | |
85 | 85 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
86 | 86 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
87 | 87 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
102 | 102 | # configured tree to be moved without reconfiguration. |
103 | 103 | |
104 | 104 | AC_DEFUN([AM_AUX_DIR_EXPAND], |
105 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl | |
106 | # Expand $ac_aux_dir to an absolute path. | |
107 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
105 | [dnl Rely on autoconf to set up CDPATH properly. | |
106 | AC_PREREQ([2.50])dnl | |
107 | # expand $ac_aux_dir to an absolute path | |
108 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
108 | 109 | ]) |
109 | 110 | |
110 | 111 | # AM_CONDITIONAL -*- Autoconf -*- |
571 | 572 | END |
572 | 573 | AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) |
573 | 574 | fi |
574 | fi | |
575 | ]) | |
575 | fi]) | |
576 | 576 | |
577 | 577 | dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not |
578 | 578 | dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further |
0 | 0 | #! /bin/sh |
1 | 1 | # Attempt to guess a canonical system name. |
2 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
3 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, | |
4 | # 2011, 2012 Free Software Foundation, Inc. | |
5 | ||
6 | timestamp='2012-02-10' | |
2 | # Copyright 1992-2013 Free Software Foundation, Inc. | |
3 | ||
4 | timestamp='2013-11-29' | |
7 | 5 | |
8 | 6 | # This file is free software; you can redistribute it and/or modify it |
9 | 7 | # under the terms of the GNU General Public License as published by |
10 | # the Free Software Foundation; either version 2 of the License, or | |
8 | # the Free Software Foundation; either version 3 of the License, or | |
11 | 9 | # (at your option) any later version. |
12 | 10 | # |
13 | 11 | # This program is distributed in the hope that it will be useful, but |
21 | 19 | # As a special exception to the GNU General Public License, if you |
22 | 20 | # distribute this file as part of a program that contains a |
23 | 21 | # configuration script generated by Autoconf, you may include it under |
24 | # the same distribution terms that you use for the rest of that program. | |
25 | ||
26 | ||
27 | # Originally written by Per Bothner. Please send patches (context | |
28 | # diff format) to <config-patches@gnu.org> and include a ChangeLog | |
29 | # entry. | |
22 | # the same distribution terms that you use for the rest of that | |
23 | # program. This Exception is an additional permission under section 7 | |
24 | # of the GNU General Public License, version 3 ("GPLv3"). | |
30 | 25 | # |
31 | # This script attempts to guess a canonical system name similar to | |
32 | # config.sub. If it succeeds, it prints the system name on stdout, and | |
33 | # exits with 0. Otherwise, it exits with 1. | |
26 | # Originally written by Per Bothner. | |
34 | 27 | # |
35 | 28 | # You can get the latest version of this script from: |
36 | 29 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD |
30 | # | |
31 | # Please send patches with a ChangeLog entry to config-patches@gnu.org. | |
32 | ||
37 | 33 | |
38 | 34 | me=`echo "$0" | sed -e 's,.*/,,'` |
39 | 35 | |
53 | 49 | GNU config.guess ($timestamp) |
54 | 50 | |
55 | 51 | Originally written by Per Bothner. |
56 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | |
57 | 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | |
58 | Free Software Foundation, Inc. | |
52 | Copyright 1992-2013 Free Software Foundation, Inc. | |
59 | 53 | |
60 | 54 | This is free software; see the source for copying conditions. There is NO |
61 | 55 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." |
136 | 130 | UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown |
137 | 131 | UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown |
138 | 132 | UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown |
133 | ||
134 | case "${UNAME_SYSTEM}" in | |
135 | Linux|GNU|GNU/*) | |
136 | # If the system lacks a compiler, then just pick glibc. | |
137 | # We could probably try harder. | |
138 | LIBC=gnu | |
139 | ||
140 | eval $set_cc_for_build | |
141 | cat <<-EOF > $dummy.c | |
142 | #include <features.h> | |
143 | #if defined(__UCLIBC__) | |
144 | LIBC=uclibc | |
145 | #elif defined(__dietlibc__) | |
146 | LIBC=dietlibc | |
147 | #else | |
148 | LIBC=gnu | |
149 | #endif | |
150 | EOF | |
151 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` | |
152 | ;; | |
153 | esac | |
139 | 154 | |
140 | 155 | # Note: order is significant - the case branches are not exclusive. |
141 | 156 | |
198 | 213 | # contains redundant information, the shorter form: |
199 | 214 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. |
200 | 215 | echo "${machine}-${os}${release}" |
216 | exit ;; | |
217 | *:Bitrig:*:*) | |
218 | UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` | |
219 | echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} | |
201 | 220 | exit ;; |
202 | 221 | *:OpenBSD:*:*) |
203 | 222 | UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` |
301 | 320 | arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) |
302 | 321 | echo arm-acorn-riscix${UNAME_RELEASE} |
303 | 322 | exit ;; |
304 | arm:riscos:*:*|arm:RISCOS:*:*) | |
323 | arm*:riscos:*:*|arm*:RISCOS:*:*) | |
305 | 324 | echo arm-unknown-riscos |
306 | 325 | exit ;; |
307 | 326 | SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) |
800 | 819 | i*:CYGWIN*:*) |
801 | 820 | echo ${UNAME_MACHINE}-pc-cygwin |
802 | 821 | exit ;; |
822 | *:MINGW64*:*) | |
823 | echo ${UNAME_MACHINE}-pc-mingw64 | |
824 | exit ;; | |
803 | 825 | *:MINGW*:*) |
804 | 826 | echo ${UNAME_MACHINE}-pc-mingw32 |
805 | 827 | exit ;; |
851 | 873 | exit ;; |
852 | 874 | *:GNU:*:*) |
853 | 875 | # the GNU system |
854 | echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` | |
876 | echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` | |
855 | 877 | exit ;; |
856 | 878 | *:GNU/*:*:*) |
857 | 879 | # other systems with GNU libc and userland |
858 | echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu | |
880 | echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} | |
859 | 881 | exit ;; |
860 | 882 | i*86:Minix:*:*) |
861 | 883 | echo ${UNAME_MACHINE}-pc-minix |
862 | 884 | exit ;; |
863 | 885 | aarch64:Linux:*:*) |
864 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
886 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
865 | 887 | exit ;; |
866 | 888 | aarch64_be:Linux:*:*) |
867 | 889 | UNAME_MACHINE=aarch64_be |
868 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
890 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
869 | 891 | exit ;; |
870 | 892 | alpha:Linux:*:*) |
871 | 893 | case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in |
878 | 900 | EV68*) UNAME_MACHINE=alphaev68 ;; |
879 | 901 | esac |
880 | 902 | objdump --private-headers /bin/sh | grep -q ld.so.1 |
881 | if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi | |
882 | echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} | |
903 | if test "$?" = 0 ; then LIBC="gnulibc1" ; fi | |
904 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
905 | exit ;; | |
906 | arc:Linux:*:* | arceb:Linux:*:*) | |
907 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
883 | 908 | exit ;; |
884 | 909 | arm*:Linux:*:*) |
885 | 910 | eval $set_cc_for_build |
886 | 911 | if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ |
887 | 912 | | grep -q __ARM_EABI__ |
888 | 913 | then |
889 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
914 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
890 | 915 | else |
891 | 916 | if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ |
892 | 917 | | grep -q __ARM_PCS_VFP |
893 | 918 | then |
894 | echo ${UNAME_MACHINE}-unknown-linux-gnueabi | |
919 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi | |
895 | 920 | else |
896 | echo ${UNAME_MACHINE}-unknown-linux-gnueabihf | |
921 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf | |
897 | 922 | fi |
898 | 923 | fi |
899 | 924 | exit ;; |
900 | 925 | avr32*:Linux:*:*) |
901 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
926 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
902 | 927 | exit ;; |
903 | 928 | cris:Linux:*:*) |
904 | echo ${UNAME_MACHINE}-axis-linux-gnu | |
929 | echo ${UNAME_MACHINE}-axis-linux-${LIBC} | |
905 | 930 | exit ;; |
906 | 931 | crisv32:Linux:*:*) |
907 | echo ${UNAME_MACHINE}-axis-linux-gnu | |
932 | echo ${UNAME_MACHINE}-axis-linux-${LIBC} | |
908 | 933 | exit ;; |
909 | 934 | frv:Linux:*:*) |
910 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
935 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
911 | 936 | exit ;; |
912 | 937 | hexagon:Linux:*:*) |
913 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
938 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
914 | 939 | exit ;; |
915 | 940 | i*86:Linux:*:*) |
916 | LIBC=gnu | |
917 | eval $set_cc_for_build | |
918 | sed 's/^ //' << EOF >$dummy.c | |
919 | #ifdef __dietlibc__ | |
920 | LIBC=dietlibc | |
921 | #endif | |
922 | EOF | |
923 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` | |
924 | echo "${UNAME_MACHINE}-pc-linux-${LIBC}" | |
941 | echo ${UNAME_MACHINE}-pc-linux-${LIBC} | |
925 | 942 | exit ;; |
926 | 943 | ia64:Linux:*:*) |
927 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
944 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
928 | 945 | exit ;; |
929 | 946 | m32r*:Linux:*:*) |
930 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
947 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
931 | 948 | exit ;; |
932 | 949 | m68*:Linux:*:*) |
933 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
950 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
934 | 951 | exit ;; |
935 | 952 | mips:Linux:*:* | mips64:Linux:*:*) |
936 | 953 | eval $set_cc_for_build |
949 | 966 | #endif |
950 | 967 | EOF |
951 | 968 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` |
952 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } | |
969 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } | |
953 | 970 | ;; |
971 | or1k:Linux:*:*) | |
972 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
973 | exit ;; | |
954 | 974 | or32:Linux:*:*) |
955 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
975 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
956 | 976 | exit ;; |
957 | 977 | padre:Linux:*:*) |
958 | echo sparc-unknown-linux-gnu | |
978 | echo sparc-unknown-linux-${LIBC} | |
959 | 979 | exit ;; |
960 | 980 | parisc64:Linux:*:* | hppa64:Linux:*:*) |
961 | echo hppa64-unknown-linux-gnu | |
981 | echo hppa64-unknown-linux-${LIBC} | |
962 | 982 | exit ;; |
963 | 983 | parisc:Linux:*:* | hppa:Linux:*:*) |
964 | 984 | # Look for CPU level |
965 | 985 | case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in |
966 | PA7*) echo hppa1.1-unknown-linux-gnu ;; | |
967 | PA8*) echo hppa2.0-unknown-linux-gnu ;; | |
968 | *) echo hppa-unknown-linux-gnu ;; | |
986 | PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; | |
987 | PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; | |
988 | *) echo hppa-unknown-linux-${LIBC} ;; | |
969 | 989 | esac |
970 | 990 | exit ;; |
971 | 991 | ppc64:Linux:*:*) |
972 | echo powerpc64-unknown-linux-gnu | |
992 | echo powerpc64-unknown-linux-${LIBC} | |
973 | 993 | exit ;; |
974 | 994 | ppc:Linux:*:*) |
975 | echo powerpc-unknown-linux-gnu | |
995 | echo powerpc-unknown-linux-${LIBC} | |
996 | exit ;; | |
997 | ppc64le:Linux:*:*) | |
998 | echo powerpc64le-unknown-linux-${LIBC} | |
999 | exit ;; | |
1000 | ppcle:Linux:*:*) | |
1001 | echo powerpcle-unknown-linux-${LIBC} | |
976 | 1002 | exit ;; |
977 | 1003 | s390:Linux:*:* | s390x:Linux:*:*) |
978 | echo ${UNAME_MACHINE}-ibm-linux | |
1004 | echo ${UNAME_MACHINE}-ibm-linux-${LIBC} | |
979 | 1005 | exit ;; |
980 | 1006 | sh64*:Linux:*:*) |
981 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1007 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
982 | 1008 | exit ;; |
983 | 1009 | sh*:Linux:*:*) |
984 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1010 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
985 | 1011 | exit ;; |
986 | 1012 | sparc:Linux:*:* | sparc64:Linux:*:*) |
987 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1013 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
988 | 1014 | exit ;; |
989 | 1015 | tile*:Linux:*:*) |
990 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1016 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
991 | 1017 | exit ;; |
992 | 1018 | vax:Linux:*:*) |
993 | echo ${UNAME_MACHINE}-dec-linux-gnu | |
1019 | echo ${UNAME_MACHINE}-dec-linux-${LIBC} | |
994 | 1020 | exit ;; |
995 | 1021 | x86_64:Linux:*:*) |
996 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1022 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
997 | 1023 | exit ;; |
998 | 1024 | xtensa*:Linux:*:*) |
999 | echo ${UNAME_MACHINE}-unknown-linux-gnu | |
1025 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} | |
1000 | 1026 | exit ;; |
1001 | 1027 | i*86:DYNIX/ptx:4*:*) |
1002 | 1028 | # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. |
1200 | 1226 | BePC:Haiku:*:*) # Haiku running on Intel PC compatible. |
1201 | 1227 | echo i586-pc-haiku |
1202 | 1228 | exit ;; |
1229 | x86_64:Haiku:*:*) | |
1230 | echo x86_64-unknown-haiku | |
1231 | exit ;; | |
1203 | 1232 | SX-4:SUPER-UX:*:*) |
1204 | 1233 | echo sx4-nec-superux${UNAME_RELEASE} |
1205 | 1234 | exit ;; |
1226 | 1255 | exit ;; |
1227 | 1256 | *:Darwin:*:*) |
1228 | 1257 | UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown |
1229 | case $UNAME_PROCESSOR in | |
1230 | i386) | |
1231 | eval $set_cc_for_build | |
1232 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then | |
1233 | if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ | |
1234 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ | |
1235 | grep IS_64BIT_ARCH >/dev/null | |
1236 | then | |
1237 | UNAME_PROCESSOR="x86_64" | |
1238 | fi | |
1239 | fi ;; | |
1240 | unknown) UNAME_PROCESSOR=powerpc ;; | |
1241 | esac | |
1258 | eval $set_cc_for_build | |
1259 | if test "$UNAME_PROCESSOR" = unknown ; then | |
1260 | UNAME_PROCESSOR=powerpc | |
1261 | fi | |
1262 | if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then | |
1263 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then | |
1264 | if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ | |
1265 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ | |
1266 | grep IS_64BIT_ARCH >/dev/null | |
1267 | then | |
1268 | case $UNAME_PROCESSOR in | |
1269 | i386) UNAME_PROCESSOR=x86_64 ;; | |
1270 | powerpc) UNAME_PROCESSOR=powerpc64 ;; | |
1271 | esac | |
1272 | fi | |
1273 | fi | |
1274 | elif test "$UNAME_PROCESSOR" = i386 ; then | |
1275 | # Avoid executing cc on OS X 10.9, as it ships with a stub | |
1276 | # that puts up a graphical alert prompting to install | |
1277 | # developer tools. Any system running Mac OS X 10.7 or | |
1278 | # later (Darwin 11 and later) is required to have a 64-bit | |
1279 | # processor. This is not true of the ARM version of Darwin | |
1280 | # that Apple uses in portable devices. | |
1281 | UNAME_PROCESSOR=x86_64 | |
1282 | fi | |
1242 | 1283 | echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} |
1243 | 1284 | exit ;; |
1244 | 1285 | *:procnto*:*:* | *:QNX:[0123456789]*:*) |
1255 | 1296 | NEO-?:NONSTOP_KERNEL:*:*) |
1256 | 1297 | echo neo-tandem-nsk${UNAME_RELEASE} |
1257 | 1298 | exit ;; |
1258 | NSE-?:NONSTOP_KERNEL:*:*) | |
1299 | NSE-*:NONSTOP_KERNEL:*:*) | |
1259 | 1300 | echo nse-tandem-nsk${UNAME_RELEASE} |
1260 | 1301 | exit ;; |
1261 | 1302 | NSR-?:NONSTOP_KERNEL:*:*) |
1328 | 1369 | echo ${UNAME_MACHINE}-unknown-esx |
1329 | 1370 | exit ;; |
1330 | 1371 | esac |
1331 | ||
1332 | #echo '(No uname command or uname output not recognized.)' 1>&2 | |
1333 | #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 | |
1334 | 1372 | |
1335 | 1373 | eval $set_cc_for_build |
1336 | 1374 | cat >$dummy.c <<EOF |
0 | 0 | #! /bin/sh |
1 | 1 | # Configuration validation subroutine script. |
2 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
3 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, | |
4 | # 2011, 2012 Free Software Foundation, Inc. | |
5 | ||
6 | timestamp='2012-04-18' | |
7 | ||
8 | # This file is (in principle) common to ALL GNU software. | |
9 | # The presence of a machine in this file suggests that SOME GNU software | |
10 | # can handle that machine. It does not imply ALL GNU software can. | |
11 | # | |
12 | # This file is free software; you can redistribute it and/or modify | |
13 | # it under the terms of the GNU General Public License as published by | |
14 | # the Free Software Foundation; either version 2 of the License, or | |
2 | # Copyright 1992-2013 Free Software Foundation, Inc. | |
3 | ||
4 | timestamp='2013-10-01' | |
5 | ||
6 | # This file is free software; you can redistribute it and/or modify it | |
7 | # under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 3 of the License, or | |
15 | 9 | # (at your option) any later version. |
16 | 10 | # |
17 | # This program is distributed in the hope that it will be useful, | |
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | # GNU General Public License for more details. | |
11 | # This program is distributed in the hope that it will be useful, but | |
12 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # General Public License for more details. | |
21 | 15 | # |
22 | 16 | # You should have received a copy of the GNU General Public License |
23 | 17 | # along with this program; if not, see <http://www.gnu.org/licenses/>. |
25 | 19 | # As a special exception to the GNU General Public License, if you |
26 | 20 | # distribute this file as part of a program that contains a |
27 | 21 | # configuration script generated by Autoconf, you may include it under |
28 | # the same distribution terms that you use for the rest of that program. | |
29 | ||
30 | ||
31 | # Please send patches to <config-patches@gnu.org>. Submit a context | |
32 | # diff and a properly formatted GNU ChangeLog entry. | |
22 | # the same distribution terms that you use for the rest of that | |
23 | # program. This Exception is an additional permission under section 7 | |
24 | # of the GNU General Public License, version 3 ("GPLv3"). | |
25 | ||
26 | ||
27 | # Please send patches with a ChangeLog entry to config-patches@gnu.org. | |
33 | 28 | # |
34 | 29 | # Configuration subroutine to validate and canonicalize a configuration type. |
35 | 30 | # Supply the specified configuration type as an argument. |
72 | 67 | version="\ |
73 | 68 | GNU config.sub ($timestamp) |
74 | 69 | |
75 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | |
76 | 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | |
77 | Free Software Foundation, Inc. | |
70 | Copyright 1992-2013 Free Software Foundation, Inc. | |
78 | 71 | |
79 | 72 | This is free software; see the source for copying conditions. There is NO |
80 | 73 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." |
122 | 115 | maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` |
123 | 116 | case $maybe_os in |
124 | 117 | nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ |
125 | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ | |
118 | linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ | |
126 | 119 | knetbsd*-gnu* | netbsd*-gnu* | \ |
127 | 120 | kopensolaris*-gnu* | \ |
128 | 121 | storm-chaos* | os2-emx* | rtmk-nova*) |
155 | 148 | -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ |
156 | 149 | -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ |
157 | 150 | -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ |
158 | -apple | -axis | -knuth | -cray | -microblaze) | |
151 | -apple | -axis | -knuth | -cray | -microblaze*) | |
159 | 152 | os= |
160 | 153 | basic_machine=$1 |
161 | 154 | ;; |
258 | 251 | | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ |
259 | 252 | | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ |
260 | 253 | | am33_2.0 \ |
261 | | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | |
262 | | be32 | be64 \ | |
254 | | arc | arceb \ | |
255 | | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | |
256 | | avr | avr32 \ | |
257 | | be32 | be64 \ | |
263 | 258 | | bfin \ |
264 | | c4x | clipper \ | |
259 | | c4x | c8051 | clipper \ | |
265 | 260 | | d10v | d30v | dlx | dsp16xx \ |
266 | 261 | | epiphany \ |
267 | 262 | | fido | fr30 | frv \ |
269 | 264 | | hexagon \ |
270 | 265 | | i370 | i860 | i960 | ia64 \ |
271 | 266 | | ip2k | iq2000 \ |
267 | | k1om \ | |
272 | 268 | | le32 | le64 \ |
273 | 269 | | lm32 \ |
274 | 270 | | m32c | m32r | m32rle | m68000 | m68k | m88k \ |
275 | | maxq | mb | microblaze | mcore | mep | metag \ | |
271 | | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | |
276 | 272 | | mips | mipsbe | mipseb | mipsel | mipsle \ |
277 | 273 | | mips16 \ |
278 | 274 | | mips64 | mips64el \ |
290 | 286 | | mipsisa64r2 | mipsisa64r2el \ |
291 | 287 | | mipsisa64sb1 | mipsisa64sb1el \ |
292 | 288 | | mipsisa64sr71k | mipsisa64sr71kel \ |
289 | | mipsr5900 | mipsr5900el \ | |
293 | 290 | | mipstx39 | mipstx39el \ |
294 | 291 | | mn10200 | mn10300 \ |
295 | 292 | | moxie \ |
296 | 293 | | mt \ |
297 | 294 | | msp430 \ |
298 | 295 | | nds32 | nds32le | nds32be \ |
299 | | nios | nios2 \ | |
296 | | nios | nios2 | nios2eb | nios2el \ | |
300 | 297 | | ns16k | ns32k \ |
301 | 298 | | open8 \ |
302 | | or32 \ | |
299 | | or1k | or32 \ | |
303 | 300 | | pdp10 | pdp11 | pj | pjl \ |
304 | 301 | | powerpc | powerpc64 | powerpc64le | powerpcle \ |
305 | 302 | | pyramid \ |
327 | 324 | c6x) |
328 | 325 | basic_machine=tic6x-unknown |
329 | 326 | ;; |
330 | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) | |
327 | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) | |
331 | 328 | basic_machine=$basic_machine-unknown |
332 | 329 | os=-none |
333 | 330 | ;; |
369 | 366 | | aarch64-* | aarch64_be-* \ |
370 | 367 | | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ |
371 | 368 | | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ |
372 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | |
369 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | |
373 | 370 | | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ |
374 | 371 | | avr-* | avr32-* \ |
375 | 372 | | be32-* | be64-* \ |
376 | 373 | | bfin-* | bs2000-* \ |
377 | 374 | | c[123]* | c30-* | [cjt]90-* | c4x-* \ |
378 | | clipper-* | craynv-* | cydra-* \ | |
375 | | c8051-* | clipper-* | craynv-* | cydra-* \ | |
379 | 376 | | d10v-* | d30v-* | dlx-* \ |
380 | 377 | | elxsi-* \ |
381 | 378 | | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ |
384 | 381 | | hexagon-* \ |
385 | 382 | | i*86-* | i860-* | i960-* | ia64-* \ |
386 | 383 | | ip2k-* | iq2000-* \ |
384 | | k1om-* \ | |
387 | 385 | | le32-* | le64-* \ |
388 | 386 | | lm32-* \ |
389 | 387 | | m32c-* | m32r-* | m32rle-* \ |
390 | 388 | | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ |
391 | | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | |
389 | | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | |
390 | | microblaze-* | microblazeel-* \ | |
392 | 391 | | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ |
393 | 392 | | mips16-* \ |
394 | 393 | | mips64-* | mips64el-* \ |
406 | 405 | | mipsisa64r2-* | mipsisa64r2el-* \ |
407 | 406 | | mipsisa64sb1-* | mipsisa64sb1el-* \ |
408 | 407 | | mipsisa64sr71k-* | mipsisa64sr71kel-* \ |
408 | | mipsr5900-* | mipsr5900el-* \ | |
409 | 409 | | mipstx39-* | mipstx39el-* \ |
410 | 410 | | mmix-* \ |
411 | 411 | | mt-* \ |
412 | 412 | | msp430-* \ |
413 | 413 | | nds32-* | nds32le-* | nds32be-* \ |
414 | | nios-* | nios2-* \ | |
414 | | nios-* | nios2-* | nios2eb-* | nios2el-* \ | |
415 | 415 | | none-* | np1-* | ns16k-* | ns32k-* \ |
416 | 416 | | open8-* \ |
417 | 417 | | orion-* \ |
787 | 787 | basic_machine=ns32k-utek |
788 | 788 | os=-sysv |
789 | 789 | ;; |
790 | microblaze) | |
790 | microblaze*) | |
791 | 791 | basic_machine=microblaze-xilinx |
792 | 792 | ;; |
793 | mingw64) | |
794 | basic_machine=x86_64-pc | |
795 | os=-mingw64 | |
796 | ;; | |
793 | 797 | mingw32) |
794 | basic_machine=i386-pc | |
798 | basic_machine=i686-pc | |
795 | 799 | os=-mingw32 |
796 | 800 | ;; |
797 | 801 | mingw32ce) |
827 | 831 | basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` |
828 | 832 | ;; |
829 | 833 | msys) |
830 | basic_machine=i386-pc | |
834 | basic_machine=i686-pc | |
831 | 835 | os=-msys |
832 | 836 | ;; |
833 | 837 | mvs) |
1018 | 1022 | basic_machine=i586-unknown |
1019 | 1023 | os=-pw32 |
1020 | 1024 | ;; |
1021 | rdos) | |
1025 | rdos | rdos64) | |
1026 | basic_machine=x86_64-pc | |
1027 | os=-rdos | |
1028 | ;; | |
1029 | rdos32) | |
1022 | 1030 | basic_machine=i386-pc |
1023 | 1031 | os=-rdos |
1024 | 1032 | ;; |
1345 | 1353 | -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ |
1346 | 1354 | | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ |
1347 | 1355 | | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ |
1348 | | -sym* | -kopensolaris* \ | |
1356 | | -sym* | -kopensolaris* | -plan9* \ | |
1349 | 1357 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ |
1350 | 1358 | | -aos* | -aros* \ |
1351 | 1359 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ |
1352 | 1360 | | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ |
1353 | 1361 | | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ |
1354 | | -openbsd* | -solidbsd* \ | |
1362 | | -bitrig* | -openbsd* | -solidbsd* \ | |
1355 | 1363 | | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ |
1356 | 1364 | | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ |
1357 | 1365 | | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ |
1358 | 1366 | | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ |
1359 | 1367 | | -chorusos* | -chorusrdb* | -cegcc* \ |
1360 | 1368 | | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ |
1361 | | -mingw32* | -linux-gnu* | -linux-android* \ | |
1362 | | -linux-newlib* | -linux-uclibc* \ | |
1369 | | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | |
1370 | | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | |
1363 | 1371 | | -uxpv* | -beos* | -mpeix* | -udk* \ |
1364 | 1372 | | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ |
1365 | 1373 | | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ |
1491 | 1499 | -aros*) |
1492 | 1500 | os=-aros |
1493 | 1501 | ;; |
1494 | -kaos*) | |
1495 | os=-kaos | |
1496 | ;; | |
1497 | 1502 | -zvmoe) |
1498 | 1503 | os=-zvmoe |
1499 | 1504 | ;; |
1542 | 1547 | c4x-* | tic4x-*) |
1543 | 1548 | os=-coff |
1544 | 1549 | ;; |
1550 | c8051-*) | |
1551 | os=-elf | |
1552 | ;; | |
1545 | 1553 | hexagon-*) |
1546 | 1554 | os=-elf |
1547 | 1555 | ;; |
1583 | 1591 | os=-elf |
1584 | 1592 | ;; |
1585 | 1593 | mips*-*) |
1594 | os=-elf | |
1595 | ;; | |
1596 | or1k-*) | |
1586 | 1597 | os=-elf |
1587 | 1598 | ;; |
1588 | 1599 | or32-*) |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for fping 3.16-rc2. | |
2 | # Generated by GNU Autoconf 2.69 for fping 3.16. | |
3 | 3 | # |
4 | 4 | # |
5 | 5 | # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. |
576 | 576 | # Identity of this package. |
577 | 577 | PACKAGE_NAME='fping' |
578 | 578 | PACKAGE_TARNAME='fping' |
579 | PACKAGE_VERSION='3.16-rc2' | |
580 | PACKAGE_STRING='fping 3.16-rc2' | |
579 | PACKAGE_VERSION='3.16' | |
580 | PACKAGE_STRING='fping 3.16' | |
581 | 581 | PACKAGE_BUGREPORT='' |
582 | 582 | PACKAGE_URL='' |
583 | 583 | |
685 | 685 | CC |
686 | 686 | IPV6_FALSE |
687 | 687 | IPV6_TRUE |
688 | IPV4_FALSE | |
689 | IPV4_TRUE | |
688 | 690 | target_alias |
689 | 691 | host_alias |
690 | 692 | build_alias |
1282 | 1284 | # Omit some internal or obsolete options to make the list less imposing. |
1283 | 1285 | # This message is too long to be a string in the A/UX 3.1 sh. |
1284 | 1286 | cat <<_ACEOF |
1285 | \`configure' configures fping 3.16-rc2 to adapt to many kinds of systems. | |
1287 | \`configure' configures fping 3.16 to adapt to many kinds of systems. | |
1286 | 1288 | |
1287 | 1289 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1288 | 1290 | |
1353 | 1355 | |
1354 | 1356 | if test -n "$ac_init_help"; then |
1355 | 1357 | case $ac_init_help in |
1356 | short | recursive ) echo "Configuration of fping 3.16-rc2:";; | |
1358 | short | recursive ) echo "Configuration of fping 3.16:";; | |
1357 | 1359 | esac |
1358 | 1360 | cat <<\_ACEOF |
1359 | 1361 | |
1361 | 1363 | --disable-option-checking ignore unrecognized --enable/--with options |
1362 | 1364 | --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) |
1363 | 1365 | --enable-FEATURE[=ARG] include FEATURE [ARG=yes] |
1364 | --enable-ipv4 (ignored for compatibility with previous versions) | |
1365 | --enable-ipv6 Build IPv6 capable fping6 | |
1366 | --enable-ipv4 Build IPv4 capable fping | |
1367 | --enable-ipv6 Build IPv6 capable fping6 | |
1366 | 1368 | --disable-timestamp Disable kernel-based packet timestaping |
1367 | 1369 | (SO_TIMESTAMP) |
1368 | 1370 | --enable-dependency-tracking |
1451 | 1453 | test -n "$ac_init_help" && exit $ac_status |
1452 | 1454 | if $ac_init_version; then |
1453 | 1455 | cat <<\_ACEOF |
1454 | fping configure 3.16-rc2 | |
1456 | fping configure 3.16 | |
1455 | 1457 | generated by GNU Autoconf 2.69 |
1456 | 1458 | |
1457 | 1459 | Copyright (C) 2012 Free Software Foundation, Inc. |
1862 | 1864 | This file contains any messages produced by compilers while |
1863 | 1865 | running configure, to aid debugging if configure makes a mistake. |
1864 | 1866 | |
1865 | It was created by fping $as_me 3.16-rc2, which was | |
1867 | It was created by fping $as_me 3.16, which was | |
1866 | 1868 | generated by GNU Autoconf 2.69. Invocation command line was |
1867 | 1869 | |
1868 | 1870 | $ $0 $@ |
2213 | 2215 | |
2214 | 2216 | # Check whether --enable-ipv4 was given. |
2215 | 2217 | if test "${enable_ipv4+set}" = set; then : |
2216 | enableval=$enable_ipv4; | |
2218 | enableval=$enable_ipv4; case "${enableval}" in | |
2219 | yes) ipv4=true ;; | |
2220 | no) ipv4=false ;; | |
2221 | *) as_fn_error $? "bad value ${enableval} for --enable-ipv4" "$LINENO" 5 ;; | |
2222 | esac | |
2223 | else | |
2224 | ipv4=true | |
2225 | fi | |
2226 | ||
2227 | if test x$ipv4 = xtrue; then | |
2228 | IPV4_TRUE= | |
2229 | IPV4_FALSE='#' | |
2230 | else | |
2231 | IPV4_TRUE='#' | |
2232 | IPV4_FALSE= | |
2217 | 2233 | fi |
2218 | 2234 | |
2219 | 2235 | |
2225 | 2241 | *) as_fn_error $? "bad value ${enableval} for --enable-ipv6" "$LINENO" 5 ;; |
2226 | 2242 | esac |
2227 | 2243 | else |
2228 | ipv6=true | |
2229 | fi | |
2230 | ||
2231 | if test x$ipv6 = xtrue; then | |
2244 | ipv6=false | |
2245 | fi | |
2246 | ||
2247 | if test x$ipv6 = xtrue; then | |
2232 | 2248 | IPV6_TRUE= |
2233 | 2249 | IPV6_FALSE='#' |
2234 | 2250 | else |
2236 | 2252 | IPV6_FALSE= |
2237 | 2253 | fi |
2238 | 2254 | |
2255 | ||
2256 | if test x$ipv4 = xfalse && test x$ipv6 = xfalse; then | |
2257 | as_fn_error $? "You must enable at least one of IPv4 and IPv6." "$LINENO" 5 | |
2258 | fi | |
2239 | 2259 | |
2240 | 2260 | # Check whether --enable-timestamp was given. |
2241 | 2261 | if test "${enable_timestamp+set}" = set; then : |
2242 | 2262 | enableval=$enable_timestamp; |
2243 | 2263 | fi |
2244 | 2264 | |
2245 | ac_aux_dir= | |
2246 | for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do | |
2247 | if test -f "$ac_dir/install-sh"; then | |
2248 | ac_aux_dir=$ac_dir | |
2249 | ac_install_sh="$ac_aux_dir/install-sh -c" | |
2250 | break | |
2251 | elif test -f "$ac_dir/install.sh"; then | |
2252 | ac_aux_dir=$ac_dir | |
2253 | ac_install_sh="$ac_aux_dir/install.sh -c" | |
2254 | break | |
2255 | elif test -f "$ac_dir/shtool"; then | |
2256 | ac_aux_dir=$ac_dir | |
2257 | ac_install_sh="$ac_aux_dir/shtool install -c" | |
2258 | break | |
2259 | fi | |
2260 | done | |
2261 | if test -z "$ac_aux_dir"; then | |
2262 | as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 | |
2263 | fi | |
2264 | ||
2265 | # These three variables are undocumented and unsupported, | |
2266 | # and are intended to be withdrawn in a future Autoconf release. | |
2267 | # They can cause serious problems if a builder's source tree is in a directory | |
2268 | # whose full name contains unusual characters. | |
2269 | ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. | |
2270 | ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. | |
2271 | ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. | |
2272 | ||
2273 | ||
2274 | # Expand $ac_aux_dir to an absolute path. | |
2275 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
2265 | # expand $ac_aux_dir to an absolute path | |
2266 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
2276 | 2267 | |
2277 | 2268 | ac_ext=c |
2278 | 2269 | ac_cpp='$CPP $CPPFLAGS' |
3143 | 3134 | as_fn_error $? "--enable-timestamp not supported on this platform" "$LINENO" 5 |
3144 | 3135 | |
3145 | 3136 | fi |
3137 | ||
3138 | ac_aux_dir= | |
3139 | for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do | |
3140 | if test -f "$ac_dir/install-sh"; then | |
3141 | ac_aux_dir=$ac_dir | |
3142 | ac_install_sh="$ac_aux_dir/install-sh -c" | |
3143 | break | |
3144 | elif test -f "$ac_dir/install.sh"; then | |
3145 | ac_aux_dir=$ac_dir | |
3146 | ac_install_sh="$ac_aux_dir/install.sh -c" | |
3147 | break | |
3148 | elif test -f "$ac_dir/shtool"; then | |
3149 | ac_aux_dir=$ac_dir | |
3150 | ac_install_sh="$ac_aux_dir/shtool install -c" | |
3151 | break | |
3152 | fi | |
3153 | done | |
3154 | if test -z "$ac_aux_dir"; then | |
3155 | as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 | |
3156 | fi | |
3157 | ||
3158 | # These three variables are undocumented and unsupported, | |
3159 | # and are intended to be withdrawn in a future Autoconf release. | |
3160 | # They can cause serious problems if a builder's source tree is in a directory | |
3161 | # whose full name contains unusual characters. | |
3162 | ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. | |
3163 | ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. | |
3164 | ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. | |
3165 | ||
3146 | 3166 | |
3147 | 3167 | # Make sure we can run config.sub. |
3148 | 3168 | $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || |
3800 | 3820 | |
3801 | 3821 | # Define the identity of the package. |
3802 | 3822 | PACKAGE='fping' |
3803 | VERSION='3.16-rc2' | |
3823 | VERSION='3.16' | |
3804 | 3824 | |
3805 | 3825 | |
3806 | 3826 | cat >>confdefs.h <<_ACEOF |
4021 | 4041 | fi |
4022 | 4042 | fi |
4023 | 4043 | |
4024 | ||
4025 | 4044 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 |
4026 | 4045 | $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } |
4027 | 4046 | # Check whether --enable-maintainer-mode was given. |
5283 | 5302 | LTLIBOBJS=$ac_ltlibobjs |
5284 | 5303 | |
5285 | 5304 | |
5305 | if test -z "${IPV4_TRUE}" && test -z "${IPV4_FALSE}"; then | |
5306 | as_fn_error $? "conditional \"IPV4\" was never defined. | |
5307 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 | |
5308 | fi | |
5286 | 5309 | if test -z "${IPV6_TRUE}" && test -z "${IPV6_FALSE}"; then |
5287 | 5310 | as_fn_error $? "conditional \"IPV6\" was never defined. |
5288 | 5311 | Usually this means the macro was only invoked conditionally." "$LINENO" 5 |
5712 | 5735 | # report actual input values of CONFIG_FILES etc. instead of their |
5713 | 5736 | # values after options handling. |
5714 | 5737 | ac_log=" |
5715 | This file was extended by fping $as_me 3.16-rc2, which was | |
5738 | This file was extended by fping $as_me 3.16, which was | |
5716 | 5739 | generated by GNU Autoconf 2.69. Invocation command line was |
5717 | 5740 | |
5718 | 5741 | CONFIG_FILES = $CONFIG_FILES |
5778 | 5801 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
5779 | 5802 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
5780 | 5803 | ac_cs_version="\\ |
5781 | fping config.status 3.16-rc2 | |
5804 | fping config.status 3.16 | |
5782 | 5805 | configured by $0, generated by GNU Autoconf 2.69, |
5783 | 5806 | with options \\"\$ac_cs_config\\" |
5784 | 5807 |
2 | 2 | dnl Minimum Autoconf version required. |
3 | 3 | AC_PREREQ(2.59) |
4 | 4 | |
5 | AC_INIT([fping],[3.16-rc2]) | |
5 | AC_INIT([fping],[3.16]) | |
6 | 6 | |
7 | 7 | dnl make ipv4 and ipv6 options |
8 | 8 | AC_ARG_ENABLE([ipv4], |
9 | AS_HELP_STRING([--enable-ipv4], [(ignored for compatibility with previous versions)])) | |
9 | [ --enable-ipv4 Build IPv4 capable fping], | |
10 | [case "${enableval}" in | |
11 | yes) ipv4=true ;; | |
12 | no) ipv4=false ;; | |
13 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv4]) ;; | |
14 | esac],[ipv4=true]) | |
15 | AM_CONDITIONAL([IPV4], [test x$ipv4 = xtrue]) | |
10 | 16 | |
11 | 17 | AC_ARG_ENABLE([ipv6], |
12 | AS_HELP_STRING([--enable-ipv6], [Build IPv6 capable fping6]), | |
18 | [ --enable-ipv6 Build IPv6 capable fping6], | |
13 | 19 | [case "${enableval}" in |
14 | 20 | yes) ipv6=true ;; |
15 | 21 | no) ipv6=false ;; |
16 | 22 | *) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;; |
17 | esac],[ipv6=true]) | |
18 | AM_CONDITIONAL([IPV6], [test x$ipv6 = xtrue]) | |
23 | esac],[ipv6=false]) | |
24 | AM_CONDITIONAL([IPV6], [test x$ipv6 = xtrue]) | |
25 | ||
26 | if test x$ipv4 = xfalse && test x$ipv6 = xfalse; then | |
27 | AC_MSG_ERROR([You must enable at least one of IPv4 and IPv6.]) | |
28 | fi | |
19 | 29 | |
20 | 30 | AC_ARG_ENABLE([timestamp], |
21 | 31 | AS_HELP_STRING([--disable-timestamp], [Disable kernel-based packet timestaping (SO_TIMESTAMP)])) |
0 | 0 | #! /bin/sh |
1 | 1 | # depcomp - compile a program generating dependencies as side-effects |
2 | 2 | |
3 | scriptversion=2012-03-27.16; # UTC | |
4 | ||
5 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, | |
6 | # 2011, 2012 Free Software Foundation, Inc. | |
3 | scriptversion=2013-05-30.07; # UTC | |
4 | ||
5 | # Copyright (C) 1999-2013 Free Software Foundation, Inc. | |
7 | 6 | |
8 | 7 | # This program is free software; you can redistribute it and/or modify |
9 | 8 | # it under the terms of the GNU General Public License as published by |
27 | 26 | |
28 | 27 | case $1 in |
29 | 28 | '') |
30 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 | |
31 | exit 1; | |
32 | ;; | |
29 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 | |
30 | exit 1; | |
31 | ;; | |
33 | 32 | -h | --h*) |
34 | 33 | cat <<\EOF |
35 | 34 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] |
56 | 55 | ;; |
57 | 56 | esac |
58 | 57 | |
58 | # Get the directory component of the given path, and save it in the | |
59 | # global variables '$dir'. Note that this directory component will | |
60 | # be either empty or ending with a '/' character. This is deliberate. | |
61 | set_dir_from () | |
62 | { | |
63 | case $1 in | |
64 | */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; | |
65 | *) dir=;; | |
66 | esac | |
67 | } | |
68 | ||
69 | # Get the suffix-stripped basename of the given path, and save it the | |
70 | # global variable '$base'. | |
71 | set_base_from () | |
72 | { | |
73 | base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` | |
74 | } | |
75 | ||
76 | # If no dependency file was actually created by the compiler invocation, | |
77 | # we still have to create a dummy depfile, to avoid errors with the | |
78 | # Makefile "include basename.Plo" scheme. | |
79 | make_dummy_depfile () | |
80 | { | |
81 | echo "#dummy" > "$depfile" | |
82 | } | |
83 | ||
84 | # Factor out some common post-processing of the generated depfile. | |
85 | # Requires the auxiliary global variable '$tmpdepfile' to be set. | |
86 | aix_post_process_depfile () | |
87 | { | |
88 | # If the compiler actually managed to produce a dependency file, | |
89 | # post-process it. | |
90 | if test -f "$tmpdepfile"; then | |
91 | # Each line is of the form 'foo.o: dependency.h'. | |
92 | # Do two passes, one to just change these to | |
93 | # $object: dependency.h | |
94 | # and one to simply output | |
95 | # dependency.h: | |
96 | # which is needed to avoid the deleted-header problem. | |
97 | { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" | |
98 | sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" | |
99 | } > "$depfile" | |
100 | rm -f "$tmpdepfile" | |
101 | else | |
102 | make_dummy_depfile | |
103 | fi | |
104 | } | |
105 | ||
59 | 106 | # A tabulation character. |
60 | 107 | tab=' ' |
61 | 108 | # A newline character. |
62 | 109 | nl=' |
63 | 110 | ' |
111 | # Character ranges might be problematic outside the C locale. | |
112 | # These definitions help. | |
113 | upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
114 | lower=abcdefghijklmnopqrstuvwxyz | |
115 | digits=0123456789 | |
116 | alpha=${upper}${lower} | |
64 | 117 | |
65 | 118 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then |
66 | 119 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
73 | 126 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} |
74 | 127 | |
75 | 128 | rm -f "$tmpdepfile" |
129 | ||
130 | # Avoid interferences from the environment. | |
131 | gccflag= dashmflag= | |
76 | 132 | |
77 | 133 | # Some modes work just like other modes, but use different flags. We |
78 | 134 | # parameterize here, but still list the modes in the big case below, |
85 | 141 | fi |
86 | 142 | |
87 | 143 | if test "$depmode" = dashXmstdout; then |
88 | # This is just like dashmstdout with a different argument. | |
89 | dashmflag=-xM | |
90 | depmode=dashmstdout | |
144 | # This is just like dashmstdout with a different argument. | |
145 | dashmflag=-xM | |
146 | depmode=dashmstdout | |
91 | 147 | fi |
92 | 148 | |
93 | 149 | cygpath_u="cygpath -u -f -" |
94 | 150 | if test "$depmode" = msvcmsys; then |
95 | # This is just like msvisualcpp but w/o cygpath translation. | |
96 | # Just convert the backslash-escaped backslashes to single forward | |
97 | # slashes to satisfy depend.m4 | |
98 | cygpath_u='sed s,\\\\,/,g' | |
99 | depmode=msvisualcpp | |
151 | # This is just like msvisualcpp but w/o cygpath translation. | |
152 | # Just convert the backslash-escaped backslashes to single forward | |
153 | # slashes to satisfy depend.m4 | |
154 | cygpath_u='sed s,\\\\,/,g' | |
155 | depmode=msvisualcpp | |
100 | 156 | fi |
101 | 157 | |
102 | 158 | if test "$depmode" = msvc7msys; then |
103 | # This is just like msvc7 but w/o cygpath translation. | |
104 | # Just convert the backslash-escaped backslashes to single forward | |
105 | # slashes to satisfy depend.m4 | |
106 | cygpath_u='sed s,\\\\,/,g' | |
107 | depmode=msvc7 | |
159 | # This is just like msvc7 but w/o cygpath translation. | |
160 | # Just convert the backslash-escaped backslashes to single forward | |
161 | # slashes to satisfy depend.m4 | |
162 | cygpath_u='sed s,\\\\,/,g' | |
163 | depmode=msvc7 | |
108 | 164 | fi |
109 | 165 | |
110 | 166 | if test "$depmode" = xlc; then |
111 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. | |
112 | gccflag=-qmakedep=gcc,-MF | |
113 | depmode=gcc | |
167 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. | |
168 | gccflag=-qmakedep=gcc,-MF | |
169 | depmode=gcc | |
114 | 170 | fi |
115 | 171 | |
116 | 172 | case "$depmode" in |
133 | 189 | done |
134 | 190 | "$@" |
135 | 191 | stat=$? |
136 | if test $stat -eq 0; then : | |
137 | else | |
192 | if test $stat -ne 0; then | |
138 | 193 | rm -f "$tmpdepfile" |
139 | 194 | exit $stat |
140 | 195 | fi |
142 | 197 | ;; |
143 | 198 | |
144 | 199 | gcc) |
200 | ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. | |
201 | ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. | |
202 | ## (see the conditional assignment to $gccflag above). | |
145 | 203 | ## There are various ways to get dependency output from gcc. Here's |
146 | 204 | ## why we pick this rather obscure method: |
147 | 205 | ## - Don't want to use -MD because we'd like the dependencies to end |
148 | 206 | ## up in a subdir. Having to rename by hand is ugly. |
149 | 207 | ## (We might end up doing this anyway to support other compilers.) |
150 | 208 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like |
151 | ## -MM, not -M (despite what the docs say). | |
209 | ## -MM, not -M (despite what the docs say). Also, it might not be | |
210 | ## supported by the other compilers which use the 'gcc' depmode. | |
152 | 211 | ## - Using -M directly means running the compiler twice (even worse |
153 | 212 | ## than renaming). |
154 | 213 | if test -z "$gccflag"; then |
156 | 215 | fi |
157 | 216 | "$@" -Wp,"$gccflag$tmpdepfile" |
158 | 217 | stat=$? |
159 | if test $stat -eq 0; then : | |
160 | else | |
218 | if test $stat -ne 0; then | |
161 | 219 | rm -f "$tmpdepfile" |
162 | 220 | exit $stat |
163 | 221 | fi |
164 | 222 | rm -f "$depfile" |
165 | 223 | echo "$object : \\" > "$depfile" |
166 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz | |
167 | ## The second -e expression handles DOS-style file names with drive letters. | |
224 | # The second -e expression handles DOS-style file names with drive | |
225 | # letters. | |
168 | 226 | sed -e 's/^[^:]*: / /' \ |
169 | 227 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" |
170 | 228 | ## This next piece of magic avoids the "deleted header file" problem. |
173 | 231 | ## typically no way to rebuild the header). We avoid this by adding |
174 | 232 | ## dummy dependencies for each header file. Too bad gcc doesn't do |
175 | 233 | ## this for us directly. |
176 | tr ' ' "$nl" < "$tmpdepfile" | | |
177 | 234 | ## Some versions of gcc put a space before the ':'. On the theory |
178 | 235 | ## that the space means something, we add a space to the output as |
179 | 236 | ## well. hp depmode also adds that space, but also prefixes the VPATH |
180 | 237 | ## to the object. Take care to not repeat it in the output. |
181 | 238 | ## Some versions of the HPUX 10.20 sed can't process this invocation |
182 | 239 | ## correctly. Breaking it into two sed invocations is a workaround. |
183 | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | |
184 | | sed -e 's/$/ :/' >> "$depfile" | |
240 | tr ' ' "$nl" < "$tmpdepfile" \ | |
241 | | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | |
242 | | sed -e 's/$/ :/' >> "$depfile" | |
185 | 243 | rm -f "$tmpdepfile" |
186 | 244 | ;; |
187 | 245 | |
199 | 257 | "$@" -MDupdate "$tmpdepfile" |
200 | 258 | fi |
201 | 259 | stat=$? |
202 | if test $stat -eq 0; then : | |
203 | else | |
260 | if test $stat -ne 0; then | |
204 | 261 | rm -f "$tmpdepfile" |
205 | 262 | exit $stat |
206 | 263 | fi |
208 | 265 | |
209 | 266 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files |
210 | 267 | echo "$object : \\" > "$depfile" |
211 | ||
212 | 268 | # Clip off the initial element (the dependent). Don't try to be |
213 | 269 | # clever and replace this with sed code, as IRIX sed won't handle |
214 | 270 | # lines with more than a fixed number of characters (4096 in |
216 | 272 | # the IRIX cc adds comments like '#:fec' to the end of the |
217 | 273 | # dependency line. |
218 | 274 | tr ' ' "$nl" < "$tmpdepfile" \ |
219 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ | |
220 | tr "$nl" ' ' >> "$depfile" | |
275 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | |
276 | | tr "$nl" ' ' >> "$depfile" | |
221 | 277 | echo >> "$depfile" |
222 | ||
223 | 278 | # The second pass generates a dummy entry for each header file. |
224 | 279 | tr ' ' "$nl" < "$tmpdepfile" \ |
225 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ | |
226 | >> "$depfile" | |
280 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ | |
281 | >> "$depfile" | |
227 | 282 | else |
228 | # The sourcefile does not contain any dependencies, so just | |
229 | # store a dummy comment line, to avoid errors with the Makefile | |
230 | # "include basename.Plo" scheme. | |
231 | echo "#dummy" > "$depfile" | |
283 | make_dummy_depfile | |
232 | 284 | fi |
233 | 285 | rm -f "$tmpdepfile" |
234 | 286 | ;; |
246 | 298 | # current directory. Also, the AIX compiler puts '$object:' at the |
247 | 299 | # start of each line; $object doesn't have directory information. |
248 | 300 | # Version 6 uses the directory in both cases. |
249 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` | |
250 | test "x$dir" = "x$object" && dir= | |
251 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` | |
301 | set_dir_from "$object" | |
302 | set_base_from "$object" | |
252 | 303 | if test "$libtool" = yes; then |
253 | 304 | tmpdepfile1=$dir$base.u |
254 | 305 | tmpdepfile2=$base.u |
261 | 312 | "$@" -M |
262 | 313 | fi |
263 | 314 | stat=$? |
264 | ||
265 | if test $stat -eq 0; then : | |
266 | else | |
315 | if test $stat -ne 0; then | |
267 | 316 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" |
268 | 317 | exit $stat |
269 | 318 | fi |
272 | 321 | do |
273 | 322 | test -f "$tmpdepfile" && break |
274 | 323 | done |
275 | if test -f "$tmpdepfile"; then | |
276 | # Each line is of the form 'foo.o: dependent.h'. | |
277 | # Do two passes, one to just change these to | |
278 | # '$object: dependent.h' and one to simply 'dependent.h:'. | |
279 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" | |
280 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" | |
281 | else | |
282 | # The sourcefile does not contain any dependencies, so just | |
283 | # store a dummy comment line, to avoid errors with the Makefile | |
284 | # "include basename.Plo" scheme. | |
285 | echo "#dummy" > "$depfile" | |
286 | fi | |
324 | aix_post_process_depfile | |
325 | ;; | |
326 | ||
327 | tcc) | |
328 | # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 | |
329 | # FIXME: That version still under development at the moment of writing. | |
330 | # Make that this statement remains true also for stable, released | |
331 | # versions. | |
332 | # It will wrap lines (doesn't matter whether long or short) with a | |
333 | # trailing '\', as in: | |
334 | # | |
335 | # foo.o : \ | |
336 | # foo.c \ | |
337 | # foo.h \ | |
338 | # | |
339 | # It will put a trailing '\' even on the last line, and will use leading | |
340 | # spaces rather than leading tabs (at least since its commit 0394caf7 | |
341 | # "Emit spaces for -MD"). | |
342 | "$@" -MD -MF "$tmpdepfile" | |
343 | stat=$? | |
344 | if test $stat -ne 0; then | |
345 | rm -f "$tmpdepfile" | |
346 | exit $stat | |
347 | fi | |
348 | rm -f "$depfile" | |
349 | # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. | |
350 | # We have to change lines of the first kind to '$object: \'. | |
351 | sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" | |
352 | # And for each line of the second kind, we have to emit a 'dep.h:' | |
353 | # dummy dependency, to avoid the deleted-header problem. | |
354 | sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" | |
287 | 355 | rm -f "$tmpdepfile" |
288 | 356 | ;; |
289 | 357 | |
290 | icc) | |
291 | # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. | |
292 | # However on | |
293 | # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c | |
294 | # ICC 7.0 will fill foo.d with something like | |
295 | # foo.o: sub/foo.c | |
296 | # foo.o: sub/foo.h | |
297 | # which is wrong. We want | |
298 | # sub/foo.o: sub/foo.c | |
299 | # sub/foo.o: sub/foo.h | |
300 | # sub/foo.c: | |
301 | # sub/foo.h: | |
302 | # ICC 7.1 will output | |
358 | ## The order of this option in the case statement is important, since the | |
359 | ## shell code in configure will try each of these formats in the order | |
360 | ## listed in this file. A plain '-MD' option would be understood by many | |
361 | ## compilers, so we must ensure this comes after the gcc and icc options. | |
362 | pgcc) | |
363 | # Portland's C compiler understands '-MD'. | |
364 | # Will always output deps to 'file.d' where file is the root name of the | |
365 | # source file under compilation, even if file resides in a subdirectory. | |
366 | # The object file name does not affect the name of the '.d' file. | |
367 | # pgcc 10.2 will output | |
303 | 368 | # foo.o: sub/foo.c sub/foo.h |
304 | # and will wrap long lines using '\': | |
369 | # and will wrap long lines using '\' : | |
305 | 370 | # foo.o: sub/foo.c ... \ |
306 | 371 | # sub/foo.h ... \ |
307 | 372 | # ... |
308 | # tcc 0.9.26 (FIXME still under development at the moment of writing) | |
309 | # will emit a similar output, but also prepend the continuation lines | |
310 | # with horizontal tabulation characters. | |
311 | "$@" -MD -MF "$tmpdepfile" | |
312 | stat=$? | |
313 | if test $stat -eq 0; then : | |
314 | else | |
373 | set_dir_from "$object" | |
374 | # Use the source, not the object, to determine the base name, since | |
375 | # that's sadly what pgcc will do too. | |
376 | set_base_from "$source" | |
377 | tmpdepfile=$base.d | |
378 | ||
379 | # For projects that build the same source file twice into different object | |
380 | # files, the pgcc approach of using the *source* file root name can cause | |
381 | # problems in parallel builds. Use a locking strategy to avoid stomping on | |
382 | # the same $tmpdepfile. | |
383 | lockdir=$base.d-lock | |
384 | trap " | |
385 | echo '$0: caught signal, cleaning up...' >&2 | |
386 | rmdir '$lockdir' | |
387 | exit 1 | |
388 | " 1 2 13 15 | |
389 | numtries=100 | |
390 | i=$numtries | |
391 | while test $i -gt 0; do | |
392 | # mkdir is a portable test-and-set. | |
393 | if mkdir "$lockdir" 2>/dev/null; then | |
394 | # This process acquired the lock. | |
395 | "$@" -MD | |
396 | stat=$? | |
397 | # Release the lock. | |
398 | rmdir "$lockdir" | |
399 | break | |
400 | else | |
401 | # If the lock is being held by a different process, wait | |
402 | # until the winning process is done or we timeout. | |
403 | while test -d "$lockdir" && test $i -gt 0; do | |
404 | sleep 1 | |
405 | i=`expr $i - 1` | |
406 | done | |
407 | fi | |
408 | i=`expr $i - 1` | |
409 | done | |
410 | trap - 1 2 13 15 | |
411 | if test $i -le 0; then | |
412 | echo "$0: failed to acquire lock after $numtries attempts" >&2 | |
413 | echo "$0: check lockdir '$lockdir'" >&2 | |
414 | exit 1 | |
415 | fi | |
416 | ||
417 | if test $stat -ne 0; then | |
315 | 418 | rm -f "$tmpdepfile" |
316 | 419 | exit $stat |
317 | 420 | fi |
318 | 421 | rm -f "$depfile" |
319 | # Each line is of the form 'foo.o: dependent.h', | |
320 | # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. | |
422 | # Each line is of the form `foo.o: dependent.h', | |
423 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. | |
321 | 424 | # Do two passes, one to just change these to |
322 | # '$object: dependent.h' and one to simply 'dependent.h:'. | |
323 | sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ | |
324 | < "$tmpdepfile" > "$depfile" | |
325 | sed ' | |
326 | s/[ '"$tab"'][ '"$tab"']*/ /g | |
327 | s/^ *// | |
328 | s/ *\\*$// | |
329 | s/^[^:]*: *// | |
330 | /^$/d | |
331 | /:$/d | |
332 | s/$/ :/ | |
333 | ' < "$tmpdepfile" >> "$depfile" | |
425 | # `$object: dependent.h' and one to simply `dependent.h:'. | |
426 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" | |
427 | # Some versions of the HPUX 10.20 sed can't process this invocation | |
428 | # correctly. Breaking it into two sed invocations is a workaround. | |
429 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | |
430 | | sed -e 's/$/ :/' >> "$depfile" | |
334 | 431 | rm -f "$tmpdepfile" |
335 | 432 | ;; |
336 | 433 | |
341 | 438 | # 'foo.d', which lands next to the object file, wherever that |
342 | 439 | # happens to be. |
343 | 440 | # Much of this is similar to the tru64 case; see comments there. |
344 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` | |
345 | test "x$dir" = "x$object" && dir= | |
346 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` | |
441 | set_dir_from "$object" | |
442 | set_base_from "$object" | |
347 | 443 | if test "$libtool" = yes; then |
348 | 444 | tmpdepfile1=$dir$base.d |
349 | 445 | tmpdepfile2=$dir.libs/$base.d |
354 | 450 | "$@" +Maked |
355 | 451 | fi |
356 | 452 | stat=$? |
357 | if test $stat -eq 0; then : | |
358 | else | |
453 | if test $stat -ne 0; then | |
359 | 454 | rm -f "$tmpdepfile1" "$tmpdepfile2" |
360 | 455 | exit $stat |
361 | 456 | fi |
365 | 460 | test -f "$tmpdepfile" && break |
366 | 461 | done |
367 | 462 | if test -f "$tmpdepfile"; then |
368 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" | |
463 | sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" | |
369 | 464 | # Add 'dependent.h:' lines. |
370 | 465 | sed -ne '2,${ |
371 | s/^ *// | |
372 | s/ \\*$// | |
373 | s/$/:/ | |
374 | p | |
375 | }' "$tmpdepfile" >> "$depfile" | |
466 | s/^ *// | |
467 | s/ \\*$// | |
468 | s/$/:/ | |
469 | p | |
470 | }' "$tmpdepfile" >> "$depfile" | |
376 | 471 | else |
377 | echo "#dummy" > "$depfile" | |
472 | make_dummy_depfile | |
378 | 473 | fi |
379 | 474 | rm -f "$tmpdepfile" "$tmpdepfile2" |
380 | 475 | ;; |
381 | 476 | |
382 | 477 | tru64) |
383 | # The Tru64 compiler uses -MD to generate dependencies as a side | |
384 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. | |
385 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put | |
386 | # dependencies in 'foo.d' instead, so we check for that too. | |
387 | # Subdirectories are respected. | |
388 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` | |
389 | test "x$dir" = "x$object" && dir= | |
390 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` | |
391 | ||
392 | if test "$libtool" = yes; then | |
393 | # With Tru64 cc, shared objects can also be used to make a | |
394 | # static library. This mechanism is used in libtool 1.4 series to | |
395 | # handle both shared and static libraries in a single compilation. | |
396 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. | |
397 | # | |
398 | # With libtool 1.5 this exception was removed, and libtool now | |
399 | # generates 2 separate objects for the 2 libraries. These two | |
400 | # compilations output dependencies in $dir.libs/$base.o.d and | |
401 | # in $dir$base.o.d. We have to check for both files, because | |
402 | # one of the two compilations can be disabled. We should prefer | |
403 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is | |
404 | # automatically cleaned when .libs/ is deleted, while ignoring | |
405 | # the former would cause a distcleancheck panic. | |
406 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 | |
407 | tmpdepfile2=$dir$base.o.d # libtool 1.5 | |
408 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 | |
409 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 | |
410 | "$@" -Wc,-MD | |
411 | else | |
412 | tmpdepfile1=$dir$base.o.d | |
413 | tmpdepfile2=$dir$base.d | |
414 | tmpdepfile3=$dir$base.d | |
415 | tmpdepfile4=$dir$base.d | |
416 | "$@" -MD | |
417 | fi | |
418 | ||
419 | stat=$? | |
420 | if test $stat -eq 0; then : | |
421 | else | |
422 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" | |
423 | exit $stat | |
424 | fi | |
425 | ||
426 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" | |
427 | do | |
428 | test -f "$tmpdepfile" && break | |
429 | done | |
430 | if test -f "$tmpdepfile"; then | |
431 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" | |
432 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" | |
433 | else | |
434 | echo "#dummy" > "$depfile" | |
435 | fi | |
436 | rm -f "$tmpdepfile" | |
437 | ;; | |
478 | # The Tru64 compiler uses -MD to generate dependencies as a side | |
479 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. | |
480 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put | |
481 | # dependencies in 'foo.d' instead, so we check for that too. | |
482 | # Subdirectories are respected. | |
483 | set_dir_from "$object" | |
484 | set_base_from "$object" | |
485 | ||
486 | if test "$libtool" = yes; then | |
487 | # Libtool generates 2 separate objects for the 2 libraries. These | |
488 | # two compilations output dependencies in $dir.libs/$base.o.d and | |
489 | # in $dir$base.o.d. We have to check for both files, because | |
490 | # one of the two compilations can be disabled. We should prefer | |
491 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is | |
492 | # automatically cleaned when .libs/ is deleted, while ignoring | |
493 | # the former would cause a distcleancheck panic. | |
494 | tmpdepfile1=$dir$base.o.d # libtool 1.5 | |
495 | tmpdepfile2=$dir.libs/$base.o.d # Likewise. | |
496 | tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 | |
497 | "$@" -Wc,-MD | |
498 | else | |
499 | tmpdepfile1=$dir$base.d | |
500 | tmpdepfile2=$dir$base.d | |
501 | tmpdepfile3=$dir$base.d | |
502 | "$@" -MD | |
503 | fi | |
504 | ||
505 | stat=$? | |
506 | if test $stat -ne 0; then | |
507 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" | |
508 | exit $stat | |
509 | fi | |
510 | ||
511 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" | |
512 | do | |
513 | test -f "$tmpdepfile" && break | |
514 | done | |
515 | # Same post-processing that is required for AIX mode. | |
516 | aix_post_process_depfile | |
517 | ;; | |
438 | 518 | |
439 | 519 | msvc7) |
440 | 520 | if test "$libtool" = yes; then |
445 | 525 | "$@" $showIncludes > "$tmpdepfile" |
446 | 526 | stat=$? |
447 | 527 | grep -v '^Note: including file: ' "$tmpdepfile" |
448 | if test "$stat" = 0; then : | |
449 | else | |
528 | if test $stat -ne 0; then | |
450 | 529 | rm -f "$tmpdepfile" |
451 | 530 | exit $stat |
452 | 531 | fi |
472 | 551 | G |
473 | 552 | p |
474 | 553 | }' >> "$depfile" |
554 | echo >> "$depfile" # make sure the fragment doesn't end with a backslash | |
475 | 555 | rm -f "$tmpdepfile" |
476 | 556 | ;; |
477 | 557 | |
523 | 603 | # in the target name. This is to cope with DOS-style filenames: |
524 | 604 | # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. |
525 | 605 | "$@" $dashmflag | |
526 | sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" | |
606 | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" | |
527 | 607 | rm -f "$depfile" |
528 | 608 | cat < "$tmpdepfile" > "$depfile" |
529 | tr ' ' "$nl" < "$tmpdepfile" | \ | |
530 | ## Some versions of the HPUX 10.20 sed can't process this invocation | |
531 | ## correctly. Breaking it into two sed invocations is a workaround. | |
532 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" | |
609 | # Some versions of the HPUX 10.20 sed can't process this sed invocation | |
610 | # correctly. Breaking it into two sed invocations is a workaround. | |
611 | tr ' ' "$nl" < "$tmpdepfile" \ | |
612 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | |
613 | | sed -e 's/$/ :/' >> "$depfile" | |
533 | 614 | rm -f "$tmpdepfile" |
534 | 615 | ;; |
535 | 616 | |
582 | 663 | # makedepend may prepend the VPATH from the source file name to the object. |
583 | 664 | # No need to regex-escape $object, excess matching of '.' is harmless. |
584 | 665 | sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" |
585 | sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ | |
586 | ## Some versions of the HPUX 10.20 sed can't process this invocation | |
587 | ## correctly. Breaking it into two sed invocations is a workaround. | |
588 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" | |
666 | # Some versions of the HPUX 10.20 sed can't process the last invocation | |
667 | # correctly. Breaking it into two sed invocations is a workaround. | |
668 | sed '1,2d' "$tmpdepfile" \ | |
669 | | tr ' ' "$nl" \ | |
670 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | |
671 | | sed -e 's/$/ :/' >> "$depfile" | |
589 | 672 | rm -f "$tmpdepfile" "$tmpdepfile".bak |
590 | 673 | ;; |
591 | 674 | |
621 | 704 | esac |
622 | 705 | done |
623 | 706 | |
624 | "$@" -E | | |
625 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | |
626 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | | |
627 | sed '$ s: \\$::' > "$tmpdepfile" | |
707 | "$@" -E \ | |
708 | | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | |
709 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | |
710 | | sed '$ s: \\$::' > "$tmpdepfile" | |
628 | 711 | rm -f "$depfile" |
629 | 712 | echo "$object : \\" > "$depfile" |
630 | 713 | cat < "$tmpdepfile" >> "$depfile" |
656 | 739 | shift |
657 | 740 | ;; |
658 | 741 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") |
659 | set fnord "$@" | |
660 | shift | |
661 | shift | |
662 | ;; | |
742 | set fnord "$@" | |
743 | shift | |
744 | shift | |
745 | ;; | |
663 | 746 | *) |
664 | set fnord "$@" "$arg" | |
665 | shift | |
666 | shift | |
667 | ;; | |
747 | set fnord "$@" "$arg" | |
748 | shift | |
749 | shift | |
750 | ;; | |
668 | 751 | esac |
669 | 752 | done |
670 | 753 | "$@" -E 2>/dev/null | |
77 | 77 | build_triplet = @build@ |
78 | 78 | host_triplet = @host@ |
79 | 79 | target_triplet = @target@ |
80 | @IPV6_TRUE@am__append_1 = fping6.8 | |
80 | @IPV4_TRUE@am__append_1 = fping.8 | |
81 | @IPV6_TRUE@am__append_2 = fping6.8 | |
81 | 82 | subdir = doc |
82 | 83 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am |
83 | 84 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
240 | 241 | top_build_prefix = @top_build_prefix@ |
241 | 242 | top_builddir = @top_builddir@ |
242 | 243 | top_srcdir = @top_srcdir@ |
243 | man_MANS = fping.8 $(am__append_1) | |
244 | man_MANS = $(am__append_1) $(am__append_2) | |
244 | 245 | EXTRA_DIST = fping.8 fping6.8 fping.pod README.1992 |
245 | 246 | all: all-am |
246 | 247 |
0 | .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) | |
0 | .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) | |
1 | 1 | .\" |
2 | 2 | .\" Standard preamble: |
3 | 3 | .\" ======================================================================== |
132 | 132 | .\" ======================================================================== |
133 | 133 | .\" |
134 | 134 | .IX Title "FPING 8" |
135 | .TH FPING 8 "2017-01-31" "fping" "" | |
135 | .TH FPING 8 "2017-02-09" "fping" "" | |
136 | 136 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
137 | 137 | .\" way too many mistakes in technical documents. |
138 | 138 | .if n .ad l |
162 | 162 | addresses instead of IPv4. |
163 | 163 | .SH "OPTIONS" |
164 | 164 | .IX Header "OPTIONS" |
165 | .IP "\fB\-4\fR" 5 | |
166 | .IX Item "-4" | |
167 | Restrict name resolution and IPs to IPv4 addresses. | |
168 | .IP "\fB\-6\fR" 5 | |
169 | .IX Item "-6" | |
170 | Restrict name resolution and IPs to IPv6 addresses. If the program name is | |
171 | \&'fping6' (via a sym-link, for example), then '\-6' is implicitly added. | |
172 | 165 | .IP "\fB\-a\fR" 5 |
173 | 166 | .IX Item "-a" |
174 | 167 | Show systems that are alive. |
28 | 28 | |
29 | 29 | =over 5 |
30 | 30 | |
31 | =item B<-4> | |
32 | ||
33 | Restrict name resolution and IPs to IPv4 addresses. | |
34 | ||
35 | =item B<-6> | |
36 | ||
37 | Restrict name resolution and IPs to IPv6 addresses. If the program name is | |
38 | 'fping6' (via a sym-link, for example), then '-6' is implicitly added. | |
39 | ||
40 | 31 | =item B<-a> |
41 | 32 | |
42 | 33 | Show systems that are alive. |
0 | .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) | |
0 | .\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) | |
1 | 1 | .\" |
2 | 2 | .\" Standard preamble: |
3 | 3 | .\" ======================================================================== |
132 | 132 | .\" ======================================================================== |
133 | 133 | .\" |
134 | 134 | .IX Title "fping6 8" |
135 | .TH fping6 8 "2017-01-31" "fping" "" | |
135 | .TH fping6 8 "2017-02-09" "fping" "" | |
136 | 136 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
137 | 137 | .\" way too many mistakes in technical documents. |
138 | 138 | .if n .ad l |
162 | 162 | addresses instead of IPv4. |
163 | 163 | .SH "OPTIONS" |
164 | 164 | .IX Header "OPTIONS" |
165 | .IP "\fB\-4\fR" 5 | |
166 | .IX Item "-4" | |
167 | Restrict name resolution and IPs to IPv4 addresses. | |
168 | .IP "\fB\-6\fR" 5 | |
169 | .IX Item "-6" | |
170 | Restrict name resolution and IPs to IPv6 addresses. If the program name is | |
171 | \&'fping6' (via a sym-link, for example), then '\-6' is implicitly added. | |
172 | 165 | .IP "\fB\-a\fR" 5 |
173 | 166 | .IX Item "-a" |
174 | 167 | Show systems that are alive. |
0 | 0 | #!/bin/sh |
1 | 1 | # install - install a program, script, or datafile |
2 | 2 | |
3 | scriptversion=2011-01-19.21; # UTC | |
3 | scriptversion=2011-11-20.07; # UTC | |
4 | 4 | |
5 | 5 | # This originates from X11R5 (mit/util/scripts/install.sh), which was |
6 | 6 | # later released in X11R6 (xc/config/util/install.sh) with the |
34 | 34 | # FSF changes to this file are in the public domain. |
35 | 35 | # |
36 | 36 | # Calling this script install-sh is preferred over install.sh, to prevent |
37 | # `make' implicit rules from creating a file called install from it | |
37 | # 'make' implicit rules from creating a file called install from it | |
38 | 38 | # when there is no Makefile. |
39 | 39 | # |
40 | 40 | # This script is compatible with the BSD install script, but was written |
155 | 155 | -s) stripcmd=$stripprog;; |
156 | 156 | |
157 | 157 | -t) dst_arg=$2 |
158 | # Protect names problematic for `test' and other utilities. | |
158 | # Protect names problematic for 'test' and other utilities. | |
159 | 159 | case $dst_arg in |
160 | 160 | -* | [=\(\)!]) dst_arg=./$dst_arg;; |
161 | 161 | esac |
189 | 189 | fi |
190 | 190 | shift # arg |
191 | 191 | dst_arg=$arg |
192 | # Protect names problematic for `test' and other utilities. | |
192 | # Protect names problematic for 'test' and other utilities. | |
193 | 193 | case $dst_arg in |
194 | 194 | -* | [=\(\)!]) dst_arg=./$dst_arg;; |
195 | 195 | esac |
201 | 201 | echo "$0: no input file specified." >&2 |
202 | 202 | exit 1 |
203 | 203 | fi |
204 | # It's OK to call `install-sh -d' without argument. | |
204 | # It's OK to call 'install-sh -d' without argument. | |
205 | 205 | # This can happen when creating conditional directories. |
206 | 206 | exit 0 |
207 | 207 | fi |
239 | 239 | |
240 | 240 | for src |
241 | 241 | do |
242 | # Protect names problematic for `test' and other utilities. | |
242 | # Protect names problematic for 'test' and other utilities. | |
243 | 243 | case $src in |
244 | 244 | -* | [=\(\)!]) src=./$src;; |
245 | 245 | esac |
353 | 353 | if test -z "$dir_arg" || { |
354 | 354 | # Check for POSIX incompatibilities with -m. |
355 | 355 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or |
356 | # other-writeable bit of parent directory when it shouldn't. | |
356 | # other-writable bit of parent directory when it shouldn't. | |
357 | 357 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. |
358 | 358 | ls_ld_tmpdir=`ls -ld "$tmpdir"` |
359 | 359 | case $ls_ld_tmpdir in |
0 | 0 | #! /bin/sh |
1 | # Common stub for a few missing GNU programs while installing. | |
2 | ||
3 | scriptversion=2012-01-06.13; # UTC | |
4 | ||
5 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, | |
6 | # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. | |
7 | # Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. | |
1 | # Common wrapper for a few potentially missing GNU programs. | |
2 | ||
3 | scriptversion=2013-10-28.13; # UTC | |
4 | ||
5 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. | |
6 | # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. | |
8 | 7 | |
9 | 8 | # This program is free software; you can redistribute it and/or modify |
10 | 9 | # it under the terms of the GNU General Public License as published by |
25 | 24 | # the same distribution terms that you use for the rest of that program. |
26 | 25 | |
27 | 26 | if test $# -eq 0; then |
28 | echo 1>&2 "Try \`$0 --help' for more information" | |
27 | echo 1>&2 "Try '$0 --help' for more information" | |
29 | 28 | exit 1 |
30 | 29 | fi |
31 | 30 | |
32 | run=: | |
33 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' | |
34 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' | |
35 | ||
36 | # In the cases where this matters, `missing' is being run in the | |
37 | # srcdir already. | |
38 | if test -f configure.ac; then | |
39 | configure_ac=configure.ac | |
40 | else | |
41 | configure_ac=configure.in | |
42 | fi | |
43 | ||
44 | msg="missing on your system" | |
45 | ||
46 | 31 | case $1 in |
47 | --run) | |
48 | # Try to run requested program, and just exit if it succeeds. | |
49 | run= | |
50 | shift | |
51 | "$@" && exit 0 | |
52 | # Exit code 63 means version mismatch. This often happens | |
53 | # when the user try to use an ancient version of a tool on | |
54 | # a file that requires a minimum version. In this case we | |
55 | # we should proceed has if the program had been absent, or | |
56 | # if --run hadn't been passed. | |
57 | if test $? = 63; then | |
58 | run=: | |
59 | msg="probably too old" | |
60 | fi | |
61 | ;; | |
32 | ||
33 | --is-lightweight) | |
34 | # Used by our autoconf macros to check whether the available missing | |
35 | # script is modern enough. | |
36 | exit 0 | |
37 | ;; | |
38 | ||
39 | --run) | |
40 | # Back-compat with the calling convention used by older automake. | |
41 | shift | |
42 | ;; | |
62 | 43 | |
63 | 44 | -h|--h|--he|--hel|--help) |
64 | 45 | echo "\ |
65 | 46 | $0 [OPTION]... PROGRAM [ARGUMENT]... |
66 | 47 | |
67 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an | |
68 | error status if there is no known handling for PROGRAM. | |
48 | Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due | |
49 | to PROGRAM being missing or too old. | |
69 | 50 | |
70 | 51 | Options: |
71 | 52 | -h, --help display this help and exit |
72 | 53 | -v, --version output version information and exit |
73 | --run try to run the given command, and emulate it if it fails | |
74 | 54 | |
75 | 55 | Supported PROGRAM values: |
76 | aclocal touch file \`aclocal.m4' | |
77 | autoconf touch file \`configure' | |
78 | autoheader touch file \`config.h.in' | |
79 | autom4te touch the output file, or create a stub one | |
80 | automake touch all \`Makefile.in' files | |
81 | bison create \`y.tab.[ch]', if possible, from existing .[ch] | |
82 | flex create \`lex.yy.c', if possible, from existing .c | |
83 | help2man touch the output file | |
84 | lex create \`lex.yy.c', if possible, from existing .c | |
85 | makeinfo touch the output file | |
86 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] | |
87 | ||
88 | Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and | |
89 | \`g' are ignored when checking the name. | |
56 | aclocal autoconf autoheader autom4te automake makeinfo | |
57 | bison yacc flex lex help2man | |
58 | ||
59 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and | |
60 | 'g' are ignored when checking the name. | |
90 | 61 | |
91 | 62 | Send bug reports to <bug-automake@gnu.org>." |
92 | 63 | exit $? |
98 | 69 | ;; |
99 | 70 | |
100 | 71 | -*) |
101 | echo 1>&2 "$0: Unknown \`$1' option" | |
102 | echo 1>&2 "Try \`$0 --help' for more information" | |
72 | echo 1>&2 "$0: unknown '$1' option" | |
73 | echo 1>&2 "Try '$0 --help' for more information" | |
103 | 74 | exit 1 |
104 | 75 | ;; |
105 | 76 | |
106 | 77 | esac |
107 | 78 | |
108 | # normalize program name to check for. | |
109 | program=`echo "$1" | sed ' | |
110 | s/^gnu-//; t | |
111 | s/^gnu//; t | |
112 | s/^g//; t'` | |
113 | ||
114 | # Now exit if we have it, but it failed. Also exit now if we | |
115 | # don't have it and --version was passed (most likely to detect | |
116 | # the program). This is about non-GNU programs, so use $1 not | |
117 | # $program. | |
118 | case $1 in | |
119 | lex*|yacc*) | |
120 | # Not GNU programs, they don't have --version. | |
121 | ;; | |
122 | ||
123 | *) | |
124 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then | |
125 | # We have it, but it failed. | |
126 | exit 1 | |
127 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then | |
128 | # Could not run --version or --help. This is probably someone | |
129 | # running `$TOOL --version' or `$TOOL --help' to check whether | |
130 | # $TOOL exists and not knowing $TOOL uses missing. | |
131 | exit 1 | |
132 | fi | |
133 | ;; | |
134 | esac | |
135 | ||
136 | # If it does not exist, or fails to run (possibly an outdated version), | |
137 | # try to emulate it. | |
138 | case $program in | |
139 | aclocal*) | |
140 | echo 1>&2 "\ | |
141 | WARNING: \`$1' is $msg. You should only need it if | |
142 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want | |
143 | to install the \`Automake' and \`Perl' packages. Grab them from | |
144 | any GNU archive site." | |
145 | touch aclocal.m4 | |
146 | ;; | |
147 | ||
148 | autoconf*) | |
149 | echo 1>&2 "\ | |
150 | WARNING: \`$1' is $msg. You should only need it if | |
151 | you modified \`${configure_ac}'. You might want to install the | |
152 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU | |
153 | archive site." | |
154 | touch configure | |
155 | ;; | |
156 | ||
157 | autoheader*) | |
158 | echo 1>&2 "\ | |
159 | WARNING: \`$1' is $msg. You should only need it if | |
160 | you modified \`acconfig.h' or \`${configure_ac}'. You might want | |
161 | to install the \`Autoconf' and \`GNU m4' packages. Grab them | |
162 | from any GNU archive site." | |
163 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` | |
164 | test -z "$files" && files="config.h" | |
165 | touch_files= | |
166 | for f in $files; do | |
167 | case $f in | |
168 | *:*) touch_files="$touch_files "`echo "$f" | | |
169 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; | |
170 | *) touch_files="$touch_files $f.in";; | |
171 | esac | |
172 | done | |
173 | touch $touch_files | |
174 | ;; | |
175 | ||
176 | automake*) | |
177 | echo 1>&2 "\ | |
178 | WARNING: \`$1' is $msg. You should only need it if | |
179 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. | |
180 | You might want to install the \`Automake' and \`Perl' packages. | |
181 | Grab them from any GNU archive site." | |
182 | find . -type f -name Makefile.am -print | | |
183 | sed 's/\.am$/.in/' | | |
184 | while read f; do touch "$f"; done | |
185 | ;; | |
186 | ||
187 | autom4te*) | |
188 | echo 1>&2 "\ | |
189 | WARNING: \`$1' is needed, but is $msg. | |
190 | You might have modified some files without having the | |
191 | proper tools for further handling them. | |
192 | You can get \`$1' as part of \`Autoconf' from any GNU | |
193 | archive site." | |
194 | ||
195 | file=`echo "$*" | sed -n "$sed_output"` | |
196 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` | |
197 | if test -f "$file"; then | |
198 | touch $file | |
199 | else | |
200 | test -z "$file" || exec >$file | |
201 | echo "#! /bin/sh" | |
202 | echo "# Created by GNU Automake missing as a replacement of" | |
203 | echo "# $ $@" | |
204 | echo "exit 0" | |
205 | chmod +x $file | |
206 | exit 1 | |
207 | fi | |
208 | ;; | |
209 | ||
210 | bison*|yacc*) | |
211 | echo 1>&2 "\ | |
212 | WARNING: \`$1' $msg. You should only need it if | |
213 | you modified a \`.y' file. You may need the \`Bison' package | |
214 | in order for those modifications to take effect. You can get | |
215 | \`Bison' from any GNU archive site." | |
216 | rm -f y.tab.c y.tab.h | |
217 | if test $# -ne 1; then | |
218 | eval LASTARG=\${$#} | |
219 | case $LASTARG in | |
220 | *.y) | |
221 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` | |
222 | if test -f "$SRCFILE"; then | |
223 | cp "$SRCFILE" y.tab.c | |
224 | fi | |
225 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` | |
226 | if test -f "$SRCFILE"; then | |
227 | cp "$SRCFILE" y.tab.h | |
228 | fi | |
229 | ;; | |
230 | esac | |
231 | fi | |
232 | if test ! -f y.tab.h; then | |
233 | echo >y.tab.h | |
234 | fi | |
235 | if test ! -f y.tab.c; then | |
236 | echo 'main() { return 0; }' >y.tab.c | |
237 | fi | |
238 | ;; | |
239 | ||
240 | lex*|flex*) | |
241 | echo 1>&2 "\ | |
242 | WARNING: \`$1' is $msg. You should only need it if | |
243 | you modified a \`.l' file. You may need the \`Flex' package | |
244 | in order for those modifications to take effect. You can get | |
245 | \`Flex' from any GNU archive site." | |
246 | rm -f lex.yy.c | |
247 | if test $# -ne 1; then | |
248 | eval LASTARG=\${$#} | |
249 | case $LASTARG in | |
250 | *.l) | |
251 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` | |
252 | if test -f "$SRCFILE"; then | |
253 | cp "$SRCFILE" lex.yy.c | |
254 | fi | |
255 | ;; | |
256 | esac | |
257 | fi | |
258 | if test ! -f lex.yy.c; then | |
259 | echo 'main() { return 0; }' >lex.yy.c | |
260 | fi | |
261 | ;; | |
262 | ||
263 | help2man*) | |
264 | echo 1>&2 "\ | |
265 | WARNING: \`$1' is $msg. You should only need it if | |
266 | you modified a dependency of a manual page. You may need the | |
267 | \`Help2man' package in order for those modifications to take | |
268 | effect. You can get \`Help2man' from any GNU archive site." | |
269 | ||
270 | file=`echo "$*" | sed -n "$sed_output"` | |
271 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` | |
272 | if test -f "$file"; then | |
273 | touch $file | |
274 | else | |
275 | test -z "$file" || exec >$file | |
276 | echo ".ab help2man is required to generate this page" | |
277 | exit $? | |
278 | fi | |
279 | ;; | |
280 | ||
281 | makeinfo*) | |
282 | echo 1>&2 "\ | |
283 | WARNING: \`$1' is $msg. You should only need it if | |
284 | you modified a \`.texi' or \`.texinfo' file, or any other file | |
285 | indirectly affecting the aspect of the manual. The spurious | |
286 | call might also be the consequence of using a buggy \`make' (AIX, | |
287 | DU, IRIX). You might want to install the \`Texinfo' package or | |
288 | the \`GNU make' package. Grab either from any GNU archive site." | |
289 | # The file to touch is that specified with -o ... | |
290 | file=`echo "$*" | sed -n "$sed_output"` | |
291 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` | |
292 | if test -z "$file"; then | |
293 | # ... or it is the one specified with @setfilename ... | |
294 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` | |
295 | file=`sed -n ' | |
296 | /^@setfilename/{ | |
297 | s/.* \([^ ]*\) *$/\1/ | |
298 | p | |
299 | q | |
300 | }' $infile` | |
301 | # ... or it is derived from the source name (dir/f.texi becomes f.info) | |
302 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info | |
303 | fi | |
304 | # If the file does not exist, the user really needs makeinfo; | |
305 | # let's fail without touching anything. | |
306 | test -f $file || exit 1 | |
307 | touch $file | |
308 | ;; | |
309 | ||
310 | *) | |
311 | echo 1>&2 "\ | |
312 | WARNING: \`$1' is needed, and is $msg. | |
313 | You might have modified some files without having the | |
314 | proper tools for further handling them. Check the \`README' file, | |
315 | it often tells you about the needed prerequisites for installing | |
316 | this package. You may also peek at any GNU archive site, in case | |
317 | some other package would contain this missing \`$1' program." | |
318 | exit 1 | |
319 | ;; | |
320 | esac | |
321 | ||
322 | exit 0 | |
79 | # Run the given program, remember its exit status. | |
80 | "$@"; st=$? | |
81 | ||
82 | # If it succeeded, we are done. | |
83 | test $st -eq 0 && exit 0 | |
84 | ||
85 | # Also exit now if we it failed (or wasn't found), and '--version' was | |
86 | # passed; such an option is passed most likely to detect whether the | |
87 | # program is present and works. | |
88 | case $2 in --version|--help) exit $st;; esac | |
89 | ||
90 | # Exit code 63 means version mismatch. This often happens when the user | |
91 | # tries to use an ancient version of a tool on a file that requires a | |
92 | # minimum version. | |
93 | if test $st -eq 63; then | |
94 | msg="probably too old" | |
95 | elif test $st -eq 127; then | |
96 | # Program was missing. | |
97 | msg="missing on your system" | |
98 | else | |
99 | # Program was found and executed, but failed. Give up. | |
100 | exit $st | |
101 | fi | |
102 | ||
103 | perl_URL=http://www.perl.org/ | |
104 | flex_URL=http://flex.sourceforge.net/ | |
105 | gnu_software_URL=http://www.gnu.org/software | |
106 | ||
107 | program_details () | |
108 | { | |
109 | case $1 in | |
110 | aclocal|automake) | |
111 | echo "The '$1' program is part of the GNU Automake package:" | |
112 | echo "<$gnu_software_URL/automake>" | |
113 | echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" | |
114 | echo "<$gnu_software_URL/autoconf>" | |
115 | echo "<$gnu_software_URL/m4/>" | |
116 | echo "<$perl_URL>" | |
117 | ;; | |
118 | autoconf|autom4te|autoheader) | |
119 | echo "The '$1' program is part of the GNU Autoconf package:" | |
120 | echo "<$gnu_software_URL/autoconf/>" | |
121 | echo "It also requires GNU m4 and Perl in order to run:" | |
122 | echo "<$gnu_software_URL/m4/>" | |
123 | echo "<$perl_URL>" | |
124 | ;; | |
125 | esac | |
126 | } | |
127 | ||
128 | give_advice () | |
129 | { | |
130 | # Normalize program name to check for. | |
131 | normalized_program=`echo "$1" | sed ' | |
132 | s/^gnu-//; t | |
133 | s/^gnu//; t | |
134 | s/^g//; t'` | |
135 | ||
136 | printf '%s\n' "'$1' is $msg." | |
137 | ||
138 | configure_deps="'configure.ac' or m4 files included by 'configure.ac'" | |
139 | case $normalized_program in | |
140 | autoconf*) | |
141 | echo "You should only need it if you modified 'configure.ac'," | |
142 | echo "or m4 files included by it." | |
143 | program_details 'autoconf' | |
144 | ;; | |
145 | autoheader*) | |
146 | echo "You should only need it if you modified 'acconfig.h' or" | |
147 | echo "$configure_deps." | |
148 | program_details 'autoheader' | |
149 | ;; | |
150 | automake*) | |
151 | echo "You should only need it if you modified 'Makefile.am' or" | |
152 | echo "$configure_deps." | |
153 | program_details 'automake' | |
154 | ;; | |
155 | aclocal*) | |
156 | echo "You should only need it if you modified 'acinclude.m4' or" | |
157 | echo "$configure_deps." | |
158 | program_details 'aclocal' | |
159 | ;; | |
160 | autom4te*) | |
161 | echo "You might have modified some maintainer files that require" | |
162 | echo "the 'autom4te' program to be rebuilt." | |
163 | program_details 'autom4te' | |
164 | ;; | |
165 | bison*|yacc*) | |
166 | echo "You should only need it if you modified a '.y' file." | |
167 | echo "You may want to install the GNU Bison package:" | |
168 | echo "<$gnu_software_URL/bison/>" | |
169 | ;; | |
170 | lex*|flex*) | |
171 | echo "You should only need it if you modified a '.l' file." | |
172 | echo "You may want to install the Fast Lexical Analyzer package:" | |
173 | echo "<$flex_URL>" | |
174 | ;; | |
175 | help2man*) | |
176 | echo "You should only need it if you modified a dependency" \ | |
177 | "of a man page." | |
178 | echo "You may want to install the GNU Help2man package:" | |
179 | echo "<$gnu_software_URL/help2man/>" | |
180 | ;; | |
181 | makeinfo*) | |
182 | echo "You should only need it if you modified a '.texi' file, or" | |
183 | echo "any other file indirectly affecting the aspect of the manual." | |
184 | echo "You might want to install the Texinfo package:" | |
185 | echo "<$gnu_software_URL/texinfo/>" | |
186 | echo "The spurious makeinfo call might also be the consequence of" | |
187 | echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" | |
188 | echo "want to install GNU make:" | |
189 | echo "<$gnu_software_URL/make/>" | |
190 | ;; | |
191 | *) | |
192 | echo "You might have modified some files without having the proper" | |
193 | echo "tools for further handling them. Check the 'README' file, it" | |
194 | echo "often tells you about the needed prerequisites for installing" | |
195 | echo "this package. You may also peek at any GNU archive site, in" | |
196 | echo "case some other package contains this missing '$1' program." | |
197 | ;; | |
198 | esac | |
199 | } | |
200 | ||
201 | give_advice "$1" | sed -e '1s/^/WARNING: /' \ | |
202 | -e '2,$s/^/ /' >&2 | |
203 | ||
204 | # Propagate the correct exit status (expected to be 127 for a program | |
205 | # not found, 63 for a program that failed due to version mismatch). | |
206 | exit $st | |
323 | 207 | |
324 | 208 | # Local variables: |
325 | 209 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
0 | 0 | AM_CFLAGS = -Wall -Wextra -Wno-sign-compare |
1 | 1 | |
2 | sbin_PROGRAMS = fping | |
2 | prog = | |
3 | 3 | |
4 | fping_SOURCES = fping.c seqmap.c socket4.c fping.h options.h seqmap.h | |
4 | if IPV4 | |
5 | prog += fping | |
6 | endif | |
7 | if IPV6 | |
8 | prog += fping6 | |
9 | endif | |
10 | ||
11 | sbin_PROGRAMS = ${prog} | |
12 | ||
13 | fping_SOURCES = fping.c seqmap.c socket.c socket4.c fping.h options.h seqmap.h | |
5 | 14 | fping_DEPENDENCIES = ../config.h |
6 | ||
7 | if IPV6 | |
8 | fping_SOURCES += socket6.c | |
9 | fping_CFLAGS = $(AM_CFLAGS) -DIPV6 | |
10 | install-exec-hook: | |
11 | ln -s fping$(EXEEXT) $(DESTDIR)$(sbindir)/fping6 | |
12 | endif | |
15 | fping6_SOURCES = fping.c seqmap.c socket.c socket6.c fping.h options.h seqmap.h | |
16 | fping6_DEPENDENCIES = ../config.h | |
17 | fping6_CFLAGS = $(AM_CFLAGS) -DIPV6 |
78 | 78 | build_triplet = @build@ |
79 | 79 | host_triplet = @host@ |
80 | 80 | target_triplet = @target@ |
81 | sbin_PROGRAMS = fping$(EXEEXT) | |
82 | @IPV6_TRUE@am__append_1 = socket6.c | |
81 | @IPV4_TRUE@am__append_1 = fping | |
82 | @IPV6_TRUE@am__append_2 = fping6 | |
83 | sbin_PROGRAMS = $(am__EXEEXT_3) | |
83 | 84 | subdir = src |
84 | 85 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
85 | 86 | $(top_srcdir)/depcomp |
91 | 92 | CONFIG_HEADER = $(top_builddir)/config.h |
92 | 93 | CONFIG_CLEAN_FILES = |
93 | 94 | CONFIG_CLEAN_VPATH_FILES = |
95 | @IPV4_TRUE@am__EXEEXT_1 = fping$(EXEEXT) | |
96 | @IPV6_TRUE@am__EXEEXT_2 = fping6$(EXEEXT) | |
97 | am__EXEEXT_3 = $(am__EXEEXT_1) $(am__EXEEXT_2) | |
94 | 98 | am__installdirs = "$(DESTDIR)$(sbindir)" |
95 | 99 | PROGRAMS = $(sbin_PROGRAMS) |
96 | am__fping_SOURCES_DIST = fping.c seqmap.c socket4.c fping.h options.h \ | |
97 | seqmap.h socket6.c | |
98 | @IPV6_TRUE@am__objects_1 = fping-socket6.$(OBJEXT) | |
99 | am_fping_OBJECTS = fping-fping.$(OBJEXT) fping-seqmap.$(OBJEXT) \ | |
100 | fping-socket4.$(OBJEXT) $(am__objects_1) | |
100 | am_fping_OBJECTS = fping.$(OBJEXT) seqmap.$(OBJEXT) socket.$(OBJEXT) \ | |
101 | socket4.$(OBJEXT) | |
101 | 102 | fping_OBJECTS = $(am_fping_OBJECTS) |
102 | 103 | fping_LDADD = $(LDADD) |
103 | fping_LINK = $(CCLD) $(fping_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ | |
104 | am_fping6_OBJECTS = fping6-fping.$(OBJEXT) fping6-seqmap.$(OBJEXT) \ | |
105 | fping6-socket.$(OBJEXT) fping6-socket6.$(OBJEXT) | |
106 | fping6_OBJECTS = $(am_fping6_OBJECTS) | |
107 | fping6_LDADD = $(LDADD) | |
108 | fping6_LINK = $(CCLD) $(fping6_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ | |
104 | 109 | $(LDFLAGS) -o $@ |
105 | 110 | AM_V_P = $(am__v_P_@AM_V@) |
106 | 111 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) |
134 | 139 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) |
135 | 140 | am__v_CCLD_0 = @echo " CCLD " $@; |
136 | 141 | am__v_CCLD_1 = |
137 | SOURCES = $(fping_SOURCES) | |
138 | DIST_SOURCES = $(am__fping_SOURCES_DIST) | |
142 | SOURCES = $(fping_SOURCES) $(fping6_SOURCES) | |
143 | DIST_SOURCES = $(fping_SOURCES) $(fping6_SOURCES) | |
139 | 144 | am__can_run_installinfo = \ |
140 | 145 | case $$AM_UPDATE_INFO_DIR in \ |
141 | 146 | n|no|NO) false;; \ |
262 | 267 | top_builddir = @top_builddir@ |
263 | 268 | top_srcdir = @top_srcdir@ |
264 | 269 | AM_CFLAGS = -Wall -Wextra -Wno-sign-compare |
265 | fping_SOURCES = fping.c seqmap.c socket4.c fping.h options.h seqmap.h \ | |
266 | $(am__append_1) | |
270 | prog = $(am__append_1) $(am__append_2) | |
271 | fping_SOURCES = fping.c seqmap.c socket.c socket4.c fping.h options.h seqmap.h | |
267 | 272 | fping_DEPENDENCIES = ../config.h |
268 | @IPV6_TRUE@fping_CFLAGS = $(AM_CFLAGS) -DIPV6 | |
273 | fping6_SOURCES = fping.c seqmap.c socket.c socket6.c fping.h options.h seqmap.h | |
274 | fping6_DEPENDENCIES = ../config.h | |
275 | fping6_CFLAGS = $(AM_CFLAGS) -DIPV6 | |
269 | 276 | all: all-am |
270 | 277 | |
271 | 278 | .SUFFIXES: |
345 | 352 | |
346 | 353 | fping$(EXEEXT): $(fping_OBJECTS) $(fping_DEPENDENCIES) $(EXTRA_fping_DEPENDENCIES) |
347 | 354 | @rm -f fping$(EXEEXT) |
348 | $(AM_V_CCLD)$(fping_LINK) $(fping_OBJECTS) $(fping_LDADD) $(LIBS) | |
355 | $(AM_V_CCLD)$(LINK) $(fping_OBJECTS) $(fping_LDADD) $(LIBS) | |
356 | ||
357 | fping6$(EXEEXT): $(fping6_OBJECTS) $(fping6_DEPENDENCIES) $(EXTRA_fping6_DEPENDENCIES) | |
358 | @rm -f fping6$(EXEEXT) | |
359 | $(AM_V_CCLD)$(fping6_LINK) $(fping6_OBJECTS) $(fping6_LDADD) $(LIBS) | |
349 | 360 | |
350 | 361 | mostlyclean-compile: |
351 | 362 | -rm -f *.$(OBJEXT) |
353 | 364 | distclean-compile: |
354 | 365 | -rm -f *.tab.c |
355 | 366 | |
356 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping-fping.Po@am__quote@ | |
357 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping-seqmap.Po@am__quote@ | |
358 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping-socket4.Po@am__quote@ | |
359 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping-socket6.Po@am__quote@ | |
367 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping.Po@am__quote@ | |
368 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping6-fping.Po@am__quote@ | |
369 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping6-seqmap.Po@am__quote@ | |
370 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping6-socket.Po@am__quote@ | |
371 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fping6-socket6.Po@am__quote@ | |
372 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seqmap.Po@am__quote@ | |
373 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Po@am__quote@ | |
374 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket4.Po@am__quote@ | |
360 | 375 | |
361 | 376 | .c.o: |
362 | 377 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
372 | 387 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
373 | 388 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` |
374 | 389 | |
375 | fping-fping.o: fping.c | |
376 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-fping.o -MD -MP -MF $(DEPDIR)/fping-fping.Tpo -c -o fping-fping.o `test -f 'fping.c' || echo '$(srcdir)/'`fping.c | |
377 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-fping.Tpo $(DEPDIR)/fping-fping.Po | |
378 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fping.c' object='fping-fping.o' libtool=no @AMDEPBACKSLASH@ | |
379 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
380 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-fping.o `test -f 'fping.c' || echo '$(srcdir)/'`fping.c | |
381 | ||
382 | fping-fping.obj: fping.c | |
383 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-fping.obj -MD -MP -MF $(DEPDIR)/fping-fping.Tpo -c -o fping-fping.obj `if test -f 'fping.c'; then $(CYGPATH_W) 'fping.c'; else $(CYGPATH_W) '$(srcdir)/fping.c'; fi` | |
384 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-fping.Tpo $(DEPDIR)/fping-fping.Po | |
385 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fping.c' object='fping-fping.obj' libtool=no @AMDEPBACKSLASH@ | |
386 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
387 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-fping.obj `if test -f 'fping.c'; then $(CYGPATH_W) 'fping.c'; else $(CYGPATH_W) '$(srcdir)/fping.c'; fi` | |
388 | ||
389 | fping-seqmap.o: seqmap.c | |
390 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-seqmap.o -MD -MP -MF $(DEPDIR)/fping-seqmap.Tpo -c -o fping-seqmap.o `test -f 'seqmap.c' || echo '$(srcdir)/'`seqmap.c | |
391 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-seqmap.Tpo $(DEPDIR)/fping-seqmap.Po | |
392 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='seqmap.c' object='fping-seqmap.o' libtool=no @AMDEPBACKSLASH@ | |
393 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
394 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-seqmap.o `test -f 'seqmap.c' || echo '$(srcdir)/'`seqmap.c | |
395 | ||
396 | fping-seqmap.obj: seqmap.c | |
397 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-seqmap.obj -MD -MP -MF $(DEPDIR)/fping-seqmap.Tpo -c -o fping-seqmap.obj `if test -f 'seqmap.c'; then $(CYGPATH_W) 'seqmap.c'; else $(CYGPATH_W) '$(srcdir)/seqmap.c'; fi` | |
398 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-seqmap.Tpo $(DEPDIR)/fping-seqmap.Po | |
399 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='seqmap.c' object='fping-seqmap.obj' libtool=no @AMDEPBACKSLASH@ | |
400 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
401 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-seqmap.obj `if test -f 'seqmap.c'; then $(CYGPATH_W) 'seqmap.c'; else $(CYGPATH_W) '$(srcdir)/seqmap.c'; fi` | |
402 | ||
403 | fping-socket4.o: socket4.c | |
404 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-socket4.o -MD -MP -MF $(DEPDIR)/fping-socket4.Tpo -c -o fping-socket4.o `test -f 'socket4.c' || echo '$(srcdir)/'`socket4.c | |
405 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-socket4.Tpo $(DEPDIR)/fping-socket4.Po | |
406 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket4.c' object='fping-socket4.o' libtool=no @AMDEPBACKSLASH@ | |
407 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
408 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-socket4.o `test -f 'socket4.c' || echo '$(srcdir)/'`socket4.c | |
409 | ||
410 | fping-socket4.obj: socket4.c | |
411 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-socket4.obj -MD -MP -MF $(DEPDIR)/fping-socket4.Tpo -c -o fping-socket4.obj `if test -f 'socket4.c'; then $(CYGPATH_W) 'socket4.c'; else $(CYGPATH_W) '$(srcdir)/socket4.c'; fi` | |
412 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-socket4.Tpo $(DEPDIR)/fping-socket4.Po | |
413 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket4.c' object='fping-socket4.obj' libtool=no @AMDEPBACKSLASH@ | |
414 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
415 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-socket4.obj `if test -f 'socket4.c'; then $(CYGPATH_W) 'socket4.c'; else $(CYGPATH_W) '$(srcdir)/socket4.c'; fi` | |
416 | ||
417 | fping-socket6.o: socket6.c | |
418 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-socket6.o -MD -MP -MF $(DEPDIR)/fping-socket6.Tpo -c -o fping-socket6.o `test -f 'socket6.c' || echo '$(srcdir)/'`socket6.c | |
419 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-socket6.Tpo $(DEPDIR)/fping-socket6.Po | |
420 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket6.c' object='fping-socket6.o' libtool=no @AMDEPBACKSLASH@ | |
421 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
422 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-socket6.o `test -f 'socket6.c' || echo '$(srcdir)/'`socket6.c | |
423 | ||
424 | fping-socket6.obj: socket6.c | |
425 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -MT fping-socket6.obj -MD -MP -MF $(DEPDIR)/fping-socket6.Tpo -c -o fping-socket6.obj `if test -f 'socket6.c'; then $(CYGPATH_W) 'socket6.c'; else $(CYGPATH_W) '$(srcdir)/socket6.c'; fi` | |
426 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping-socket6.Tpo $(DEPDIR)/fping-socket6.Po | |
427 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket6.c' object='fping-socket6.obj' libtool=no @AMDEPBACKSLASH@ | |
428 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
429 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping_CFLAGS) $(CFLAGS) -c -o fping-socket6.obj `if test -f 'socket6.c'; then $(CYGPATH_W) 'socket6.c'; else $(CYGPATH_W) '$(srcdir)/socket6.c'; fi` | |
390 | fping6-fping.o: fping.c | |
391 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-fping.o -MD -MP -MF $(DEPDIR)/fping6-fping.Tpo -c -o fping6-fping.o `test -f 'fping.c' || echo '$(srcdir)/'`fping.c | |
392 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-fping.Tpo $(DEPDIR)/fping6-fping.Po | |
393 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fping.c' object='fping6-fping.o' libtool=no @AMDEPBACKSLASH@ | |
394 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
395 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-fping.o `test -f 'fping.c' || echo '$(srcdir)/'`fping.c | |
396 | ||
397 | fping6-fping.obj: fping.c | |
398 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-fping.obj -MD -MP -MF $(DEPDIR)/fping6-fping.Tpo -c -o fping6-fping.obj `if test -f 'fping.c'; then $(CYGPATH_W) 'fping.c'; else $(CYGPATH_W) '$(srcdir)/fping.c'; fi` | |
399 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-fping.Tpo $(DEPDIR)/fping6-fping.Po | |
400 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fping.c' object='fping6-fping.obj' libtool=no @AMDEPBACKSLASH@ | |
401 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
402 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-fping.obj `if test -f 'fping.c'; then $(CYGPATH_W) 'fping.c'; else $(CYGPATH_W) '$(srcdir)/fping.c'; fi` | |
403 | ||
404 | fping6-seqmap.o: seqmap.c | |
405 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-seqmap.o -MD -MP -MF $(DEPDIR)/fping6-seqmap.Tpo -c -o fping6-seqmap.o `test -f 'seqmap.c' || echo '$(srcdir)/'`seqmap.c | |
406 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-seqmap.Tpo $(DEPDIR)/fping6-seqmap.Po | |
407 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='seqmap.c' object='fping6-seqmap.o' libtool=no @AMDEPBACKSLASH@ | |
408 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
409 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-seqmap.o `test -f 'seqmap.c' || echo '$(srcdir)/'`seqmap.c | |
410 | ||
411 | fping6-seqmap.obj: seqmap.c | |
412 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-seqmap.obj -MD -MP -MF $(DEPDIR)/fping6-seqmap.Tpo -c -o fping6-seqmap.obj `if test -f 'seqmap.c'; then $(CYGPATH_W) 'seqmap.c'; else $(CYGPATH_W) '$(srcdir)/seqmap.c'; fi` | |
413 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-seqmap.Tpo $(DEPDIR)/fping6-seqmap.Po | |
414 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='seqmap.c' object='fping6-seqmap.obj' libtool=no @AMDEPBACKSLASH@ | |
415 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
416 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-seqmap.obj `if test -f 'seqmap.c'; then $(CYGPATH_W) 'seqmap.c'; else $(CYGPATH_W) '$(srcdir)/seqmap.c'; fi` | |
417 | ||
418 | fping6-socket.o: socket.c | |
419 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-socket.o -MD -MP -MF $(DEPDIR)/fping6-socket.Tpo -c -o fping6-socket.o `test -f 'socket.c' || echo '$(srcdir)/'`socket.c | |
420 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-socket.Tpo $(DEPDIR)/fping6-socket.Po | |
421 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket.c' object='fping6-socket.o' libtool=no @AMDEPBACKSLASH@ | |
422 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
423 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-socket.o `test -f 'socket.c' || echo '$(srcdir)/'`socket.c | |
424 | ||
425 | fping6-socket.obj: socket.c | |
426 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-socket.obj -MD -MP -MF $(DEPDIR)/fping6-socket.Tpo -c -o fping6-socket.obj `if test -f 'socket.c'; then $(CYGPATH_W) 'socket.c'; else $(CYGPATH_W) '$(srcdir)/socket.c'; fi` | |
427 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-socket.Tpo $(DEPDIR)/fping6-socket.Po | |
428 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket.c' object='fping6-socket.obj' libtool=no @AMDEPBACKSLASH@ | |
429 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
430 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-socket.obj `if test -f 'socket.c'; then $(CYGPATH_W) 'socket.c'; else $(CYGPATH_W) '$(srcdir)/socket.c'; fi` | |
431 | ||
432 | fping6-socket6.o: socket6.c | |
433 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-socket6.o -MD -MP -MF $(DEPDIR)/fping6-socket6.Tpo -c -o fping6-socket6.o `test -f 'socket6.c' || echo '$(srcdir)/'`socket6.c | |
434 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-socket6.Tpo $(DEPDIR)/fping6-socket6.Po | |
435 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket6.c' object='fping6-socket6.o' libtool=no @AMDEPBACKSLASH@ | |
436 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
437 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-socket6.o `test -f 'socket6.c' || echo '$(srcdir)/'`socket6.c | |
438 | ||
439 | fping6-socket6.obj: socket6.c | |
440 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -MT fping6-socket6.obj -MD -MP -MF $(DEPDIR)/fping6-socket6.Tpo -c -o fping6-socket6.obj `if test -f 'socket6.c'; then $(CYGPATH_W) 'socket6.c'; else $(CYGPATH_W) '$(srcdir)/socket6.c'; fi` | |
441 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fping6-socket6.Tpo $(DEPDIR)/fping6-socket6.Po | |
442 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='socket6.c' object='fping6-socket6.obj' libtool=no @AMDEPBACKSLASH@ | |
443 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
444 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fping6_CFLAGS) $(CFLAGS) -c -o fping6-socket6.obj `if test -f 'socket6.c'; then $(CYGPATH_W) 'socket6.c'; else $(CYGPATH_W) '$(srcdir)/socket6.c'; fi` | |
430 | 445 | |
431 | 446 | ID: $(am__tagged_files) |
432 | 447 | $(am__define_uniq_tagged_files); mkid -fID $$unique |
547 | 562 | maintainer-clean-generic: |
548 | 563 | @echo "This command is intended for maintainers to use" |
549 | 564 | @echo "it deletes files that may require special tools to rebuild." |
550 | @IPV6_FALSE@install-exec-hook: | |
551 | 565 | clean: clean-am |
552 | 566 | |
553 | 567 | clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am |
577 | 591 | install-dvi-am: |
578 | 592 | |
579 | 593 | install-exec-am: install-sbinPROGRAMS |
580 | @$(NORMAL_INSTALL) | |
581 | $(MAKE) $(AM_MAKEFLAGS) install-exec-hook | |
594 | ||
582 | 595 | install-html: install-html-am |
583 | 596 | |
584 | 597 | install-html-am: |
618 | 631 | |
619 | 632 | uninstall-am: uninstall-sbinPROGRAMS |
620 | 633 | |
621 | .MAKE: install-am install-exec-am install-strip | |
634 | .MAKE: install-am install-strip | |
622 | 635 | |
623 | 636 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ |
624 | 637 | clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \ |
625 | 638 | distclean-compile distclean-generic distclean-tags distdir dvi \ |
626 | 639 | dvi-am html html-am info info-am install install-am \ |
627 | 640 | install-data install-data-am install-dvi install-dvi-am \ |
628 | install-exec install-exec-am install-exec-hook install-html \ | |
629 | install-html-am install-info install-info-am install-man \ | |
630 | install-pdf install-pdf-am install-ps install-ps-am \ | |
631 | install-sbinPROGRAMS install-strip installcheck \ | |
632 | installcheck-am installdirs maintainer-clean \ | |
633 | maintainer-clean-generic mostlyclean mostlyclean-compile \ | |
634 | mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ | |
635 | uninstall-am uninstall-sbinPROGRAMS | |
636 | ||
637 | @IPV6_TRUE@install-exec-hook: | |
638 | @IPV6_TRUE@ ln -s fping$(EXEEXT) $(DESTDIR)$(sbindir)/fping6 | |
641 | install-exec install-exec-am install-html install-html-am \ | |
642 | install-info install-info-am install-man install-pdf \ | |
643 | install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \ | |
644 | install-strip installcheck installcheck-am installdirs \ | |
645 | maintainer-clean maintainer-clean-generic mostlyclean \ | |
646 | mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ | |
647 | tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS | |
648 | ||
639 | 649 | |
640 | 650 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
641 | 651 | # Otherwise a system limit (for SysV at least) may be exceeded. |
30 | 30 | */ |
31 | 31 | |
32 | 32 | #ifdef __cplusplus |
33 | extern "C" | |
34 | { | |
33 | extern "C" { | |
35 | 34 | #endif /* __cplusplus */ |
36 | 35 | |
37 | 36 | #include "fping.h" |
39 | 38 | |
40 | 39 | /*** autoconf includes ***/ |
41 | 40 | |
42 | ||
43 | #include <stdio.h> | |
44 | 41 | #include <errno.h> |
45 | #include <time.h> | |
46 | 42 | #include <signal.h> |
47 | 43 | #include <stdarg.h> |
44 | #include <stdio.h> | |
45 | #include <time.h> | |
48 | 46 | |
49 | 47 | #include "config.h" |
50 | 48 | #include "seqmap.h" |
57 | 55 | #include <stdlib.h> |
58 | 56 | #endif /* HAVE_STDLIB_H */ |
59 | 57 | |
58 | #include <stddef.h> | |
60 | 59 | #include <string.h> |
61 | #include <stddef.h> | |
62 | ||
60 | ||
61 | #include <sys/socket.h> | |
62 | #include <sys/time.h> | |
63 | 63 | #include <sys/types.h> |
64 | #include <sys/time.h> | |
65 | #include <sys/socket.h> | |
66 | 64 | |
67 | 65 | #if HAVE_SYS_FILE_H |
68 | 66 | #include <sys/file.h> |
77 | 75 | #include <netinet/ip_icmp.h> |
78 | 76 | |
79 | 77 | #include <arpa/inet.h> |
78 | #include <ctype.h> | |
80 | 79 | #include <netdb.h> |
81 | #include <ctype.h> | |
82 | ||
80 | ||
81 | /* RS6000 hasn't getopt.h */ | |
82 | #ifdef HAVE_GETOPT_H | |
83 | 83 | #include <getopt.h> |
84 | ||
84 | #endif /* HAVE_GETOPT_H */ | |
85 | ||
86 | /* RS6000 has sys/select.h */ | |
87 | #ifdef HAVE_SYS_SELECT_H | |
85 | 88 | #include <sys/select.h> |
89 | #endif /* HAVE_SYS_SELECT_H */ | |
86 | 90 | |
87 | 91 | /*** externals ***/ |
88 | 92 | |
89 | extern char *optarg; | |
90 | extern int optind,opterr; | |
93 | extern char* optarg; | |
94 | extern int optind, opterr; | |
91 | 95 | #ifndef h_errno |
92 | 96 | extern int h_errno; |
93 | 97 | #endif |
98 | 102 | |
99 | 103 | /*** Constants ***/ |
100 | 104 | |
101 | #define EMAIL "david@schweikert.ch" | |
105 | #define EMAIL "david@schweikert.ch" | |
102 | 106 | |
103 | 107 | /*** Ping packet defines ***/ |
104 | 108 | |
105 | #define MAX_IP_PACKET 65536 /* (theoretical) max IP packet size */ | |
106 | #define SIZE_IP_HDR 40 | |
107 | #define SIZE_ICMP_HDR 8 /* from ip_icmp.h */ | |
108 | #define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR ) | |
109 | ||
110 | #define MAX_GENERATE 100000 /* maximum number of hosts that -g can generate */ | |
109 | #define MAX_IP_PACKET 65536 /* (theoretical) max IP packet size */ | |
110 | #define SIZE_IP_HDR 40 | |
111 | #ifndef IPV6 | |
112 | #define SIZE_ICMP_HDR ICMP_MINLEN /* from ip_icmp.h */ | |
113 | #else | |
114 | #define SIZE_ICMP_HDR sizeof(FPING_ICMPHDR) | |
115 | #endif | |
116 | #define MAX_PING_DATA (MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR) | |
117 | ||
118 | #define MAX_GENERATE 100000 /* maximum number of hosts that -g can generate */ | |
111 | 119 | |
112 | 120 | /* sized so as to be like traditional ping */ |
113 | #define DEFAULT_PING_DATA_SIZE 56 | |
121 | #define DEFAULT_PING_DATA_SIZE 56 | |
114 | 122 | |
115 | 123 | /* maxima and minima */ |
116 | #define MIN_INTERVAL 1 /* in millisec */ | |
117 | #define MIN_PERHOST_INTERVAL 10 /* in millisec */ | |
124 | #define MIN_INTERVAL 1 /* in millisec */ | |
125 | #define MIN_PERHOST_INTERVAL 10 /* in millisec */ | |
118 | 126 | |
119 | 127 | /* response time array flags */ |
120 | #define RESP_WAITING -1 | |
121 | #define RESP_UNUSED -2 | |
122 | #define RESP_ERROR -3 | |
128 | #define RESP_WAITING -1 | |
129 | #define RESP_UNUSED -2 | |
130 | #define RESP_ERROR -3 | |
123 | 131 | |
124 | 132 | /* debugging flags */ |
125 | #if defined( DEBUG ) || defined( _DEBUG ) | |
126 | #define DBG_TRACE 1 | |
127 | #define DBG_SENT_TIMES 2 | |
128 | #define DBG_RANDOM_LOSE_FEW 4 | |
129 | #define DBG_RANDOM_LOSE_MANY 8 | |
130 | #define DBG_PRINT_PER_SYSTEM 16 | |
131 | #define DBG_REPORT_ALL_RTTS 32 | |
133 | #if defined(DEBUG) || defined(_DEBUG) | |
134 | #define DBG_TRACE 1 | |
135 | #define DBG_SENT_TIMES 2 | |
136 | #define DBG_RANDOM_LOSE_FEW 4 | |
137 | #define DBG_RANDOM_LOSE_MANY 8 | |
138 | #define DBG_PRINT_PER_SYSTEM 16 | |
139 | #define DBG_REPORT_ALL_RTTS 32 | |
132 | 140 | #endif /* DEBUG || _DEBUG */ |
133 | 141 | |
134 | 142 | /* Long names for ICMP packet types */ |
135 | 143 | #define ICMP_TYPE_STR_MAX 18 |
136 | char *icmp_type_str[19] = | |
137 | { | |
138 | "ICMP Echo Reply", /* 0 */ | |
144 | char* icmp_type_str[19] = { | |
145 | "ICMP Echo Reply", /* 0 */ | |
139 | 146 | "", |
140 | 147 | "", |
141 | "ICMP Unreachable", /* 3 */ | |
142 | "ICMP Source Quench", /* 4 */ | |
143 | "ICMP Redirect", /* 5 */ | |
148 | "ICMP Unreachable", /* 3 */ | |
149 | "ICMP Source Quench", /* 4 */ | |
150 | "ICMP Redirect", /* 5 */ | |
144 | 151 | "", |
145 | 152 | "", |
146 | "ICMP Echo", /* 8 */ | |
153 | "ICMP Echo", /* 8 */ | |
147 | 154 | "", |
148 | 155 | "", |
149 | "ICMP Time Exceeded", /* 11 */ | |
150 | "ICMP Parameter Problem", /* 12 */ | |
151 | "ICMP Timestamp Request", /* 13 */ | |
152 | "ICMP Timestamp Reply", /* 14 */ | |
156 | "ICMP Time Exceeded", /* 11 */ | |
157 | "ICMP Parameter Problem", /* 12 */ | |
158 | "ICMP Timestamp Request", /* 13 */ | |
159 | "ICMP Timestamp Reply", /* 14 */ | |
153 | 160 | "ICMP Information Request", /* 15 */ |
154 | "ICMP Information Reply", /* 16 */ | |
155 | "ICMP Mask Request", /* 17 */ | |
156 | "ICMP Mask Reply" /* 18 */ | |
161 | "ICMP Information Reply", /* 16 */ | |
162 | "ICMP Mask Request", /* 17 */ | |
163 | "ICMP Mask Reply" /* 18 */ | |
157 | 164 | }; |
158 | 165 | |
159 | char *icmp_unreach_str[16] = | |
160 | { | |
161 | "ICMP Network Unreachable", /* 0 */ | |
162 | "ICMP Host Unreachable", /* 1 */ | |
163 | "ICMP Protocol Unreachable", /* 2 */ | |
164 | "ICMP Port Unreachable", /* 3 */ | |
165 | "ICMP Unreachable (Fragmentation Needed)", /* 4 */ | |
166 | "ICMP Unreachable (Source Route Failed)", /* 5 */ | |
167 | "ICMP Unreachable (Destination Network Unknown)", /* 6 */ | |
168 | "ICMP Unreachable (Destination Host Unknown)", /* 7 */ | |
169 | "ICMP Unreachable (Source Host Isolated)", /* 8 */ | |
170 | "ICMP Unreachable (Communication with Network Prohibited)", /* 9 */ | |
171 | "ICMP Unreachable (Communication with Host Prohibited)", /* 10 */ | |
172 | "ICMP Unreachable (Network Unreachable For Type Of Service)", /* 11 */ | |
173 | "ICMP Unreachable (Host Unreachable For Type Of Service)", /* 12 */ | |
166 | char* icmp_unreach_str[16] = { | |
167 | "ICMP Network Unreachable", /* 0 */ | |
168 | "ICMP Host Unreachable", /* 1 */ | |
169 | "ICMP Protocol Unreachable", /* 2 */ | |
170 | "ICMP Port Unreachable", /* 3 */ | |
171 | "ICMP Unreachable (Fragmentation Needed)", /* 4 */ | |
172 | "ICMP Unreachable (Source Route Failed)", /* 5 */ | |
173 | "ICMP Unreachable (Destination Network Unknown)", /* 6 */ | |
174 | "ICMP Unreachable (Destination Host Unknown)", /* 7 */ | |
175 | "ICMP Unreachable (Source Host Isolated)", /* 8 */ | |
176 | "ICMP Unreachable (Communication with Network Prohibited)", /* 9 */ | |
177 | "ICMP Unreachable (Communication with Host Prohibited)", /* 10 */ | |
178 | "ICMP Unreachable (Network Unreachable For Type Of Service)", /* 11 */ | |
179 | "ICMP Unreachable (Host Unreachable For Type Of Service)", /* 12 */ | |
174 | 180 | "ICMP Unreachable (Communication Administratively Prohibited)", /* 13 */ |
175 | "ICMP Unreachable (Host Precedence Violation)", /* 14 */ | |
176 | "ICMP Unreachable (Precedence cutoff in effect)" /* 15 */ | |
181 | "ICMP Unreachable (Host Precedence Violation)", /* 14 */ | |
182 | "ICMP Unreachable (Precedence cutoff in effect)" /* 15 */ | |
177 | 183 | }; |
178 | 184 | |
179 | #define ICMP_UNREACH_MAXTYPE 15 | |
185 | #define ICMP_UNREACH_MAXTYPE 15 | |
180 | 186 | |
181 | 187 | /* entry used to keep track of each host we are pinging */ |
182 | 188 | |
183 | #define EV_TYPE_PING 1 | |
184 | #define EV_TYPE_TIMEOUT 2 | |
185 | ||
186 | typedef struct host_entry | |
187 | { | |
188 | /* Each host can have an event attached: either the next time that a ping needs | |
189 | #define EV_TYPE_PING 1 | |
190 | #define EV_TYPE_TIMEOUT 2 | |
191 | ||
192 | typedef struct host_entry { | |
193 | /* Each host can have an event attached: either the next time that a ping needs | |
189 | 194 | * to be sent, or the timeout, if the last ping was sent */ |
190 | struct host_entry *ev_prev; /* double linked list for the event-queue */ | |
191 | struct host_entry *ev_next; /* double linked list for the event-queue */ | |
192 | struct timeval ev_time; /* time, after which this event should happen */ | |
193 | int ev_type; /* event type */ | |
194 | ||
195 | int i; /* index into array */ | |
196 | char *name; /* name as given by user */ | |
197 | char *host; /* text description of host */ | |
198 | char *pad; /* pad to align print names */ | |
199 | struct sockaddr_storage saddr; /* internet address */ | |
200 | socklen_t saddr_len; | |
201 | int timeout; /* time to wait for response */ | |
202 | unsigned char running; /* unset when through sending */ | |
203 | unsigned char waiting; /* waiting for response */ | |
204 | struct timeval last_send_time; /* time of last packet sent */ | |
205 | int num_sent; /* number of ping packets sent */ | |
206 | int num_recv; /* number of pings received (duplicates ignored) */ | |
207 | int num_recv_total; /* number of pings received, including duplicates */ | |
208 | int max_reply; /* longest response time */ | |
209 | int min_reply; /* shortest response time */ | |
210 | int total_time; /* sum of response times */ | |
211 | /* _i -> splits (reset on every report interval) */ | |
212 | int num_sent_i; /* number of ping packets sent */ | |
213 | int num_recv_i; /* number of pings received */ | |
214 | int max_reply_i; /* longest response time */ | |
215 | int min_reply_i; /* shortest response time */ | |
216 | int total_time_i; /* sum of response times */ | |
217 | int discard_next_recv_i;/* don't count next received reply for split reporting */ | |
218 | int *resp_times; /* individual response times */ | |
219 | #if defined( DEBUG ) || defined( _DEBUG ) | |
220 | int *sent_times; /* per-sent-ping timestamp */ | |
195 | struct host_entry* ev_prev; /* double linked list for the event-queue */ | |
196 | struct host_entry* ev_next; /* double linked list for the event-queue */ | |
197 | struct timeval ev_time; /* time, after which this event should happen */ | |
198 | int ev_type; /* event type */ | |
199 | ||
200 | int i; /* index into array */ | |
201 | char* name; /* name as given by user */ | |
202 | char* host; /* text description of host */ | |
203 | char* pad; /* pad to align print names */ | |
204 | struct sockaddr_storage saddr; /* internet address */ | |
205 | socklen_t saddr_len; | |
206 | int timeout; /* time to wait for response */ | |
207 | unsigned char running; /* unset when through sending */ | |
208 | unsigned char waiting; /* waiting for response */ | |
209 | struct timeval last_send_time; /* time of last packet sent */ | |
210 | int num_sent; /* number of ping packets sent */ | |
211 | int num_recv; /* number of pings received (duplicates ignored) */ | |
212 | int num_recv_total; /* number of pings received, including duplicates */ | |
213 | int max_reply; /* longest response time */ | |
214 | int min_reply; /* shortest response time */ | |
215 | int total_time; /* sum of response times */ | |
216 | /* _i -> splits (reset on every report interval) */ | |
217 | int num_sent_i; /* number of ping packets sent */ | |
218 | int num_recv_i; /* number of pings received */ | |
219 | int max_reply_i; /* longest response time */ | |
220 | int min_reply_i; /* shortest response time */ | |
221 | int total_time_i; /* sum of response times */ | |
222 | int discard_next_recv_i; /* don't count next received reply for split reporting */ | |
223 | int* resp_times; /* individual response times */ | |
224 | #if defined(DEBUG) || defined(_DEBUG) | |
225 | int* sent_times; /* per-sent-ping timestamp */ | |
221 | 226 | #endif /* DEBUG || _DEBUG */ |
222 | 227 | } HOST_ENTRY; |
223 | 228 | |
224 | 229 | /*** globals ***/ |
225 | 230 | |
226 | HOST_ENTRY **table = NULL; /* array of pointers to items in the list */ | |
231 | HOST_ENTRY** table = NULL; /* array of pointers to items in the list */ | |
227 | 232 | |
228 | 233 | /* event queue (ev): This, together with the ev_next / ev_prev elements are used |
229 | 234 | * to track the next event happening for each host. This can be either a new ping |
230 | 235 | * that needs to be sent or a timeout */ |
231 | HOST_ENTRY *ev_first; | |
232 | HOST_ENTRY *ev_last; | |
233 | ||
234 | char *prog; | |
235 | int ident; /* our pid */ | |
236 | int socket4 = 0; | |
237 | #ifndef IPV6 | |
238 | int hints_ai_family = AF_INET; | |
239 | #else | |
240 | int socket6 = 0; | |
241 | int hints_ai_family = AF_UNSPEC; | |
242 | #endif | |
243 | ||
236 | HOST_ENTRY* ev_first; | |
237 | HOST_ENTRY* ev_last; | |
238 | ||
239 | char* prog; | |
240 | int ident; /* our pid */ | |
241 | int s; /* socket */ | |
244 | 242 | unsigned int debugging = 0; |
245 | 243 | |
246 | 244 | /* times get *100 because all times are calculated in 10 usec units, not ms */ |
254 | 252 | unsigned int trials; |
255 | 253 | unsigned int report_interval = 0; |
256 | 254 | unsigned int ttl = 0; |
257 | int src_addr_set = 0; | |
255 | int src_addr_present = 0; | |
256 | #ifndef IPV6 | |
258 | 257 | struct in_addr src_addr; |
259 | #ifdef IPV6 | |
260 | int src_addr6_set = 0; | |
261 | struct in6_addr src_addr6; | |
258 | #else | |
259 | struct in6_addr src_addr; | |
262 | 260 | #endif |
263 | 261 | |
264 | 262 | /* global stats */ |
267 | 265 | int total_replies = 0; |
268 | 266 | double sum_replies = 0; |
269 | 267 | int max_hostname_len = 0; |
270 | int num_jobs = 0; /* number of hosts still to do */ | |
271 | int num_hosts; /* total number of hosts */ | |
272 | int num_alive = 0, /* total number alive */ | |
273 | num_unreachable = 0, /* total number unreachable */ | |
274 | num_noaddress = 0; /* total number of addresses not found */ | |
275 | int num_timeout = 0, /* number of times select timed out */ | |
276 | num_pingsent = 0, /* total pings sent */ | |
277 | num_pingreceived = 0, /* total pings received */ | |
278 | num_othericmprcvd = 0; /* total non-echo-reply ICMP received */ | |
279 | ||
280 | struct timeval current_time; /* current time (pseudo) */ | |
268 | int num_jobs = 0; /* number of hosts still to do */ | |
269 | int num_hosts; /* total number of hosts */ | |
270 | int num_alive = 0, /* total number alive */ | |
271 | num_unreachable = 0, /* total number unreachable */ | |
272 | num_noaddress = 0; /* total number of addresses not found */ | |
273 | int num_timeout = 0, /* number of times select timed out */ | |
274 | num_pingsent = 0, /* total pings sent */ | |
275 | num_pingreceived = 0, /* total pings received */ | |
276 | num_othericmprcvd = 0; /* total non-echo-reply ICMP received */ | |
277 | ||
278 | struct timeval current_time; /* current time (pseudo) */ | |
281 | 279 | struct timeval start_time; |
282 | 280 | struct timeval end_time; |
283 | struct timeval last_send_time; /* time last ping was sent */ | |
284 | struct timeval next_report_time; /* time next -Q report is expected */ | |
281 | struct timeval last_send_time; /* time last ping was sent */ | |
282 | struct timeval next_report_time; /* time next -Q report is expected */ | |
285 | 283 | struct timezone tz; |
286 | 284 | |
287 | 285 | /* switches */ |
288 | int generate_flag = 0; /* flag for IP list generation */ | |
286 | int generate_flag = 0; /* flag for IP list generation */ | |
289 | 287 | int verbose_flag, quiet_flag, stats_flag, unreachable_flag, alive_flag; |
290 | 288 | int elapsed_flag, version_flag, count_flag, loop_flag, netdata_flag; |
291 | 289 | int per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag; |
293 | 291 | int outage_flag = 0; |
294 | 292 | int timestamp_flag = 0; |
295 | 293 | int random_data_flag = 0; |
296 | #if defined( DEBUG ) || defined( _DEBUG ) | |
294 | #if defined(DEBUG) || defined(_DEBUG) | |
297 | 295 | int randomly_lose_flag, sent_times_flag, trace_flag, print_per_system_flag; |
298 | 296 | int lose_factor; |
299 | 297 | #endif /* DEBUG || _DEBUG */ |
300 | 298 | |
301 | char *filename = NULL; /* file containing hosts to ping */ | |
299 | char* filename = NULL; /* file containing hosts to ping */ | |
302 | 300 | |
303 | 301 | /*** forward declarations ***/ |
304 | 302 | |
305 | void add_name( char *name ); | |
306 | void add_addr( char *name, char *host, struct sockaddr *ipaddr, socklen_t ipaddr_len); | |
307 | char *na_cat( char *name, struct in_addr ipaddr ); | |
308 | void crash_and_burn( char *message ); | |
309 | void errno_crash_and_burn( char *message ); | |
310 | char *get_host_by_address( struct in_addr in ); | |
311 | void remove_job( HOST_ENTRY *h ); | |
312 | int send_ping( HOST_ENTRY *h ); | |
313 | long timeval_diff( struct timeval *a, struct timeval *b ); | |
314 | void timeval_add(struct timeval *a, long t_10u); | |
315 | void usage( int ); | |
316 | int wait_for_reply( long ); | |
317 | void print_per_system_stats( void ); | |
318 | void print_per_system_splits( void ); | |
319 | void print_netdata( void ); | |
320 | void print_global_stats( void ); | |
303 | void add_name(char* name); | |
304 | void add_addr(char* name, char* host, struct sockaddr* ipaddr, socklen_t ipaddr_len); | |
305 | char* na_cat(char* name, struct in_addr ipaddr); | |
306 | void crash_and_burn(char* message); | |
307 | void errno_crash_and_burn(char* message); | |
308 | char* get_host_by_address(struct in_addr in); | |
309 | int recvfrom_wto(int s, char* buf, int len, struct sockaddr* saddr, socklen_t* saddr_len, long timo); | |
310 | void remove_job(HOST_ENTRY* h); | |
311 | int send_ping(int s, HOST_ENTRY* h); | |
312 | long timeval_diff(struct timeval* a, struct timeval* b); | |
313 | void timeval_add(struct timeval* a, long t_10u); | |
314 | void usage(int); | |
315 | int wait_for_reply(long); | |
316 | void print_per_system_stats(void); | |
317 | void print_per_system_splits(void); | |
318 | void print_netdata(void); | |
319 | void print_global_stats(void); | |
321 | 320 | void main_loop(); |
322 | 321 | void finish(); |
323 | char *sprint_tm( int t ); | |
324 | void ev_enqueue(HOST_ENTRY *h); | |
325 | HOST_ENTRY *ev_dequeue(); | |
326 | void ev_remove(HOST_ENTRY *h); | |
327 | void add_cidr(char *); | |
328 | void add_range(char *, char *); | |
329 | void print_warning(char *fmt, ...); | |
330 | int addr_cmp(struct sockaddr *a, struct sockaddr *b); | |
322 | int handle_random_icmp(FPING_ICMPHDR* p, struct sockaddr* addr, socklen_t addr_len); | |
323 | char* sprint_tm(int t); | |
324 | void ev_enqueue(HOST_ENTRY* h); | |
325 | HOST_ENTRY* ev_dequeue(); | |
326 | void ev_remove(HOST_ENTRY* h); | |
327 | void add_cidr(char*); | |
328 | void add_range(char*, char*); | |
329 | void print_warning(char* fmt, ...); | |
330 | int addr_cmp(struct sockaddr* a, struct sockaddr* b); | |
331 | 331 | |
332 | 332 | /*** function definitions ***/ |
333 | 333 | |
345 | 345 | |
346 | 346 | ************************************************************/ |
347 | 347 | |
348 | int main( int argc, char **argv ) | |
348 | int main(int argc, char** argv) | |
349 | 349 | { |
350 | 350 | int c, i, n; |
351 | char *buf; | |
351 | char* buf; | |
352 | 352 | uid_t uid; |
353 | 353 | int tos = 0; |
354 | HOST_ENTRY *cursor; | |
354 | HOST_ENTRY* cursor; | |
355 | 355 | |
356 | 356 | prog = argv[0]; |
357 | 357 | |
358 | socket4 = open_ping_socket_ipv4(ping_data_size); | |
359 | #ifdef IPV6 | |
360 | socket6 = open_ping_socket_ipv6(ping_data_size); | |
361 | #endif | |
362 | ||
363 | if((uid = getuid())) { | |
358 | s = open_ping_socket(ping_data_size); | |
359 | ||
360 | if ((uid = getuid())) { | |
364 | 361 | /* drop privileges */ |
365 | if(setuid( getuid() ) == -1) | |
362 | if (setuid(getuid()) == -1) | |
366 | 363 | perror("cannot setuid"); |
367 | 364 | } |
368 | 365 | |
373 | 370 | |
374 | 371 | /* get command line options */ |
375 | 372 | |
376 | while( ( c = getopt( argc, argv, "46ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:" ) ) != EOF ) | |
377 | { | |
378 | switch( c ) | |
373 | while ((c = getopt(argc, argv, "ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:")) != EOF) { | |
374 | switch (c) { | |
375 | case 'M': | |
376 | #ifdef IP_MTU_DISCOVER | |
379 | 377 | { |
380 | case '4': | |
381 | if(hints_ai_family != AF_UNSPEC) { | |
382 | fprintf(stderr, "%s: can't specify both -4 and -6\n", prog); | |
383 | exit(1); | |
384 | } | |
385 | hints_ai_family = AF_INET; | |
386 | break; | |
387 | case '6': | |
388 | #ifdef IPV6 | |
389 | if(hints_ai_family != AF_UNSPEC) { | |
390 | fprintf(stderr, "%s: can't specify both -4 and -6\n", prog); | |
391 | exit(1); | |
392 | } | |
393 | hints_ai_family = AF_INET6; | |
378 | int val = IP_PMTUDISC_DO; | |
379 | #ifndef IPV6 | |
380 | if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val))) { | |
394 | 381 | #else |
395 | fprintf(stderr, "%s: IPv6 not supported by this binary\n", prog); | |
382 | if (setsockopt(s, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val))) { | |
383 | #endif | |
384 | perror("setsockopt IP_MTU_DISCOVER"); | |
385 | } | |
386 | } | |
387 | #else | |
388 | fprintf(stderr, "-M option not supported on this platform\n"); | |
396 | 389 | exit(1); |
397 | 390 | #endif |
398 | break; | |
399 | case 'M': | |
400 | #ifdef IP_MTU_DISCOVER | |
401 | if(socket4) { | |
402 | int val = IP_PMTUDISC_DO; | |
403 | if (setsockopt(socket4, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val))) { | |
404 | perror("setsockopt IP_MTU_DISCOVER"); | |
405 | } | |
406 | } | |
407 | #ifdef IPV6 | |
408 | if(socket6) { | |
409 | int val = IPV6_PMTUDISC_DO; | |
410 | if (setsockopt(socket6, IPPROTO_IPV6, IPV6_MTU_DISCOVER, &val, sizeof(val))) { | |
411 | perror("setsockopt IPV6_MTU_DISCOVER"); | |
412 | } | |
413 | } | |
414 | #endif | |
415 | #else | |
416 | fprintf(stderr, "%s, -M option not supported on this platform\n", prog); | |
417 | exit(1); | |
418 | #endif | |
419 | break; | |
391 | break; | |
420 | 392 | |
421 | 393 | case 't': |
422 | if( !( timeout = ( unsigned int )atoi( optarg ) * 100 ) ) | |
394 | if (!(timeout = (unsigned int)atoi(optarg) * 100)) | |
423 | 395 | usage(1); |
424 | 396 | |
425 | 397 | break; |
426 | 398 | |
427 | 399 | case 'r': |
428 | if (!sscanf(optarg,"%u",&retry)) | |
400 | if (!sscanf(optarg, "%u", &retry)) | |
429 | 401 | usage(1); |
430 | 402 | break; |
431 | 403 | |
432 | 404 | case 'i': |
433 | if (!sscanf(optarg,"%u",&interval)) | |
405 | if (!sscanf(optarg, "%u", &interval)) | |
434 | 406 | usage(1); |
435 | 407 | interval *= 100; |
436 | 408 | break; |
437 | 409 | |
438 | 410 | case 'p': |
439 | if( !( perhost_interval = ( unsigned int )atoi( optarg ) * 100 ) ) | |
411 | if (!(perhost_interval = (unsigned int)atoi(optarg) * 100)) | |
440 | 412 | usage(1); |
441 | 413 | |
442 | 414 | break; |
443 | 415 | |
444 | 416 | case 'c': |
445 | if( !( count = ( unsigned int )atoi( optarg ) ) ) | |
417 | if (!(count = (unsigned int)atoi(optarg))) | |
446 | 418 | usage(1); |
447 | 419 | |
448 | 420 | count_flag = 1; |
449 | 421 | break; |
450 | 422 | |
451 | 423 | case 'C': |
452 | if( !( count = ( unsigned int )atoi( optarg ) ) ) | |
424 | if (!(count = (unsigned int)atoi(optarg))) | |
453 | 425 | usage(1); |
454 | 426 | |
455 | 427 | count_flag = 1; |
457 | 429 | break; |
458 | 430 | |
459 | 431 | case 'b': |
460 | if (!sscanf(optarg,"%u",&ping_data_size)) | |
432 | if (!sscanf(optarg, "%u", &ping_data_size)) | |
461 | 433 | usage(1); |
462 | 434 | |
463 | 435 | break; |
474 | 446 | case 'Q': |
475 | 447 | verbose_flag = 0; |
476 | 448 | quiet_flag = 1; |
477 | if( !( report_interval = ( unsigned int )atoi( optarg ) * 100000 ) ) | |
449 | if (!(report_interval = (unsigned int)atoi(optarg) * 100000)) | |
478 | 450 | usage(1); |
479 | 451 | |
480 | 452 | break; |
501 | 473 | break; |
502 | 474 | |
503 | 475 | case 'B': |
504 | if( !( backoff = atof( optarg ) ) ) | |
476 | if (!(backoff = atof(optarg))) | |
505 | 477 | usage(1); |
506 | 478 | |
507 | 479 | break; |
532 | 504 | break; |
533 | 505 | |
534 | 506 | case 'H': |
535 | if( !( ttl = ( u_int )atoi( optarg ) )) | |
507 | if (!(ttl = (u_int)atoi(optarg))) | |
536 | 508 | usage(1); |
537 | 509 | break; |
538 | 510 | |
539 | #if defined( DEBUG ) || defined( _DEBUG ) | |
511 | #if defined(DEBUG) || defined(_DEBUG) | |
540 | 512 | case 'z': |
541 | if( ! ( debugging = ( unsigned int )atoi( optarg ) ) ) | |
513 | if (!(debugging = (unsigned int)atoi(optarg))) | |
542 | 514 | usage(1); |
543 | 515 | |
544 | 516 | break; |
545 | 517 | #endif /* DEBUG || _DEBUG */ |
546 | 518 | |
547 | 519 | case 'v': |
548 | printf( "%s: Version %s\n", argv[0], VERSION); | |
549 | printf( "%s: comments to %s\n", argv[0], EMAIL ); | |
550 | exit( 0 ); | |
520 | printf("%s: Version %s\n", argv[0], VERSION); | |
521 | printf("%s: comments to %s\n", argv[0], EMAIL); | |
522 | exit(0); | |
551 | 523 | |
552 | 524 | case 'f': |
553 | 525 | filename = optarg; |
560 | 532 | break; |
561 | 533 | |
562 | 534 | case 'S': |
563 | if(inet_pton(AF_INET, optarg, &src_addr)) | |
564 | { | |
565 | src_addr_set = 1; | |
566 | break; | |
567 | } | |
568 | #ifdef IPV6 | |
569 | if(inet_pton(AF_INET6, optarg, &src_addr6)) | |
570 | { | |
571 | src_addr6_set = 1; | |
572 | break; | |
573 | } | |
535 | #ifndef IPV6 | |
536 | if (!inet_pton(AF_INET, optarg, &src_addr)) | |
537 | #else | |
538 | if (!inet_pton(AF_INET6, optarg, &src_addr)) | |
574 | 539 | #endif |
575 | usage(1); | |
540 | usage(1); | |
541 | src_addr_present = 1; | |
576 | 542 | break; |
577 | 543 | |
578 | 544 | case 'I': |
579 | 545 | #ifdef SO_BINDTODEVICE |
580 | if(socket4) { | |
581 | if (setsockopt(socket4, SOL_SOCKET, SO_BINDTODEVICE, optarg, strlen(optarg))) { | |
582 | perror("binding to specific interface (SO_BINTODEVICE)"); | |
583 | } | |
584 | } | |
585 | #ifdef IPV6 | |
586 | if(socket6) { | |
587 | if (setsockopt(socket6, SOL_SOCKET, SO_BINDTODEVICE, optarg, strlen(optarg))) { | |
588 | perror("binding to specific interface (SO_BINTODEVICE), IPV6"); | |
589 | } | |
590 | } | |
591 | #endif | |
546 | if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, optarg, strlen(optarg))) { | |
547 | perror("binding to specific interface (SO_BINTODEVICE)"); | |
548 | } | |
592 | 549 | #else |
593 | printf( "%s: cant bind to a particular net interface since SO_BINDTODEVICE is not supported on your os.\n", argv[0] ); | |
594 | exit(3);; | |
550 | printf("%s: cant bind to a particular net interface since SO_BINDTODEVICE is not supported on your os.\n", argv[0]); | |
551 | exit(3); | |
552 | ; | |
595 | 553 | #endif |
596 | 554 | break; |
597 | 555 | |
600 | 558 | break; |
601 | 559 | |
602 | 560 | case 'O': |
603 | if (sscanf(optarg,"%i",&tos)){ | |
604 | if(socket4) { | |
605 | if ( setsockopt(socket4, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) { | |
606 | perror("setting type of service octet IP_TOS"); | |
607 | } | |
561 | if (sscanf(optarg, "%i", &tos)) { | |
562 | #ifndef IPV6 | |
563 | if (setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) { | |
564 | #else | |
565 | if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos))) { | |
566 | #endif | |
567 | perror("setting type of service octet IP_TOS"); | |
608 | 568 | } |
609 | #ifdef IPV6 | |
610 | if(socket6) { | |
611 | if ( setsockopt(socket6, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos))) { | |
612 | perror("setting type of service octet IPV6_TCLASS"); | |
613 | } | |
614 | } | |
615 | #endif | |
616 | } | |
617 | else { | |
569 | } else { | |
618 | 570 | usage(1); |
619 | 571 | } |
620 | 572 | break; |
627 | 579 | fprintf(stderr, "see 'fping -h' for usage information\n"); |
628 | 580 | exit(1); |
629 | 581 | break; |
630 | ||
631 | }/* SWITCH */ | |
632 | }/* WHILE */ | |
633 | ||
634 | /* if we are called 'fping6', assume '-6' */ | |
635 | if(strstr(argv[0], "fping6")) { | |
636 | hints_ai_family = AF_INET6; | |
582 | } | |
637 | 583 | } |
638 | 584 | |
639 | 585 | /* validate various option settings */ |
640 | 586 | |
641 | 587 | if (ttl > 255) { |
642 | fprintf(stderr, "%s: ttl %u out of range\n", prog, ttl); | |
588 | fprintf(stderr, "ttl %u out of range\n", ttl); | |
643 | 589 | exit(1); |
644 | 590 | } |
645 | 591 | |
646 | if( unreachable_flag && alive_flag ) | |
647 | { | |
648 | fprintf( stderr, "%s: specify only one of a, u\n", prog); | |
592 | if (unreachable_flag && alive_flag) { | |
593 | fprintf(stderr, "%s: specify only one of a, u\n", argv[0]); | |
649 | 594 | exit(1); |
650 | 595 | |
651 | }/* IF */ | |
652 | ||
653 | if( count_flag && loop_flag ) | |
654 | { | |
655 | fprintf( stderr, "%s: specify only one of c, l\n", prog); | |
596 | } | |
597 | ||
598 | if (count_flag && loop_flag) { | |
599 | fprintf(stderr, "%s: specify only one of c, l\n", argv[0]); | |
656 | 600 | exit(1); |
657 | ||
658 | }/* IF */ | |
659 | ||
660 | if( ( interval < MIN_INTERVAL * 100 || | |
661 | perhost_interval < MIN_PERHOST_INTERVAL * 100 ) | |
662 | && getuid() ) | |
663 | { | |
664 | fprintf( stderr, "%s: these options are too risky for mere mortals.\n", prog ); | |
665 | fprintf( stderr, "%s: You need -i >= %u and -p >= %u\n", | |
666 | prog, MIN_INTERVAL, MIN_PERHOST_INTERVAL ); | |
601 | } | |
602 | ||
603 | if ((interval < MIN_INTERVAL * 100 || perhost_interval < MIN_PERHOST_INTERVAL * 100) | |
604 | && getuid()) { | |
605 | fprintf(stderr, "%s: these options are too risky for mere mortals.\n", prog); | |
606 | fprintf(stderr, "%s: You need -i >= %u and -p >= %u\n", | |
607 | prog, MIN_INTERVAL, MIN_PERHOST_INTERVAL); | |
667 | 608 | exit(1); |
668 | }/* IF */ | |
669 | ||
670 | if( ping_data_size > MAX_PING_DATA ) | |
671 | { | |
672 | fprintf( stderr, "%s: data size %u not valid, must be lower than %u\n", | |
673 | prog, ping_data_size, (unsigned int) MAX_PING_DATA ); | |
609 | } | |
610 | ||
611 | if (ping_data_size > MAX_PING_DATA) { | |
612 | fprintf(stderr, "%s: data size %u not valid, must be lower than %u\n", | |
613 | prog, ping_data_size, (unsigned int)MAX_PING_DATA); | |
674 | 614 | exit(1); |
675 | ||
676 | }/* IF */ | |
677 | ||
678 | if( ( backoff > MAX_BACKOFF_FACTOR ) || ( backoff < MIN_BACKOFF_FACTOR ) ) | |
679 | { | |
680 | fprintf( stderr, "%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n", | |
681 | prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR ); | |
615 | } | |
616 | ||
617 | if ((backoff > MAX_BACKOFF_FACTOR) || (backoff < MIN_BACKOFF_FACTOR)) { | |
618 | fprintf(stderr, "%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n", | |
619 | prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR); | |
682 | 620 | exit(1); |
683 | ||
684 | }/* IF */ | |
685 | ||
686 | if( alive_flag || unreachable_flag ) | |
621 | } | |
622 | ||
623 | if (alive_flag || unreachable_flag) | |
687 | 624 | verbose_flag = 0; |
688 | 625 | |
689 | if( count_flag ) | |
690 | { | |
691 | if( verbose_flag ) | |
626 | if (count_flag) { | |
627 | if (verbose_flag) | |
692 | 628 | per_recv_flag = 1; |
693 | 629 | |
694 | 630 | alive_flag = unreachable_flag = verbose_flag = 0; |
695 | ||
696 | }/* IF */ | |
697 | ||
698 | if( loop_flag ) | |
699 | { | |
700 | if( !report_interval ) | |
631 | } | |
632 | ||
633 | if (loop_flag) { | |
634 | if (!report_interval) | |
701 | 635 | per_recv_flag = 1; |
702 | 636 | |
703 | 637 | alive_flag = unreachable_flag = verbose_flag = 0; |
704 | ||
705 | }/* IF */ | |
706 | ||
707 | ||
708 | trials = ( count > retry + 1 ) ? count : retry + 1; | |
709 | ||
710 | #if defined( DEBUG ) || defined( _DEBUG ) | |
711 | if( debugging & DBG_TRACE ) | |
638 | } | |
639 | ||
640 | trials = (count > retry + 1) ? count : retry + 1; | |
641 | ||
642 | #if defined(DEBUG) || defined(_DEBUG) | |
643 | if (debugging & DBG_TRACE) | |
712 | 644 | trace_flag = 1; |
713 | 645 | |
714 | if( ( debugging & DBG_SENT_TIMES ) && !loop_flag ) | |
646 | if ((debugging & DBG_SENT_TIMES) && !loop_flag) | |
715 | 647 | sent_times_flag = 1; |
716 | 648 | |
717 | if( debugging & DBG_RANDOM_LOSE_FEW ) | |
718 | { | |
649 | if (debugging & DBG_RANDOM_LOSE_FEW) { | |
719 | 650 | randomly_lose_flag = 1; |
720 | lose_factor = 1; /* ie, 1/4 */ | |
721 | ||
722 | }/* IF */ | |
723 | ||
724 | if( debugging & DBG_RANDOM_LOSE_MANY ) | |
725 | { | |
651 | lose_factor = 1; /* ie, 1/4 */ | |
652 | } | |
653 | ||
654 | if (debugging & DBG_RANDOM_LOSE_MANY) { | |
726 | 655 | randomly_lose_flag = 1; |
727 | lose_factor = 5; /* ie, 3/4 */ | |
728 | ||
729 | }/* IF */ | |
730 | ||
731 | if( debugging & DBG_PRINT_PER_SYSTEM ) | |
656 | lose_factor = 5; /* ie, 3/4 */ | |
657 | } | |
658 | ||
659 | if (debugging & DBG_PRINT_PER_SYSTEM) | |
732 | 660 | print_per_system_flag = 1; |
733 | 661 | |
734 | if( ( debugging & DBG_REPORT_ALL_RTTS ) && !loop_flag ) | |
662 | if ((debugging & DBG_REPORT_ALL_RTTS) && !loop_flag) | |
735 | 663 | report_all_rtts_flag = 1; |
736 | 664 | |
737 | if( trace_flag ) | |
738 | { | |
739 | fprintf( stderr, "%s:\n count: %u, retry: %u, interval: %u\n", | |
740 | prog, count, retry, interval / 10 ); | |
741 | fprintf( stderr, " perhost_interval: %u, timeout: %u\n", | |
742 | perhost_interval / 10, timeout / 10 ); | |
743 | fprintf( stderr, " ping_data_size = %u, trials = %u\n", | |
744 | ping_data_size, trials ); | |
745 | ||
746 | if( verbose_flag ) fprintf( stderr, " verbose_flag set\n" ); | |
747 | if( multif_flag ) fprintf( stderr, " multif_flag set\n" ); | |
748 | if( name_flag ) fprintf( stderr, " name_flag set\n" ); | |
749 | if( addr_flag ) fprintf( stderr, " addr_flag set\n" ); | |
750 | if( stats_flag ) fprintf( stderr, " stats_flag set\n" ); | |
751 | if( unreachable_flag ) fprintf( stderr, " unreachable_flag set\n" ); | |
752 | if( alive_flag ) fprintf( stderr, " alive_flag set\n" ); | |
753 | if( elapsed_flag ) fprintf( stderr, " elapsed_flag set\n" ); | |
754 | if( version_flag ) fprintf( stderr, " version_flag set\n" ); | |
755 | if( count_flag ) fprintf( stderr, " count_flag set\n" ); | |
756 | if( loop_flag ) fprintf( stderr, " loop_flag set\n" ); | |
757 | if( backoff_flag ) fprintf( stderr, " backoff_flag set\n" ); | |
758 | if( per_recv_flag ) fprintf( stderr, " per_recv_flag set\n" ); | |
759 | if( report_all_rtts_flag ) fprintf( stderr, " report_all_rtts_flag set\n" ); | |
760 | if( randomly_lose_flag ) fprintf( stderr, " randomly_lose_flag set\n" ); | |
761 | if( sent_times_flag ) fprintf( stderr, " sent_times_flag set\n" ); | |
762 | if( print_per_system_flag ) fprintf( stderr, " print_per_system_flag set\n" ); | |
763 | if( outage_flag ) fprintf( stderr, " outage_flag set\n" ); | |
764 | if( netdata_flag ) fprintf( stderr, " netdata_flag set\n" ); | |
765 | ||
766 | }/* IF */ | |
665 | if (trace_flag) { | |
666 | fprintf(stderr, "%s:\n count: %u, retry: %u, interval: %u\n", | |
667 | prog, count, retry, interval / 10); | |
668 | fprintf(stderr, " perhost_interval: %u, timeout: %u\n", | |
669 | perhost_interval / 10, timeout / 10); | |
670 | fprintf(stderr, " ping_data_size = %u, trials = %u\n", | |
671 | ping_data_size, trials); | |
672 | ||
673 | if (verbose_flag) | |
674 | fprintf(stderr, " verbose_flag set\n"); | |
675 | if (multif_flag) | |
676 | fprintf(stderr, " multif_flag set\n"); | |
677 | if (name_flag) | |
678 | fprintf(stderr, " name_flag set\n"); | |
679 | if (addr_flag) | |
680 | fprintf(stderr, " addr_flag set\n"); | |
681 | if (stats_flag) | |
682 | fprintf(stderr, " stats_flag set\n"); | |
683 | if (unreachable_flag) | |
684 | fprintf(stderr, " unreachable_flag set\n"); | |
685 | if (alive_flag) | |
686 | fprintf(stderr, " alive_flag set\n"); | |
687 | if (elapsed_flag) | |
688 | fprintf(stderr, " elapsed_flag set\n"); | |
689 | if (version_flag) | |
690 | fprintf(stderr, " version_flag set\n"); | |
691 | if (count_flag) | |
692 | fprintf(stderr, " count_flag set\n"); | |
693 | if (loop_flag) | |
694 | fprintf(stderr, " loop_flag set\n"); | |
695 | if (backoff_flag) | |
696 | fprintf(stderr, " backoff_flag set\n"); | |
697 | if (per_recv_flag) | |
698 | fprintf(stderr, " per_recv_flag set\n"); | |
699 | if (report_all_rtts_flag) | |
700 | fprintf(stderr, " report_all_rtts_flag set\n"); | |
701 | if (randomly_lose_flag) | |
702 | fprintf(stderr, " randomly_lose_flag set\n"); | |
703 | if (sent_times_flag) | |
704 | fprintf(stderr, " sent_times_flag set\n"); | |
705 | if (print_per_system_flag) | |
706 | fprintf(stderr, " print_per_system_flag set\n"); | |
707 | if (outage_flag) | |
708 | fprintf(stderr, " outage_flag set\n"); | |
709 | if (netdata_flag) | |
710 | fprintf(stderr, " netdata_flag set\n"); | |
711 | } | |
767 | 712 | #endif /* DEBUG || _DEBUG */ |
768 | 713 | |
769 | 714 | /* set the TTL, if the -H option was set (otherwise ttl will be = 0) */ |
770 | if(ttl > 0) { | |
771 | if(socket4) { | |
772 | if (setsockopt(socket4, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl))) { | |
773 | perror("setting time to live"); | |
774 | } | |
775 | } | |
776 | #ifdef IPV6 | |
777 | if(socket6) { | |
778 | if (setsockopt(socket6, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) { | |
779 | perror("setting time to live"); | |
780 | } | |
781 | } | |
715 | if (ttl > 0) { | |
716 | #ifndef IPV6 | |
717 | if (setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl))) { | |
718 | #else | |
719 | if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) { | |
782 | 720 | #endif |
721 | perror("setting time to live"); | |
722 | } | |
783 | 723 | } |
784 | 724 | |
785 | 725 | #if HAVE_SO_TIMESTAMP |
786 | 726 | { |
787 | 727 | int opt = 1; |
788 | if(socket4) { | |
789 | if (setsockopt(socket4, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) { | |
790 | perror("setting SO_TIMESTAMP option"); | |
791 | } | |
792 | } | |
793 | #ifdef IPV6 | |
794 | if(socket6) { | |
795 | if (setsockopt(socket6, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) { | |
796 | perror("setting SO_TIMESTAMP option (IPv6)"); | |
797 | } | |
798 | } | |
799 | #endif | |
728 | if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))) { | |
729 | perror("setting SO_TIMESTAMP option"); | |
730 | } | |
800 | 731 | } |
801 | 732 | #endif |
802 | 733 | |
811 | 742 | /* file and generate are mutually exclusive */ |
812 | 743 | /* file and command line are mutually exclusive */ |
813 | 744 | /* generate requires command line parameters beyond the switches */ |
814 | if( ( *argv && filename ) || ( filename && generate_flag ) || ( generate_flag && !*argv ) ) | |
745 | if ((*argv && filename) || (filename && generate_flag) || (generate_flag && !*argv)) | |
815 | 746 | usage(1); |
816 | 747 | |
817 | 748 | /* if no conditions are specified, then assume input from stdin */ |
818 | if( !*argv && !filename && !generate_flag ) | |
749 | if (!*argv && !filename && !generate_flag) | |
819 | 750 | filename = "-"; |
820 | 751 | |
821 | if( *argv && !generate_flag ) | |
822 | { | |
823 | while( *argv ) | |
824 | { | |
825 | add_name( *argv ); | |
752 | if (*argv && !generate_flag) { | |
753 | while (*argv) { | |
754 | add_name(*argv); | |
826 | 755 | ++argv; |
827 | 756 | |
828 | }/* WHILE */ | |
829 | }/* IF */ | |
830 | else if( filename ) | |
831 | { | |
832 | FILE *ping_file; | |
757 | } | |
758 | } | |
759 | else if (filename) { | |
760 | FILE* ping_file; | |
833 | 761 | char line[132]; |
834 | 762 | char host[132]; |
835 | 763 | |
836 | if( strcmp( filename, "-" ) == 0 ) | |
837 | ping_file = fdopen( 0, "r" ); | |
764 | if (strcmp(filename, "-") == 0) | |
765 | ping_file = fdopen(0, "r"); | |
838 | 766 | else |
839 | ping_file = fopen( filename, "r" ); | |
840 | ||
841 | if( !ping_file ) | |
842 | errno_crash_and_burn( "fopen" ); | |
843 | ||
844 | ||
845 | while( fgets( line, sizeof(line), ping_file ) ) | |
846 | { | |
847 | if( sscanf( line, "%s", host ) != 1 ) | |
767 | ping_file = fopen(filename, "r"); | |
768 | ||
769 | if (!ping_file) | |
770 | errno_crash_and_burn("fopen"); | |
771 | ||
772 | while (fgets(line, sizeof(line), ping_file)) { | |
773 | if (sscanf(line, "%s", host) != 1) | |
848 | 774 | continue; |
849 | 775 | |
850 | if( ( !*host ) || ( host[0] == '#' ) ) /* magic to avoid comments */ | |
776 | if ((!*host) || (host[0] == '#')) /* magic to avoid comments */ | |
851 | 777 | continue; |
852 | 778 | |
853 | 779 | add_name(host); |
854 | }/* WHILE */ | |
855 | ||
856 | fclose( ping_file ); | |
857 | } | |
858 | else if( *argv && generate_flag ) { | |
859 | if(argc == 1) { | |
780 | } | |
781 | ||
782 | fclose(ping_file); | |
783 | } else if (*argv && generate_flag) { | |
784 | if (argc == 1) { | |
860 | 785 | /* one target: we expect a cidr range (n.n.n.n/m) */ |
861 | 786 | add_cidr(argv[0]); |
862 | } | |
863 | else if(argc == 2) { | |
787 | } else if (argc == 2) { | |
864 | 788 | add_range(argv[0], argv[1]); |
865 | } | |
866 | else { | |
789 | } else { | |
867 | 790 | usage(1); |
868 | 791 | } |
869 | } | |
870 | else { | |
792 | } else { | |
871 | 793 | usage(1); |
872 | 794 | } |
873 | 795 | |
874 | if(!num_hosts) { | |
796 | if (!num_hosts) { | |
875 | 797 | exit(num_noaddress ? 2 : 1); |
876 | 798 | } |
877 | 799 | |
878 | #ifndef IPV6 | |
879 | if(src_addr_set) { | |
880 | socket_set_src_addr_ipv4(socket4, &src_addr); | |
881 | } | |
882 | #else | |
883 | if(src_addr6_set) { | |
884 | socket_set_src_addr_ipv6(socket6, &src_addr6); | |
885 | } | |
886 | #endif | |
800 | if (src_addr_present) { | |
801 | socket_set_src_addr(s, src_addr); | |
802 | } | |
887 | 803 | |
888 | 804 | /* allocate array to hold outstanding ping requests */ |
889 | 805 | |
890 | table = ( HOST_ENTRY** )malloc( sizeof( HOST_ENTRY* ) * num_hosts ); | |
891 | if( !table ) | |
892 | crash_and_burn( "Can't malloc array of hosts" ); | |
806 | table = (HOST_ENTRY**)malloc(sizeof(HOST_ENTRY*) * num_hosts); | |
807 | if (!table) | |
808 | crash_and_burn("Can't malloc array of hosts"); | |
893 | 809 | |
894 | 810 | cursor = ev_first; |
895 | 811 | |
896 | for( num_jobs = 0; num_jobs < num_hosts; num_jobs++ ) | |
897 | { | |
812 | for (num_jobs = 0; num_jobs < num_hosts; num_jobs++) { | |
898 | 813 | table[num_jobs] = cursor; |
899 | 814 | cursor->i = num_jobs; |
900 | 815 | |
901 | 816 | /* as long as we're here, put this in so names print out nicely */ |
902 | if( count_flag || loop_flag ) | |
903 | { | |
904 | n = max_hostname_len - strlen( cursor->host ); | |
905 | buf = ( char* ) malloc( n + 1 ); | |
906 | if( !buf ) | |
907 | crash_and_burn( "can't malloc host pad" ); | |
908 | ||
909 | for ( i = 0; i < n; i++ ) | |
817 | if (count_flag || loop_flag) { | |
818 | n = max_hostname_len - strlen(cursor->host); | |
819 | buf = (char*)malloc(n + 1); | |
820 | if (!buf) | |
821 | crash_and_burn("can't malloc host pad"); | |
822 | ||
823 | for (i = 0; i < n; i++) | |
910 | 824 | buf[i] = ' '; |
911 | 825 | |
912 | 826 | buf[n] = '\0'; |
913 | 827 | cursor->pad = buf; |
914 | 828 | |
915 | }/* IF */ | |
916 | ||
917 | cursor=cursor->ev_next; | |
918 | ||
919 | }/* FOR */ | |
920 | ||
921 | init_ping_buffer_ipv4(ping_data_size); | |
922 | #ifdef IPV6 | |
923 | init_ping_buffer_ipv6(ping_data_size); | |
924 | #endif | |
925 | ||
926 | signal( SIGINT, finish ); | |
927 | ||
928 | gettimeofday( &start_time, &tz ); | |
829 | } | |
830 | ||
831 | cursor = cursor->ev_next; | |
832 | } | |
833 | ||
834 | init_ping_buffer(ping_data_size); | |
835 | ||
836 | signal(SIGINT, finish); | |
837 | ||
838 | gettimeofday(&start_time, &tz); | |
929 | 839 | current_time = start_time; |
930 | 840 | |
931 | if( report_interval ) { | |
841 | if (report_interval) { | |
932 | 842 | next_report_time = start_time; |
933 | 843 | timeval_add(&next_report_time, report_interval); |
934 | 844 | } |
935 | 845 | |
936 | 846 | last_send_time.tv_sec = current_time.tv_sec - 10000; |
937 | 847 | |
938 | #if defined( DEBUG ) || defined( _DEBUG ) | |
939 | if( randomly_lose_flag ) | |
940 | srandom( start_time.tv_usec ); | |
848 | #if defined(DEBUG) || defined(_DEBUG) | |
849 | if (randomly_lose_flag) | |
850 | srandom(start_time.tv_usec); | |
941 | 851 | #endif /* DEBUG || _DEBUG */ |
942 | 852 | |
943 | 853 | seqmap_init(); |
948 | 858 | finish(); |
949 | 859 | |
950 | 860 | return 0; |
951 | } /* main() */ | |
952 | ||
953 | void add_cidr(char *addr) | |
954 | { | |
955 | char *addr_end; | |
956 | char *mask_str; | |
861 | } | |
862 | ||
863 | void add_cidr(char* addr) | |
864 | { | |
865 | char* addr_end; | |
866 | char* mask_str; | |
957 | 867 | unsigned long mask; |
958 | 868 | unsigned long bitmask; |
959 | 869 | int ret; |
960 | 870 | struct addrinfo addr_hints; |
961 | struct addrinfo *addr_res; | |
871 | struct addrinfo* addr_res; | |
962 | 872 | unsigned long net_addr; |
963 | 873 | unsigned long net_last; |
964 | 874 | |
965 | 875 | /* Split address from mask */ |
966 | 876 | addr_end = strchr(addr, '/'); |
967 | if(addr_end == NULL) { | |
877 | if (addr_end == NULL) { | |
968 | 878 | usage(1); |
969 | 879 | } |
970 | 880 | *addr_end = '\0'; |
976 | 886 | addr_hints.ai_family = AF_UNSPEC; |
977 | 887 | addr_hints.ai_flags = AI_NUMERICHOST; |
978 | 888 | ret = getaddrinfo(addr, NULL, &addr_hints, &addr_res); |
979 | if(ret) { | |
980 | fprintf(stderr, "%s, can't parse address %s: %s\n", prog, addr, gai_strerror(ret)); | |
889 | if (ret) { | |
890 | fprintf(stderr, "Error: can't parse address %s: %s\n", addr, gai_strerror(ret)); | |
981 | 891 | exit(1); |
982 | 892 | } |
983 | if(addr_res->ai_family != AF_INET) { | |
984 | fprintf(stderr, "%s: -g works only with IPv4 addresses\n", prog); | |
893 | if (addr_res->ai_family != AF_INET) { | |
894 | fprintf(stderr, "Error: -g works only with IPv4 addresses\n"); | |
985 | 895 | exit(1); |
986 | 896 | } |
987 | net_addr = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr); | |
897 | net_addr = ntohl(((struct sockaddr_in*)addr_res->ai_addr)->sin_addr.s_addr); | |
988 | 898 | |
989 | 899 | /* check mask */ |
990 | if(mask < 1 || mask > 32) { | |
991 | fprintf(stderr, "%s: netmask must be between 1 and 32 (is: %s)\n", prog, mask_str); | |
900 | if (mask < 1 || mask > 32) { | |
901 | fprintf(stderr, "Error: netmask must be between 1 and 32 (is: %s)\n", mask_str); | |
992 | 902 | exit(1); |
993 | 903 | } |
994 | 904 | |
995 | 905 | /* convert mask integer from 1 to 32 to a bitmask */ |
996 | bitmask = ((unsigned long) 0xFFFFFFFF) << (32-mask); | |
906 | bitmask = ((unsigned long)0xFFFFFFFF) << (32 - mask); | |
997 | 907 | |
998 | 908 | /* calculate network range */ |
999 | 909 | net_addr &= bitmask; |
1000 | net_last = net_addr + ((unsigned long) 0x1 << (32-mask)) - 1; | |
910 | net_last = net_addr + ((unsigned long)0x1 << (32 - mask)) - 1; | |
1001 | 911 | |
1002 | 912 | /* exclude network and broadcast address for regular prefixes */ |
1003 | 913 | if (mask < 31) { |
1006 | 916 | } |
1007 | 917 | |
1008 | 918 | /* add all hosts in that network (net_addr and net_last inclusive) */ |
1009 | for(; net_addr <= net_last; net_addr++) { | |
919 | for (; net_addr <= net_last; net_addr++) { | |
1010 | 920 | struct in_addr in_addr_tmp; |
1011 | 921 | char buffer[20]; |
1012 | 922 | in_addr_tmp.s_addr = htonl(net_addr); |
1014 | 924 | add_name(buffer); |
1015 | 925 | } |
1016 | 926 | |
1017 | ||
1018 | 927 | freeaddrinfo(addr_res); |
1019 | 928 | } |
1020 | 929 | |
1021 | void add_range(char *start, char *end) | |
930 | void add_range(char* start, char* end) | |
1022 | 931 | { |
1023 | 932 | struct addrinfo addr_hints; |
1024 | struct addrinfo *addr_res; | |
933 | struct addrinfo* addr_res; | |
1025 | 934 | unsigned long start_long; |
1026 | 935 | unsigned long end_long; |
1027 | 936 | int ret; |
1031 | 940 | addr_hints.ai_family = AF_UNSPEC; |
1032 | 941 | addr_hints.ai_flags = AI_NUMERICHOST; |
1033 | 942 | ret = getaddrinfo(start, NULL, &addr_hints, &addr_res); |
1034 | if(ret) { | |
1035 | fprintf(stderr, "%s: can't parse address %s: %s\n", prog, start, gai_strerror(ret)); | |
943 | if (ret) { | |
944 | fprintf(stderr, "Error: can't parse address %s: %s\n", start, gai_strerror(ret)); | |
1036 | 945 | exit(1); |
1037 | 946 | } |
1038 | if(addr_res->ai_family != AF_INET) { | |
947 | if (addr_res->ai_family != AF_INET) { | |
1039 | 948 | freeaddrinfo(addr_res); |
1040 | fprintf(stderr, "%s: -g works only with IPv4 addresses\n", prog); | |
949 | fprintf(stderr, "Error: -g works only with IPv4 addresses\n"); | |
1041 | 950 | exit(1); |
1042 | 951 | } |
1043 | start_long = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr); | |
952 | start_long = ntohl(((struct sockaddr_in*)addr_res->ai_addr)->sin_addr.s_addr); | |
1044 | 953 | |
1045 | 954 | /* parse end address (IPv4 only) */ |
1046 | 955 | memset(&addr_hints, 0, sizeof(struct addrinfo)); |
1047 | 956 | addr_hints.ai_family = AF_UNSPEC; |
1048 | 957 | addr_hints.ai_flags = AI_NUMERICHOST; |
1049 | 958 | ret = getaddrinfo(end, NULL, &addr_hints, &addr_res); |
1050 | if(ret) { | |
1051 | fprintf(stderr, "%s: can't parse address %s: %s\n", prog, end, gai_strerror(ret)); | |
959 | if (ret) { | |
960 | fprintf(stderr, "Error: can't parse address %s: %s\n", end, gai_strerror(ret)); | |
1052 | 961 | exit(1); |
1053 | 962 | } |
1054 | if(addr_res->ai_family != AF_INET) { | |
963 | if (addr_res->ai_family != AF_INET) { | |
1055 | 964 | freeaddrinfo(addr_res); |
1056 | fprintf(stderr, "%s: -g works only with IPv4 addresses\n", prog); | |
965 | fprintf(stderr, "Error: -g works only with IPv4 addresses\n"); | |
1057 | 966 | exit(1); |
1058 | 967 | } |
1059 | 968 | end_long = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr); |
1060 | 969 | freeaddrinfo(addr_res); |
1061 | 970 | |
1062 | if(end_long > start_long + MAX_GENERATE) { | |
1063 | fprintf(stderr, "%s: -g parameter generates too many addresses\n", prog); | |
1064 | exit(1); | |
971 | if (end_long > start_long + MAX_GENERATE) { | |
972 | fprintf(stderr, "%s: -g parameter generates too many addresses\n", prog); | |
973 | exit(1); | |
1065 | 974 | } |
1066 | 975 | |
1067 | 976 | /* generate */ |
1068 | for(; start_long <= end_long; start_long++) { | |
977 | for (; start_long <= end_long; start_long++) { | |
1069 | 978 | struct in_addr in_addr_tmp; |
1070 | 979 | char buffer[20]; |
1071 | 980 | in_addr_tmp.s_addr = htonl(start_long); |
1074 | 983 | } |
1075 | 984 | } |
1076 | 985 | |
1077 | ||
1078 | 986 | void main_loop() |
1079 | 987 | { |
1080 | 988 | long lt; |
1081 | 989 | long wait_time; |
1082 | 990 | long wait_time_next_report; |
1083 | HOST_ENTRY *h; | |
1084 | ||
1085 | while(ev_first) { | |
991 | HOST_ENTRY* h; | |
992 | ||
993 | while (ev_first) { | |
1086 | 994 | /* Any event that can be processed now ? */ |
1087 | if(ev_first->ev_time.tv_sec < current_time.tv_sec || | |
1088 | (ev_first->ev_time.tv_sec == current_time.tv_sec && | |
1089 | ev_first->ev_time.tv_usec < current_time.tv_usec)) | |
1090 | { | |
995 | if (ev_first->ev_time.tv_sec < current_time.tv_sec || (ev_first->ev_time.tv_sec == current_time.tv_sec && ev_first->ev_time.tv_usec < current_time.tv_usec)) { | |
1091 | 996 | /* Event type: ping */ |
1092 | if(ev_first->ev_type == EV_TYPE_PING) { | |
997 | if (ev_first->ev_type == EV_TYPE_PING) { | |
1093 | 998 | /* Make sure that we don't ping more than once every "interval" */ |
1094 | lt = timeval_diff( ¤t_time, &last_send_time ); | |
1095 | if(lt < interval) goto wait_for_reply; | |
999 | lt = timeval_diff(¤t_time, &last_send_time); | |
1000 | if (lt < interval) | |
1001 | goto wait_for_reply; | |
1096 | 1002 | |
1097 | 1003 | /* Dequeue the event */ |
1098 | 1004 | h = ev_dequeue(); |
1099 | 1005 | |
1100 | 1006 | /* Send the ping */ |
1101 | send_ping(h); | |
1007 | /*printf("Sending ping after %d ms\n", lt/100); */ | |
1008 | send_ping(s, h); | |
1102 | 1009 | |
1103 | 1010 | /* Check what needs to be done next */ |
1104 | if(!loop_flag && !count_flag) { | |
1011 | if (!loop_flag && !count_flag) { | |
1105 | 1012 | /* Normal mode: schedule retry */ |
1106 | if(h->waiting < retry + 1) { | |
1013 | if (h->waiting < retry + 1) { | |
1107 | 1014 | h->ev_type = EV_TYPE_PING; |
1108 | 1015 | h->ev_time.tv_sec = last_send_time.tv_sec; |
1109 | 1016 | h->ev_time.tv_usec = last_send_time.tv_usec; |
1110 | 1017 | timeval_add(&h->ev_time, h->timeout); |
1111 | 1018 | ev_enqueue(h); |
1112 | 1019 | |
1113 | if(backoff_flag) { | |
1020 | if (backoff_flag) { | |
1114 | 1021 | h->timeout *= backoff; |
1115 | 1022 | } |
1116 | 1023 | } |
1124 | 1031 | } |
1125 | 1032 | } |
1126 | 1033 | /* Loop and count mode: schedule next ping */ |
1127 | else if(loop_flag || (count_flag && h->num_sent < count)) | |
1128 | { | |
1034 | else if (loop_flag || (count_flag && h->num_sent < count)) { | |
1129 | 1035 | h->ev_type = EV_TYPE_PING; |
1130 | 1036 | h->ev_time.tv_sec = last_send_time.tv_sec; |
1131 | 1037 | h->ev_time.tv_usec = last_send_time.tv_usec; |
1133 | 1039 | ev_enqueue(h); |
1134 | 1040 | } |
1135 | 1041 | /* Count mode: schedule timeout after last ping */ |
1136 | else if(count_flag && h->num_sent >= count) { | |
1042 | else if (count_flag && h->num_sent >= count) { | |
1137 | 1043 | h->ev_type = EV_TYPE_TIMEOUT; |
1138 | 1044 | h->ev_time.tv_sec = last_send_time.tv_sec; |
1139 | 1045 | h->ev_time.tv_usec = last_send_time.tv_usec; |
1142 | 1048 | } |
1143 | 1049 | } |
1144 | 1050 | /* Event type: timeout */ |
1145 | else if(ev_first->ev_type == EV_TYPE_TIMEOUT) { | |
1051 | else if (ev_first->ev_type == EV_TYPE_TIMEOUT) { | |
1146 | 1052 | num_timeout++; |
1147 | 1053 | remove_job(ev_first); |
1148 | 1054 | } |
1151 | 1057 | wait_for_reply: |
1152 | 1058 | |
1153 | 1059 | /* When can we expect the next event? */ |
1154 | if(ev_first) { | |
1155 | if(ev_first->ev_time.tv_sec == 0) { | |
1060 | if (ev_first) { | |
1061 | if (ev_first->ev_time.tv_sec == 0) { | |
1156 | 1062 | wait_time = 0; |
1157 | } | |
1158 | else { | |
1063 | } else { | |
1159 | 1064 | wait_time = timeval_diff(&ev_first->ev_time, ¤t_time); |
1160 | if(wait_time < 0) wait_time = 0; | |
1161 | } | |
1162 | if(ev_first->ev_type == EV_TYPE_PING) { | |
1065 | if (wait_time < 0) | |
1066 | wait_time = 0; | |
1067 | } | |
1068 | if (ev_first->ev_type == EV_TYPE_PING) { | |
1163 | 1069 | /* make sure that we wait enough, so that the inter-ping delay is |
1164 | 1070 | * bigger than 'interval' */ |
1165 | if(wait_time < interval) { | |
1071 | if (wait_time < interval) { | |
1166 | 1072 | lt = timeval_diff(¤t_time, &last_send_time); |
1167 | if(lt < interval) { | |
1168 | wait_time = interval-lt; | |
1169 | } | |
1170 | else { | |
1073 | if (lt < interval) { | |
1074 | wait_time = interval - lt; | |
1075 | } else { | |
1171 | 1076 | wait_time = 0; |
1172 | 1077 | } |
1173 | 1078 | } |
1174 | 1079 | } |
1175 | 1080 | |
1176 | #if defined( DEBUG ) || defined( _DEBUG ) | |
1177 | if( trace_flag ) { | |
1081 | #if defined(DEBUG) || defined(_DEBUG) | |
1082 | if (trace_flag) { | |
1178 | 1083 | fprintf(stderr, "next event in %d ms (%s)\n", wait_time / 100, ev_first->host); |
1179 | 1084 | } |
1180 | 1085 | #endif |
1181 | } | |
1182 | else { | |
1086 | } else { | |
1183 | 1087 | wait_time = interval; |
1184 | 1088 | } |
1185 | 1089 | |
1186 | 1090 | /* Make sure we don't wait too long, in case a report is expected */ |
1187 | if( report_interval && ( loop_flag || count_flag ) ) { | |
1188 | wait_time_next_report = timeval_diff ( &next_report_time, ¤t_time ); | |
1189 | if(wait_time_next_report < wait_time) { | |
1190 | wait_time = wait_time_next_report; | |
1191 | if(wait_time < 0) { wait_time = 0; } | |
1192 | } | |
1091 | if (report_interval && (loop_flag || count_flag)) { | |
1092 | wait_time_next_report = timeval_diff(&next_report_time, ¤t_time); | |
1093 | if (wait_time_next_report < wait_time) { | |
1094 | wait_time = wait_time_next_report; | |
1095 | if (wait_time < 0) { | |
1096 | wait_time = 0; | |
1097 | } | |
1098 | } | |
1193 | 1099 | } |
1194 | 1100 | |
1195 | 1101 | /* Receive replies */ |
1196 | 1102 | /* (this is what sleeps during each loop iteration) */ |
1197 | if(wait_for_reply(wait_time)) { | |
1198 | while(wait_for_reply(0)); /* process other replies in the queue */ | |
1199 | } | |
1200 | ||
1201 | gettimeofday( ¤t_time, &tz ); | |
1103 | if (wait_for_reply(wait_time)) { | |
1104 | while (wait_for_reply(0)) | |
1105 | ; /* process other replies in the queue */ | |
1106 | } | |
1107 | ||
1108 | gettimeofday(¤t_time, &tz); | |
1202 | 1109 | |
1203 | 1110 | /* Print report */ |
1204 | if( report_interval && ( loop_flag || count_flag ) && | |
1205 | ( timeval_diff ( ¤t_time, &next_report_time ) >= 0 ) ) | |
1206 | { | |
1207 | if(netdata_flag) | |
1111 | if (report_interval && (loop_flag || count_flag) && (timeval_diff(¤t_time, &next_report_time) >= 0)) { | |
1112 | if (netdata_flag) | |
1208 | 1113 | print_netdata(); |
1209 | 1114 | else |
1210 | 1115 | print_per_system_splits(); |
1211 | 1116 | |
1212 | while(timeval_diff ( ¤t_time, &next_report_time ) >= 0 ) | |
1117 | while (timeval_diff(¤t_time, &next_report_time) >= 0) | |
1213 | 1118 | timeval_add(&next_report_time, report_interval); |
1214 | 1119 | } |
1215 | 1120 | } |
1232 | 1137 | void finish() |
1233 | 1138 | { |
1234 | 1139 | int i; |
1235 | HOST_ENTRY *h; | |
1236 | ||
1237 | gettimeofday( &end_time, &tz ); | |
1140 | HOST_ENTRY* h; | |
1141 | ||
1142 | gettimeofday(&end_time, &tz); | |
1238 | 1143 | |
1239 | 1144 | /* tot up unreachables */ |
1240 | for( i = 0; i < num_hosts; i++ ) | |
1241 | { | |
1145 | for (i = 0; i < num_hosts; i++) { | |
1242 | 1146 | h = table[i]; |
1243 | 1147 | |
1244 | if( !h->num_recv ) | |
1245 | { | |
1148 | if (!h->num_recv) { | |
1246 | 1149 | num_unreachable++; |
1247 | 1150 | |
1248 | if( verbose_flag || unreachable_flag ) | |
1249 | { | |
1250 | printf( "%s", h->host ); | |
1251 | ||
1252 | if( verbose_flag ) | |
1253 | printf( " is unreachable" ); | |
1254 | ||
1255 | printf( "\n" ); | |
1256 | ||
1257 | }/* IF */ | |
1258 | }/* IF */ | |
1259 | }/* FOR */ | |
1260 | ||
1261 | if( count_flag || loop_flag ) | |
1151 | if (verbose_flag || unreachable_flag) { | |
1152 | printf("%s", h->host); | |
1153 | ||
1154 | if (verbose_flag) | |
1155 | printf(" is unreachable"); | |
1156 | ||
1157 | printf("\n"); | |
1158 | ||
1159 | } | |
1160 | } | |
1161 | } | |
1162 | ||
1163 | if (count_flag || loop_flag) | |
1262 | 1164 | print_per_system_stats(); |
1263 | #if defined( DEBUG ) || defined( _DEBUG ) | |
1264 | else if( print_per_system_flag ) | |
1165 | #if defined(DEBUG) || defined(_DEBUG) | |
1166 | else if (print_per_system_flag) | |
1265 | 1167 | print_per_system_stats(); |
1266 | 1168 | #endif /* DEBUG || _DEBUG */ |
1267 | 1169 | |
1268 | if( stats_flag ) | |
1170 | if (stats_flag) | |
1269 | 1171 | print_global_stats(); |
1270 | 1172 | |
1271 | if( num_noaddress ) | |
1272 | exit( 2 ); | |
1273 | else if( num_alive != num_hosts ) | |
1274 | exit( 1 ); | |
1173 | if (num_noaddress) | |
1174 | exit(2); | |
1175 | else if (num_alive != num_hosts) | |
1176 | exit(1); | |
1275 | 1177 | |
1276 | 1178 | exit(0); |
1277 | 1179 | |
1278 | } /* finish() */ | |
1279 | ||
1180 | } | |
1280 | 1181 | |
1281 | 1182 | /************************************************************ |
1282 | 1183 | |
1291 | 1192 | |
1292 | 1193 | ************************************************************/ |
1293 | 1194 | |
1294 | void print_per_system_stats( void ) | |
1195 | void print_per_system_stats(void) | |
1295 | 1196 | { |
1296 | 1197 | int i, j, avg, outage_ms; |
1297 | HOST_ENTRY *h; | |
1198 | HOST_ENTRY* h; | |
1298 | 1199 | int resp; |
1299 | 1200 | |
1300 | fflush( stdout ); | |
1301 | ||
1302 | if( verbose_flag || per_recv_flag ) | |
1303 | fprintf( stderr, "\n" ); | |
1304 | ||
1305 | for( i = 0; i < num_hosts; i++ ) | |
1306 | { | |
1201 | fflush(stdout); | |
1202 | ||
1203 | if (verbose_flag || per_recv_flag) | |
1204 | fprintf(stderr, "\n"); | |
1205 | ||
1206 | for (i = 0; i < num_hosts; i++) { | |
1307 | 1207 | h = table[i]; |
1308 | fprintf( stderr, "%s%s :", h->host, h->pad ); | |
1309 | ||
1310 | if( report_all_rtts_flag ) { | |
1311 | for( j = 0; j < h->num_sent; j++ ) { | |
1312 | if( ( resp = h->resp_times[j] ) >= 0 ) | |
1313 | fprintf( stderr, " %d.%02d", resp / 100, resp % 100 ); | |
1208 | fprintf(stderr, "%s%s :", h->host, h->pad); | |
1209 | ||
1210 | if (report_all_rtts_flag) { | |
1211 | for (j = 0; j < h->num_sent; j++) { | |
1212 | if ((resp = h->resp_times[j]) >= 0) | |
1213 | fprintf(stderr, " %d.%02d", resp / 100, resp % 100); | |
1314 | 1214 | else |
1315 | fprintf( stderr, " -" ); | |
1316 | } | |
1317 | ||
1318 | fprintf( stderr, "\n" ); | |
1319 | } | |
1320 | else { | |
1321 | if( h->num_recv <= h->num_sent ) | |
1322 | { | |
1323 | fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%", | |
1324 | h->num_sent, h->num_recv, h->num_sent > 0 ? | |
1325 | ( ( h->num_sent - h->num_recv ) * 100 ) / h->num_sent : 0 ); | |
1215 | fprintf(stderr, " -"); | |
1216 | } | |
1217 | ||
1218 | fprintf(stderr, "\n"); | |
1219 | } else { | |
1220 | if (h->num_recv <= h->num_sent) { | |
1221 | fprintf(stderr, " xmt/rcv/%%loss = %d/%d/%d%%", | |
1222 | h->num_sent, h->num_recv, h->num_sent > 0 ? ((h->num_sent - h->num_recv) * 100) / h->num_sent : 0); | |
1326 | 1223 | |
1327 | 1224 | if (outage_flag) { |
1328 | 1225 | /* Time outage total */ |
1329 | outage_ms = (h->num_sent - h->num_recv) * perhost_interval/100; | |
1330 | fprintf( stderr, ", outage(ms) = %d", outage_ms ); | |
1226 | outage_ms = (h->num_sent - h->num_recv) * perhost_interval / 100; | |
1227 | fprintf(stderr, ", outage(ms) = %d", outage_ms); | |
1331 | 1228 | } |
1332 | 1229 | |
1333 | } | |
1334 | else { | |
1335 | fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%", | |
1230 | } else { | |
1231 | fprintf(stderr, " xmt/rcv/%%return = %d/%d/%d%%", | |
1336 | 1232 | h->num_sent, h->num_recv, |
1337 | ( ( h->num_recv * 100 ) / h->num_sent ) ); | |
1338 | ||
1339 | } | |
1340 | ||
1341 | if( h->num_recv ) { | |
1233 | ((h->num_recv * 100) / h->num_sent)); | |
1234 | } | |
1235 | ||
1236 | if (h->num_recv) { | |
1342 | 1237 | avg = h->total_time / h->num_recv; |
1343 | fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply ) ); | |
1344 | fprintf( stderr, "/%s", sprint_tm( avg ) ); | |
1345 | fprintf( stderr, "/%s", sprint_tm( h->max_reply ) ); | |
1346 | ||
1238 | fprintf(stderr, ", min/avg/max = %s", sprint_tm(h->min_reply)); | |
1239 | fprintf(stderr, "/%s", sprint_tm(avg)); | |
1240 | fprintf(stderr, "/%s", sprint_tm(h->max_reply)); | |
1347 | 1241 | } |
1348 | 1242 | |
1349 | 1243 | fprintf(stderr, "\n"); |
1350 | 1244 | } |
1351 | 1245 | |
1352 | #if defined( DEBUG ) || defined( _DEBUG ) | |
1353 | if( sent_times_flag ) | |
1354 | { | |
1355 | for( j = 0; j < h->num_sent; j++ ) | |
1356 | { | |
1357 | if( ( resp = h->sent_times[j] ) >= 0 ) | |
1358 | fprintf( stderr, " %s", sprint_tm( resp ) ); | |
1246 | #if defined(DEBUG) || defined(_DEBUG) | |
1247 | if (sent_times_flag) { | |
1248 | for (j = 0; j < h->num_sent; j++) { | |
1249 | if ((resp = h->sent_times[j]) >= 0) | |
1250 | fprintf(stderr, " %s", sprint_tm(resp)); | |
1359 | 1251 | else |
1360 | fprintf( stderr, " -" ); | |
1361 | ||
1362 | fprintf( stderr, "\n" ); | |
1363 | ||
1252 | fprintf(stderr, " -"); | |
1253 | ||
1254 | fprintf(stderr, "\n"); | |
1364 | 1255 | } |
1365 | 1256 | } |
1366 | 1257 | #endif |
1367 | 1258 | } |
1368 | 1259 | } |
1369 | 1260 | |
1370 | ||
1371 | 1261 | /************************************************************ |
1372 | 1262 | |
1373 | 1263 | Function: print_netdata |
1381 | 1271 | |
1382 | 1272 | ************************************************************/ |
1383 | 1273 | |
1384 | void print_netdata( void ) | |
1274 | void print_netdata(void) | |
1385 | 1275 | { |
1386 | 1276 | static int sent_charts = 0; |
1387 | 1277 | |
1388 | 1278 | int i, avg; |
1389 | HOST_ENTRY *h; | |
1390 | ||
1391 | fflush( stdout ); | |
1392 | ||
1393 | for( i = 0; i < num_hosts; i++ ) | |
1394 | { | |
1279 | HOST_ENTRY* h; | |
1280 | ||
1281 | fflush(stdout); | |
1282 | ||
1283 | for (i = 0; i < num_hosts; i++) { | |
1395 | 1284 | h = table[i]; |
1396 | 1285 | |
1397 | if(!sent_charts) { | |
1286 | if (!sent_charts) { | |
1398 | 1287 | printf("CHART fping.%s_packets '' 'FPing Packets for host %s' packets '%s' fping.packets line 110020 %d\n", h->name, h->host, h->name, report_interval / 100000); |
1399 | 1288 | printf("DIMENSION xmt sent absolute 1 1\n"); |
1400 | 1289 | printf("DIMENSION rcv received absolute 1 1\n"); |
1405 | 1294 | printf("SET rcv = %d\n", h->num_recv_i); |
1406 | 1295 | printf("END\n"); |
1407 | 1296 | |
1408 | if(!sent_charts) { | |
1297 | if (!sent_charts) { | |
1409 | 1298 | printf("CHART fping.%s_quality '' 'FPing Quality for host %s' percentage '%s' fping.quality area 110010 %d\n", h->name, h->host, h->name, report_interval / 100000); |
1410 | 1299 | printf("DIMENSION returned '' absolute 1 1\n"); |
1411 | 1300 | /* printf("DIMENSION lost '' absolute 1 1\n"); */ |
1412 | 1301 | } |
1413 | 1302 | |
1414 | 1303 | /* if we just sent the probe and didn't receive a reply, we shouldn't count it */ |
1415 | h->discard_next_recv_i=0; | |
1416 | if( h->waiting && timeval_diff(¤t_time, &h->last_send_time) < h->timeout) { | |
1417 | if(h->num_sent_i) { | |
1304 | h->discard_next_recv_i = 0; | |
1305 | if (h->waiting && timeval_diff(¤t_time, &h->last_send_time) < h->timeout) { | |
1306 | if (h->num_sent_i) { | |
1418 | 1307 | h->num_sent_i--; |
1419 | h->discard_next_recv_i=1; | |
1420 | } | |
1421 | } | |
1422 | ||
1308 | h->discard_next_recv_i = 1; | |
1309 | } | |
1310 | } | |
1423 | 1311 | |
1424 | 1312 | printf("BEGIN fping.%s_quality\n", h->name); |
1425 | /* | |
1313 | /* | |
1426 | 1314 | if( h->num_recv_i <= h->num_sent_i ) |
1427 | 1315 | printf("SET lost = %d\n", h->num_sent_i > 0 ? ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 ); |
1428 | 1316 | else |
1429 | 1317 | printf("SET lost = 0\n"); |
1430 | 1318 | */ |
1431 | 1319 | |
1432 | printf("SET returned = %d\n", h->num_sent_i > 0 ? ( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 ); | |
1320 | printf("SET returned = %d\n", h->num_sent_i > 0 ? ((h->num_recv_i * 100) / h->num_sent_i) : 0); | |
1433 | 1321 | printf("END\n"); |
1434 | 1322 | |
1435 | if(!sent_charts) { | |
1323 | if (!sent_charts) { | |
1436 | 1324 | printf("CHART fping.%s_latency '' 'FPing Latency for host %s' ms '%s' fping.latency area 110000 %d\n", h->name, h->host, h->name, report_interval / 100000); |
1437 | 1325 | printf("DIMENSION min minimum absolute 10 1000\n"); |
1438 | 1326 | printf("DIMENSION max maximum absolute 10 1000\n"); |
1440 | 1328 | } |
1441 | 1329 | |
1442 | 1330 | printf("BEGIN fping.%s_latency\n", h->name); |
1443 | if( h->num_recv_i ) | |
1444 | { | |
1331 | if (h->num_recv_i) { | |
1445 | 1332 | avg = h->total_time_i / h->num_recv_i; |
1446 | 1333 | printf("SET min = %d\n", h->min_reply_i); |
1447 | 1334 | printf("SET avg = %d\n", avg); |
1448 | 1335 | printf("SET max = %d\n", h->max_reply_i); |
1449 | 1336 | |
1450 | }/* IF */ | |
1337 | } | |
1451 | 1338 | printf("END\n"); |
1452 | 1339 | |
1453 | h->num_sent_i = h->num_recv_i = h->max_reply_i = | |
1454 | h->min_reply_i = h->total_time_i = 0; | |
1455 | ||
1456 | }/* FOR */ | |
1340 | h->num_sent_i = h->num_recv_i = h->max_reply_i = h->min_reply_i = h->total_time_i = 0; | |
1341 | ||
1342 | } | |
1457 | 1343 | |
1458 | 1344 | sent_charts = 1; |
1459 | } /* print_per_system_splits() */ | |
1345 | } | |
1460 | 1346 | |
1461 | 1347 | /************************************************************ |
1462 | 1348 | |
1471 | 1357 | |
1472 | 1358 | ************************************************************/ |
1473 | 1359 | |
1474 | void print_per_system_splits( void ) | |
1360 | void print_per_system_splits(void) | |
1475 | 1361 | { |
1476 | 1362 | int i, avg, outage_ms_i; |
1477 | HOST_ENTRY *h; | |
1478 | struct tm *curr_tm; | |
1479 | ||
1480 | fflush( stdout ); | |
1481 | ||
1482 | if( verbose_flag || per_recv_flag ) | |
1483 | fprintf( stderr, "\n" ); | |
1484 | ||
1485 | gettimeofday( ¤t_time, &tz ); | |
1486 | curr_tm = localtime( ( time_t* )¤t_time.tv_sec ); | |
1487 | fprintf( stderr, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour, | |
1488 | curr_tm->tm_min, curr_tm->tm_sec ); | |
1489 | ||
1490 | for( i = 0; i < num_hosts; i++ ) { | |
1363 | HOST_ENTRY* h; | |
1364 | struct tm* curr_tm; | |
1365 | ||
1366 | fflush(stdout); | |
1367 | ||
1368 | if (verbose_flag || per_recv_flag) | |
1369 | fprintf(stderr, "\n"); | |
1370 | ||
1371 | gettimeofday(¤t_time, &tz); | |
1372 | curr_tm = localtime((time_t*)¤t_time.tv_sec); | |
1373 | fprintf(stderr, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour, | |
1374 | curr_tm->tm_min, curr_tm->tm_sec); | |
1375 | ||
1376 | for (i = 0; i < num_hosts; i++) { | |
1491 | 1377 | h = table[i]; |
1492 | fprintf( stderr, "%s%s :", h->host, h->pad ); | |
1378 | fprintf(stderr, "%s%s :", h->host, h->pad); | |
1493 | 1379 | |
1494 | 1380 | /* if we just sent the probe and didn't receive a reply, we shouldn't count it */ |
1495 | h->discard_next_recv_i=0; | |
1496 | if( h->waiting && timeval_diff(¤t_time, &h->last_send_time) < h->timeout) { | |
1497 | if(h->num_sent_i) { | |
1381 | h->discard_next_recv_i = 0; | |
1382 | if (h->waiting && timeval_diff(¤t_time, &h->last_send_time) < h->timeout) { | |
1383 | if (h->num_sent_i) { | |
1498 | 1384 | h->num_sent_i--; |
1499 | h->discard_next_recv_i=1; | |
1500 | } | |
1501 | } | |
1502 | ||
1503 | if( h->num_recv_i <= h->num_sent_i ) { | |
1504 | fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%", | |
1505 | h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ? | |
1506 | ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 ); | |
1385 | h->discard_next_recv_i = 1; | |
1386 | } | |
1387 | } | |
1388 | ||
1389 | if (h->num_recv_i <= h->num_sent_i) { | |
1390 | fprintf(stderr, " xmt/rcv/%%loss = %d/%d/%d%%", | |
1391 | h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ? ((h->num_sent_i - h->num_recv_i) * 100) / h->num_sent_i : 0); | |
1507 | 1392 | |
1508 | 1393 | if (outage_flag) { |
1509 | 1394 | /* Time outage */ |
1510 | outage_ms_i = (h->num_sent_i - h->num_recv_i) * perhost_interval/100; | |
1511 | fprintf( stderr, ", outage(ms) = %d", outage_ms_i ); | |
1512 | } | |
1513 | } | |
1514 | else { | |
1515 | fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%", | |
1516 | h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ? | |
1517 | ( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 ); | |
1518 | } | |
1519 | ||
1520 | if( h->num_recv_i ) { | |
1395 | outage_ms_i = (h->num_sent_i - h->num_recv_i) * perhost_interval / 100; | |
1396 | fprintf(stderr, ", outage(ms) = %d", outage_ms_i); | |
1397 | } | |
1398 | } else { | |
1399 | fprintf(stderr, " xmt/rcv/%%return = %d/%d/%d%%", | |
1400 | h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ? ((h->num_recv_i * 100) / h->num_sent_i) : 0); | |
1401 | } | |
1402 | ||
1403 | if (h->num_recv_i) { | |
1521 | 1404 | avg = h->total_time_i / h->num_recv_i; |
1522 | fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) ); | |
1523 | fprintf( stderr, "/%s", sprint_tm( avg ) ); | |
1524 | fprintf( stderr, "/%s", sprint_tm( h->max_reply_i ) ); | |
1525 | ||
1526 | } | |
1527 | ||
1528 | fprintf( stderr, "\n" ); | |
1529 | h->num_sent_i = h->num_recv_i = h->max_reply_i = | |
1530 | h->min_reply_i = h->total_time_i = 0; | |
1531 | ||
1532 | } | |
1533 | } /* print_per_system_splits() */ | |
1534 | ||
1405 | fprintf(stderr, ", min/avg/max = %s", sprint_tm(h->min_reply_i)); | |
1406 | fprintf(stderr, "/%s", sprint_tm(avg)); | |
1407 | fprintf(stderr, "/%s", sprint_tm(h->max_reply_i)); | |
1408 | } | |
1409 | ||
1410 | fprintf(stderr, "\n"); | |
1411 | h->num_sent_i = h->num_recv_i = h->max_reply_i = h->min_reply_i = h->total_time_i = 0; | |
1412 | } | |
1413 | } | |
1535 | 1414 | |
1536 | 1415 | /************************************************************ |
1537 | 1416 | |
1546 | 1425 | |
1547 | 1426 | ************************************************************/ |
1548 | 1427 | |
1549 | void print_global_stats( void ) | |
1550 | { | |
1551 | fflush( stdout ); | |
1552 | fprintf( stderr, "\n" ); | |
1553 | fprintf( stderr, " %7d targets\n", num_hosts ); | |
1554 | fprintf( stderr, " %7d alive\n", num_alive ); | |
1555 | fprintf( stderr, " %7d unreachable\n" ,num_unreachable ); | |
1556 | fprintf( stderr, " %7d unknown addresses\n", num_noaddress ); | |
1557 | fprintf( stderr, "\n" ); | |
1558 | fprintf( stderr, " %7d timeouts (waiting for response)\n", num_timeout ); | |
1559 | fprintf( stderr, " %7d ICMP Echos sent\n", num_pingsent ); | |
1560 | fprintf( stderr, " %7d ICMP Echo Replies received\n", num_pingreceived ); | |
1561 | fprintf( stderr, " %7d other ICMP received\n", num_othericmprcvd ); | |
1562 | fprintf( stderr, "\n" ); | |
1563 | ||
1564 | if( total_replies == 0 ) | |
1565 | { | |
1428 | void print_global_stats(void) | |
1429 | { | |
1430 | fflush(stdout); | |
1431 | fprintf(stderr, "\n"); | |
1432 | fprintf(stderr, " %7d targets\n", num_hosts); | |
1433 | fprintf(stderr, " %7d alive\n", num_alive); | |
1434 | fprintf(stderr, " %7d unreachable\n", num_unreachable); | |
1435 | fprintf(stderr, " %7d unknown addresses\n", num_noaddress); | |
1436 | fprintf(stderr, "\n"); | |
1437 | fprintf(stderr, " %7d timeouts (waiting for response)\n", num_timeout); | |
1438 | fprintf(stderr, " %7d ICMP Echos sent\n", num_pingsent); | |
1439 | fprintf(stderr, " %7d ICMP Echo Replies received\n", num_pingreceived); | |
1440 | fprintf(stderr, " %7d other ICMP received\n", num_othericmprcvd); | |
1441 | fprintf(stderr, "\n"); | |
1442 | ||
1443 | if (total_replies == 0) { | |
1566 | 1444 | min_reply = 0; |
1567 | 1445 | max_reply = 0; |
1568 | 1446 | total_replies = 1; |
1569 | 1447 | sum_replies = 0; |
1570 | 1448 | |
1571 | }/* IF */ | |
1572 | ||
1573 | fprintf( stderr, " %s ms (min round trip time)\n", sprint_tm( min_reply ) ); | |
1574 | fprintf( stderr, " %s ms (avg round trip time)\n", | |
1575 | sprint_tm( ( int )( sum_replies / total_replies ) ) ); | |
1576 | fprintf( stderr, " %s ms (max round trip time)\n", sprint_tm( max_reply ) ); | |
1577 | fprintf( stderr, " %12.3f sec (elapsed real time)\n", | |
1578 | timeval_diff( &end_time, &start_time ) / 100000.0 ); | |
1579 | fprintf( stderr, "\n" ); | |
1580 | ||
1581 | } /* print_global_stats() */ | |
1582 | ||
1449 | } | |
1450 | ||
1451 | fprintf(stderr, " %s ms (min round trip time)\n", sprint_tm(min_reply)); | |
1452 | fprintf(stderr, " %s ms (avg round trip time)\n", | |
1453 | sprint_tm((int)(sum_replies / total_replies))); | |
1454 | fprintf(stderr, " %s ms (max round trip time)\n", sprint_tm(max_reply)); | |
1455 | fprintf(stderr, " %12.3f sec (elapsed real time)\n", | |
1456 | timeval_diff(&end_time, &start_time) / 100000.0); | |
1457 | fprintf(stderr, "\n"); | |
1458 | ||
1459 | } | |
1583 | 1460 | |
1584 | 1461 | /************************************************************ |
1585 | 1462 | |
1599 | 1476 | |
1600 | 1477 | ************************************************************/ |
1601 | 1478 | |
1602 | int send_ping( HOST_ENTRY *h ) | |
1479 | int send_ping(int s, HOST_ENTRY* h) | |
1603 | 1480 | { |
1604 | 1481 | int n; |
1605 | 1482 | int myseq; |
1606 | 1483 | int ret = 1; |
1607 | 1484 | |
1608 | gettimeofday( &h->last_send_time, &tz ); | |
1485 | gettimeofday(&h->last_send_time, &tz); | |
1609 | 1486 | myseq = seqmap_add(h->i, h->num_sent, &h->last_send_time); |
1610 | 1487 | |
1611 | 1488 | #if defined(DEBUG) || defined(_DEBUG) |
1612 | if( trace_flag ) | |
1613 | printf( "sending [%d] to %s\n", h->num_sent, h->host ); | |
1489 | if (trace_flag) | |
1490 | printf("sending [%d] to %s\n", h->num_sent, h->host); | |
1614 | 1491 | #endif /* DEBUG || _DEBUG */ |
1615 | 1492 | |
1616 | if(h->saddr.ss_family == AF_INET) { | |
1617 | n = socket_sendto_ping_ipv4(socket4, (struct sockaddr *) &h->saddr, h->saddr_len, myseq, ident); | |
1618 | } | |
1619 | #ifdef IPV6 | |
1620 | else if(h->saddr.ss_family == AF_INET6) { | |
1621 | n = socket_sendto_ping_ipv6(socket6, (struct sockaddr *) &h->saddr, h->saddr_len, myseq, ident); | |
1622 | } | |
1623 | #endif | |
1624 | else { | |
1625 | return 0; | |
1626 | } | |
1627 | ||
1628 | if( | |
1493 | n = socket_sendto_ping(s, (struct sockaddr*)&h->saddr, h->saddr_len, myseq, ident); | |
1494 | ||
1495 | if ( | |
1629 | 1496 | (n < 0) |
1630 | #if defined( EHOSTDOWN ) | |
1497 | #if defined(EHOSTDOWN) | |
1631 | 1498 | && errno != EHOSTDOWN |
1632 | 1499 | #endif |
1633 | ) { | |
1634 | if( verbose_flag ) { | |
1635 | print_warning( "%s: error while sending ping: %s\n", h->host, strerror( errno ) ); | |
1636 | } | |
1637 | ||
1638 | if( !loop_flag ) | |
1500 | ) { | |
1501 | if (verbose_flag) { | |
1502 | print_warning("%s: error while sending ping: %s\n", h->host, strerror(errno)); | |
1503 | } | |
1504 | ||
1505 | if (!loop_flag) | |
1639 | 1506 | h->resp_times[h->num_sent] = RESP_ERROR; |
1640 | 1507 | |
1641 | 1508 | ret = 0; |
1642 | } | |
1643 | else { | |
1509 | } else { | |
1644 | 1510 | /* mark this trial as outstanding */ |
1645 | if( !loop_flag ) | |
1511 | if (!loop_flag) | |
1646 | 1512 | h->resp_times[h->num_sent] = RESP_WAITING; |
1647 | 1513 | |
1648 | #if defined( DEBUG ) || defined( _DEBUG ) | |
1649 | if( sent_times_flag ) | |
1650 | h->sent_times[h->num_sent] = timeval_diff( &h->last_send_time, &start_time ); | |
1514 | #if defined(DEBUG) || defined(_DEBUG) | |
1515 | if (sent_times_flag) | |
1516 | h->sent_times[h->num_sent] = timeval_diff(&h->last_send_time, &start_time); | |
1651 | 1517 | #endif |
1652 | 1518 | } |
1653 | 1519 | |
1656 | 1522 | h->waiting++; |
1657 | 1523 | num_pingsent++; |
1658 | 1524 | last_send_time = h->last_send_time; |
1659 | h->discard_next_recv_i=0; | |
1660 | ||
1661 | return(ret); | |
1662 | } | |
1663 | ||
1664 | int socket_can_read(struct timeval *timeout) | |
1525 | h->discard_next_recv_i = 0; | |
1526 | ||
1527 | return (ret); | |
1528 | } | |
1529 | ||
1530 | int wait_on_socket(int socket, struct timeval* timeout) | |
1665 | 1531 | { |
1666 | 1532 | int nfound; |
1667 | 1533 | fd_set readset, writeset; |
1668 | int socketmax; | |
1669 | ||
1670 | #ifndef IPV6 | |
1671 | socketmax = socket4; | |
1672 | #else | |
1673 | socketmax = socket4 > socket6 ? socket4 : socket6; | |
1674 | #endif | |
1675 | 1534 | |
1676 | 1535 | select_again: |
1677 | FD_ZERO( &readset ); | |
1678 | FD_ZERO( &writeset ); | |
1679 | FD_SET( socket4, &readset ); | |
1680 | #ifdef IPV6 | |
1681 | FD_SET( socket6, &readset ); | |
1682 | #endif | |
1683 | ||
1684 | nfound = select(socketmax + 1, &readset, &writeset, NULL, timeout); | |
1685 | if(nfound < 0) { | |
1686 | if(errno == EINTR) { | |
1536 | FD_ZERO(&readset); | |
1537 | FD_ZERO(&writeset); | |
1538 | FD_SET(s, &readset); | |
1539 | ||
1540 | nfound = select(socket + 1, &readset, &writeset, NULL, timeout); | |
1541 | if (nfound < 0) { | |
1542 | if (errno == EINTR) { | |
1687 | 1543 | /* interrupted system call: redo the select */ |
1688 | 1544 | goto select_again; |
1689 | } | |
1690 | else { | |
1545 | } else { | |
1691 | 1546 | perror("select"); |
1692 | 1547 | } |
1693 | 1548 | } |
1694 | 1549 | |
1695 | if(nfound > 0) { | |
1696 | if(FD_ISSET(socket4, &readset)) { | |
1697 | return socket4; | |
1698 | } | |
1699 | #ifdef IPV6 | |
1700 | if(FD_ISSET(socket6, &readset)) { | |
1701 | return socket6; | |
1550 | if (nfound == 0) | |
1551 | return 0; | |
1552 | else | |
1553 | return 1; | |
1554 | } | |
1555 | ||
1556 | int receive_reply(int socket, | |
1557 | struct timeval* timeout, | |
1558 | struct timeval* reply_timestamp, | |
1559 | struct sockaddr* reply_src_addr, | |
1560 | size_t reply_src_addr_len, | |
1561 | char* reply_buf, | |
1562 | size_t reply_buf_len) | |
1563 | { | |
1564 | int recv_len; | |
1565 | ||
1566 | /* Wait for input on the socket */ | |
1567 | if (timeout && !wait_on_socket(socket, timeout)) { | |
1568 | return 0; /* timeout */ | |
1569 | } | |
1570 | ||
1571 | /* Receive data */ | |
1572 | { | |
1573 | static unsigned char msg_control[40]; | |
1574 | struct iovec msg_iov = { | |
1575 | reply_buf, | |
1576 | reply_buf_len | |
1577 | }; | |
1578 | struct msghdr recv_msghdr = { | |
1579 | reply_src_addr, | |
1580 | reply_src_addr_len, | |
1581 | &msg_iov, | |
1582 | 1, | |
1583 | &msg_control, | |
1584 | sizeof(msg_control), | |
1585 | 0 | |
1586 | }; | |
1587 | int timestamp_set = 0; | |
1588 | ||
1589 | recv_len = recvmsg(socket, &recv_msghdr, 0); | |
1590 | if (recv_len <= 0) { | |
1591 | return 0; | |
1592 | } | |
1593 | ||
1594 | #if HAVE_SO_TIMESTAMP | |
1595 | /* ancilliary data */ | |
1596 | struct cmsghdr* cmsg; | |
1597 | for (cmsg = CMSG_FIRSTHDR(&recv_msghdr); | |
1598 | cmsg != NULL; | |
1599 | cmsg = CMSG_NXTHDR(&recv_msghdr, cmsg)) { | |
1600 | if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP) { | |
1601 | memcpy(reply_timestamp, CMSG_DATA(cmsg), sizeof(*reply_timestamp)); | |
1602 | timestamp_set = 1; | |
1603 | } | |
1702 | 1604 | } |
1703 | 1605 | #endif |
1704 | } | |
1705 | ||
1706 | return 0; | |
1707 | } | |
1708 | ||
1709 | int receive_packet(int socket, | |
1710 | struct timeval *reply_timestamp, | |
1711 | struct sockaddr *reply_src_addr, | |
1712 | size_t reply_src_addr_len, | |
1713 | char *reply_buf, | |
1714 | size_t reply_buf_len) | |
1715 | { | |
1716 | int recv_len; | |
1717 | static unsigned char msg_control[40]; | |
1718 | struct iovec msg_iov = { | |
1719 | reply_buf, | |
1720 | reply_buf_len | |
1721 | }; | |
1722 | struct msghdr recv_msghdr = { | |
1723 | reply_src_addr, | |
1724 | reply_src_addr_len, | |
1725 | &msg_iov, | |
1726 | 1, | |
1727 | &msg_control, | |
1728 | sizeof(msg_control), | |
1729 | 0 | |
1730 | }; | |
1731 | int timestamp_set = 0; | |
1732 | struct cmsghdr *cmsg; | |
1733 | ||
1734 | recv_len = recvmsg(socket, &recv_msghdr, 0); | |
1735 | if(recv_len <= 0) { | |
1736 | return 0; | |
1737 | } | |
1738 | ||
1739 | #if HAVE_SO_TIMESTAMP | |
1740 | /* ancilliary data */ | |
1741 | for(cmsg = CMSG_FIRSTHDR(&recv_msghdr); | |
1742 | cmsg != NULL; | |
1743 | cmsg = CMSG_NXTHDR(&recv_msghdr, cmsg)) | |
1606 | ||
1607 | if (!timestamp_set) { | |
1608 | gettimeofday(reply_timestamp, NULL); | |
1609 | } | |
1610 | } | |
1611 | ||
1612 | return recv_len; | |
1613 | } | |
1614 | ||
1615 | int wait_for_reply(long wait_time) | |
1616 | { | |
1617 | int result; | |
1618 | static char buffer[4096]; | |
1619 | struct sockaddr_storage response_addr; | |
1620 | int hlen = 0; | |
1621 | FPING_ICMPHDR* icp; | |
1622 | int n, avg; | |
1623 | HOST_ENTRY* h; | |
1624 | long this_reply; | |
1625 | int this_count; | |
1626 | struct timeval* sent_time; | |
1627 | struct timeval recv_time; | |
1628 | SEQMAP_VALUE* seqmap_value; | |
1629 | #ifndef IPV6 | |
1630 | struct ip* ip; | |
1631 | #endif | |
1632 | ||
1633 | /* receive packet */ | |
1744 | 1634 | { |
1745 | if(cmsg->cmsg_level == SOL_SOCKET && | |
1746 | cmsg->cmsg_type == SCM_TIMESTAMP) | |
1747 | { | |
1748 | memcpy(reply_timestamp, CMSG_DATA(cmsg), sizeof(*reply_timestamp)); | |
1749 | timestamp_set = 1; | |
1750 | } | |
1635 | struct timeval to; | |
1636 | if (wait_time) { | |
1637 | if (wait_time < 100000) { | |
1638 | to.tv_sec = 0; | |
1639 | to.tv_usec = wait_time * 10; | |
1640 | } else { | |
1641 | to.tv_sec = wait_time / 100000; | |
1642 | to.tv_usec = (wait_time % 100000) * 10; | |
1643 | } | |
1644 | } | |
1645 | ||
1646 | result = receive_reply(s, /* socket */ | |
1647 | wait_time ? &to : NULL, /* timeout */ | |
1648 | &recv_time, /* reply_timestamp */ | |
1649 | (struct sockaddr*)&response_addr, /* reply_src_addr */ | |
1650 | sizeof(response_addr), /* reply_src_addr_len */ | |
1651 | buffer, /* reply_buf */ | |
1652 | sizeof(buffer) /* reply_buf_len */ | |
1653 | ); | |
1654 | ||
1655 | if (result <= 0) { | |
1656 | return 0; | |
1657 | } | |
1658 | } | |
1659 | ||
1660 | #if defined(DEBUG) || defined(_DEBUG) | |
1661 | if (randomly_lose_flag) { | |
1662 | if ((random() & 0x07) <= lose_factor) | |
1663 | return 0; | |
1751 | 1664 | } |
1752 | 1665 | #endif |
1753 | 1666 | |
1754 | if(! timestamp_set) { | |
1755 | gettimeofday(reply_timestamp, NULL); | |
1756 | } | |
1757 | ||
1758 | #if defined( DEBUG ) || defined( _DEBUG ) | |
1759 | if( randomly_lose_flag ) | |
1760 | { | |
1761 | if( ( random() & 0x07 ) <= lose_factor ) | |
1762 | return 0; | |
1763 | } | |
1764 | #endif | |
1765 | ||
1766 | return recv_len; | |
1767 | } | |
1768 | ||
1769 | int decode_icmp_ipv4( | |
1770 | struct sockaddr *response_addr, | |
1771 | size_t response_addr_len, | |
1772 | char *reply_buf, | |
1773 | size_t reply_buf_len, | |
1774 | unsigned short *id, | |
1775 | unsigned short *seq | |
1776 | ) | |
1777 | { | |
1778 | struct ip *ip = (struct ip *) reply_buf; | |
1779 | struct icmp *icp; | |
1780 | int hlen = 0; | |
1781 | ||
1782 | #if defined( __alpha__ ) && __STDC__ && !defined( __GLIBC__ ) | |
1667 | #ifndef IPV6 | |
1668 | ip = (struct ip*)buffer; | |
1669 | #if defined(__alpha__) && __STDC__ && !defined(__GLIBC__) | |
1783 | 1670 | /* The alpha headers are decidedly broken. |
1784 | 1671 | * Using an ANSI compiler, it provides ip_vhl instead of ip_hl and |
1785 | 1672 | * ip_v. So, to get ip_hl, we mask off the bottom four bits. |
1786 | 1673 | */ |
1787 | hlen = ( ip->ip_vhl & 0x0F ) << 2; | |
1674 | hlen = (ip->ip_vhl & 0x0F) << 2; | |
1788 | 1675 | #else |
1789 | 1676 | hlen = ip->ip_hl << 2; |
1677 | #endif /* defined(__alpha__) && __STDC__ */ | |
1678 | if (result < hlen + ICMP_MINLEN) | |
1679 | #else | |
1680 | if (result < sizeof(FPING_ICMPHDR)) | |
1790 | 1681 | #endif |
1791 | ||
1792 | if( reply_buf_len < hlen + ICMP_MINLEN ) { | |
1793 | /* too short */ | |
1794 | if( verbose_flag ) | |
1795 | { | |
1682 | { | |
1683 | if (verbose_flag) { | |
1796 | 1684 | char buf[INET6_ADDRSTRLEN]; |
1797 | getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1798 | printf( "received packet too short for ICMP (%d bytes from %s)\n", (int) reply_buf_len, buf); | |
1799 | } | |
1800 | return 0; | |
1801 | } | |
1802 | ||
1803 | icp = (struct icmp *)(reply_buf + hlen); | |
1804 | ||
1805 | if( icp->icmp_type != ICMP_ECHOREPLY ) | |
1685 | getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1686 | printf("received packet too short for ICMP (%d bytes from %s)\n", result, buf); | |
1687 | } | |
1688 | return (1); /* too short */ | |
1689 | } | |
1690 | ||
1691 | gettimeofday(¤t_time, &tz); | |
1692 | ||
1693 | icp = (FPING_ICMPHDR*)(buffer + hlen); | |
1694 | #ifndef IPV6 | |
1695 | if (icp->icmp_type != ICMP_ECHOREPLY) | |
1696 | #else | |
1697 | if (icp->icmp6_type != ICMP6_ECHO_REPLY) | |
1698 | #endif | |
1806 | 1699 | { |
1807 | /* Handle other ICMP packets */ | |
1808 | struct icmp *sent_icmp; | |
1809 | SEQMAP_VALUE *seqmap_value; | |
1810 | char addr_ascii[INET6_ADDRSTRLEN]; | |
1811 | HOST_ENTRY *h; | |
1812 | ||
1813 | /* reply icmp packet (hlen + ICMP_MINLEN) followed by "sent packet" (ip + icmp headers) */ | |
1814 | if(reply_buf_len < hlen + ICMP_MINLEN + sizeof(struct ip) + ICMP_MINLEN) { | |
1815 | /* discard ICMP message if we can't tell that it was caused by us (i.e. if the "sent packet" is not included). */ | |
1816 | return 0; | |
1817 | } | |
1818 | ||
1819 | sent_icmp = (struct icmp *) (reply_buf + hlen + ICMP_MINLEN + sizeof(struct ip)); | |
1820 | ||
1821 | if(sent_icmp->icmp_type != ICMP_ECHO || ntohs(sent_icmp->icmp_id) != ident) { | |
1822 | /* not caused by us */ | |
1823 | return 0; | |
1824 | } | |
1825 | ||
1826 | seqmap_value = seqmap_fetch(ntohs(sent_icmp->icmp_seq), ¤t_time); | |
1827 | if(seqmap_value == NULL) { | |
1828 | return 0; | |
1829 | } | |
1830 | ||
1831 | getnameinfo(response_addr, response_addr_len, addr_ascii, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1832 | ||
1833 | switch(icp->icmp_type) { | |
1834 | case ICMP_UNREACH: | |
1835 | h = table[seqmap_value->host_nr]; | |
1836 | if( icp->icmp_code > ICMP_UNREACH_MAXTYPE ) { | |
1837 | print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", | |
1838 | addr_ascii, h->host ); | |
1839 | } | |
1840 | else { | |
1841 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1842 | icmp_unreach_str[icp->icmp_code], addr_ascii, h->host); | |
1843 | } | |
1844 | ||
1845 | print_warning("\n" ); | |
1846 | num_othericmprcvd++; | |
1847 | break; | |
1848 | ||
1849 | case ICMP_SOURCEQUENCH: | |
1850 | case ICMP_REDIRECT: | |
1851 | case ICMP_TIMXCEED: | |
1852 | case ICMP_PARAMPROB: | |
1853 | h = table[seqmap_value->host_nr]; | |
1854 | if(icp->icmp_type <= ICMP_TYPE_STR_MAX) { | |
1855 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1856 | icmp_type_str[icp->icmp_type], addr_ascii, h->host ); | |
1857 | } | |
1858 | else { | |
1859 | print_warning("ICMP %d from %s for ICMP Echo sent to %s", | |
1860 | icp->icmp_type, addr_ascii, h->host ); | |
1861 | } | |
1862 | print_warning( "\n" ); | |
1863 | num_othericmprcvd++; | |
1864 | break; | |
1865 | } | |
1866 | ||
1867 | return 0; | |
1868 | } | |
1869 | ||
1870 | *id = ntohs(icp->icmp_id); | |
1871 | *seq = ntohs(icp->icmp_seq); | |
1872 | ||
1873 | return 1; | |
1874 | } | |
1875 | ||
1876 | #ifdef IPV6 | |
1877 | int decode_icmp_ipv6( | |
1878 | struct sockaddr *response_addr, | |
1879 | size_t response_addr_len, | |
1880 | char *reply_buf, | |
1881 | size_t reply_buf_len, | |
1882 | unsigned short *id, | |
1883 | unsigned short *seq | |
1884 | ) | |
1885 | { | |
1886 | struct icmp6_hdr *icp; | |
1887 | ||
1888 | if( reply_buf_len < sizeof(struct icmp6_hdr) ) | |
1889 | { | |
1890 | if( verbose_flag ) | |
1891 | { | |
1892 | char buf[INET6_ADDRSTRLEN]; | |
1893 | getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1894 | printf( "received packet too short for ICMP (%d bytes from %s)\n", (int) reply_buf_len, buf); | |
1895 | } | |
1896 | return 0; /* too short */ | |
1897 | } | |
1898 | ||
1899 | icp = (struct icmp6_hdr *) reply_buf; | |
1900 | ||
1901 | if( icp->icmp6_type != ICMP6_ECHO_REPLY ) | |
1902 | { | |
1903 | /* Handle other ICMP packets */ | |
1904 | struct icmp6_hdr *sent_icmp; | |
1905 | SEQMAP_VALUE *seqmap_value; | |
1906 | char addr_ascii[INET6_ADDRSTRLEN]; | |
1907 | HOST_ENTRY *h; | |
1908 | ||
1909 | /* reply icmp packet (ICMP_MINLEN) followed by "sent packet" (ip + icmp headers) */ | |
1910 | if(reply_buf_len < ICMP_MINLEN + sizeof(struct ip) + ICMP_MINLEN) { | |
1911 | /* discard ICMP message if we can't tell that it was caused by us (i.e. if the "sent packet" is not included). */ | |
1912 | return 0; | |
1913 | } | |
1914 | ||
1915 | sent_icmp = (struct icmp6_hdr *) (reply_buf + sizeof(struct icmp6_hdr) + sizeof(struct ip)); | |
1916 | ||
1917 | if(sent_icmp->icmp6_type != ICMP_ECHO || ntohs(sent_icmp->icmp6_id) != ident) { | |
1918 | /* not caused by us */ | |
1919 | return 0; | |
1920 | } | |
1921 | ||
1922 | seqmap_value = seqmap_fetch(ntohs(sent_icmp->icmp6_seq), ¤t_time); | |
1923 | if(seqmap_value == NULL) { | |
1924 | return 0; | |
1925 | } | |
1926 | ||
1927 | getnameinfo(response_addr, response_addr_len, addr_ascii, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1928 | ||
1929 | switch(icp->icmp6_type) { | |
1930 | case ICMP_UNREACH: | |
1931 | h = table[seqmap_value->host_nr]; | |
1932 | if( icp->icmp6_code > ICMP_UNREACH_MAXTYPE ) { | |
1933 | print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", | |
1934 | addr_ascii, h->host ); | |
1935 | } | |
1936 | else { | |
1937 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1938 | icmp_unreach_str[icp->icmp6_code], addr_ascii, h->host); | |
1939 | } | |
1940 | ||
1941 | print_warning("\n" ); | |
1942 | num_othericmprcvd++; | |
1943 | break; | |
1944 | ||
1945 | case ICMP_SOURCEQUENCH: | |
1946 | case ICMP_REDIRECT: | |
1947 | case ICMP_TIMXCEED: | |
1948 | case ICMP_PARAMPROB: | |
1949 | h = table[seqmap_value->host_nr]; | |
1950 | if(icp->icmp6_type <= ICMP_TYPE_STR_MAX) { | |
1951 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1952 | icmp_type_str[icp->icmp6_type], addr_ascii, h->host ); | |
1953 | } | |
1954 | else { | |
1955 | print_warning("ICMP %d from %s for ICMP Echo sent to %s", | |
1956 | icp->icmp6_type, addr_ascii, h->host ); | |
1957 | } | |
1958 | print_warning( "\n" ); | |
1959 | num_othericmprcvd++; | |
1960 | break; | |
1961 | } | |
1962 | ||
1963 | return 0; | |
1964 | } | |
1965 | ||
1966 | *id = ntohs(icp->icmp6_id); | |
1967 | *seq = ntohs(icp->icmp6_seq); | |
1968 | ||
1969 | return 1; | |
1970 | } | |
1700 | /* handle some problem */ | |
1701 | if (handle_random_icmp(icp, (struct sockaddr*)&response_addr, sizeof(response_addr))) | |
1702 | num_othericmprcvd++; | |
1703 | return 1; | |
1704 | } | |
1705 | ||
1706 | #ifndef IPV6 | |
1707 | if (ntohs(icp->icmp_id) != ident) | |
1708 | #else | |
1709 | if (ntohs(icp->icmp6_id) != ident) | |
1971 | 1710 | #endif |
1972 | ||
1973 | ||
1974 | int wait_for_reply(long wait_time) | |
1975 | { | |
1976 | int result; | |
1977 | static char buffer[4096]; | |
1978 | struct sockaddr_storage response_addr; | |
1979 | int n, avg; | |
1980 | HOST_ENTRY *h; | |
1981 | long this_reply; | |
1982 | int this_count; | |
1983 | struct timeval *sent_time; | |
1984 | struct timeval recv_time; | |
1985 | SEQMAP_VALUE *seqmap_value; | |
1986 | unsigned short id; | |
1987 | unsigned short seq; | |
1988 | struct timeval to; | |
1989 | int s = 0; | |
1990 | ||
1991 | /* Wait for a socket to become ready */ | |
1992 | if(wait_time) { | |
1993 | if(wait_time < 100000) { | |
1994 | to.tv_sec = 0; | |
1995 | to.tv_usec = wait_time * 10; | |
1996 | } | |
1997 | else { | |
1998 | to.tv_sec = wait_time / 100000 ; | |
1999 | to.tv_usec = (wait_time % 100000) * 10 ; | |
2000 | } | |
2001 | } | |
2002 | else { | |
2003 | to.tv_sec = 0; | |
2004 | to.tv_usec = 0; | |
2005 | } | |
2006 | s = socket_can_read(&to); | |
2007 | if(s == 0) { | |
2008 | return 0; /* timeout */ | |
2009 | } | |
2010 | ||
2011 | /* Receive packet */ | |
2012 | result = receive_packet(s, /* socket */ | |
2013 | &recv_time, /* reply_timestamp */ | |
2014 | (struct sockaddr *) &response_addr, /* reply_src_addr */ | |
2015 | sizeof(response_addr), /* reply_src_addr_len */ | |
2016 | buffer, /* reply_buf */ | |
2017 | sizeof(buffer) /* reply_buf_len */ | |
2018 | ); | |
2019 | ||
2020 | if(result <= 0) { | |
2021 | return 0; | |
2022 | } | |
2023 | ||
2024 | gettimeofday( ¤t_time, &tz ); | |
2025 | ||
2026 | /* Process ICMP packet and retrieve id/seq */ | |
2027 | if(response_addr.ss_family == AF_INET) { | |
2028 | if(!decode_icmp_ipv4( | |
2029 | (struct sockaddr *) &response_addr, | |
2030 | sizeof(response_addr), | |
2031 | buffer, | |
2032 | sizeof(buffer), | |
2033 | &id, | |
2034 | &seq) | |
2035 | ) { | |
2036 | return 1; | |
2037 | } | |
2038 | } | |
2039 | #ifdef IPV6 | |
2040 | else if(response_addr.ss_family == AF_INET6) { | |
2041 | if(!decode_icmp_ipv6( | |
2042 | (struct sockaddr *) &response_addr, | |
2043 | sizeof(response_addr), | |
2044 | buffer, | |
2045 | sizeof(buffer), | |
2046 | &id, | |
2047 | &seq) | |
2048 | ) { | |
2049 | return 1; | |
2050 | } | |
2051 | } | |
1711 | return 1; /* packet received, but not the one we are looking for! */ | |
1712 | ||
1713 | #ifndef IPV6 | |
1714 | seqmap_value = seqmap_fetch(ntohs(icp->icmp_seq), ¤t_time); | |
1715 | #else | |
1716 | seqmap_value = seqmap_fetch(ntohs(icp->icmp6_seq), ¤t_time); | |
2052 | 1717 | #endif |
2053 | else { | |
2054 | return 1; | |
2055 | } | |
2056 | ||
2057 | if( id != ident ) { | |
2058 | return 1; /* packet received, but not the one we are looking for! */ | |
2059 | } | |
2060 | ||
2061 | seqmap_value = seqmap_fetch(seq, ¤t_time); | |
2062 | if(seqmap_value == NULL) { | |
1718 | if (seqmap_value == NULL) { | |
2063 | 1719 | return 1; |
2064 | 1720 | } |
2065 | 1721 | |
2067 | 1723 | |
2068 | 1724 | n = seqmap_value->host_nr; |
2069 | 1725 | h = table[n]; |
2070 | sent_time = &seqmap_value->ping_ts; | |
1726 | sent_time = &seqmap_value->ping_ts; | |
2071 | 1727 | this_count = seqmap_value->ping_count; |
2072 | this_reply = timeval_diff( &recv_time, sent_time ); | |
2073 | ||
2074 | if( loop_flag || h->resp_times[this_count] == RESP_WAITING ) | |
2075 | { | |
1728 | this_reply = timeval_diff(&recv_time, sent_time); | |
1729 | ||
1730 | if (loop_flag || h->resp_times[this_count] == RESP_WAITING) { | |
2076 | 1731 | /* only for non-duplicates: */ |
2077 | 1732 | h->waiting = 0; |
2078 | 1733 | h->timeout = timeout; |
2079 | 1734 | h->num_recv++; |
2080 | 1735 | |
2081 | if(h->discard_next_recv_i) { | |
2082 | h->discard_next_recv_i=0; | |
2083 | } | |
2084 | else { | |
1736 | if (h->discard_next_recv_i) { | |
1737 | h->discard_next_recv_i = 0; | |
1738 | } else { | |
2085 | 1739 | h->num_recv_i++; |
2086 | if( !h->max_reply_i || this_reply > h->max_reply_i ) h->max_reply_i = this_reply; | |
2087 | if( !h->min_reply_i || this_reply < h->min_reply_i ) h->min_reply_i = this_reply; | |
1740 | if (!h->max_reply_i || this_reply > h->max_reply_i) | |
1741 | h->max_reply_i = this_reply; | |
1742 | if (!h->min_reply_i || this_reply < h->min_reply_i) | |
1743 | h->min_reply_i = this_reply; | |
2088 | 1744 | h->total_time_i += this_reply; |
2089 | 1745 | } |
2090 | 1746 | |
2091 | if( !max_reply || this_reply > max_reply ) max_reply = this_reply; | |
2092 | if( !min_reply || this_reply < min_reply ) min_reply = this_reply; | |
2093 | if( !h->max_reply || this_reply > h->max_reply ) h->max_reply = this_reply; | |
2094 | if( !h->min_reply || this_reply < h->min_reply ) h->min_reply = this_reply; | |
1747 | if (!max_reply || this_reply > max_reply) | |
1748 | max_reply = this_reply; | |
1749 | if (!min_reply || this_reply < min_reply) | |
1750 | min_reply = this_reply; | |
1751 | if (!h->max_reply || this_reply > h->max_reply) | |
1752 | h->max_reply = this_reply; | |
1753 | if (!h->min_reply || this_reply < h->min_reply) | |
1754 | h->min_reply = this_reply; | |
2095 | 1755 | sum_replies += this_reply; |
2096 | 1756 | h->total_time += this_reply; |
2097 | 1757 | total_replies++; |
2100 | 1760 | /* received ping is cool, so process it */ |
2101 | 1761 | h->num_recv_total++; |
2102 | 1762 | |
2103 | #if defined( DEBUG ) || defined( _DEBUG ) | |
2104 | if( trace_flag ) | |
2105 | printf( "received [%d] from %s\n", this_count, h->host ); | |
1763 | #if defined(DEBUG) || defined(_DEBUG) | |
1764 | if (trace_flag) | |
1765 | printf("received [%d] from %s\n", this_count, h->host); | |
2106 | 1766 | #endif /* DEBUG || _DEBUG */ |
2107 | 1767 | |
2108 | 1768 | /* note reply time in array, probably */ |
2109 | if( !loop_flag ) | |
2110 | { | |
2111 | if( ( this_count >= 0 ) && ( this_count < trials ) ) | |
2112 | { | |
2113 | if( h->resp_times[this_count] >= 0 ) | |
2114 | { | |
2115 | if( !per_recv_flag ) | |
2116 | { | |
2117 | fprintf( stderr, "%s : duplicate for [%d], %d bytes, %s ms", | |
2118 | h->host, this_count, result, sprint_tm( this_reply ) ); | |
2119 | ||
2120 | if(addr_cmp((struct sockaddr *)&response_addr, (struct sockaddr *)&h->saddr)) { | |
1769 | if (!loop_flag) { | |
1770 | if ((this_count >= 0) && (this_count < trials)) { | |
1771 | if (h->resp_times[this_count] >= 0) { | |
1772 | if (!per_recv_flag) { | |
1773 | fprintf(stderr, "%s : duplicate for [%d], %d bytes, %s ms", | |
1774 | h->host, this_count, result, sprint_tm(this_reply)); | |
1775 | ||
1776 | if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) { | |
2121 | 1777 | char buf[INET6_ADDRSTRLEN]; |
2122 | getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
2123 | fprintf( stderr, " [<- %s]", buf); | |
1778 | getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1779 | fprintf(stderr, " [<- %s]", buf); | |
2124 | 1780 | } |
2125 | fprintf( stderr, "\n" ); | |
2126 | ||
2127 | }/* IF */ | |
2128 | }/* IF */ | |
1781 | fprintf(stderr, "\n"); | |
1782 | ||
1783 | } | |
1784 | } | |
2129 | 1785 | else |
2130 | 1786 | h->resp_times[this_count] = this_reply; |
2131 | 1787 | |
2132 | }/* IF */ | |
2133 | else | |
2134 | { | |
1788 | } | |
1789 | else { | |
2135 | 1790 | /* count is out of bounds?? */ |
2136 | fprintf( stderr, "%s : duplicate for [%d], %d bytes, %s ms\n", | |
2137 | h->host, this_count, result, sprint_tm( this_reply ) ); | |
2138 | ||
2139 | }/* ELSE */ | |
2140 | }/* IF */ | |
2141 | ||
2142 | if( h->num_recv == 1 ) | |
2143 | { | |
1791 | fprintf(stderr, "%s : duplicate for [%d], %d bytes, %s ms\n", | |
1792 | h->host, this_count, result, sprint_tm(this_reply)); | |
1793 | ||
1794 | } | |
1795 | } | |
1796 | ||
1797 | if (h->num_recv == 1) { | |
2144 | 1798 | num_alive++; |
2145 | if( verbose_flag || alive_flag ) | |
2146 | { | |
2147 | printf( "%s", h->host ); | |
2148 | ||
2149 | if( verbose_flag ) | |
2150 | printf( " is alive" ); | |
2151 | ||
2152 | if( elapsed_flag ) | |
2153 | printf( " (%s ms)", sprint_tm( this_reply ) ); | |
2154 | ||
2155 | if(addr_cmp((struct sockaddr *)&response_addr, (struct sockaddr *)&h->saddr)) { | |
1799 | if (verbose_flag || alive_flag) { | |
1800 | printf("%s", h->host); | |
1801 | ||
1802 | if (verbose_flag) | |
1803 | printf(" is alive"); | |
1804 | ||
1805 | if (elapsed_flag) | |
1806 | printf(" (%s ms)", sprint_tm(this_reply)); | |
1807 | ||
1808 | if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) { | |
2156 | 1809 | char buf[INET6_ADDRSTRLEN]; |
2157 | getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
2158 | fprintf( stderr, " [<- %s]", buf); | |
2159 | } | |
2160 | ||
2161 | printf( "\n" ); | |
2162 | ||
2163 | }/* IF */ | |
2164 | }/* IF */ | |
2165 | ||
2166 | if( per_recv_flag ) | |
2167 | { | |
2168 | if(timestamp_flag) { | |
1810 | getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1811 | fprintf(stderr, " [<- %s]", buf); | |
1812 | } | |
1813 | ||
1814 | printf("\n"); | |
1815 | } | |
1816 | } | |
1817 | ||
1818 | if (per_recv_flag) { | |
1819 | if (timestamp_flag) { | |
2169 | 1820 | printf("[%lu.%06lu] ", |
2170 | (unsigned long)recv_time.tv_sec, | |
2171 | (unsigned long)recv_time.tv_usec); | |
1821 | (unsigned long)recv_time.tv_sec, | |
1822 | (unsigned long)recv_time.tv_usec); | |
2172 | 1823 | } |
2173 | 1824 | avg = h->total_time / h->num_recv; |
2174 | printf( "%s%s : [%d], %d bytes, %s ms", | |
2175 | h->host, h->pad, this_count, result, sprint_tm( this_reply ) ); | |
2176 | printf( " (%s avg, ", sprint_tm( avg ) ); | |
2177 | ||
2178 | if( h->num_recv <= h->num_sent ) { | |
2179 | printf( "%d%% loss)", | |
2180 | ( ( h->num_sent - h->num_recv ) * 100 ) / h->num_sent ); | |
2181 | ||
2182 | } | |
2183 | else { | |
2184 | printf( "%d%% return)", | |
2185 | ( h->num_recv_total * 100 ) / h->num_sent ); | |
2186 | ||
2187 | } | |
2188 | ||
2189 | if(addr_cmp((struct sockaddr *)&response_addr, (struct sockaddr *)&h->saddr)) { | |
1825 | printf("%s%s : [%d], %d bytes, %s ms", | |
1826 | h->host, h->pad, this_count, result, sprint_tm(this_reply)); | |
1827 | printf(" (%s avg, ", sprint_tm(avg)); | |
1828 | ||
1829 | if (h->num_recv <= h->num_sent) { | |
1830 | printf("%d%% loss)", | |
1831 | ((h->num_sent - h->num_recv) * 100) / h->num_sent); | |
1832 | ||
1833 | } else { | |
1834 | printf("%d%% return)", | |
1835 | (h->num_recv_total * 100) / h->num_sent); | |
1836 | } | |
1837 | ||
1838 | if (addr_cmp((struct sockaddr*)&response_addr, (struct sockaddr*)&h->saddr)) { | |
2190 | 1839 | char buf[INET6_ADDRSTRLEN]; |
2191 | getnameinfo((struct sockaddr *)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
2192 | fprintf( stderr, " [<- %s]", buf); | |
2193 | } | |
2194 | ||
2195 | printf( "\n" ); | |
2196 | ||
2197 | }/* IF */ | |
1840 | getnameinfo((struct sockaddr*)&response_addr, sizeof(response_addr), buf, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1841 | fprintf(stderr, " [<- %s]", buf); | |
1842 | } | |
1843 | ||
1844 | printf("\n"); | |
1845 | ||
1846 | } | |
2198 | 1847 | |
2199 | 1848 | /* remove this job, if we are done */ |
2200 | if((count_flag && h->num_recv >= count) || | |
2201 | (!loop_flag && !count_flag && h->num_recv)) | |
2202 | { | |
1849 | if ((count_flag && h->num_recv >= count) || (!loop_flag && !count_flag && h->num_recv)) { | |
2203 | 1850 | remove_job(h); |
2204 | 1851 | } |
2205 | 1852 | |
2206 | fflush( stdout ); | |
1853 | fflush(stdout); | |
2207 | 1854 | return num_jobs; |
2208 | ||
2209 | } /* wait_for_reply() */ | |
1855 | } | |
1856 | ||
1857 | /************************************************************ | |
1858 | ||
1859 | Function: handle_random_icmp | |
1860 | ||
1861 | ************************************************************/ | |
1862 | ||
1863 | int handle_random_icmp(FPING_ICMPHDR* p, struct sockaddr* addr, socklen_t addr_len) | |
1864 | { | |
1865 | FPING_ICMPHDR* sent_icmp; | |
1866 | unsigned char* c; | |
1867 | HOST_ENTRY* h; | |
1868 | SEQMAP_VALUE* seqmap_value; | |
1869 | char addr_ascii[INET6_ADDRSTRLEN]; | |
1870 | unsigned short icmp_type; | |
1871 | unsigned short icmp_code; | |
1872 | unsigned short sent_icmp_type; | |
1873 | unsigned short sent_icmp_seq; | |
1874 | unsigned short sent_icmp_id; | |
1875 | ||
1876 | getnameinfo((struct sockaddr*)addr, addr_len, addr_ascii, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST); | |
1877 | ||
1878 | c = (unsigned char*)p; | |
1879 | ||
1880 | sent_icmp = (FPING_ICMPHDR*)(c + 28); | |
1881 | #ifndef IPV6 | |
1882 | icmp_type = p->icmp_type; | |
1883 | icmp_code = p->icmp_code; | |
1884 | sent_icmp_type = sent_icmp->icmp_type; | |
1885 | sent_icmp_seq = sent_icmp->icmp_seq; | |
1886 | sent_icmp_id = sent_icmp->icmp_id; | |
1887 | #else | |
1888 | icmp_type = p->icmp6_type; | |
1889 | icmp_code = p->icmp6_code; | |
1890 | sent_icmp_type = sent_icmp->icmp6_type; | |
1891 | sent_icmp_seq = sent_icmp->icmp6_seq; | |
1892 | sent_icmp_id = sent_icmp->icmp6_id; | |
1893 | #endif | |
1894 | ||
1895 | switch (icmp_type) { | |
1896 | case ICMP_UNREACH: | |
1897 | seqmap_value = seqmap_fetch(ntohs(sent_icmp_seq), ¤t_time); | |
1898 | ||
1899 | if ((sent_icmp_type == ICMP_ECHO) && (ntohs(sent_icmp_id) == ident) && (seqmap_value != NULL)) { | |
1900 | /* this is a response to a ping we sent */ | |
1901 | h = table[ntohs(sent_icmp_seq) % num_hosts]; | |
1902 | ||
1903 | if (icmp_code > ICMP_UNREACH_MAXTYPE) { | |
1904 | print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", | |
1905 | addr_ascii, h->host); | |
1906 | } else { | |
1907 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1908 | icmp_unreach_str[icmp_code], addr_ascii, h->host); | |
1909 | } | |
1910 | ||
1911 | if (inet_addr(h->host) == INADDR_NONE) | |
1912 | print_warning(" (%s)", addr_ascii); | |
1913 | ||
1914 | print_warning("\n"); | |
1915 | } | |
1916 | return 1; | |
1917 | ||
1918 | case ICMP_SOURCEQUENCH: | |
1919 | case ICMP_REDIRECT: | |
1920 | case ICMP_TIMXCEED: | |
1921 | case ICMP_PARAMPROB: | |
1922 | seqmap_value = seqmap_fetch(ntohs(sent_icmp_seq), ¤t_time); | |
1923 | ||
1924 | if ((sent_icmp_type == ICMP_ECHO) && (ntohs(sent_icmp_id) == ident) && (seqmap_value != NULL)) { | |
1925 | /* this is a response to a ping we sent */ | |
1926 | h = table[ntohs(sent_icmp_seq) % num_hosts]; | |
1927 | if (icmp_type <= ICMP_TYPE_STR_MAX) { | |
1928 | print_warning("%s from %s for ICMP Echo sent to %s", | |
1929 | icmp_type_str[icmp_type], addr_ascii, h->host); | |
1930 | } else { | |
1931 | print_warning("ICMP %d from %s for ICMP Echo sent to %s", | |
1932 | icmp_type, addr_ascii, h->host); | |
1933 | } | |
1934 | ||
1935 | if (inet_addr(h->host) == INADDR_NONE) | |
1936 | print_warning(" (%s)", addr_ascii); | |
1937 | ||
1938 | print_warning("\n"); | |
1939 | ||
1940 | } | |
1941 | ||
1942 | return 2; | |
1943 | ||
1944 | /* no way to tell whether any of these are sent due to our ping */ | |
1945 | /* or not (shouldn't be, of course), so just discard */ | |
1946 | case ICMP_TSTAMP: | |
1947 | case ICMP_TSTAMPREPLY: | |
1948 | case ICMP_IREQ: | |
1949 | case ICMP_IREQREPLY: | |
1950 | case ICMP_MASKREQ: | |
1951 | case ICMP_MASKREPLY: | |
1952 | default: | |
1953 | return 0; | |
1954 | ||
1955 | } | |
1956 | } | |
2210 | 1957 | |
2211 | 1958 | /************************************************************ |
2212 | 1959 | |
2224 | 1971 | |
2225 | 1972 | ************************************************************/ |
2226 | 1973 | |
2227 | void add_name( char *name ) | |
2228 | { | |
2229 | struct addrinfo *res0, *res, hints; | |
2230 | int ret_ga; | |
2231 | char *printname; | |
2232 | char namebuf[256]; | |
2233 | char addrbuf[256]; | |
1974 | void add_name(char* name) | |
1975 | { | |
1976 | struct addrinfo *res0, *res, hints; | |
1977 | int ret_ga; | |
1978 | char* printname; | |
1979 | char namebuf[256]; | |
1980 | char addrbuf[256]; | |
2234 | 1981 | |
2235 | 1982 | /* getaddrinfo */ |
2236 | 1983 | bzero(&hints, sizeof(struct addrinfo)); |
2237 | 1984 | hints.ai_flags = 0; |
2238 | 1985 | hints.ai_socktype = SOCK_RAW; |
2239 | hints.ai_family = hints_ai_family; | |
2240 | if(hints_ai_family == AF_INET) { | |
2241 | hints.ai_protocol = IPPROTO_ICMP; | |
2242 | } | |
2243 | #ifdef IPV6 | |
2244 | else if(hints_ai_family == AF_INET6) { | |
2245 | hints.ai_protocol = IPPROTO_ICMPV6; | |
2246 | } | |
1986 | #ifndef IPV6 | |
1987 | hints.ai_family = AF_INET; | |
1988 | hints.ai_protocol = IPPROTO_ICMP; | |
1989 | #else | |
1990 | hints.ai_family = AF_INET6; | |
1991 | hints.ai_protocol = IPPROTO_ICMPV6; | |
2247 | 1992 | #endif |
2248 | else { | |
2249 | hints.ai_protocol = 0; | |
2250 | } | |
2251 | 1993 | ret_ga = getaddrinfo(name, NULL, &hints, &res0); |
2252 | 1994 | if (ret_ga) { |
2253 | if(!quiet_flag) | |
1995 | if (!quiet_flag) | |
2254 | 1996 | print_warning("%s: %s\n", name, gai_strerror(ret_ga)); |
2255 | 1997 | num_noaddress++; |
2256 | 1998 | return; |
2263 | 2005 | */ |
2264 | 2006 | for (res = res0; res; res = res->ai_next) { |
2265 | 2007 | /* name_flag: addr -> name lookup requested) */ |
2266 | if(!name_flag) { | |
2008 | if (!name_flag) { | |
2267 | 2009 | printname = name; |
2268 | } | |
2269 | else { | |
2010 | } else { | |
2270 | 2011 | int ret; |
2271 | 2012 | ret = getnameinfo(res->ai_addr, res->ai_addrlen, namebuf, |
2272 | sizeof(namebuf)/sizeof(char), NULL, 0, 0); | |
2013 | sizeof(namebuf) / sizeof(char), NULL, 0, 0); | |
2273 | 2014 | if (ret) { |
2274 | if(!quiet_flag) { | |
2275 | ret = getnameinfo(res->ai_addr, res->ai_addrlen, namebuf, | |
2276 | sizeof(namebuf)/sizeof(char), NULL, 0, 0); | |
2277 | print_warning("%s: can't reverse-lookup (%s)\n", name, gai_strerror(ret_ga)); | |
2015 | if (!quiet_flag) { | |
2016 | print_warning("%s: can't reverse-lookup (%s)\n", name, gai_strerror(ret)); | |
2278 | 2017 | } |
2279 | 2018 | printname = name; |
2280 | } | |
2281 | else { | |
2019 | } else { | |
2282 | 2020 | printname = namebuf; |
2283 | 2021 | } |
2284 | 2022 | } |
2285 | 2023 | |
2286 | 2024 | /* addr_flag: name -> addr lookup requested */ |
2287 | if(addr_flag) { | |
2025 | if (addr_flag) { | |
2288 | 2026 | int ret; |
2289 | 2027 | ret = getnameinfo(res->ai_addr, res->ai_addrlen, addrbuf, |
2290 | sizeof(addrbuf)/sizeof(char), NULL, 0, NI_NUMERICHOST); | |
2028 | sizeof(addrbuf) / sizeof(char), NULL, 0, NI_NUMERICHOST); | |
2291 | 2029 | if (ret) { |
2292 | if(!quiet_flag) { | |
2293 | print_warning("%s: can't forward-lookup address (%s)\n", name, gai_strerror(ret_ga)); | |
2030 | if (!quiet_flag) { | |
2031 | print_warning("%s: can't forward-lookup address (%s)\n", name, gai_strerror(ret)); | |
2294 | 2032 | } |
2295 | 2033 | continue; |
2296 | 2034 | } |
2297 | 2035 | |
2298 | if(name_flag) { | |
2036 | if (name_flag) { | |
2299 | 2037 | char nameaddrbuf[512]; |
2300 | snprintf(nameaddrbuf, sizeof(nameaddrbuf)/sizeof(char), "%s (%s)", printname, addrbuf); | |
2038 | snprintf(nameaddrbuf, sizeof(nameaddrbuf) / sizeof(char), "%s (%s)", printname, addrbuf); | |
2301 | 2039 | add_addr(name, nameaddrbuf, res->ai_addr, res->ai_addrlen); |
2302 | } | |
2303 | else { | |
2040 | } else { | |
2304 | 2041 | add_addr(name, addrbuf, res->ai_addr, res->ai_addrlen); |
2305 | 2042 | } |
2306 | } | |
2307 | else { | |
2043 | } else { | |
2308 | 2044 | add_addr(name, printname, res->ai_addr, res->ai_addrlen); |
2309 | 2045 | } |
2310 | 2046 | |
2311 | if(!multif_flag) { | |
2047 | if (!multif_flag) { | |
2312 | 2048 | break; |
2313 | 2049 | } |
2314 | 2050 | } |
2329 | 2065 | |
2330 | 2066 | ************************************************************/ |
2331 | 2067 | |
2332 | void add_addr( char *name, char *host, struct sockaddr *ipaddr, socklen_t ipaddr_len ) | |
2333 | { | |
2334 | HOST_ENTRY *p; | |
2068 | void add_addr(char* name, char* host, struct sockaddr* ipaddr, socklen_t ipaddr_len) | |
2069 | { | |
2070 | HOST_ENTRY* p; | |
2335 | 2071 | int n, *i; |
2336 | 2072 | |
2337 | p = ( HOST_ENTRY* )malloc( sizeof( HOST_ENTRY ) ); | |
2338 | if( !p ) | |
2339 | crash_and_burn( "can't allocate HOST_ENTRY" ); | |
2340 | ||
2341 | memset( ( char* ) p, 0, sizeof( HOST_ENTRY ) ); | |
2073 | p = (HOST_ENTRY*)malloc(sizeof(HOST_ENTRY)); | |
2074 | if (!p) | |
2075 | crash_and_burn("can't allocate HOST_ENTRY"); | |
2076 | ||
2077 | memset((char*)p, 0, sizeof(HOST_ENTRY)); | |
2342 | 2078 | |
2343 | 2079 | p->name = strdup(name); |
2344 | 2080 | p->host = strdup(host); |
2348 | 2084 | p->running = 1; |
2349 | 2085 | p->min_reply = 0; |
2350 | 2086 | |
2351 | if(netdata_flag) { | |
2352 | char *s = p->name; | |
2353 | while(*s) { | |
2354 | if(!isalnum(*s)) *s = '_'; | |
2087 | if (netdata_flag) { | |
2088 | char* s = p->name; | |
2089 | while (*s) { | |
2090 | if (!isalnum(*s)) | |
2091 | *s = '_'; | |
2355 | 2092 | s++; |
2356 | 2093 | } |
2357 | 2094 | } |
2358 | 2095 | |
2359 | if( strlen( p->host ) > max_hostname_len ) | |
2360 | max_hostname_len = strlen( p->host ); | |
2096 | if (strlen(p->host) > max_hostname_len) | |
2097 | max_hostname_len = strlen(p->host); | |
2361 | 2098 | |
2362 | 2099 | /* array for response time results */ |
2363 | if( !loop_flag ) | |
2364 | { | |
2365 | i = ( int* )malloc( trials * sizeof( int ) ); | |
2366 | if( !i ) | |
2367 | crash_and_burn( "can't allocate resp_times array" ); | |
2368 | ||
2369 | for( n = 1; n < trials; n++ ) | |
2100 | if (!loop_flag) { | |
2101 | i = (int*)malloc(trials * sizeof(int)); | |
2102 | if (!i) | |
2103 | crash_and_burn("can't allocate resp_times array"); | |
2104 | ||
2105 | for (n = 1; n < trials; n++) | |
2370 | 2106 | i[n] = RESP_UNUSED; |
2371 | 2107 | |
2372 | 2108 | p->resp_times = i; |
2373 | 2109 | |
2374 | }/* IF */ | |
2375 | ||
2376 | #if defined( DEBUG ) || defined( _DEBUG ) | |
2110 | } | |
2111 | ||
2112 | #if defined(DEBUG) || defined(_DEBUG) | |
2377 | 2113 | /* likewise for sent times */ |
2378 | if( sent_times_flag ) | |
2379 | { | |
2380 | i = ( int* )malloc( trials * sizeof( int ) ); | |
2381 | if( !i ) | |
2382 | crash_and_burn( "can't allocate sent_times array" ); | |
2383 | ||
2384 | for( n = 1; n < trials; n++ ) | |
2114 | if (sent_times_flag) { | |
2115 | i = (int*)malloc(trials * sizeof(int)); | |
2116 | if (!i) | |
2117 | crash_and_burn("can't allocate sent_times array"); | |
2118 | ||
2119 | for (n = 1; n < trials; n++) | |
2385 | 2120 | i[n] = RESP_UNUSED; |
2386 | 2121 | |
2387 | 2122 | p->sent_times = i; |
2388 | 2123 | |
2389 | }/* IF */ | |
2124 | } | |
2390 | 2125 | #endif /* DEBUG || _DEBUG */ |
2391 | 2126 | |
2392 | 2127 | /* schedule first ping */ |
2393 | 2128 | p->ev_type = EV_TYPE_PING; |
2394 | p->ev_time.tv_sec = 0; | |
2129 | p->ev_time.tv_sec = 0; | |
2395 | 2130 | p->ev_time.tv_usec = 0; |
2396 | 2131 | ev_enqueue(p); |
2397 | 2132 | |
2398 | 2133 | num_hosts++; |
2399 | ||
2400 | } /* add_addr() */ | |
2401 | ||
2134 | } | |
2402 | 2135 | |
2403 | 2136 | /************************************************************ |
2404 | 2137 | |
2412 | 2145 | |
2413 | 2146 | ************************************************************/ |
2414 | 2147 | |
2415 | void remove_job( HOST_ENTRY *h ) | |
2416 | { | |
2417 | #if defined( DEBUG ) || defined( _DEBUG ) | |
2418 | if( trace_flag ) | |
2419 | printf( "removing job for %s\n", h->host ); | |
2148 | void remove_job(HOST_ENTRY* h) | |
2149 | { | |
2150 | #if defined(DEBUG) || defined(_DEBUG) | |
2151 | if (trace_flag) | |
2152 | printf("removing job for %s\n", h->host); | |
2420 | 2153 | #endif /* DEBUG || _DEBUG */ |
2421 | 2154 | |
2422 | 2155 | h->running = 0; |
2424 | 2157 | --num_jobs; |
2425 | 2158 | |
2426 | 2159 | ev_remove(h); |
2427 | ||
2428 | } /* remove_job() */ | |
2160 | } | |
2429 | 2161 | |
2430 | 2162 | /************************************************************ |
2431 | 2163 | |
2439 | 2171 | |
2440 | 2172 | ************************************************************/ |
2441 | 2173 | |
2442 | void crash_and_burn( char *message ) | |
2443 | { | |
2444 | if( verbose_flag ) | |
2445 | fprintf( stderr, "%s: %s\n", prog, message ); | |
2446 | ||
2447 | exit( 4 ); | |
2448 | ||
2449 | } /* crash_and_burn() */ | |
2450 | ||
2174 | void crash_and_burn(char* message) | |
2175 | { | |
2176 | if (verbose_flag) | |
2177 | fprintf(stderr, "%s: %s\n", prog, message); | |
2178 | ||
2179 | exit(4); | |
2180 | } | |
2451 | 2181 | |
2452 | 2182 | /************************************************************ |
2453 | 2183 | |
2461 | 2191 | |
2462 | 2192 | ************************************************************/ |
2463 | 2193 | |
2464 | void errno_crash_and_burn( char *message ) | |
2465 | { | |
2466 | fprintf( stderr, "%s: %s : %s\n", prog, message, strerror( errno ) ); | |
2467 | exit( 4 ); | |
2468 | } /* errno_crash_and_burn() */ | |
2469 | ||
2194 | void errno_crash_and_burn(char* message) | |
2195 | { | |
2196 | fprintf(stderr, "%s: %s : %s\n", prog, message, strerror(errno)); | |
2197 | exit(4); | |
2198 | } | |
2470 | 2199 | |
2471 | 2200 | /************************************************************ |
2472 | 2201 | |
2476 | 2205 | |
2477 | 2206 | *************************************************************/ |
2478 | 2207 | |
2479 | void print_warning(char *format, ...) { | |
2208 | void print_warning(char* format, ...) | |
2209 | { | |
2480 | 2210 | va_list args; |
2481 | if(!quiet_flag) { | |
2482 | va_start(args, format ); | |
2211 | if (!quiet_flag) { | |
2212 | va_start(args, format); | |
2483 | 2213 | vfprintf(stderr, format, args); |
2484 | 2214 | va_end(args); |
2485 | 2215 | } |
2486 | 2216 | } |
2487 | 2217 | |
2488 | ||
2489 | ||
2490 | 2218 | /************************************************************ |
2491 | 2219 | |
2492 | 2220 | Function: timeval_diff |
2504 | 2232 | |
2505 | 2233 | ************************************************************/ |
2506 | 2234 | |
2507 | long timeval_diff( struct timeval *a, struct timeval *b ) | |
2235 | long timeval_diff(struct timeval* a, struct timeval* b) | |
2508 | 2236 | { |
2509 | 2237 | long sec_diff = a->tv_sec - b->tv_sec; |
2510 | if(sec_diff == 0) { | |
2238 | if (sec_diff == 0) { | |
2511 | 2239 | return (a->tv_usec - b->tv_usec) / 10; |
2512 | } | |
2513 | else if(sec_diff < 100) { | |
2240 | } else if (sec_diff < 100) { | |
2514 | 2241 | return (sec_diff * 1000000 + a->tv_usec - b->tv_usec) / 10; |
2515 | } | |
2516 | else { | |
2242 | } else { | |
2517 | 2243 | /* For such large differences, we don't really care about the microseconds... */ |
2518 | 2244 | return sec_diff * 100000; |
2519 | 2245 | } |
2520 | } /* timeval_diff() */ | |
2246 | } | |
2521 | 2247 | |
2522 | 2248 | /************************************************************ |
2523 | 2249 | |
2524 | 2250 | Function: timeval_add |
2525 | 2251 | |
2526 | 2252 | *************************************************************/ |
2527 | void timeval_add(struct timeval *a, long t_10u) | |
2253 | void timeval_add(struct timeval* a, long t_10u) | |
2528 | 2254 | { |
2529 | 2255 | t_10u *= 10; |
2530 | 2256 | a->tv_sec += (t_10u + a->tv_usec) / 1000000; |
2548 | 2274 | |
2549 | 2275 | ************************************************************/ |
2550 | 2276 | |
2551 | char * sprint_tm( int t ) | |
2277 | char* sprint_tm(int t) | |
2552 | 2278 | { |
2553 | 2279 | static char buf[10]; |
2554 | 2280 | |
2555 | if( t < 0 ) { | |
2281 | if (t < 0) { | |
2556 | 2282 | /* negative (unexpected) */ |
2557 | sprintf( buf, "%.2g", (double) t / 100 ); | |
2558 | } | |
2559 | else if( t < 100 ) { | |
2283 | sprintf(buf, "%.2g", (double)t / 100); | |
2284 | } else if (t < 100) { | |
2560 | 2285 | /* <= 0.99 ms */ |
2561 | sprintf( buf, "0.%02d", t ); | |
2562 | } | |
2563 | else if( t < 1000 ) { | |
2286 | sprintf(buf, "0.%02d", t); | |
2287 | } else if (t < 1000) { | |
2564 | 2288 | /* 1.00 - 9.99 ms */ |
2565 | sprintf( buf, "%d.%02d", t / 100, t % 100 ); | |
2566 | } | |
2567 | else if( t < 10000 ) { | |
2289 | sprintf(buf, "%d.%02d", t / 100, t % 100); | |
2290 | } else if (t < 10000) { | |
2568 | 2291 | /* 10.0 - 99.9 ms */ |
2569 | sprintf( buf, "%d.%d", t / 100, ( t % 100 ) / 10 ); | |
2570 | } | |
2571 | else if( t < 100000000 ) { | |
2292 | sprintf(buf, "%d.%d", t / 100, (t % 100) / 10); | |
2293 | } else if (t < 100000000) { | |
2572 | 2294 | /* 100 - 1'000'000 ms */ |
2573 | sprintf( buf, "%d", t / 100 ); | |
2574 | } | |
2575 | else { | |
2576 | sprintf( buf, "%.2e", (double) (t / 100) ); | |
2577 | } | |
2578 | ||
2579 | return( buf ); | |
2295 | sprintf(buf, "%d", t / 100); | |
2296 | } else { | |
2297 | sprintf(buf, "%.2e", (double)(t / 100)); | |
2298 | } | |
2299 | ||
2300 | return (buf); | |
2580 | 2301 | } |
2581 | 2302 | |
2582 | 2303 | /************************************************************ |
2304 | Function: recvfrom_wto | |
2305 | ************************************************************* | |
2306 | Description: | |
2307 | ||
2308 | receive with timeout | |
2309 | returns length of data read or -1 if timeout | |
2310 | crash_and_burn on any other errrors | |
2311 | ************************************************************/ | |
2312 | ||
2313 | int recvfrom_wto(int s, char* buf, int len, struct sockaddr* saddr, socklen_t* saddr_len, long timo) | |
2314 | { | |
2315 | int nfound, n; | |
2316 | struct timeval to; | |
2317 | fd_set readset, writeset; | |
2318 | ||
2319 | select_again: | |
2320 | if (timo < 100000) { | |
2321 | to.tv_sec = 0; | |
2322 | to.tv_usec = timo * 10; | |
2323 | } else { | |
2324 | to.tv_sec = timo / 100000; | |
2325 | to.tv_usec = (timo % 100000) * 10; | |
2326 | } | |
2327 | ||
2328 | FD_ZERO(&readset); | |
2329 | FD_ZERO(&writeset); | |
2330 | FD_SET(s, &readset); | |
2331 | ||
2332 | nfound = select(s + 1, &readset, &writeset, NULL, &to); | |
2333 | if (nfound < 0) { | |
2334 | if (errno == EINTR) { | |
2335 | /* interrupted system call: redo the select */ | |
2336 | goto select_again; | |
2337 | } else { | |
2338 | errno_crash_and_burn("select"); | |
2339 | } | |
2340 | } | |
2341 | ||
2342 | if (nfound == 0) | |
2343 | return -1; /* timeout */ | |
2344 | ||
2345 | /* recvfrom(int socket, void *restrict buffer, size_t length, int flags, struct sockaddr *restrict address, socklen_t *restrict address_len); */ | |
2346 | n = recvfrom(s, buf, len, 0, saddr, saddr_len); | |
2347 | if (n < 0) | |
2348 | errno_crash_and_burn("recvfrom"); | |
2349 | ||
2350 | return n; | |
2351 | } | |
2352 | ||
2353 | /************************************************************ | |
2583 | 2354 | |
2584 | 2355 | Function: addr_cmp |
2585 | 2356 | |
2586 | 2357 | *************************************************************/ |
2587 | int addr_cmp(struct sockaddr *a, struct sockaddr *b) | |
2588 | { | |
2589 | if(a->sa_family != b->sa_family) { | |
2358 | int addr_cmp(struct sockaddr* a, struct sockaddr* b) | |
2359 | { | |
2360 | if (a->sa_family != b->sa_family) { | |
2590 | 2361 | return a->sa_family - b->sa_family; |
2591 | } | |
2592 | else { | |
2593 | if(a->sa_family == AF_INET) { | |
2594 | return ((struct sockaddr_in *) a)->sin_addr.s_addr - ((struct sockaddr_in *) b)->sin_addr.s_addr; | |
2595 | } | |
2596 | else if(a->sa_family == AF_INET6) { | |
2597 | return memcmp(&((struct sockaddr_in6 *) a)->sin6_addr, | |
2598 | &((struct sockaddr_in6 *) b)->sin6_addr, | |
2599 | sizeof(((struct sockaddr_in6 *) a)->sin6_addr)); | |
2362 | } else { | |
2363 | if (a->sa_family == AF_INET) { | |
2364 | return ((struct sockaddr_in*)a)->sin_addr.s_addr - ((struct sockaddr_in*)b)->sin_addr.s_addr; | |
2365 | } else if (a->sa_family == AF_INET6) { | |
2366 | return memcmp(&((struct sockaddr_in6*)a)->sin6_addr, | |
2367 | &((struct sockaddr_in6*)b)->sin6_addr, | |
2368 | sizeof(((struct sockaddr_in6*)a)->sin6_addr)); | |
2600 | 2369 | } |
2601 | 2370 | } |
2602 | 2371 | |
2618 | 2387 | than the others. |
2619 | 2388 | |
2620 | 2389 | *************************************************************/ |
2621 | void ev_enqueue(HOST_ENTRY *h) | |
2622 | { | |
2623 | HOST_ENTRY *i; | |
2624 | HOST_ENTRY *i_prev; | |
2625 | ||
2626 | #if defined( DEBUG ) || defined( _DEBUG ) | |
2627 | if( trace_flag ) { | |
2390 | void ev_enqueue(HOST_ENTRY* h) | |
2391 | { | |
2392 | HOST_ENTRY* i; | |
2393 | HOST_ENTRY* i_prev; | |
2394 | ||
2395 | #if defined(DEBUG) || defined(_DEBUG) | |
2396 | if (trace_flag) { | |
2628 | 2397 | long st = timeval_diff(&h->ev_time, ¤t_time); |
2629 | fprintf(stderr, "Enqueue: host=%s, when=%d ms (%d, %d)\n", h->host, st/100, h->ev_time.tv_sec, h->ev_time.tv_usec); | |
2398 | fprintf(stderr, "Enqueue: host=%s, when=%d ms (%d, %d)\n", h->host, st / 100, h->ev_time.tv_sec, h->ev_time.tv_usec); | |
2630 | 2399 | } |
2631 | 2400 | #endif |
2632 | 2401 | |
2633 | 2402 | /* Empty list */ |
2634 | if(ev_last == NULL) { | |
2403 | if (ev_last == NULL) { | |
2635 | 2404 | h->ev_next = NULL; |
2636 | 2405 | h->ev_prev = NULL; |
2637 | 2406 | ev_first = h; |
2640 | 2409 | } |
2641 | 2410 | |
2642 | 2411 | /* Insert on tail? */ |
2643 | if(h->ev_time.tv_sec > ev_last->ev_time.tv_sec || | |
2644 | (h->ev_time.tv_sec == ev_last->ev_time.tv_sec && | |
2645 | h->ev_time.tv_usec >= ev_last->ev_time.tv_usec)) | |
2646 | { | |
2412 | if (h->ev_time.tv_sec > ev_last->ev_time.tv_sec || (h->ev_time.tv_sec == ev_last->ev_time.tv_sec && h->ev_time.tv_usec >= ev_last->ev_time.tv_usec)) { | |
2647 | 2413 | h->ev_next = NULL; |
2648 | 2414 | h->ev_prev = ev_last; |
2649 | 2415 | ev_last->ev_next = h; |
2653 | 2419 | |
2654 | 2420 | /* Find insertion point */ |
2655 | 2421 | i = ev_last; |
2656 | while(1) { | |
2422 | while (1) { | |
2657 | 2423 | i_prev = i->ev_prev; |
2658 | if(i_prev == NULL || | |
2659 | h->ev_time.tv_sec > i_prev->ev_time.tv_sec || | |
2660 | (h->ev_time.tv_sec == i_prev->ev_time.tv_sec && | |
2661 | h->ev_time.tv_usec >= i_prev->ev_time.tv_usec)) | |
2662 | { | |
2424 | if (i_prev == NULL || h->ev_time.tv_sec > i_prev->ev_time.tv_sec || (h->ev_time.tv_sec == i_prev->ev_time.tv_sec && h->ev_time.tv_usec >= i_prev->ev_time.tv_usec)) { | |
2663 | 2425 | h->ev_prev = i_prev; |
2664 | 2426 | h->ev_next = i; |
2665 | 2427 | i->ev_prev = h; |
2666 | if(i_prev != NULL) { | |
2428 | if (i_prev != NULL) { | |
2667 | 2429 | i_prev->ev_next = h; |
2668 | } | |
2669 | else { | |
2430 | } else { | |
2670 | 2431 | ev_first = h; |
2671 | 2432 | } |
2672 | 2433 | return; |
2680 | 2441 | Function: ev_dequeue |
2681 | 2442 | |
2682 | 2443 | *************************************************************/ |
2683 | HOST_ENTRY *ev_dequeue() | |
2684 | { | |
2685 | HOST_ENTRY *dequeued; | |
2686 | ||
2687 | if(ev_first == NULL) { | |
2444 | HOST_ENTRY* ev_dequeue() | |
2445 | { | |
2446 | HOST_ENTRY* dequeued; | |
2447 | ||
2448 | if (ev_first == NULL) { | |
2688 | 2449 | return NULL; |
2689 | 2450 | } |
2690 | 2451 | dequeued = ev_first; |
2698 | 2459 | Function: ev_remove |
2699 | 2460 | |
2700 | 2461 | *************************************************************/ |
2701 | void ev_remove(HOST_ENTRY *h) | |
2702 | { | |
2703 | if(ev_first == h) { | |
2462 | void ev_remove(HOST_ENTRY* h) | |
2463 | { | |
2464 | if (ev_first == h) { | |
2704 | 2465 | ev_first = h->ev_next; |
2705 | 2466 | } |
2706 | if(ev_last == h) { | |
2467 | if (ev_last == h) { | |
2707 | 2468 | ev_last = h->ev_prev; |
2708 | 2469 | } |
2709 | if(h->ev_prev) { | |
2470 | if (h->ev_prev) { | |
2710 | 2471 | h->ev_prev->ev_next = h->ev_next; |
2711 | 2472 | } |
2712 | if(h->ev_next) { | |
2473 | if (h->ev_next) { | |
2713 | 2474 | h->ev_next->ev_prev = h->ev_prev; |
2714 | 2475 | } |
2715 | 2476 | h->ev_prev = NULL; |
2716 | 2477 | h->ev_next = NULL; |
2717 | 2478 | } |
2718 | 2479 | |
2719 | ||
2720 | 2480 | /************************************************************ |
2721 | 2481 | |
2722 | 2482 | Function: usage |
2731 | 2491 | |
2732 | 2492 | void usage(int is_error) |
2733 | 2493 | { |
2734 | FILE *out = is_error ? stderr : stdout; | |
2735 | fprintf(out, "\n" ); | |
2736 | fprintf(out, "Usage: %s [options] [targets...]\n", prog ); | |
2737 | fprintf(out, " -4 only use IPv4 addresses\n" ); | |
2738 | fprintf(out, " -6 only use IPv6 addresses\n" ); | |
2739 | fprintf(out, " -a show targets that are alive\n" ); | |
2740 | fprintf(out, " -A show targets by address\n" ); | |
2494 | FILE* out = is_error ? stderr : stdout; | |
2495 | fprintf(out, "\n"); | |
2496 | fprintf(out, "Usage: %s [options] [targets...]\n", prog); | |
2497 | fprintf(out, " -a show targets that are alive\n"); | |
2498 | fprintf(out, " -A show targets by address\n"); | |
2741 | 2499 | fprintf(out, " -b n amount of ping data to send, in bytes (default %d)\n", DEFAULT_PING_DATA_SIZE); |
2742 | fprintf(out, " -B f set exponential backoff factor to f\n" ); | |
2743 | fprintf(out, " -c n count of pings to send to each target (default %d)\n", count ); | |
2744 | fprintf(out, " -C n same as -c, report results in verbose format\n" ); | |
2745 | fprintf(out, " -D print timestamp before each output line\n" ); | |
2746 | fprintf(out, " -e show elapsed time on return packets\n" ); | |
2747 | fprintf(out, " -f file read list of targets from a file ( - means stdin) (only if no -g specified)\n" ); | |
2748 | fprintf(out, " -g generate target list (only if no -f specified)\n" ); | |
2749 | fprintf(out, " (specify the start and end IP in the target list, or supply a IP netmask)\n" ); | |
2750 | fprintf(out, " (ex. %s -g 192.168.1.0 192.168.1.255 or %s -g 192.168.1.0/24)\n", prog, prog ); | |
2500 | fprintf(out, " -B f set exponential backoff factor to f\n"); | |
2501 | fprintf(out, " -c n count of pings to send to each target (default %d)\n", count); | |
2502 | fprintf(out, " -C n same as -c, report results in verbose format\n"); | |
2503 | fprintf(out, " -D print timestamp before each output line\n"); | |
2504 | fprintf(out, " -e show elapsed time on return packets\n"); | |
2505 | fprintf(out, " -f file read list of targets from a file ( - means stdin) (only if no -g specified)\n"); | |
2506 | fprintf(out, " -g generate target list (only if no -f specified)\n"); | |
2507 | fprintf(out, " (specify the start and end IP in the target list, or supply a IP netmask)\n"); | |
2508 | fprintf(out, " (ex. %s -g 192.168.1.0 192.168.1.255 or %s -g 192.168.1.0/24)\n", prog, prog); | |
2751 | 2509 | fprintf(out, " -H n Set the IP TTL value (Time To Live hops)\n"); |
2752 | fprintf(out, " -i n interval between sending ping packets (in millisec) (default %d)\n", interval / 100 ); | |
2510 | fprintf(out, " -i n interval between sending ping packets (in millisec) (default %d)\n", interval / 100); | |
2753 | 2511 | #ifdef SO_BINDTODEVICE |
2754 | fprintf(out, " -I if bind to a particular interface\n"); | |
2512 | fprintf(out, " -I if bind to a particular interface\n"); | |
2755 | 2513 | #endif |
2756 | fprintf(out, " -l loop sending pings forever\n" ); | |
2757 | fprintf(out, " -m use all IPs of provided hostnames (e.g. IPv4 and IPv6), use with -A\n" ); | |
2758 | fprintf(out, " -M set the Don't Fragment flag\n" ); | |
2759 | fprintf(out, " -n show targets by name (-d is equivalent)\n" ); | |
2760 | fprintf(out, " -N output compatible for netdata (-l -Q are required)\n" ); | |
2761 | fprintf(out, " -o show the accumulated outage time (lost packets * packet interval)\n" ); | |
2762 | fprintf(out, " -O n set the type of service (tos) flag on the ICMP packets\n" ); | |
2763 | fprintf(out, " -p n interval between ping packets to one target (in millisec)\n" ); | |
2764 | fprintf(out, " (in looping and counting modes, default %d)\n", perhost_interval / 100 ); | |
2765 | fprintf(out, " -q quiet (don't show per-target/per-ping results)\n" ); | |
2766 | fprintf(out, " -Q n same as -q, but show summary every n seconds\n" ); | |
2767 | fprintf(out, " -r n number of retries (default %d)\n", DEFAULT_RETRY ); | |
2768 | fprintf(out, " -R random packet data (to foil link data compression)\n" ); | |
2769 | fprintf(out, " -s print final stats\n" ); | |
2770 | fprintf(out, " -S addr set source address\n" ); | |
2771 | fprintf(out, " -t n individual target initial timeout (in millisec) (default %d)\n", timeout / 100 ); | |
2514 | fprintf(out, " -l loop sending pings forever\n"); | |
2515 | fprintf(out, " -m use all IPs of provided hostnames (e.g. IPv4 and IPv6), use with -A\n"); | |
2516 | fprintf(out, " -M set the Don't Fragment flag\n"); | |
2517 | fprintf(out, " -n show targets by name (-d is equivalent)\n"); | |
2518 | fprintf(out, " -N output compatible for netdata (-l -Q are required)\n"); | |
2519 | fprintf(out, " -o show the accumulated outage time (lost packets * packet interval)\n"); | |
2520 | fprintf(out, " -O n set the type of service (tos) flag on the ICMP packets\n"); | |
2521 | fprintf(out, " -p n interval between ping packets to one target (in millisec)\n"); | |
2522 | fprintf(out, " (in looping and counting modes, default %d)\n", perhost_interval / 100); | |
2523 | fprintf(out, " -q quiet (don't show per-target/per-ping results)\n"); | |
2524 | fprintf(out, " -Q n same as -q, but show summary every n seconds\n"); | |
2525 | fprintf(out, " -r n number of retries (default %d)\n", DEFAULT_RETRY); | |
2526 | fprintf(out, " -R random packet data (to foil link data compression)\n"); | |
2527 | fprintf(out, " -s print final stats\n"); | |
2528 | fprintf(out, " -S addr set source address\n"); | |
2529 | fprintf(out, " -t n individual target initial timeout (in millisec) (default %d)\n", timeout / 100); | |
2772 | 2530 | fprintf(out, " -T n ignored (for compatibility with fping 2.4)\n"); |
2773 | fprintf(out, " -u show targets that are unreachable\n" ); | |
2774 | fprintf(out, " -v show version\n" ); | |
2775 | fprintf(out, " targets list of targets to check (if no -f specified)\n" ); | |
2531 | fprintf(out, " -u show targets that are unreachable\n"); | |
2532 | fprintf(out, " -v show version\n"); | |
2533 | fprintf(out, " targets list of targets to check (if no -f specified)\n"); | |
2776 | 2534 | fprintf(out, "\n"); |
2777 | 2535 | exit(is_error); |
2778 | } /* usage() */ | |
2536 | } |
6 | 6 | #include <sys/types.h> |
7 | 7 | #include <netinet/in.h> |
8 | 8 | |
9 | #ifndef IPV6 | |
10 | #define FPING_INADDR struct in_addr | |
11 | #define FPING_ICMPHDR struct icmp | |
12 | #else | |
13 | #define FPING_INADDR struct in6_addr | |
14 | #define FPING_ICMPHDR struct icmp6_hdr | |
15 | #endif | |
16 | ||
9 | 17 | /* fping.c */ |
10 | 18 | void crash_and_burn( char *message ); |
11 | 19 | void errno_crash_and_burn( char *message ); |
13 | 21 | int random_data_flag; |
14 | 22 | |
15 | 23 | /* socket.c */ |
16 | int open_ping_socket_ipv4(); | |
17 | void init_ping_buffer_ipv4(size_t ping_data_size); | |
18 | void socket_set_src_addr_ipv4(int s, struct in_addr *src_addr); | |
19 | int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq, uint16_t icmp_id); | |
20 | #ifdef IPV6 | |
21 | int open_ping_socket_ipv6(); | |
22 | void init_ping_buffer_ipv6(size_t ping_data_size); | |
23 | void socket_set_src_addr_ipv6(int s, struct in6_addr *src_addr); | |
24 | int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq, uint16_t icmp_id); | |
25 | #endif | |
24 | int open_ping_socket(); | |
25 | void init_ping_buffer(size_t ping_data_size); | |
26 | void socket_set_src_addr(int s, FPING_INADDR src_addr); | |
27 | int socket_sendto_ping(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq, uint16_t icmp_id); | |
26 | 28 | |
27 | 29 | #endif |
0 | /* | |
0 | /* | |
1 | 1 | * fping: fast-ping, file-ping, favorite-ping, funky-ping |
2 | 2 | * |
3 | 3 | * Ping a list of target hosts in a round robin fashion. |
21 | 21 | * duplicated in all such forms and that any documentation, |
22 | 22 | * advertising materials, and other materials related to such |
23 | 23 | * distribution and use acknowledge that the software was developed |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
26 | 26 | * specific prior written permission. |
27 | 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
28 | 28 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
35 | 35 | */ |
36 | 36 | |
37 | 37 | #include "seqmap.h" |
38 | #include "limits.h" | |
38 | 39 | #include "options.h" |
39 | #include "limits.h" | |
40 | 40 | |
41 | #include <stdio.h> | |
41 | 42 | #include <stdlib.h> |
42 | #include <stdio.h> | |
43 | 43 | |
44 | 44 | /* description of the data structure used: |
45 | 45 | * |
50 | 50 | * - when entering a value, we check that the current entry is expired |
51 | 51 | */ |
52 | 52 | |
53 | static SEQMAP_VALUE *seqmap_map = NULL; | |
53 | static SEQMAP_VALUE* seqmap_map = NULL; | |
54 | 54 | static unsigned int seqmap_next_id = 0; |
55 | 55 | |
56 | #define SEQMAP_TIMEOUT_IN_S 10 | |
56 | #define SEQMAP_TIMEOUT_IN_S 10 | |
57 | 57 | #define SEQMAP_UNASSIGNED_HOST_NR UINT_MAX |
58 | 58 | |
59 | 59 | void seqmap_init() |
60 | 60 | { |
61 | 61 | seqmap_map = calloc(SEQMAP_MAXSEQ, sizeof(SEQMAP_VALUE)); |
62 | if(seqmap_map == NULL) { | |
62 | if (seqmap_map == NULL) { | |
63 | 63 | perror("malloc error (can't allocate seqmap_map)"); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | unsigned int seqmap_add(unsigned int host_nr, unsigned int ping_count, struct timeval *now) | |
67 | unsigned int seqmap_add(unsigned int host_nr, unsigned int ping_count, struct timeval* now) | |
68 | 68 | { |
69 | 69 | unsigned int current_id; |
70 | SEQMAP_VALUE *next_value; | |
70 | SEQMAP_VALUE* next_value; | |
71 | 71 | |
72 | if(!seqmap_map) { | |
72 | if (!seqmap_map) { | |
73 | 73 | fprintf(stderr, "fping internal error: seqmap not initialized.\n"); |
74 | 74 | exit(4); |
75 | 75 | } |
77 | 77 | /* check if expired (note that unused seqmap values will have fields set to |
78 | 78 | * 0, so will be seen as expired */ |
79 | 79 | next_value = &seqmap_map[seqmap_next_id]; |
80 | if(next_value->ping_ts.tv_sec != 0 && (now->tv_sec - next_value->ping_ts.tv_sec) < SEQMAP_TIMEOUT_IN_S) { | |
80 | if (next_value->ping_ts.tv_sec != 0 && (now->tv_sec - next_value->ping_ts.tv_sec) < SEQMAP_TIMEOUT_IN_S) { | |
81 | 81 | fprintf(stderr, "fping error: not enough sequence numbers available! (expire_timeout=%d, host_nr=%d, ping_count=%d, seqmap_next_id=%d)\n", |
82 | 82 | SEQMAP_TIMEOUT_IN_S, host_nr, ping_count, seqmap_next_id); |
83 | 83 | exit(4); |
96 | 96 | return current_id; |
97 | 97 | } |
98 | 98 | |
99 | SEQMAP_VALUE *seqmap_fetch(unsigned int id, struct timeval *now) | |
99 | SEQMAP_VALUE* seqmap_fetch(unsigned int id, struct timeval* now) | |
100 | 100 | { |
101 | SEQMAP_VALUE *value; | |
101 | SEQMAP_VALUE* value; | |
102 | 102 | |
103 | if(id > SEQMAP_MAXSEQ) { | |
103 | if (id > SEQMAP_MAXSEQ) { | |
104 | 104 | return NULL; |
105 | 105 | } |
106 | 106 | |
107 | 107 | value = &seqmap_map[id]; |
108 | 108 | |
109 | 109 | /* verify that value is not expired */ |
110 | if(now->tv_sec - value->ping_ts.tv_sec >= SEQMAP_TIMEOUT_IN_S) { | |
110 | if (now->tv_sec - value->ping_ts.tv_sec >= SEQMAP_TIMEOUT_IN_S) { | |
111 | 111 | return NULL; |
112 | 112 | } |
113 | 113 |
0 | /* | |
1 | * fping: fast-ping, file-ping, favorite-ping, funky-ping | |
2 | * | |
3 | * Ping a list of target hosts in a round robin fashion. | |
4 | * A better ping overall. | |
5 | * | |
6 | * fping website: http://www.fping.org | |
7 | * | |
8 | * Current maintainer of fping: David Schweikert | |
9 | * Please send suggestions and patches to: david@schweikert.ch | |
10 | * | |
11 | * | |
12 | * Original author: Roland Schemers <schemers@stanford.edu> | |
13 | * IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl> | |
14 | * Improved main loop: David Schweikert <david@schweikert.ch> | |
15 | * Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch> | |
16 | * Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de) | |
17 | * | |
18 | * | |
19 | * Redistribution and use in source and binary forms are permitted | |
20 | * provided that the above copyright notice and this paragraph are | |
21 | * duplicated in all such forms and that any documentation, | |
22 | * advertising materials, and other materials related to such | |
23 | * distribution and use acknowledge that the software was developed | |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
26 | * specific prior written permission. | |
27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
28 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
29 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
30 | */ | |
31 | ||
32 | #include "config.h" | |
33 | #include "fping.h" | |
34 | ||
35 | int open_ping_socket_ipv4(); | |
36 | int open_ping_socket_ipv6(); | |
37 | void init_ping_buffer_ipv4(size_t ping_data_size); | |
38 | void init_ping_buffer_ipv6(size_t ping_data_size); | |
39 | void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr); | |
40 | void socket_set_src_addr_ipv6(int s, FPING_INADDR src_addr); | |
41 | int socket_sendto_ping_ipv4(int s, struct sockaddr* saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr); | |
42 | int socket_sendto_ping_ipv6(int s, struct sockaddr* saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr); | |
43 | ||
44 | int open_ping_socket() | |
45 | { | |
46 | #ifndef IPV6 | |
47 | return open_ping_socket_ipv4(); | |
48 | #else | |
49 | return open_ping_socket_ipv6(); | |
50 | #endif | |
51 | } | |
52 | ||
53 | void init_ping_buffer(size_t ping_data_size) | |
54 | { | |
55 | #ifndef IPV6 | |
56 | return init_ping_buffer_ipv4(ping_data_size); | |
57 | #else | |
58 | return init_ping_buffer_ipv6(ping_data_size); | |
59 | #endif | |
60 | } | |
61 | ||
62 | void socket_set_src_addr(int s, FPING_INADDR src_addr) | |
63 | { | |
64 | #ifndef IPV6 | |
65 | socket_set_src_addr_ipv4(s, src_addr); | |
66 | #else | |
67 | socket_set_src_addr_ipv6(s, src_addr); | |
68 | #endif | |
69 | } | |
70 | ||
71 | int socket_sendto_ping(int s, struct sockaddr* saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr) | |
72 | { | |
73 | #ifndef IPV6 | |
74 | return socket_sendto_ping_ipv4(s, saddr, saddr_len, icmp_seq_nr, icmp_id_nr); | |
75 | #else | |
76 | return socket_sendto_ping_ipv6(s, saddr, saddr_len, icmp_seq_nr, icmp_id_nr); | |
77 | #endif | |
78 | } |
0 | /* | |
0 | /* | |
1 | 1 | * fping: fast-ping, file-ping, favorite-ping, funky-ping |
2 | 2 | * |
3 | 3 | * Ping a list of target hosts in a round robin fashion. |
21 | 21 | * duplicated in all such forms and that any documentation, |
22 | 22 | * advertising materials, and other materials related to such |
23 | 23 | * distribution and use acknowledge that the software was developed |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
26 | 26 | * specific prior written permission. |
27 | 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
28 | 28 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
29 | 29 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
30 | 30 | */ |
31 | 31 | |
32 | #include "config.h" | |
32 | 33 | #include "fping.h" |
33 | #include "config.h" | |
34 | 34 | |
35 | #include <fcntl.h> | |
36 | #include <netdb.h> | |
37 | #include <netinet/in.h> | |
38 | #include <netinet/in_systm.h> | |
39 | #include <netinet/ip.h> | |
40 | #include <netinet/ip_icmp.h> | |
41 | #include <stdio.h> | |
42 | #include <stdlib.h> | |
43 | #include <string.h> | |
35 | 44 | #include <sys/socket.h> |
36 | #include <netinet/in.h> | |
37 | #include <netinet/ip.h> | |
38 | #include <netinet/in_systm.h> | |
39 | #include <netinet/ip_icmp.h> | |
40 | #include <netdb.h> | |
41 | #include <stdio.h> | |
42 | #include <string.h> | |
43 | #include <stdlib.h> | |
44 | #include <fcntl.h> | |
45 | 45 | |
46 | char *ping_buffer_ipv4 = 0; | |
47 | size_t ping_pkt_size_ipv4; | |
46 | char* ping_buffer = 0; | |
47 | size_t ping_pkt_size; | |
48 | 48 | |
49 | 49 | int open_ping_socket_ipv4() |
50 | 50 | { |
51 | struct protoent *proto; | |
51 | struct protoent* proto; | |
52 | 52 | int s; |
53 | 53 | |
54 | 54 | /* confirm that ICMP is available on this machine */ |
55 | if( ( proto = getprotobyname( "icmp" ) ) == NULL ) | |
56 | crash_and_burn( "icmp: unknown protocol" ); | |
55 | if ((proto = getprotobyname("icmp")) == NULL) | |
56 | crash_and_burn("icmp: unknown protocol"); | |
57 | 57 | |
58 | 58 | /* create raw socket for ICMP calls (ping) */ |
59 | s = socket( AF_INET, SOCK_RAW, proto->p_proto ); | |
60 | if( s < 0 ) { | |
59 | s = socket(AF_INET, SOCK_RAW, proto->p_proto); | |
60 | if (s < 0) { | |
61 | 61 | /* try non-privileged icmp (works on Mac OSX without privileges, for example) */ |
62 | s = socket( AF_INET, SOCK_DGRAM, proto->p_proto ); | |
63 | if( s < 0 ) { | |
64 | errno_crash_and_burn( "can't create socket (must run as root?)" ); | |
62 | s = socket(AF_INET, SOCK_DGRAM, proto->p_proto); | |
63 | if (s < 0) { | |
64 | errno_crash_and_burn("can't create socket (must run as root?)"); | |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
69 | 69 | { |
70 | 70 | int flags; |
71 | 71 | |
72 | if((flags = fcntl(s, F_GETFL, 0)) < 0) | |
72 | if ((flags = fcntl(s, F_GETFL, 0)) < 0) | |
73 | 73 | perror("fcntl"); |
74 | 74 | |
75 | if(fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) | |
75 | if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) | |
76 | 76 | perror("fcntl"); |
77 | 77 | } |
78 | 78 | |
82 | 82 | void init_ping_buffer_ipv4(size_t ping_data_size) |
83 | 83 | { |
84 | 84 | /* allocate ping buffer */ |
85 | ping_pkt_size_ipv4 = ping_data_size + ICMP_MINLEN; | |
86 | ping_buffer_ipv4 = (char *) calloc(1, ping_pkt_size_ipv4); | |
87 | if(!ping_buffer_ipv4) | |
88 | crash_and_burn( "can't malloc ping packet" ); | |
85 | ping_pkt_size = ping_data_size + ICMP_MINLEN; | |
86 | ping_buffer = (char*)calloc(1, ping_pkt_size); | |
87 | if (!ping_buffer) | |
88 | crash_and_burn("can't malloc ping packet"); | |
89 | 89 | } |
90 | 90 | |
91 | void socket_set_src_addr_ipv4(int s, struct in_addr *src_addr) | |
91 | void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr) | |
92 | 92 | { |
93 | 93 | struct sockaddr_in sa; |
94 | memset( &sa, 0, sizeof( sa ) ); | |
94 | memset(&sa, 0, sizeof(sa)); | |
95 | 95 | sa.sin_family = AF_INET; |
96 | sa.sin_addr = *src_addr; | |
96 | sa.sin_addr = src_addr; | |
97 | 97 | |
98 | if ( bind( s, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 ) | |
99 | errno_crash_and_burn( "cannot bind source address" ); | |
98 | if (bind(s, (struct sockaddr*)&sa, sizeof(sa)) < 0) | |
99 | errno_crash_and_burn("cannot bind source address"); | |
100 | 100 | } |
101 | 101 | |
102 | unsigned short calcsum(unsigned short *buffer, int length) | |
102 | unsigned short calcsum(unsigned short* buffer, int length) | |
103 | 103 | { |
104 | 104 | unsigned long sum; |
105 | 105 | |
106 | 106 | /* initialize sum to zero and loop until length (in words) is 0 */ |
107 | for (sum=0; length>1; length-=2) /* sizeof() returns number of bytes, we're interested in number of words */ | |
108 | sum += *buffer++; /* add 1 word of buffer to sum and proceed to the next */ | |
107 | for (sum = 0; length > 1; length -= 2) /* sizeof() returns number of bytes, we're interested in number of words */ | |
108 | sum += *buffer++; /* add 1 word of buffer to sum and proceed to the next */ | |
109 | 109 | |
110 | 110 | /* we may have an extra byte */ |
111 | if (length==1) | |
112 | sum += (char)*buffer; | |
111 | if (length == 1) | |
112 | sum += (char)*buffer; | |
113 | 113 | |
114 | 114 | sum = (sum >> 16) + (sum & 0xFFFF); /* add high 16 to low 16 */ |
115 | sum += (sum >> 16); /* add carry */ | |
115 | sum += (sum >> 16); /* add carry */ | |
116 | 116 | return ~sum; |
117 | 117 | } |
118 | 118 | |
119 | int socket_sendto_ping_ipv4(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr) | |
119 | int socket_sendto_ping_ipv4(int s, struct sockaddr* saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr) | |
120 | 120 | { |
121 | struct icmp *icp; | |
121 | struct icmp* icp; | |
122 | 122 | int n; |
123 | 123 | |
124 | icp = (struct icmp *) ping_buffer_ipv4; | |
124 | icp = (struct icmp*)ping_buffer; | |
125 | 125 | |
126 | 126 | icp->icmp_type = ICMP_ECHO; |
127 | 127 | icp->icmp_code = 0; |
130 | 130 | icp->icmp_id = htons(icmp_id_nr); |
131 | 131 | |
132 | 132 | if (random_data_flag) { |
133 | for (n = ((char*)&icp->icmp_data - (char *)icp); n < ping_pkt_size_ipv4; ++n) { | |
134 | ping_buffer_ipv4[n] = random() & 0xFF; | |
133 | for (n = ((void*)&icp->icmp_data - (void*)icp); n < ping_pkt_size; ++n) { | |
134 | ping_buffer[n] = random() & 0xFF; | |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | icp->icmp_cksum = calcsum((unsigned short *) icp, ping_pkt_size_ipv4); | |
138 | icp->icmp_cksum = calcsum((unsigned short*)icp, ping_pkt_size); | |
139 | 139 | |
140 | n = sendto(s, icp, ping_pkt_size_ipv4, 0, saddr, saddr_len); | |
140 | n = sendto(s, icp, ping_pkt_size, 0, saddr, saddr_len); | |
141 | 141 | |
142 | 142 | return n; |
143 | 143 | } |
0 | /* | |
0 | /* | |
1 | 1 | * fping: fast-ping, file-ping, favorite-ping, funky-ping |
2 | 2 | * |
3 | 3 | * Ping a list of target hosts in a round robin fashion. |
21 | 21 | * duplicated in all such forms and that any documentation, |
22 | 22 | * advertising materials, and other materials related to such |
23 | 23 | * distribution and use acknowledge that the software was developed |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
24 | * by Stanford University. The name of the University may not be used | |
25 | * to endorse or promote products derived from this software without | |
26 | 26 | * specific prior written permission. |
27 | 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
28 | 28 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
29 | 29 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
30 | 30 | */ |
31 | 31 | |
32 | #include "config.h" | |
32 | 33 | #include "fping.h" |
33 | #include "config.h" | |
34 | 34 | |
35 | #include <fcntl.h> | |
36 | #include <netdb.h> | |
37 | #include <netinet/in.h> | |
38 | #include <stdio.h> | |
39 | #include <stdlib.h> | |
40 | #include <string.h> | |
35 | 41 | #include <sys/socket.h> |
36 | #include <netinet/in.h> | |
37 | #include <netdb.h> | |
38 | #include <stdio.h> | |
39 | #include <string.h> | |
40 | #include <stdlib.h> | |
41 | #include <fcntl.h> | |
42 | 42 | |
43 | #include <netinet/icmp6.h> | |
43 | #include <netinet/icmp6.h> | |
44 | 44 | |
45 | char *ping_buffer_ipv6 = 0; | |
46 | size_t ping_pkt_size_ipv6; | |
45 | char* ping_buffer = 0; | |
46 | size_t ping_pkt_size; | |
47 | 47 | |
48 | 48 | int open_ping_socket_ipv6() |
49 | 49 | { |
50 | struct protoent *proto; | |
50 | struct protoent* proto; | |
51 | 51 | int s; |
52 | 52 | |
53 | 53 | /* confirm that ICMP is available on this machine */ |
54 | if( ( proto = getprotobyname( "ipv6-icmp" ) ) == NULL ) | |
55 | crash_and_burn( "icmp: unknown protocol" ); | |
54 | if ((proto = getprotobyname("ipv6-icmp")) == NULL) | |
55 | crash_and_burn("icmp: unknown protocol"); | |
56 | 56 | |
57 | 57 | /* create raw socket for ICMP calls (ping) */ |
58 | s = socket( AF_INET6, SOCK_RAW, proto->p_proto ); | |
59 | if( s < 0 ) { | |
58 | s = socket(AF_INET6, SOCK_RAW, proto->p_proto); | |
59 | if (s < 0) { | |
60 | 60 | /* try non-privileged icmp (works on Mac OSX without privileges, for example) */ |
61 | s = socket( AF_INET6, SOCK_DGRAM, proto->p_proto ); | |
62 | if( s < 0 ) { | |
63 | errno_crash_and_burn( "can't create raw socket (must run as root?)" ); | |
61 | s = socket(AF_INET6, SOCK_DGRAM, proto->p_proto); | |
62 | if (s < 0) { | |
63 | errno_crash_and_burn("can't create raw socket (must run as root?)"); | |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
68 | 68 | { |
69 | 69 | int flags; |
70 | 70 | |
71 | if((flags = fcntl(s, F_GETFL, 0)) < 0) | |
71 | if ((flags = fcntl(s, F_GETFL, 0)) < 0) | |
72 | 72 | perror("fcntl"); |
73 | 73 | |
74 | if(fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) | |
74 | if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) | |
75 | 75 | perror("fcntl"); |
76 | 76 | } |
77 | 77 | |
81 | 81 | void init_ping_buffer_ipv6(size_t ping_data_size) |
82 | 82 | { |
83 | 83 | /* allocate ping buffer */ |
84 | ping_pkt_size_ipv6 = ping_data_size + sizeof(struct icmp6_hdr); | |
85 | ping_buffer_ipv6 = (char *) calloc(1, ping_pkt_size_ipv6); | |
86 | if(!ping_buffer_ipv6) | |
87 | crash_and_burn( "can't malloc ping packet" ); | |
84 | ping_pkt_size = ping_data_size + sizeof(struct icmp6_hdr); | |
85 | ping_buffer = (char*)calloc(1, ping_pkt_size); | |
86 | if (!ping_buffer) | |
87 | crash_and_burn("can't malloc ping packet"); | |
88 | 88 | } |
89 | 89 | |
90 | void socket_set_src_addr_ipv6(int s, struct in6_addr *src_addr) | |
90 | void socket_set_src_addr_ipv6(int s, FPING_INADDR src_addr) | |
91 | 91 | { |
92 | 92 | struct sockaddr_in6 sa; |
93 | memset( &sa, 0, sizeof( sa ) ); | |
93 | memset(&sa, 0, sizeof(sa)); | |
94 | 94 | sa.sin6_family = AF_INET6; |
95 | sa.sin6_addr = *src_addr; | |
95 | sa.sin6_addr = src_addr; | |
96 | 96 | |
97 | if ( bind( s, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 ) | |
98 | errno_crash_and_burn( "cannot bind source address" ); | |
97 | if (bind(s, (struct sockaddr*)&sa, sizeof(sa)) < 0) | |
98 | errno_crash_and_burn("cannot bind source address"); | |
99 | 99 | } |
100 | 100 | |
101 | int socket_sendto_ping_ipv6(int s, struct sockaddr *saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr) | |
101 | int socket_sendto_ping_ipv6(int s, struct sockaddr* saddr, socklen_t saddr_len, uint16_t icmp_seq_nr, uint16_t icmp_id_nr) | |
102 | 102 | { |
103 | struct icmp6_hdr *icp; | |
103 | struct icmp6_hdr* icp; | |
104 | 104 | int n; |
105 | 105 | |
106 | icp = (struct icmp6_hdr *) ping_buffer_ipv6; | |
107 | icp->icmp6_type = ICMP6_ECHO_REQUEST; | |
108 | icp->icmp6_code = 0; | |
109 | icp->icmp6_seq = htons(icmp_seq_nr); | |
110 | icp->icmp6_id = htons(icmp_id_nr); | |
106 | icp = (struct icmp6_hdr*)ping_buffer; | |
107 | icp->icmp6_type = ICMP6_ECHO_REQUEST; | |
108 | icp->icmp6_code = 0; | |
109 | icp->icmp6_seq = htons(icmp_seq_nr); | |
110 | icp->icmp6_id = htons(icmp_id_nr); | |
111 | 111 | |
112 | 112 | if (random_data_flag) { |
113 | for (n = sizeof(struct icmp6_hdr); n < ping_pkt_size_ipv6; ++n) { | |
114 | ping_buffer_ipv6[n] = random() & 0xFF; | |
113 | for (n = sizeof(struct icmp6_hdr); n < ping_pkt_size; ++n) { | |
114 | ping_buffer[n] = random() & 0xFF; | |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | icp->icmp6_cksum = 0; /* The IPv6 stack calculates the checksum for us... */ | |
118 | icp->icmp6_cksum = 0; /* The IPv6 stack calculates the checksum for us... */ | |
119 | 119 | |
120 | n = sendto(s, icp, ping_pkt_size_ipv6, 0, saddr, saddr_len); | |
120 | n = sendto(s, icp, ping_pkt_size, 0, saddr, saddr_len); | |
121 | 121 | |
122 | 122 | return n; |
123 | 123 | } |