summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/l2ping.19
-rw-r--r--tools/l2ping.c27
2 files changed, 25 insertions, 11 deletions
diff --git a/tools/l2ping.1 b/tools/l2ping.1
index 186e5056..0c7da44b 100644
--- a/tools/l2ping.1
+++ b/tools/l2ping.1
@@ -10,6 +10,8 @@ l2ping \- Send L2CAP echo request and receive answer
] [
.I -c count
] [
+.I -t timeout
+] [
.I -f
] <
.I bd_addr
@@ -34,6 +36,11 @@ Send
.B count
number of packets then exit.
.TP
+.I -c timeout
+Wait
+.B timeout
+for the response.
+.TP
.I -f
Kind of flood ping. Use with care! It reduces the delay time between packets
to 0.
@@ -44,6 +51,6 @@ The Bluetooth MAC address to be pinged in dotted hex notation like
or
.B 01:EF:cd:aB:02:03
.SH AUTHORS
-Written by Maxim Krasnyansky <maxk@qualcomm.com>
+Written by Maxim Krasnyansky <maxk@qualcomm.com> and Marcel Holtmann <marcel@holtmann.org>
.PP
man page by Nils Faerber <nils@kernelconcepts.de>
diff --git a/tools/l2ping.c b/tools/l2ping.c
index 1f3f3a41..45ddbe92 100644
--- a/tools/l2ping.c
+++ b/tools/l2ping.c
@@ -56,10 +56,11 @@
/* Defaults */
bdaddr_t bdaddr;
-int size = 20;
-int ident = 200;
-int delay = 1;
-int count = -1;
+int size = 20;
+int ident = 200;
+int delay = 1;
+int count = -1;
+int timeout = 10;
/* Stats */
int sent_pkt = 0, recv_pkt = 0;
@@ -120,7 +121,7 @@ static void ping(char *svr)
/* Initialize buffer */
for (i = L2CAP_CMD_HDR_SIZE; i < sizeof(buf); i++)
- buf[i]=(i%40)+'A';
+ buf[i] = (i % 40) + 'A';
id = ident;
@@ -148,7 +149,7 @@ static void ping(char *svr)
register int err;
pf[0].fd = s; pf[0].events = POLLIN;
- if ((err = poll(pf, 1, 10*1000)) < 0) {
+ if ((err = poll(pf, 1, timeout * 1000)) < 0) {
perror("Poll failed");
exit(1);
}
@@ -193,12 +194,14 @@ static void ping(char *svr)
printf("%d bytes from %s id %d time %.2fms\n", cmd->len, svr, id - ident, tv2fl(tv_diff));
- if (delay) sleep(delay);
+ if (delay)
+ sleep(delay);
} else {
printf("no response from %s: id %d\n", svr, id);
}
- if (++id > 254) id = ident;
+ if (++id > 254)
+ id = ident;
}
stat(0);
}
@@ -207,7 +210,7 @@ static void usage(void)
{
printf("l2ping - L2CAP ping\n");
printf("Usage:\n");
- printf("\tl2ping [-S source addr] [-s size] [-c count] [-f] <bd_addr>\n");
+ printf("\tl2ping [-S source addr] [-s size] [-c count] [-t timeout] [-f] <bd_addr>\n");
}
extern int optind,opterr,optopt;
@@ -220,7 +223,7 @@ int main(int argc, char *argv[])
/* Default options */
bacpy(&bdaddr, BDADDR_ANY);
- while ((opt=getopt(argc,argv,"s:c:fS:")) != EOF) {
+ while ((opt=getopt(argc,argv,"s:c:t:fS:")) != EOF) {
switch(opt) {
case 'f':
/* Kinda flood ping */
@@ -231,6 +234,10 @@ int main(int argc, char *argv[])
count = atoi(optarg);
break;
+ case 't':
+ timeout = atoi(optarg);
+ break;
+
case 's':
size = atoi(optarg);
break;