diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2010-06-03 17:43:28 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-21 13:39:07 -0400 |
commit | 85eb53c6f719523dde9e0658823dffd2664d4d1c (patch) | |
tree | e26bfedce9df120ee6b7e939d8e690c61d2bf859 /net/bluetooth/l2cap.c | |
parent | 64988868637304330f7df20d08b965592312c531 (diff) |
Bluetooth: Change the way we set ERTM mode as mandatory
If the socket type is SOCK_STREAM we set Enhanced Retransmisson Mode or
Streaming Mode as mandatory. That means that we will close the channel
if the other side doesn't support or request the the mandatory mode.
Basic mode can't be set as mandatory.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/l2cap.c')
-rw-r--r-- | net/bluetooth/l2cap.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 65c6a989449a..e78a7504d09c 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -831,6 +831,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
831 | 831 | ||
832 | pi->imtu = l2cap_pi(parent)->imtu; | 832 | pi->imtu = l2cap_pi(parent)->imtu; |
833 | pi->omtu = l2cap_pi(parent)->omtu; | 833 | pi->omtu = l2cap_pi(parent)->omtu; |
834 | pi->conf_state = l2cap_pi(parent)->conf_state; | ||
834 | pi->mode = l2cap_pi(parent)->mode; | 835 | pi->mode = l2cap_pi(parent)->mode; |
835 | pi->fcs = l2cap_pi(parent)->fcs; | 836 | pi->fcs = l2cap_pi(parent)->fcs; |
836 | pi->max_tx = l2cap_pi(parent)->max_tx; | 837 | pi->max_tx = l2cap_pi(parent)->max_tx; |
@@ -841,10 +842,12 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
841 | } else { | 842 | } else { |
842 | pi->imtu = L2CAP_DEFAULT_MTU; | 843 | pi->imtu = L2CAP_DEFAULT_MTU; |
843 | pi->omtu = 0; | 844 | pi->omtu = 0; |
844 | if (enable_ertm && sk->sk_type == SOCK_STREAM) | 845 | if (enable_ertm && sk->sk_type == SOCK_STREAM) { |
845 | pi->mode = L2CAP_MODE_ERTM; | 846 | pi->mode = L2CAP_MODE_ERTM; |
846 | else | 847 | pi->conf_state |= L2CAP_CONF_STATE2_DEVICE; |
848 | } else { | ||
847 | pi->mode = L2CAP_MODE_BASIC; | 849 | pi->mode = L2CAP_MODE_BASIC; |
850 | } | ||
848 | pi->max_tx = L2CAP_DEFAULT_MAX_TX; | 851 | pi->max_tx = L2CAP_DEFAULT_MAX_TX; |
849 | pi->fcs = L2CAP_FCS_CRC16; | 852 | pi->fcs = L2CAP_FCS_CRC16; |
850 | pi->tx_win = L2CAP_DEFAULT_TX_WINDOW; | 853 | pi->tx_win = L2CAP_DEFAULT_TX_WINDOW; |
@@ -1925,6 +1928,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
1925 | l2cap_pi(sk)->mode = opts.mode; | 1928 | l2cap_pi(sk)->mode = opts.mode; |
1926 | switch (l2cap_pi(sk)->mode) { | 1929 | switch (l2cap_pi(sk)->mode) { |
1927 | case L2CAP_MODE_BASIC: | 1930 | case L2CAP_MODE_BASIC: |
1931 | l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_STATE2_DEVICE; | ||
1928 | break; | 1932 | break; |
1929 | case L2CAP_MODE_ERTM: | 1933 | case L2CAP_MODE_ERTM: |
1930 | case L2CAP_MODE_STREAMING: | 1934 | case L2CAP_MODE_STREAMING: |
@@ -2469,7 +2473,12 @@ static int l2cap_build_conf_req(struct sock *sk, void *data) | |||
2469 | switch (pi->mode) { | 2473 | switch (pi->mode) { |
2470 | case L2CAP_MODE_STREAMING: | 2474 | case L2CAP_MODE_STREAMING: |
2471 | case L2CAP_MODE_ERTM: | 2475 | case L2CAP_MODE_ERTM: |
2472 | pi->conf_state |= L2CAP_CONF_STATE2_DEVICE; | 2476 | if (!(pi->conf_state & L2CAP_CONF_STATE2_DEVICE)) { |
2477 | pi->mode = l2cap_select_mode(rfc.mode, | ||
2478 | pi->conn->feat_mask); | ||
2479 | break; | ||
2480 | } | ||
2481 | |||
2473 | if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask)) | 2482 | if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask)) |
2474 | l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); | 2483 | l2cap_send_disconn_req(pi->conn, sk, ECONNRESET); |
2475 | break; | 2484 | break; |
@@ -2602,7 +2611,12 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data) | |||
2602 | switch (pi->mode) { | 2611 | switch (pi->mode) { |
2603 | case L2CAP_MODE_STREAMING: | 2612 | case L2CAP_MODE_STREAMING: |
2604 | case L2CAP_MODE_ERTM: | 2613 | case L2CAP_MODE_ERTM: |
2605 | pi->conf_state |= L2CAP_CONF_STATE2_DEVICE; | 2614 | if (!(pi->conf_state & L2CAP_CONF_STATE2_DEVICE)) { |
2615 | pi->mode = l2cap_select_mode(rfc.mode, | ||
2616 | pi->conn->feat_mask); | ||
2617 | break; | ||
2618 | } | ||
2619 | |||
2606 | if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask)) | 2620 | if (!l2cap_mode_supported(pi->mode, pi->conn->feat_mask)) |
2607 | return -ECONNREFUSED; | 2621 | return -ECONNREFUSED; |
2608 | break; | 2622 | break; |