* [PATCH 1/4] tools/l2test: Add -e option
@ 2015-06-01 9:27 Szymon Janc
2015-06-01 9:27 ` [PATCH 2/4] tools/l2test: Allow to send zero frames before delay Szymon Janc
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Szymon Janc @ 2015-06-01 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This allows to specify initial value for sequence when sending frames.
---
tools/l2test.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/tools/l2test.c b/tools/l2test.c
index 8065578..75603a8 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -108,6 +108,9 @@ static unsigned long send_delay = 0;
/* Default delay before receiving */
static unsigned long recv_delay = 0;
+/* Initial sequence value when sending frames */
+static int seq_start = 0;
+
static char *filename = NULL;
static int rfcmode = 0;
@@ -974,7 +977,7 @@ static void do_send(int sk)
buf[i] = 0x7f;
}
- seq = 0;
+ seq = seq_start;
while ((num_frames == -1) || (num_frames-- > 0)) {
put_le32(seq, buf);
put_le16(data_size, buf + 4);
@@ -997,7 +1000,8 @@ static void do_send(int sk)
size -= len;
}
- if (num_frames && send_delay && count && !(seq % count))
+ if (num_frames && send_delay && count &&
+ !(seq % (count + seq_start)))
usleep(send_delay);
}
}
@@ -1325,7 +1329,8 @@ static void usage(void)
"\t[-S] secure connection\n"
"\t[-M] become master\n"
"\t[-T] enable timestamps\n"
- "\t[-V type] address type (help for list, default = bredr)\n");
+ "\t[-V type] address type (help for list, default = bredr)\n"
+ "\t[-e seq] initial sequence value (default = 0)\n");
}
int main(int argc, char *argv[])
@@ -1336,7 +1341,7 @@ int main(int argc, char *argv[])
bacpy(&bdaddr, BDADDR_ANY);
while ((opt = getopt(argc, argv, "rdscuwmntqxyzpb:a:"
- "i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMT")) != EOF) {
+ "i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMTe:")) != EOF) {
switch (opt) {
case 'r':
mode = RECV;
@@ -1542,6 +1547,10 @@ int main(int argc, char *argv[])
break;
+ case 'e':
+ seq_start = atoi(optarg);
+ break;
+
default:
usage();
exit(1);
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] tools/l2test: Allow to send zero frames before delay
2015-06-01 9:27 [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
@ 2015-06-01 9:27 ` Szymon Janc
2015-06-01 9:27 ` [PATCH 3/4] tools/l2test: Sort options alphabetically Szymon Janc
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2015-06-01 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
---
tools/l2test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/l2test.c b/tools/l2test.c
index 75603a8..dac98f9 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -977,6 +977,9 @@ static void do_send(int sk)
buf[i] = 0x7f;
}
+ if (!count && send_delay)
+ usleep(send_delay);
+
seq = seq_start;
while ((num_frames == -1) || (num_frames-- > 0)) {
put_le32(seq, buf);
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] tools/l2test: Sort options alphabetically
2015-06-01 9:27 [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
2015-06-01 9:27 ` [PATCH 2/4] tools/l2test: Allow to send zero frames before delay Szymon Janc
@ 2015-06-01 9:27 ` Szymon Janc
2015-06-01 9:27 ` [PATCH 4/4] tools/l2test: Add -g option Szymon Janc
2015-06-01 12:56 ` [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2015-06-01 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
l2test has many options and sorting them will make it easier to find
unused one.
---
tools/l2test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/l2test.c b/tools/l2test.c
index dac98f9..55955d8 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -1343,8 +1343,8 @@ int main(int argc, char *argv[])
bacpy(&bdaddr, BDADDR_ANY);
- while ((opt = getopt(argc, argv, "rdscuwmntqxyzpb:a:"
- "i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMTe:")) != EOF) {
+ while ((opt = getopt(argc, argv, "a:b:cde:i:mnpqrstuwxyz"
+ "AB:C:D:EF:GH:I:J:K:L:MN:O:P:Q:RSTUV:W:X:Y:Z:")) != EOF) {
switch (opt) {
case 'r':
mode = RECV;
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] tools/l2test: Add -g option
2015-06-01 9:27 [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
2015-06-01 9:27 ` [PATCH 2/4] tools/l2test: Allow to send zero frames before delay Szymon Janc
2015-06-01 9:27 ` [PATCH 3/4] tools/l2test: Sort options alphabetically Szymon Janc
@ 2015-06-01 9:27 ` Szymon Janc
2015-06-01 12:56 ` [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2015-06-01 9:27 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This option allow to sleep before disconnecting socket.
---
tools/l2test.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/tools/l2test.c b/tools/l2test.c
index 55955d8..5148328 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -108,6 +108,9 @@ static unsigned long send_delay = 0;
/* Default delay before receiving */
static unsigned long recv_delay = 0;
+/* Default delay before disconnecting */
+static unsigned long disc_delay = 0;
+
/* Initial sequence value when sending frames */
static int seq_start = 0;
@@ -1013,6 +1016,9 @@ static void send_mode(int sk)
{
do_send(sk);
+ if (disc_delay)
+ usleep(disc_delay);
+
syslog(LOG_INFO, "Closing channel ...");
if (shutdown(sk, SHUT_RDWR) < 0)
syslog(LOG_INFO, "Close failed: %m");
@@ -1317,6 +1323,7 @@ static void usage(void)
"\t[-C num] send num frames before delay (default = 1)\n"
"\t[-D milliseconds] delay after sending num frames (default = 0)\n"
"\t[-K milliseconds] delay before receiving (default = 0)\n"
+ "\t[-g milliseconds] delay before disconnecting (default = 0)\n"
"\t[-X mode] l2cap mode (help for list, default = basic)\n"
"\t[-a policy] chan policy (help for list, default = bredr)\n"
"\t[-F fcs] use CRC16 check (default = 1)\n"
@@ -1554,6 +1561,10 @@ int main(int argc, char *argv[])
seq_start = atoi(optarg);
break;
+ case 'g':
+ disc_delay = atoi(optarg) * 1000;
+ break;
+
default:
usage();
exit(1);
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/4] tools/l2test: Add -e option
2015-06-01 9:27 [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
` (2 preceding siblings ...)
2015-06-01 9:27 ` [PATCH 4/4] tools/l2test: Add -g option Szymon Janc
@ 2015-06-01 12:56 ` Szymon Janc
3 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2015-06-01 12:56 UTC (permalink / raw)
To: linux-bluetooth
On Monday 01 of June 2015 11:27:04 Szymon Janc wrote:
> This allows to specify initial value for sequence when sending frames.
> ---
> tools/l2test.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/tools/l2test.c b/tools/l2test.c
> index 8065578..75603a8 100644
> --- a/tools/l2test.c
> +++ b/tools/l2test.c
> @@ -108,6 +108,9 @@ static unsigned long send_delay = 0;
> /* Default delay before receiving */
> static unsigned long recv_delay = 0;
>
> +/* Initial sequence value when sending frames */
> +static int seq_start = 0;
> +
> static char *filename = NULL;
>
> static int rfcmode = 0;
> @@ -974,7 +977,7 @@ static void do_send(int sk)
> buf[i] = 0x7f;
> }
>
> - seq = 0;
> + seq = seq_start;
> while ((num_frames == -1) || (num_frames-- > 0)) {
> put_le32(seq, buf);
> put_le16(data_size, buf + 4);
> @@ -997,7 +1000,8 @@ static void do_send(int sk)
> size -= len;
> }
>
> - if (num_frames && send_delay && count && !(seq % count))
> + if (num_frames && send_delay && count &&
> + !(seq % (count + seq_start)))
> usleep(send_delay);
> }
> }
> @@ -1325,7 +1329,8 @@ static void usage(void)
> "\t[-S] secure connection\n"
> "\t[-M] become master\n"
> "\t[-T] enable timestamps\n"
> - "\t[-V type] address type (help for list, default = bredr)\n");
> + "\t[-V type] address type (help for list, default = bredr)\n"
> + "\t[-e seq] initial sequence value (default = 0)\n");
> }
>
> int main(int argc, char *argv[])
> @@ -1336,7 +1341,7 @@ int main(int argc, char *argv[])
> bacpy(&bdaddr, BDADDR_ANY);
>
> while ((opt = getopt(argc, argv, "rdscuwmntqxyzpb:a:"
> - "i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMT")) != EOF) {
> + "i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMTe:")) != EOF) {
> switch (opt) {
> case 'r':
> mode = RECV;
> @@ -1542,6 +1547,10 @@ int main(int argc, char *argv[])
>
> break;
>
> + case 'e':
> + seq_start = atoi(optarg);
> + break;
> +
> default:
> usage();
> exit(1);
Applied.
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-01 12:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 9:27 [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
2015-06-01 9:27 ` [PATCH 2/4] tools/l2test: Allow to send zero frames before delay Szymon Janc
2015-06-01 9:27 ` [PATCH 3/4] tools/l2test: Sort options alphabetically Szymon Janc
2015-06-01 9:27 ` [PATCH 4/4] tools/l2test: Add -g option Szymon Janc
2015-06-01 12:56 ` [PATCH 1/4] tools/l2test: Add -e option Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).