diff options
author | matteo <matteo@FreeBSD.org> | 2008-08-26 14:34:09 +0000 |
---|---|---|
committer | matteo <matteo@FreeBSD.org> | 2008-08-26 14:34:09 +0000 |
commit | ccc2330ba755451caffa377d95369e2954970561 (patch) | |
tree | acc4e4bedd71e27446863ad88689355e0d7b6d48 /sbin/ping6/ping6.c | |
parent | ce7f76ed26404d0764981e7aa84f96fc0d9388bb (diff) | |
download | FreeBSD-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/ping6.c')
-rw-r--r-- | sbin/ping6/ping6.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |