linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, gustavo@padovan.org
Subject: [PATCH 2/4] Add duplex test case to l2test
Date: Tue, 30 Mar 2010 15:53:27 -0300	[thread overview]
Message-ID: <1269975209-10044-2-git-send-email-padovan@profusion.mobi> (raw)
In-Reply-To: <1269975209-10044-1-git-send-email-padovan@profusion.mobi>

Use a SOCK_NONBLOCK to send and receive at the same time.
---
 test/l2test.c |   43 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index bfffab2..d11992f 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -60,6 +60,8 @@ enum {
 	LSEND,
 	SENDDUMP,
 	LSENDDUMP,
+	LSENDRECV,
+	CSENDRECV,
 	INFOREQ,
 	PAIRING,
 };
@@ -775,6 +777,22 @@ static void senddump_mode(int sk)
 	dump_mode(sk);
 }
 
+static void send_and_recv_mode(int sk)
+{
+	int flags;
+
+	if ((flags = fcntl(sk, F_GETFL, 0)) < 0)
+		flags = 0;
+	fcntl(sk, F_SETFL, flags | O_NONBLOCK);
+
+	/* fork for duplex channel */
+	if (fork())
+		send_mode(sk);
+	else
+		recv_mode(sk);
+	return;
+}
+
 static void reconnect_mode(char *svr)
 {
 	while (1) {
@@ -1024,6 +1042,8 @@ static void usage(void)
 		"\t-w listen and send\n"
 		"\t-d listen and dump incoming data\n"
 		"\t-x listen, then send, then dump incoming data\n"
+		"\t-t listen, then send and receive at the same time\n"
+		"\t-q connect, then send and receive at the same time\n"
 		"\t-s connect and send\n"
 		"\t-u connect and receive\n"
 		"\t-n connect and be silent\n"
@@ -1061,7 +1081,7 @@ int main(int argc, char *argv[])
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmnxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RGUAESMT")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:RUGAESMT")) != EOF) {
 		switch(opt) {
 		case 'r':
 			mode = RECV;
@@ -1100,6 +1120,15 @@ int main(int argc, char *argv[])
 			need_addr = 1;
 			break;
 
+		case 't':
+			mode = LSENDRECV;
+			break;
+
+		case 'q':
+			mode = CSENDRECV;
+			need_addr = 1;
+			break;
+
 		case 'x':
 			mode = LSENDDUMP;
 			break;
@@ -1286,6 +1315,18 @@ int main(int argc, char *argv[])
 			do_listen(senddump_mode);
 			break;
 
+		case LSENDRECV:
+			do_listen(send_and_recv_mode);
+			break;
+
+		case CSENDRECV:
+			sk = do_connect(argv[optind]);
+			if (sk < 0)
+				exit(1);
+
+			send_and_recv_mode(sk);
+			break;
+
 		case INFOREQ:
 			info_request(argv[optind]);
 			exit(0);
-- 
1.6.4.4

  reply	other threads:[~2010-03-30 18:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-30 18:53 [PATCH 1/4] l2test: add option to use SOCK_STREAM Gustavo F. Padovan
2010-03-30 18:53 ` Gustavo F. Padovan [this message]
2010-03-30 18:53   ` [PATCH 3/4] Add txWindow and MaxTt to l2cap_options Gustavo F. Padovan
2010-03-30 18:53     ` [PATCH 4/4] Add options to test MaxTx and TxWindow Gustavo F. Padovan
2010-04-28 15:55 ` [PATCH 1/4] l2test: add option to use SOCK_STREAM Johan Hedberg

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=1269975209-10044-2-git-send-email-padovan@profusion.mobi \
    --to=padovan@profusion.mobi \
    --cc=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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;
as well as URLs for NNTP newsgroup(s).