- 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
This commit is contained in:
christos 1997-03-11 21:22:49 +00:00
parent f64034e8f6
commit 203dfd3486
3 changed files with 1356 additions and 748 deletions

View File

@ -1,9 +1,10 @@
# $NetBSD: Makefile,v 1.7 1995/03/18 14:59:13 cgd Exp $
# $NetBSD: Makefile,v 1.8 1997/03/11 21:22:49 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= ping
MAN= ping.8
BINOWN= root
BINMODE=4555
CFLAGS+=-g
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ping.8,v 1.11 1996/11/06 20:42:14 cgd Exp $
.\" $NetBSD: ping.8,v 1.12 1997/03/11 21:22:51 christos Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
.\"
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
.\"
.Dd December 11, 1993
.Dd March 11, 1997
.Dt PING 8
.Os BSD 4.3
.Sh NAME
@ -43,16 +43,18 @@
packets to network hosts
.Sh SYNOPSIS
.Nm ping
.Op Fl dfLnqRrv
.Op Fl dfnqrvDPQRL
.Op Fl c Ar count
.Op Fl I Ar ifaddr
.Op Fl g Ar gateway
.Op Fl i Ar wait
.Op Fl l Ar preload
.Op Fl p Ar pattern
.Op Fl S Ar ifaddr
.Op Fl s Ar packetsize
.Op Fl t Ar ttl
.Op Fl w Ar maxwait
.Op Fl I Ar ifaddr
.Op Fl S Ar ifaddr
.Op Fl T Ar tos
.Ar host
.Sh DESCRIPTION
.Nm Ping
@ -82,6 +84,10 @@ packets.
Set the
.Dv SO_DEBUG
option on the socket being used.
.It Fl D
Set the
.Dv Don't Fragment
bit.
.It Fl f
Flood ping.
Outputs packets as fast as they come back or one hundred times per second,
@ -101,10 +107,11 @@ Wait
.Ar wait
seconds
.Em between sending each packet .
The default is to wait for one second between each packet.
This option is incompatible with the
.Fl f
option.
The default is to wait for one second between each packet,
except when the -f option is used the wait interval is 0.01 seconds.
.It Fl I Ar ifaddr
Send multicast datagrams on the network interface specified by the
interface's hostname or IP address.
.It Fl l Ar preload
If
.Ar preload
@ -153,7 +160,20 @@ The default is 56, which translates into 64
data bytes when combined
with the 8 bytes of
.Tn ICMP
header data.
header data. The maximum allowed value is 65468 bytes.
header data. If the
.Fl D
or
.Fl T
options are specified, or the
.Fl t
option to a unicast destination, a raw socket will be used and the 8 bytes of
header data are included in
.Ar packetsize .
.It Fl t Ar ttl
Use the specified time-to-live.
.It Fl T Ar tos
Use the specified type of service.
.It Fl v
Verbose output.
.Tn ICMP
@ -167,13 +187,14 @@ before transmitting the next one. The default is 10.
.Pp
In addition, the following options may be used for multicast pings:
.Bl -tag -width Ds
.It Fl I Ar ifaddr
Transmit using the specified interface address.
.It Fl L
Disable the loopback, so the transmitting host doesn't see the ICMP
requests.
.It Fl t Ar ttl
Use the specified time-to-live.
.It Fl R
Record Route. Includes the RECORD_ROUTE option in the ECHO_REQUEST
packet and displays the route buffer on returned packets. Note that
the IP header is only large enough for six such routes. Many hosts
ignore or discard this option.
.El
.Pp
When using
@ -199,6 +220,31 @@ argument for
.Xr stty 1
for more information).
.Pp
.Nm
continually sends one datagram per second, and prints one line of
output for every ECHO_RESPONSE returned. On a trusted system with IP
Security Options enabled, if the network idiom is not MONO,
.Nm
also prints a second line containing the hexadecimal representation
of the IP security option in the ECHO_RESPONSE. If the
.Fl c
count option is given, only that number of requests is sent. No
output is produced if there is no response. Round-trip times and
packet loss statistics are computed. If duplicate packets are
received, they are not included in the packet loss calculation,
although the round trip time of these packets is used in calculating
the minimum/average/maximum round-trip time numbers. When the
specified number of packets have been sent (and received) or if
the program is terminated with an interrupt (SIGINT), a brief
summary is displayed. When not using the
.Fl -f
(flood) option, the first interrupt, usually generated by control-C or DEL,
causes
.Nm
to wait for its outstanding requests to return. It will wait no longer
than the longest round trip time encountered by previous, successful pings.
The second interrupt stops ping immediately.
.Pp
This program is intended for use in network testing, measurement and
management.
Because of the load it can impose on the network, it is unwise to use
@ -336,6 +382,10 @@ packets that they use for
packets, for example either 30 or 60.
Others may use completely wild values.
.El
.Sh EXIT STATUS
.Nm
returns 0 on success (the host is alive), and non zero if the arguments are
incorrect or the host is not responding.
.Sh BUGS
Many Hosts and Gateways ignore the
.Tn RECORD_ROUTE

File diff suppressed because it is too large Load Diff