1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-28 08:02:54 +00:00

Implement audible support similar to ping(8) -a option. Since -a was already taken, I chose -e (no real argument for this) but I'm willing to change to a different character if needed/desired.

PR:	bin/123752 (inspired by)
MFC after:	2 days
This commit is contained in:
Matteo Riondato 2008-08-26 14:34:09 +00:00
parent 7b87c1e36e
commit 155dac2fdc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182195
2 changed files with 16 additions and 3 deletions

View File

@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 27, 2008
.Dd August 26, 2008
.Dt PING6 8
.Os
.Sh NAME
@ -40,7 +40,7 @@ packets to network hosts
.Sh SYNOPSIS
.Nm
.\" without ipsec, or new ipsec
.Op Fl dfHmnNoqtvwW
.Op Fl defHmnNoqtvwW
.\" old ipsec
.\" .Op Fl AdEfmnNqRtvwW
.Bk -words
@ -148,6 +148,12 @@ option on the socket being used.
.\" .It Fl E
.\" Enables transport-mode IPsec encapsulated security payload
.\" (experimental).
.It Fl e
Audible.
Include a bell
.Tn ( ASCII
0x07)
character in the output when any packet is received.
.It Fl f
Flood ping.
Outputs packets as fast as they come back or one hundred times per second,

View File

@ -189,6 +189,7 @@ struct tv32 {
#define F_SUPTYPES 0x80000
#define F_NOMINMTU 0x100000
#define F_ONCE 0x200000
#define F_AUDIBLE 0x400000
#define F_NOUSERDATA (F_NODEADDR | F_FQDN | F_FQDNOLD | F_SUPTYPES)
u_int options;
@ -215,6 +216,7 @@ int datalen = DEFDATALEN;
int s; /* socket file descriptor */
u_char outpack[MAXPACKETLEN];
char BSPACE = '\b'; /* characters written for flood */
char BBELL = '\a'; /* characters written for AUDIBLE */
char DOT = '.';
char *hostname;
int ident; /* process id to identify our packets */
@ -345,7 +347,7 @@ main(argc, argv)
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
"a:b:c:dfHg:h:I:i:l:mnNop:qS:s:tvwW" ADDOPTS)) != -1) {
"a:b:c:defHg:h:I:i:l:mnNop:qS:s:tvwW" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'a':
@ -414,6 +416,9 @@ main(argc, argv)
case 'd':
options |= F_SO_DEBUG;
break;
case 'e':
options |= F_AUDIBLE;
break;
case 'f':
if (getuid()) {
errno = EPERM;
@ -1555,6 +1560,8 @@ pr_pack(buf, cc, mhdr)
if (options & F_FLOOD)
(void)write(STDOUT_FILENO, &BSPACE, 1);
else {
if (options & F_AUDIBLE)
(void)write(STDOUT_FILENO, &BBELL, 1);
(void)printf("%d bytes from %s, icmp_seq=%u", cc,
pr_addr(from, fromlen), seq);
(void)printf(" hlim=%d", hoplim);