summaryrefslogtreecommitdiffstats
path: root/common/glib-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/glib-helper.c')
-rw-r--r--common/glib-helper.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index 7810ba7e..8fa8efcf 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -440,8 +440,11 @@ static int sco_connect(struct io_context *io_ctxt, const bdaddr_t *src,
}
static int l2cap_connect(struct io_context *io_ctxt, const bdaddr_t *src,
- const bdaddr_t *dst, uint16_t psm)
+ const bdaddr_t *dst, uint16_t psm,
+ uint16_t mtu)
{
+ struct l2cap_options l2o;
+ socklen_t olen;
struct sockaddr_l2 l2a;
int sk, err;
@@ -449,6 +452,14 @@ static int l2cap_connect(struct io_context *io_ctxt, const bdaddr_t *src,
if (sk < 0)
return -errno;
+ if (mtu) {
+ memset(&l2o, 0, sizeof(l2o));
+ olen = sizeof(l2o);
+ getsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &l2o, &olen);
+ l2o.imtu = l2o.omtu = mtu;
+ setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, &l2o, sizeof(l2o));
+ }
+
memset(&l2a, 0, sizeof(l2a));
l2a.l2_family = AF_BLUETOOTH;
bacpy(&l2a.l2_bdaddr, src);
@@ -551,7 +562,7 @@ int bt_rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
}
int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst,
- uint16_t psm, bt_io_callback_t cb, void *user_data)
+ uint16_t psm, uint16_t mtu, bt_io_callback_t cb, void *user_data)
{
struct io_context *io_ctxt;
int err;
@@ -560,7 +571,7 @@ int bt_l2cap_connect(const bdaddr_t *src, const bdaddr_t *dst,
if (err < 0)
return err;
- err = l2cap_connect(io_ctxt, src, dst, psm);
+ err = l2cap_connect(io_ctxt, src, dst, psm, mtu);
if (err < 0) {
io_context_cleanup(io_ctxt);
return err;