[PATCH 4/4] tools/l2test: Add -g option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux