summaryrefslogtreecommitdiffstats
path: root/sbin/ping6
diff options
context:
space:
mode:
authormatteo <matteo@FreeBSD.org>2008-08-26 14:34:09 +0000
committermatteo <matteo@FreeBSD.org>2008-08-26 14:34:09 +0000
commitccc2330ba755451caffa377d95369e2954970561 (patch)
treeacc4e4bedd71e27446863ad88689355e0d7b6d48 /sbin/ping6
parentce7f76ed26404d0764981e7aa84f96fc0d9388bb (diff)
downloadFreeBSD-src-ccc2330ba755451caffa377d95369e2954970561.zip
FreeBSD-src-ccc2330ba755451caffa377d95369e2954970561.tar.gz
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
Diffstat (limited to 'sbin/ping6')
-rw-r--r--sbin/ping6/ping6.810
-rw-r--r--sbin/ping6/ping6.c9
2 files changed, 16 insertions, 3 deletions
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);
OpenPOWER on IntegriCloud