linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] lib: Add flag to double L2CAP IMTU size used for SDP connection
@ 2014-01-20  0:31 Szymon Janc
  2014-01-20  0:31 ` [PATCH 2/5] core: Opencode get_sdp_session in sdp-client Szymon Janc
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Szymon Janc @ 2014-01-20  0:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This will allow to workaround Dualshock4 not respecting L2CAP MTU
size while sending SDP response.
---
 lib/sdp.c     | 22 ++++++++++++++++++++++
 lib/sdp_lib.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/lib/sdp.c b/lib/sdp.c
index 886e7cf..4d9a4bb 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -4644,6 +4644,25 @@ static int sdp_connect_local(sdp_session_t *session)
 	return connect(session->sock, (struct sockaddr *) &sa, sizeof(sa));
 }
 
+static int double_l2cap_imtu(int sk)
+{
+	struct l2cap_options l2o;
+	socklen_t len;
+
+	memset(&l2o, 0, sizeof(l2o));
+	len = sizeof(l2o);
+
+	if (getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &len) < 0)
+		return -1;
+
+	l2o.imtu = 2 * l2o.imtu;
+
+	if (setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &l2o, sizeof(l2o)) < 0)
+		return -1;
+
+	return 0;
+}
+
 static int sdp_connect_l2cap(const bdaddr_t *src,
 		const bdaddr_t *dst, sdp_session_t *session)
 {
@@ -4678,6 +4697,9 @@ static int sdp_connect_l2cap(const bdaddr_t *src,
 		setsockopt(sk, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
 	}
 
+	if ((flags & SDP_DOUBLE_IMTU) && double_l2cap_imtu(sk) < 0)
+		return -1;
+
 	sa.l2_psm = htobs(SDP_PSM);
 	sa.l2_bdaddr = *dst;
 
diff --git a/lib/sdp_lib.h b/lib/sdp_lib.h
index 6e1eb91..56ba2ea 100644
--- a/lib/sdp_lib.h
+++ b/lib/sdp_lib.h
@@ -81,6 +81,7 @@ static inline void sdp_list_foreach(sdp_list_t *list, sdp_list_func_t f, void *u
 #define SDP_RETRY_IF_BUSY	0x01
 #define SDP_WAIT_ON_CLOSE	0x02
 #define SDP_NON_BLOCKING	0x04
+#define SDP_DOUBLE_IMTU		0x08
 
 /*
  * a session with an SDP server
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-20 20:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-20  0:31 [PATCH 1/5] lib: Add flag to double L2CAP IMTU size used for SDP connection Szymon Janc
2014-01-20  0:31 ` [PATCH 2/5] core: Opencode get_sdp_session in sdp-client Szymon Janc
2014-01-20  0:31 ` [PATCH 3/5] core: Add flags parameter to bt_search_service Szymon Janc
2014-01-20  0:31 ` [PATCH 4/5] device: Add workaround for Sony Dualshock 4 broken SDP Szymon Janc
2014-01-20  0:31 ` [PATCH 5/5] device: Match Dualshock4 with name and class Szymon Janc
2014-01-20 17:31 ` [PATCH 1/5] lib: Add flag to double L2CAP IMTU size used for SDP connection simon
2014-01-20 20:00   ` 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).