-.\" $OpenBSD: ping.8,v 1.63 2020/02/11 18:41:39 deraadt Exp $
+.\" $OpenBSD: ping.8,v 1.64 2021/02/21 10:38:42 sthen Exp $
.\" $NetBSD: ping.8,v 1.10 1995/12/31 04:55:35 ghudson Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\"
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
.\"
-.Dd $Mdocdate: February 11 2020 $
+.Dd $Mdocdate: February 21 2021 $
.Dt PING 8
.Os
.Sh NAME
.Nd send ICMP ECHO_REQUEST packets to network hosts
.Sh SYNOPSIS
.Nm ping
-.Op Fl DdEefHLnqRv
+.Op Fl DdEefgHLnqRv
.Op Fl c Ar count
.Op Fl I Ar sourceaddr
.Op Fl i Ar interval
.Op Fl w Ar maxwait
.Ar host
.Nm ping6
-.Op Fl DdEefHLmnqv
+.Op Fl DdEefgHLmnqv
.Op Fl c Ar count
.Op Fl h Ar hoplimit
.Op Fl I Ar sourceaddr
.Bf -emphasis
This can be very hard on a network and should be used with caution.
.Ef
+.It Fl g
+Provides a visual display of packets received and lost.
+For every
+.Dv ECHO_REPLY
+received, an exclamation mark
+.Sq !
+is printed, while for every missed packet a period
+.Sq \&.
+is printed.
+Duplicate and truncated replies are indicated with
+.Sq D
+and
+.Sq T
+respectively.
.It Fl H
Try reverse lookups for addresses.
.It Fl h Ar hoplimit
-/* $OpenBSD: ping.c,v 1.243 2020/12/29 16:40:47 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.244 2021/02/21 10:38:42 sthen Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
#define F_QUIET 0x0010
#define F_RROUTE 0x0020
#define F_SO_DEBUG 0x0040
-/* 0x0080 */
+#define F_SHOWCHAR 0x0080
#define F_VERBOSE 0x0100
/* 0x0200 */
#define F_HDRINCL 0x0400
preload = 0;
datap = &outpack[ECHOLEN + ECHOTMLEN];
while ((ch = getopt(argc, argv, v6flag ?
- "c:DdEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" :
- "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) {
+ "c:DdEefgHh:I:i:Ll:mNnp:qS:s:T:V:vw:" :
+ "DEI:LRS:c:defgHi:l:np:qs:T:t:V:vw:")) != -1) {
switch(ch) {
case 'c':
npackets = strtonum(optarg, 0, INT64_MAX, &errstr);
options |= F_FLOOD;
setvbuf(stdout, NULL, _IONBF, 0);
break;
+ case 'g':
+ options |= F_SHOWCHAR;
+ break;
case 'H':
options |= F_HOSTNAME;
break;
if (!(options & F_FLOOD) &&
(options & F_AUD_MISS))
fputc('\a', stderr);
+ if ((options & F_SHOWCHAR) &&
+ !(options & F_FLOOD)) {
+ putchar('.');
+ fflush(stdout);
+ }
}
continue;
}
if (options & F_FLOOD)
write(STDOUT_FILENO, &BSPACE, 1);
- else {
+ else if (options & F_SHOWCHAR) {
+ if (dupflag)
+ putchar('D');
+ else if (cc - ECHOLEN < datalen)
+ putchar('T');
+ else
+ putchar('!');
+ } else {
printf("%d bytes from %s: icmp_seq=%u", cc,
pr_addr(from, fromlen), ntohs(seq));
if (v6flag)
pr_ipopt(hlen, buf);
if (!(options & F_FLOOD)) {
- putchar('\n');
- if (v6flag && (options & F_VERBOSE))
- pr_exthdrs(mhdr);
+ if (!(options & F_SHOWCHAR)) {
+ putchar('\n');
+ if (v6flag && (options & F_VERBOSE))
+ pr_exthdrs(mhdr);
+ }
fflush(stdout);
if (options & F_AUD_RECV)
fputc('\a', stderr);
{
if (v6flag) {
fprintf(stderr,
- "usage: ping6 [-DdEefHLmnqv] [-c count] [-h hoplimit] "
+ "usage: ping6 [-DdEefgHLmnqv] [-c count] [-h hoplimit] "
"[-I sourceaddr]\n\t[-i interval] [-l preload] "
"[-p pattern] [-s packetsize] [-T toskeyword]\n"
"\t[-V rtable] [-w maxwait] host\n");
} else {
fprintf(stderr,
- "usage: ping [-DdEefHLnqRv] [-c count] [-I sourceaddr] "
+ "usage: ping [-DdEefgHLnqRv] [-c count] [-I sourceaddr] "
"[-i interval]\n\t[-l preload] [-p pattern] [-s packetsize]"
#ifndef SMALL
" [-T toskeyword]"