History log of /netbsd-current/sbin/ping/ping.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.122 01-Dec-2022 christos

fix sign.


# 1.121 01-Dec-2022 christos

Add a sanity check for the ip header length (from FreeBSD)


# 1.120 22-May-2022 andvar

fix various small typos, mainly in comments.


# 1.119 07-Apr-2022 andvar

fix various typos in comments.


# 1.118 11-Jun-2021 rillig

ping, ping6: fix comment about ID field

Since ping.c 1.76 and ping6.c 1.58 from 2004-04-22, the ID field
contains random bits instead of a process ID.


Revision tags: netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.117 02-Oct-2017 maya

un-ifdef sgi. NFC


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6; 1.102.8;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.120 22-May-2022 andvar

fix various small typos, mainly in comments.


# 1.119 07-Apr-2022 andvar

fix various typos in comments.


# 1.118 11-Jun-2021 rillig

ping, ping6: fix comment about ID field

Since ping.c 1.76 and ping6.c 1.58 from 2004-04-22, the ID field
contains random bits instead of a process ID.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.117 02-Oct-2017 maya

un-ifdef sgi. NFC


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6; 1.102.8;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.119 07-Apr-2022 andvar

fix various typos in comments.


# 1.118 11-Jun-2021 rillig

ping, ping6: fix comment about ID field

Since ping.c 1.76 and ping6.c 1.58 from 2004-04-22, the ID field
contains random bits instead of a process ID.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.117 02-Oct-2017 maya

un-ifdef sgi. NFC


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6; 1.102.8;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.118 11-Jun-2021 rillig

ping, ping6: fix comment about ID field

Since ping.c 1.76 and ping6.c 1.58 from 2004-04-22, the ID field
contains random bits instead of a process ID.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.117 02-Oct-2017 maya

un-ifdef sgi. NFC


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6; 1.102.8;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.117 02-Oct-2017 maya

un-ifdef sgi. NFC


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6; 1.102.8;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.116 17-Mar-2017 ryo

Fix cksum calculation for clearing the cached route.

In ping.c:r1.104, the size of echoreply packet was changed to ICMP_MINLEN,
Therefore also calculation size must be ICMP_MINLEN.


Revision tags: bouyer-socketcan-base
# 1.115 11-Jan-2017 joerg

branches: 1.115.2;
Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.115 11-Jan-2017 joerg

Use an explicitly aligned buffer for ip.


Revision tags: pgoyette-localcount-20170107
# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.114 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Reject packet intervals < 1 ns as they lead to infinite loops adding
zero timespecs.

Fix the behind-schedule behavior so it doesn't spend all its time in
that loop adding very small timespecs. Try ping -c 500 -i 0.000000001
to see this in action with the old ping.


# 1.113 18-Dec-2016 dholland

PR bin/36997 Zafer Aydogan: ping doesn't validate numeric inputs enough.

Check for values between INT_MAX and LONG_MAX (if they're different)
when using strtol to get an int. This applies to the -c and -l options;
the other uses were already checked.

Also limit the inter-packet interval given with -i to values that
don't cause integer overflow calling poll() with milliseconds.

Really large intervals (the number is read as floating point) can
produce positive poll() values but negative integers when converted to
struct timespec; this produces behavior akin to using -l at first and
could be construed as a local DoS vulnerability.


Revision tags: pgoyette-localcount-20161104
# 1.112 07-Oct-2016 joerg

Make optspace an array of uint8_t, since some of the bytes written into
it are outside the signed char range.


Revision tags: localcount-20160914 pgoyette-localcount-20160806
# 1.111 31-Jul-2016 dholland

Manipulate the signal masks so signals only arrive while we're waiting,
so they can't illegally reenter libc.

Fixes the problem Greg A. Woods describes in PR 51267, which might or
might not be the original submitter's problem.


# 1.110 31-Jul-2016 dholland

Don't call variables that are used "dummy".


Revision tags: pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.109 29-Nov-2014 christos

branches: 1.109.2;
Adjust default packet size to 56 data bytes (64 total).
Make error messages consistent.


# 1.108 27-Nov-2014 christos

PR/49423: Martin Husemann: ping for small packets does not work in -7 or
-current
XXX: pullup 7?


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 tls-maxphys-base
# 1.107 19-Oct-2013 christos

branches: 1.107.4;
avoid bogus uninitialized gcc warning


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.106 06-Mar-2013 yamt

more precision for F_TIMING64


Revision tags: yamt-pagecache-base8
# 1.105 30-Dec-2012 christos

deduct phdrlen after computing max size.


# 1.104 30-Dec-2012 christos

1. Allocate the max packet size before accounting for phdrlen, harmless.
2. In the clear-route-cache sendto, don't send 0 bytes (if -s was specified
with < 8, phdrlen would be 0).
3. Always send ICMP_MINLEN packets; this is what everyone else does. Makes
ping -s n where n < 8 work.
4. The condition for checking the data bytes was completely wrong. only check
the data bytes if we got all of them.
5. The condition for printing a newline was wrong; before it would not print
a newline before printing the data bytes, and it would append to the previous
error message.


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 18-Sep-2012 msaitoh

