From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/2] Bluez: l2test: enhance L2CAP mode option
Date: Tue, 5 Jul 2011 17:29:23 +0300 [thread overview]
Message-ID: <1309876163-30261-2-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1309876163-30261-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
test/l2test.c | 41 +++++++++++++++++++++++++++++++++++------
1 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/test/l2test.c b/test/l2test.c
index 3b606d2..44c617c 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -112,6 +112,28 @@ static int reliable = 0;
static int timestamp = 0;
static int defer_setup = 0;
+static struct {
+ char *name;
+ int flag;
+} l2cap_modes[] = {
+ { "basic", L2CAP_MODE_BASIC },
+ { "flowctl", L2CAP_MODE_FLOWCTL },
+ { "retrans", L2CAP_MODE_RETRANS },
+ { "ertm", L2CAP_MODE_ERTM },
+ { "streaming", L2CAP_MODE_STREAMING },
+ { 0 }
+};
+
+static void list_l2cap_modes(void)
+{
+ int i;
+
+ printf("l2test - L2CAP testing\n"
+ "List L2CAP modes:\n");
+ for (i=0; l2cap_modes[i].name; i++)
+ printf("\t%s\n", l2cap_modes[i].name);
+}
+
static float tv2fl(struct timeval tv)
{
return (float)tv.tv_sec + (float)(tv.tv_usec/1000000.0);
@@ -1083,7 +1105,7 @@ static void usage(void)
"\t[-N num] send num frames (default = infinite)\n"
"\t[-C num] send num frames before delay (default = 1)\n"
"\t[-D milliseconds] delay after sending num frames (default = 0)\n"
- "\t[-X mode] select retransmission/flow-control mode\n"
+ "\t[-X mode] l2cap mode(help for list, default = basic)\n"
"\t[-F fcs] use CRC16 check (default = 1)\n"
"\t[-Q num] Max Transmit value (default = 3)\n"
"\t[-Z size] Transmission Window size (default = 63)\n"
@@ -1100,7 +1122,7 @@ static void usage(void)
int main(int argc, char *argv[])
{
struct sigaction sa;
- int opt, sk, mode = RECV, need_addr = 0;
+ int opt, sk, i, mode = RECV, need_addr = 0;
bacpy(&bdaddr, BDADDR_ANY);
@@ -1218,10 +1240,17 @@ int main(int argc, char *argv[])
break;
case 'X':
- if (strcasecmp(optarg, "ertm") == 0)
- rfcmode = L2CAP_MODE_ERTM;
- else
- rfcmode = atoi(optarg);
+ rfcmode = -1;
+
+ for (i = 0; l2cap_modes[i].name; i++)
+ if (!strcasecmp(l2cap_modes[i].name, optarg))
+ rfcmode = l2cap_modes[i].flag;
+
+ if (!strcasecmp(optarg, "help") || rfcmode == -1) {
+ list_l2cap_modes();
+ exit(1);
+ }
+
break;
case 'F':
--
1.7.4.1
next prev parent reply other threads:[~2011-07-05 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-05 14:29 [PATCH 1/2] BlueZ: l2test: Use defined L2CAP extended feature mask Emeltchenko Andrei
2011-07-05 14:29 ` Emeltchenko Andrei [this message]
2011-07-05 15:57 ` [PATCH 2/2] Bluez: l2test: enhance L2CAP mode option Gustavo Padovan
2011-07-05 16:07 ` Daniele Forsi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309876163-30261-2-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox