diff options
Diffstat (limited to 'net/bluetooth/l2cap.c')
-rw-r--r-- | net/bluetooth/l2cap.c | 306 |
1 files changed, 204 insertions, 102 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 36ef27b625db..6fbbae78b304 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -55,7 +55,9 @@ | |||
55 | #define BT_DBG(D...) | 55 | #define BT_DBG(D...) |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #define VERSION "2.8" | 58 | #define VERSION "2.9" |
59 | |||
60 | static u32 l2cap_feat_mask = 0x0000; | ||
59 | 61 | ||
60 | static const struct proto_ops l2cap_sock_ops; | 62 | static const struct proto_ops l2cap_sock_ops; |
61 | 63 | ||
@@ -258,7 +260,119 @@ static void l2cap_chan_del(struct sock *sk, int err) | |||
258 | sk->sk_state_change(sk); | 260 | sk->sk_state_change(sk); |
259 | } | 261 | } |
260 | 262 | ||
263 | static inline u8 l2cap_get_ident(struct l2cap_conn *conn) | ||
264 | { | ||
265 | u8 id; | ||
266 | |||
267 | /* Get next available identificator. | ||
268 | * 1 - 128 are used by kernel. | ||
269 | * 129 - 199 are reserved. | ||
270 | * 200 - 254 are used by utilities like l2ping, etc. | ||
271 | */ | ||
272 | |||
273 | spin_lock_bh(&conn->lock); | ||
274 | |||
275 | if (++conn->tx_ident > 128) | ||
276 | conn->tx_ident = 1; | ||
277 | |||
278 | id = conn->tx_ident; | ||
279 | |||
280 | spin_unlock_bh(&conn->lock); | ||
281 | |||
282 | return id; | ||
283 | } | ||
284 | |||
285 | static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) | ||
286 | { | ||
287 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); | ||
288 | |||
289 | BT_DBG("code 0x%2.2x", code); | ||
290 | |||
291 | if (!skb) | ||
292 | return -ENOMEM; | ||
293 | |||
294 | return hci_send_acl(conn->hcon, skb, 0); | ||
295 | } | ||
296 | |||
261 | /* ---- L2CAP connections ---- */ | 297 | /* ---- L2CAP connections ---- */ |
298 | static void l2cap_conn_start(struct l2cap_conn *conn) | ||
299 | { | ||
300 | struct l2cap_chan_list *l = &conn->chan_list; | ||
301 | struct sock *sk; | ||
302 | |||
303 | BT_DBG("conn %p", conn); | ||
304 | |||
305 | read_lock(&l->lock); | ||
306 | |||
307 | for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) { | ||
308 | bh_lock_sock(sk); | ||
309 | |||
310 | if (sk->sk_type != SOCK_SEQPACKET) { | ||
311 | l2cap_sock_clear_timer(sk); | ||
312 | sk->sk_state = BT_CONNECTED; | ||
313 | sk->sk_state_change(sk); | ||
314 | } else if (sk->sk_state == BT_CONNECT) { | ||
315 | struct l2cap_conn_req req; | ||
316 | l2cap_pi(sk)->ident = l2cap_get_ident(conn); | ||
317 | req.scid = cpu_to_le16(l2cap_pi(sk)->scid); | ||
318 | req.psm = l2cap_pi(sk)->psm; | ||
319 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | ||
320 | L2CAP_CONN_REQ, sizeof(req), &req); | ||
321 | } | ||
322 | |||
323 | bh_unlock_sock(sk); | ||
324 | } | ||
325 | |||
326 | read_unlock(&l->lock); | ||
327 | } | ||
328 | |||
329 | static void l2cap_conn_ready(struct l2cap_conn *conn) | ||
330 | { | ||
331 | BT_DBG("conn %p", conn); | ||
332 | |||
333 | if (conn->chan_list.head || !hlist_empty(&l2cap_sk_list.head)) { | ||
334 | struct l2cap_info_req req; | ||
335 | |||
336 | req.type = cpu_to_le16(L2CAP_IT_FEAT_MASK); | ||
337 | |||
338 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT; | ||
339 | conn->info_ident = l2cap_get_ident(conn); | ||
340 | |||
341 | mod_timer(&conn->info_timer, | ||
342 | jiffies + msecs_to_jiffies(L2CAP_INFO_TIMEOUT)); | ||
343 | |||
344 | l2cap_send_cmd(conn, conn->info_ident, | ||
345 | L2CAP_INFO_REQ, sizeof(req), &req); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | /* Notify sockets that we cannot guaranty reliability anymore */ | ||
350 | static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) | ||
351 | { | ||
352 | struct l2cap_chan_list *l = &conn->chan_list; | ||
353 | struct sock *sk; | ||
354 | |||
355 | BT_DBG("conn %p", conn); | ||
356 | |||
357 | read_lock(&l->lock); | ||
358 | |||
359 | for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) { | ||
360 | if (l2cap_pi(sk)->link_mode & L2CAP_LM_RELIABLE) | ||
361 | sk->sk_err = err; | ||
362 | } | ||
363 | |||
364 | read_unlock(&l->lock); | ||
365 | } | ||
366 | |||
367 | static void l2cap_info_timeout(unsigned long arg) | ||
368 | { | ||
369 | struct l2cap_conn *conn = (void *) arg; | ||
370 | |||
371 | conn->info_ident = 0; | ||
372 | |||
373 | l2cap_conn_start(conn); | ||
374 | } | ||
375 | |||
262 | static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) | 376 | static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) |
263 | { | 377 | { |
264 | struct l2cap_conn *conn = hcon->l2cap_data; | 378 | struct l2cap_conn *conn = hcon->l2cap_data; |
@@ -279,6 +393,12 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) | |||
279 | conn->src = &hcon->hdev->bdaddr; | 393 | conn->src = &hcon->hdev->bdaddr; |
280 | conn->dst = &hcon->dst; | 394 | conn->dst = &hcon->dst; |
281 | 395 | ||
396 | conn->feat_mask = 0; | ||
397 | |||
398 | init_timer(&conn->info_timer); | ||
399 | conn->info_timer.function = l2cap_info_timeout; | ||
400 | conn->info_timer.data = (unsigned long) conn; | ||
401 | |||
282 | spin_lock_init(&conn->lock); | 402 | spin_lock_init(&conn->lock); |
283 | rwlock_init(&conn->chan_list.lock); | 403 | rwlock_init(&conn->chan_list.lock); |
284 | 404 | ||
@@ -318,40 +438,6 @@ static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, stru | |||
318 | write_unlock_bh(&l->lock); | 438 | write_unlock_bh(&l->lock); |
319 | } | 439 | } |
320 | 440 | ||
321 | static inline u8 l2cap_get_ident(struct l2cap_conn *conn) | ||
322 | { | ||
323 | u8 id; | ||
324 | |||
325 | /* Get next available identificator. | ||
326 | * 1 - 128 are used by kernel. | ||
327 | * 129 - 199 are reserved. | ||
328 | * 200 - 254 are used by utilities like l2ping, etc. | ||
329 | */ | ||
330 | |||
331 | spin_lock_bh(&conn->lock); | ||
332 | |||
333 | if (++conn->tx_ident > 128) | ||
334 | conn->tx_ident = 1; | ||
335 | |||
336 | id = conn->tx_ident; | ||
337 | |||
338 | spin_unlock_bh(&conn->lock); | ||
339 | |||
340 | return id; | ||
341 | } | ||
342 | |||
343 | static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) | ||
344 | { | ||
345 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); | ||
346 | |||
347 | BT_DBG("code 0x%2.2x", code); | ||
348 | |||
349 | if (!skb) | ||
350 | return -ENOMEM; | ||
351 | |||
352 | return hci_send_acl(conn->hcon, skb, 0); | ||
353 | } | ||
354 | |||
355 | /* ---- Socket interface ---- */ | 441 | /* ---- Socket interface ---- */ |
356 | static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src) | 442 | static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src) |
357 | { | 443 | { |
@@ -508,7 +594,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
508 | 594 | ||
509 | /* Default config options */ | 595 | /* Default config options */ |
510 | pi->conf_len = 0; | 596 | pi->conf_len = 0; |
511 | pi->conf_mtu = L2CAP_DEFAULT_MTU; | ||
512 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; | 597 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; |
513 | } | 598 | } |
514 | 599 | ||
@@ -530,7 +615,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p | |||
530 | INIT_LIST_HEAD(&bt_sk(sk)->accept_q); | 615 | INIT_LIST_HEAD(&bt_sk(sk)->accept_q); |
531 | 616 | ||
532 | sk->sk_destruct = l2cap_sock_destruct; | 617 | sk->sk_destruct = l2cap_sock_destruct; |
533 | sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT; | 618 | sk->sk_sndtimeo = msecs_to_jiffies(L2CAP_CONN_TIMEOUT); |
534 | 619 | ||
535 | sock_reset_flag(sk, SOCK_ZAPPED); | 620 | sock_reset_flag(sk, SOCK_ZAPPED); |
536 | 621 | ||
@@ -650,6 +735,11 @@ static int l2cap_do_connect(struct sock *sk) | |||
650 | l2cap_sock_set_timer(sk, sk->sk_sndtimeo); | 735 | l2cap_sock_set_timer(sk, sk->sk_sndtimeo); |
651 | 736 | ||
652 | if (hcon->state == BT_CONNECTED) { | 737 | if (hcon->state == BT_CONNECTED) { |
738 | if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)) { | ||
739 | l2cap_conn_ready(conn); | ||
740 | goto done; | ||
741 | } | ||
742 | |||
653 | if (sk->sk_type == SOCK_SEQPACKET) { | 743 | if (sk->sk_type == SOCK_SEQPACKET) { |
654 | struct l2cap_conn_req req; | 744 | struct l2cap_conn_req req; |
655 | l2cap_pi(sk)->ident = l2cap_get_ident(conn); | 745 | l2cap_pi(sk)->ident = l2cap_get_ident(conn); |
@@ -958,7 +1048,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
958 | opts.imtu = l2cap_pi(sk)->imtu; | 1048 | opts.imtu = l2cap_pi(sk)->imtu; |
959 | opts.omtu = l2cap_pi(sk)->omtu; | 1049 | opts.omtu = l2cap_pi(sk)->omtu; |
960 | opts.flush_to = l2cap_pi(sk)->flush_to; | 1050 | opts.flush_to = l2cap_pi(sk)->flush_to; |
961 | opts.mode = 0x00; | 1051 | opts.mode = L2CAP_MODE_BASIC; |
962 | 1052 | ||
963 | len = min_t(unsigned int, sizeof(opts), optlen); | 1053 | len = min_t(unsigned int, sizeof(opts), optlen); |
964 | if (copy_from_user((char *) &opts, optval, len)) { | 1054 | if (copy_from_user((char *) &opts, optval, len)) { |
@@ -1007,7 +1097,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
1007 | opts.imtu = l2cap_pi(sk)->imtu; | 1097 | opts.imtu = l2cap_pi(sk)->imtu; |
1008 | opts.omtu = l2cap_pi(sk)->omtu; | 1098 | opts.omtu = l2cap_pi(sk)->omtu; |
1009 | opts.flush_to = l2cap_pi(sk)->flush_to; | 1099 | opts.flush_to = l2cap_pi(sk)->flush_to; |
1010 | opts.mode = 0x00; | 1100 | opts.mode = L2CAP_MODE_BASIC; |
1011 | 1101 | ||
1012 | len = min_t(unsigned int, len, sizeof(opts)); | 1102 | len = min_t(unsigned int, len, sizeof(opts)); |
1013 | if (copy_to_user(optval, (char *) &opts, len)) | 1103 | if (copy_to_user(optval, (char *) &opts, len)) |
@@ -1084,52 +1174,6 @@ static int l2cap_sock_release(struct socket *sock) | |||
1084 | return err; | 1174 | return err; |
1085 | } | 1175 | } |
1086 | 1176 | ||
1087 | static void l2cap_conn_ready(struct l2cap_conn *conn) | ||
1088 | { | ||
1089 | struct l2cap_chan_list *l = &conn->chan_list; | ||
1090 | struct sock *sk; | ||
1091 | |||
1092 | BT_DBG("conn %p", conn); | ||
1093 | |||
1094 | read_lock(&l->lock); | ||
1095 | |||
1096 | for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) { | ||
1097 | bh_lock_sock(sk); | ||
1098 | |||
1099 | if (sk->sk_type != SOCK_SEQPACKET) { | ||
1100 | l2cap_sock_clear_timer(sk); | ||
1101 | sk->sk_state = BT_CONNECTED; | ||
1102 | sk->sk_state_change(sk); | ||
1103 | } else if (sk->sk_state == BT_CONNECT) { | ||
1104 | struct l2cap_conn_req req; | ||
1105 | l2cap_pi(sk)->ident = l2cap_get_ident(conn); | ||
1106 | req.scid = cpu_to_le16(l2cap_pi(sk)->scid); | ||
1107 | req.psm = l2cap_pi(sk)->psm; | ||
1108 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, L2CAP_CONN_REQ, sizeof(req), &req); | ||
1109 | } | ||
1110 | |||
1111 | bh_unlock_sock(sk); | ||
1112 | } | ||
1113 | |||
1114 | read_unlock(&l->lock); | ||
1115 | } | ||
1116 | |||
1117 | /* Notify sockets that we cannot guaranty reliability anymore */ | ||
1118 | static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) | ||
1119 | { | ||
1120 | struct l2cap_chan_list *l = &conn->chan_list; | ||
1121 | struct sock *sk; | ||
1122 | |||
1123 | BT_DBG("conn %p", conn); | ||
1124 | |||
1125 | read_lock(&l->lock); | ||
1126 | for (sk = l->head; sk; sk = l2cap_pi(sk)->next_c) { | ||
1127 | if (l2cap_pi(sk)->link_mode & L2CAP_LM_RELIABLE) | ||
1128 | sk->sk_err = err; | ||
1129 | } | ||
1130 | read_unlock(&l->lock); | ||
1131 | } | ||
1132 | |||
1133 | static void l2cap_chan_ready(struct sock *sk) | 1177 | static void l2cap_chan_ready(struct sock *sk) |
1134 | { | 1178 | { |
1135 | struct sock *parent = bt_sk(sk)->parent; | 1179 | struct sock *parent = bt_sk(sk)->parent; |
@@ -1256,11 +1300,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned | |||
1256 | break; | 1300 | break; |
1257 | 1301 | ||
1258 | case 2: | 1302 | case 2: |
1259 | *val = __le16_to_cpu(*((__le16 *)opt->val)); | 1303 | *val = __le16_to_cpu(*((__le16 *) opt->val)); |
1260 | break; | 1304 | break; |
1261 | 1305 | ||
1262 | case 4: | 1306 | case 4: |
1263 | *val = __le32_to_cpu(*((__le32 *)opt->val)); | 1307 | *val = __le32_to_cpu(*((__le32 *) opt->val)); |
1264 | break; | 1308 | break; |
1265 | 1309 | ||
1266 | default: | 1310 | default: |
@@ -1332,6 +1376,8 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data) | |||
1332 | int len = pi->conf_len; | 1376 | int len = pi->conf_len; |
1333 | int type, hint, olen; | 1377 | int type, hint, olen; |
1334 | unsigned long val; | 1378 | unsigned long val; |
1379 | struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; | ||
1380 | u16 mtu = L2CAP_DEFAULT_MTU; | ||
1335 | u16 result = L2CAP_CONF_SUCCESS; | 1381 | u16 result = L2CAP_CONF_SUCCESS; |
1336 | 1382 | ||
1337 | BT_DBG("sk %p", sk); | 1383 | BT_DBG("sk %p", sk); |
@@ -1344,7 +1390,7 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data) | |||
1344 | 1390 | ||
1345 | switch (type) { | 1391 | switch (type) { |
1346 | case L2CAP_CONF_MTU: | 1392 | case L2CAP_CONF_MTU: |
1347 | pi->conf_mtu = val; | 1393 | mtu = val; |
1348 | break; | 1394 | break; |
1349 | 1395 | ||
1350 | case L2CAP_CONF_FLUSH_TO: | 1396 | case L2CAP_CONF_FLUSH_TO: |
@@ -1354,6 +1400,11 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data) | |||
1354 | case L2CAP_CONF_QOS: | 1400 | case L2CAP_CONF_QOS: |
1355 | break; | 1401 | break; |
1356 | 1402 | ||
1403 | case L2CAP_CONF_RFC: | ||
1404 | if (olen == sizeof(rfc)) | ||
1405 | memcpy(&rfc, (void *) val, olen); | ||
1406 | break; | ||
1407 | |||
1357 | default: | 1408 | default: |
1358 | if (hint) | 1409 | if (hint) |
1359 | break; | 1410 | break; |
@@ -1368,12 +1419,24 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data) | |||
1368 | /* Configure output options and let the other side know | 1419 | /* Configure output options and let the other side know |
1369 | * which ones we don't like. */ | 1420 | * which ones we don't like. */ |
1370 | 1421 | ||
1371 | if (pi->conf_mtu < pi->omtu) | 1422 | if (rfc.mode == L2CAP_MODE_BASIC) { |
1423 | if (mtu < pi->omtu) | ||
1424 | result = L2CAP_CONF_UNACCEPT; | ||
1425 | else { | ||
1426 | pi->omtu = mtu; | ||
1427 | pi->conf_state |= L2CAP_CONF_OUTPUT_DONE; | ||
1428 | } | ||
1429 | |||
1430 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu); | ||
1431 | } else { | ||
1372 | result = L2CAP_CONF_UNACCEPT; | 1432 | result = L2CAP_CONF_UNACCEPT; |
1373 | else | ||
1374 | pi->omtu = pi->conf_mtu; | ||
1375 | 1433 | ||
1376 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu); | 1434 | memset(&rfc, 0, sizeof(rfc)); |
1435 | rfc.mode = L2CAP_MODE_BASIC; | ||
1436 | |||
1437 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | ||
1438 | sizeof(rfc), (unsigned long) &rfc); | ||
1439 | } | ||
1377 | } | 1440 | } |
1378 | 1441 | ||
1379 | rsp->scid = cpu_to_le16(pi->dcid); | 1442 | rsp->scid = cpu_to_le16(pi->dcid); |
@@ -1397,6 +1460,23 @@ static int l2cap_build_conf_rsp(struct sock *sk, void *data, u16 result, u16 fla | |||
1397 | return ptr - data; | 1460 | return ptr - data; |
1398 | } | 1461 | } |
1399 | 1462 | ||
1463 | static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | ||
1464 | { | ||
1465 | struct l2cap_cmd_rej *rej = (struct l2cap_cmd_rej *) data; | ||
1466 | |||
1467 | if (rej->reason != 0x0000) | ||
1468 | return 0; | ||
1469 | |||
1470 | if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && | ||
1471 | cmd->ident == conn->info_ident) { | ||
1472 | conn->info_ident = 0; | ||
1473 | del_timer(&conn->info_timer); | ||
1474 | l2cap_conn_start(conn); | ||
1475 | } | ||
1476 | |||
1477 | return 0; | ||
1478 | } | ||
1479 | |||
1400 | static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 1480 | static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) |
1401 | { | 1481 | { |
1402 | struct l2cap_chan_list *list = &conn->chan_list; | 1482 | struct l2cap_chan_list *list = &conn->chan_list; |
@@ -1577,16 +1657,19 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
1577 | 1657 | ||
1578 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, len, rsp); | 1658 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, len, rsp); |
1579 | 1659 | ||
1580 | /* Output config done. */ | ||
1581 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_OUTPUT_DONE; | ||
1582 | |||
1583 | /* Reset config buffer. */ | 1660 | /* Reset config buffer. */ |
1584 | l2cap_pi(sk)->conf_len = 0; | 1661 | l2cap_pi(sk)->conf_len = 0; |
1585 | 1662 | ||
1663 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE)) | ||
1664 | goto unlock; | ||
1665 | |||
1586 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { | 1666 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { |
1587 | sk->sk_state = BT_CONNECTED; | 1667 | sk->sk_state = BT_CONNECTED; |
1588 | l2cap_chan_ready(sk); | 1668 | l2cap_chan_ready(sk); |
1589 | } else if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) { | 1669 | goto unlock; |
1670 | } | ||
1671 | |||
1672 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) { | ||
1590 | u8 req[64]; | 1673 | u8 req[64]; |
1591 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 1674 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
1592 | l2cap_build_conf_req(sk, req), req); | 1675 | l2cap_build_conf_req(sk, req), req); |
@@ -1646,7 +1729,6 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
1646 | if (flags & 0x01) | 1729 | if (flags & 0x01) |
1647 | goto done; | 1730 | goto done; |
1648 | 1731 | ||
1649 | /* Input config done */ | ||
1650 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; | 1732 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; |
1651 | 1733 | ||
1652 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { | 1734 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { |
@@ -1711,16 +1793,27 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd | |||
1711 | static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 1793 | static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) |
1712 | { | 1794 | { |
1713 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; | 1795 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; |
1714 | struct l2cap_info_rsp rsp; | ||
1715 | u16 type; | 1796 | u16 type; |
1716 | 1797 | ||
1717 | type = __le16_to_cpu(req->type); | 1798 | type = __le16_to_cpu(req->type); |
1718 | 1799 | ||
1719 | BT_DBG("type 0x%4.4x", type); | 1800 | BT_DBG("type 0x%4.4x", type); |
1720 | 1801 | ||
1721 | rsp.type = cpu_to_le16(type); | 1802 | if (type == L2CAP_IT_FEAT_MASK) { |
1722 | rsp.result = cpu_to_le16(L2CAP_IR_NOTSUPP); | 1803 | u8 buf[8]; |
1723 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), &rsp); | 1804 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; |
1805 | rsp->type = cpu_to_le16(L2CAP_IT_FEAT_MASK); | ||
1806 | rsp->result = cpu_to_le16(L2CAP_IR_SUCCESS); | ||
1807 | put_unaligned(cpu_to_le32(l2cap_feat_mask), (__le32 *) rsp->data); | ||
1808 | l2cap_send_cmd(conn, cmd->ident, | ||
1809 | L2CAP_INFO_RSP, sizeof(buf), buf); | ||
1810 | } else { | ||
1811 | struct l2cap_info_rsp rsp; | ||
1812 | rsp.type = cpu_to_le16(type); | ||
1813 | rsp.result = cpu_to_le16(L2CAP_IR_NOTSUPP); | ||
1814 | l2cap_send_cmd(conn, cmd->ident, | ||
1815 | L2CAP_INFO_RSP, sizeof(rsp), &rsp); | ||
1816 | } | ||
1724 | 1817 | ||
1725 | return 0; | 1818 | return 0; |
1726 | } | 1819 | } |
@@ -1735,6 +1828,15 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
1735 | 1828 | ||
1736 | BT_DBG("type 0x%4.4x result 0x%2.2x", type, result); | 1829 | BT_DBG("type 0x%4.4x result 0x%2.2x", type, result); |
1737 | 1830 | ||
1831 | conn->info_ident = 0; | ||
1832 | |||
1833 | del_timer(&conn->info_timer); | ||
1834 | |||
1835 | if (type == L2CAP_IT_FEAT_MASK) | ||
1836 | conn->feat_mask = __le32_to_cpu(get_unaligned((__le32 *) rsp->data)); | ||
1837 | |||
1838 | l2cap_conn_start(conn); | ||
1839 | |||
1738 | return 0; | 1840 | return 0; |
1739 | } | 1841 | } |
1740 | 1842 | ||
@@ -1764,7 +1866,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk | |||
1764 | 1866 | ||
1765 | switch (cmd.code) { | 1867 | switch (cmd.code) { |
1766 | case L2CAP_COMMAND_REJ: | 1868 | case L2CAP_COMMAND_REJ: |
1767 | /* FIXME: We should process this */ | 1869 | l2cap_command_rej(conn, &cmd, data); |
1768 | break; | 1870 | break; |
1769 | 1871 | ||
1770 | case L2CAP_CONN_REQ: | 1872 | case L2CAP_CONN_REQ: |