Fix a bug that misunderstand F_TIMING64, F_POLICY and F_AUTHHDR.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-0-5-RELEASE netbsd-6-0-4-RELEASE netbsd-6-0-3-RELEASE netbsd-6-0-2-RELEASE netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base
# 1.102 04-Jan-2012 drochner

branches: 1.102.2; 1.102.6;
include <netipsec/ipsec.h> rather than <netinet6/ipsec.h> from userland
where possible, for consistency and compatibility to FreeBSD
(exception: KAME specific statistics gathering in netstat(1) and systat(1))


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.101 11-Sep-2011 christos

branches: 1.101.2;
print summary stats.


# 1.100 10-Sep-2011 wiz

Sort options and descriptions in standard order.
Remove unecessary Bk/Ek in SYNOPSIS.


# 1.99 10-Sep-2011 christos

PR/45257: Instead of passing a 32bit sec and 32 bit usec timestamp in little
endian format by default, pass a struct timespec in native host format. Add
-C flag to produce a compatible timestamp like before.


# 1.98 27-Aug-2011 joerg

static + __dead


# 1.97 21-Aug-2011 christos

handle the first loop where time == 0.


# 1.96 20-Aug-2011 christos

we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.


# 1.95 19-Aug-2011 christos

PR/45257: Ryo Shimizu: ping(8) prints bogus round-trip times after Year 2038
Clamp all time computations to 32 bits; idea from dsl@


# 1.94 09-Aug-2011 joerg

Don't use array access to compute addresses that are definitely beyond
the static array boundaries.


Revision tags: cherry-xenmp-base
# 1.93 11-Mar-2011 pooka

Make get/setuid prog ops (so that i can do rump.ping -f regardless
of host privs).


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.92 13-Dec-2010 pooka

RUMP_ACTION -> RUMPPRG


# 1.91 11-Nov-2010 pooka

add compile-conditional rumpclient support


Revision tags: matt-premerge-20091211
# 1.90 02-Nov-2009 christos

remove ancient ifdefs (Aleksej Saushev)


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.89 11-Apr-2009 lukem

fix sign-compare issues


# 1.88 31-Mar-2009 christos

PR/41111: Ed Ravin: ping -R gives misleading error when remote side doesn't
support record route
Deal with source route and record route specially giving a meaningful error
message.
Pullup to 5.0?


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base mjf-devfs2-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.87 08-Jan-2008 seanb

branches: 1.87.10; 1.87.12; 1.87.16;
Shutdown sloop socket for read as it's never read on to
prevent mbufs from queueing in its recv buf.
PR:21459


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.86 17-Jan-2007 hubertf

branches: 1.86.4; 1.86.6;
Remove more duplicate #includes,
from Slava Semushin <slava.semushin@gmail.com>


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.85 28-Sep-2006 elad

Change error message to say "setuid", forgotten in previous commit.

Pointed out by Ray Lai, thanks!


# 1.84 24-Sep-2006 elad

On 2nd thought, setuid() is better here.


# 1.83 24-Sep-2006 elad

PR/28741: Michael Santos: ping does [not] drop root privileges

Moved socket calls way up, and called seteuid(getuid()).


Revision tags: abandoned-netbsd-4-base
# 1.82 14-Jul-2006 yamt

prtsig: remove a mysterious abort().


# 1.81 03-Jun-2006 christos

Use SA_NOKERNINFO instead of playing with the tty.


# 1.80 01-Jun-2006 christos

Factor out the tty code and explain we prefer to stop in the ^Z bg case
when we exit, rather than kill the tty setting.


# 1.79 01-Jun-2006 christos

PR/33623: Chuck Cranor: Ping stops when ran in the background
because it tries to set the tty not to print kerninfo. Change it
to only only play with the tty when ping is running in the foreground
(and will not stop when calling tcsetattr()). In my opinion, it is
preferable to print the kerninfo line with the ping info message
rather than to mess with the tty, but that's just me.


