[PATCH 3/3] l2test: Add BT Channel Policy option

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

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Make l2test able to set channel policy socket option.
---
 test/l2test.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index ce20bb3..7f97774 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -116,6 +116,7 @@ static int timestamp = 0;
 static int defer_setup = 0;
 static int priority = -1;
 static int rcvbuf = 0;
+static int chan_policy = 0;
 
 struct lookup_table {
 	char	*name;
@@ -133,6 +134,13 @@ static struct lookup_table l2cap_modes[] = {
 	{ 0 }
 };
 
+static struct lookup_table chan_policies[] = {
+	{ "bredr",	BT_CHANNEL_POLICY_BREDR_ONLY		},
+	{ "bredr_pref",	BT_CHANNEL_POLICY_BREDR_PREFERRED	},
+	{ "amp_pref",	BT_CHANNEL_POLICY_AMP_PREFERRED		},
+	{ NULL,		0					},
+};
+
 static int get_lookup_flag(struct lookup_table *table, char *name)
 {
 	int i;
@@ -296,6 +304,15 @@ static int do_connect(char *svr)
 	}
 #endif
 
+	if (chan_policy != -1) {
+		if (setsockopt(sk, SOL_BLUETOOTH, BT_CHANNEL_POLICY,
+				&chan_policy, sizeof(chan_policy)) < 0) {
+			syslog(LOG_ERR, "Can't enable chan policy : %s (%d)",
+							strerror(errno), errno);
+			goto error;
+		}
+	}
+
 	/* Enable SO_LINGER */
 	if (linger) {
 		struct linger l = { .l_onoff = 1, .l_linger = linger };
@@ -1216,7 +1233,7 @@ int main(int argc, char *argv[])
 
 	bacpy(&bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:RUGAESMT")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:RUGAESMTa:")) != EOF) {
 		switch(opt) {
 		case 'r':
 			mode = RECV;
@@ -1339,8 +1356,17 @@ int main(int argc, char *argv[])
 			if (rfcmode == -1) {
 				print_lookup_values(l2cap_modes,
 						"List L2CAP modes:");
+				exit(1);
+			}
+
+			break;
 
+		case 'a':
+			chan_policy = get_lookup_flag(chan_policies, optarg);
 
+			if (chan_policy == -1) {
+				print_lookup_values(chan_policies,
+						"List L2CAP chan policies:");
 				exit(1);
 			}
 
-- 
1.7.9

--
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