vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Greetings all, In some cases it is handy to hear an audible signal for each received ICMP ping reply, when doing network diagnostics. On some UNIX systems this feature is called by the -a command line option. Here is a (unified diff) patch for the -a option against OpenBSD-current sources CVS'ed October 12, 2003. If you like it, I hope it will be included in the main source tree. regards, Arno "Antarez" Kruse Om mani padme hum ? sbin/ping/ping ? sbin/ping/ping.cat8 Index: sbin/ping/ping.8 ================================================== ================= RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.28 diff -u -r1.28 ping.8 --- sbin/ping/ping.8 3 Jun 2003 13:16:08 -0000 1.28 +++ sbin/ping/ping.8 12 Oct 2003 17:30:47 -0000 @@ -41,7 +41,7 @@ .Sh SYNOPSIS .Nm ping .Bk -words -.Op Fl DdfLnqRrv +.Op Fl aDdfLnqRrv .Op Fl c Ar count .Op Fl I Ar ifaddr .Op Fl i Ar wait @@ -76,6 +76,10 @@ packet. The options are as follows: .Bl -tag -width Ds +.It Fl a +Audible reply. Print a bell (ASCII 0x07) character for each +.Tn ECHO_REPLY +received. .It Fl c Ar count Stop after sending .Ar count Index: sbin/ping/ping.c ================================================== ================= RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.63 diff -u -r1.63 ping.c --- sbin/ping/ping.c 24 Jul 2003 03:10:04 -0000 1.63 +++ sbin/ping/ping.c 12 Oct 2003 17:30:50 -0000 @@ -119,6 +119,7 @@ #define F_SADDR 0x200 #define F_HDRINCL 0x400 #define F_TTL 0x800 +#define F_AUDIBLE 0x2000 /* multicast options */ int moptions; @@ -145,6 +146,7 @@ char DOT = '.'; char *hostname; int ident; /* process id to identify our packets */ +char BBELL = '\a'; /* characters written for AUDIBLE */ /* counters */ long npackets; /* max packets to transmit */ @@ -209,8 +211,11 @@ preload = 0; datap = &outpack[8 + sizeof(struct tvi)]; - while ((ch = getopt(argc, argv, "DI:LRS:c:dfh:i:l:np:qrs:T:t:vw:")) != -1) + while ((ch = getopt(argc, argv, "DI:LRS:c:adfh:i:l:np:qrs:T:t:vw:")) != -1) switch(ch) { + case 'a': + options |= F_AUDIBLE; + break; case 'c': npackets = strtol(optarg, NULL, 0); if (npackets <= 0) @@ -723,6 +728,8 @@ (int)(triptime % 1000)); if (dupflag) (void)printf(" (DUP!)"); + if (options & F_AUDIBLE) + (void)write(STDOUT_FILENO, &BBELL, 1); /* check the data */ cp = (u_char *)&icp->icmp_data[sizeof(struct tvi)]; dp = &outpack[8 + sizeof(struct tvi)]; @@ -1329,7 +1336,7 @@ usage(void) { (void)fprintf(stderr, - "usage: ping [-DdfLnqRrv] [-c count] [-I ifaddr] [-i wait]\n" + "usage: ping [-aDdfLnqRrv] [-c count] [-I ifaddr] [-i wait]\n" "\t[-l preload] [-p pattern] [-s packetsize] [-T tos] [-t ttl]\n" "\t[-w maxwait] host\n"); exit(1); |