summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-06-05 10:58:01 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2020-06-05 11:16:40 -0700
commit81629d982c672e4b3288c4499f9912f60f7040e9 (patch)
tree87b560546377a4124904a5ae5aa6183ea89a6c35
parent9bc0b090e202dfc4bd31c0212778941875e7a5ef (diff)
downloadbluez-81629d982c672e4b3288c4499f9912f60f7040e9.tar.gz
btio: Fix not translation mode to L2CAP mode
When using L2CAP_OPTIONS legacy modes need to be used since they are not compatible with BT_MODE.
-rw-r--r--btio/btio.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/btio/btio.c b/btio/btio.c
index 13c731062..844d6007f 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -597,6 +597,20 @@ static gboolean get_key_size(int sock, int *size, GError **err)
return FALSE;
}
+static uint8_t mode_l2mode(uint8_t mode)
+{
+ switch (mode) {
+ case BT_IO_MODE_BASIC:
+ return L2CAP_MODE_BASIC;
+ case BT_IO_MODE_ERTM:
+ return L2CAP_MODE_ERTM;
+ case BT_IO_MODE_STREAMING:
+ return L2CAP_MODE_STREAMING;
+ default:
+ return UINT8_MAX;
+ }
+}
+
static gboolean set_l2opts(int sock, uint16_t imtu, uint16_t omtu,
uint8_t mode, GError **err)
{
@@ -614,8 +628,14 @@ static gboolean set_l2opts(int sock, uint16_t imtu, uint16_t omtu,
l2o.imtu = imtu;
if (omtu)
l2o.omtu = omtu;
- if (mode)
- l2o.mode = mode;
+
+ if (mode) {
+ l2o.mode = mode_l2mode(mode);
+ if (l2o.mode == UINT8_MAX) {
+ ERROR_FAILED(err, "Unsupported mode", errno);
+ return FALSE;
+ }
+ }
if (setsockopt(sock, SOL_L2CAP, L2CAP_OPTIONS, &l2o, sizeof(l2o)) < 0) {
ERROR_FAILED(err, "setsockopt(L2CAP_OPTIONS)", errno);