diff options
author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-10-06 05:07:01 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-10-12 06:06:05 -0400 |
commit | 2d7928184c3d8724064de282be4e3c3d70f39d32 (patch) | |
tree | 4997dbe597e980349eb1fa51a10f15c0064ce436 /net/bluetooth | |
parent | 4c89b6aad5b7c5c56dadca66af6ceae0addbf2bf (diff) |
Bluetooth: Fix L2CAP coding style
Follow the net subsystem coding style
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 316 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 62 |
2 files changed, 207 insertions, 171 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 867eda23435b..a032741c96e6 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -48,19 +48,20 @@ static LIST_HEAD(chan_list); | |||
48 | static DEFINE_RWLOCK(chan_list_lock); | 48 | static DEFINE_RWLOCK(chan_list_lock); |
49 | 49 | ||
50 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, | 50 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, |
51 | u8 code, u8 ident, u16 dlen, void *data); | 51 | u8 code, u8 ident, u16 dlen, void *data); |
52 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, | 52 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, |
53 | void *data); | 53 | void *data); |
54 | static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); | 54 | static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); |
55 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, | 55 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, |
56 | struct l2cap_chan *chan, int err); | 56 | struct l2cap_chan *chan, int err); |
57 | 57 | ||
58 | static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, | 58 | static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, |
59 | struct sk_buff_head *skbs, u8 event); | 59 | struct sk_buff_head *skbs, u8 event); |
60 | 60 | ||
61 | /* ---- L2CAP channels ---- */ | 61 | /* ---- L2CAP channels ---- */ |
62 | 62 | ||
63 | static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) | 63 | static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, |
64 | u16 cid) | ||
64 | { | 65 | { |
65 | struct l2cap_chan *c; | 66 | struct l2cap_chan *c; |
66 | 67 | ||
@@ -71,7 +72,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 | |||
71 | return NULL; | 72 | return NULL; |
72 | } | 73 | } |
73 | 74 | ||
74 | static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) | 75 | static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, |
76 | u16 cid) | ||
75 | { | 77 | { |
76 | struct l2cap_chan *c; | 78 | struct l2cap_chan *c; |
77 | 79 | ||
@@ -84,7 +86,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 | |||
84 | 86 | ||
85 | /* Find channel with given SCID. | 87 | /* Find channel with given SCID. |
86 | * Returns locked channel. */ | 88 | * Returns locked channel. */ |
87 | static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) | 89 | static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, |
90 | u16 cid) | ||
88 | { | 91 | { |
89 | struct l2cap_chan *c; | 92 | struct l2cap_chan *c; |
90 | 93 | ||
@@ -97,7 +100,8 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci | |||
97 | return c; | 100 | return c; |
98 | } | 101 | } |
99 | 102 | ||
100 | static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident) | 103 | static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, |
104 | u8 ident) | ||
101 | { | 105 | { |
102 | struct l2cap_chan *c; | 106 | struct l2cap_chan *c; |
103 | 107 | ||
@@ -178,7 +182,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) | |||
178 | static void __l2cap_state_change(struct l2cap_chan *chan, int state) | 182 | static void __l2cap_state_change(struct l2cap_chan *chan, int state) |
179 | { | 183 | { |
180 | BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), | 184 | BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), |
181 | state_to_string(state)); | 185 | state_to_string(state)); |
182 | 186 | ||
183 | chan->state = state; | 187 | chan->state = state; |
184 | chan->ops->state_change(chan, state); | 188 | chan->ops->state_change(chan, state); |
@@ -361,7 +365,7 @@ static void l2cap_seq_list_append(struct l2cap_seq_list *seq_list, u16 seq) | |||
361 | static void l2cap_chan_timeout(struct work_struct *work) | 365 | static void l2cap_chan_timeout(struct work_struct *work) |
362 | { | 366 | { |
363 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, | 367 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, |
364 | chan_timer.work); | 368 | chan_timer.work); |
365 | struct l2cap_conn *conn = chan->conn; | 369 | struct l2cap_conn *conn = chan->conn; |
366 | int reason; | 370 | int reason; |
367 | 371 | ||
@@ -373,7 +377,7 @@ static void l2cap_chan_timeout(struct work_struct *work) | |||
373 | if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) | 377 | if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) |
374 | reason = ECONNREFUSED; | 378 | reason = ECONNREFUSED; |
375 | else if (chan->state == BT_CONNECT && | 379 | else if (chan->state == BT_CONNECT && |
376 | chan->sec_level != BT_SECURITY_SDP) | 380 | chan->sec_level != BT_SECURITY_SDP) |
377 | reason = ECONNREFUSED; | 381 | reason = ECONNREFUSED; |
378 | else | 382 | else |
379 | reason = ETIMEDOUT; | 383 | reason = ETIMEDOUT; |
@@ -573,8 +577,8 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
573 | struct l2cap_conn *conn = chan->conn; | 577 | struct l2cap_conn *conn = chan->conn; |
574 | struct sock *sk = chan->sk; | 578 | struct sock *sk = chan->sk; |
575 | 579 | ||
576 | BT_DBG("chan %p state %s sk %p", chan, | 580 | BT_DBG("chan %p state %s sk %p", chan, state_to_string(chan->state), |
577 | state_to_string(chan->state), sk); | 581 | sk); |
578 | 582 | ||
579 | switch (chan->state) { | 583 | switch (chan->state) { |
580 | case BT_LISTEN: | 584 | case BT_LISTEN: |
@@ -585,7 +589,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
585 | case BT_CONNECTED: | 589 | case BT_CONNECTED: |
586 | case BT_CONFIG: | 590 | case BT_CONFIG: |
587 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 591 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && |
588 | conn->hcon->type == ACL_LINK) { | 592 | conn->hcon->type == ACL_LINK) { |
589 | __set_chan_timer(chan, sk->sk_sndtimeo); | 593 | __set_chan_timer(chan, sk->sk_sndtimeo); |
590 | l2cap_send_disconn_req(conn, chan, reason); | 594 | l2cap_send_disconn_req(conn, chan, reason); |
591 | } else | 595 | } else |
@@ -594,7 +598,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
594 | 598 | ||
595 | case BT_CONNECT2: | 599 | case BT_CONNECT2: |
596 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 600 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && |
597 | conn->hcon->type == ACL_LINK) { | 601 | conn->hcon->type == ACL_LINK) { |
598 | struct l2cap_conn_rsp rsp; | 602 | struct l2cap_conn_rsp rsp; |
599 | __u16 result; | 603 | __u16 result; |
600 | 604 | ||
@@ -609,7 +613,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
609 | rsp.result = cpu_to_le16(result); | 613 | rsp.result = cpu_to_le16(result); |
610 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | 614 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); |
611 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 615 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
612 | sizeof(rsp), &rsp); | 616 | sizeof(rsp), &rsp); |
613 | } | 617 | } |
614 | 618 | ||
615 | l2cap_chan_del(chan, reason); | 619 | l2cap_chan_del(chan, reason); |
@@ -691,7 +695,8 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn) | |||
691 | return id; | 695 | return id; |
692 | } | 696 | } |
693 | 697 | ||
694 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) | 698 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, |
699 | void *data) | ||
695 | { | 700 | { |
696 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); | 701 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); |
697 | u8 flags; | 702 | u8 flags; |
@@ -718,10 +723,10 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) | |||
718 | u16 flags; | 723 | u16 flags; |
719 | 724 | ||
720 | BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, | 725 | BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, |
721 | skb->priority); | 726 | skb->priority); |
722 | 727 | ||
723 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && | 728 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && |
724 | lmp_no_flush_capable(hcon->hdev)) | 729 | lmp_no_flush_capable(hcon->hdev)) |
725 | flags = ACL_START_NO_FLUSH; | 730 | flags = ACL_START_NO_FLUSH; |
726 | else | 731 | else |
727 | flags = ACL_START; | 732 | flags = ACL_START; |
@@ -1008,7 +1013,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) | |||
1008 | return; | 1013 | return; |
1009 | 1014 | ||
1010 | if (l2cap_chan_check_security(chan) && | 1015 | if (l2cap_chan_check_security(chan) && |
1011 | __l2cap_no_conn_pending(chan)) { | 1016 | __l2cap_no_conn_pending(chan)) { |
1012 | l2cap_start_connection(chan); | 1017 | l2cap_start_connection(chan); |
1013 | } | 1018 | } |
1014 | } else { | 1019 | } else { |
@@ -1020,8 +1025,8 @@ static void l2cap_do_start(struct l2cap_chan *chan) | |||
1020 | 1025 | ||
1021 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); | 1026 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); |
1022 | 1027 | ||
1023 | l2cap_send_cmd(conn, conn->info_ident, | 1028 | l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, |
1024 | L2CAP_INFO_REQ, sizeof(req), &req); | 1029 | sizeof(req), &req); |
1025 | } | 1030 | } |
1026 | } | 1031 | } |
1027 | 1032 | ||
@@ -1041,7 +1046,8 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) | |||
1041 | } | 1046 | } |
1042 | } | 1047 | } |
1043 | 1048 | ||
1044 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) | 1049 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, |
1050 | struct l2cap_chan *chan, int err) | ||
1045 | { | 1051 | { |
1046 | struct sock *sk = chan->sk; | 1052 | struct sock *sk = chan->sk; |
1047 | struct l2cap_disconn_req req; | 1053 | struct l2cap_disconn_req req; |
@@ -1062,8 +1068,8 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c | |||
1062 | 1068 | ||
1063 | req.dcid = cpu_to_le16(chan->dcid); | 1069 | req.dcid = cpu_to_le16(chan->dcid); |
1064 | req.scid = cpu_to_le16(chan->scid); | 1070 | req.scid = cpu_to_le16(chan->scid); |
1065 | l2cap_send_cmd(conn, l2cap_get_ident(conn), | 1071 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ, |
1066 | L2CAP_DISCONN_REQ, sizeof(req), &req); | 1072 | sizeof(req), &req); |
1067 | 1073 | ||
1068 | lock_sock(sk); | 1074 | lock_sock(sk); |
1069 | __l2cap_state_change(chan, BT_DISCONN); | 1075 | __l2cap_state_change(chan, BT_DISCONN); |
@@ -1092,13 +1098,13 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
1092 | 1098 | ||
1093 | if (chan->state == BT_CONNECT) { | 1099 | if (chan->state == BT_CONNECT) { |
1094 | if (!l2cap_chan_check_security(chan) || | 1100 | if (!l2cap_chan_check_security(chan) || |
1095 | !__l2cap_no_conn_pending(chan)) { | 1101 | !__l2cap_no_conn_pending(chan)) { |
1096 | l2cap_chan_unlock(chan); | 1102 | l2cap_chan_unlock(chan); |
1097 | continue; | 1103 | continue; |
1098 | } | 1104 | } |
1099 | 1105 | ||
1100 | if (!l2cap_mode_supported(chan->mode, conn->feat_mask) | 1106 | if (!l2cap_mode_supported(chan->mode, conn->feat_mask) |
1101 | && test_bit(CONF_STATE2_DEVICE, | 1107 | && test_bit(CONF_STATE2_DEVICE, |
1102 | &chan->conf_state)) { | 1108 | &chan->conf_state)) { |
1103 | l2cap_chan_close(chan, ECONNRESET); | 1109 | l2cap_chan_close(chan, ECONNRESET); |
1104 | l2cap_chan_unlock(chan); | 1110 | l2cap_chan_unlock(chan); |
@@ -1135,17 +1141,17 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
1135 | } | 1141 | } |
1136 | 1142 | ||
1137 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 1143 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
1138 | sizeof(rsp), &rsp); | 1144 | sizeof(rsp), &rsp); |
1139 | 1145 | ||
1140 | if (test_bit(CONF_REQ_SENT, &chan->conf_state) || | 1146 | if (test_bit(CONF_REQ_SENT, &chan->conf_state) || |
1141 | rsp.result != L2CAP_CR_SUCCESS) { | 1147 | rsp.result != L2CAP_CR_SUCCESS) { |
1142 | l2cap_chan_unlock(chan); | 1148 | l2cap_chan_unlock(chan); |
1143 | continue; | 1149 | continue; |
1144 | } | 1150 | } |
1145 | 1151 | ||
1146 | set_bit(CONF_REQ_SENT, &chan->conf_state); | 1152 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
1147 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 1153 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
1148 | l2cap_build_conf_req(chan, buf), buf); | 1154 | l2cap_build_conf_req(chan, buf), buf); |
1149 | chan->num_conf_req++; | 1155 | chan->num_conf_req++; |
1150 | } | 1156 | } |
1151 | 1157 | ||
@@ -1302,7 +1308,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) | |||
1302 | static void l2cap_info_timeout(struct work_struct *work) | 1308 | static void l2cap_info_timeout(struct work_struct *work) |
1303 | { | 1309 | { |
1304 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, | 1310 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, |
1305 | info_timer.work); | 1311 | info_timer.work); |
1306 | 1312 | ||
1307 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 1313 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
1308 | conn->info_ident = 0; | 1314 | conn->info_ident = 0; |
@@ -1356,7 +1362,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) | |||
1356 | static void security_timeout(struct work_struct *work) | 1362 | static void security_timeout(struct work_struct *work) |
1357 | { | 1363 | { |
1358 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, | 1364 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, |
1359 | security_timer.work); | 1365 | security_timer.work); |
1360 | 1366 | ||
1361 | BT_DBG("conn %p", conn); | 1367 | BT_DBG("conn %p", conn); |
1362 | 1368 | ||
@@ -1496,7 +1502,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1496 | 1502 | ||
1497 | /* PSM must be odd and lsb of upper byte must be 0 */ | 1503 | /* PSM must be odd and lsb of upper byte must be 0 */ |
1498 | if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid && | 1504 | if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid && |
1499 | chan->chan_type != L2CAP_CHAN_RAW) { | 1505 | chan->chan_type != L2CAP_CHAN_RAW) { |
1500 | err = -EINVAL; | 1506 | err = -EINVAL; |
1501 | goto done; | 1507 | goto done; |
1502 | } | 1508 | } |
@@ -1805,7 +1811,7 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan) | |||
1805 | skb = l2cap_ertm_seq_in_queue(&chan->tx_q, seq); | 1811 | skb = l2cap_ertm_seq_in_queue(&chan->tx_q, seq); |
1806 | if (!skb) { | 1812 | if (!skb) { |
1807 | BT_DBG("Error: Can't retransmit seq %d, frame missing", | 1813 | BT_DBG("Error: Can't retransmit seq %d, frame missing", |
1808 | seq); | 1814 | seq); |
1809 | continue; | 1815 | continue; |
1810 | } | 1816 | } |
1811 | 1817 | ||
@@ -1890,7 +1896,7 @@ static void l2cap_retransmit_all(struct l2cap_chan *chan, | |||
1890 | if (chan->unacked_frames) { | 1896 | if (chan->unacked_frames) { |
1891 | skb_queue_walk(&chan->tx_q, skb) { | 1897 | skb_queue_walk(&chan->tx_q, skb) { |
1892 | if (bt_cb(skb)->control.txseq == control->reqseq || | 1898 | if (bt_cb(skb)->control.txseq == control->reqseq || |
1893 | skb == chan->tx_send_head) | 1899 | skb == chan->tx_send_head) |
1894 | break; | 1900 | break; |
1895 | } | 1901 | } |
1896 | 1902 | ||
@@ -2191,7 +2197,7 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan, | |||
2191 | } | 2197 | } |
2192 | 2198 | ||
2193 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | 2199 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, |
2194 | u32 priority) | 2200 | u32 priority) |
2195 | { | 2201 | { |
2196 | struct sk_buff *skb; | 2202 | struct sk_buff *skb; |
2197 | int err; | 2203 | int err; |
@@ -2653,7 +2659,8 @@ fail: | |||
2653 | return NULL; | 2659 | return NULL; |
2654 | } | 2660 | } |
2655 | 2661 | ||
2656 | static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val) | 2662 | static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, |
2663 | unsigned long *val) | ||
2657 | { | 2664 | { |
2658 | struct l2cap_conf_opt *opt = *ptr; | 2665 | struct l2cap_conf_opt *opt = *ptr; |
2659 | int len; | 2666 | int len; |
@@ -2833,13 +2840,13 @@ static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) | |||
2833 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) | 2840 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) |
2834 | { | 2841 | { |
2835 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && | 2842 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && |
2836 | __l2cap_ews_supported(chan)) { | 2843 | __l2cap_ews_supported(chan)) { |
2837 | /* use extended control field */ | 2844 | /* use extended control field */ |
2838 | set_bit(FLAG_EXT_CTRL, &chan->flags); | 2845 | set_bit(FLAG_EXT_CTRL, &chan->flags); |
2839 | chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; | 2846 | chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; |
2840 | } else { | 2847 | } else { |
2841 | chan->tx_win = min_t(u16, chan->tx_win, | 2848 | chan->tx_win = min_t(u16, chan->tx_win, |
2842 | L2CAP_DEFAULT_TX_WINDOW); | 2849 | L2CAP_DEFAULT_TX_WINDOW); |
2843 | chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; | 2850 | chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; |
2844 | } | 2851 | } |
2845 | chan->ack_win = chan->tx_win; | 2852 | chan->ack_win = chan->tx_win; |
@@ -2879,7 +2886,7 @@ done: | |||
2879 | switch (chan->mode) { | 2886 | switch (chan->mode) { |
2880 | case L2CAP_MODE_BASIC: | 2887 | case L2CAP_MODE_BASIC: |
2881 | if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) && | 2888 | if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) && |
2882 | !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING)) | 2889 | !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING)) |
2883 | break; | 2890 | break; |
2884 | 2891 | ||
2885 | rfc.mode = L2CAP_MODE_BASIC; | 2892 | rfc.mode = L2CAP_MODE_BASIC; |
@@ -2890,7 +2897,7 @@ done: | |||
2890 | rfc.max_pdu_size = 0; | 2897 | rfc.max_pdu_size = 0; |
2891 | 2898 | ||
2892 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 2899 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2893 | (unsigned long) &rfc); | 2900 | (unsigned long) &rfc); |
2894 | break; | 2901 | break; |
2895 | 2902 | ||
2896 | case L2CAP_MODE_ERTM: | 2903 | case L2CAP_MODE_ERTM: |
@@ -2900,18 +2907,17 @@ done: | |||
2900 | rfc.monitor_timeout = 0; | 2907 | rfc.monitor_timeout = 0; |
2901 | 2908 | ||
2902 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - | 2909 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - |
2903 | L2CAP_EXT_HDR_SIZE - | 2910 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - |
2904 | L2CAP_SDULEN_SIZE - | 2911 | L2CAP_FCS_SIZE); |
2905 | L2CAP_FCS_SIZE); | ||
2906 | rfc.max_pdu_size = cpu_to_le16(size); | 2912 | rfc.max_pdu_size = cpu_to_le16(size); |
2907 | 2913 | ||
2908 | l2cap_txwin_setup(chan); | 2914 | l2cap_txwin_setup(chan); |
2909 | 2915 | ||
2910 | rfc.txwin_size = min_t(u16, chan->tx_win, | 2916 | rfc.txwin_size = min_t(u16, chan->tx_win, |
2911 | L2CAP_DEFAULT_TX_WINDOW); | 2917 | L2CAP_DEFAULT_TX_WINDOW); |
2912 | 2918 | ||
2913 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 2919 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2914 | (unsigned long) &rfc); | 2920 | (unsigned long) &rfc); |
2915 | 2921 | ||
2916 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) | 2922 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
2917 | l2cap_add_opt_efs(&ptr, chan); | 2923 | l2cap_add_opt_efs(&ptr, chan); |
@@ -2920,14 +2926,14 @@ done: | |||
2920 | break; | 2926 | break; |
2921 | 2927 | ||
2922 | if (chan->fcs == L2CAP_FCS_NONE || | 2928 | if (chan->fcs == L2CAP_FCS_NONE || |
2923 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { | 2929 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
2924 | chan->fcs = L2CAP_FCS_NONE; | 2930 | chan->fcs = L2CAP_FCS_NONE; |
2925 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 2931 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
2926 | } | 2932 | } |
2927 | 2933 | ||
2928 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | 2934 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) |
2929 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, | 2935 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, |
2930 | chan->tx_win); | 2936 | chan->tx_win); |
2931 | break; | 2937 | break; |
2932 | 2938 | ||
2933 | case L2CAP_MODE_STREAMING: | 2939 | case L2CAP_MODE_STREAMING: |
@@ -2939,13 +2945,12 @@ done: | |||
2939 | rfc.monitor_timeout = 0; | 2945 | rfc.monitor_timeout = 0; |
2940 | 2946 | ||
2941 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - | 2947 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - |
2942 | L2CAP_EXT_HDR_SIZE - | 2948 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - |
2943 | L2CAP_SDULEN_SIZE - | 2949 | L2CAP_FCS_SIZE); |
2944 | L2CAP_FCS_SIZE); | ||
2945 | rfc.max_pdu_size = cpu_to_le16(size); | 2950 | rfc.max_pdu_size = cpu_to_le16(size); |
2946 | 2951 | ||
2947 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 2952 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2948 | (unsigned long) &rfc); | 2953 | (unsigned long) &rfc); |
2949 | 2954 | ||
2950 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) | 2955 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
2951 | l2cap_add_opt_efs(&ptr, chan); | 2956 | l2cap_add_opt_efs(&ptr, chan); |
@@ -2954,7 +2959,7 @@ done: | |||
2954 | break; | 2959 | break; |
2955 | 2960 | ||
2956 | if (chan->fcs == L2CAP_FCS_NONE || | 2961 | if (chan->fcs == L2CAP_FCS_NONE || |
2957 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { | 2962 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
2958 | chan->fcs = L2CAP_FCS_NONE; | 2963 | chan->fcs = L2CAP_FCS_NONE; |
2959 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 2964 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
2960 | } | 2965 | } |
@@ -3046,7 +3051,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
3046 | case L2CAP_MODE_ERTM: | 3051 | case L2CAP_MODE_ERTM: |
3047 | if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { | 3052 | if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { |
3048 | chan->mode = l2cap_select_mode(rfc.mode, | 3053 | chan->mode = l2cap_select_mode(rfc.mode, |
3049 | chan->conn->feat_mask); | 3054 | chan->conn->feat_mask); |
3050 | break; | 3055 | break; |
3051 | } | 3056 | } |
3052 | 3057 | ||
@@ -3071,8 +3076,8 @@ done: | |||
3071 | if (chan->num_conf_rsp == 1) | 3076 | if (chan->num_conf_rsp == 1) |
3072 | return -ECONNREFUSED; | 3077 | return -ECONNREFUSED; |
3073 | 3078 | ||
3074 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3079 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
3075 | sizeof(rfc), (unsigned long) &rfc); | 3080 | (unsigned long) &rfc); |
3076 | } | 3081 | } |
3077 | 3082 | ||
3078 | if (result == L2CAP_CONF_SUCCESS) { | 3083 | if (result == L2CAP_CONF_SUCCESS) { |
@@ -3089,8 +3094,8 @@ done: | |||
3089 | 3094 | ||
3090 | if (remote_efs) { | 3095 | if (remote_efs) { |
3091 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && | 3096 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && |
3092 | efs.stype != L2CAP_SERV_NOTRAFIC && | 3097 | efs.stype != L2CAP_SERV_NOTRAFIC && |
3093 | efs.stype != chan->local_stype) { | 3098 | efs.stype != chan->local_stype) { |
3094 | 3099 | ||
3095 | result = L2CAP_CONF_UNACCEPT; | 3100 | result = L2CAP_CONF_UNACCEPT; |
3096 | 3101 | ||
@@ -3098,8 +3103,8 @@ done: | |||
3098 | return -ECONNREFUSED; | 3103 | return -ECONNREFUSED; |
3099 | 3104 | ||
3100 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3105 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
3101 | sizeof(efs), | 3106 | sizeof(efs), |
3102 | (unsigned long) &efs); | 3107 | (unsigned long) &efs); |
3103 | } else { | 3108 | } else { |
3104 | /* Send PENDING Conf Rsp */ | 3109 | /* Send PENDING Conf Rsp */ |
3105 | result = L2CAP_CONF_PENDING; | 3110 | result = L2CAP_CONF_PENDING; |
@@ -3122,10 +3127,8 @@ done: | |||
3122 | chan->remote_max_tx = rfc.max_transmit; | 3127 | chan->remote_max_tx = rfc.max_transmit; |
3123 | 3128 | ||
3124 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), | 3129 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), |
3125 | chan->conn->mtu - | 3130 | chan->conn->mtu - L2CAP_EXT_HDR_SIZE - |
3126 | L2CAP_EXT_HDR_SIZE - | 3131 | L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE); |
3127 | L2CAP_SDULEN_SIZE - | ||
3128 | L2CAP_FCS_SIZE); | ||
3129 | rfc.max_pdu_size = cpu_to_le16(size); | 3132 | rfc.max_pdu_size = cpu_to_le16(size); |
3130 | chan->remote_mps = size; | 3133 | chan->remote_mps = size; |
3131 | 3134 | ||
@@ -3137,36 +3140,35 @@ done: | |||
3137 | set_bit(CONF_MODE_DONE, &chan->conf_state); | 3140 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
3138 | 3141 | ||
3139 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3142 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
3140 | sizeof(rfc), (unsigned long) &rfc); | 3143 | sizeof(rfc), (unsigned long) &rfc); |
3141 | 3144 | ||
3142 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { | 3145 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { |
3143 | chan->remote_id = efs.id; | 3146 | chan->remote_id = efs.id; |
3144 | chan->remote_stype = efs.stype; | 3147 | chan->remote_stype = efs.stype; |
3145 | chan->remote_msdu = le16_to_cpu(efs.msdu); | 3148 | chan->remote_msdu = le16_to_cpu(efs.msdu); |
3146 | chan->remote_flush_to = | 3149 | chan->remote_flush_to = |
3147 | le32_to_cpu(efs.flush_to); | 3150 | le32_to_cpu(efs.flush_to); |
3148 | chan->remote_acc_lat = | 3151 | chan->remote_acc_lat = |
3149 | le32_to_cpu(efs.acc_lat); | 3152 | le32_to_cpu(efs.acc_lat); |
3150 | chan->remote_sdu_itime = | 3153 | chan->remote_sdu_itime = |
3151 | le32_to_cpu(efs.sdu_itime); | 3154 | le32_to_cpu(efs.sdu_itime); |
3152 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3155 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
3153 | sizeof(efs), (unsigned long) &efs); | 3156 | sizeof(efs), |
3157 | (unsigned long) &efs); | ||
3154 | } | 3158 | } |
3155 | break; | 3159 | break; |
3156 | 3160 | ||
3157 | case L2CAP_MODE_STREAMING: | 3161 | case L2CAP_MODE_STREAMING: |
3158 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), | 3162 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), |
3159 | chan->conn->mtu - | 3163 | chan->conn->mtu - L2CAP_EXT_HDR_SIZE - |
3160 | L2CAP_EXT_HDR_SIZE - | 3164 | L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE); |
3161 | L2CAP_SDULEN_SIZE - | ||
3162 | L2CAP_FCS_SIZE); | ||
3163 | rfc.max_pdu_size = cpu_to_le16(size); | 3165 | rfc.max_pdu_size = cpu_to_le16(size); |
3164 | chan->remote_mps = size; | 3166 | chan->remote_mps = size; |
3165 | 3167 | ||
3166 | set_bit(CONF_MODE_DONE, &chan->conf_state); | 3168 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
3167 | 3169 | ||
3168 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3170 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
3169 | sizeof(rfc), (unsigned long) &rfc); | 3171 | (unsigned long) &rfc); |
3170 | 3172 | ||
3171 | break; | 3173 | break; |
3172 | 3174 | ||
@@ -3187,7 +3189,8 @@ done: | |||
3187 | return ptr - data; | 3189 | return ptr - data; |
3188 | } | 3190 | } |
3189 | 3191 | ||
3190 | static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, void *data, u16 *result) | 3192 | static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
3193 | void *data, u16 *result) | ||
3191 | { | 3194 | { |
3192 | struct l2cap_conf_req *req = data; | 3195 | struct l2cap_conf_req *req = data; |
3193 | void *ptr = req->data; | 3196 | void *ptr = req->data; |
@@ -3214,7 +3217,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3214 | case L2CAP_CONF_FLUSH_TO: | 3217 | case L2CAP_CONF_FLUSH_TO: |
3215 | chan->flush_to = val; | 3218 | chan->flush_to = val; |
3216 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, | 3219 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, |
3217 | 2, chan->flush_to); | 3220 | 2, chan->flush_to); |
3218 | break; | 3221 | break; |
3219 | 3222 | ||
3220 | case L2CAP_CONF_RFC: | 3223 | case L2CAP_CONF_RFC: |
@@ -3222,13 +3225,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3222 | memcpy(&rfc, (void *)val, olen); | 3225 | memcpy(&rfc, (void *)val, olen); |
3223 | 3226 | ||
3224 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && | 3227 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && |
3225 | rfc.mode != chan->mode) | 3228 | rfc.mode != chan->mode) |
3226 | return -ECONNREFUSED; | 3229 | return -ECONNREFUSED; |
3227 | 3230 | ||
3228 | chan->fcs = 0; | 3231 | chan->fcs = 0; |
3229 | 3232 | ||
3230 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3233 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
3231 | sizeof(rfc), (unsigned long) &rfc); | 3234 | sizeof(rfc), (unsigned long) &rfc); |
3232 | break; | 3235 | break; |
3233 | 3236 | ||
3234 | case L2CAP_CONF_EWS: | 3237 | case L2CAP_CONF_EWS: |
@@ -3242,12 +3245,12 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3242 | memcpy(&efs, (void *)val, olen); | 3245 | memcpy(&efs, (void *)val, olen); |
3243 | 3246 | ||
3244 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && | 3247 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && |
3245 | efs.stype != L2CAP_SERV_NOTRAFIC && | 3248 | efs.stype != L2CAP_SERV_NOTRAFIC && |
3246 | efs.stype != chan->local_stype) | 3249 | efs.stype != chan->local_stype) |
3247 | return -ECONNREFUSED; | 3250 | return -ECONNREFUSED; |
3248 | 3251 | ||
3249 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3252 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), |
3250 | sizeof(efs), (unsigned long) &efs); | 3253 | (unsigned long) &efs); |
3251 | break; | 3254 | break; |
3252 | } | 3255 | } |
3253 | } | 3256 | } |
@@ -3270,10 +3273,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3270 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { | 3273 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { |
3271 | chan->local_msdu = le16_to_cpu(efs.msdu); | 3274 | chan->local_msdu = le16_to_cpu(efs.msdu); |
3272 | chan->local_sdu_itime = | 3275 | chan->local_sdu_itime = |
3273 | le32_to_cpu(efs.sdu_itime); | 3276 | le32_to_cpu(efs.sdu_itime); |
3274 | chan->local_acc_lat = le32_to_cpu(efs.acc_lat); | 3277 | chan->local_acc_lat = le32_to_cpu(efs.acc_lat); |
3275 | chan->local_flush_to = | 3278 | chan->local_flush_to = |
3276 | le32_to_cpu(efs.flush_to); | 3279 | le32_to_cpu(efs.flush_to); |
3277 | } | 3280 | } |
3278 | break; | 3281 | break; |
3279 | 3282 | ||
@@ -3288,7 +3291,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3288 | return ptr - data; | 3291 | return ptr - data; |
3289 | } | 3292 | } |
3290 | 3293 | ||
3291 | static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, u16 flags) | 3294 | static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, |
3295 | u16 result, u16 flags) | ||
3292 | { | 3296 | { |
3293 | struct l2cap_conf_rsp *rsp = data; | 3297 | struct l2cap_conf_rsp *rsp = data; |
3294 | void *ptr = rsp->data; | 3298 | void *ptr = rsp->data; |
@@ -3312,14 +3316,13 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) | |||
3312 | rsp.dcid = cpu_to_le16(chan->scid); | 3316 | rsp.dcid = cpu_to_le16(chan->scid); |
3313 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); | 3317 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); |
3314 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | 3318 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); |
3315 | l2cap_send_cmd(conn, chan->ident, | 3319 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
3316 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | ||
3317 | 3320 | ||
3318 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) | 3321 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) |
3319 | return; | 3322 | return; |
3320 | 3323 | ||
3321 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3324 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3322 | l2cap_build_conf_req(chan, buf), buf); | 3325 | l2cap_build_conf_req(chan, buf), buf); |
3323 | chan->num_conf_req++; | 3326 | chan->num_conf_req++; |
3324 | } | 3327 | } |
3325 | 3328 | ||
@@ -3374,7 +3377,8 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) | |||
3374 | } | 3377 | } |
3375 | } | 3378 | } |
3376 | 3379 | ||
3377 | static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3380 | static inline int l2cap_command_rej(struct l2cap_conn *conn, |
3381 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3378 | { | 3382 | { |
3379 | struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; | 3383 | struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; |
3380 | 3384 | ||
@@ -3382,7 +3386,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3382 | return 0; | 3386 | return 0; |
3383 | 3387 | ||
3384 | if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && | 3388 | if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && |
3385 | cmd->ident == conn->info_ident) { | 3389 | cmd->ident == conn->info_ident) { |
3386 | cancel_delayed_work(&conn->info_timer); | 3390 | cancel_delayed_work(&conn->info_timer); |
3387 | 3391 | ||
3388 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 3392 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
@@ -3422,7 +3426,7 @@ static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, | |||
3422 | 3426 | ||
3423 | /* Check if the ACL is secure enough (if not SDP) */ | 3427 | /* Check if the ACL is secure enough (if not SDP) */ |
3424 | if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) && | 3428 | if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) && |
3425 | !hci_conn_check_link_mode(conn->hcon)) { | 3429 | !hci_conn_check_link_mode(conn->hcon)) { |
3426 | conn->disc_reason = HCI_ERROR_AUTH_FAILURE; | 3430 | conn->disc_reason = HCI_ERROR_AUTH_FAILURE; |
3427 | result = L2CAP_CR_SEC_BLOCK; | 3431 | result = L2CAP_CR_SEC_BLOCK; |
3428 | goto response; | 3432 | goto response; |
@@ -3500,16 +3504,16 @@ sendresp: | |||
3500 | 3504 | ||
3501 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); | 3505 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); |
3502 | 3506 | ||
3503 | l2cap_send_cmd(conn, conn->info_ident, | 3507 | l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, |
3504 | L2CAP_INFO_REQ, sizeof(info), &info); | 3508 | sizeof(info), &info); |
3505 | } | 3509 | } |
3506 | 3510 | ||
3507 | if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && | 3511 | if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && |
3508 | result == L2CAP_CR_SUCCESS) { | 3512 | result == L2CAP_CR_SUCCESS) { |
3509 | u8 buf[128]; | 3513 | u8 buf[128]; |
3510 | set_bit(CONF_REQ_SENT, &chan->conf_state); | 3514 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
3511 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3515 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3512 | l2cap_build_conf_req(chan, buf), buf); | 3516 | l2cap_build_conf_req(chan, buf), buf); |
3513 | chan->num_conf_req++; | 3517 | chan->num_conf_req++; |
3514 | } | 3518 | } |
3515 | } | 3519 | } |
@@ -3521,7 +3525,8 @@ static int l2cap_connect_req(struct l2cap_conn *conn, | |||
3521 | return 0; | 3525 | return 0; |
3522 | } | 3526 | } |
3523 | 3527 | ||
3524 | static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3528 | static inline int l2cap_connect_rsp(struct l2cap_conn *conn, |
3529 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3525 | { | 3530 | { |
3526 | struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; | 3531 | struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; |
3527 | u16 scid, dcid, result, status; | 3532 | u16 scid, dcid, result, status; |
@@ -3535,7 +3540,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3535 | status = __le16_to_cpu(rsp->status); | 3540 | status = __le16_to_cpu(rsp->status); |
3536 | 3541 | ||
3537 | BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", | 3542 | BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", |
3538 | dcid, scid, result, status); | 3543 | dcid, scid, result, status); |
3539 | 3544 | ||
3540 | mutex_lock(&conn->chan_lock); | 3545 | mutex_lock(&conn->chan_lock); |
3541 | 3546 | ||
@@ -3568,7 +3573,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3568 | break; | 3573 | break; |
3569 | 3574 | ||
3570 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3575 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3571 | l2cap_build_conf_req(chan, req), req); | 3576 | l2cap_build_conf_req(chan, req), req); |
3572 | chan->num_conf_req++; | 3577 | chan->num_conf_req++; |
3573 | break; | 3578 | break; |
3574 | 3579 | ||
@@ -3616,7 +3621,9 @@ static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data, | |||
3616 | L2CAP_CONF_SUCCESS, flags), data); | 3621 | L2CAP_CONF_SUCCESS, flags), data); |
3617 | } | 3622 | } |
3618 | 3623 | ||
3619 | static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) | 3624 | static inline int l2cap_config_req(struct l2cap_conn *conn, |
3625 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, | ||
3626 | u8 *data) | ||
3620 | { | 3627 | { |
3621 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; | 3628 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; |
3622 | u16 dcid, flags; | 3629 | u16 dcid, flags; |
@@ -3641,7 +3648,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3641 | rej.dcid = cpu_to_le16(chan->dcid); | 3648 | rej.dcid = cpu_to_le16(chan->dcid); |
3642 | 3649 | ||
3643 | l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ, | 3650 | l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ, |
3644 | sizeof(rej), &rej); | 3651 | sizeof(rej), &rej); |
3645 | goto unlock; | 3652 | goto unlock; |
3646 | } | 3653 | } |
3647 | 3654 | ||
@@ -3649,8 +3656,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3649 | len = cmd_len - sizeof(*req); | 3656 | len = cmd_len - sizeof(*req); |
3650 | if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { | 3657 | if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { |
3651 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3658 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, |
3652 | l2cap_build_conf_rsp(chan, rsp, | 3659 | l2cap_build_conf_rsp(chan, rsp, |
3653 | L2CAP_CONF_REJECT, flags), rsp); | 3660 | L2CAP_CONF_REJECT, flags), rsp); |
3654 | goto unlock; | 3661 | goto unlock; |
3655 | } | 3662 | } |
3656 | 3663 | ||
@@ -3661,8 +3668,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3661 | if (flags & L2CAP_CONF_FLAG_CONTINUATION) { | 3668 | if (flags & L2CAP_CONF_FLAG_CONTINUATION) { |
3662 | /* Incomplete config. Send empty response. */ | 3669 | /* Incomplete config. Send empty response. */ |
3663 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3670 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, |
3664 | l2cap_build_conf_rsp(chan, rsp, | 3671 | l2cap_build_conf_rsp(chan, rsp, |
3665 | L2CAP_CONF_SUCCESS, flags), rsp); | 3672 | L2CAP_CONF_SUCCESS, flags), rsp); |
3666 | goto unlock; | 3673 | goto unlock; |
3667 | } | 3674 | } |
3668 | 3675 | ||
@@ -3700,7 +3707,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3700 | if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { | 3707 | if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { |
3701 | u8 buf[64]; | 3708 | u8 buf[64]; |
3702 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3709 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3703 | l2cap_build_conf_req(chan, buf), buf); | 3710 | l2cap_build_conf_req(chan, buf), buf); |
3704 | chan->num_conf_req++; | 3711 | chan->num_conf_req++; |
3705 | } | 3712 | } |
3706 | 3713 | ||
@@ -3719,7 +3726,8 @@ unlock: | |||
3719 | return err; | 3726 | return err; |
3720 | } | 3727 | } |
3721 | 3728 | ||
3722 | static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3729 | static inline int l2cap_config_rsp(struct l2cap_conn *conn, |
3730 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3723 | { | 3731 | { |
3724 | struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; | 3732 | struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; |
3725 | u16 scid, flags, result; | 3733 | u16 scid, flags, result; |
@@ -3751,7 +3759,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3751 | char buf[64]; | 3759 | char buf[64]; |
3752 | 3760 | ||
3753 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, | 3761 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
3754 | buf, &result); | 3762 | buf, &result); |
3755 | if (len < 0) { | 3763 | if (len < 0) { |
3756 | l2cap_send_disconn_req(conn, chan, ECONNRESET); | 3764 | l2cap_send_disconn_req(conn, chan, ECONNRESET); |
3757 | goto done; | 3765 | goto done; |
@@ -3775,14 +3783,14 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3775 | /* throw out any old stored conf requests */ | 3783 | /* throw out any old stored conf requests */ |
3776 | result = L2CAP_CONF_SUCCESS; | 3784 | result = L2CAP_CONF_SUCCESS; |
3777 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, | 3785 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
3778 | req, &result); | 3786 | req, &result); |
3779 | if (len < 0) { | 3787 | if (len < 0) { |
3780 | l2cap_send_disconn_req(conn, chan, ECONNRESET); | 3788 | l2cap_send_disconn_req(conn, chan, ECONNRESET); |
3781 | goto done; | 3789 | goto done; |
3782 | } | 3790 | } |
3783 | 3791 | ||
3784 | l2cap_send_cmd(conn, l2cap_get_ident(conn), | 3792 | l2cap_send_cmd(conn, l2cap_get_ident(conn), |
3785 | L2CAP_CONF_REQ, len, req); | 3793 | L2CAP_CONF_REQ, len, req); |
3786 | chan->num_conf_req++; | 3794 | chan->num_conf_req++; |
3787 | if (result != L2CAP_CONF_SUCCESS) | 3795 | if (result != L2CAP_CONF_SUCCESS) |
3788 | goto done; | 3796 | goto done; |
@@ -3820,7 +3828,8 @@ done: | |||
3820 | return err; | 3828 | return err; |
3821 | } | 3829 | } |
3822 | 3830 | ||
3823 | static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3831 | static inline int l2cap_disconnect_req(struct l2cap_conn *conn, |
3832 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3824 | { | 3833 | { |
3825 | struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; | 3834 | struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; |
3826 | struct l2cap_disconn_rsp rsp; | 3835 | struct l2cap_disconn_rsp rsp; |
@@ -3866,7 +3875,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd | |||
3866 | return 0; | 3875 | return 0; |
3867 | } | 3876 | } |
3868 | 3877 | ||
3869 | static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3878 | static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, |
3879 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3870 | { | 3880 | { |
3871 | struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; | 3881 | struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; |
3872 | u16 dcid, scid; | 3882 | u16 dcid, scid; |
@@ -3900,7 +3910,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd | |||
3900 | return 0; | 3910 | return 0; |
3901 | } | 3911 | } |
3902 | 3912 | ||
3903 | static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3913 | static inline int l2cap_information_req(struct l2cap_conn *conn, |
3914 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3904 | { | 3915 | { |
3905 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; | 3916 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; |
3906 | u16 type; | 3917 | u16 type; |
@@ -3917,14 +3928,14 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm | |||
3917 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); | 3928 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); |
3918 | if (!disable_ertm) | 3929 | if (!disable_ertm) |
3919 | feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING | 3930 | feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING |
3920 | | L2CAP_FEAT_FCS; | 3931 | | L2CAP_FEAT_FCS; |
3921 | if (enable_hs) | 3932 | if (enable_hs) |
3922 | feat_mask |= L2CAP_FEAT_EXT_FLOW | 3933 | feat_mask |= L2CAP_FEAT_EXT_FLOW |
3923 | | L2CAP_FEAT_EXT_WINDOW; | 3934 | | L2CAP_FEAT_EXT_WINDOW; |
3924 | 3935 | ||
3925 | put_unaligned_le32(feat_mask, rsp->data); | 3936 | put_unaligned_le32(feat_mask, rsp->data); |
3926 | l2cap_send_cmd(conn, cmd->ident, | 3937 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), |
3927 | L2CAP_INFO_RSP, sizeof(buf), buf); | 3938 | buf); |
3928 | } else if (type == L2CAP_IT_FIXED_CHAN) { | 3939 | } else if (type == L2CAP_IT_FIXED_CHAN) { |
3929 | u8 buf[12]; | 3940 | u8 buf[12]; |
3930 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; | 3941 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; |
@@ -3937,20 +3948,21 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm | |||
3937 | rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN); | 3948 | rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN); |
3938 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); | 3949 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); |
3939 | memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); | 3950 | memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); |
3940 | l2cap_send_cmd(conn, cmd->ident, | 3951 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), |
3941 | L2CAP_INFO_RSP, sizeof(buf), buf); | 3952 | buf); |
3942 | } else { | 3953 | } else { |
3943 | struct l2cap_info_rsp rsp; | 3954 | struct l2cap_info_rsp rsp; |
3944 | rsp.type = cpu_to_le16(type); | 3955 | rsp.type = cpu_to_le16(type); |
3945 | rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP); | 3956 | rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP); |
3946 | l2cap_send_cmd(conn, cmd->ident, | 3957 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), |
3947 | L2CAP_INFO_RSP, sizeof(rsp), &rsp); | 3958 | &rsp); |
3948 | } | 3959 | } |
3949 | 3960 | ||
3950 | return 0; | 3961 | return 0; |
3951 | } | 3962 | } |
3952 | 3963 | ||
3953 | static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3964 | static inline int l2cap_information_rsp(struct l2cap_conn *conn, |
3965 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3954 | { | 3966 | { |
3955 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; | 3967 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; |
3956 | u16 type, result; | 3968 | u16 type, result; |
@@ -3962,7 +3974,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
3962 | 3974 | ||
3963 | /* L2CAP Info req/rsp are unbound to channels, add extra checks */ | 3975 | /* L2CAP Info req/rsp are unbound to channels, add extra checks */ |
3964 | if (cmd->ident != conn->info_ident || | 3976 | if (cmd->ident != conn->info_ident || |
3965 | conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) | 3977 | conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) |
3966 | return 0; | 3978 | return 0; |
3967 | 3979 | ||
3968 | cancel_delayed_work(&conn->info_timer); | 3980 | cancel_delayed_work(&conn->info_timer); |
@@ -3987,7 +3999,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
3987 | conn->info_ident = l2cap_get_ident(conn); | 3999 | conn->info_ident = l2cap_get_ident(conn); |
3988 | 4000 | ||
3989 | l2cap_send_cmd(conn, conn->info_ident, | 4001 | l2cap_send_cmd(conn, conn->info_ident, |
3990 | L2CAP_INFO_REQ, sizeof(req), &req); | 4002 | L2CAP_INFO_REQ, sizeof(req), &req); |
3991 | } else { | 4003 | } else { |
3992 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 4004 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
3993 | conn->info_ident = 0; | 4005 | conn->info_ident = 0; |
@@ -4009,8 +4021,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
4009 | } | 4021 | } |
4010 | 4022 | ||
4011 | static inline int l2cap_create_channel_req(struct l2cap_conn *conn, | 4023 | static inline int l2cap_create_channel_req(struct l2cap_conn *conn, |
4012 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, | 4024 | struct l2cap_cmd_hdr *cmd, |
4013 | void *data) | 4025 | u16 cmd_len, void *data) |
4014 | { | 4026 | { |
4015 | struct l2cap_create_chan_req *req = data; | 4027 | struct l2cap_create_chan_req *req = data; |
4016 | struct l2cap_create_chan_rsp rsp; | 4028 | struct l2cap_create_chan_rsp rsp; |
@@ -4039,6 +4051,15 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn, | |||
4039 | return 0; | 4051 | return 0; |
4040 | } | 4052 | } |
4041 | 4053 | ||
4054 | static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn, | ||
4055 | struct l2cap_cmd_hdr *cmd, | ||
4056 | void *data) | ||
4057 | { | ||
4058 | BT_DBG("conn %p", conn); | ||
4059 | |||
4060 | return l2cap_connect_rsp(conn, cmd, data); | ||
4061 | } | ||
4062 | |||
4042 | static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, | 4063 | static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, |
4043 | u16 icid, u16 result) | 4064 | u16 icid, u16 result) |
4044 | { | 4065 | { |
@@ -4165,7 +4186,7 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, | |||
4165 | } | 4186 | } |
4166 | 4187 | ||
4167 | static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, | 4188 | static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, |
4168 | u16 to_multiplier) | 4189 | u16 to_multiplier) |
4169 | { | 4190 | { |
4170 | u16 max_latency; | 4191 | u16 max_latency; |
4171 | 4192 | ||
@@ -4186,7 +4207,8 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, | |||
4186 | } | 4207 | } |
4187 | 4208 | ||
4188 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | 4209 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, |
4189 | struct l2cap_cmd_hdr *cmd, u8 *data) | 4210 | struct l2cap_cmd_hdr *cmd, |
4211 | u8 *data) | ||
4190 | { | 4212 | { |
4191 | struct hci_conn *hcon = conn->hcon; | 4213 | struct hci_conn *hcon = conn->hcon; |
4192 | struct l2cap_conn_param_update_req *req; | 4214 | struct l2cap_conn_param_update_req *req; |
@@ -4208,7 +4230,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4208 | to_multiplier = __le16_to_cpu(req->to_multiplier); | 4230 | to_multiplier = __le16_to_cpu(req->to_multiplier); |
4209 | 4231 | ||
4210 | BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x", | 4232 | BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x", |
4211 | min, max, latency, to_multiplier); | 4233 | min, max, latency, to_multiplier); |
4212 | 4234 | ||
4213 | memset(&rsp, 0, sizeof(rsp)); | 4235 | memset(&rsp, 0, sizeof(rsp)); |
4214 | 4236 | ||
@@ -4219,7 +4241,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4219 | rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED); | 4241 | rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED); |
4220 | 4242 | ||
4221 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP, | 4243 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP, |
4222 | sizeof(rsp), &rsp); | 4244 | sizeof(rsp), &rsp); |
4223 | 4245 | ||
4224 | if (!err) | 4246 | if (!err) |
4225 | hci_le_conn_update(hcon, min, max, latency, to_multiplier); | 4247 | hci_le_conn_update(hcon, min, max, latency, to_multiplier); |
@@ -4228,7 +4250,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4228 | } | 4250 | } |
4229 | 4251 | ||
4230 | static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | 4252 | static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, |
4231 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) | 4253 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, |
4254 | u8 *data) | ||
4232 | { | 4255 | { |
4233 | int err = 0; | 4256 | int err = 0; |
4234 | 4257 | ||
@@ -4307,7 +4330,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | |||
4307 | } | 4330 | } |
4308 | 4331 | ||
4309 | static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, | 4332 | static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, |
4310 | struct l2cap_cmd_hdr *cmd, u8 *data) | 4333 | struct l2cap_cmd_hdr *cmd, u8 *data) |
4311 | { | 4334 | { |
4312 | switch (cmd->code) { | 4335 | switch (cmd->code) { |
4313 | case L2CAP_COMMAND_REJ: | 4336 | case L2CAP_COMMAND_REJ: |
@@ -4326,7 +4349,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, | |||
4326 | } | 4349 | } |
4327 | 4350 | ||
4328 | static inline void l2cap_sig_channel(struct l2cap_conn *conn, | 4351 | static inline void l2cap_sig_channel(struct l2cap_conn *conn, |
4329 | struct sk_buff *skb) | 4352 | struct sk_buff *skb) |
4330 | { | 4353 | { |
4331 | u8 *data = skb->data; | 4354 | u8 *data = skb->data; |
4332 | int len = skb->len; | 4355 | int len = skb->len; |
@@ -4343,7 +4366,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, | |||
4343 | 4366 | ||
4344 | cmd_len = le16_to_cpu(cmd.len); | 4367 | cmd_len = le16_to_cpu(cmd.len); |
4345 | 4368 | ||
4346 | BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident); | 4369 | BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, |
4370 | cmd.ident); | ||
4347 | 4371 | ||
4348 | if (cmd_len > len || !cmd.ident) { | 4372 | if (cmd_len > len || !cmd.ident) { |
4349 | BT_DBG("corrupted command"); | 4373 | BT_DBG("corrupted command"); |
@@ -4362,7 +4386,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, | |||
4362 | 4386 | ||
4363 | /* FIXME: Map err to a valid reason */ | 4387 | /* FIXME: Map err to a valid reason */ |
4364 | rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD); | 4388 | rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD); |
4365 | l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej); | 4389 | l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, |
4390 | sizeof(rej), &rej); | ||
4366 | } | 4391 | } |
4367 | 4392 | ||
4368 | data += cmd_len; | 4393 | data += cmd_len; |
@@ -4427,8 +4452,8 @@ static void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) | |||
4427 | } | 4452 | } |
4428 | } | 4453 | } |
4429 | 4454 | ||
4430 | static void append_skb_frag(struct sk_buff *skb, | 4455 | static void append_skb_frag(struct sk_buff *skb, struct sk_buff *new_frag, |
4431 | struct sk_buff *new_frag, struct sk_buff **last_frag) | 4456 | struct sk_buff **last_frag) |
4432 | { | 4457 | { |
4433 | /* skb->len reflects data in skb as well as all fragments | 4458 | /* skb->len reflects data in skb as well as all fragments |
4434 | * skb->data_len reflects only data in fragments | 4459 | * skb->data_len reflects only data in fragments |
@@ -4677,7 +4702,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq) | |||
4677 | 4702 | ||
4678 | if (chan->rx_state == L2CAP_RX_STATE_SREJ_SENT) { | 4703 | if (chan->rx_state == L2CAP_RX_STATE_SREJ_SENT) { |
4679 | if (__seq_offset(chan, txseq, chan->last_acked_seq) >= | 4704 | if (__seq_offset(chan, txseq, chan->last_acked_seq) >= |
4680 | chan->tx_win) { | 4705 | chan->tx_win) { |
4681 | /* See notes below regarding "double poll" and | 4706 | /* See notes below regarding "double poll" and |
4682 | * invalid packets. | 4707 | * invalid packets. |
4683 | */ | 4708 | */ |
@@ -4718,8 +4743,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq) | |||
4718 | } | 4743 | } |
4719 | 4744 | ||
4720 | if (__seq_offset(chan, txseq, chan->last_acked_seq) < | 4745 | if (__seq_offset(chan, txseq, chan->last_acked_seq) < |
4721 | __seq_offset(chan, chan->expected_tx_seq, | 4746 | __seq_offset(chan, chan->expected_tx_seq, chan->last_acked_seq)) { |
4722 | chan->last_acked_seq)){ | ||
4723 | BT_DBG("Duplicate - expected_tx_seq later than txseq"); | 4747 | BT_DBG("Duplicate - expected_tx_seq later than txseq"); |
4724 | return L2CAP_TXSEQ_DUPLICATE; | 4748 | return L2CAP_TXSEQ_DUPLICATE; |
4725 | } | 4749 | } |
@@ -5479,7 +5503,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5479 | } | 5503 | } |
5480 | 5504 | ||
5481 | if (!status && (chan->state == BT_CONNECTED || | 5505 | if (!status && (chan->state == BT_CONNECTED || |
5482 | chan->state == BT_CONFIG)) { | 5506 | chan->state == BT_CONFIG)) { |
5483 | struct sock *sk = chan->sk; | 5507 | struct sock *sk = chan->sk; |
5484 | 5508 | ||
5485 | clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); | 5509 | clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); |
@@ -5530,7 +5554,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5530 | rsp.result = cpu_to_le16(res); | 5554 | rsp.result = cpu_to_le16(res); |
5531 | rsp.status = cpu_to_le16(stat); | 5555 | rsp.status = cpu_to_le16(stat); |
5532 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 5556 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
5533 | sizeof(rsp), &rsp); | 5557 | sizeof(rsp), &rsp); |
5534 | 5558 | ||
5535 | if (!test_bit(CONF_REQ_SENT, &chan->conf_state) && | 5559 | if (!test_bit(CONF_REQ_SENT, &chan->conf_state) && |
5536 | res == L2CAP_CR_SUCCESS) { | 5560 | res == L2CAP_CR_SUCCESS) { |
@@ -5596,7 +5620,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5596 | 5620 | ||
5597 | if (skb->len > len) { | 5621 | if (skb->len > len) { |
5598 | BT_ERR("Frame is too long (len %d, expected len %d)", | 5622 | BT_ERR("Frame is too long (len %d, expected len %d)", |
5599 | skb->len, len); | 5623 | skb->len, len); |
5600 | l2cap_conn_unreliable(conn, ECOMM); | 5624 | l2cap_conn_unreliable(conn, ECOMM); |
5601 | goto drop; | 5625 | goto drop; |
5602 | } | 5626 | } |
@@ -5607,7 +5631,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5607 | goto drop; | 5631 | goto drop; |
5608 | 5632 | ||
5609 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), | 5633 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), |
5610 | skb->len); | 5634 | skb->len); |
5611 | conn->rx_len = len - skb->len; | 5635 | conn->rx_len = len - skb->len; |
5612 | } else { | 5636 | } else { |
5613 | BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len); | 5637 | BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len); |
@@ -5620,7 +5644,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5620 | 5644 | ||
5621 | if (skb->len > conn->rx_len) { | 5645 | if (skb->len > conn->rx_len) { |
5622 | BT_ERR("Fragment is too long (len %d, expected %d)", | 5646 | BT_ERR("Fragment is too long (len %d, expected %d)", |
5623 | skb->len, conn->rx_len); | 5647 | skb->len, conn->rx_len); |
5624 | kfree_skb(conn->rx_skb); | 5648 | kfree_skb(conn->rx_skb); |
5625 | conn->rx_skb = NULL; | 5649 | conn->rx_skb = NULL; |
5626 | conn->rx_len = 0; | 5650 | conn->rx_len = 0; |
@@ -5629,7 +5653,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5629 | } | 5653 | } |
5630 | 5654 | ||
5631 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), | 5655 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), |
5632 | skb->len); | 5656 | skb->len); |
5633 | conn->rx_len -= skb->len; | 5657 | conn->rx_len -= skb->len; |
5634 | 5658 | ||
5635 | if (!conn->rx_len) { | 5659 | if (!conn->rx_len) { |
@@ -5688,8 +5712,8 @@ int __init l2cap_init(void) | |||
5688 | return err; | 5712 | return err; |
5689 | 5713 | ||
5690 | if (bt_debugfs) { | 5714 | if (bt_debugfs) { |
5691 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, | 5715 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs, |
5692 | bt_debugfs, NULL, &l2cap_debugfs_fops); | 5716 | NULL, &l2cap_debugfs_fops); |
5693 | if (!l2cap_debugfs) | 5717 | if (!l2cap_debugfs) |
5694 | BT_ERR("Failed to create L2CAP debug file"); | 5718 | BT_ERR("Failed to create L2CAP debug file"); |
5695 | } | 5719 | } |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index ed2dfc942c3c..f95fc7ed0a09 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -40,7 +40,8 @@ static struct bt_sock_list l2cap_sk_list = { | |||
40 | 40 | ||
41 | static const struct proto_ops l2cap_sock_ops; | 41 | static const struct proto_ops l2cap_sock_ops; |
42 | static void l2cap_sock_init(struct sock *sk, struct sock *parent); | 42 | static void l2cap_sock_init(struct sock *sk, struct sock *parent); |
43 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); | 43 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
44 | int proto, gfp_t prio); | ||
44 | 45 | ||
45 | static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) | 46 | static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) |
46 | { | 47 | { |
@@ -106,7 +107,8 @@ done: | |||
106 | return err; | 107 | return err; |
107 | } | 108 | } |
108 | 109 | ||
109 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) | 110 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, |
111 | int alen, int flags) | ||
110 | { | 112 | { |
111 | struct sock *sk = sock->sk; | 113 | struct sock *sk = sock->sk; |
112 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 114 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -134,7 +136,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
134 | lock_sock(sk); | 136 | lock_sock(sk); |
135 | 137 | ||
136 | err = bt_sock_wait_state(sk, BT_CONNECTED, | 138 | err = bt_sock_wait_state(sk, BT_CONNECTED, |
137 | sock_sndtimeo(sk, flags & O_NONBLOCK)); | 139 | sock_sndtimeo(sk, flags & O_NONBLOCK)); |
138 | 140 | ||
139 | release_sock(sk); | 141 | release_sock(sk); |
140 | 142 | ||
@@ -185,7 +187,8 @@ done: | |||
185 | return err; | 187 | return err; |
186 | } | 188 | } |
187 | 189 | ||
188 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags) | 190 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, |
191 | int flags) | ||
189 | { | 192 | { |
190 | DECLARE_WAITQUEUE(wait, current); | 193 | DECLARE_WAITQUEUE(wait, current); |
191 | struct sock *sk = sock->sk, *nsk; | 194 | struct sock *sk = sock->sk, *nsk; |
@@ -241,7 +244,8 @@ done: | |||
241 | return err; | 244 | return err; |
242 | } | 245 | } |
243 | 246 | ||
244 | static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) | 247 | static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, |
248 | int *len, int peer) | ||
245 | { | 249 | { |
246 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; | 250 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; |
247 | struct sock *sk = sock->sk; | 251 | struct sock *sk = sock->sk; |
@@ -265,7 +269,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l | |||
265 | return 0; | 269 | return 0; |
266 | } | 270 | } |
267 | 271 | ||
268 | static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) | 272 | static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, |
273 | char __user *optval, int __user *optlen) | ||
269 | { | 274 | { |
270 | struct sock *sk = sock->sk; | 275 | struct sock *sk = sock->sk; |
271 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 276 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -308,7 +313,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us | |||
308 | break; | 313 | break; |
309 | case BT_SECURITY_HIGH: | 314 | case BT_SECURITY_HIGH: |
310 | opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | | 315 | opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | |
311 | L2CAP_LM_SECURE; | 316 | L2CAP_LM_SECURE; |
312 | break; | 317 | break; |
313 | default: | 318 | default: |
314 | opt = 0; | 319 | opt = 0; |
@@ -352,7 +357,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us | |||
352 | return err; | 357 | return err; |
353 | } | 358 | } |
354 | 359 | ||
355 | static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) | 360 | static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, |
361 | char __user *optval, int __user *optlen) | ||
356 | { | 362 | { |
357 | struct sock *sk = sock->sk; | 363 | struct sock *sk = sock->sk; |
358 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 364 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -376,7 +382,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
376 | switch (optname) { | 382 | switch (optname) { |
377 | case BT_SECURITY: | 383 | case BT_SECURITY: |
378 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 384 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
379 | chan->chan_type != L2CAP_CHAN_RAW) { | 385 | chan->chan_type != L2CAP_CHAN_RAW) { |
380 | err = -EINVAL; | 386 | err = -EINVAL; |
381 | break; | 387 | break; |
382 | } | 388 | } |
@@ -411,14 +417,14 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
411 | 417 | ||
412 | case BT_FLUSHABLE: | 418 | case BT_FLUSHABLE: |
413 | if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), | 419 | if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), |
414 | (u32 __user *) optval)) | 420 | (u32 __user *) optval)) |
415 | err = -EFAULT; | 421 | err = -EFAULT; |
416 | 422 | ||
417 | break; | 423 | break; |
418 | 424 | ||
419 | case BT_POWER: | 425 | case BT_POWER: |
420 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM | 426 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM |
421 | && sk->sk_type != SOCK_RAW) { | 427 | && sk->sk_type != SOCK_RAW) { |
422 | err = -EINVAL; | 428 | err = -EINVAL; |
423 | break; | 429 | break; |
424 | } | 430 | } |
@@ -466,7 +472,8 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) | |||
466 | return true; | 472 | return true; |
467 | } | 473 | } |
468 | 474 | ||
469 | static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) | 475 | static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, |
476 | char __user *optval, unsigned int optlen) | ||
470 | { | 477 | { |
471 | struct sock *sk = sock->sk; | 478 | struct sock *sk = sock->sk; |
472 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 479 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -565,7 +572,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
565 | return err; | 572 | return err; |
566 | } | 573 | } |
567 | 574 | ||
568 | static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) | 575 | static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, |
576 | char __user *optval, unsigned int optlen) | ||
569 | { | 577 | { |
570 | struct sock *sk = sock->sk; | 578 | struct sock *sk = sock->sk; |
571 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 579 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -588,7 +596,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
588 | switch (optname) { | 596 | switch (optname) { |
589 | case BT_SECURITY: | 597 | case BT_SECURITY: |
590 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 598 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
591 | chan->chan_type != L2CAP_CHAN_RAW) { | 599 | chan->chan_type != L2CAP_CHAN_RAW) { |
592 | err = -EINVAL; | 600 | err = -EINVAL; |
593 | break; | 601 | break; |
594 | } | 602 | } |
@@ -602,7 +610,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
602 | } | 610 | } |
603 | 611 | ||
604 | if (sec.level < BT_SECURITY_LOW || | 612 | if (sec.level < BT_SECURITY_LOW || |
605 | sec.level > BT_SECURITY_HIGH) { | 613 | sec.level > BT_SECURITY_HIGH) { |
606 | err = -EINVAL; | 614 | err = -EINVAL; |
607 | break; | 615 | break; |
608 | } | 616 | } |
@@ -628,7 +636,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
628 | 636 | ||
629 | /* or for ACL link */ | 637 | /* or for ACL link */ |
630 | } else if ((sk->sk_state == BT_CONNECT2 && | 638 | } else if ((sk->sk_state == BT_CONNECT2 && |
631 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || | 639 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || |
632 | sk->sk_state == BT_CONNECTED) { | 640 | sk->sk_state == BT_CONNECTED) { |
633 | if (!l2cap_chan_check_security(chan)) | 641 | if (!l2cap_chan_check_security(chan)) |
634 | set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); | 642 | set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); |
@@ -685,7 +693,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
685 | 693 | ||
686 | case BT_POWER: | 694 | case BT_POWER: |
687 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 695 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
688 | chan->chan_type != L2CAP_CHAN_RAW) { | 696 | chan->chan_type != L2CAP_CHAN_RAW) { |
689 | err = -EINVAL; | 697 | err = -EINVAL; |
690 | break; | 698 | break; |
691 | } | 699 | } |
@@ -721,7 +729,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
721 | } | 729 | } |
722 | 730 | ||
723 | if (chan->mode != L2CAP_MODE_ERTM && | 731 | if (chan->mode != L2CAP_MODE_ERTM && |
724 | chan->mode != L2CAP_MODE_STREAMING) { | 732 | chan->mode != L2CAP_MODE_STREAMING) { |
725 | err = -EOPNOTSUPP; | 733 | err = -EOPNOTSUPP; |
726 | break; | 734 | break; |
727 | } | 735 | } |
@@ -738,7 +746,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
738 | return err; | 746 | return err; |
739 | } | 747 | } |
740 | 748 | ||
741 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) | 749 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, |
750 | struct msghdr *msg, size_t len) | ||
742 | { | 751 | { |
743 | struct sock *sk = sock->sk; | 752 | struct sock *sk = sock->sk; |
744 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 753 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -763,7 +772,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
763 | return err; | 772 | return err; |
764 | } | 773 | } |
765 | 774 | ||
766 | static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) | 775 | static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
776 | struct msghdr *msg, size_t len, int flags) | ||
767 | { | 777 | { |
768 | struct sock *sk = sock->sk; | 778 | struct sock *sk = sock->sk; |
769 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 779 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
@@ -867,7 +877,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) | |||
867 | 877 | ||
868 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | 878 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) |
869 | err = bt_sock_wait_state(sk, BT_CLOSED, | 879 | err = bt_sock_wait_state(sk, BT_CLOSED, |
870 | sk->sk_lingertime); | 880 | sk->sk_lingertime); |
871 | } | 881 | } |
872 | 882 | ||
873 | if (!err && sk->sk_err) | 883 | if (!err && sk->sk_err) |
@@ -931,7 +941,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan) | |||
931 | } | 941 | } |
932 | 942 | ||
933 | sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, | 943 | sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, |
934 | GFP_ATOMIC); | 944 | GFP_ATOMIC); |
935 | if (!sk) | 945 | if (!sk) |
936 | return NULL; | 946 | return NULL; |
937 | 947 | ||
@@ -1161,7 +1171,8 @@ static struct proto l2cap_proto = { | |||
1161 | .obj_size = sizeof(struct l2cap_pinfo) | 1171 | .obj_size = sizeof(struct l2cap_pinfo) |
1162 | }; | 1172 | }; |
1163 | 1173 | ||
1164 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) | 1174 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
1175 | int proto, gfp_t prio) | ||
1165 | { | 1176 | { |
1166 | struct sock *sk; | 1177 | struct sock *sk; |
1167 | struct l2cap_chan *chan; | 1178 | struct l2cap_chan *chan; |
@@ -1206,7 +1217,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, | |||
1206 | sock->state = SS_UNCONNECTED; | 1217 | sock->state = SS_UNCONNECTED; |
1207 | 1218 | ||
1208 | if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && | 1219 | if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && |
1209 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) | 1220 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) |
1210 | return -ESOCKTNOSUPPORT; | 1221 | return -ESOCKTNOSUPPORT; |
1211 | 1222 | ||
1212 | if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) | 1223 | if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) |
@@ -1263,7 +1274,8 @@ int __init l2cap_init_sockets(void) | |||
1263 | goto error; | 1274 | goto error; |
1264 | } | 1275 | } |
1265 | 1276 | ||
1266 | err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); | 1277 | err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, |
1278 | NULL); | ||
1267 | if (err < 0) { | 1279 | if (err < 0) { |
1268 | BT_ERR("Failed to create L2CAP proc file"); | 1280 | BT_ERR("Failed to create L2CAP proc file"); |
1269 | bt_sock_unregister(BTPROTO_L2CAP); | 1281 | bt_sock_unregister(BTPROTO_L2CAP); |