diff options
-rw-r--r-- | include/net/bluetooth/l2cap.h | 6 | ||||
-rw-r--r-- | net/bluetooth/Makefile | 3 | ||||
-rw-r--r-- | net/bluetooth/a2mp.c | 69 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 6 |
4 files changed, 80 insertions, 4 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index c5726c24ee03..aaba222306b6 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -52,6 +52,8 @@ | |||
52 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) | 52 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) |
53 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) | 53 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) |
54 | 54 | ||
55 | #define L2CAP_A2MP_DEFAULT_MTU 670 | ||
56 | |||
55 | /* L2CAP socket address */ | 57 | /* L2CAP socket address */ |
56 | struct sockaddr_l2 { | 58 | struct sockaddr_l2 { |
57 | sa_family_t l2_family; | 59 | sa_family_t l2_family; |
@@ -236,6 +238,7 @@ struct l2cap_conn_rsp { | |||
236 | /* channel indentifier */ | 238 | /* channel indentifier */ |
237 | #define L2CAP_CID_SIGNALING 0x0001 | 239 | #define L2CAP_CID_SIGNALING 0x0001 |
238 | #define L2CAP_CID_CONN_LESS 0x0002 | 240 | #define L2CAP_CID_CONN_LESS 0x0002 |
241 | #define L2CAP_CID_A2MP 0x0003 | ||
239 | #define L2CAP_CID_LE_DATA 0x0004 | 242 | #define L2CAP_CID_LE_DATA 0x0004 |
240 | #define L2CAP_CID_LE_SIGNALING 0x0005 | 243 | #define L2CAP_CID_LE_SIGNALING 0x0005 |
241 | #define L2CAP_CID_SMP 0x0006 | 244 | #define L2CAP_CID_SMP 0x0006 |
@@ -758,5 +761,8 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | |||
758 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 761 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
759 | int l2cap_chan_check_security(struct l2cap_chan *chan); | 762 | int l2cap_chan_check_security(struct l2cap_chan *chan); |
760 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); | 763 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); |
764 | int l2cap_ertm_init(struct l2cap_chan *chan); | ||
765 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
766 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
761 | 767 | ||
762 | #endif /* __L2CAP_H */ | 768 | #endif /* __L2CAP_H */ |
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index 2dc5a5700f53..fa6d94a4602a 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile | |||
@@ -9,4 +9,5 @@ obj-$(CONFIG_BT_CMTP) += cmtp/ | |||
9 | obj-$(CONFIG_BT_HIDP) += hidp/ | 9 | obj-$(CONFIG_BT_HIDP) += hidp/ |
10 | 10 | ||
11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ | 11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ |
12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o | 12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ |
13 | a2mp.o | ||
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c new file mode 100644 index 000000000000..de455a264451 --- /dev/null +++ b/net/bluetooth/a2mp.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved. | ||
3 | Copyright (c) 2011,2012 Intel Corp. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License version 2 and | ||
7 | only version 2 as published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <net/bluetooth/bluetooth.h> | ||
16 | #include <net/bluetooth/hci_core.h> | ||
17 | #include <net/bluetooth/l2cap.h> | ||
18 | |||
19 | static struct l2cap_ops a2mp_chan_ops = { | ||
20 | .name = "L2CAP A2MP channel", | ||
21 | }; | ||
22 | |||
23 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | ||
24 | { | ||
25 | struct l2cap_chan *chan; | ||
26 | int err; | ||
27 | |||
28 | chan = l2cap_chan_create(); | ||
29 | if (!chan) | ||
30 | return NULL; | ||
31 | |||
32 | BT_DBG("chan %p", chan); | ||
33 | |||
34 | hci_conn_hold(conn->hcon); | ||
35 | |||
36 | chan->omtu = L2CAP_A2MP_DEFAULT_MTU; | ||
37 | chan->imtu = L2CAP_A2MP_DEFAULT_MTU; | ||
38 | chan->flush_to = L2CAP_DEFAULT_FLUSH_TO; | ||
39 | |||
40 | chan->ops = &a2mp_chan_ops; | ||
41 | |||
42 | l2cap_chan_set_defaults(chan); | ||
43 | chan->remote_max_tx = chan->max_tx; | ||
44 | chan->remote_tx_win = chan->tx_win; | ||
45 | |||
46 | chan->retrans_timeout = L2CAP_DEFAULT_RETRANS_TO; | ||
47 | chan->monitor_timeout = L2CAP_DEFAULT_MONITOR_TO; | ||
48 | |||
49 | skb_queue_head_init(&chan->tx_q); | ||
50 | |||
51 | chan->mode = L2CAP_MODE_ERTM; | ||
52 | |||
53 | err = l2cap_ertm_init(chan); | ||
54 | if (err < 0) { | ||
55 | l2cap_chan_del(chan, 0); | ||
56 | return NULL; | ||
57 | } | ||
58 | |||
59 | chan->conf_state = 0; | ||
60 | |||
61 | l2cap_chan_add(conn, chan); | ||
62 | |||
63 | chan->remote_mps = chan->omtu; | ||
64 | chan->mps = chan->omtu; | ||
65 | |||
66 | chan->state = BT_CONNECTED; | ||
67 | |||
68 | return chan; | ||
69 | } | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 778c0c8cdc59..2c616cf24c71 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -484,14 +484,14 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | |||
484 | list_add(&chan->list, &conn->chan_l); | 484 | list_add(&chan->list, &conn->chan_l); |
485 | } | 485 | } |
486 | 486 | ||
487 | static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | 487 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) |
488 | { | 488 | { |
489 | mutex_lock(&conn->chan_lock); | 489 | mutex_lock(&conn->chan_lock); |
490 | __l2cap_chan_add(conn, chan); | 490 | __l2cap_chan_add(conn, chan); |
491 | mutex_unlock(&conn->chan_lock); | 491 | mutex_unlock(&conn->chan_lock); |
492 | } | 492 | } |
493 | 493 | ||
494 | static void l2cap_chan_del(struct l2cap_chan *chan, int err) | 494 | void l2cap_chan_del(struct l2cap_chan *chan, int err) |
495 | { | 495 | { |
496 | struct l2cap_conn *conn = chan->conn; | 496 | struct l2cap_conn *conn = chan->conn; |
497 | 497 | ||
@@ -2691,7 +2691,7 @@ static void l2cap_ack_timeout(struct work_struct *work) | |||
2691 | l2cap_chan_put(chan); | 2691 | l2cap_chan_put(chan); |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | static inline int l2cap_ertm_init(struct l2cap_chan *chan) | 2694 | int l2cap_ertm_init(struct l2cap_chan *chan) |
2695 | { | 2695 | { |
2696 | int err; | 2696 | int err; |
2697 | 2697 | ||