diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-05-29 06:59:01 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-06-04 23:34:11 -0400 |
commit | 466f8004f364e9cb46d9124109972489eccfb404 (patch) | |
tree | 100233272787a891de4022eca15ba5c414719b2c /net/bluetooth/a2mp.c | |
parent | 0181a70f549bd1683d18a5a1d79ac25bcdb76570 (diff) |
Bluetooth: A2MP: Create A2MP channel
Create and initialize fixed A2MP channel
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/a2mp.c')
-rw-r--r-- | net/bluetooth/a2mp.c | 69 |
1 files changed, 69 insertions, 0 deletions
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 | } | ||