diff options
author | João Paulo Rechi Vita <jprvita@profusion.mobi> | 2010-05-01 15:15:42 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-05-10 03:28:51 -0400 |
commit | 0041ecfa3025d7612fdaab12b2f07c9c3c09f42f (patch) | |
tree | c0d3012f5fb96a05ed05033270a1fcf4be1c4555 /net/bluetooth/l2cap.c | |
parent | bd3c9e255e76ae232d417e3914ca5d80ca3e9485 (diff) |
Bluetooth: Check if mode is supported on getsockopt
Add this check to getsockopt makes possible to fail early instead of
waiting until listen / connect.
Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/l2cap.c')
-rw-r--r-- | net/bluetooth/l2cap.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 1a32562adf46..bf5bb7dc6abf 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -1814,9 +1814,22 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
1814 | break; | 1814 | break; |
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | l2cap_pi(sk)->mode = opts.mode; | ||
1818 | switch (l2cap_pi(sk)->mode) { | ||
1819 | case L2CAP_MODE_BASIC: | ||
1820 | break; | ||
1821 | case L2CAP_MODE_ERTM: | ||
1822 | case L2CAP_MODE_STREAMING: | ||
1823 | if (enable_ertm) | ||
1824 | break; | ||
1825 | /* fall through */ | ||
1826 | default: | ||
1827 | err = -EINVAL; | ||
1828 | break; | ||
1829 | } | ||
1830 | |||
1817 | l2cap_pi(sk)->imtu = opts.imtu; | 1831 | l2cap_pi(sk)->imtu = opts.imtu; |
1818 | l2cap_pi(sk)->omtu = opts.omtu; | 1832 | l2cap_pi(sk)->omtu = opts.omtu; |
1819 | l2cap_pi(sk)->mode = opts.mode; | ||
1820 | l2cap_pi(sk)->fcs = opts.fcs; | 1833 | l2cap_pi(sk)->fcs = opts.fcs; |
1821 | l2cap_pi(sk)->max_tx = opts.max_tx; | 1834 | l2cap_pi(sk)->max_tx = opts.max_tx; |
1822 | l2cap_pi(sk)->tx_win = (__u8)opts.txwin_size; | 1835 | l2cap_pi(sk)->tx_win = (__u8)opts.txwin_size; |