diff options
author | Thomas Habets <thomas@habets.pp.se> | 2009-11-06 20:25:25 +0100 |
---|---|---|
committer | Thomas Habets <thomas@habets.pp.se> | 2009-11-06 20:25:25 +0100 |
commit | a622fa9f52803dd6c3fc759fecfb25d26f5ca57e (patch) | |
tree | 72cdf577e2a97362457f5d685fa124f04047f81b | |
parent | 707dfa52bef57ded9921feb6cad1dd2088a19c1b (diff) | |
download | arping-a622fa9f52803dd6c3fc759fecfb25d26f5ca57e.tar.gz |
Added -e, beep when there is *no* reply (close bug e4a)
-rw-r--r-- | .be/bugs/e4ac34f5-f8b8-4b59-abe3-c283e341f23e/values | 31 | ||||
-rw-r--r-- | doc/arping.8 | 4 | ||||
-rw-r--r-- | doc/arping.yodl | 3 | ||||
-rw-r--r-- | src/arping.c | 32 |
4 files changed, 36 insertions, 34 deletions
diff --git a/.be/bugs/e4ac34f5-f8b8-4b59-abe3-c283e341f23e/values b/.be/bugs/e4ac34f5-f8b8-4b59-abe3-c283e341f23e/values index eac75b6..84f50dc 100644 --- a/.be/bugs/e4ac34f5-f8b8-4b59-abe3-c283e341f23e/values +++ b/.be/bugs/e4ac34f5-f8b8-4b59-abe3-c283e341f23e/values @@ -1,35 +1,14 @@ +creator: Thomas Habets <thomas@habets.pp.se> +severity: minor -creator=Thomas Habets <thomas@habets.pp.se> +status: closed +summary: Add -A, beep when there is *no* reply - -severity=minor - - - - - - -status=open - - - - - - -summary=Add -A, beep when there is *no* reply - - - - - - -time=Wed, 07 Jan 2009 17:42:49 +0000 - - +time: Wed, 07 Jan 2009 17:42:49 +0000 diff --git a/doc/arping.8 b/doc/arping.8 index b917e8a..f73e6d0 100644 --- a/doc/arping.8 +++ b/doc/arping.8 @@ -5,7 +5,7 @@ arping \- sends arp and/or ip pings to a given host .PP .SH "SYNOPSIS" -\fBarping\fP [-abdDFhpqrRd0uv] [-S \fIhost/ip\fP] [-T \fIhost/ip\fP] [-s \fIMAC\fP] [-t \fIMAC\fP] [-c \fIcount\fP] [-i \fIinterface\fP] [ -w \fIus\fP ] <\fIhost\fP | -B> +\fBarping\fP [-abdDeFhpqrRd0uv] [-S \fIhost/ip\fP] [-T \fIhost/ip\fP] [-s \fIMAC\fP] [-t \fIMAC\fP] [-c \fIcount\fP] [-i \fIinterface\fP] [ -w \fIus\fP ] <\fIhost\fP | -B> .PP \fBarping\fP --help .PP @@ -65,6 +65,8 @@ two different MAC addresses\&. .IP "-D" Display answers as dots and missing packets as exclamation points\&. Like flood ping on a Cisco\&. +.IP "-e" +Like -a but beep when there is no reply\&. .IP "-F" Don\&'t try to be smart about the interface name\&. Even if this switch is not given, -i disables this smartness\&. diff --git a/doc/arping.yodl b/doc/arping.yodl index 365dd4a..2484ca1 100644 --- a/doc/arping.yodl +++ b/doc/arping.yodl @@ -3,7 +3,7 @@ manpage(arping)(8)(21th June, 2003)(arping)() manpagename(arping)(sends arp and/or ip pings to a given host) manpagesynopsis() - bf(arping) [-abdDFhpqrRd0uv] [-S em(host/ip)] [-T em(host/ip)] [-s em(MAC)] \ + bf(arping) [-abdDeFhpqrRd0uv] [-S em(host/ip)] [-T em(host/ip)] [-s em(MAC)] \ [-t em(MAC)] [-c em(count)] [-i em(interface)] [ -w em(us) ] <em(host) | -B> bf(arping) --help @@ -55,6 +55,7 @@ for a host. two different MAC addresses. dit(-D) Display answers as dots and missing packets as exclamation points. Like flood ping on a Cisco. + dit(-e) Like -a but beep when there is no reply. dit(-F) Don't try to be smart about the interface name. Even if this switch is not given, -i disables this smartness. dit(-h) Displays a help message and exits. diff --git a/src/arping.c b/src/arping.c index a51f5ab..22748e9 100644 --- a/src/arping.c +++ b/src/arping.c @@ -120,6 +120,7 @@ static struct timeval lastpacketsent; uint32_t srcip,dstip; static int beep = 0; +static int reverse_beep = 0; static int verbose = 0; static int alsototal = 0; /*static int pingmac = 0; */ @@ -257,6 +258,7 @@ extended_usage() "answers from\n" " two different MAC addresses.\n" " -D Display answers as dots and missing packets as exclamation points.\n" + " -e Like -a but beep when there is no reply.\n" " -F Don't try to be smart about the interface name. (even if this\n" " switch is not given, -i overrides smartness)\n" " -h Displays a help message and exits.\n" @@ -298,11 +300,14 @@ standard_usage() { printf("ARPing %s, by Thomas Habets <thomas@habets.pp.se>\n", version); - printf("usage: arping [ -0aAbdDFpqrRuv ] [ -w <us> ] [ -S <host/ip> ] " - "[ -T <host/ip ]\n" - " [ -s <MAC> ] [ -t <MAC> ] [ -c <count> ] " - "[ -i <interface> ]\n" - " <host/ip/MAC | -B>\n"); + printf("usage: arping [ -0aAbdDeFpqrRuv ] [ -w <us> ] " + "[ -S <host/ip> ]\n" + " " + "[ -T <host/ip ] " + "[ -s <MAC> ] [ -t <MAC> ] [ -c <count> ]\n" + " " + "[ -i <interface> ] " + "<host/ip/MAC | -B>\n"); } /** @@ -976,7 +981,7 @@ int main(int argc, char **argv) memset(dstmac, 0xff, ETH_ALEN); memset(ethxmas, 0xff, ETH_ALEN); - while (EOF!=(c=getopt(argc,argv,"0aAbBc:dDFhi:I:pqrRs:S:t:T:uvw:"))) { + while (EOF!=(c=getopt(argc,argv,"0aAbBc:dDeFhi:I:pqrRs:S:t:T:uvw:"))) { switch(c) { case '0': srcip = 0; @@ -1005,6 +1010,9 @@ int main(int argc, char **argv) case 'D': display = DOT; break; + case 'e': + reverse_beep = 1; + break; case 'F': dont_use_arping_lookupdev=1; break; @@ -1330,17 +1338,29 @@ int main(int argc, char **argv) */ if (mode == PINGIP) { unsigned int c; + unsigned int r; for (c = 0; c < maxcount && !time_to_die; c++) { pingip_send(srcmac, dstmac, srcip, dstip); + r = numrecvd; ping_recv(pcap,packetwait, (pcap_handler)pingip_recv); + if (reverse_beep && !time_to_die && (r == numrecvd)) { + printf("\a"); + fflush(stdout); + } } } else { /* PINGMAC */ unsigned int c; + unsigned int r; for (c = 0; c < maxcount && !time_to_die; c++) { pingmac_send(srcmac, dstmac, srcip, dstip, rand(), c); + r = numrecvd; ping_recv(pcap,packetwait, (pcap_handler)pingmac_recv); + if (reverse_beep && !time_to_die && (r == numrecvd)) { + printf("\a"); + fflush(stdout); + } } } if (display == DOT) { |