From ccc2330ba755451caffa377d95369e2954970561 Mon Sep 17 00:00:00 2001 From: matteo Date: Tue, 26 Aug 2008 14:34:09 +0000 Subject: 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 --- sbin/ping6/ping6.8 | 10 ++++++++-- sbin/ping6/ping6.c | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'sbin/ping6') diff --git a/sbin/ping6/ping6.8 b/sbin/ping6/ping6.8 index fe57b99..d15c76c 100644 --- a/sbin/ping6/ping6.8 +++ b/sbin/ping6/ping6.8 @@ -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, diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 849c17a..7d0e432 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -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); -- cgit v1.1