# 1.78 09-May-2006 mrg

change (mostly) int to socklen_t. GCC 4 doesn't like that int and
socklen_t are different signness.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.77 13-May-2004 kleink

branches: 1.77.2; 1.77.4; 1.77.6;
There's no point in bringing PRNG output to network byteorder prior to
transmission.


# 1.76 22-Apr-2004 itojun

do not disclose endian. henning@openbsd


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.75 26-Jan-2004 itojun

branches: 1.75.2; 1.75.4; 1.75.6;
do not disclose endianness/sizeof(long) on probe packet. idea from openbsd


# 1.74 05-Jan-2004 jmmv

Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.


# 1.73 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.72 14-Apr-2003 itojun

permit -s 0. from Maxim Konovalov


Revision tags: fvdl_fs64_base
# 1.71 16-Nov-2002 itojun

set sa_len right


# 1.70 16-Nov-2002 itojun

die if strdup fails


# 1.69 16-Nov-2002 itojun

use strlcpy. initialize sa_len correctly.


# 1.68 21-Sep-2002 mycroft

Touch up error/warning messages.


# 1.67 21-Sep-2002 mycroft

select() -> poll()


# 1.66 12-Aug-2002 matt

Add support for printing out messages about missing packet gaps. This is
done with the -v switch. If -q is also given with -v, then only the
packet gap messages will be printed along with summary after each gap
message.


# 1.65 01-Aug-2002 itojun

u_short cleansing (use u_int16_t where appropriate)


# 1.64 31-May-2002 itojun

clarify comment when nreceived > ntransmitted. from deraadt


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.63 20-Dec-2001 soren

Sync getopt() / man page with actual getopt options.


# 1.62 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.61 10-Oct-2001 yamt

- use IP_MAXPACKET instead of 65535.
- change max packet size from 65468 to 65467(= IP_MAXPACKET-60-8).


# 1.60 09-Oct-2001 yamt

- fix overrun bug.
- bump bufsize to fix "packet loss" with large packet.


# 1.59 19-Feb-2001 cgd

convert to use getprogname()


# 1.58 12-Jan-2001 itojun

correct use of howmany() for fd_set. commented by deraadt


# 1.57 10-Oct-2000 is

Format string cleanups by Bill Sommerfeld.


# 1.56 07-Oct-2000 itojun

avoid fd_set overflow. see openbsd select(2).


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.55 31-Jan-2000 itojun

branches: 1.55.4;
sync with latest libipsec and kernel.


# 1.54 20-Jan-2000 mycroft

Fix data comparison to not overrun array bounds.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.53 04-Jul-1999 itojun

do not pass NULL to errx().

From: Chris Joness <cjones@rupert.honors.montana.edu>


# 1.52 04-Jul-1999 itojun

do not bark even if ipsec policy setting for "route flushing 127.0.0.1"
ping socket is not successful. it usually means that the kernel is
not ipsec ready, and in that case this should be just okay.


# 1.51 03-Jul-1999 kleink

0 -> STDIN_FILENO


# 1.50 02-Jul-1999 itojun

IPsec support (specify policy on ping - quite useful to test
if IPsec is working or not) is added.


# 1.49 19-Jun-1999 sommerfeld

Support for ping -a: beep when packet received.
Slightly tweaked from version submitted by andrew@untraceable.net in PR7815


# 1.48 17-Apr-1999 mjl

Correct nokerninfo tty flag being left set in most error cases.
Closes PR/7388 by Dave Huang <khym@bga.com>.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.47 08-Mar-1999 sommerfe

branches: 1.47.2;
Don't bother doing stddev calculation when n==1, since that results in
a computation of 0.0/0.0.
On IEEE systems you get a NaN from this; non-IEEE systems probably
give you a SIGFPE.


# 1.46 25-Feb-1999 jwise

Once more around the hickory shrub. Faster and simpler stddev calculation from
Bill Studenmund.


# 1.45 25-Feb-1999 jwise

Fix calculation of standard deviation. From Brian C. Grayson <bgrayson@orac.ece.utexas.edu>


# 1.44 24-Feb-1999 jwise

Add code from Daniel Hagerty <hag@ai.mit.edu> to print standard deviation
when printing out final statistics line.

Closes PR bin/6198


# 1.43 06-Nov-1998 christos

char -> unsigned char


# 1.42 26-Oct-1998 enami

Fix usage string;
- option to specify maxwait is -w, not -i.
- add missing -h host and -Q option.


# 1.41 25-Oct-1998 christos

Update to the 980911 version from ftp.rhyolite.com:/src/ping.tar.Z


