diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
| commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
| tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/net/bluetooth | |
| parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) | |
Patched in Tegra support.
Diffstat (limited to 'include/net/bluetooth')
| -rw-r--r-- | include/net/bluetooth/a2mp.h | 148 | ||||
| -rw-r--r-- | include/net/bluetooth/amp.h | 54 | ||||
| -rw-r--r-- | include/net/bluetooth/bluetooth.h | 165 | ||||
| -rw-r--r-- | include/net/bluetooth/hci.h | 387 | ||||
| -rw-r--r-- | include/net/bluetooth/hci_core.h | 820 | ||||
| -rw-r--r-- | include/net/bluetooth/hci_mon.h | 51 | ||||
| -rw-r--r-- | include/net/bluetooth/l2cap.h | 545 | ||||
| -rw-r--r-- | include/net/bluetooth/mgmt.h | 456 | ||||
| -rw-r--r-- | include/net/bluetooth/rfcomm.h | 1 | ||||
| -rw-r--r-- | include/net/bluetooth/sco.h | 4 | ||||
| -rw-r--r-- | include/net/bluetooth/smp.h | 31 |
11 files changed, 627 insertions, 2035 deletions
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h deleted file mode 100644 index 42f21766c53..00000000000 --- a/include/net/bluetooth/a2mp.h +++ /dev/null | |||
| @@ -1,148 +0,0 @@ | |||
| 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 | #ifndef __A2MP_H | ||
| 16 | #define __A2MP_H | ||
| 17 | |||
| 18 | #include <net/bluetooth/l2cap.h> | ||
| 19 | |||
| 20 | #define A2MP_FEAT_EXT 0x8000 | ||
| 21 | |||
| 22 | enum amp_mgr_state { | ||
| 23 | READ_LOC_AMP_INFO, | ||
| 24 | READ_LOC_AMP_ASSOC, | ||
| 25 | READ_LOC_AMP_ASSOC_FINAL, | ||
| 26 | }; | ||
| 27 | |||
| 28 | struct amp_mgr { | ||
| 29 | struct list_head list; | ||
| 30 | struct l2cap_conn *l2cap_conn; | ||
| 31 | struct l2cap_chan *a2mp_chan; | ||
| 32 | struct l2cap_chan *bredr_chan; | ||
| 33 | struct kref kref; | ||
| 34 | __u8 ident; | ||
| 35 | __u8 handle; | ||
| 36 | enum amp_mgr_state state; | ||
| 37 | unsigned long flags; | ||
| 38 | |||
| 39 | struct list_head amp_ctrls; | ||
| 40 | struct mutex amp_ctrls_lock; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct a2mp_cmd { | ||
| 44 | __u8 code; | ||
| 45 | __u8 ident; | ||
| 46 | __le16 len; | ||
| 47 | __u8 data[0]; | ||
| 48 | } __packed; | ||
| 49 | |||
| 50 | /* A2MP command codes */ | ||
| 51 | #define A2MP_COMMAND_REJ 0x01 | ||
| 52 | struct a2mp_cmd_rej { | ||
| 53 | __le16 reason; | ||
| 54 | __u8 data[0]; | ||
| 55 | } __packed; | ||
| 56 | |||
| 57 | #define A2MP_DISCOVER_REQ 0x02 | ||
| 58 | struct a2mp_discov_req { | ||
| 59 | __le16 mtu; | ||
| 60 | __le16 ext_feat; | ||
| 61 | } __packed; | ||
| 62 | |||
| 63 | struct a2mp_cl { | ||
| 64 | __u8 id; | ||
| 65 | __u8 type; | ||
| 66 | __u8 status; | ||
| 67 | } __packed; | ||
| 68 | |||
| 69 | #define A2MP_DISCOVER_RSP 0x03 | ||
| 70 | struct a2mp_discov_rsp { | ||
| 71 | __le16 mtu; | ||
| 72 | __le16 ext_feat; | ||
| 73 | struct a2mp_cl cl[0]; | ||
| 74 | } __packed; | ||
| 75 | |||
| 76 | #define A2MP_CHANGE_NOTIFY 0x04 | ||
| 77 | #define A2MP_CHANGE_RSP 0x05 | ||
| 78 | |||
| 79 | #define A2MP_GETINFO_REQ 0x06 | ||
| 80 | struct a2mp_info_req { | ||
| 81 | __u8 id; | ||
| 82 | } __packed; | ||
| 83 | |||
| 84 | #define A2MP_GETINFO_RSP 0x07 | ||
| 85 | struct a2mp_info_rsp { | ||
| 86 | __u8 id; | ||
| 87 | __u8 status; | ||
| 88 | __le32 total_bw; | ||
| 89 | __le32 max_bw; | ||
| 90 | __le32 min_latency; | ||
| 91 | __le16 pal_cap; | ||
| 92 | __le16 assoc_size; | ||
| 93 | } __packed; | ||
| 94 | |||
| 95 | #define A2MP_GETAMPASSOC_REQ 0x08 | ||
| 96 | struct a2mp_amp_assoc_req { | ||
| 97 | __u8 id; | ||
| 98 | } __packed; | ||
| 99 | |||
| 100 | #define A2MP_GETAMPASSOC_RSP 0x09 | ||
| 101 | struct a2mp_amp_assoc_rsp { | ||
| 102 | __u8 id; | ||
| 103 | __u8 status; | ||
| 104 | __u8 amp_assoc[0]; | ||
| 105 | } __packed; | ||
| 106 | |||
| 107 | #define A2MP_CREATEPHYSLINK_REQ 0x0A | ||
| 108 | #define A2MP_DISCONNPHYSLINK_REQ 0x0C | ||
| 109 | struct a2mp_physlink_req { | ||
| 110 | __u8 local_id; | ||
| 111 | __u8 remote_id; | ||
| 112 | __u8 amp_assoc[0]; | ||
| 113 | } __packed; | ||
| 114 | |||
| 115 | #define A2MP_CREATEPHYSLINK_RSP 0x0B | ||
| 116 | #define A2MP_DISCONNPHYSLINK_RSP 0x0D | ||
| 117 | struct a2mp_physlink_rsp { | ||
| 118 | __u8 local_id; | ||
| 119 | __u8 remote_id; | ||
| 120 | __u8 status; | ||
| 121 | } __packed; | ||
| 122 | |||
| 123 | /* A2MP response status */ | ||
| 124 | #define A2MP_STATUS_SUCCESS 0x00 | ||
| 125 | #define A2MP_STATUS_INVALID_CTRL_ID 0x01 | ||
| 126 | #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02 | ||
| 127 | #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02 | ||
| 128 | #define A2MP_STATUS_COLLISION_OCCURED 0x03 | ||
| 129 | #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04 | ||
| 130 | #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05 | ||
| 131 | #define A2MP_STATUS_SECURITY_VIOLATION 0x06 | ||
| 132 | |||
| 133 | extern struct list_head amp_mgr_list; | ||
| 134 | extern struct mutex amp_mgr_list_lock; | ||
| 135 | |||
| 136 | struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr); | ||
| 137 | int amp_mgr_put(struct amp_mgr *mgr); | ||
| 138 | u8 __next_ident(struct amp_mgr *mgr); | ||
| 139 | struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | ||
| 140 | struct sk_buff *skb); | ||
| 141 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state); | ||
| 142 | void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data); | ||
| 143 | void a2mp_discover_amp(struct l2cap_chan *chan); | ||
| 144 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev); | ||
| 145 | void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status); | ||
| 146 | void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status); | ||
| 147 | |||
| 148 | #endif /* __A2MP_H */ | ||
diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h deleted file mode 100644 index 7ea3db77ba8..00000000000 --- a/include/net/bluetooth/amp.h +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright (c) 2011,2012 Intel Corp. | ||
| 3 | |||
| 4 | This program is free software; you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License version 2 and | ||
| 6 | only version 2 as published by the Free Software Foundation. | ||
| 7 | |||
| 8 | This program is distributed in the hope that it will be useful, | ||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | GNU General Public License for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef __AMP_H | ||
| 15 | #define __AMP_H | ||
| 16 | |||
| 17 | struct amp_ctrl { | ||
| 18 | struct list_head list; | ||
| 19 | struct kref kref; | ||
| 20 | __u8 id; | ||
| 21 | __u16 assoc_len_so_far; | ||
| 22 | __u16 assoc_rem_len; | ||
| 23 | __u16 assoc_len; | ||
| 24 | __u8 *assoc; | ||
| 25 | }; | ||
| 26 | |||
| 27 | int amp_ctrl_put(struct amp_ctrl *ctrl); | ||
| 28 | void amp_ctrl_get(struct amp_ctrl *ctrl); | ||
| 29 | struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id); | ||
| 30 | struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id); | ||
| 31 | void amp_ctrl_list_flush(struct amp_mgr *mgr); | ||
| 32 | |||
| 33 | struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
| 34 | u8 remote_id, bool out); | ||
| 35 | |||
| 36 | int phylink_gen_key(struct hci_conn *hcon, u8 *data, u8 *len, u8 *type); | ||
| 37 | |||
| 38 | void amp_read_loc_info(struct hci_dev *hdev, struct amp_mgr *mgr); | ||
| 39 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle); | ||
| 40 | void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr); | ||
| 41 | void amp_read_loc_assoc_final_data(struct hci_dev *hdev, | ||
| 42 | struct hci_conn *hcon); | ||
| 43 | void amp_create_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
| 44 | struct hci_conn *hcon); | ||
| 45 | void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
| 46 | struct hci_conn *hcon); | ||
| 47 | void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle); | ||
| 48 | void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle); | ||
| 49 | void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon); | ||
| 50 | void amp_create_logical_link(struct l2cap_chan *chan); | ||
| 51 | void amp_disconnect_logical_link(struct hci_chan *hchan); | ||
| 52 | void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason); | ||
| 53 | |||
| 54 | #endif /* __AMP_H */ | ||
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 2554b3f5222..e727555d4ee 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
| 3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
| 4 | 4 | ||
| @@ -12,33 +12,30 @@ | |||
| 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
| 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
| 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
| 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | 19 | ||
| 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
| 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
| 22 | SOFTWARE IS DISCLAIMED. | 22 | SOFTWARE IS DISCLAIMED. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #ifndef __BLUETOOTH_H | 25 | #ifndef __BLUETOOTH_H |
| 26 | #define __BLUETOOTH_H | 26 | #define __BLUETOOTH_H |
| 27 | 27 | ||
| 28 | #include <asm/types.h> | ||
| 29 | #include <asm/byteorder.h> | ||
| 30 | #include <linux/list.h> | ||
| 28 | #include <linux/poll.h> | 31 | #include <linux/poll.h> |
| 29 | #include <net/sock.h> | 32 | #include <net/sock.h> |
| 30 | #include <linux/seq_file.h> | ||
| 31 | 33 | ||
| 32 | #ifndef AF_BLUETOOTH | 34 | #ifndef AF_BLUETOOTH |
| 33 | #define AF_BLUETOOTH 31 | 35 | #define AF_BLUETOOTH 31 |
| 34 | #define PF_BLUETOOTH AF_BLUETOOTH | 36 | #define PF_BLUETOOTH AF_BLUETOOTH |
| 35 | #endif | 37 | #endif |
| 36 | 38 | ||
| 37 | /* Bluetooth versions */ | ||
| 38 | #define BLUETOOTH_VER_1_1 1 | ||
| 39 | #define BLUETOOTH_VER_1_2 2 | ||
| 40 | #define BLUETOOTH_VER_2_0 3 | ||
| 41 | |||
| 42 | /* Reserv for core and drivers use */ | 39 | /* Reserv for core and drivers use */ |
| 43 | #define BT_SKB_RESERVE 8 | 40 | #define BT_SKB_RESERVE 8 |
| 44 | 41 | ||
| @@ -80,41 +77,12 @@ struct bt_power { | |||
| 80 | #define BT_POWER_FORCE_ACTIVE_OFF 0 | 77 | #define BT_POWER_FORCE_ACTIVE_OFF 0 |
| 81 | #define BT_POWER_FORCE_ACTIVE_ON 1 | 78 | #define BT_POWER_FORCE_ACTIVE_ON 1 |
| 82 | 79 | ||
| 83 | #define BT_CHANNEL_POLICY 10 | 80 | __attribute__((format (printf, 2, 3))) |
| 84 | 81 | int bt_printk(const char *level, const char *fmt, ...); | |
| 85 | /* BR/EDR only (default policy) | 82 | |
| 86 | * AMP controllers cannot be used. | 83 | #define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) |
| 87 | * Channel move requests from the remote device are denied. | 84 | #define BT_ERR(fmt, arg...) bt_printk(KERN_ERR, pr_fmt(fmt), ##arg) |
| 88 | * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. | 85 | #define BT_DBG(fmt, arg...) pr_debug(fmt "\n", ##arg) |
| 89 | */ | ||
| 90 | #define BT_CHANNEL_POLICY_BREDR_ONLY 0 | ||
| 91 | |||
| 92 | /* BR/EDR Preferred | ||
| 93 | * Allow use of AMP controllers. | ||
| 94 | * If the L2CAP channel is currently on AMP, move it to BR/EDR. | ||
| 95 | * Channel move requests from the remote device are allowed. | ||
| 96 | */ | ||
| 97 | #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 | ||
| 98 | |||
| 99 | /* AMP Preferred | ||
| 100 | * Allow use of AMP controllers | ||
| 101 | * If the L2CAP channel is currently on BR/EDR and AMP controller | ||
| 102 | * resources are available, initiate a channel move to AMP. | ||
| 103 | * Channel move requests from the remote device are allowed. | ||
| 104 | * If the L2CAP socket has not been connected yet, try to create | ||
| 105 | * and configure the channel directly on an AMP controller rather | ||
| 106 | * than BR/EDR. | ||
| 107 | */ | ||
| 108 | #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 | ||
| 109 | |||
| 110 | __printf(1, 2) | ||
| 111 | int bt_info(const char *fmt, ...); | ||
| 112 | __printf(1, 2) | ||
| 113 | int bt_err(const char *fmt, ...); | ||
| 114 | |||
| 115 | #define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) | ||
| 116 | #define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) | ||
| 117 | #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) | ||
| 118 | 86 | ||
| 119 | /* Connection and socket states */ | 87 | /* Connection and socket states */ |
| 120 | enum { | 88 | enum { |
| @@ -129,45 +97,13 @@ enum { | |||
| 129 | BT_CLOSED | 97 | BT_CLOSED |
| 130 | }; | 98 | }; |
| 131 | 99 | ||
| 132 | /* If unused will be removed by compiler */ | ||
| 133 | static inline const char *state_to_string(int state) | ||
| 134 | { | ||
| 135 | switch (state) { | ||
| 136 | case BT_CONNECTED: | ||
| 137 | return "BT_CONNECTED"; | ||
| 138 | case BT_OPEN: | ||
| 139 | return "BT_OPEN"; | ||
| 140 | case BT_BOUND: | ||
| 141 | return "BT_BOUND"; | ||
| 142 | case BT_LISTEN: | ||
| 143 | return "BT_LISTEN"; | ||
| 144 | case BT_CONNECT: | ||
| 145 | return "BT_CONNECT"; | ||
| 146 | case BT_CONNECT2: | ||
| 147 | return "BT_CONNECT2"; | ||
| 148 | case BT_CONFIG: | ||
| 149 | return "BT_CONFIG"; | ||
| 150 | case BT_DISCONN: | ||
| 151 | return "BT_DISCONN"; | ||
| 152 | case BT_CLOSED: | ||
| 153 | return "BT_CLOSED"; | ||
| 154 | } | ||
| 155 | |||
| 156 | return "invalid state"; | ||
| 157 | } | ||
| 158 | |||
| 159 | /* BD Address */ | 100 | /* BD Address */ |
| 160 | typedef struct { | 101 | typedef struct { |
| 161 | __u8 b[6]; | 102 | __u8 b[6]; |
| 162 | } __packed bdaddr_t; | 103 | } __packed bdaddr_t; |
| 163 | 104 | ||
| 164 | /* BD Address type */ | 105 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) |
| 165 | #define BDADDR_BREDR 0x00 | 106 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) |
| 166 | #define BDADDR_LE_PUBLIC 0x01 | ||
| 167 | #define BDADDR_LE_RANDOM 0x02 | ||
| 168 | |||
| 169 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} }) | ||
| 170 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) | ||
| 171 | 107 | ||
| 172 | /* Copy, swap, convert BD Address */ | 108 | /* Copy, swap, convert BD Address */ |
| 173 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) | 109 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) |
| @@ -180,6 +116,8 @@ static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) | |||
| 180 | } | 116 | } |
| 181 | 117 | ||
| 182 | void baswap(bdaddr_t *dst, bdaddr_t *src); | 118 | void baswap(bdaddr_t *dst, bdaddr_t *src); |
| 119 | char *batostr(bdaddr_t *ba); | ||
| 120 | bdaddr_t *strtoba(char *str); | ||
| 183 | 121 | ||
| 184 | /* Common socket structures and functions */ | 122 | /* Common socket structures and functions */ |
| 185 | 123 | ||
| @@ -191,21 +129,12 @@ struct bt_sock { | |||
| 191 | bdaddr_t dst; | 129 | bdaddr_t dst; |
| 192 | struct list_head accept_q; | 130 | struct list_head accept_q; |
| 193 | struct sock *parent; | 131 | struct sock *parent; |
| 194 | unsigned long flags; | 132 | u32 defer_setup; |
| 195 | }; | ||
| 196 | |||
| 197 | enum { | ||
| 198 | BT_SK_DEFER_SETUP, | ||
| 199 | BT_SK_SUSPEND, | ||
| 200 | }; | 133 | }; |
| 201 | 134 | ||
| 202 | struct bt_sock_list { | 135 | struct bt_sock_list { |
| 203 | struct hlist_head head; | 136 | struct hlist_head head; |
| 204 | rwlock_t lock; | 137 | rwlock_t lock; |
| 205 | #ifdef CONFIG_PROC_FS | ||
| 206 | struct file_operations fops; | ||
| 207 | int (* custom_seq_show)(struct seq_file *, void *); | ||
| 208 | #endif | ||
| 209 | }; | 138 | }; |
| 210 | 139 | ||
| 211 | int bt_sock_register(int proto, const struct net_proto_family *ops); | 140 | int bt_sock_register(int proto, const struct net_proto_family *ops); |
| @@ -216,7 +145,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 216 | struct msghdr *msg, size_t len, int flags); | 145 | struct msghdr *msg, size_t len, int flags); |
| 217 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | 146 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
| 218 | struct msghdr *msg, size_t len, int flags); | 147 | struct msghdr *msg, size_t len, int flags); |
| 219 | uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); | 148 | uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); |
| 220 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); | 149 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
| 221 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); | 150 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); |
| 222 | 151 | ||
| @@ -225,24 +154,15 @@ void bt_accept_unlink(struct sock *sk); | |||
| 225 | struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); | 154 | struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); |
| 226 | 155 | ||
| 227 | /* Skb helpers */ | 156 | /* Skb helpers */ |
| 228 | struct l2cap_ctrl { | ||
| 229 | unsigned int sframe:1, | ||
| 230 | poll:1, | ||
| 231 | final:1, | ||
| 232 | fcs:1, | ||
| 233 | sar:2, | ||
| 234 | super:2; | ||
| 235 | __u16 reqseq; | ||
| 236 | __u16 txseq; | ||
| 237 | __u8 retries; | ||
| 238 | }; | ||
| 239 | |||
| 240 | struct bt_skb_cb { | 157 | struct bt_skb_cb { |
| 241 | __u8 pkt_type; | 158 | __u8 pkt_type; |
| 242 | __u8 incoming; | 159 | __u8 incoming; |
| 243 | __u16 expect; | 160 | __u16 expect; |
| 161 | __u8 tx_seq; | ||
| 162 | __u8 retries; | ||
| 163 | __u8 sar; | ||
| 164 | unsigned short channel; | ||
| 244 | __u8 force_active; | 165 | __u8 force_active; |
| 245 | struct l2cap_ctrl control; | ||
| 246 | }; | 166 | }; |
| 247 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) | 167 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) |
| 248 | 168 | ||
| @@ -250,8 +170,7 @@ static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) | |||
| 250 | { | 170 | { |
| 251 | struct sk_buff *skb; | 171 | struct sk_buff *skb; |
| 252 | 172 | ||
| 253 | skb = alloc_skb(len + BT_SKB_RESERVE, how); | 173 | if ((skb = alloc_skb(len + BT_SKB_RESERVE, how))) { |
| 254 | if (skb) { | ||
| 255 | skb_reserve(skb, BT_SKB_RESERVE); | 174 | skb_reserve(skb, BT_SKB_RESERVE); |
| 256 | bt_cb(skb)->incoming = 0; | 175 | bt_cb(skb)->incoming = 0; |
| 257 | } | 176 | } |
| @@ -263,11 +182,12 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, | |||
| 263 | { | 182 | { |
| 264 | struct sk_buff *skb; | 183 | struct sk_buff *skb; |
| 265 | 184 | ||
| 266 | skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err); | 185 | release_sock(sk); |
| 267 | if (skb) { | 186 | if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) { |
| 268 | skb_reserve(skb, BT_SKB_RESERVE); | 187 | skb_reserve(skb, BT_SKB_RESERVE); |
| 269 | bt_cb(skb)->incoming = 0; | 188 | bt_cb(skb)->incoming = 0; |
| 270 | } | 189 | } |
| 190 | lock_sock(sk); | ||
| 271 | 191 | ||
| 272 | if (!skb && *err) | 192 | if (!skb && *err) |
| 273 | return NULL; | 193 | return NULL; |
| @@ -296,19 +216,34 @@ extern void hci_sock_cleanup(void); | |||
| 296 | extern int bt_sysfs_init(void); | 216 | extern int bt_sysfs_init(void); |
| 297 | extern void bt_sysfs_cleanup(void); | 217 | extern void bt_sysfs_cleanup(void); |
| 298 | 218 | ||
| 299 | extern int bt_procfs_init(struct module* module, struct net *net, const char *name, | ||
| 300 | struct bt_sock_list* sk_list, | ||
| 301 | int (* seq_show)(struct seq_file *, void *)); | ||
| 302 | extern void bt_procfs_cleanup(struct net *net, const char *name); | ||
| 303 | |||
| 304 | extern struct dentry *bt_debugfs; | 219 | extern struct dentry *bt_debugfs; |
| 305 | 220 | ||
| 221 | #ifdef CONFIG_BT_L2CAP | ||
| 306 | int l2cap_init(void); | 222 | int l2cap_init(void); |
| 307 | void l2cap_exit(void); | 223 | void l2cap_exit(void); |
| 224 | #else | ||
| 225 | static inline int l2cap_init(void) | ||
| 226 | { | ||
| 227 | return 0; | ||
| 228 | } | ||
| 308 | 229 | ||
| 230 | static inline void l2cap_exit(void) | ||
| 231 | { | ||
| 232 | } | ||
| 233 | #endif | ||
| 234 | |||
| 235 | #ifdef CONFIG_BT_SCO | ||
| 309 | int sco_init(void); | 236 | int sco_init(void); |
| 310 | void sco_exit(void); | 237 | void sco_exit(void); |
| 238 | #else | ||
| 239 | static inline int sco_init(void) | ||
| 240 | { | ||
| 241 | return 0; | ||
| 242 | } | ||
| 311 | 243 | ||
| 312 | void bt_sock_reclassify_lock(struct sock *sk, int proto); | 244 | static inline void sco_exit(void) |
| 245 | { | ||
| 246 | } | ||
| 247 | #endif | ||
| 313 | 248 | ||
| 314 | #endif /* __BLUETOOTH_H */ | 249 | #endif /* __BLUETOOTH_H */ |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 45eee08157b..915d7ae527b 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
| @@ -30,11 +30,6 @@ | |||
| 30 | #define HCI_MAX_EVENT_SIZE 260 | 30 | #define HCI_MAX_EVENT_SIZE 260 |
| 31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) | 31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) |
| 32 | 32 | ||
| 33 | #define HCI_LINK_KEY_SIZE 16 | ||
| 34 | #define HCI_AMP_LINK_KEY_SIZE (2 * HCI_LINK_KEY_SIZE) | ||
| 35 | |||
| 36 | #define HCI_MAX_AMP_ASSOC_SIZE 672 | ||
| 37 | |||
| 38 | /* HCI dev events */ | 33 | /* HCI dev events */ |
| 39 | #define HCI_DEV_REG 1 | 34 | #define HCI_DEV_REG 1 |
| 40 | #define HCI_DEV_UNREG 2 | 35 | #define HCI_DEV_UNREG 2 |
| @@ -42,6 +37,7 @@ | |||
| 42 | #define HCI_DEV_DOWN 4 | 37 | #define HCI_DEV_DOWN 4 |
| 43 | #define HCI_DEV_SUSPEND 5 | 38 | #define HCI_DEV_SUSPEND 5 |
| 44 | #define HCI_DEV_RESUME 6 | 39 | #define HCI_DEV_RESUME 6 |
| 40 | #define HCI_DEV_WRITE 7 | ||
| 45 | 41 | ||
| 46 | /* HCI notify events */ | 42 | /* HCI notify events */ |
| 47 | #define HCI_NOTIFY_CONN_ADD 1 | 43 | #define HCI_NOTIFY_CONN_ADD 1 |
| @@ -61,21 +57,9 @@ | |||
| 61 | #define HCI_BREDR 0x00 | 57 | #define HCI_BREDR 0x00 |
| 62 | #define HCI_AMP 0x01 | 58 | #define HCI_AMP 0x01 |
| 63 | 59 | ||
| 64 | /* First BR/EDR Controller shall have ID = 0 */ | ||
| 65 | #define HCI_BREDR_ID 0 | ||
| 66 | |||
| 67 | /* AMP controller status */ | ||
| 68 | #define AMP_CTRL_POWERED_DOWN 0x00 | ||
| 69 | #define AMP_CTRL_BLUETOOTH_ONLY 0x01 | ||
| 70 | #define AMP_CTRL_NO_CAPACITY 0x02 | ||
| 71 | #define AMP_CTRL_LOW_CAPACITY 0x03 | ||
| 72 | #define AMP_CTRL_MEDIUM_CAPACITY 0x04 | ||
| 73 | #define AMP_CTRL_HIGH_CAPACITY 0x05 | ||
| 74 | #define AMP_CTRL_FULL_CAPACITY 0x06 | ||
| 75 | |||
| 76 | /* HCI device quirks */ | 60 | /* HCI device quirks */ |
| 77 | enum { | 61 | enum { |
| 78 | HCI_QUIRK_RESET_ON_CLOSE, | 62 | HCI_QUIRK_NO_RESET, |
| 79 | HCI_QUIRK_RAW_DEVICE, | 63 | HCI_QUIRK_RAW_DEVICE, |
| 80 | HCI_QUIRK_FIXUP_BUFFER_SIZE | 64 | HCI_QUIRK_FIXUP_BUFFER_SIZE |
| 81 | }; | 65 | }; |
| @@ -94,14 +78,6 @@ enum { | |||
| 94 | 78 | ||
| 95 | HCI_RAW, | 79 | HCI_RAW, |
| 96 | 80 | ||
| 97 | HCI_RESET, | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* | ||
| 101 | * BR/EDR and/or LE controller flags: the flags defined here should represent | ||
| 102 | * states from the controller. | ||
| 103 | */ | ||
| 104 | enum { | ||
| 105 | HCI_SETUP, | 81 | HCI_SETUP, |
| 106 | HCI_AUTO_OFF, | 82 | HCI_AUTO_OFF, |
| 107 | HCI_MGMT, | 83 | HCI_MGMT, |
| @@ -109,18 +85,8 @@ enum { | |||
| 109 | HCI_SERVICE_CACHE, | 85 | HCI_SERVICE_CACHE, |
| 110 | HCI_LINK_KEYS, | 86 | HCI_LINK_KEYS, |
| 111 | HCI_DEBUG_KEYS, | 87 | HCI_DEBUG_KEYS, |
| 112 | HCI_UNREGISTER, | 88 | |
| 113 | 89 | HCI_RESET, | |
| 114 | HCI_LE_SCAN, | ||
| 115 | HCI_SSP_ENABLED, | ||
| 116 | HCI_HS_ENABLED, | ||
| 117 | HCI_LE_ENABLED, | ||
| 118 | HCI_LE_PERIPHERAL, | ||
| 119 | HCI_CONNECTABLE, | ||
| 120 | HCI_DISCOVERABLE, | ||
| 121 | HCI_LINK_SECURITY, | ||
| 122 | HCI_PENDING_CLASS, | ||
| 123 | HCI_PERIODIC_INQ, | ||
| 124 | }; | 90 | }; |
| 125 | 91 | ||
| 126 | /* HCI ioctl defines */ | 92 | /* HCI ioctl defines */ |
| @@ -151,12 +117,12 @@ enum { | |||
| 151 | #define HCIINQUIRY _IOR('H', 240, int) | 117 | #define HCIINQUIRY _IOR('H', 240, int) |
| 152 | 118 | ||
| 153 | /* HCI timeouts */ | 119 | /* HCI timeouts */ |
| 154 | #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 120 | #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ |
| 155 | #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */ | 121 | #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ |
| 156 | #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */ | 122 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ |
| 157 | #define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 123 | #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ |
| 158 | #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */ | 124 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ |
| 159 | #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 125 | #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ |
| 160 | 126 | ||
| 161 | /* HCI data types */ | 127 | /* HCI data types */ |
| 162 | #define HCI_COMMAND_PKT 0x01 | 128 | #define HCI_COMMAND_PKT 0x01 |
| @@ -192,14 +158,15 @@ enum { | |||
| 192 | #define ESCO_2EV5 0x0100 | 158 | #define ESCO_2EV5 0x0100 |
| 193 | #define ESCO_3EV5 0x0200 | 159 | #define ESCO_3EV5 0x0200 |
| 194 | 160 | ||
| 195 | #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) | 161 | #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) |
| 196 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) | 162 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) |
| 163 | #define ALL_ESCO_MASK (SCO_ESCO_MASK | ESCO_EV3 | ESCO_EV4 | ESCO_EV5 | \ | ||
| 164 | EDR_ESCO_MASK) | ||
| 197 | 165 | ||
| 198 | /* ACL flags */ | 166 | /* ACL flags */ |
| 199 | #define ACL_START_NO_FLUSH 0x00 | 167 | #define ACL_START_NO_FLUSH 0x00 |
| 200 | #define ACL_CONT 0x01 | 168 | #define ACL_CONT 0x01 |
| 201 | #define ACL_START 0x02 | 169 | #define ACL_START 0x02 |
| 202 | #define ACL_COMPLETE 0x03 | ||
| 203 | #define ACL_ACTIVE_BCAST 0x04 | 170 | #define ACL_ACTIVE_BCAST 0x04 |
| 204 | #define ACL_PICO_BCAST 0x08 | 171 | #define ACL_PICO_BCAST 0x08 |
| 205 | 172 | ||
| @@ -209,7 +176,6 @@ enum { | |||
| 209 | #define ESCO_LINK 0x02 | 176 | #define ESCO_LINK 0x02 |
| 210 | /* Low Energy links do not have defined link type. Use invented one */ | 177 | /* Low Energy links do not have defined link type. Use invented one */ |
| 211 | #define LE_LINK 0x80 | 178 | #define LE_LINK 0x80 |
| 212 | #define AMP_LINK 0x81 | ||
| 213 | 179 | ||
| 214 | /* LMP features */ | 180 | /* LMP features */ |
| 215 | #define LMP_3SLOT 0x01 | 181 | #define LMP_3SLOT 0x01 |
| @@ -239,7 +205,6 @@ enum { | |||
| 239 | 205 | ||
| 240 | #define LMP_EV4 0x01 | 206 | #define LMP_EV4 0x01 |
| 241 | #define LMP_EV5 0x02 | 207 | #define LMP_EV5 0x02 |
| 242 | #define LMP_NO_BREDR 0x20 | ||
| 243 | #define LMP_LE 0x40 | 208 | #define LMP_LE 0x40 |
| 244 | 209 | ||
| 245 | #define LMP_SNIFF_SUBR 0x02 | 210 | #define LMP_SNIFF_SUBR 0x02 |
| @@ -258,9 +223,7 @@ enum { | |||
| 258 | #define LMP_EXTFEATURES 0x80 | 223 | #define LMP_EXTFEATURES 0x80 |
| 259 | 224 | ||
| 260 | /* Extended LMP features */ | 225 | /* Extended LMP features */ |
| 261 | #define LMP_HOST_SSP 0x01 | 226 | #define LMP_HOST_LE 0x02 |
| 262 | #define LMP_HOST_LE 0x02 | ||
| 263 | #define LMP_HOST_LE_BREDR 0x04 | ||
| 264 | 227 | ||
| 265 | /* Connection modes */ | 228 | /* Connection modes */ |
| 266 | #define HCI_CM_ACTIVE 0x0000 | 229 | #define HCI_CM_ACTIVE 0x0000 |
| @@ -299,51 +262,10 @@ enum { | |||
| 299 | #define HCI_LK_UNAUTH_COMBINATION 0x04 | 262 | #define HCI_LK_UNAUTH_COMBINATION 0x04 |
| 300 | #define HCI_LK_AUTH_COMBINATION 0x05 | 263 | #define HCI_LK_AUTH_COMBINATION 0x05 |
| 301 | #define HCI_LK_CHANGED_COMBINATION 0x06 | 264 | #define HCI_LK_CHANGED_COMBINATION 0x06 |
| 302 | /* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */ | 265 | /* The spec doesn't define types for SMP keys */ |
| 303 | #define HCI_SMP_STK 0x80 | 266 | #define HCI_LK_SMP_LTK 0x81 |
| 304 | #define HCI_SMP_STK_SLAVE 0x81 | 267 | #define HCI_LK_SMP_IRK 0x82 |
| 305 | #define HCI_SMP_LTK 0x82 | 268 | #define HCI_LK_SMP_CSRK 0x83 |
| 306 | #define HCI_SMP_LTK_SLAVE 0x83 | ||
| 307 | |||
| 308 | /* ---- HCI Error Codes ---- */ | ||
| 309 | #define HCI_ERROR_AUTH_FAILURE 0x05 | ||
| 310 | #define HCI_ERROR_CONNECTION_TIMEOUT 0x08 | ||
| 311 | #define HCI_ERROR_REJ_BAD_ADDR 0x0f | ||
| 312 | #define HCI_ERROR_REMOTE_USER_TERM 0x13 | ||
| 313 | #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14 | ||
| 314 | #define HCI_ERROR_REMOTE_POWER_OFF 0x15 | ||
| 315 | #define HCI_ERROR_LOCAL_HOST_TERM 0x16 | ||
| 316 | #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 | ||
| 317 | |||
| 318 | /* Flow control modes */ | ||
| 319 | #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00 | ||
| 320 | #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01 | ||
| 321 | |||
| 322 | /* The core spec defines 127 as the "not available" value */ | ||
| 323 | #define HCI_TX_POWER_INVALID 127 | ||
| 324 | |||
| 325 | /* Extended Inquiry Response field types */ | ||
| 326 | #define EIR_FLAGS 0x01 /* flags */ | ||
| 327 | #define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */ | ||
| 328 | #define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ | ||
| 329 | #define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */ | ||
| 330 | #define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ | ||
| 331 | #define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */ | ||
| 332 | #define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ | ||
| 333 | #define EIR_NAME_SHORT 0x08 /* shortened local name */ | ||
| 334 | #define EIR_NAME_COMPLETE 0x09 /* complete local name */ | ||
| 335 | #define EIR_TX_POWER 0x0A /* transmit power level */ | ||
| 336 | #define EIR_CLASS_OF_DEV 0x0D /* Class of Device */ | ||
| 337 | #define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */ | ||
| 338 | #define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */ | ||
| 339 | #define EIR_DEVICE_ID 0x10 /* device ID */ | ||
| 340 | |||
| 341 | /* Low Energy Advertising Flags */ | ||
| 342 | #define LE_AD_LIMITED 0x01 /* Limited Discoverable */ | ||
| 343 | #define LE_AD_GENERAL 0x02 /* General Discoverable */ | ||
| 344 | #define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */ | ||
| 345 | #define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */ | ||
| 346 | #define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */ | ||
| 347 | 269 | ||
| 348 | /* ----- HCI Commands ---- */ | 270 | /* ----- HCI Commands ---- */ |
| 349 | #define HCI_OP_NOP 0x0000 | 271 | #define HCI_OP_NOP 0x0000 |
| @@ -357,8 +279,6 @@ struct hci_cp_inquiry { | |||
| 357 | 279 | ||
| 358 | #define HCI_OP_INQUIRY_CANCEL 0x0402 | 280 | #define HCI_OP_INQUIRY_CANCEL 0x0402 |
| 359 | 281 | ||
| 360 | #define HCI_OP_PERIODIC_INQ 0x0403 | ||
| 361 | |||
| 362 | #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 | 282 | #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 |
| 363 | 283 | ||
| 364 | #define HCI_OP_CREATE_CONN 0x0405 | 284 | #define HCI_OP_CREATE_CONN 0x0405 |
| @@ -403,7 +323,7 @@ struct hci_cp_reject_conn_req { | |||
| 403 | #define HCI_OP_LINK_KEY_REPLY 0x040b | 323 | #define HCI_OP_LINK_KEY_REPLY 0x040b |
| 404 | struct hci_cp_link_key_reply { | 324 | struct hci_cp_link_key_reply { |
| 405 | bdaddr_t bdaddr; | 325 | bdaddr_t bdaddr; |
| 406 | __u8 link_key[HCI_LINK_KEY_SIZE]; | 326 | __u8 link_key[16]; |
| 407 | } __packed; | 327 | } __packed; |
| 408 | 328 | ||
| 409 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c | 329 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c |
| @@ -529,14 +449,6 @@ struct hci_rp_user_confirm_reply { | |||
| 529 | 449 | ||
| 530 | #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d | 450 | #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d |
| 531 | 451 | ||
| 532 | #define HCI_OP_USER_PASSKEY_REPLY 0x042e | ||
| 533 | struct hci_cp_user_passkey_reply { | ||
| 534 | bdaddr_t bdaddr; | ||
| 535 | __le32 passkey; | ||
| 536 | } __packed; | ||
| 537 | |||
| 538 | #define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f | ||
| 539 | |||
| 540 | #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 | 452 | #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 |
| 541 | struct hci_cp_remote_oob_data_reply { | 453 | struct hci_cp_remote_oob_data_reply { |
| 542 | bdaddr_t bdaddr; | 454 | bdaddr_t bdaddr; |
| @@ -555,62 +467,6 @@ struct hci_cp_io_capability_neg_reply { | |||
| 555 | __u8 reason; | 467 | __u8 reason; |
| 556 | } __packed; | 468 | } __packed; |
| 557 | 469 | ||
| 558 | #define HCI_OP_CREATE_PHY_LINK 0x0435 | ||
| 559 | struct hci_cp_create_phy_link { | ||
| 560 | __u8 phy_handle; | ||
| 561 | __u8 key_len; | ||
| 562 | __u8 key_type; | ||
| 563 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
| 564 | } __packed; | ||
| 565 | |||
| 566 | #define HCI_OP_ACCEPT_PHY_LINK 0x0436 | ||
| 567 | struct hci_cp_accept_phy_link { | ||
| 568 | __u8 phy_handle; | ||
| 569 | __u8 key_len; | ||
| 570 | __u8 key_type; | ||
| 571 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
| 572 | } __packed; | ||
| 573 | |||
| 574 | #define HCI_OP_DISCONN_PHY_LINK 0x0437 | ||
| 575 | struct hci_cp_disconn_phy_link { | ||
| 576 | __u8 phy_handle; | ||
| 577 | __u8 reason; | ||
| 578 | } __packed; | ||
| 579 | |||
| 580 | struct ext_flow_spec { | ||
| 581 | __u8 id; | ||
| 582 | __u8 stype; | ||
| 583 | __le16 msdu; | ||
| 584 | __le32 sdu_itime; | ||
| 585 | __le32 acc_lat; | ||
| 586 | __le32 flush_to; | ||
| 587 | } __packed; | ||
| 588 | |||
| 589 | #define HCI_OP_CREATE_LOGICAL_LINK 0x0438 | ||
| 590 | #define HCI_OP_ACCEPT_LOGICAL_LINK 0x0439 | ||
| 591 | struct hci_cp_create_accept_logical_link { | ||
| 592 | __u8 phy_handle; | ||
| 593 | struct ext_flow_spec tx_flow_spec; | ||
| 594 | struct ext_flow_spec rx_flow_spec; | ||
| 595 | } __packed; | ||
| 596 | |||
| 597 | #define HCI_OP_DISCONN_LOGICAL_LINK 0x043a | ||
| 598 | struct hci_cp_disconn_logical_link { | ||
| 599 | __le16 log_handle; | ||
| 600 | } __packed; | ||
| 601 | |||
| 602 | #define HCI_OP_LOGICAL_LINK_CANCEL 0x043b | ||
| 603 | struct hci_cp_logical_link_cancel { | ||
| 604 | __u8 phy_handle; | ||
| 605 | __u8 flow_spec_id; | ||
| 606 | } __packed; | ||
| 607 | |||
| 608 | struct hci_rp_logical_link_cancel { | ||
| 609 | __u8 status; | ||
| 610 | __u8 phy_handle; | ||
| 611 | __u8 flow_spec_id; | ||
| 612 | } __packed; | ||
| 613 | |||
| 614 | #define HCI_OP_SNIFF_MODE 0x0803 | 470 | #define HCI_OP_SNIFF_MODE 0x0803 |
| 615 | struct hci_cp_sniff_mode { | 471 | struct hci_cp_sniff_mode { |
| 616 | __le16 handle; | 472 | __le16 handle; |
| @@ -785,8 +641,8 @@ struct hci_cp_host_buffer_size { | |||
| 785 | 641 | ||
| 786 | #define HCI_OP_WRITE_EIR 0x0c52 | 642 | #define HCI_OP_WRITE_EIR 0x0c52 |
| 787 | struct hci_cp_write_eir { | 643 | struct hci_cp_write_eir { |
| 788 | __u8 fec; | 644 | uint8_t fec; |
| 789 | __u8 data[HCI_MAX_EIR_LENGTH]; | 645 | uint8_t data[HCI_MAX_EIR_LENGTH]; |
| 790 | } __packed; | 646 | } __packed; |
| 791 | 647 | ||
| 792 | #define HCI_OP_READ_SSP_MODE 0x0c55 | 648 | #define HCI_OP_READ_SSP_MODE 0x0c55 |
| @@ -808,21 +664,11 @@ struct hci_rp_read_local_oob_data { | |||
| 808 | } __packed; | 664 | } __packed; |
| 809 | 665 | ||
| 810 | #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 | 666 | #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 |
| 811 | struct hci_rp_read_inq_rsp_tx_power { | ||
| 812 | __u8 status; | ||
| 813 | __s8 tx_power; | ||
| 814 | } __packed; | ||
| 815 | |||
| 816 | #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66 | ||
| 817 | struct hci_rp_read_flow_control_mode { | ||
| 818 | __u8 status; | ||
| 819 | __u8 mode; | ||
| 820 | } __packed; | ||
| 821 | 667 | ||
| 822 | #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d | 668 | #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d |
| 823 | struct hci_cp_write_le_host_supported { | 669 | struct hci_cp_write_le_host_supported { |
| 824 | __u8 le; | 670 | __u8 le; |
| 825 | __u8 simul; | 671 | __u8 simul; |
| 826 | } __packed; | 672 | } __packed; |
| 827 | 673 | ||
| 828 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 | 674 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 |
| @@ -873,64 +719,6 @@ struct hci_rp_read_bd_addr { | |||
| 873 | bdaddr_t bdaddr; | 719 | bdaddr_t bdaddr; |
| 874 | } __packed; | 720 | } __packed; |
| 875 | 721 | ||
| 876 | #define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a | ||
| 877 | struct hci_rp_read_data_block_size { | ||
| 878 | __u8 status; | ||
| 879 | __le16 max_acl_len; | ||
| 880 | __le16 block_len; | ||
| 881 | __le16 num_blocks; | ||
| 882 | } __packed; | ||
| 883 | |||
| 884 | #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c | ||
| 885 | struct hci_cp_write_page_scan_activity { | ||
| 886 | __le16 interval; | ||
| 887 | __le16 window; | ||
| 888 | } __packed; | ||
| 889 | |||
| 890 | #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47 | ||
| 891 | #define PAGE_SCAN_TYPE_STANDARD 0x00 | ||
| 892 | #define PAGE_SCAN_TYPE_INTERLACED 0x01 | ||
| 893 | |||
| 894 | #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 | ||
| 895 | struct hci_rp_read_local_amp_info { | ||
| 896 | __u8 status; | ||
| 897 | __u8 amp_status; | ||
| 898 | __le32 total_bw; | ||
| 899 | __le32 max_bw; | ||
| 900 | __le32 min_latency; | ||
| 901 | __le32 max_pdu; | ||
| 902 | __u8 amp_type; | ||
| 903 | __le16 pal_cap; | ||
| 904 | __le16 max_assoc_size; | ||
| 905 | __le32 max_flush_to; | ||
| 906 | __le32 be_flush_to; | ||
| 907 | } __packed; | ||
| 908 | |||
| 909 | #define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a | ||
| 910 | struct hci_cp_read_local_amp_assoc { | ||
| 911 | __u8 phy_handle; | ||
| 912 | __le16 len_so_far; | ||
| 913 | __le16 max_len; | ||
| 914 | } __packed; | ||
| 915 | struct hci_rp_read_local_amp_assoc { | ||
| 916 | __u8 status; | ||
| 917 | __u8 phy_handle; | ||
| 918 | __le16 rem_len; | ||
| 919 | __u8 frag[0]; | ||
| 920 | } __packed; | ||
| 921 | |||
| 922 | #define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b | ||
| 923 | struct hci_cp_write_remote_amp_assoc { | ||
| 924 | __u8 phy_handle; | ||
| 925 | __le16 len_so_far; | ||
| 926 | __le16 rem_len; | ||
| 927 | __u8 frag[0]; | ||
| 928 | } __packed; | ||
| 929 | struct hci_rp_write_remote_amp_assoc { | ||
| 930 | __u8 status; | ||
| 931 | __u8 phy_handle; | ||
| 932 | } __packed; | ||
| 933 | |||
| 934 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 | 722 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 |
| 935 | struct hci_cp_le_set_event_mask { | 723 | struct hci_cp_le_set_event_mask { |
| 936 | __u8 mask[8]; | 724 | __u8 mask[8]; |
| @@ -943,34 +731,6 @@ struct hci_rp_le_read_buffer_size { | |||
| 943 | __u8 le_max_pkt; | 731 | __u8 le_max_pkt; |
| 944 | } __packed; | 732 | } __packed; |
| 945 | 733 | ||
| 946 | #define HCI_OP_LE_READ_ADV_TX_POWER 0x2007 | ||
| 947 | struct hci_rp_le_read_adv_tx_power { | ||
| 948 | __u8 status; | ||
| 949 | __s8 tx_power; | ||
| 950 | } __packed; | ||
| 951 | |||
| 952 | #define HCI_MAX_AD_LENGTH 31 | ||
| 953 | |||
| 954 | #define HCI_OP_LE_SET_ADV_DATA 0x2008 | ||
| 955 | struct hci_cp_le_set_adv_data { | ||
| 956 | __u8 length; | ||
| 957 | __u8 data[HCI_MAX_AD_LENGTH]; | ||
| 958 | } __packed; | ||
| 959 | |||
| 960 | #define HCI_OP_LE_SET_ADV_ENABLE 0x200a | ||
| 961 | |||
| 962 | #define HCI_OP_LE_SET_SCAN_PARAM 0x200b | ||
| 963 | struct hci_cp_le_set_scan_param { | ||
| 964 | __u8 type; | ||
| 965 | __le16 interval; | ||
| 966 | __le16 window; | ||
| 967 | __u8 own_address_type; | ||
| 968 | __u8 filter_policy; | ||
| 969 | } __packed; | ||
| 970 | |||
| 971 | #define LE_SCANNING_DISABLED 0x00 | ||
| 972 | #define LE_SCANNING_ENABLED 0x01 | ||
| 973 | |||
| 974 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c | 734 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c |
| 975 | struct hci_cp_le_set_scan_enable { | 735 | struct hci_cp_le_set_scan_enable { |
| 976 | __u8 enable; | 736 | __u8 enable; |
| @@ -1146,14 +906,9 @@ struct hci_ev_role_change { | |||
| 1146 | } __packed; | 906 | } __packed; |
| 1147 | 907 | ||
| 1148 | #define HCI_EV_NUM_COMP_PKTS 0x13 | 908 | #define HCI_EV_NUM_COMP_PKTS 0x13 |
| 1149 | struct hci_comp_pkts_info { | ||
| 1150 | __le16 handle; | ||
| 1151 | __le16 count; | ||
| 1152 | } __packed; | ||
| 1153 | |||
| 1154 | struct hci_ev_num_comp_pkts { | 909 | struct hci_ev_num_comp_pkts { |
| 1155 | __u8 num_hndl; | 910 | __u8 num_hndl; |
| 1156 | struct hci_comp_pkts_info handles[0]; | 911 | /* variable length part */ |
| 1157 | } __packed; | 912 | } __packed; |
| 1158 | 913 | ||
| 1159 | #define HCI_EV_MODE_CHANGE 0x14 | 914 | #define HCI_EV_MODE_CHANGE 0x14 |
| @@ -1177,7 +932,7 @@ struct hci_ev_link_key_req { | |||
| 1177 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 | 932 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 |
| 1178 | struct hci_ev_link_key_notify { | 933 | struct hci_ev_link_key_notify { |
| 1179 | bdaddr_t bdaddr; | 934 | bdaddr_t bdaddr; |
| 1180 | __u8 link_key[HCI_LINK_KEY_SIZE]; | 935 | __u8 link_key[16]; |
| 1181 | __u8 key_type; | 936 | __u8 key_type; |
| 1182 | } __packed; | 937 | } __packed; |
| 1183 | 938 | ||
| @@ -1273,12 +1028,6 @@ struct extended_inquiry_info { | |||
| 1273 | __u8 data[240]; | 1028 | __u8 data[240]; |
| 1274 | } __packed; | 1029 | } __packed; |
| 1275 | 1030 | ||
| 1276 | #define HCI_EV_KEY_REFRESH_COMPLETE 0x30 | ||
| 1277 | struct hci_ev_key_refresh_complete { | ||
| 1278 | __u8 status; | ||
| 1279 | __le16 handle; | ||
| 1280 | } __packed; | ||
| 1281 | |||
| 1282 | #define HCI_EV_IO_CAPA_REQUEST 0x31 | 1031 | #define HCI_EV_IO_CAPA_REQUEST 0x31 |
| 1283 | struct hci_ev_io_capa_request { | 1032 | struct hci_ev_io_capa_request { |
| 1284 | bdaddr_t bdaddr; | 1033 | bdaddr_t bdaddr; |
| @@ -1298,11 +1047,6 @@ struct hci_ev_user_confirm_req { | |||
| 1298 | __le32 passkey; | 1047 | __le32 passkey; |
| 1299 | } __packed; | 1048 | } __packed; |
| 1300 | 1049 | ||
| 1301 | #define HCI_EV_USER_PASSKEY_REQUEST 0x34 | ||
| 1302 | struct hci_ev_user_passkey_req { | ||
| 1303 | bdaddr_t bdaddr; | ||
| 1304 | } __packed; | ||
| 1305 | |||
| 1306 | #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 | 1050 | #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 |
| 1307 | struct hci_ev_remote_oob_data_request { | 1051 | struct hci_ev_remote_oob_data_request { |
| 1308 | bdaddr_t bdaddr; | 1052 | bdaddr_t bdaddr; |
| @@ -1314,24 +1058,6 @@ struct hci_ev_simple_pair_complete { | |||
| 1314 | bdaddr_t bdaddr; | 1058 | bdaddr_t bdaddr; |
| 1315 | } __packed; | 1059 | } __packed; |
| 1316 | 1060 | ||
| 1317 | #define HCI_EV_USER_PASSKEY_NOTIFY 0x3b | ||
| 1318 | struct hci_ev_user_passkey_notify { | ||
| 1319 | bdaddr_t bdaddr; | ||
| 1320 | __le32 passkey; | ||
| 1321 | } __packed; | ||
| 1322 | |||
| 1323 | #define HCI_KEYPRESS_STARTED 0 | ||
| 1324 | #define HCI_KEYPRESS_ENTERED 1 | ||
| 1325 | #define HCI_KEYPRESS_ERASED 2 | ||
| 1326 | #define HCI_KEYPRESS_CLEARED 3 | ||
| 1327 | #define HCI_KEYPRESS_COMPLETED 4 | ||
| 1328 | |||
| 1329 | #define HCI_EV_KEYPRESS_NOTIFY 0x3c | ||
| 1330 | struct hci_ev_keypress_notify { | ||
| 1331 | bdaddr_t bdaddr; | ||
| 1332 | __u8 type; | ||
| 1333 | } __packed; | ||
| 1334 | |||
| 1335 | #define HCI_EV_REMOTE_HOST_FEATURES 0x3d | 1061 | #define HCI_EV_REMOTE_HOST_FEATURES 0x3d |
| 1336 | struct hci_ev_remote_host_features { | 1062 | struct hci_ev_remote_host_features { |
| 1337 | bdaddr_t bdaddr; | 1063 | bdaddr_t bdaddr; |
| @@ -1343,55 +1069,7 @@ struct hci_ev_le_meta { | |||
| 1343 | __u8 subevent; | 1069 | __u8 subevent; |
| 1344 | } __packed; | 1070 | } __packed; |
| 1345 | 1071 | ||
| 1346 | #define HCI_EV_PHY_LINK_COMPLETE 0x40 | ||
| 1347 | struct hci_ev_phy_link_complete { | ||
| 1348 | __u8 status; | ||
| 1349 | __u8 phy_handle; | ||
| 1350 | } __packed; | ||
| 1351 | |||
| 1352 | #define HCI_EV_CHANNEL_SELECTED 0x41 | ||
| 1353 | struct hci_ev_channel_selected { | ||
| 1354 | __u8 phy_handle; | ||
| 1355 | } __packed; | ||
| 1356 | |||
| 1357 | #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42 | ||
| 1358 | struct hci_ev_disconn_phy_link_complete { | ||
| 1359 | __u8 status; | ||
| 1360 | __u8 phy_handle; | ||
| 1361 | __u8 reason; | ||
| 1362 | } __packed; | ||
| 1363 | |||
| 1364 | #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45 | ||
| 1365 | struct hci_ev_logical_link_complete { | ||
| 1366 | __u8 status; | ||
| 1367 | __le16 handle; | ||
| 1368 | __u8 phy_handle; | ||
| 1369 | __u8 flow_spec_id; | ||
| 1370 | } __packed; | ||
| 1371 | |||
| 1372 | #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46 | ||
| 1373 | struct hci_ev_disconn_logical_link_complete { | ||
| 1374 | __u8 status; | ||
| 1375 | __le16 handle; | ||
| 1376 | __u8 reason; | ||
| 1377 | } __packed; | ||
| 1378 | |||
| 1379 | #define HCI_EV_NUM_COMP_BLOCKS 0x48 | ||
| 1380 | struct hci_comp_blocks_info { | ||
| 1381 | __le16 handle; | ||
| 1382 | __le16 pkts; | ||
| 1383 | __le16 blocks; | ||
| 1384 | } __packed; | ||
| 1385 | |||
| 1386 | struct hci_ev_num_comp_blocks { | ||
| 1387 | __le16 num_blocks; | ||
| 1388 | __u8 num_hndl; | ||
| 1389 | struct hci_comp_blocks_info handles[0]; | ||
| 1390 | } __packed; | ||
| 1391 | |||
| 1392 | /* Low energy meta events */ | 1072 | /* Low energy meta events */ |
| 1393 | #define LE_CONN_ROLE_MASTER 0x00 | ||
| 1394 | |||
| 1395 | #define HCI_EV_LE_CONN_COMPLETE 0x01 | 1073 | #define HCI_EV_LE_CONN_COMPLETE 0x01 |
| 1396 | struct hci_ev_le_conn_complete { | 1074 | struct hci_ev_le_conn_complete { |
| 1397 | __u8 status; | 1075 | __u8 status; |
| @@ -1478,6 +1156,7 @@ struct hci_sco_hdr { | |||
| 1478 | __u8 dlen; | 1156 | __u8 dlen; |
| 1479 | } __packed; | 1157 | } __packed; |
| 1480 | 1158 | ||
| 1159 | #include <linux/skbuff.h> | ||
| 1481 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) | 1160 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) |
| 1482 | { | 1161 | { |
| 1483 | return (struct hci_event_hdr *) skb->data; | 1162 | return (struct hci_event_hdr *) skb->data; |
| @@ -1494,12 +1173,12 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) | |||
| 1494 | } | 1173 | } |
| 1495 | 1174 | ||
| 1496 | /* Command opcode pack/unpack */ | 1175 | /* Command opcode pack/unpack */ |
| 1497 | #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10))) | 1176 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) |
| 1498 | #define hci_opcode_ogf(op) (op >> 10) | 1177 | #define hci_opcode_ogf(op) (op >> 10) |
| 1499 | #define hci_opcode_ocf(op) (op & 0x03ff) | 1178 | #define hci_opcode_ocf(op) (op & 0x03ff) |
| 1500 | 1179 | ||
| 1501 | /* ACL handle and flags pack/unpack */ | 1180 | /* ACL handle and flags pack/unpack */ |
| 1502 | #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12))) | 1181 | #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) |
| 1503 | #define hci_handle(h) (h & 0x0fff) | 1182 | #define hci_handle(h) (h & 0x0fff) |
| 1504 | #define hci_flags(h) (h >> 12) | 1183 | #define hci_flags(h) (h >> 12) |
| 1505 | 1184 | ||
| @@ -1522,8 +1201,7 @@ struct sockaddr_hci { | |||
| 1522 | #define HCI_DEV_NONE 0xffff | 1201 | #define HCI_DEV_NONE 0xffff |
| 1523 | 1202 | ||
| 1524 | #define HCI_CHANNEL_RAW 0 | 1203 | #define HCI_CHANNEL_RAW 0 |
| 1525 | #define HCI_CHANNEL_MONITOR 2 | 1204 | #define HCI_CHANNEL_CONTROL 1 |
| 1526 | #define HCI_CHANNEL_CONTROL 3 | ||
| 1527 | 1205 | ||
| 1528 | struct hci_filter { | 1206 | struct hci_filter { |
| 1529 | unsigned long type_mask; | 1207 | unsigned long type_mask; |
| @@ -1586,6 +1264,9 @@ struct hci_conn_info { | |||
| 1586 | __u8 out; | 1264 | __u8 out; |
| 1587 | __u16 state; | 1265 | __u16 state; |
| 1588 | __u32 link_mode; | 1266 | __u32 link_mode; |
| 1267 | __u32 mtu; | ||
| 1268 | __u32 cnt; | ||
| 1269 | __u32 pkts; | ||
| 1589 | }; | 1270 | }; |
| 1590 | 1271 | ||
| 1591 | struct hci_dev_req { | 1272 | struct hci_dev_req { |
| @@ -1624,6 +1305,4 @@ struct hci_inquiry_req { | |||
| 1624 | }; | 1305 | }; |
| 1625 | #define IREQ_CACHE_FLUSH 0x0001 | 1306 | #define IREQ_CACHE_FLUSH 0x0001 |
| 1626 | 1307 | ||
| 1627 | extern bool enable_hs; | ||
| 1628 | |||
| 1629 | #endif /* __HCI_H */ | 1308 | #endif /* __HCI_H */ |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 014a2eaa538..626f8b0a679 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
| @@ -25,10 +25,12 @@ | |||
| 25 | #ifndef __HCI_CORE_H | 25 | #ifndef __HCI_CORE_H |
| 26 | #define __HCI_CORE_H | 26 | #define __HCI_CORE_H |
| 27 | 27 | ||
| 28 | #include <linux/interrupt.h> | ||
| 28 | #include <net/bluetooth/hci.h> | 29 | #include <net/bluetooth/hci.h> |
| 29 | 30 | ||
| 30 | /* HCI priority */ | 31 | /* HCI upper protocols */ |
| 31 | #define HCI_PRIO_MAX 7 | 32 | #define HCI_PROTO_L2CAP 0 |
| 33 | #define HCI_PROTO_SCO 1 | ||
| 32 | 34 | ||
| 33 | /* HCI Core structures */ | 35 | /* HCI Core structures */ |
| 34 | struct inquiry_data { | 36 | struct inquiry_data { |
| @@ -43,37 +45,21 @@ struct inquiry_data { | |||
| 43 | }; | 45 | }; |
| 44 | 46 | ||
| 45 | struct inquiry_entry { | 47 | struct inquiry_entry { |
| 46 | struct list_head all; /* inq_cache.all */ | 48 | struct inquiry_entry *next; |
| 47 | struct list_head list; /* unknown or resolve */ | ||
| 48 | enum { | ||
| 49 | NAME_NOT_KNOWN, | ||
| 50 | NAME_NEEDED, | ||
| 51 | NAME_PENDING, | ||
| 52 | NAME_KNOWN, | ||
| 53 | } name_state; | ||
| 54 | __u32 timestamp; | 49 | __u32 timestamp; |
| 55 | struct inquiry_data data; | 50 | struct inquiry_data data; |
| 56 | }; | 51 | }; |
| 57 | 52 | ||
| 58 | struct discovery_state { | 53 | struct inquiry_cache { |
| 59 | int type; | 54 | spinlock_t lock; |
| 60 | enum { | ||
| 61 | DISCOVERY_STOPPED, | ||
| 62 | DISCOVERY_STARTING, | ||
| 63 | DISCOVERY_FINDING, | ||
| 64 | DISCOVERY_RESOLVING, | ||
| 65 | DISCOVERY_STOPPING, | ||
| 66 | } state; | ||
| 67 | struct list_head all; /* All devices found during inquiry */ | ||
| 68 | struct list_head unknown; /* Name state not known */ | ||
| 69 | struct list_head resolve; /* Name needs to be resolved */ | ||
| 70 | __u32 timestamp; | 55 | __u32 timestamp; |
| 56 | struct inquiry_entry *list; | ||
| 71 | }; | 57 | }; |
| 72 | 58 | ||
| 73 | struct hci_conn_hash { | 59 | struct hci_conn_hash { |
| 74 | struct list_head list; | 60 | struct list_head list; |
| 61 | spinlock_t lock; | ||
| 75 | unsigned int acl_num; | 62 | unsigned int acl_num; |
| 76 | unsigned int amp_num; | ||
| 77 | unsigned int sco_num; | 63 | unsigned int sco_num; |
| 78 | unsigned int le_num; | 64 | unsigned int le_num; |
| 79 | }; | 65 | }; |
| @@ -89,24 +75,28 @@ struct bt_uuid { | |||
| 89 | u8 svc_hint; | 75 | u8 svc_hint; |
| 90 | }; | 76 | }; |
| 91 | 77 | ||
| 92 | struct smp_ltk { | 78 | struct key_master_id { |
| 93 | struct list_head list; | ||
| 94 | bdaddr_t bdaddr; | ||
| 95 | u8 bdaddr_type; | ||
| 96 | u8 authenticated; | ||
| 97 | u8 type; | ||
| 98 | u8 enc_size; | ||
| 99 | __le16 ediv; | 79 | __le16 ediv; |
| 100 | u8 rand[8]; | 80 | u8 rand[8]; |
| 81 | } __packed; | ||
| 82 | |||
| 83 | struct link_key_data { | ||
| 84 | bdaddr_t bdaddr; | ||
| 85 | u8 type; | ||
| 101 | u8 val[16]; | 86 | u8 val[16]; |
| 87 | u8 pin_len; | ||
| 88 | u8 dlen; | ||
| 89 | u8 data[0]; | ||
| 102 | } __packed; | 90 | } __packed; |
| 103 | 91 | ||
| 104 | struct link_key { | 92 | struct link_key { |
| 105 | struct list_head list; | 93 | struct list_head list; |
| 106 | bdaddr_t bdaddr; | 94 | bdaddr_t bdaddr; |
| 107 | u8 type; | 95 | u8 type; |
| 108 | u8 val[HCI_LINK_KEY_SIZE]; | 96 | u8 val[16]; |
| 109 | u8 pin_len; | 97 | u8 pin_len; |
| 98 | u8 dlen; | ||
| 99 | u8 data[0]; | ||
| 110 | }; | 100 | }; |
| 111 | 101 | ||
| 112 | struct oob_data { | 102 | struct oob_data { |
| @@ -116,27 +106,17 @@ struct oob_data { | |||
| 116 | u8 randomizer[16]; | 106 | u8 randomizer[16]; |
| 117 | }; | 107 | }; |
| 118 | 108 | ||
| 119 | struct le_scan_params { | 109 | struct adv_entry { |
| 120 | u8 type; | 110 | struct list_head list; |
| 121 | u16 interval; | 111 | bdaddr_t bdaddr; |
| 122 | u16 window; | 112 | u8 bdaddr_type; |
| 123 | int timeout; | ||
| 124 | }; | ||
| 125 | |||
| 126 | #define HCI_MAX_SHORT_NAME_LENGTH 10 | ||
| 127 | |||
| 128 | struct amp_assoc { | ||
| 129 | __u16 len; | ||
| 130 | __u16 offset; | ||
| 131 | __u16 rem_len; | ||
| 132 | __u16 len_so_far; | ||
| 133 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; | ||
| 134 | }; | 113 | }; |
| 135 | 114 | ||
| 136 | #define NUM_REASSEMBLY 4 | 115 | #define NUM_REASSEMBLY 4 |
| 137 | struct hci_dev { | 116 | struct hci_dev { |
| 138 | struct list_head list; | 117 | struct list_head list; |
| 139 | struct mutex lock; | 118 | spinlock_t lock; |
| 119 | atomic_t refcnt; | ||
| 140 | 120 | ||
| 141 | char name[8]; | 121 | char name[8]; |
| 142 | unsigned long flags; | 122 | unsigned long flags; |
| @@ -145,26 +125,21 @@ struct hci_dev { | |||
| 145 | __u8 dev_type; | 125 | __u8 dev_type; |
| 146 | bdaddr_t bdaddr; | 126 | bdaddr_t bdaddr; |
| 147 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; | 127 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
| 148 | __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; | ||
| 149 | __u8 eir[HCI_MAX_EIR_LENGTH]; | 128 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
| 150 | __u8 dev_class[3]; | 129 | __u8 dev_class[3]; |
| 151 | __u8 major_class; | 130 | __u8 major_class; |
| 152 | __u8 minor_class; | 131 | __u8 minor_class; |
| 153 | __u8 features[8]; | 132 | __u8 features[8]; |
| 154 | __u8 host_features[8]; | 133 | __u8 extfeatures[8]; |
| 155 | __u8 commands[64]; | 134 | __u8 commands[64]; |
| 135 | __u8 ssp_mode; | ||
| 156 | __u8 hci_ver; | 136 | __u8 hci_ver; |
| 157 | __u16 hci_rev; | 137 | __u16 hci_rev; |
| 158 | __u8 lmp_ver; | 138 | __u8 lmp_ver; |
| 159 | __u16 manufacturer; | 139 | __u16 manufacturer; |
| 160 | __u16 lmp_subver; | 140 | __le16 lmp_subver; |
| 161 | __u16 voice_setting; | 141 | __u16 voice_setting; |
| 162 | __u8 io_capability; | 142 | __u8 io_capability; |
| 163 | __s8 inq_tx_power; | ||
| 164 | __u16 devid_source; | ||
| 165 | __u16 devid_vendor; | ||
| 166 | __u16 devid_product; | ||
| 167 | __u16 devid_version; | ||
| 168 | 143 | ||
| 169 | __u16 pkt_type; | 144 | __u16 pkt_type; |
| 170 | __u16 esco_type; | 145 | __u16 esco_type; |
| @@ -175,21 +150,6 @@ struct hci_dev { | |||
| 175 | __u16 sniff_min_interval; | 150 | __u16 sniff_min_interval; |
| 176 | __u16 sniff_max_interval; | 151 | __u16 sniff_max_interval; |
| 177 | 152 | ||
| 178 | __u8 amp_status; | ||
| 179 | __u32 amp_total_bw; | ||
| 180 | __u32 amp_max_bw; | ||
| 181 | __u32 amp_min_latency; | ||
| 182 | __u32 amp_max_pdu; | ||
| 183 | __u8 amp_type; | ||
| 184 | __u16 amp_pal_cap; | ||
| 185 | __u16 amp_assoc_size; | ||
| 186 | __u32 amp_max_flush_to; | ||
| 187 | __u32 amp_be_flush_to; | ||
| 188 | |||
| 189 | struct amp_assoc loc_assoc; | ||
| 190 | |||
| 191 | __u8 flow_ctl_mode; | ||
| 192 | |||
| 193 | unsigned int auto_accept_delay; | 153 | unsigned int auto_accept_delay; |
| 194 | 154 | ||
| 195 | unsigned long quirks; | 155 | unsigned long quirks; |
| @@ -206,11 +166,6 @@ struct hci_dev { | |||
| 206 | unsigned int sco_pkts; | 166 | unsigned int sco_pkts; |
| 207 | unsigned int le_pkts; | 167 | unsigned int le_pkts; |
| 208 | 168 | ||
| 209 | __u16 block_len; | ||
| 210 | __u16 block_mtu; | ||
| 211 | __u16 num_blocks; | ||
| 212 | __u16 block_cnt; | ||
| 213 | |||
| 214 | unsigned long acl_last_tx; | 169 | unsigned long acl_last_tx; |
| 215 | unsigned long sco_last_tx; | 170 | unsigned long sco_last_tx; |
| 216 | unsigned long le_last_tx; | 171 | unsigned long le_last_tx; |
| @@ -218,18 +173,13 @@ struct hci_dev { | |||
| 218 | struct workqueue_struct *workqueue; | 173 | struct workqueue_struct *workqueue; |
| 219 | 174 | ||
| 220 | struct work_struct power_on; | 175 | struct work_struct power_on; |
| 221 | struct delayed_work power_off; | 176 | struct work_struct power_off; |
| 222 | 177 | struct timer_list off_timer; | |
| 223 | __u16 discov_timeout; | ||
| 224 | struct delayed_work discov_off; | ||
| 225 | |||
| 226 | struct delayed_work service_cache; | ||
| 227 | 178 | ||
| 228 | struct timer_list cmd_timer; | 179 | struct timer_list cmd_timer; |
| 229 | 180 | struct tasklet_struct cmd_task; | |
| 230 | struct work_struct rx_work; | 181 | struct tasklet_struct rx_task; |
| 231 | struct work_struct cmd_work; | 182 | struct tasklet_struct tx_task; |
| 232 | struct work_struct tx_work; | ||
| 233 | 183 | ||
| 234 | struct sk_buff_head rx_q; | 184 | struct sk_buff_head rx_q; |
| 235 | struct sk_buff_head raw_q; | 185 | struct sk_buff_head raw_q; |
| @@ -245,9 +195,9 @@ struct hci_dev { | |||
| 245 | 195 | ||
| 246 | __u16 init_last_cmd; | 196 | __u16 init_last_cmd; |
| 247 | 197 | ||
| 248 | struct list_head mgmt_pending; | 198 | struct crypto_blkcipher *tfm; |
| 249 | 199 | ||
| 250 | struct discovery_state discovery; | 200 | struct inquiry_cache inq_cache; |
| 251 | struct hci_conn_hash conn_hash; | 201 | struct hci_conn_hash conn_hash; |
| 252 | struct list_head blacklist; | 202 | struct list_head blacklist; |
| 253 | 203 | ||
| @@ -255,43 +205,38 @@ struct hci_dev { | |||
| 255 | 205 | ||
| 256 | struct list_head link_keys; | 206 | struct list_head link_keys; |
| 257 | 207 | ||
| 258 | struct list_head long_term_keys; | ||
| 259 | |||
| 260 | struct list_head remote_oob_data; | 208 | struct list_head remote_oob_data; |
| 261 | 209 | ||
| 210 | struct list_head adv_entries; | ||
| 211 | struct timer_list adv_timer; | ||
| 212 | |||
| 262 | struct hci_dev_stats stat; | 213 | struct hci_dev_stats stat; |
| 263 | 214 | ||
| 264 | struct sk_buff_head driver_init; | 215 | struct sk_buff_head driver_init; |
| 265 | 216 | ||
| 217 | void *driver_data; | ||
| 218 | void *core_data; | ||
| 219 | |||
| 266 | atomic_t promisc; | 220 | atomic_t promisc; |
| 267 | 221 | ||
| 268 | struct dentry *debugfs; | 222 | struct dentry *debugfs; |
| 269 | 223 | ||
| 224 | struct device *parent; | ||
| 270 | struct device dev; | 225 | struct device dev; |
| 271 | 226 | ||
| 272 | struct rfkill *rfkill; | 227 | struct rfkill *rfkill; |
| 273 | 228 | ||
| 274 | unsigned long dev_flags; | 229 | struct module *owner; |
| 275 | |||
| 276 | struct delayed_work le_scan_disable; | ||
| 277 | |||
| 278 | struct work_struct le_scan; | ||
| 279 | struct le_scan_params le_scan_params; | ||
| 280 | |||
| 281 | __s8 adv_tx_power; | ||
| 282 | __u8 adv_data[HCI_MAX_AD_LENGTH]; | ||
| 283 | __u8 adv_data_len; | ||
| 284 | 230 | ||
| 285 | int (*open)(struct hci_dev *hdev); | 231 | int (*open)(struct hci_dev *hdev); |
| 286 | int (*close)(struct hci_dev *hdev); | 232 | int (*close)(struct hci_dev *hdev); |
| 287 | int (*flush)(struct hci_dev *hdev); | 233 | int (*flush)(struct hci_dev *hdev); |
| 288 | int (*send)(struct sk_buff *skb); | 234 | int (*send)(struct sk_buff *skb); |
| 235 | void (*destruct)(struct hci_dev *hdev); | ||
| 289 | void (*notify)(struct hci_dev *hdev, unsigned int evt); | 236 | void (*notify)(struct hci_dev *hdev, unsigned int evt); |
| 290 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); | 237 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); |
| 291 | }; | 238 | }; |
| 292 | 239 | ||
| 293 | #define HCI_PHY_HANDLE(handle) (handle & 0xff) | ||
| 294 | |||
| 295 | struct hci_conn { | 240 | struct hci_conn { |
| 296 | struct list_head list; | 241 | struct list_head list; |
| 297 | 242 | ||
| @@ -303,10 +248,11 @@ struct hci_conn { | |||
| 303 | __u16 state; | 248 | __u16 state; |
| 304 | __u8 mode; | 249 | __u8 mode; |
| 305 | __u8 type; | 250 | __u8 type; |
| 306 | bool out; | 251 | __u8 out; |
| 307 | __u8 attempt; | 252 | __u8 attempt; |
| 308 | __u8 dev_class[3]; | 253 | __u8 dev_class[3]; |
| 309 | __u8 features[8]; | 254 | __u8 features[8]; |
| 255 | __u8 ssp_mode; | ||
| 310 | __u16 interval; | 256 | __u16 interval; |
| 311 | __u16 pkt_type; | 257 | __u16 pkt_type; |
| 312 | __u16 link_policy; | 258 | __u16 link_policy; |
| @@ -318,33 +264,31 @@ struct hci_conn { | |||
| 318 | __u8 pin_length; | 264 | __u8 pin_length; |
| 319 | __u8 enc_key_size; | 265 | __u8 enc_key_size; |
| 320 | __u8 io_capability; | 266 | __u8 io_capability; |
| 321 | __u32 passkey_notify; | 267 | __u8 power_save; |
| 322 | __u8 passkey_entered; | ||
| 323 | __u16 disc_timeout; | 268 | __u16 disc_timeout; |
| 324 | unsigned long flags; | 269 | unsigned long pend; |
| 325 | 270 | ||
| 326 | __u8 remote_cap; | 271 | __u8 remote_cap; |
| 272 | __u8 remote_oob; | ||
| 327 | __u8 remote_auth; | 273 | __u8 remote_auth; |
| 328 | __u8 remote_id; | ||
| 329 | bool flush_key; | ||
| 330 | 274 | ||
| 331 | unsigned int sent; | 275 | unsigned int sent; |
| 332 | 276 | ||
| 333 | struct sk_buff_head data_q; | 277 | struct sk_buff_head data_q; |
| 334 | struct list_head chan_list; | ||
| 335 | 278 | ||
| 336 | struct delayed_work disc_work; | 279 | struct timer_list disc_timer; |
| 337 | struct timer_list idle_timer; | 280 | struct timer_list idle_timer; |
| 338 | struct timer_list auto_accept_timer; | 281 | struct timer_list auto_accept_timer; |
| 339 | 282 | ||
| 283 | struct work_struct work_add; | ||
| 284 | struct work_struct work_del; | ||
| 285 | |||
| 340 | struct device dev; | 286 | struct device dev; |
| 341 | atomic_t devref; | 287 | atomic_t devref; |
| 342 | 288 | ||
| 343 | struct hci_dev *hdev; | 289 | struct hci_dev *hdev; |
| 344 | void *l2cap_data; | 290 | void *l2cap_data; |
| 345 | void *sco_data; | 291 | void *sco_data; |
| 346 | void *smp_conn; | ||
| 347 | struct amp_mgr *amp_mgr; | ||
| 348 | 292 | ||
| 349 | struct hci_conn *link; | 293 | struct hci_conn *link; |
| 350 | 294 | ||
| @@ -353,58 +297,37 @@ struct hci_conn { | |||
| 353 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); | 297 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); |
| 354 | }; | 298 | }; |
| 355 | 299 | ||
| 356 | struct hci_chan { | 300 | extern struct hci_proto *hci_proto[]; |
| 357 | struct list_head list; | ||
| 358 | __u16 handle; | ||
| 359 | struct hci_conn *conn; | ||
| 360 | struct sk_buff_head data_q; | ||
| 361 | unsigned int sent; | ||
| 362 | __u8 state; | ||
| 363 | }; | ||
| 364 | |||
| 365 | extern struct list_head hci_dev_list; | 301 | extern struct list_head hci_dev_list; |
| 366 | extern struct list_head hci_cb_list; | 302 | extern struct list_head hci_cb_list; |
| 367 | extern rwlock_t hci_dev_list_lock; | 303 | extern rwlock_t hci_dev_list_lock; |
| 368 | extern rwlock_t hci_cb_list_lock; | 304 | extern rwlock_t hci_cb_list_lock; |
| 369 | 305 | ||
| 370 | /* ----- HCI interface to upper protocols ----- */ | ||
| 371 | extern int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
| 372 | extern void l2cap_connect_cfm(struct hci_conn *hcon, u8 status); | ||
| 373 | extern int l2cap_disconn_ind(struct hci_conn *hcon); | ||
| 374 | extern void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); | ||
| 375 | extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); | ||
| 376 | extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, | ||
| 377 | u16 flags); | ||
| 378 | |||
| 379 | extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); | ||
| 380 | extern void sco_connect_cfm(struct hci_conn *hcon, __u8 status); | ||
| 381 | extern void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason); | ||
| 382 | extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); | ||
| 383 | |||
| 384 | /* ----- Inquiry cache ----- */ | 306 | /* ----- Inquiry cache ----- */ |
| 385 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ | 307 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
| 386 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ | 308 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
| 387 | 309 | ||
| 388 | static inline void discovery_init(struct hci_dev *hdev) | 310 | #define inquiry_cache_lock(c) spin_lock(&c->lock) |
| 311 | #define inquiry_cache_unlock(c) spin_unlock(&c->lock) | ||
| 312 | #define inquiry_cache_lock_bh(c) spin_lock_bh(&c->lock) | ||
| 313 | #define inquiry_cache_unlock_bh(c) spin_unlock_bh(&c->lock) | ||
| 314 | |||
| 315 | static inline void inquiry_cache_init(struct hci_dev *hdev) | ||
| 389 | { | 316 | { |
| 390 | hdev->discovery.state = DISCOVERY_STOPPED; | 317 | struct inquiry_cache *c = &hdev->inq_cache; |
| 391 | INIT_LIST_HEAD(&hdev->discovery.all); | 318 | spin_lock_init(&c->lock); |
| 392 | INIT_LIST_HEAD(&hdev->discovery.unknown); | 319 | c->list = NULL; |
| 393 | INIT_LIST_HEAD(&hdev->discovery.resolve); | ||
| 394 | } | 320 | } |
| 395 | 321 | ||
| 396 | bool hci_discovery_active(struct hci_dev *hdev); | ||
| 397 | |||
| 398 | void hci_discovery_set_state(struct hci_dev *hdev, int state); | ||
| 399 | |||
| 400 | static inline int inquiry_cache_empty(struct hci_dev *hdev) | 322 | static inline int inquiry_cache_empty(struct hci_dev *hdev) |
| 401 | { | 323 | { |
| 402 | return list_empty(&hdev->discovery.all); | 324 | struct inquiry_cache *c = &hdev->inq_cache; |
| 325 | return c->list == NULL; | ||
| 403 | } | 326 | } |
| 404 | 327 | ||
| 405 | static inline long inquiry_cache_age(struct hci_dev *hdev) | 328 | static inline long inquiry_cache_age(struct hci_dev *hdev) |
| 406 | { | 329 | { |
| 407 | struct discovery_state *c = &hdev->discovery; | 330 | struct inquiry_cache *c = &hdev->inq_cache; |
| 408 | return jiffies - c->timestamp; | 331 | return jiffies - c->timestamp; |
| 409 | } | 332 | } |
| 410 | 333 | ||
| @@ -414,16 +337,8 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) | |||
| 414 | } | 337 | } |
| 415 | 338 | ||
| 416 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, | 339 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, |
| 417 | bdaddr_t *bdaddr); | 340 | bdaddr_t *bdaddr); |
| 418 | struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, | 341 | void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); |
| 419 | bdaddr_t *bdaddr); | ||
| 420 | struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, | ||
| 421 | bdaddr_t *bdaddr, | ||
| 422 | int state); | ||
| 423 | void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, | ||
| 424 | struct inquiry_entry *ie); | ||
| 425 | bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, | ||
| 426 | bool name_known, bool *ssp); | ||
| 427 | 342 | ||
| 428 | /* ----- HCI Connections ----- */ | 343 | /* ----- HCI Connections ----- */ |
| 429 | enum { | 344 | enum { |
| @@ -433,31 +348,25 @@ enum { | |||
| 433 | HCI_CONN_RSWITCH_PEND, | 348 | HCI_CONN_RSWITCH_PEND, |
| 434 | HCI_CONN_MODE_CHANGE_PEND, | 349 | HCI_CONN_MODE_CHANGE_PEND, |
| 435 | HCI_CONN_SCO_SETUP_PEND, | 350 | HCI_CONN_SCO_SETUP_PEND, |
| 436 | HCI_CONN_LE_SMP_PEND, | ||
| 437 | HCI_CONN_MGMT_CONNECTED, | ||
| 438 | HCI_CONN_SSP_ENABLED, | ||
| 439 | HCI_CONN_POWER_SAVE, | ||
| 440 | HCI_CONN_REMOTE_OOB, | ||
| 441 | }; | 351 | }; |
| 442 | 352 | ||
| 443 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) | 353 | static inline void hci_conn_hash_init(struct hci_dev *hdev) |
| 444 | { | 354 | { |
| 445 | struct hci_dev *hdev = conn->hdev; | 355 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 446 | return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 356 | INIT_LIST_HEAD(&h->list); |
| 447 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); | 357 | spin_lock_init(&h->lock); |
| 358 | h->acl_num = 0; | ||
| 359 | h->sco_num = 0; | ||
| 448 | } | 360 | } |
| 449 | 361 | ||
| 450 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | 362 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) |
| 451 | { | 363 | { |
| 452 | struct hci_conn_hash *h = &hdev->conn_hash; | 364 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 453 | list_add_rcu(&c->list, &h->list); | 365 | list_add(&c->list, &h->list); |
| 454 | switch (c->type) { | 366 | switch (c->type) { |
| 455 | case ACL_LINK: | 367 | case ACL_LINK: |
| 456 | h->acl_num++; | 368 | h->acl_num++; |
| 457 | break; | 369 | break; |
| 458 | case AMP_LINK: | ||
| 459 | h->amp_num++; | ||
| 460 | break; | ||
| 461 | case LE_LINK: | 370 | case LE_LINK: |
| 462 | h->le_num++; | 371 | h->le_num++; |
| 463 | break; | 372 | break; |
| @@ -471,17 +380,11 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | |||
| 471 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | 380 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) |
| 472 | { | 381 | { |
| 473 | struct hci_conn_hash *h = &hdev->conn_hash; | 382 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 474 | 383 | list_del(&c->list); | |
| 475 | list_del_rcu(&c->list); | ||
| 476 | synchronize_rcu(); | ||
| 477 | |||
| 478 | switch (c->type) { | 384 | switch (c->type) { |
| 479 | case ACL_LINK: | 385 | case ACL_LINK: |
| 480 | h->acl_num--; | 386 | h->acl_num--; |
| 481 | break; | 387 | break; |
| 482 | case AMP_LINK: | ||
| 483 | h->amp_num--; | ||
| 484 | break; | ||
| 485 | case LE_LINK: | 388 | case LE_LINK: |
| 486 | h->le_num--; | 389 | h->le_num--; |
| 487 | break; | 390 | break; |
| @@ -492,40 +395,18 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | |||
| 492 | } | 395 | } |
| 493 | } | 396 | } |
| 494 | 397 | ||
| 495 | static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) | ||
| 496 | { | ||
| 497 | struct hci_conn_hash *h = &hdev->conn_hash; | ||
| 498 | switch (type) { | ||
| 499 | case ACL_LINK: | ||
| 500 | return h->acl_num; | ||
| 501 | case AMP_LINK: | ||
| 502 | return h->amp_num; | ||
| 503 | case LE_LINK: | ||
| 504 | return h->le_num; | ||
| 505 | case SCO_LINK: | ||
| 506 | case ESCO_LINK: | ||
| 507 | return h->sco_num; | ||
| 508 | default: | ||
| 509 | return 0; | ||
| 510 | } | ||
| 511 | } | ||
| 512 | |||
| 513 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, | 398 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
| 514 | __u16 handle) | 399 | __u16 handle) |
| 515 | { | 400 | { |
| 516 | struct hci_conn_hash *h = &hdev->conn_hash; | 401 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 402 | struct list_head *p; | ||
| 517 | struct hci_conn *c; | 403 | struct hci_conn *c; |
| 518 | 404 | ||
| 519 | rcu_read_lock(); | 405 | list_for_each(p, &h->list) { |
| 520 | 406 | c = list_entry(p, struct hci_conn, list); | |
| 521 | list_for_each_entry_rcu(c, &h->list, list) { | 407 | if (c->handle == handle) |
| 522 | if (c->handle == handle) { | ||
| 523 | rcu_read_unlock(); | ||
| 524 | return c; | 408 | return c; |
| 525 | } | ||
| 526 | } | 409 | } |
| 527 | rcu_read_unlock(); | ||
| 528 | |||
| 529 | return NULL; | 410 | return NULL; |
| 530 | } | 411 | } |
| 531 | 412 | ||
| @@ -533,19 +414,14 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, | |||
| 533 | __u8 type, bdaddr_t *ba) | 414 | __u8 type, bdaddr_t *ba) |
| 534 | { | 415 | { |
| 535 | struct hci_conn_hash *h = &hdev->conn_hash; | 416 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 417 | struct list_head *p; | ||
| 536 | struct hci_conn *c; | 418 | struct hci_conn *c; |
| 537 | 419 | ||
| 538 | rcu_read_lock(); | 420 | list_for_each(p, &h->list) { |
| 539 | 421 | c = list_entry(p, struct hci_conn, list); | |
| 540 | list_for_each_entry_rcu(c, &h->list, list) { | 422 | if (c->type == type && !bacmp(&c->dst, ba)) |
| 541 | if (c->type == type && !bacmp(&c->dst, ba)) { | ||
| 542 | rcu_read_unlock(); | ||
| 543 | return c; | 423 | return c; |
| 544 | } | ||
| 545 | } | 424 | } |
| 546 | |||
| 547 | rcu_read_unlock(); | ||
| 548 | |||
| 549 | return NULL; | 425 | return NULL; |
| 550 | } | 426 | } |
| 551 | 427 | ||
| @@ -553,39 +429,32 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, | |||
| 553 | __u8 type, __u16 state) | 429 | __u8 type, __u16 state) |
| 554 | { | 430 | { |
| 555 | struct hci_conn_hash *h = &hdev->conn_hash; | 431 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 432 | struct list_head *p; | ||
| 556 | struct hci_conn *c; | 433 | struct hci_conn *c; |
| 557 | 434 | ||
| 558 | rcu_read_lock(); | 435 | list_for_each(p, &h->list) { |
| 559 | 436 | c = list_entry(p, struct hci_conn, list); | |
| 560 | list_for_each_entry_rcu(c, &h->list, list) { | 437 | if (c->type == type && c->state == state) |
| 561 | if (c->type == type && c->state == state) { | ||
| 562 | rcu_read_unlock(); | ||
| 563 | return c; | 438 | return c; |
| 564 | } | ||
| 565 | } | 439 | } |
| 566 | |||
| 567 | rcu_read_unlock(); | ||
| 568 | |||
| 569 | return NULL; | 440 | return NULL; |
| 570 | } | 441 | } |
| 571 | 442 | ||
| 443 | void hci_acl_connect(struct hci_conn *conn); | ||
| 572 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason); | 444 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason); |
| 445 | void hci_add_sco(struct hci_conn *conn, __u16 handle); | ||
| 573 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); | 446 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); |
| 574 | void hci_sco_setup(struct hci_conn *conn, __u8 status); | 447 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
| 575 | 448 | ||
| 576 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | 449 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, |
| 450 | __u16 pkt_type, bdaddr_t *dst); | ||
| 577 | int hci_conn_del(struct hci_conn *conn); | 451 | int hci_conn_del(struct hci_conn *conn); |
| 578 | void hci_conn_hash_flush(struct hci_dev *hdev); | 452 | void hci_conn_hash_flush(struct hci_dev *hdev); |
| 579 | void hci_conn_check_pending(struct hci_dev *hdev); | 453 | void hci_conn_check_pending(struct hci_dev *hdev); |
| 580 | void hci_conn_accept(struct hci_conn *conn, int mask); | ||
| 581 | |||
| 582 | struct hci_chan *hci_chan_create(struct hci_conn *conn); | ||
| 583 | void hci_chan_del(struct hci_chan *chan); | ||
| 584 | void hci_chan_list_flush(struct hci_conn *conn); | ||
| 585 | struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); | ||
| 586 | 454 | ||
| 587 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | 455 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, |
| 588 | __u8 dst_type, __u8 sec_level, __u8 auth_type); | 456 | __u16 pkt_type, bdaddr_t *dst, |
| 457 | __u8 sec_level, __u8 auth_type); | ||
| 589 | int hci_conn_check_link_mode(struct hci_conn *conn); | 458 | int hci_conn_check_link_mode(struct hci_conn *conn); |
| 590 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); | 459 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
| 591 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); | 460 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
| @@ -593,107 +462,75 @@ int hci_conn_change_link_key(struct hci_conn *conn); | |||
| 593 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | 462 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
| 594 | 463 | ||
| 595 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); | 464 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
| 465 | void hci_conn_enter_sniff_mode(struct hci_conn *conn); | ||
| 596 | 466 | ||
| 597 | void hci_conn_hold_device(struct hci_conn *conn); | 467 | void hci_conn_hold_device(struct hci_conn *conn); |
| 598 | void hci_conn_put_device(struct hci_conn *conn); | 468 | void hci_conn_put_device(struct hci_conn *conn); |
| 599 | 469 | ||
| 600 | static inline void hci_conn_hold(struct hci_conn *conn) | 470 | static inline void hci_conn_hold(struct hci_conn *conn) |
| 601 | { | 471 | { |
| 602 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | ||
| 603 | |||
| 604 | atomic_inc(&conn->refcnt); | 472 | atomic_inc(&conn->refcnt); |
| 605 | cancel_delayed_work(&conn->disc_work); | 473 | del_timer(&conn->disc_timer); |
| 606 | } | 474 | } |
| 607 | 475 | ||
| 608 | static inline void hci_conn_put(struct hci_conn *conn) | 476 | static inline void hci_conn_put(struct hci_conn *conn) |
| 609 | { | 477 | { |
| 610 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | ||
| 611 | |||
| 612 | if (atomic_dec_and_test(&conn->refcnt)) { | 478 | if (atomic_dec_and_test(&conn->refcnt)) { |
| 613 | unsigned long timeo; | 479 | unsigned long timeo; |
| 614 | 480 | if (conn->type == ACL_LINK) { | |
| 615 | switch (conn->type) { | ||
| 616 | case ACL_LINK: | ||
| 617 | case LE_LINK: | ||
| 618 | del_timer(&conn->idle_timer); | 481 | del_timer(&conn->idle_timer); |
| 619 | if (conn->state == BT_CONNECTED) { | 482 | if (conn->state == BT_CONNECTED) { |
| 620 | timeo = conn->disc_timeout; | 483 | timeo = msecs_to_jiffies(conn->disc_timeout); |
| 621 | if (!conn->out) | 484 | if (!conn->out) |
| 622 | timeo *= 2; | 485 | timeo *= 20; |
| 623 | } else { | 486 | } else { |
| 624 | timeo = msecs_to_jiffies(10); | 487 | timeo = msecs_to_jiffies(10); |
| 625 | } | 488 | } |
| 626 | break; | 489 | } else { |
| 627 | |||
| 628 | case AMP_LINK: | ||
| 629 | timeo = conn->disc_timeout; | ||
| 630 | break; | ||
| 631 | |||
| 632 | default: | ||
| 633 | timeo = msecs_to_jiffies(10); | 490 | timeo = msecs_to_jiffies(10); |
| 634 | break; | ||
| 635 | } | 491 | } |
| 636 | 492 | mod_timer(&conn->disc_timer, jiffies + timeo); | |
| 637 | cancel_delayed_work(&conn->disc_work); | ||
| 638 | queue_delayed_work(conn->hdev->workqueue, | ||
| 639 | &conn->disc_work, timeo); | ||
| 640 | } | 493 | } |
| 641 | } | 494 | } |
| 642 | 495 | ||
| 643 | /* ----- HCI Devices ----- */ | 496 | /* ----- HCI Devices ----- */ |
| 644 | static inline void hci_dev_put(struct hci_dev *d) | 497 | static inline void __hci_dev_put(struct hci_dev *d) |
| 645 | { | 498 | { |
| 646 | BT_DBG("%s orig refcnt %d", d->name, | 499 | if (atomic_dec_and_test(&d->refcnt)) |
| 647 | atomic_read(&d->dev.kobj.kref.refcount)); | 500 | d->destruct(d); |
| 648 | |||
| 649 | put_device(&d->dev); | ||
| 650 | } | 501 | } |
| 651 | 502 | ||
| 652 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) | 503 | static inline void hci_dev_put(struct hci_dev *d) |
| 653 | { | 504 | { |
| 654 | BT_DBG("%s orig refcnt %d", d->name, | 505 | __hci_dev_put(d); |
| 655 | atomic_read(&d->dev.kobj.kref.refcount)); | 506 | module_put(d->owner); |
| 656 | |||
| 657 | get_device(&d->dev); | ||
| 658 | return d; | ||
| 659 | } | 507 | } |
| 660 | 508 | ||
| 661 | #define hci_dev_lock(d) mutex_lock(&d->lock) | 509 | static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) |
| 662 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) | ||
| 663 | |||
| 664 | #define to_hci_dev(d) container_of(d, struct hci_dev, dev) | ||
| 665 | #define to_hci_conn(c) container_of(c, struct hci_conn, dev) | ||
| 666 | |||
| 667 | static inline void *hci_get_drvdata(struct hci_dev *hdev) | ||
| 668 | { | 510 | { |
| 669 | return dev_get_drvdata(&hdev->dev); | 511 | atomic_inc(&d->refcnt); |
| 512 | return d; | ||
| 670 | } | 513 | } |
| 671 | 514 | ||
| 672 | static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) | 515 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) |
| 673 | { | 516 | { |
| 674 | dev_set_drvdata(&hdev->dev, data); | 517 | if (try_module_get(d->owner)) |
| 518 | return __hci_dev_hold(d); | ||
| 519 | return NULL; | ||
| 675 | } | 520 | } |
| 676 | 521 | ||
| 677 | /* hci_dev_list shall be locked */ | 522 | #define hci_dev_lock(d) spin_lock(&d->lock) |
| 678 | static inline uint8_t __hci_num_ctrl(void) | 523 | #define hci_dev_unlock(d) spin_unlock(&d->lock) |
| 679 | { | 524 | #define hci_dev_lock_bh(d) spin_lock_bh(&d->lock) |
| 680 | uint8_t count = 0; | 525 | #define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock) |
| 681 | struct list_head *p; | ||
| 682 | |||
| 683 | list_for_each(p, &hci_dev_list) { | ||
| 684 | count++; | ||
| 685 | } | ||
| 686 | |||
| 687 | return count; | ||
| 688 | } | ||
| 689 | 526 | ||
| 690 | struct hci_dev *hci_dev_get(int index); | 527 | struct hci_dev *hci_dev_get(int index); |
| 691 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); | 528 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); |
| 692 | 529 | ||
| 693 | struct hci_dev *hci_alloc_dev(void); | 530 | struct hci_dev *hci_alloc_dev(void); |
| 694 | void hci_free_dev(struct hci_dev *hdev); | 531 | void hci_free_dev(struct hci_dev *hdev); |
| 695 | int hci_register_dev(struct hci_dev *hdev); | 532 | int hci_register_dev(struct hci_dev *hdev); |
| 696 | void hci_unregister_dev(struct hci_dev *hdev); | 533 | int hci_unregister_dev(struct hci_dev *hdev); |
| 697 | int hci_suspend_dev(struct hci_dev *hdev); | 534 | int hci_suspend_dev(struct hci_dev *hdev); |
| 698 | int hci_resume_dev(struct hci_dev *hdev); | 535 | int hci_resume_dev(struct hci_dev *hdev); |
| 699 | int hci_dev_open(__u16 dev); | 536 | int hci_dev_open(__u16 dev); |
| @@ -708,26 +545,22 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); | |||
| 708 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); | 545 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
| 709 | int hci_inquiry(void __user *arg); | 546 | int hci_inquiry(void __user *arg); |
| 710 | 547 | ||
| 711 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, | 548 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 712 | bdaddr_t *bdaddr); | ||
| 713 | int hci_blacklist_clear(struct hci_dev *hdev); | 549 | int hci_blacklist_clear(struct hci_dev *hdev); |
| 714 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 550 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 715 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 551 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 716 | 552 | ||
| 717 | int hci_uuids_clear(struct hci_dev *hdev); | 553 | int hci_uuids_clear(struct hci_dev *hdev); |
| 718 | 554 | ||
| 719 | int hci_link_keys_clear(struct hci_dev *hdev); | 555 | int hci_link_keys_clear(struct hci_dev *hdev); |
| 720 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 556 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 721 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | 557 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, |
| 722 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); | 558 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); |
| 723 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); | 559 | struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); |
| 724 | int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, | 560 | struct link_key *hci_find_link_key_type(struct hci_dev *hdev, |
| 725 | int new_key, u8 authenticated, u8 tk[16], u8 enc_size, | 561 | bdaddr_t *bdaddr, u8 type); |
| 726 | __le16 ediv, u8 rand[8]); | 562 | int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, |
| 727 | struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, | 563 | u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); |
| 728 | u8 addr_type); | ||
| 729 | int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
| 730 | int hci_smp_ltks_clear(struct hci_dev *hdev); | ||
| 731 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 564 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 732 | 565 | ||
| 733 | int hci_remote_oob_data_clear(struct hci_dev *hdev); | 566 | int hci_remote_oob_data_clear(struct hci_dev *hdev); |
| @@ -737,7 +570,13 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | |||
| 737 | u8 *randomizer); | 570 | u8 *randomizer); |
| 738 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); | 571 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 739 | 572 | ||
| 740 | int hci_update_ad(struct hci_dev *hdev); | 573 | #define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */ |
| 574 | int hci_adv_entries_clear(struct hci_dev *hdev); | ||
| 575 | struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
| 576 | int hci_add_adv_entry(struct hci_dev *hdev, | ||
| 577 | struct hci_ev_le_advertising_info *ev); | ||
| 578 | |||
| 579 | void hci_del_off_timer(struct hci_dev *hdev); | ||
| 741 | 580 | ||
| 742 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); | 581 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
| 743 | 582 | ||
| @@ -745,93 +584,75 @@ int hci_recv_frame(struct sk_buff *skb); | |||
| 745 | int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); | 584 | int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); |
| 746 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); | 585 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); |
| 747 | 586 | ||
| 748 | void hci_init_sysfs(struct hci_dev *hdev); | 587 | int hci_register_sysfs(struct hci_dev *hdev); |
| 749 | int hci_add_sysfs(struct hci_dev *hdev); | 588 | void hci_unregister_sysfs(struct hci_dev *hdev); |
| 750 | void hci_del_sysfs(struct hci_dev *hdev); | ||
| 751 | void hci_conn_init_sysfs(struct hci_conn *conn); | 589 | void hci_conn_init_sysfs(struct hci_conn *conn); |
| 752 | void hci_conn_add_sysfs(struct hci_conn *conn); | 590 | void hci_conn_add_sysfs(struct hci_conn *conn); |
| 753 | void hci_conn_del_sysfs(struct hci_conn *conn); | 591 | void hci_conn_del_sysfs(struct hci_conn *conn); |
| 754 | 592 | ||
| 755 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) | 593 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev)) |
| 756 | 594 | ||
| 757 | /* ----- LMP capabilities ----- */ | 595 | /* ----- LMP capabilities ----- */ |
| 758 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) | ||
| 759 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) | 596 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) |
| 760 | #define lmp_hold_capable(dev) ((dev)->features[0] & LMP_HOLD) | 597 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) |
| 761 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) | 598 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) |
| 762 | #define lmp_park_capable(dev) ((dev)->features[1] & LMP_PARK) | ||
| 763 | #define lmp_inq_rssi_capable(dev) ((dev)->features[3] & LMP_RSSI_INQ) | ||
| 764 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) | ||
| 765 | #define lmp_bredr_capable(dev) (!((dev)->features[4] & LMP_NO_BREDR)) | ||
| 766 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) | ||
| 767 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) | 599 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) |
| 768 | #define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC) | 600 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) |
| 769 | #define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ) | ||
| 770 | #define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR) | ||
| 771 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) | 601 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) |
| 772 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) | 602 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) |
| 773 | #define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO) | 603 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) |
| 774 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[7] & LMP_INQ_TX_PWR) | ||
| 775 | #define lmp_ext_feat_capable(dev) ((dev)->features[7] & LMP_EXTFEATURES) | ||
| 776 | 604 | ||
| 777 | /* ----- Extended LMP capabilities ----- */ | 605 | /* ----- Extended LMP capabilities ----- */ |
| 778 | #define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP) | 606 | #define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) |
| 779 | #define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE) | ||
| 780 | #define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR) | ||
| 781 | |||
| 782 | /* returns true if at least one AMP active */ | ||
| 783 | static inline bool hci_amp_capable(void) | ||
| 784 | { | ||
| 785 | struct hci_dev *hdev; | ||
| 786 | bool ret = false; | ||
| 787 | |||
| 788 | read_lock(&hci_dev_list_lock); | ||
| 789 | list_for_each_entry(hdev, &hci_dev_list, list) | ||
| 790 | if (hdev->amp_type == HCI_AMP && | ||
| 791 | test_bit(HCI_UP, &hdev->flags)) | ||
| 792 | ret = true; | ||
| 793 | read_unlock(&hci_dev_list_lock); | ||
| 794 | |||
| 795 | return ret; | ||
| 796 | } | ||
| 797 | 607 | ||
| 798 | /* ----- HCI protocols ----- */ | 608 | /* ----- HCI protocols ----- */ |
| 799 | #define HCI_PROTO_DEFER 0x01 | 609 | struct hci_proto { |
| 610 | char *name; | ||
| 611 | unsigned int id; | ||
| 612 | unsigned long flags; | ||
| 613 | |||
| 614 | void *priv; | ||
| 615 | |||
| 616 | int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 617 | __u8 type); | ||
| 618 | int (*connect_cfm) (struct hci_conn *conn, __u8 status); | ||
| 619 | int (*disconn_ind) (struct hci_conn *conn); | ||
| 620 | int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); | ||
| 621 | int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, | ||
| 622 | __u16 flags); | ||
| 623 | int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); | ||
| 624 | int (*security_cfm) (struct hci_conn *conn, __u8 status, | ||
| 625 | __u8 encrypt); | ||
| 626 | }; | ||
| 800 | 627 | ||
| 801 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, | 628 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 802 | __u8 type, __u8 *flags) | 629 | __u8 type) |
| 803 | { | 630 | { |
| 804 | switch (type) { | 631 | register struct hci_proto *hp; |
| 805 | case ACL_LINK: | 632 | int mask = 0; |
| 806 | return l2cap_connect_ind(hdev, bdaddr); | ||
| 807 | 633 | ||
| 808 | case SCO_LINK: | 634 | hp = hci_proto[HCI_PROTO_L2CAP]; |
| 809 | case ESCO_LINK: | 635 | if (hp && hp->connect_ind) |
| 810 | return sco_connect_ind(hdev, bdaddr, flags); | 636 | mask |= hp->connect_ind(hdev, bdaddr, type); |
| 811 | 637 | ||
| 812 | default: | 638 | hp = hci_proto[HCI_PROTO_SCO]; |
| 813 | BT_ERR("unknown link type %d", type); | 639 | if (hp && hp->connect_ind) |
| 814 | return -EINVAL; | 640 | mask |= hp->connect_ind(hdev, bdaddr, type); |
| 815 | } | 641 | |
| 642 | return mask; | ||
| 816 | } | 643 | } |
| 817 | 644 | ||
| 818 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | 645 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) |
| 819 | { | 646 | { |
| 820 | switch (conn->type) { | 647 | register struct hci_proto *hp; |
| 821 | case ACL_LINK: | ||
| 822 | case LE_LINK: | ||
| 823 | l2cap_connect_cfm(conn, status); | ||
| 824 | break; | ||
| 825 | 648 | ||
| 826 | case SCO_LINK: | 649 | hp = hci_proto[HCI_PROTO_L2CAP]; |
| 827 | case ESCO_LINK: | 650 | if (hp && hp->connect_cfm) |
| 828 | sco_connect_cfm(conn, status); | 651 | hp->connect_cfm(conn, status); |
| 829 | break; | ||
| 830 | 652 | ||
| 831 | default: | 653 | hp = hci_proto[HCI_PROTO_SCO]; |
| 832 | BT_ERR("unknown link type %d", conn->type); | 654 | if (hp && hp->connect_cfm) |
| 833 | break; | 655 | hp->connect_cfm(conn, status); |
| 834 | } | ||
| 835 | 656 | ||
| 836 | if (conn->connect_cfm_cb) | 657 | if (conn->connect_cfm_cb) |
| 837 | conn->connect_cfm_cb(conn, status); | 658 | conn->connect_cfm_cb(conn, status); |
| @@ -839,33 +660,31 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | |||
| 839 | 660 | ||
| 840 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) | 661 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
| 841 | { | 662 | { |
| 842 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 663 | register struct hci_proto *hp; |
| 843 | return HCI_ERROR_REMOTE_USER_TERM; | 664 | int reason = 0x13; |
| 665 | |||
| 666 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
| 667 | if (hp && hp->disconn_ind) | ||
| 668 | reason = hp->disconn_ind(conn); | ||
| 669 | |||
| 670 | hp = hci_proto[HCI_PROTO_SCO]; | ||
| 671 | if (hp && hp->disconn_ind) | ||
| 672 | reason = hp->disconn_ind(conn); | ||
| 844 | 673 | ||
| 845 | return l2cap_disconn_ind(conn); | 674 | return reason; |
| 846 | } | 675 | } |
| 847 | 676 | ||
| 848 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | 677 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) |
| 849 | { | 678 | { |
| 850 | switch (conn->type) { | 679 | register struct hci_proto *hp; |
| 851 | case ACL_LINK: | ||
| 852 | case LE_LINK: | ||
| 853 | l2cap_disconn_cfm(conn, reason); | ||
| 854 | break; | ||
| 855 | |||
| 856 | case SCO_LINK: | ||
| 857 | case ESCO_LINK: | ||
| 858 | sco_disconn_cfm(conn, reason); | ||
| 859 | break; | ||
| 860 | 680 | ||
| 861 | /* L2CAP would be handled for BREDR chan */ | 681 | hp = hci_proto[HCI_PROTO_L2CAP]; |
| 862 | case AMP_LINK: | 682 | if (hp && hp->disconn_cfm) |
| 863 | break; | 683 | hp->disconn_cfm(conn, reason); |
| 864 | 684 | ||
| 865 | default: | 685 | hp = hci_proto[HCI_PROTO_SCO]; |
| 866 | BT_ERR("unknown link type %d", conn->type); | 686 | if (hp && hp->disconn_cfm) |
| 867 | break; | 687 | hp->disconn_cfm(conn, reason); |
| 868 | } | ||
| 869 | 688 | ||
| 870 | if (conn->disconn_cfm_cb) | 689 | if (conn->disconn_cfm_cb) |
| 871 | conn->disconn_cfm_cb(conn, reason); | 690 | conn->disconn_cfm_cb(conn, reason); |
| @@ -873,16 +692,21 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | |||
| 873 | 692 | ||
| 874 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | 693 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) |
| 875 | { | 694 | { |
| 695 | register struct hci_proto *hp; | ||
| 876 | __u8 encrypt; | 696 | __u8 encrypt; |
| 877 | 697 | ||
| 878 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 698 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) |
| 879 | return; | ||
| 880 | |||
| 881 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) | ||
| 882 | return; | 699 | return; |
| 883 | 700 | ||
| 884 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | 701 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; |
| 885 | l2cap_security_cfm(conn, status, encrypt); | 702 | |
| 703 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
| 704 | if (hp && hp->security_cfm) | ||
| 705 | hp->security_cfm(conn, status, encrypt); | ||
| 706 | |||
| 707 | hp = hci_proto[HCI_PROTO_SCO]; | ||
| 708 | if (hp && hp->security_cfm) | ||
| 709 | hp->security_cfm(conn, status, encrypt); | ||
| 886 | 710 | ||
| 887 | if (conn->security_cfm_cb) | 711 | if (conn->security_cfm_cb) |
| 888 | conn->security_cfm_cb(conn, status); | 712 | conn->security_cfm_cb(conn, status); |
| @@ -891,15 +715,23 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | |||
| 891 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, | 715 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, |
| 892 | __u8 encrypt) | 716 | __u8 encrypt) |
| 893 | { | 717 | { |
| 894 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 718 | register struct hci_proto *hp; |
| 895 | return; | 719 | |
| 720 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
| 721 | if (hp && hp->security_cfm) | ||
| 722 | hp->security_cfm(conn, status, encrypt); | ||
| 896 | 723 | ||
| 897 | l2cap_security_cfm(conn, status, encrypt); | 724 | hp = hci_proto[HCI_PROTO_SCO]; |
| 725 | if (hp && hp->security_cfm) | ||
| 726 | hp->security_cfm(conn, status, encrypt); | ||
| 898 | 727 | ||
| 899 | if (conn->security_cfm_cb) | 728 | if (conn->security_cfm_cb) |
| 900 | conn->security_cfm_cb(conn, status); | 729 | conn->security_cfm_cb(conn, status); |
| 901 | } | 730 | } |
| 902 | 731 | ||
| 732 | int hci_register_proto(struct hci_proto *hproto); | ||
| 733 | int hci_unregister_proto(struct hci_proto *hproto); | ||
| 734 | |||
| 903 | /* ----- HCI callbacks ----- */ | 735 | /* ----- HCI callbacks ----- */ |
| 904 | struct hci_cb { | 736 | struct hci_cb { |
| 905 | struct list_head list; | 737 | struct list_head list; |
| @@ -914,28 +746,29 @@ struct hci_cb { | |||
| 914 | 746 | ||
| 915 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) | 747 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) |
| 916 | { | 748 | { |
| 917 | struct hci_cb *cb; | 749 | struct list_head *p; |
| 918 | __u8 encrypt; | 750 | __u8 encrypt; |
| 919 | 751 | ||
| 920 | hci_proto_auth_cfm(conn, status); | 752 | hci_proto_auth_cfm(conn, status); |
| 921 | 753 | ||
| 922 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) | 754 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) |
| 923 | return; | 755 | return; |
| 924 | 756 | ||
| 925 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | 757 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; |
| 926 | 758 | ||
| 927 | read_lock(&hci_cb_list_lock); | 759 | read_lock_bh(&hci_cb_list_lock); |
| 928 | list_for_each_entry(cb, &hci_cb_list, list) { | 760 | list_for_each(p, &hci_cb_list) { |
| 761 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
| 929 | if (cb->security_cfm) | 762 | if (cb->security_cfm) |
| 930 | cb->security_cfm(conn, status, encrypt); | 763 | cb->security_cfm(conn, status, encrypt); |
| 931 | } | 764 | } |
| 932 | read_unlock(&hci_cb_list_lock); | 765 | read_unlock_bh(&hci_cb_list_lock); |
| 933 | } | 766 | } |
| 934 | 767 | ||
| 935 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, | 768 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, |
| 936 | __u8 encrypt) | 769 | __u8 encrypt) |
| 937 | { | 770 | { |
| 938 | struct hci_cb *cb; | 771 | struct list_head *p; |
| 939 | 772 | ||
| 940 | if (conn->sec_level == BT_SECURITY_SDP) | 773 | if (conn->sec_level == BT_SECURITY_SDP) |
| 941 | conn->sec_level = BT_SECURITY_LOW; | 774 | conn->sec_level = BT_SECURITY_LOW; |
| @@ -945,180 +778,88 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, | |||
| 945 | 778 | ||
| 946 | hci_proto_encrypt_cfm(conn, status, encrypt); | 779 | hci_proto_encrypt_cfm(conn, status, encrypt); |
| 947 | 780 | ||
| 948 | read_lock(&hci_cb_list_lock); | 781 | read_lock_bh(&hci_cb_list_lock); |
| 949 | list_for_each_entry(cb, &hci_cb_list, list) { | 782 | list_for_each(p, &hci_cb_list) { |
| 783 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
| 950 | if (cb->security_cfm) | 784 | if (cb->security_cfm) |
| 951 | cb->security_cfm(conn, status, encrypt); | 785 | cb->security_cfm(conn, status, encrypt); |
| 952 | } | 786 | } |
| 953 | read_unlock(&hci_cb_list_lock); | 787 | read_unlock_bh(&hci_cb_list_lock); |
| 954 | } | 788 | } |
| 955 | 789 | ||
| 956 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) | 790 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) |
| 957 | { | 791 | { |
| 958 | struct hci_cb *cb; | 792 | struct list_head *p; |
| 959 | 793 | ||
| 960 | read_lock(&hci_cb_list_lock); | 794 | read_lock_bh(&hci_cb_list_lock); |
| 961 | list_for_each_entry(cb, &hci_cb_list, list) { | 795 | list_for_each(p, &hci_cb_list) { |
| 796 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
| 962 | if (cb->key_change_cfm) | 797 | if (cb->key_change_cfm) |
| 963 | cb->key_change_cfm(conn, status); | 798 | cb->key_change_cfm(conn, status); |
| 964 | } | 799 | } |
| 965 | read_unlock(&hci_cb_list_lock); | 800 | read_unlock_bh(&hci_cb_list_lock); |
| 966 | } | 801 | } |
| 967 | 802 | ||
| 968 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, | 803 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, |
| 969 | __u8 role) | 804 | __u8 role) |
| 970 | { | 805 | { |
| 971 | struct hci_cb *cb; | 806 | struct list_head *p; |
| 972 | 807 | ||
| 973 | read_lock(&hci_cb_list_lock); | 808 | read_lock_bh(&hci_cb_list_lock); |
| 974 | list_for_each_entry(cb, &hci_cb_list, list) { | 809 | list_for_each(p, &hci_cb_list) { |
| 810 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
| 975 | if (cb->role_switch_cfm) | 811 | if (cb->role_switch_cfm) |
| 976 | cb->role_switch_cfm(conn, status, role); | 812 | cb->role_switch_cfm(conn, status, role); |
| 977 | } | 813 | } |
| 978 | read_unlock(&hci_cb_list_lock); | 814 | read_unlock_bh(&hci_cb_list_lock); |
| 979 | } | ||
| 980 | |||
| 981 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) | ||
| 982 | { | ||
| 983 | size_t parsed = 0; | ||
| 984 | |||
| 985 | if (data_len < 2) | ||
| 986 | return false; | ||
| 987 | |||
| 988 | while (parsed < data_len - 1) { | ||
| 989 | u8 field_len = data[0]; | ||
| 990 | |||
| 991 | if (field_len == 0) | ||
| 992 | break; | ||
| 993 | |||
| 994 | parsed += field_len + 1; | ||
| 995 | |||
| 996 | if (parsed > data_len) | ||
| 997 | break; | ||
| 998 | |||
| 999 | if (data[1] == type) | ||
| 1000 | return true; | ||
| 1001 | |||
| 1002 | data += field_len + 1; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | return false; | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | static inline size_t eir_get_length(u8 *eir, size_t eir_len) | ||
| 1009 | { | ||
| 1010 | size_t parsed = 0; | ||
| 1011 | |||
| 1012 | while (parsed < eir_len) { | ||
| 1013 | u8 field_len = eir[0]; | ||
| 1014 | |||
| 1015 | if (field_len == 0) | ||
| 1016 | return parsed; | ||
| 1017 | |||
| 1018 | parsed += field_len + 1; | ||
| 1019 | eir += field_len + 1; | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | return eir_len; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data, | ||
| 1026 | u8 data_len) | ||
| 1027 | { | ||
| 1028 | eir[eir_len++] = sizeof(type) + data_len; | ||
| 1029 | eir[eir_len++] = type; | ||
| 1030 | memcpy(&eir[eir_len], data, data_len); | ||
| 1031 | eir_len += data_len; | ||
| 1032 | |||
| 1033 | return eir_len; | ||
| 1034 | } | 815 | } |
| 1035 | 816 | ||
| 1036 | int hci_register_cb(struct hci_cb *hcb); | 817 | int hci_register_cb(struct hci_cb *hcb); |
| 1037 | int hci_unregister_cb(struct hci_cb *hcb); | 818 | int hci_unregister_cb(struct hci_cb *hcb); |
| 1038 | 819 | ||
| 820 | int hci_register_notifier(struct notifier_block *nb); | ||
| 821 | int hci_unregister_notifier(struct notifier_block *nb); | ||
| 822 | |||
| 1039 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); | 823 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); |
| 1040 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); | 824 | void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); |
| 1041 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); | 825 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); |
| 1042 | 826 | ||
| 1043 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); | 827 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); |
| 1044 | 828 | ||
| 1045 | /* ----- HCI Sockets ----- */ | 829 | void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); |
| 1046 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); | ||
| 1047 | void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); | ||
| 1048 | void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); | ||
| 1049 | 830 | ||
| 1050 | void hci_sock_dev_event(struct hci_dev *hdev, int event); | 831 | /* ----- HCI Sockets ----- */ |
| 832 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, | ||
| 833 | struct sock *skip_sk); | ||
| 1051 | 834 | ||
| 1052 | /* Management interface */ | 835 | /* Management interface */ |
| 1053 | #define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR)) | ||
| 1054 | #define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \ | ||
| 1055 | BIT(BDADDR_LE_RANDOM)) | ||
| 1056 | #define DISCOV_TYPE_INTERLEAVED (BIT(BDADDR_BREDR) | \ | ||
| 1057 | BIT(BDADDR_LE_PUBLIC) | \ | ||
| 1058 | BIT(BDADDR_LE_RANDOM)) | ||
| 1059 | |||
| 1060 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); | 836 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); |
| 1061 | int mgmt_index_added(struct hci_dev *hdev); | 837 | int mgmt_index_added(u16 index); |
| 1062 | int mgmt_index_removed(struct hci_dev *hdev); | 838 | int mgmt_index_removed(u16 index); |
| 1063 | int mgmt_powered(struct hci_dev *hdev, u8 powered); | 839 | int mgmt_powered(u16 index, u8 powered); |
| 1064 | int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); | 840 | int mgmt_discoverable(u16 index, u8 discoverable); |
| 1065 | int mgmt_connectable(struct hci_dev *hdev, u8 connectable); | 841 | int mgmt_connectable(u16 index, u8 connectable); |
| 1066 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); | 842 | int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); |
| 1067 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | 843 | int mgmt_connected(u16 index, bdaddr_t *bdaddr); |
| 1068 | bool persistent); | 844 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); |
| 1069 | int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 845 | int mgmt_disconnect_failed(u16 index); |
| 1070 | u8 addr_type, u32 flags, u8 *name, u8 name_len, | 846 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
| 1071 | u8 *dev_class); | 847 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); |
| 1072 | int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, | 848 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
| 1073 | u8 link_type, u8 addr_type, u8 reason); | 849 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
| 1074 | int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | 850 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, |
| 1075 | u8 link_type, u8 addr_type, u8 status); | 851 | u8 confirm_hint); |
| 1076 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 852 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
| 1077 | u8 addr_type, u8 status); | 853 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, |
| 1078 | int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); | 854 | u8 status); |
| 1079 | int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 855 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
| 1080 | u8 status); | 856 | int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); |
| 1081 | int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 857 | int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, |
| 1082 | u8 status); | 858 | u8 status); |
| 1083 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | 859 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, |
| 1084 | u8 link_type, u8 addr_type, __le32 value, | 860 | u8 *eir); |
| 1085 | u8 confirm_hint); | 861 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); |
| 1086 | int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 862 | int mgmt_discovering(u16 index, u8 discovering); |
| 1087 | u8 link_type, u8 addr_type, u8 status); | ||
| 1088 | int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 1089 | u8 link_type, u8 addr_type, u8 status); | ||
| 1090 | int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 1091 | u8 link_type, u8 addr_type); | ||
| 1092 | int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 1093 | u8 link_type, u8 addr_type, u8 status); | ||
| 1094 | int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 1095 | u8 link_type, u8 addr_type, u8 status); | ||
| 1096 | int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
| 1097 | u8 link_type, u8 addr_type, u32 passkey, | ||
| 1098 | u8 entered); | ||
| 1099 | int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
| 1100 | u8 addr_type, u8 status); | ||
| 1101 | int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); | ||
| 1102 | int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); | ||
| 1103 | int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, | ||
| 1104 | u8 status); | ||
| 1105 | int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); | ||
| 1106 | int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | ||
| 1107 | u8 *randomizer, u8 status); | ||
| 1108 | int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); | ||
| 1109 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
| 1110 | u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, | ||
| 1111 | u8 ssp, u8 *eir, u16 eir_len); | ||
| 1112 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
| 1113 | u8 addr_type, s8 rssi, u8 *name, u8 name_len); | ||
| 1114 | int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); | ||
| 1115 | int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); | ||
| 1116 | int mgmt_discovering(struct hci_dev *hdev, u8 discovering); | ||
| 1117 | int mgmt_interleaved_discovery(struct hci_dev *hdev); | ||
| 1118 | int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | ||
| 1119 | int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | ||
| 1120 | bool mgmt_valid_hdev(struct hci_dev *hdev); | ||
| 1121 | int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); | ||
| 1122 | 863 | ||
| 1123 | /* HCI info for socket */ | 864 | /* HCI info for socket */ |
| 1124 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 865 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
| @@ -1154,12 +895,7 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, | |||
| 1154 | u16 latency, u16 to_multiplier); | 895 | u16 latency, u16 to_multiplier); |
| 1155 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], | 896 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], |
| 1156 | __u8 ltk[16]); | 897 | __u8 ltk[16]); |
| 1157 | int hci_do_inquiry(struct hci_dev *hdev, u8 length); | 898 | void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); |
| 1158 | int hci_cancel_inquiry(struct hci_dev *hdev); | 899 | void hci_le_ltk_neg_reply(struct hci_conn *conn); |
| 1159 | int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, | ||
| 1160 | int timeout); | ||
| 1161 | int hci_cancel_le_scan(struct hci_dev *hdev); | ||
| 1162 | |||
| 1163 | u8 bdaddr_to_le(u8 bdaddr_type); | ||
| 1164 | 900 | ||
| 1165 | #endif /* __HCI_CORE_H */ | 901 | #endif /* __HCI_CORE_H */ |
diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h deleted file mode 100644 index 77d1e576418..00000000000 --- a/include/net/bluetooth/hci_mon.h +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 1 | /* | ||
| 2 | BlueZ - Bluetooth protocol stack for Linux | ||
| 3 | |||
| 4 | Copyright (C) 2011-2012 Intel Corporation | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License version 2 as | ||
| 8 | published by the Free Software Foundation; | ||
| 9 | |||
| 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| 11 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
| 13 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
| 14 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
| 15 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | |||
| 19 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
| 20 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
| 21 | SOFTWARE IS DISCLAIMED. | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef __HCI_MON_H | ||
| 25 | #define __HCI_MON_H | ||
| 26 | |||
| 27 | struct hci_mon_hdr { | ||
| 28 | __le16 opcode; | ||
| 29 | __le16 index; | ||
| 30 | __le16 len; | ||
| 31 | } __packed; | ||
| 32 | #define HCI_MON_HDR_SIZE 6 | ||
| 33 | |||
| 34 | #define HCI_MON_NEW_INDEX 0 | ||
| 35 | #define HCI_MON_DEL_INDEX 1 | ||
| 36 | #define HCI_MON_COMMAND_PKT 2 | ||
| 37 | #define HCI_MON_EVENT_PKT 3 | ||
| 38 | #define HCI_MON_ACL_TX_PKT 4 | ||
| 39 | #define HCI_MON_ACL_RX_PKT 5 | ||
| 40 | #define HCI_MON_SCO_TX_PKT 6 | ||
| 41 | #define HCI_MON_SCO_RX_PKT 7 | ||
| 42 | |||
| 43 | struct hci_mon_new_index { | ||
| 44 | __u8 type; | ||
| 45 | __u8 bus; | ||
| 46 | bdaddr_t bdaddr; | ||
| 47 | char name[8]; | ||
| 48 | } __packed; | ||
| 49 | #define HCI_MON_NEW_INDEX_SIZE 16 | ||
| 50 | |||
| 51 | #endif /* __HCI_MON_H */ | ||
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 7588ef44eba..4f34ad25e75 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
| @@ -27,35 +27,20 @@ | |||
| 27 | #ifndef __L2CAP_H | 27 | #ifndef __L2CAP_H |
| 28 | #define __L2CAP_H | 28 | #define __L2CAP_H |
| 29 | 29 | ||
| 30 | #include <asm/unaligned.h> | ||
| 31 | |||
| 32 | /* L2CAP defaults */ | 30 | /* L2CAP defaults */ |
| 33 | #define L2CAP_DEFAULT_MTU 672 | 31 | #define L2CAP_DEFAULT_MTU 672 |
| 34 | #define L2CAP_DEFAULT_MIN_MTU 48 | 32 | #define L2CAP_DEFAULT_MIN_MTU 48 |
| 35 | #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF | 33 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff |
| 36 | #define L2CAP_EFS_DEFAULT_FLUSH_TO 0xFFFFFFFF | ||
| 37 | #define L2CAP_DEFAULT_TX_WINDOW 63 | 34 | #define L2CAP_DEFAULT_TX_WINDOW 63 |
| 38 | #define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF | ||
| 39 | #define L2CAP_DEFAULT_MAX_TX 3 | 35 | #define L2CAP_DEFAULT_MAX_TX 3 |
| 40 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ | 36 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ |
| 41 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ | 37 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ |
| 42 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1492 /* Sized for AMP packet */ | 38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
| 43 | #define L2CAP_DEFAULT_ACK_TO 200 | 39 | #define L2CAP_DEFAULT_ACK_TO 200 |
| 44 | #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF | 40 | #define L2CAP_LE_DEFAULT_MTU 23 |
| 45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF | 41 | |
| 46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF | 42 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ |
| 47 | #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */ | 43 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
| 48 | #define L2CAP_LE_MIN_MTU 23 | ||
| 49 | |||
| 50 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) | ||
| 51 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) | ||
| 52 | #define L2CAP_ENC_TIMEOUT msecs_to_jiffies(5000) | ||
| 53 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) | ||
| 54 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) | ||
| 55 | #define L2CAP_MOVE_TIMEOUT msecs_to_jiffies(4000) | ||
| 56 | #define L2CAP_MOVE_ERTX_TIMEOUT msecs_to_jiffies(60000) | ||
| 57 | |||
| 58 | #define L2CAP_A2MP_DEFAULT_MTU 670 | ||
| 59 | 44 | ||
| 60 | /* L2CAP socket address */ | 45 | /* L2CAP socket address */ |
| 61 | struct sockaddr_l2 { | 46 | struct sockaddr_l2 { |
| @@ -63,7 +48,6 @@ struct sockaddr_l2 { | |||
| 63 | __le16 l2_psm; | 48 | __le16 l2_psm; |
| 64 | bdaddr_t l2_bdaddr; | 49 | bdaddr_t l2_bdaddr; |
| 65 | __le16 l2_cid; | 50 | __le16 l2_cid; |
| 66 | __u8 l2_bdaddr_type; | ||
| 67 | }; | 51 | }; |
| 68 | 52 | ||
| 69 | /* L2CAP socket options */ | 53 | /* L2CAP socket options */ |
| @@ -104,86 +88,52 @@ struct l2cap_conninfo { | |||
| 104 | #define L2CAP_ECHO_RSP 0x09 | 88 | #define L2CAP_ECHO_RSP 0x09 |
| 105 | #define L2CAP_INFO_REQ 0x0a | 89 | #define L2CAP_INFO_REQ 0x0a |
| 106 | #define L2CAP_INFO_RSP 0x0b | 90 | #define L2CAP_INFO_RSP 0x0b |
| 107 | #define L2CAP_CREATE_CHAN_REQ 0x0c | ||
| 108 | #define L2CAP_CREATE_CHAN_RSP 0x0d | ||
| 109 | #define L2CAP_MOVE_CHAN_REQ 0x0e | ||
| 110 | #define L2CAP_MOVE_CHAN_RSP 0x0f | ||
| 111 | #define L2CAP_MOVE_CHAN_CFM 0x10 | ||
| 112 | #define L2CAP_MOVE_CHAN_CFM_RSP 0x11 | ||
| 113 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 | 91 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 |
| 114 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 | 92 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 |
| 115 | 93 | ||
| 116 | /* L2CAP extended feature mask */ | 94 | /* L2CAP feature mask */ |
| 117 | #define L2CAP_FEAT_FLOWCTL 0x00000001 | 95 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
| 118 | #define L2CAP_FEAT_RETRANS 0x00000002 | 96 | #define L2CAP_FEAT_RETRANS 0x00000002 |
| 119 | #define L2CAP_FEAT_BIDIR_QOS 0x00000004 | ||
| 120 | #define L2CAP_FEAT_ERTM 0x00000008 | 97 | #define L2CAP_FEAT_ERTM 0x00000008 |
| 121 | #define L2CAP_FEAT_STREAMING 0x00000010 | 98 | #define L2CAP_FEAT_STREAMING 0x00000010 |
| 122 | #define L2CAP_FEAT_FCS 0x00000020 | 99 | #define L2CAP_FEAT_FCS 0x00000020 |
| 123 | #define L2CAP_FEAT_EXT_FLOW 0x00000040 | ||
| 124 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 | 100 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 |
| 125 | #define L2CAP_FEAT_EXT_WINDOW 0x00000100 | ||
| 126 | #define L2CAP_FEAT_UCD 0x00000200 | ||
| 127 | 101 | ||
| 128 | /* L2CAP checksum option */ | 102 | /* L2CAP checksum option */ |
| 129 | #define L2CAP_FCS_NONE 0x00 | 103 | #define L2CAP_FCS_NONE 0x00 |
| 130 | #define L2CAP_FCS_CRC16 0x01 | 104 | #define L2CAP_FCS_CRC16 0x01 |
| 131 | 105 | ||
| 132 | /* L2CAP fixed channels */ | ||
| 133 | #define L2CAP_FC_L2CAP 0x02 | ||
| 134 | #define L2CAP_FC_A2MP 0x08 | ||
| 135 | |||
| 136 | /* L2CAP Control Field bit masks */ | 106 | /* L2CAP Control Field bit masks */ |
| 137 | #define L2CAP_CTRL_SAR 0xC000 | 107 | #define L2CAP_CTRL_SAR 0xC000 |
| 138 | #define L2CAP_CTRL_REQSEQ 0x3F00 | 108 | #define L2CAP_CTRL_REQSEQ 0x3F00 |
| 139 | #define L2CAP_CTRL_TXSEQ 0x007E | 109 | #define L2CAP_CTRL_TXSEQ 0x007E |
| 140 | #define L2CAP_CTRL_SUPERVISE 0x000C | 110 | #define L2CAP_CTRL_RETRANS 0x0080 |
| 141 | 111 | #define L2CAP_CTRL_FINAL 0x0080 | |
| 142 | #define L2CAP_CTRL_RETRANS 0x0080 | 112 | #define L2CAP_CTRL_POLL 0x0010 |
| 143 | #define L2CAP_CTRL_FINAL 0x0080 | 113 | #define L2CAP_CTRL_SUPERVISE 0x000C |
| 144 | #define L2CAP_CTRL_POLL 0x0010 | 114 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ |
| 145 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ | 115 | |
| 146 | 116 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 | |
| 147 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 | 117 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 |
| 148 | #define L2CAP_CTRL_SUPER_SHIFT 2 | 118 | #define L2CAP_CTRL_SAR_SHIFT 14 |
| 149 | #define L2CAP_CTRL_POLL_SHIFT 4 | ||
| 150 | #define L2CAP_CTRL_FINAL_SHIFT 7 | ||
| 151 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 | ||
| 152 | #define L2CAP_CTRL_SAR_SHIFT 14 | ||
| 153 | |||
| 154 | /* L2CAP Extended Control Field bit mask */ | ||
| 155 | #define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 | ||
| 156 | #define L2CAP_EXT_CTRL_SAR 0x00030000 | ||
| 157 | #define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 | ||
| 158 | #define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC | ||
| 159 | |||
| 160 | #define L2CAP_EXT_CTRL_POLL 0x00040000 | ||
| 161 | #define L2CAP_EXT_CTRL_FINAL 0x00000002 | ||
| 162 | #define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ | ||
| 163 | |||
| 164 | #define L2CAP_EXT_CTRL_FINAL_SHIFT 1 | ||
| 165 | #define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 | ||
| 166 | #define L2CAP_EXT_CTRL_SAR_SHIFT 16 | ||
| 167 | #define L2CAP_EXT_CTRL_SUPER_SHIFT 16 | ||
| 168 | #define L2CAP_EXT_CTRL_POLL_SHIFT 18 | ||
| 169 | #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 | ||
| 170 | 119 | ||
| 171 | /* L2CAP Supervisory Function */ | 120 | /* L2CAP Supervisory Function */ |
| 172 | #define L2CAP_SUPER_RR 0x00 | 121 | #define L2CAP_SUPER_RCV_READY 0x0000 |
| 173 | #define L2CAP_SUPER_REJ 0x01 | 122 | #define L2CAP_SUPER_REJECT 0x0004 |
| 174 | #define L2CAP_SUPER_RNR 0x02 | 123 | #define L2CAP_SUPER_RCV_NOT_READY 0x0008 |
| 175 | #define L2CAP_SUPER_SREJ 0x03 | 124 | #define L2CAP_SUPER_SELECT_REJECT 0x000C |
| 176 | 125 | ||
| 177 | /* L2CAP Segmentation and Reassembly */ | 126 | /* L2CAP Segmentation and Reassembly */ |
| 178 | #define L2CAP_SAR_UNSEGMENTED 0x00 | 127 | #define L2CAP_SDU_UNSEGMENTED 0x0000 |
| 179 | #define L2CAP_SAR_START 0x01 | 128 | #define L2CAP_SDU_START 0x4000 |
| 180 | #define L2CAP_SAR_END 0x02 | 129 | #define L2CAP_SDU_END 0x8000 |
| 181 | #define L2CAP_SAR_CONTINUE 0x03 | 130 | #define L2CAP_SDU_CONTINUE 0xC000 |
| 182 | 131 | ||
| 183 | /* L2CAP Command rej. reasons */ | 132 | /* L2CAP Command rej. reasons */ |
| 184 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 | 133 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 |
| 185 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 | 134 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 |
| 186 | #define L2CAP_REJ_INVALID_CID 0x0002 | 135 | #define L2CAP_REJ_INVALID_CID 0x0002 |
| 136 | |||
| 187 | 137 | ||
| 188 | /* L2CAP structures */ | 138 | /* L2CAP structures */ |
| 189 | struct l2cap_hdr { | 139 | struct l2cap_hdr { |
| @@ -191,14 +141,6 @@ struct l2cap_hdr { | |||
| 191 | __le16 cid; | 141 | __le16 cid; |
| 192 | } __packed; | 142 | } __packed; |
| 193 | #define L2CAP_HDR_SIZE 4 | 143 | #define L2CAP_HDR_SIZE 4 |
| 194 | #define L2CAP_ENH_HDR_SIZE 6 | ||
| 195 | #define L2CAP_EXT_HDR_SIZE 8 | ||
| 196 | |||
| 197 | #define L2CAP_FCS_SIZE 2 | ||
| 198 | #define L2CAP_SDULEN_SIZE 2 | ||
| 199 | #define L2CAP_PSMLEN_SIZE 2 | ||
| 200 | #define L2CAP_ENH_CTRL_SIZE 2 | ||
| 201 | #define L2CAP_EXT_CTRL_SIZE 4 | ||
| 202 | 144 | ||
| 203 | struct l2cap_cmd_hdr { | 145 | struct l2cap_cmd_hdr { |
| 204 | __u8 code; | 146 | __u8 code; |
| @@ -234,29 +176,23 @@ struct l2cap_conn_rsp { | |||
| 234 | __le16 status; | 176 | __le16 status; |
| 235 | } __packed; | 177 | } __packed; |
| 236 | 178 | ||
| 237 | /* protocol/service multiplexer (PSM) */ | ||
| 238 | #define L2CAP_PSM_SDP 0x0001 | ||
| 239 | #define L2CAP_PSM_RFCOMM 0x0003 | ||
| 240 | |||
| 241 | /* channel indentifier */ | 179 | /* channel indentifier */ |
| 242 | #define L2CAP_CID_SIGNALING 0x0001 | 180 | #define L2CAP_CID_SIGNALING 0x0001 |
| 243 | #define L2CAP_CID_CONN_LESS 0x0002 | 181 | #define L2CAP_CID_CONN_LESS 0x0002 |
| 244 | #define L2CAP_CID_A2MP 0x0003 | ||
| 245 | #define L2CAP_CID_LE_DATA 0x0004 | 182 | #define L2CAP_CID_LE_DATA 0x0004 |
| 246 | #define L2CAP_CID_LE_SIGNALING 0x0005 | 183 | #define L2CAP_CID_LE_SIGNALING 0x0005 |
| 247 | #define L2CAP_CID_SMP 0x0006 | 184 | #define L2CAP_CID_SMP 0x0006 |
| 248 | #define L2CAP_CID_DYN_START 0x0040 | 185 | #define L2CAP_CID_DYN_START 0x0040 |
| 249 | #define L2CAP_CID_DYN_END 0xffff | 186 | #define L2CAP_CID_DYN_END 0xffff |
| 250 | 187 | ||
| 251 | /* connect/create channel results */ | 188 | /* connect result */ |
| 252 | #define L2CAP_CR_SUCCESS 0x0000 | 189 | #define L2CAP_CR_SUCCESS 0x0000 |
| 253 | #define L2CAP_CR_PEND 0x0001 | 190 | #define L2CAP_CR_PEND 0x0001 |
| 254 | #define L2CAP_CR_BAD_PSM 0x0002 | 191 | #define L2CAP_CR_BAD_PSM 0x0002 |
| 255 | #define L2CAP_CR_SEC_BLOCK 0x0003 | 192 | #define L2CAP_CR_SEC_BLOCK 0x0003 |
| 256 | #define L2CAP_CR_NO_MEM 0x0004 | 193 | #define L2CAP_CR_NO_MEM 0x0004 |
| 257 | #define L2CAP_CR_BAD_AMP 0x0005 | ||
| 258 | 194 | ||
| 259 | /* connect/create channel status */ | 195 | /* connect status */ |
| 260 | #define L2CAP_CS_NO_INFO 0x0000 | 196 | #define L2CAP_CS_NO_INFO 0x0000 |
| 261 | #define L2CAP_CS_AUTHEN_PEND 0x0001 | 197 | #define L2CAP_CS_AUTHEN_PEND 0x0001 |
| 262 | #define L2CAP_CS_AUTHOR_PEND 0x0002 | 198 | #define L2CAP_CS_AUTHOR_PEND 0x0002 |
| @@ -278,11 +214,6 @@ struct l2cap_conf_rsp { | |||
| 278 | #define L2CAP_CONF_UNACCEPT 0x0001 | 214 | #define L2CAP_CONF_UNACCEPT 0x0001 |
| 279 | #define L2CAP_CONF_REJECT 0x0002 | 215 | #define L2CAP_CONF_REJECT 0x0002 |
| 280 | #define L2CAP_CONF_UNKNOWN 0x0003 | 216 | #define L2CAP_CONF_UNKNOWN 0x0003 |
| 281 | #define L2CAP_CONF_PENDING 0x0004 | ||
| 282 | #define L2CAP_CONF_EFS_REJECT 0x0005 | ||
| 283 | |||
| 284 | /* configuration req/rsp continuation flag */ | ||
| 285 | #define L2CAP_CONF_FLAG_CONTINUATION 0x0001 | ||
| 286 | 217 | ||
| 287 | struct l2cap_conf_opt { | 218 | struct l2cap_conf_opt { |
| 288 | __u8 type; | 219 | __u8 type; |
| @@ -299,8 +230,6 @@ struct l2cap_conf_opt { | |||
| 299 | #define L2CAP_CONF_QOS 0x03 | 230 | #define L2CAP_CONF_QOS 0x03 |
| 300 | #define L2CAP_CONF_RFC 0x04 | 231 | #define L2CAP_CONF_RFC 0x04 |
| 301 | #define L2CAP_CONF_FCS 0x05 | 232 | #define L2CAP_CONF_FCS 0x05 |
| 302 | #define L2CAP_CONF_EFS 0x06 | ||
| 303 | #define L2CAP_CONF_EWS 0x07 | ||
| 304 | 233 | ||
| 305 | #define L2CAP_CONF_MAX_SIZE 22 | 234 | #define L2CAP_CONF_MAX_SIZE 22 |
| 306 | 235 | ||
| @@ -319,21 +248,6 @@ struct l2cap_conf_rfc { | |||
| 319 | #define L2CAP_MODE_ERTM 0x03 | 248 | #define L2CAP_MODE_ERTM 0x03 |
| 320 | #define L2CAP_MODE_STREAMING 0x04 | 249 | #define L2CAP_MODE_STREAMING 0x04 |
| 321 | 250 | ||
| 322 | struct l2cap_conf_efs { | ||
| 323 | __u8 id; | ||
| 324 | __u8 stype; | ||
| 325 | __le16 msdu; | ||
| 326 | __le32 sdu_itime; | ||
| 327 | __le32 acc_lat; | ||
| 328 | __le32 flush_to; | ||
| 329 | } __packed; | ||
| 330 | |||
| 331 | #define L2CAP_SERV_NOTRAFIC 0x00 | ||
| 332 | #define L2CAP_SERV_BESTEFFORT 0x01 | ||
| 333 | #define L2CAP_SERV_GUARANTEED 0x02 | ||
| 334 | |||
| 335 | #define L2CAP_BESTEFFORT_ID 0x01 | ||
| 336 | |||
| 337 | struct l2cap_disconn_req { | 251 | struct l2cap_disconn_req { |
| 338 | __le16 dcid; | 252 | __le16 dcid; |
| 339 | __le16 scid; | 253 | __le16 scid; |
| @@ -354,57 +268,14 @@ struct l2cap_info_rsp { | |||
| 354 | __u8 data[0]; | 268 | __u8 data[0]; |
| 355 | } __packed; | 269 | } __packed; |
| 356 | 270 | ||
| 357 | struct l2cap_create_chan_req { | ||
| 358 | __le16 psm; | ||
| 359 | __le16 scid; | ||
| 360 | __u8 amp_id; | ||
| 361 | } __packed; | ||
| 362 | |||
| 363 | struct l2cap_create_chan_rsp { | ||
| 364 | __le16 dcid; | ||
| 365 | __le16 scid; | ||
| 366 | __le16 result; | ||
| 367 | __le16 status; | ||
| 368 | } __packed; | ||
| 369 | |||
| 370 | struct l2cap_move_chan_req { | ||
| 371 | __le16 icid; | ||
| 372 | __u8 dest_amp_id; | ||
| 373 | } __packed; | ||
| 374 | |||
| 375 | struct l2cap_move_chan_rsp { | ||
| 376 | __le16 icid; | ||
| 377 | __le16 result; | ||
| 378 | } __packed; | ||
| 379 | |||
| 380 | #define L2CAP_MR_SUCCESS 0x0000 | ||
| 381 | #define L2CAP_MR_PEND 0x0001 | ||
| 382 | #define L2CAP_MR_BAD_ID 0x0002 | ||
| 383 | #define L2CAP_MR_SAME_ID 0x0003 | ||
| 384 | #define L2CAP_MR_NOT_SUPP 0x0004 | ||
| 385 | #define L2CAP_MR_COLLISION 0x0005 | ||
| 386 | #define L2CAP_MR_NOT_ALLOWED 0x0006 | ||
| 387 | |||
| 388 | struct l2cap_move_chan_cfm { | ||
| 389 | __le16 icid; | ||
| 390 | __le16 result; | ||
| 391 | } __packed; | ||
| 392 | |||
| 393 | #define L2CAP_MC_CONFIRMED 0x0000 | ||
| 394 | #define L2CAP_MC_UNCONFIRMED 0x0001 | ||
| 395 | |||
| 396 | struct l2cap_move_chan_cfm_rsp { | ||
| 397 | __le16 icid; | ||
| 398 | } __packed; | ||
| 399 | |||
| 400 | /* info type */ | 271 | /* info type */ |
| 401 | #define L2CAP_IT_CL_MTU 0x0001 | 272 | #define L2CAP_IT_CL_MTU 0x0001 |
| 402 | #define L2CAP_IT_FEAT_MASK 0x0002 | 273 | #define L2CAP_IT_FEAT_MASK 0x0002 |
| 403 | #define L2CAP_IT_FIXED_CHAN 0x0003 | 274 | #define L2CAP_IT_FIXED_CHAN 0x0003 |
| 404 | 275 | ||
| 405 | /* info result */ | 276 | /* info result */ |
| 406 | #define L2CAP_IR_SUCCESS 0x0000 | 277 | #define L2CAP_IR_SUCCESS 0x0000 |
| 407 | #define L2CAP_IR_NOTSUPP 0x0001 | 278 | #define L2CAP_IR_NOTSUPP 0x0001 |
| 408 | 279 | ||
| 409 | struct l2cap_conn_param_update_req { | 280 | struct l2cap_conn_param_update_req { |
| 410 | __le16 min; | 281 | __le16 min; |
| @@ -422,26 +293,20 @@ struct l2cap_conn_param_update_rsp { | |||
| 422 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 | 293 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
| 423 | 294 | ||
| 424 | /* ----- L2CAP channels and connections ----- */ | 295 | /* ----- L2CAP channels and connections ----- */ |
| 425 | struct l2cap_seq_list { | 296 | struct srej_list { |
| 426 | __u16 head; | 297 | __u8 tx_seq; |
| 427 | __u16 tail; | 298 | struct list_head list; |
| 428 | __u16 mask; | ||
| 429 | __u16 *list; | ||
| 430 | }; | 299 | }; |
| 431 | 300 | ||
| 432 | #define L2CAP_SEQ_LIST_CLEAR 0xFFFF | ||
| 433 | #define L2CAP_SEQ_LIST_TAIL 0x8000 | ||
| 434 | |||
| 435 | struct l2cap_chan { | 301 | struct l2cap_chan { |
| 436 | struct sock *sk; | 302 | struct sock *sk; |
| 437 | 303 | ||
| 438 | struct l2cap_conn *conn; | 304 | struct l2cap_conn *conn; |
| 439 | struct hci_conn *hs_hcon; | ||
| 440 | struct hci_chan *hs_hchan; | ||
| 441 | struct kref kref; | ||
| 442 | 305 | ||
| 443 | __u8 state; | 306 | __u8 state; |
| 444 | 307 | ||
| 308 | atomic_t refcnt; | ||
| 309 | |||
| 445 | __le16 psm; | 310 | __le16 psm; |
| 446 | __u16 dcid; | 311 | __u16 dcid; |
| 447 | __u16 scid; | 312 | __u16 scid; |
| @@ -451,11 +316,14 @@ struct l2cap_chan { | |||
| 451 | __u16 flush_to; | 316 | __u16 flush_to; |
| 452 | __u8 mode; | 317 | __u8 mode; |
| 453 | __u8 chan_type; | 318 | __u8 chan_type; |
| 454 | __u8 chan_policy; | ||
| 455 | 319 | ||
| 456 | __le16 sport; | 320 | __le16 sport; |
| 457 | 321 | ||
| 458 | __u8 sec_level; | 322 | __u8 sec_level; |
| 323 | __u8 role_switch; | ||
| 324 | __u8 force_reliable; | ||
| 325 | __u8 flushable; | ||
| 326 | __u8 force_active; | ||
| 459 | 327 | ||
| 460 | __u8 ident; | 328 | __u8 ident; |
| 461 | 329 | ||
| @@ -466,124 +334,92 @@ struct l2cap_chan { | |||
| 466 | 334 | ||
| 467 | __u8 fcs; | 335 | __u8 fcs; |
| 468 | 336 | ||
| 469 | __u16 tx_win; | 337 | __u8 tx_win; |
| 470 | __u16 tx_win_max; | ||
| 471 | __u16 ack_win; | ||
| 472 | __u8 max_tx; | 338 | __u8 max_tx; |
| 473 | __u16 retrans_timeout; | 339 | __u16 retrans_timeout; |
| 474 | __u16 monitor_timeout; | 340 | __u16 monitor_timeout; |
| 475 | __u16 mps; | 341 | __u16 mps; |
| 476 | 342 | ||
| 477 | __u8 tx_state; | ||
| 478 | __u8 rx_state; | ||
| 479 | |||
| 480 | unsigned long conf_state; | 343 | unsigned long conf_state; |
| 481 | unsigned long conn_state; | 344 | unsigned long conn_state; |
| 482 | unsigned long flags; | 345 | |
| 483 | 346 | __u8 next_tx_seq; | |
| 484 | __u8 remote_amp_id; | 347 | __u8 expected_ack_seq; |
| 485 | __u8 local_amp_id; | 348 | __u8 expected_tx_seq; |
| 486 | __u8 move_id; | 349 | __u8 buffer_seq; |
| 487 | __u8 move_state; | 350 | __u8 buffer_seq_srej; |
| 488 | __u8 move_role; | 351 | __u8 srej_save_reqseq; |
| 489 | 352 | __u8 frames_sent; | |
| 490 | __u16 next_tx_seq; | 353 | __u8 unacked_frames; |
| 491 | __u16 expected_ack_seq; | ||
| 492 | __u16 expected_tx_seq; | ||
| 493 | __u16 buffer_seq; | ||
| 494 | __u16 srej_save_reqseq; | ||
| 495 | __u16 last_acked_seq; | ||
| 496 | __u16 frames_sent; | ||
| 497 | __u16 unacked_frames; | ||
| 498 | __u8 retry_count; | 354 | __u8 retry_count; |
| 499 | __u16 srej_queue_next; | 355 | __u8 num_acked; |
| 500 | __u16 sdu_len; | 356 | __u16 sdu_len; |
| 357 | __u16 partial_sdu_len; | ||
| 501 | struct sk_buff *sdu; | 358 | struct sk_buff *sdu; |
| 502 | struct sk_buff *sdu_last_frag; | ||
| 503 | 359 | ||
| 504 | __u16 remote_tx_win; | 360 | __u8 remote_tx_win; |
| 505 | __u8 remote_max_tx; | 361 | __u8 remote_max_tx; |
| 506 | __u16 remote_mps; | 362 | __u16 remote_mps; |
| 507 | 363 | ||
| 508 | __u8 local_id; | 364 | struct timer_list chan_timer; |
| 509 | __u8 local_stype; | 365 | struct timer_list retrans_timer; |
| 510 | __u16 local_msdu; | 366 | struct timer_list monitor_timer; |
| 511 | __u32 local_sdu_itime; | 367 | struct timer_list ack_timer; |
| 512 | __u32 local_acc_lat; | ||
| 513 | __u32 local_flush_to; | ||
| 514 | |||
| 515 | __u8 remote_id; | ||
| 516 | __u8 remote_stype; | ||
| 517 | __u16 remote_msdu; | ||
| 518 | __u32 remote_sdu_itime; | ||
| 519 | __u32 remote_acc_lat; | ||
| 520 | __u32 remote_flush_to; | ||
| 521 | |||
| 522 | struct delayed_work chan_timer; | ||
| 523 | struct delayed_work retrans_timer; | ||
| 524 | struct delayed_work monitor_timer; | ||
| 525 | struct delayed_work ack_timer; | ||
| 526 | |||
| 527 | struct sk_buff *tx_send_head; | 368 | struct sk_buff *tx_send_head; |
| 528 | struct sk_buff_head tx_q; | 369 | struct sk_buff_head tx_q; |
| 529 | struct sk_buff_head srej_q; | 370 | struct sk_buff_head srej_q; |
| 530 | struct l2cap_seq_list srej_list; | 371 | struct list_head srej_l; |
| 531 | struct l2cap_seq_list retrans_list; | ||
| 532 | 372 | ||
| 533 | struct list_head list; | 373 | struct list_head list; |
| 534 | struct list_head global_l; | 374 | struct list_head global_l; |
| 535 | 375 | ||
| 536 | void *data; | 376 | void *data; |
| 537 | struct l2cap_ops *ops; | 377 | struct l2cap_ops *ops; |
| 538 | struct mutex lock; | ||
| 539 | }; | 378 | }; |
| 540 | 379 | ||
| 541 | struct l2cap_ops { | 380 | struct l2cap_ops { |
| 542 | char *name; | 381 | char *name; |
| 543 | 382 | ||
| 544 | struct l2cap_chan *(*new_connection) (struct l2cap_chan *chan); | 383 | struct l2cap_chan *(*new_connection) (void *data); |
| 545 | int (*recv) (struct l2cap_chan * chan, | 384 | int (*recv) (void *data, struct sk_buff *skb); |
| 546 | struct sk_buff *skb); | 385 | void (*close) (void *data); |
| 547 | void (*teardown) (struct l2cap_chan *chan, int err); | 386 | void (*state_change) (void *data, int state); |
| 548 | void (*close) (struct l2cap_chan *chan); | ||
| 549 | void (*state_change) (struct l2cap_chan *chan, | ||
| 550 | int state); | ||
| 551 | void (*ready) (struct l2cap_chan *chan); | ||
| 552 | void (*defer) (struct l2cap_chan *chan); | ||
| 553 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | ||
| 554 | unsigned long len, int nb); | ||
| 555 | }; | 387 | }; |
| 556 | 388 | ||
| 557 | struct l2cap_conn { | 389 | struct l2cap_conn { |
| 558 | struct hci_conn *hcon; | 390 | struct hci_conn *hcon; |
| 559 | struct hci_chan *hchan; | 391 | |
| 392 | bdaddr_t *dst; | ||
| 393 | bdaddr_t *src; | ||
| 560 | 394 | ||
| 561 | bdaddr_t *dst; | 395 | unsigned int mtu; |
| 562 | bdaddr_t *src; | ||
| 563 | 396 | ||
| 564 | unsigned int mtu; | 397 | __u32 feat_mask; |
| 565 | 398 | ||
| 566 | __u32 feat_mask; | 399 | __u8 info_state; |
| 567 | __u8 fixed_chan_mask; | 400 | __u8 info_ident; |
| 568 | 401 | ||
| 569 | __u8 info_state; | 402 | struct timer_list info_timer; |
| 570 | __u8 info_ident; | ||
| 571 | 403 | ||
| 572 | struct delayed_work info_timer; | 404 | spinlock_t lock; |
| 573 | 405 | ||
| 574 | spinlock_t lock; | 406 | struct sk_buff *rx_skb; |
| 407 | __u32 rx_len; | ||
| 408 | __u8 tx_ident; | ||
| 575 | 409 | ||
| 576 | struct sk_buff *rx_skb; | 410 | __u8 disc_reason; |
| 577 | __u32 rx_len; | ||
| 578 | __u8 tx_ident; | ||
| 579 | 411 | ||
| 580 | __u8 disc_reason; | 412 | __u8 preq[7]; /* SMP Pairing Request */ |
| 413 | __u8 prsp[7]; /* SMP Pairing Response */ | ||
| 414 | __u8 prnd[16]; /* SMP Pairing Random */ | ||
| 415 | __u8 pcnf[16]; /* SMP Pairing Confirm */ | ||
| 416 | __u8 tk[16]; /* SMP Temporary Key */ | ||
| 417 | __u8 smp_key_size; | ||
| 581 | 418 | ||
| 582 | struct delayed_work security_timer; | 419 | struct timer_list security_timer; |
| 583 | struct smp_chan *smp_chan; | ||
| 584 | 420 | ||
| 585 | struct list_head chan_l; | 421 | struct list_head chan_l; |
| 586 | struct mutex chan_lock; | 422 | rwlock_t chan_lock; |
| 587 | }; | 423 | }; |
| 588 | 424 | ||
| 589 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 425 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
| @@ -593,15 +429,14 @@ struct l2cap_conn { | |||
| 593 | #define L2CAP_CHAN_RAW 1 | 429 | #define L2CAP_CHAN_RAW 1 |
| 594 | #define L2CAP_CHAN_CONN_LESS 2 | 430 | #define L2CAP_CHAN_CONN_LESS 2 |
| 595 | #define L2CAP_CHAN_CONN_ORIENTED 3 | 431 | #define L2CAP_CHAN_CONN_ORIENTED 3 |
| 596 | #define L2CAP_CHAN_CONN_FIX_A2MP 4 | ||
| 597 | 432 | ||
| 598 | /* ----- L2CAP socket info ----- */ | 433 | /* ----- L2CAP socket info ----- */ |
| 599 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 434 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
| 600 | 435 | ||
| 601 | struct l2cap_pinfo { | 436 | struct l2cap_pinfo { |
| 602 | struct bt_sock bt; | 437 | struct bt_sock bt; |
| 603 | struct l2cap_chan *chan; | 438 | struct l2cap_chan *chan; |
| 604 | struct sk_buff *rx_busy_skb; | 439 | struct sk_buff *rx_busy_skb; |
| 605 | }; | 440 | }; |
| 606 | 441 | ||
| 607 | enum { | 442 | enum { |
| @@ -611,18 +446,15 @@ enum { | |||
| 611 | CONF_MTU_DONE, | 446 | CONF_MTU_DONE, |
| 612 | CONF_MODE_DONE, | 447 | CONF_MODE_DONE, |
| 613 | CONF_CONNECT_PEND, | 448 | CONF_CONNECT_PEND, |
| 614 | CONF_RECV_NO_FCS, | 449 | CONF_NO_FCS_RECV, |
| 615 | CONF_STATE2_DEVICE, | 450 | CONF_STATE2_DEVICE, |
| 616 | CONF_EWS_RECV, | ||
| 617 | CONF_LOC_CONF_PEND, | ||
| 618 | CONF_REM_CONF_PEND, | ||
| 619 | CONF_NOT_COMPLETE, | ||
| 620 | }; | 451 | }; |
| 621 | 452 | ||
| 622 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 453 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
| 623 | #define L2CAP_CONF_MAX_CONF_RSP 2 | 454 | #define L2CAP_CONF_MAX_CONF_RSP 2 |
| 624 | 455 | ||
| 625 | enum { | 456 | enum { |
| 457 | CONN_SAR_SDU, | ||
| 626 | CONN_SREJ_SENT, | 458 | CONN_SREJ_SENT, |
| 627 | CONN_WAIT_F, | 459 | CONN_WAIT_F, |
| 628 | CONN_SREJ_ACT, | 460 | CONN_SREJ_ACT, |
| @@ -634,156 +466,37 @@ enum { | |||
| 634 | CONN_RNR_SENT, | 466 | CONN_RNR_SENT, |
| 635 | }; | 467 | }; |
| 636 | 468 | ||
| 637 | /* Definitions for flags in l2cap_chan */ | ||
| 638 | enum { | ||
| 639 | FLAG_ROLE_SWITCH, | ||
| 640 | FLAG_FORCE_ACTIVE, | ||
| 641 | FLAG_FORCE_RELIABLE, | ||
| 642 | FLAG_FLUSHABLE, | ||
| 643 | FLAG_EXT_CTRL, | ||
| 644 | FLAG_EFS_ENABLE, | ||
| 645 | }; | ||
| 646 | |||
| 647 | enum { | ||
| 648 | L2CAP_TX_STATE_XMIT, | ||
| 649 | L2CAP_TX_STATE_WAIT_F, | ||
| 650 | }; | ||
| 651 | |||
| 652 | enum { | ||
| 653 | L2CAP_RX_STATE_RECV, | ||
| 654 | L2CAP_RX_STATE_SREJ_SENT, | ||
| 655 | L2CAP_RX_STATE_MOVE, | ||
| 656 | L2CAP_RX_STATE_WAIT_P, | ||
| 657 | L2CAP_RX_STATE_WAIT_F, | ||
| 658 | }; | ||
| 659 | |||
| 660 | enum { | ||
| 661 | L2CAP_TXSEQ_EXPECTED, | ||
| 662 | L2CAP_TXSEQ_EXPECTED_SREJ, | ||
| 663 | L2CAP_TXSEQ_UNEXPECTED, | ||
| 664 | L2CAP_TXSEQ_UNEXPECTED_SREJ, | ||
| 665 | L2CAP_TXSEQ_DUPLICATE, | ||
| 666 | L2CAP_TXSEQ_DUPLICATE_SREJ, | ||
| 667 | L2CAP_TXSEQ_INVALID, | ||
| 668 | L2CAP_TXSEQ_INVALID_IGNORE, | ||
| 669 | }; | ||
| 670 | |||
| 671 | enum { | ||
| 672 | L2CAP_EV_DATA_REQUEST, | ||
| 673 | L2CAP_EV_LOCAL_BUSY_DETECTED, | ||
| 674 | L2CAP_EV_LOCAL_BUSY_CLEAR, | ||
| 675 | L2CAP_EV_RECV_REQSEQ_AND_FBIT, | ||
| 676 | L2CAP_EV_RECV_FBIT, | ||
| 677 | L2CAP_EV_RETRANS_TO, | ||
| 678 | L2CAP_EV_MONITOR_TO, | ||
| 679 | L2CAP_EV_EXPLICIT_POLL, | ||
| 680 | L2CAP_EV_RECV_IFRAME, | ||
| 681 | L2CAP_EV_RECV_RR, | ||
| 682 | L2CAP_EV_RECV_REJ, | ||
| 683 | L2CAP_EV_RECV_RNR, | ||
| 684 | L2CAP_EV_RECV_SREJ, | ||
| 685 | L2CAP_EV_RECV_FRAME, | ||
| 686 | }; | ||
| 687 | |||
| 688 | enum { | ||
| 689 | L2CAP_MOVE_ROLE_NONE, | ||
| 690 | L2CAP_MOVE_ROLE_INITIATOR, | ||
| 691 | L2CAP_MOVE_ROLE_RESPONDER, | ||
| 692 | }; | ||
| 693 | |||
| 694 | enum { | ||
| 695 | L2CAP_MOVE_STABLE, | ||
| 696 | L2CAP_MOVE_WAIT_REQ, | ||
| 697 | L2CAP_MOVE_WAIT_RSP, | ||
| 698 | L2CAP_MOVE_WAIT_RSP_SUCCESS, | ||
| 699 | L2CAP_MOVE_WAIT_CONFIRM, | ||
| 700 | L2CAP_MOVE_WAIT_CONFIRM_RSP, | ||
| 701 | L2CAP_MOVE_WAIT_LOGICAL_COMP, | ||
| 702 | L2CAP_MOVE_WAIT_LOGICAL_CFM, | ||
| 703 | L2CAP_MOVE_WAIT_LOCAL_BUSY, | ||
| 704 | L2CAP_MOVE_WAIT_PREPARE, | ||
| 705 | }; | ||
| 706 | |||
| 707 | void l2cap_chan_hold(struct l2cap_chan *c); | ||
| 708 | void l2cap_chan_put(struct l2cap_chan *c); | ||
| 709 | |||
| 710 | static inline void l2cap_chan_lock(struct l2cap_chan *chan) | ||
| 711 | { | ||
| 712 | mutex_lock(&chan->lock); | ||
| 713 | } | ||
| 714 | |||
| 715 | static inline void l2cap_chan_unlock(struct l2cap_chan *chan) | ||
| 716 | { | ||
| 717 | mutex_unlock(&chan->lock); | ||
| 718 | } | ||
| 719 | |||
| 720 | static inline void l2cap_set_timer(struct l2cap_chan *chan, | ||
| 721 | struct delayed_work *work, long timeout) | ||
| 722 | { | ||
| 723 | BT_DBG("chan %p state %s timeout %ld", chan, | ||
| 724 | state_to_string(chan->state), timeout); | ||
| 725 | |||
| 726 | /* If delayed work cancelled do not hold(chan) | ||
| 727 | since it is already done with previous set_timer */ | ||
| 728 | if (!cancel_delayed_work(work)) | ||
| 729 | l2cap_chan_hold(chan); | ||
| 730 | |||
| 731 | schedule_delayed_work(work, timeout); | ||
| 732 | } | ||
| 733 | |||
| 734 | static inline bool l2cap_clear_timer(struct l2cap_chan *chan, | ||
| 735 | struct delayed_work *work) | ||
| 736 | { | ||
| 737 | bool ret; | ||
| 738 | |||
| 739 | /* put(chan) if delayed work cancelled otherwise it | ||
| 740 | is done in delayed work function */ | ||
| 741 | ret = cancel_delayed_work(work); | ||
| 742 | if (ret) | ||
| 743 | l2cap_chan_put(chan); | ||
| 744 | |||
| 745 | return ret; | ||
| 746 | } | ||
| 747 | |||
| 748 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) | 469 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) |
| 749 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) | 470 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) |
| 471 | #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ | ||
| 472 | L2CAP_DEFAULT_RETRANS_TO); | ||
| 750 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) | 473 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) |
| 474 | #define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ | ||
| 475 | L2CAP_DEFAULT_MONITOR_TO); | ||
| 751 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) | 476 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) |
| 752 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ | 477 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ |
| 753 | msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 478 | L2CAP_DEFAULT_ACK_TO); |
| 754 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) | 479 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) |
| 755 | 480 | ||
| 756 | static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) | 481 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
| 757 | { | 482 | { |
| 758 | if (seq1 >= seq2) | 483 | int sub; |
| 759 | return seq1 - seq2; | ||
| 760 | else | ||
| 761 | return chan->tx_win_max + 1 - seq2 + seq1; | ||
| 762 | } | ||
| 763 | 484 | ||
| 764 | static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) | 485 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; |
| 765 | { | ||
| 766 | return (seq + 1) % (chan->tx_win_max + 1); | ||
| 767 | } | ||
| 768 | |||
| 769 | static inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan) | ||
| 770 | { | ||
| 771 | return NULL; | ||
| 772 | } | ||
| 773 | 486 | ||
| 774 | static inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err) | 487 | if (sub < 0) |
| 775 | { | 488 | sub += 64; |
| 776 | } | ||
| 777 | 489 | ||
| 778 | static inline void l2cap_chan_no_ready(struct l2cap_chan *chan) | 490 | return sub == ch->remote_tx_win; |
| 779 | { | ||
| 780 | } | 491 | } |
| 781 | 492 | ||
| 782 | static inline void l2cap_chan_no_defer(struct l2cap_chan *chan) | 493 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) |
| 783 | { | 494 | #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) |
| 784 | } | 495 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) |
| 496 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) | ||
| 497 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) | ||
| 785 | 498 | ||
| 786 | extern bool disable_ertm; | 499 | extern int disable_ertm; |
| 787 | 500 | ||
| 788 | int l2cap_init_sockets(void); | 501 | int l2cap_init_sockets(void); |
| 789 | void l2cap_cleanup_sockets(void); | 502 | void l2cap_cleanup_sockets(void); |
| @@ -794,23 +507,11 @@ int __l2cap_wait_ack(struct sock *sk); | |||
| 794 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | 507 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); |
| 795 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | 508 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); |
| 796 | 509 | ||
| 797 | struct l2cap_chan *l2cap_chan_create(void); | 510 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); |
| 798 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); | 511 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); |
| 799 | int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | 512 | void l2cap_chan_destroy(struct l2cap_chan *chan); |
| 800 | bdaddr_t *dst, u8 dst_type); | 513 | int l2cap_chan_connect(struct l2cap_chan *chan); |
| 801 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | 514 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
| 802 | u32 priority); | ||
| 803 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 515 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
| 804 | int l2cap_chan_check_security(struct l2cap_chan *chan); | ||
| 805 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); | ||
| 806 | int l2cap_ertm_init(struct l2cap_chan *chan); | ||
| 807 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
| 808 | void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
| 809 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
| 810 | void l2cap_send_conn_req(struct l2cap_chan *chan); | ||
| 811 | void l2cap_move_start(struct l2cap_chan *chan); | ||
| 812 | void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan, | ||
| 813 | u8 status); | ||
| 814 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); | ||
| 815 | 516 | ||
| 816 | #endif /* __L2CAP_H */ | 517 | #endif /* __L2CAP_H */ |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 22980a7c387..5428fd32cce 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
| 3 | 3 | ||
| 4 | Copyright (C) 2010 Nokia Corporation | 4 | Copyright (C) 2010 Nokia Corporation |
| 5 | Copyright (C) 2011-2012 Intel Corporation | ||
| 6 | 5 | ||
| 7 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License version 2 as | 7 | it under the terms of the GNU General Public License version 2 as |
| @@ -24,464 +23,281 @@ | |||
| 24 | 23 | ||
| 25 | #define MGMT_INDEX_NONE 0xFFFF | 24 | #define MGMT_INDEX_NONE 0xFFFF |
| 26 | 25 | ||
| 27 | #define MGMT_STATUS_SUCCESS 0x00 | ||
| 28 | #define MGMT_STATUS_UNKNOWN_COMMAND 0x01 | ||
| 29 | #define MGMT_STATUS_NOT_CONNECTED 0x02 | ||
| 30 | #define MGMT_STATUS_FAILED 0x03 | ||
| 31 | #define MGMT_STATUS_CONNECT_FAILED 0x04 | ||
| 32 | #define MGMT_STATUS_AUTH_FAILED 0x05 | ||
| 33 | #define MGMT_STATUS_NOT_PAIRED 0x06 | ||
| 34 | #define MGMT_STATUS_NO_RESOURCES 0x07 | ||
| 35 | #define MGMT_STATUS_TIMEOUT 0x08 | ||
| 36 | #define MGMT_STATUS_ALREADY_CONNECTED 0x09 | ||
| 37 | #define MGMT_STATUS_BUSY 0x0a | ||
| 38 | #define MGMT_STATUS_REJECTED 0x0b | ||
| 39 | #define MGMT_STATUS_NOT_SUPPORTED 0x0c | ||
| 40 | #define MGMT_STATUS_INVALID_PARAMS 0x0d | ||
| 41 | #define MGMT_STATUS_DISCONNECTED 0x0e | ||
| 42 | #define MGMT_STATUS_NOT_POWERED 0x0f | ||
| 43 | #define MGMT_STATUS_CANCELLED 0x10 | ||
| 44 | #define MGMT_STATUS_INVALID_INDEX 0x11 | ||
| 45 | |||
| 46 | struct mgmt_hdr { | 26 | struct mgmt_hdr { |
| 47 | __le16 opcode; | 27 | __le16 opcode; |
| 48 | __le16 index; | 28 | __le16 index; |
| 49 | __le16 len; | 29 | __le16 len; |
| 50 | } __packed; | ||
| 51 | |||
| 52 | struct mgmt_addr_info { | ||
| 53 | bdaddr_t bdaddr; | ||
| 54 | __u8 type; | ||
| 55 | } __packed; | 30 | } __packed; |
| 56 | #define MGMT_ADDR_INFO_SIZE 7 | ||
| 57 | 31 | ||
| 58 | #define MGMT_OP_READ_VERSION 0x0001 | 32 | #define MGMT_OP_READ_VERSION 0x0001 |
| 59 | #define MGMT_READ_VERSION_SIZE 0 | ||
| 60 | struct mgmt_rp_read_version { | 33 | struct mgmt_rp_read_version { |
| 61 | __u8 version; | 34 | __u8 version; |
| 62 | __le16 revision; | 35 | __le16 revision; |
| 63 | } __packed; | ||
| 64 | |||
| 65 | #define MGMT_OP_READ_COMMANDS 0x0002 | ||
| 66 | #define MGMT_READ_COMMANDS_SIZE 0 | ||
| 67 | struct mgmt_rp_read_commands { | ||
| 68 | __le16 num_commands; | ||
| 69 | __le16 num_events; | ||
| 70 | __le16 opcodes[0]; | ||
| 71 | } __packed; | 36 | } __packed; |
| 72 | 37 | ||
| 73 | #define MGMT_OP_READ_INDEX_LIST 0x0003 | 38 | #define MGMT_OP_READ_INDEX_LIST 0x0003 |
| 74 | #define MGMT_READ_INDEX_LIST_SIZE 0 | ||
| 75 | struct mgmt_rp_read_index_list { | 39 | struct mgmt_rp_read_index_list { |
| 76 | __le16 num_controllers; | 40 | __le16 num_controllers; |
| 77 | __le16 index[0]; | 41 | __le16 index[0]; |
| 78 | } __packed; | 42 | } __packed; |
| 79 | 43 | ||
| 80 | /* Reserve one extra byte for names in management messages so that they | 44 | /* Reserve one extra byte for names in management messages so that they |
| 81 | * are always guaranteed to be nul-terminated */ | 45 | * are always guaranteed to be nul-terminated */ |
| 82 | #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) | 46 | #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) |
| 83 | #define MGMT_MAX_SHORT_NAME_LENGTH (HCI_MAX_SHORT_NAME_LENGTH + 1) | ||
| 84 | |||
| 85 | #define MGMT_SETTING_POWERED 0x00000001 | ||
| 86 | #define MGMT_SETTING_CONNECTABLE 0x00000002 | ||
| 87 | #define MGMT_SETTING_FAST_CONNECTABLE 0x00000004 | ||
| 88 | #define MGMT_SETTING_DISCOVERABLE 0x00000008 | ||
| 89 | #define MGMT_SETTING_PAIRABLE 0x00000010 | ||
| 90 | #define MGMT_SETTING_LINK_SECURITY 0x00000020 | ||
| 91 | #define MGMT_SETTING_SSP 0x00000040 | ||
| 92 | #define MGMT_SETTING_BREDR 0x00000080 | ||
| 93 | #define MGMT_SETTING_HS 0x00000100 | ||
| 94 | #define MGMT_SETTING_LE 0x00000200 | ||
| 95 | 47 | ||
| 96 | #define MGMT_OP_READ_INFO 0x0004 | 48 | #define MGMT_OP_READ_INFO 0x0004 |
| 97 | #define MGMT_READ_INFO_SIZE 0 | ||
| 98 | struct mgmt_rp_read_info { | 49 | struct mgmt_rp_read_info { |
| 99 | bdaddr_t bdaddr; | 50 | __u8 type; |
| 100 | __u8 version; | 51 | __u8 powered; |
| 101 | __le16 manufacturer; | 52 | __u8 connectable; |
| 102 | __le32 supported_settings; | 53 | __u8 discoverable; |
| 103 | __le32 current_settings; | 54 | __u8 pairable; |
| 104 | __u8 dev_class[3]; | 55 | __u8 sec_mode; |
| 105 | __u8 name[MGMT_MAX_NAME_LENGTH]; | 56 | bdaddr_t bdaddr; |
| 106 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | 57 | __u8 dev_class[3]; |
| 58 | __u8 features[8]; | ||
| 59 | __u16 manufacturer; | ||
| 60 | __u8 hci_ver; | ||
| 61 | __u16 hci_rev; | ||
| 62 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
| 107 | } __packed; | 63 | } __packed; |
| 108 | 64 | ||
| 109 | struct mgmt_mode { | 65 | struct mgmt_mode { |
| 110 | __u8 val; | 66 | __u8 val; |
| 111 | } __packed; | 67 | } __packed; |
| 112 | 68 | ||
| 113 | #define MGMT_SETTING_SIZE 1 | ||
| 114 | |||
| 115 | #define MGMT_OP_SET_POWERED 0x0005 | 69 | #define MGMT_OP_SET_POWERED 0x0005 |
| 116 | 70 | ||
| 117 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 | 71 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 |
| 118 | struct mgmt_cp_set_discoverable { | ||
| 119 | __u8 val; | ||
| 120 | __le16 timeout; | ||
| 121 | } __packed; | ||
| 122 | #define MGMT_SET_DISCOVERABLE_SIZE 3 | ||
| 123 | 72 | ||
| 124 | #define MGMT_OP_SET_CONNECTABLE 0x0007 | 73 | #define MGMT_OP_SET_CONNECTABLE 0x0007 |
| 125 | 74 | ||
| 126 | #define MGMT_OP_SET_FAST_CONNECTABLE 0x0008 | 75 | #define MGMT_OP_SET_PAIRABLE 0x0008 |
| 127 | |||
| 128 | #define MGMT_OP_SET_PAIRABLE 0x0009 | ||
| 129 | |||
| 130 | #define MGMT_OP_SET_LINK_SECURITY 0x000A | ||
| 131 | |||
| 132 | #define MGMT_OP_SET_SSP 0x000B | ||
| 133 | |||
| 134 | #define MGMT_OP_SET_HS 0x000C | ||
| 135 | |||
| 136 | #define MGMT_OP_SET_LE 0x000D | ||
| 137 | #define MGMT_OP_SET_DEV_CLASS 0x000E | ||
| 138 | struct mgmt_cp_set_dev_class { | ||
| 139 | __u8 major; | ||
| 140 | __u8 minor; | ||
| 141 | } __packed; | ||
| 142 | #define MGMT_SET_DEV_CLASS_SIZE 2 | ||
| 143 | |||
| 144 | #define MGMT_OP_SET_LOCAL_NAME 0x000F | ||
| 145 | struct mgmt_cp_set_local_name { | ||
| 146 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
| 147 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | ||
| 148 | } __packed; | ||
| 149 | #define MGMT_SET_LOCAL_NAME_SIZE 260 | ||
| 150 | 76 | ||
| 151 | #define MGMT_OP_ADD_UUID 0x0010 | 77 | #define MGMT_OP_ADD_UUID 0x0009 |
| 152 | struct mgmt_cp_add_uuid { | 78 | struct mgmt_cp_add_uuid { |
| 153 | __u8 uuid[16]; | 79 | __u8 uuid[16]; |
| 154 | __u8 svc_hint; | 80 | __u8 svc_hint; |
| 155 | } __packed; | 81 | } __packed; |
| 156 | #define MGMT_ADD_UUID_SIZE 17 | ||
| 157 | 82 | ||
| 158 | #define MGMT_OP_REMOVE_UUID 0x0011 | 83 | #define MGMT_OP_REMOVE_UUID 0x000A |
| 159 | struct mgmt_cp_remove_uuid { | 84 | struct mgmt_cp_remove_uuid { |
| 160 | __u8 uuid[16]; | 85 | __u8 uuid[16]; |
| 86 | } __packed; | ||
| 87 | |||
| 88 | #define MGMT_OP_SET_DEV_CLASS 0x000B | ||
| 89 | struct mgmt_cp_set_dev_class { | ||
| 90 | __u8 major; | ||
| 91 | __u8 minor; | ||
| 161 | } __packed; | 92 | } __packed; |
| 162 | #define MGMT_REMOVE_UUID_SIZE 16 | ||
| 163 | 93 | ||
| 164 | struct mgmt_link_key_info { | 94 | #define MGMT_OP_SET_SERVICE_CACHE 0x000C |
| 165 | struct mgmt_addr_info addr; | 95 | struct mgmt_cp_set_service_cache { |
| 166 | __u8 type; | 96 | __u8 enable; |
| 167 | __u8 val[16]; | ||
| 168 | __u8 pin_len; | ||
| 169 | } __packed; | 97 | } __packed; |
| 170 | 98 | ||
| 171 | #define MGMT_OP_LOAD_LINK_KEYS 0x0012 | 99 | struct mgmt_key_info { |
| 172 | struct mgmt_cp_load_link_keys { | 100 | bdaddr_t bdaddr; |
| 173 | __u8 debug_keys; | 101 | u8 type; |
| 174 | __le16 key_count; | 102 | u8 val[16]; |
| 175 | struct mgmt_link_key_info keys[0]; | 103 | u8 pin_len; |
| 104 | u8 dlen; | ||
| 105 | u8 data[0]; | ||
| 176 | } __packed; | 106 | } __packed; |
| 177 | #define MGMT_LOAD_LINK_KEYS_SIZE 3 | ||
| 178 | 107 | ||
| 179 | struct mgmt_ltk_info { | 108 | #define MGMT_OP_LOAD_KEYS 0x000D |
| 180 | struct mgmt_addr_info addr; | 109 | struct mgmt_cp_load_keys { |
| 181 | __u8 authenticated; | 110 | __u8 debug_keys; |
| 182 | __u8 master; | 111 | __le16 key_count; |
| 183 | __u8 enc_size; | 112 | struct mgmt_key_info keys[0]; |
| 184 | __le16 ediv; | ||
| 185 | __u8 rand[8]; | ||
| 186 | __u8 val[16]; | ||
| 187 | } __packed; | 113 | } __packed; |
| 188 | 114 | ||
| 189 | #define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013 | 115 | #define MGMT_OP_REMOVE_KEY 0x000E |
| 190 | struct mgmt_cp_load_long_term_keys { | 116 | struct mgmt_cp_remove_key { |
| 191 | __le16 key_count; | 117 | bdaddr_t bdaddr; |
| 192 | struct mgmt_ltk_info keys[0]; | 118 | __u8 disconnect; |
| 193 | } __packed; | 119 | } __packed; |
| 194 | #define MGMT_LOAD_LONG_TERM_KEYS_SIZE 2 | ||
| 195 | 120 | ||
| 196 | #define MGMT_OP_DISCONNECT 0x0014 | 121 | #define MGMT_OP_DISCONNECT 0x000F |
| 197 | struct mgmt_cp_disconnect { | 122 | struct mgmt_cp_disconnect { |
| 198 | struct mgmt_addr_info addr; | 123 | bdaddr_t bdaddr; |
| 199 | } __packed; | 124 | } __packed; |
| 200 | #define MGMT_DISCONNECT_SIZE MGMT_ADDR_INFO_SIZE | ||
| 201 | struct mgmt_rp_disconnect { | 125 | struct mgmt_rp_disconnect { |
| 202 | struct mgmt_addr_info addr; | 126 | bdaddr_t bdaddr; |
| 203 | } __packed; | 127 | } __packed; |
| 204 | 128 | ||
| 205 | #define MGMT_OP_GET_CONNECTIONS 0x0015 | 129 | #define MGMT_OP_GET_CONNECTIONS 0x0010 |
| 206 | #define MGMT_GET_CONNECTIONS_SIZE 0 | ||
| 207 | struct mgmt_rp_get_connections { | 130 | struct mgmt_rp_get_connections { |
| 208 | __le16 conn_count; | 131 | __le16 conn_count; |
| 209 | struct mgmt_addr_info addr[0]; | 132 | bdaddr_t conn[0]; |
| 210 | } __packed; | 133 | } __packed; |
| 211 | 134 | ||
| 212 | #define MGMT_OP_PIN_CODE_REPLY 0x0016 | 135 | #define MGMT_OP_PIN_CODE_REPLY 0x0011 |
| 213 | struct mgmt_cp_pin_code_reply { | 136 | struct mgmt_cp_pin_code_reply { |
| 214 | struct mgmt_addr_info addr; | 137 | bdaddr_t bdaddr; |
| 215 | __u8 pin_len; | 138 | __u8 pin_len; |
| 216 | __u8 pin_code[16]; | 139 | __u8 pin_code[16]; |
| 217 | } __packed; | 140 | } __packed; |
| 218 | #define MGMT_PIN_CODE_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 17) | ||
| 219 | struct mgmt_rp_pin_code_reply { | 141 | struct mgmt_rp_pin_code_reply { |
| 220 | struct mgmt_addr_info addr; | 142 | bdaddr_t bdaddr; |
| 143 | uint8_t status; | ||
| 221 | } __packed; | 144 | } __packed; |
| 222 | 145 | ||
| 223 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 | 146 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012 |
| 224 | struct mgmt_cp_pin_code_neg_reply { | 147 | struct mgmt_cp_pin_code_neg_reply { |
| 225 | struct mgmt_addr_info addr; | 148 | bdaddr_t bdaddr; |
| 226 | } __packed; | 149 | } __packed; |
| 227 | #define MGMT_PIN_CODE_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
| 228 | 150 | ||
| 229 | #define MGMT_OP_SET_IO_CAPABILITY 0x0018 | 151 | #define MGMT_OP_SET_IO_CAPABILITY 0x0013 |
| 230 | struct mgmt_cp_set_io_capability { | 152 | struct mgmt_cp_set_io_capability { |
| 231 | __u8 io_capability; | 153 | __u8 io_capability; |
| 232 | } __packed; | 154 | } __packed; |
| 233 | #define MGMT_SET_IO_CAPABILITY_SIZE 1 | ||
| 234 | 155 | ||
| 235 | #define MGMT_OP_PAIR_DEVICE 0x0019 | 156 | #define MGMT_OP_PAIR_DEVICE 0x0014 |
| 236 | struct mgmt_cp_pair_device { | 157 | struct mgmt_cp_pair_device { |
| 237 | struct mgmt_addr_info addr; | 158 | bdaddr_t bdaddr; |
| 238 | __u8 io_cap; | 159 | __u8 io_cap; |
| 239 | } __packed; | 160 | } __packed; |
| 240 | #define MGMT_PAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
| 241 | struct mgmt_rp_pair_device { | 161 | struct mgmt_rp_pair_device { |
| 242 | struct mgmt_addr_info addr; | 162 | bdaddr_t bdaddr; |
| 163 | __u8 status; | ||
| 243 | } __packed; | 164 | } __packed; |
| 244 | 165 | ||
| 245 | #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A | 166 | #define MGMT_OP_USER_CONFIRM_REPLY 0x0015 |
| 246 | #define MGMT_CANCEL_PAIR_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
| 247 | |||
| 248 | #define MGMT_OP_UNPAIR_DEVICE 0x001B | ||
| 249 | struct mgmt_cp_unpair_device { | ||
| 250 | struct mgmt_addr_info addr; | ||
| 251 | __u8 disconnect; | ||
| 252 | } __packed; | ||
| 253 | #define MGMT_UNPAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
| 254 | struct mgmt_rp_unpair_device { | ||
| 255 | struct mgmt_addr_info addr; | ||
| 256 | }; | ||
| 257 | |||
| 258 | #define MGMT_OP_USER_CONFIRM_REPLY 0x001C | ||
| 259 | struct mgmt_cp_user_confirm_reply { | 167 | struct mgmt_cp_user_confirm_reply { |
| 260 | struct mgmt_addr_info addr; | 168 | bdaddr_t bdaddr; |
| 261 | } __packed; | 169 | } __packed; |
| 262 | #define MGMT_USER_CONFIRM_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
| 263 | struct mgmt_rp_user_confirm_reply { | 170 | struct mgmt_rp_user_confirm_reply { |
| 264 | struct mgmt_addr_info addr; | 171 | bdaddr_t bdaddr; |
| 172 | __u8 status; | ||
| 265 | } __packed; | 173 | } __packed; |
| 266 | 174 | ||
| 267 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D | 175 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 |
| 268 | struct mgmt_cp_user_confirm_neg_reply { | ||
| 269 | struct mgmt_addr_info addr; | ||
| 270 | } __packed; | ||
| 271 | #define MGMT_USER_CONFIRM_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
| 272 | 176 | ||
| 273 | #define MGMT_OP_USER_PASSKEY_REPLY 0x001E | 177 | #define MGMT_OP_SET_LOCAL_NAME 0x0017 |
| 274 | struct mgmt_cp_user_passkey_reply { | 178 | struct mgmt_cp_set_local_name { |
| 275 | struct mgmt_addr_info addr; | 179 | __u8 name[MGMT_MAX_NAME_LENGTH]; |
| 276 | __le32 passkey; | ||
| 277 | } __packed; | ||
| 278 | #define MGMT_USER_PASSKEY_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 4) | ||
| 279 | struct mgmt_rp_user_passkey_reply { | ||
| 280 | struct mgmt_addr_info addr; | ||
| 281 | } __packed; | ||
| 282 | |||
| 283 | #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F | ||
| 284 | struct mgmt_cp_user_passkey_neg_reply { | ||
| 285 | struct mgmt_addr_info addr; | ||
| 286 | } __packed; | 180 | } __packed; |
| 287 | #define MGMT_USER_PASSKEY_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
| 288 | 181 | ||
| 289 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 | 182 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018 |
| 290 | #define MGMT_READ_LOCAL_OOB_DATA_SIZE 0 | ||
| 291 | struct mgmt_rp_read_local_oob_data { | 183 | struct mgmt_rp_read_local_oob_data { |
| 292 | __u8 hash[16]; | 184 | __u8 hash[16]; |
| 293 | __u8 randomizer[16]; | 185 | __u8 randomizer[16]; |
| 294 | } __packed; | 186 | } __packed; |
| 295 | 187 | ||
| 296 | #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 | 188 | #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019 |
| 297 | struct mgmt_cp_add_remote_oob_data { | 189 | struct mgmt_cp_add_remote_oob_data { |
| 298 | struct mgmt_addr_info addr; | 190 | bdaddr_t bdaddr; |
| 299 | __u8 hash[16]; | 191 | __u8 hash[16]; |
| 300 | __u8 randomizer[16]; | 192 | __u8 randomizer[16]; |
| 301 | } __packed; | 193 | } __packed; |
| 302 | #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) | ||
| 303 | 194 | ||
| 304 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 | 195 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A |
| 305 | struct mgmt_cp_remove_remote_oob_data { | 196 | struct mgmt_cp_remove_remote_oob_data { |
| 306 | struct mgmt_addr_info addr; | 197 | bdaddr_t bdaddr; |
| 307 | } __packed; | 198 | } __packed; |
| 308 | #define MGMT_REMOVE_REMOTE_OOB_DATA_SIZE MGMT_ADDR_INFO_SIZE | ||
| 309 | 199 | ||
| 310 | #define MGMT_OP_START_DISCOVERY 0x0023 | 200 | #define MGMT_OP_START_DISCOVERY 0x001B |
| 311 | struct mgmt_cp_start_discovery { | ||
| 312 | __u8 type; | ||
| 313 | } __packed; | ||
| 314 | #define MGMT_START_DISCOVERY_SIZE 1 | ||
| 315 | |||
| 316 | #define MGMT_OP_STOP_DISCOVERY 0x0024 | ||
| 317 | struct mgmt_cp_stop_discovery { | ||
| 318 | __u8 type; | ||
| 319 | } __packed; | ||
| 320 | #define MGMT_STOP_DISCOVERY_SIZE 1 | ||
| 321 | 201 | ||
| 322 | #define MGMT_OP_CONFIRM_NAME 0x0025 | 202 | #define MGMT_OP_STOP_DISCOVERY 0x001C |
| 323 | struct mgmt_cp_confirm_name { | ||
| 324 | struct mgmt_addr_info addr; | ||
| 325 | __u8 name_known; | ||
| 326 | } __packed; | ||
| 327 | #define MGMT_CONFIRM_NAME_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
| 328 | struct mgmt_rp_confirm_name { | ||
| 329 | struct mgmt_addr_info addr; | ||
| 330 | } __packed; | ||
| 331 | 203 | ||
| 332 | #define MGMT_OP_BLOCK_DEVICE 0x0026 | 204 | #define MGMT_OP_BLOCK_DEVICE 0x001D |
| 333 | struct mgmt_cp_block_device { | 205 | struct mgmt_cp_block_device { |
| 334 | struct mgmt_addr_info addr; | 206 | bdaddr_t bdaddr; |
| 335 | } __packed; | 207 | } __packed; |
| 336 | #define MGMT_BLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
| 337 | 208 | ||
| 338 | #define MGMT_OP_UNBLOCK_DEVICE 0x0027 | 209 | #define MGMT_OP_UNBLOCK_DEVICE 0x001E |
| 339 | struct mgmt_cp_unblock_device { | 210 | struct mgmt_cp_unblock_device { |
| 340 | struct mgmt_addr_info addr; | 211 | bdaddr_t bdaddr; |
| 341 | } __packed; | 212 | } __packed; |
| 342 | #define MGMT_UNBLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
| 343 | |||
| 344 | #define MGMT_OP_SET_DEVICE_ID 0x0028 | ||
| 345 | struct mgmt_cp_set_device_id { | ||
| 346 | __le16 source; | ||
| 347 | __le16 vendor; | ||
| 348 | __le16 product; | ||
| 349 | __le16 version; | ||
| 350 | } __packed; | ||
| 351 | #define MGMT_SET_DEVICE_ID_SIZE 8 | ||
| 352 | 213 | ||
| 353 | #define MGMT_EV_CMD_COMPLETE 0x0001 | 214 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
| 354 | struct mgmt_ev_cmd_complete { | 215 | struct mgmt_ev_cmd_complete { |
| 355 | __le16 opcode; | 216 | __le16 opcode; |
| 356 | __u8 status; | 217 | __u8 data[0]; |
| 357 | __u8 data[0]; | ||
| 358 | } __packed; | 218 | } __packed; |
| 359 | 219 | ||
| 360 | #define MGMT_EV_CMD_STATUS 0x0002 | 220 | #define MGMT_EV_CMD_STATUS 0x0002 |
| 361 | struct mgmt_ev_cmd_status { | 221 | struct mgmt_ev_cmd_status { |
| 362 | __le16 opcode; | 222 | __u8 status; |
| 363 | __u8 status; | 223 | __le16 opcode; |
| 364 | } __packed; | 224 | } __packed; |
| 365 | 225 | ||
| 366 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 | 226 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 |
| 367 | struct mgmt_ev_controller_error { | 227 | struct mgmt_ev_controller_error { |
| 368 | __u8 error_code; | 228 | __u8 error_code; |
| 369 | } __packed; | 229 | } __packed; |
| 370 | 230 | ||
| 371 | #define MGMT_EV_INDEX_ADDED 0x0004 | 231 | #define MGMT_EV_INDEX_ADDED 0x0004 |
| 372 | 232 | ||
| 373 | #define MGMT_EV_INDEX_REMOVED 0x0005 | 233 | #define MGMT_EV_INDEX_REMOVED 0x0005 |
| 374 | 234 | ||
| 375 | #define MGMT_EV_NEW_SETTINGS 0x0006 | 235 | #define MGMT_EV_POWERED 0x0006 |
| 376 | 236 | ||
| 377 | #define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007 | 237 | #define MGMT_EV_DISCOVERABLE 0x0007 |
| 378 | struct mgmt_ev_class_of_dev_changed { | ||
| 379 | __u8 dev_class[3]; | ||
| 380 | }; | ||
| 381 | 238 | ||
| 382 | #define MGMT_EV_LOCAL_NAME_CHANGED 0x0008 | 239 | #define MGMT_EV_CONNECTABLE 0x0008 |
| 383 | struct mgmt_ev_local_name_changed { | ||
| 384 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
| 385 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | ||
| 386 | } __packed; | ||
| 387 | 240 | ||
| 388 | #define MGMT_EV_NEW_LINK_KEY 0x0009 | 241 | #define MGMT_EV_PAIRABLE 0x0009 |
| 389 | struct mgmt_ev_new_link_key { | ||
| 390 | __u8 store_hint; | ||
| 391 | struct mgmt_link_key_info key; | ||
| 392 | } __packed; | ||
| 393 | 242 | ||
| 394 | #define MGMT_EV_NEW_LONG_TERM_KEY 0x000A | 243 | #define MGMT_EV_NEW_KEY 0x000A |
| 395 | struct mgmt_ev_new_long_term_key { | 244 | struct mgmt_ev_new_key { |
| 396 | __u8 store_hint; | 245 | __u8 store_hint; |
| 397 | struct mgmt_ltk_info key; | 246 | struct mgmt_key_info key; |
| 398 | } __packed; | 247 | } __packed; |
| 399 | 248 | ||
| 400 | #define MGMT_EV_DEVICE_CONNECTED 0x000B | 249 | #define MGMT_EV_CONNECTED 0x000B |
| 401 | struct mgmt_ev_device_connected { | 250 | struct mgmt_ev_connected { |
| 402 | struct mgmt_addr_info addr; | 251 | bdaddr_t bdaddr; |
| 403 | __le32 flags; | ||
| 404 | __le16 eir_len; | ||
| 405 | __u8 eir[0]; | ||
| 406 | } __packed; | 252 | } __packed; |
| 407 | 253 | ||
| 408 | #define MGMT_DEV_DISCONN_UNKNOWN 0x00 | 254 | #define MGMT_EV_DISCONNECTED 0x000C |
| 409 | #define MGMT_DEV_DISCONN_TIMEOUT 0x01 | 255 | struct mgmt_ev_disconnected { |
| 410 | #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 | 256 | bdaddr_t bdaddr; |
| 411 | #define MGMT_DEV_DISCONN_REMOTE 0x03 | ||
| 412 | |||
| 413 | #define MGMT_EV_DEVICE_DISCONNECTED 0x000C | ||
| 414 | struct mgmt_ev_device_disconnected { | ||
| 415 | struct mgmt_addr_info addr; | ||
| 416 | __u8 reason; | ||
| 417 | } __packed; | 257 | } __packed; |
| 418 | 258 | ||
| 419 | #define MGMT_EV_CONNECT_FAILED 0x000D | 259 | #define MGMT_EV_CONNECT_FAILED 0x000D |
| 420 | struct mgmt_ev_connect_failed { | 260 | struct mgmt_ev_connect_failed { |
| 421 | struct mgmt_addr_info addr; | 261 | bdaddr_t bdaddr; |
| 422 | __u8 status; | 262 | __u8 status; |
| 423 | } __packed; | 263 | } __packed; |
| 424 | 264 | ||
| 425 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E | 265 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E |
| 426 | struct mgmt_ev_pin_code_request { | 266 | struct mgmt_ev_pin_code_request { |
| 427 | struct mgmt_addr_info addr; | 267 | bdaddr_t bdaddr; |
| 428 | __u8 secure; | 268 | __u8 secure; |
| 429 | } __packed; | 269 | } __packed; |
| 430 | 270 | ||
| 431 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F | 271 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F |
| 432 | struct mgmt_ev_user_confirm_request { | 272 | struct mgmt_ev_user_confirm_request { |
| 433 | struct mgmt_addr_info addr; | 273 | bdaddr_t bdaddr; |
| 434 | __u8 confirm_hint; | 274 | __u8 confirm_hint; |
| 435 | __le32 value; | 275 | __le32 value; |
| 436 | } __packed; | ||
| 437 | |||
| 438 | #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 | ||
| 439 | struct mgmt_ev_user_passkey_request { | ||
| 440 | struct mgmt_addr_info addr; | ||
| 441 | } __packed; | 276 | } __packed; |
| 442 | 277 | ||
| 443 | #define MGMT_EV_AUTH_FAILED 0x0011 | 278 | #define MGMT_EV_AUTH_FAILED 0x0010 |
| 444 | struct mgmt_ev_auth_failed { | 279 | struct mgmt_ev_auth_failed { |
| 445 | struct mgmt_addr_info addr; | 280 | bdaddr_t bdaddr; |
| 446 | __u8 status; | 281 | __u8 status; |
| 447 | } __packed; | 282 | } __packed; |
| 448 | 283 | ||
| 449 | #define MGMT_DEV_FOUND_CONFIRM_NAME 0x01 | 284 | #define MGMT_EV_LOCAL_NAME_CHANGED 0x0011 |
| 450 | #define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02 | 285 | struct mgmt_ev_local_name_changed { |
| 286 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
| 287 | } __packed; | ||
| 451 | 288 | ||
| 452 | #define MGMT_EV_DEVICE_FOUND 0x0012 | 289 | #define MGMT_EV_DEVICE_FOUND 0x0012 |
| 453 | struct mgmt_ev_device_found { | 290 | struct mgmt_ev_device_found { |
| 454 | struct mgmt_addr_info addr; | 291 | bdaddr_t bdaddr; |
| 455 | __s8 rssi; | 292 | __u8 dev_class[3]; |
| 456 | __le32 flags; | 293 | __s8 rssi; |
| 457 | __le16 eir_len; | 294 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
| 458 | __u8 eir[0]; | ||
| 459 | } __packed; | 295 | } __packed; |
| 460 | 296 | ||
| 461 | #define MGMT_EV_DISCOVERING 0x0013 | 297 | #define MGMT_EV_REMOTE_NAME 0x0013 |
| 462 | struct mgmt_ev_discovering { | 298 | struct mgmt_ev_remote_name { |
| 463 | __u8 type; | 299 | bdaddr_t bdaddr; |
| 464 | __u8 discovering; | 300 | __u8 name[MGMT_MAX_NAME_LENGTH]; |
| 465 | } __packed; | 301 | } __packed; |
| 466 | 302 | ||
| 467 | #define MGMT_EV_DEVICE_BLOCKED 0x0014 | 303 | #define MGMT_EV_DISCOVERING 0x0014 |
| 468 | struct mgmt_ev_device_blocked { | ||
| 469 | struct mgmt_addr_info addr; | ||
| 470 | } __packed; | ||
| 471 | |||
| 472 | #define MGMT_EV_DEVICE_UNBLOCKED 0x0015 | ||
| 473 | struct mgmt_ev_device_unblocked { | ||
| 474 | struct mgmt_addr_info addr; | ||
| 475 | } __packed; | ||
| 476 | |||
| 477 | #define MGMT_EV_DEVICE_UNPAIRED 0x0016 | ||
| 478 | struct mgmt_ev_device_unpaired { | ||
| 479 | struct mgmt_addr_info addr; | ||
| 480 | } __packed; | ||
| 481 | |||
| 482 | #define MGMT_EV_PASSKEY_NOTIFY 0x0017 | ||
| 483 | struct mgmt_ev_passkey_notify { | ||
| 484 | struct mgmt_addr_info addr; | ||
| 485 | __le32 passkey; | ||
| 486 | __u8 entered; | ||
| 487 | } __packed; | ||
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index e2e3ecad100..d5eee2093b1 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h | |||
| @@ -211,7 +211,6 @@ struct rfcomm_dlc { | |||
| 211 | #define RFCOMM_AUTH_ACCEPT 6 | 211 | #define RFCOMM_AUTH_ACCEPT 6 |
| 212 | #define RFCOMM_AUTH_REJECT 7 | 212 | #define RFCOMM_AUTH_REJECT 7 |
| 213 | #define RFCOMM_DEFER_SETUP 8 | 213 | #define RFCOMM_DEFER_SETUP 8 |
| 214 | #define RFCOMM_ENC_DROP 9 | ||
| 215 | 214 | ||
| 216 | /* Scheduling flags and events */ | 215 | /* Scheduling flags and events */ |
| 217 | #define RFCOMM_SCHED_WAKEUP 31 | 216 | #define RFCOMM_SCHED_WAKEUP 31 |
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h index 1e35c43657c..6d1857ab8e5 100644 --- a/include/net/bluetooth/sco.h +++ b/include/net/bluetooth/sco.h | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | struct sockaddr_sco { | 37 | struct sockaddr_sco { |
| 38 | sa_family_t sco_family; | 38 | sa_family_t sco_family; |
| 39 | bdaddr_t sco_bdaddr; | 39 | bdaddr_t sco_bdaddr; |
| 40 | __u16 sco_pkt_type; | ||
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | /* SCO socket options */ | 43 | /* SCO socket options */ |
| @@ -72,7 +73,8 @@ struct sco_conn { | |||
| 72 | 73 | ||
| 73 | struct sco_pinfo { | 74 | struct sco_pinfo { |
| 74 | struct bt_sock bt; | 75 | struct bt_sock bt; |
| 75 | __u32 flags; | 76 | __u16 pkt_type; |
| 77 | |||
| 76 | struct sco_conn *conn; | 78 | struct sco_conn *conn; |
| 77 | }; | 79 | }; |
| 78 | 80 | ||
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h index f8ba07f3e5f..46c45761230 100644 --- a/include/net/bluetooth/smp.h +++ b/include/net/bluetooth/smp.h | |||
| @@ -77,7 +77,7 @@ struct smp_cmd_encrypt_info { | |||
| 77 | 77 | ||
| 78 | #define SMP_CMD_MASTER_IDENT 0x07 | 78 | #define SMP_CMD_MASTER_IDENT 0x07 |
| 79 | struct smp_cmd_master_ident { | 79 | struct smp_cmd_master_ident { |
| 80 | __le16 ediv; | 80 | __u16 ediv; |
| 81 | __u8 rand[8]; | 81 | __u8 rand[8]; |
| 82 | } __packed; | 82 | } __packed; |
| 83 | 83 | ||
| @@ -108,39 +108,16 @@ struct smp_cmd_security_req { | |||
| 108 | #define SMP_CONFIRM_FAILED 0x04 | 108 | #define SMP_CONFIRM_FAILED 0x04 |
| 109 | #define SMP_PAIRING_NOTSUPP 0x05 | 109 | #define SMP_PAIRING_NOTSUPP 0x05 |
| 110 | #define SMP_ENC_KEY_SIZE 0x06 | 110 | #define SMP_ENC_KEY_SIZE 0x06 |
| 111 | #define SMP_CMD_NOTSUPP 0x07 | 111 | #define SMP_CMD_NOTSUPP 0x07 |
| 112 | #define SMP_UNSPECIFIED 0x08 | 112 | #define SMP_UNSPECIFIED 0x08 |
| 113 | #define SMP_REPEATED_ATTEMPTS 0x09 | 113 | #define SMP_REPEATED_ATTEMPTS 0x09 |
| 114 | 114 | ||
| 115 | #define SMP_MIN_ENC_KEY_SIZE 7 | 115 | #define SMP_MIN_ENC_KEY_SIZE 7 |
| 116 | #define SMP_MAX_ENC_KEY_SIZE 16 | 116 | #define SMP_MAX_ENC_KEY_SIZE 16 |
| 117 | 117 | ||
| 118 | #define SMP_FLAG_TK_VALID 1 | ||
| 119 | #define SMP_FLAG_CFM_PENDING 2 | ||
| 120 | #define SMP_FLAG_MITM_AUTH 3 | ||
| 121 | |||
| 122 | struct smp_chan { | ||
| 123 | struct l2cap_conn *conn; | ||
| 124 | u8 preq[7]; /* SMP Pairing Request */ | ||
| 125 | u8 prsp[7]; /* SMP Pairing Response */ | ||
| 126 | u8 prnd[16]; /* SMP Pairing Random (local) */ | ||
| 127 | u8 rrnd[16]; /* SMP Pairing Random (remote) */ | ||
| 128 | u8 pcnf[16]; /* SMP Pairing Confirm */ | ||
| 129 | u8 tk[16]; /* SMP Temporary Key */ | ||
| 130 | u8 enc_key_size; | ||
| 131 | unsigned long smp_flags; | ||
| 132 | struct crypto_blkcipher *tfm; | ||
| 133 | struct work_struct confirm; | ||
| 134 | struct work_struct random; | ||
| 135 | |||
| 136 | }; | ||
| 137 | |||
| 138 | /* SMP Commands */ | 118 | /* SMP Commands */ |
| 139 | int smp_conn_security(struct hci_conn *hcon, __u8 sec_level); | 119 | int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level); |
| 140 | int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); | 120 | int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); |
| 141 | int smp_distribute_keys(struct l2cap_conn *conn, __u8 force); | 121 | int smp_distribute_keys(struct l2cap_conn *conn, __u8 force); |
| 142 | int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey); | ||
| 143 | |||
| 144 | void smp_chan_destroy(struct l2cap_conn *conn); | ||
| 145 | 122 | ||
| 146 | #endif /* __SMP_H */ | 123 | #endif /* __SMP_H */ |
