diff options
author | Simon Mikuda <simon.mikuda@streamunlimited.com> | 2023-03-28 07:26:19 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2023-03-28 13:49:35 -0700 |
commit | 54601cbcf283468ecb867d3db14ddbd1badbe858 (patch) | |
tree | d47b29e1c5e65cdf7b810c7f356104127357f2da /tools | |
parent | cedace72c3f71d356fc1895787569c7412ee94b2 (diff) | |
download | bluez-54601cbcf283468ecb867d3db14ddbd1badbe858.tar.gz |
l2test: Fix setting mode for BR/EDR l2cap socket
BT_MODE_* enums are used only for socket SOL_BLUETOOTH, option BT_MODE
Otherwise we should use L2CAP_MODE_* enums.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/l2test.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/l2test.c b/tools/l2test.c index 232247b78..011a68c37 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -155,6 +155,24 @@ static struct lookup_table bdaddr_types[] = { { NULL, 0 }, }; +static int bt_mode_to_l2cap_mode(int mode) +{ + switch (mode) { + case BT_MODE_BASIC: + return L2CAP_MODE_BASIC; + case BT_MODE_ERTM: + return L2CAP_MODE_ERTM; + case BT_MODE_STREAMING: + return L2CAP_MODE_STREAMING; + case BT_MODE_LE_FLOWCTL: + return L2CAP_MODE_LE_FLOWCTL; + case BT_MODE_EXT_FLOWCTL: + return L2CAP_MODE_FLOWCTL; + default: + return mode; + } +} + static int get_lookup_flag(struct lookup_table *table, char *name) { int i; @@ -287,9 +305,11 @@ static int getopts(int sk, struct l2cap_options *opts, bool connected) static int setopts(int sk, struct l2cap_options *opts) { - if (bdaddr_type == BDADDR_BREDR) + if (bdaddr_type == BDADDR_BREDR) { + opts->mode = bt_mode_to_l2cap_mode(opts->mode); return setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts, sizeof(*opts)); + } if (opts->mode) { if (setsockopt(sk, SOL_BLUETOOTH, BT_MODE, &opts->mode, |