# 1.40 01-Oct-1998 frueauf

Add getuid() check if -f is set, fixes pr 6222 by Uwe Arndt.


# 1.39 14-Sep-1998 tv

Restrict -l to the superuser as suggested in PR 3973 from <soren@t.dk>.
Also distinguish "-f" from "-i 0.x" in the superuser restriction messages.


# 1.38 14-Sep-1998 tv

Nuke the termios stuff from the 1997/03/11 import, which prevents ping
from being run in the background of most shells without redirecting stdin
from /dev/null. (AFAICT, the termios stuff is useless and does not
interfere with SIGINFO handling.)


# 1.37 28-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.36 16-Apr-1998 kleink

Take into consideration that icmp_nextmtu is stored in network byte order;
from Leonard Samuelson in PR bin/5230.


# 1.35 01-Dec-1997 christos

PR/4615: David Jones: Ping usage does not show -o option.


# 1.34 30-Nov-1997 christos

Make the "failed to clear cached route" a warning only if verbose is set.
This always happens when lo0 is not configured and confuses new users.


# 1.33 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-BETA netbsd-1-3-base
# 1.32 15-Sep-1997 lukem

branches: 1.32.2;
* cleanup .Nm
* deprecate register
* cleanup for WARNS=1
* bzero(), bcopy() -> memset(), memmove()
* prefix hex numbers with '0x'


# 1.31 17-Jul-1997 mikel

convert to host byte order when printing stats of received ICMP
packets other than echo-replies; from Dave Huang in PR bin/3876


# 1.30 01-Jun-1997 christos

Update from Vernon Schryver, fixing the kluge to flush the route cache.


# 1.29 02-Apr-1997 augustss

Make ping obey the -n flag in places.


# 1.28 24-Mar-1997 christos

Don't allow < 1 sec ping interval to regular users.


# 1.27 19-Mar-1997 christos

Try adding `o' option again; connection died.


# 1.26 19-Mar-1997 christos

Take care of alignment problems on the alpha: From John Birell, via cgd.


# 1.25 18-Mar-1997 christos

PR/3329: From David Jones: Add F_ONCE


# 1.24 13-Mar-1997 christos

Fix PR/3327: rcvd_tbl index was assumed to be in host order, creating
incorrect dup reports. From enami tsugutomo


# 1.23 11-Mar-1997 christos

- remove -g from Makefile
- fix setsockopt and recvfrom casts.


# 1.22 11-Mar-1997 christos

- Use err, warn, errx
- Don't use floor, because we would need libm
- Add maxwait option from old ping
- Add a centralized gethost() to get hostnames
- Fix PR/1014 and PR/2017; (adds -D, -T options, and -I and -t for unicast)
- Document exit status


# 1.21 06-Nov-1996 cgd

make ping(8) print out statistics when given a SIGINFO.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.20 11-Aug-1995 cgd

fix a couple of bugs pointed out by John Birrell, though fix some
differently he did. (1) don't assume that the timeval in
the packet is correctly aligned, (2) don't compare beyond the end
of the packet, (3) minor cast for printf happiness.


# 1.19 27-Jul-1995 ghudson

Add and document options -w (to specify a maximum wait timeout, useful
for testing network interfaces) and -S (to specify a source address
on a machine with multiple interfaces).


# 1.18 26-Jun-1995 jtc

sys/signal.h -> signal.h


# 1.17 03-Jun-1995 mycroft

Fill in sin_len.


# 1.16 21-May-1995 mycroft

Use inet_aton(), not inet_addr().


# 1.15 22-Apr-1995 cgd

if no packets were received, exit with status 1. this should be
documented somewhere. As suggested by Rens Troost.


# 1.14 21-Mar-1995 mycroft

Update to use timer{add,sub}().


# 1.13 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.12 18-Dec-1994 cgd

-Wall cleanups from Jim Jegers


# 1.11 31-Oct-1994 cgd

will need <sys/queue.h>


# 1.10 23-Sep-1994 mycroft

Remove some more uses of obsolete functions.


# 1.9 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.8 23-Sep-1994 mycroft

Merge with 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 15-Dec-1993 hpeyerl

Another multicast patch.
>From LBL and Steve Mccanne


# 1.6 23-Sep-1993 mycroft

Use doubles to rather than longs to avoid tsum overflowing so quickly.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 22-Jul-1993 cgd

have ping do the right thing, wrt microseconds.
actually, now it'll overflow its counters sooner than before, and everything
should *really* be converted to doubles and/or "unsigned long long"s


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision