Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | BlueZ - Bluetooth protocol stack for Linux |
Ron Shaffer | 2d0a034 | 2010-05-28 11:53:46 -0400 | [diff] [blame] | 3 | Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
| 5 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> |
| 6 | |
| 7 | 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 |
| 9 | published by the Free Software Foundation; |
| 10 | |
| 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 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 |
Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 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 |
| 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | |
Ron Shaffer | 04fafe4 | 2010-05-28 11:53:45 -0400 | [diff] [blame] | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
| 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | SOFTWARE IS DISCLAIMED. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __HCI_CORE_H |
| 26 | #define __HCI_CORE_H |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <net/bluetooth/hci.h> |
Marcel Holtmann | f49daa8 | 2014-07-11 04:58:29 +0200 | [diff] [blame] | 29 | #include <net/bluetooth/hci_sock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Luiz Augusto von Dentz | 5e59b79 | 2011-11-01 10:58:57 +0200 | [diff] [blame] | 31 | /* HCI priority */ |
| 32 | #define HCI_PRIO_MAX 7 |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* HCI Core structures */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | struct inquiry_data { |
| 36 | bdaddr_t bdaddr; |
| 37 | __u8 pscan_rep_mode; |
| 38 | __u8 pscan_period_mode; |
| 39 | __u8 pscan_mode; |
| 40 | __u8 dev_class[3]; |
Marcel Holtmann | 1ebb925 | 2005-11-08 09:57:21 -0800 | [diff] [blame] | 41 | __le16 clock_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | __s8 rssi; |
Marcel Holtmann | 41a9621 | 2008-07-14 20:13:48 +0200 | [diff] [blame] | 43 | __u8 ssp_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct inquiry_entry { |
Johan Hedberg | 561aafb | 2012-01-04 13:31:59 +0200 | [diff] [blame] | 47 | struct list_head all; /* inq_cache.all */ |
| 48 | struct list_head list; /* unknown or resolve */ |
| 49 | enum { |
| 50 | NAME_NOT_KNOWN, |
| 51 | NAME_NEEDED, |
| 52 | NAME_PENDING, |
| 53 | NAME_KNOWN, |
| 54 | } name_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | __u32 timestamp; |
| 56 | struct inquiry_data data; |
| 57 | }; |
| 58 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 59 | struct discovery_state { |
Gustavo F. Padovan | f64b993 | 2012-03-06 23:48:33 -0300 | [diff] [blame] | 60 | int type; |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 61 | enum { |
| 62 | DISCOVERY_STOPPED, |
| 63 | DISCOVERY_STARTING, |
Andre Guedes | 343f935 | 2012-02-17 20:39:37 -0300 | [diff] [blame] | 64 | DISCOVERY_FINDING, |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 65 | DISCOVERY_RESOLVING, |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 66 | DISCOVERY_STOPPING, |
| 67 | } state; |
Gustavo Padovan | c3c7ea6 | 2012-05-23 04:04:20 -0300 | [diff] [blame] | 68 | struct list_head all; /* All devices found during inquiry */ |
Gustavo F. Padovan | f64b993 | 2012-03-06 23:48:33 -0300 | [diff] [blame] | 69 | struct list_head unknown; /* Name state not known */ |
| 70 | struct list_head resolve; /* Name needs to be resolved */ |
| 71 | __u32 timestamp; |
Johan Hedberg | b9a6328 | 2014-03-25 10:51:52 +0200 | [diff] [blame] | 72 | bdaddr_t last_adv_addr; |
| 73 | u8 last_adv_addr_type; |
Johan Hedberg | ff5cd29 | 2014-03-25 14:40:52 +0200 | [diff] [blame] | 74 | s8 last_adv_rssi; |
Marcel Holtmann | c70a7e4 | 2014-07-01 14:11:21 +0200 | [diff] [blame] | 75 | u32 last_adv_flags; |
Johan Hedberg | b9a6328 | 2014-03-25 10:51:52 +0200 | [diff] [blame] | 76 | u8 last_adv_data[HCI_MAX_AD_LENGTH]; |
| 77 | u8 last_adv_data_len; |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 78 | bool report_invalid_rssi; |
Jakub Pawlowski | 37eab04 | 2014-12-05 10:55:55 +0100 | [diff] [blame] | 79 | s8 rssi; |
| 80 | u16 uuid_count; |
| 81 | u8 (*uuids)[16]; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 82 | unsigned long scan_start; |
| 83 | unsigned long scan_duration; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | struct hci_conn_hash { |
| 87 | struct list_head list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | unsigned int acl_num; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 89 | unsigned int amp_num; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | unsigned int sco_num; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 91 | unsigned int le_num; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 92 | unsigned int le_num_slave; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
Johan Hedberg | f035856 | 2010-05-18 13:20:32 +0200 | [diff] [blame] | 95 | struct bdaddr_list { |
| 96 | struct list_head list; |
| 97 | bdaddr_t bdaddr; |
Marcel Holtmann | b9ee0a7 | 2013-10-17 17:24:13 -0700 | [diff] [blame] | 98 | u8 bdaddr_type; |
Johan Hedberg | f035856 | 2010-05-18 13:20:32 +0200 | [diff] [blame] | 99 | }; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 100 | |
| 101 | struct bt_uuid { |
| 102 | struct list_head list; |
| 103 | u8 uuid[16]; |
Johan Hedberg | 83be8ec | 2013-01-27 00:31:29 +0200 | [diff] [blame] | 104 | u8 size; |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 105 | u8 svc_hint; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 106 | }; |
| 107 | |
Marcel Holtmann | 7ee4ea3 | 2014-03-09 12:19:17 -0700 | [diff] [blame] | 108 | struct smp_csrk { |
| 109 | bdaddr_t bdaddr; |
| 110 | u8 bdaddr_type; |
| 111 | u8 master; |
| 112 | u8 val[16]; |
| 113 | }; |
| 114 | |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 115 | struct smp_ltk { |
| 116 | struct list_head list; |
Johan Hedberg | 970d0f1 | 2014-11-13 14:37:47 +0200 | [diff] [blame] | 117 | struct rcu_head rcu; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 118 | bdaddr_t bdaddr; |
| 119 | u8 bdaddr_type; |
| 120 | u8 authenticated; |
| 121 | u8 type; |
| 122 | u8 enc_size; |
| 123 | __le16 ediv; |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 124 | __le64 rand; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 125 | u8 val[16]; |
Marcel Holtmann | 03c515d | 2014-01-31 18:42:18 -0800 | [diff] [blame] | 126 | }; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 127 | |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 128 | struct smp_irk { |
| 129 | struct list_head list; |
Johan Hedberg | adae20c | 2014-11-13 14:37:48 +0200 | [diff] [blame] | 130 | struct rcu_head rcu; |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 131 | bdaddr_t rpa; |
| 132 | bdaddr_t bdaddr; |
| 133 | u8 addr_type; |
| 134 | u8 val[16]; |
| 135 | }; |
| 136 | |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 137 | struct link_key { |
| 138 | struct list_head list; |
Johan Hedberg | 0378b59 | 2014-11-19 15:22:22 +0200 | [diff] [blame] | 139 | struct rcu_head rcu; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 140 | bdaddr_t bdaddr; |
| 141 | u8 type; |
Andrei Emeltchenko | 9b3b446 | 2012-05-23 11:31:20 +0300 | [diff] [blame] | 142 | u8 val[HCI_LINK_KEY_SIZE]; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 143 | u8 pin_len; |
| 144 | }; |
| 145 | |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 146 | struct oob_data { |
| 147 | struct list_head list; |
| 148 | bdaddr_t bdaddr; |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 149 | u8 bdaddr_type; |
Marcel Holtmann | f7697b1 | 2015-01-30 23:20:55 -0800 | [diff] [blame] | 150 | u8 present; |
Marcel Holtmann | 519ca9d | 2014-01-10 02:07:28 -0800 | [diff] [blame] | 151 | u8 hash192[16]; |
Johan Hedberg | 38da170 | 2014-11-17 20:52:20 +0200 | [diff] [blame] | 152 | u8 rand192[16]; |
Marcel Holtmann | 519ca9d | 2014-01-10 02:07:28 -0800 | [diff] [blame] | 153 | u8 hash256[16]; |
Johan Hedberg | 38da170 | 2014-11-17 20:52:20 +0200 | [diff] [blame] | 154 | u8 rand256[16]; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
Johan Hedberg | 490c5ba | 2012-02-22 19:19:09 +0200 | [diff] [blame] | 157 | #define HCI_MAX_SHORT_NAME_LENGTH 10 |
| 158 | |
Johan Hedberg | d6bfd59 | 2014-02-23 19:42:20 +0200 | [diff] [blame] | 159 | /* Default LE RPA expiry time, 15 minutes */ |
| 160 | #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60) |
| 161 | |
Andrzej Kaczmarek | 31ad169 | 2014-05-14 13:43:02 +0200 | [diff] [blame] | 162 | /* Default min/max age of connection information (1s/3s) */ |
| 163 | #define DEFAULT_CONN_INFO_MIN_AGE 1000 |
| 164 | #define DEFAULT_CONN_INFO_MAX_AGE 3000 |
| 165 | |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 166 | struct amp_assoc { |
| 167 | __u16 len; |
| 168 | __u16 offset; |
Andrei Emeltchenko | 93c284e | 2012-09-27 17:26:20 +0300 | [diff] [blame] | 169 | __u16 rem_len; |
| 170 | __u16 len_so_far; |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 171 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; |
| 172 | }; |
| 173 | |
Johan Hedberg | d2c5d77 | 2013-04-17 15:00:52 +0300 | [diff] [blame] | 174 | #define HCI_MAX_PAGES 3 |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 175 | |
Suraj Sumangala | cd4c539 | 2010-07-14 13:02:16 +0530 | [diff] [blame] | 176 | #define NUM_REASSEMBLY 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | struct hci_dev { |
| 178 | struct list_head list; |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 179 | struct mutex lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
| 181 | char name[8]; |
| 182 | unsigned long flags; |
| 183 | __u16 id; |
Marcel Holtmann | c13854c | 2010-02-08 15:27:07 +0100 | [diff] [blame] | 184 | __u8 bus; |
Marcel Holtmann | 943da25 | 2010-02-13 02:28:41 +0100 | [diff] [blame] | 185 | __u8 dev_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | bdaddr_t bdaddr; |
Marcel Holtmann | e30d3f5 | 2014-07-05 10:48:03 +0200 | [diff] [blame] | 187 | bdaddr_t setup_addr; |
Marcel Holtmann | 24c457e | 2014-07-02 00:53:47 +0200 | [diff] [blame] | 188 | bdaddr_t public_addr; |
Marcel Holtmann | 7a4cd51 | 2014-02-19 19:52:13 -0800 | [diff] [blame] | 189 | bdaddr_t random_addr; |
Marcel Holtmann | d13eafc | 2013-10-02 04:41:30 -0700 | [diff] [blame] | 190 | bdaddr_t static_addr; |
Johan Hedberg | 56ed2cb | 2014-02-27 14:05:40 +0200 | [diff] [blame] | 191 | __u8 adv_addr_type; |
Johan Hedberg | 1f6c637 | 2011-03-16 14:29:35 +0200 | [diff] [blame] | 192 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
Johan Hedberg | 490c5ba | 2012-02-22 19:19:09 +0200 | [diff] [blame] | 193 | __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; |
Johan Hedberg | 80a1e1d | 2011-03-28 14:07:23 +0300 | [diff] [blame] | 194 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 195 | __u8 dev_class[3]; |
Johan Hedberg | 1aff6f0 | 2011-01-13 21:56:52 +0200 | [diff] [blame] | 196 | __u8 major_class; |
| 197 | __u8 minor_class; |
Johan Hedberg | d2c5d77 | 2013-04-17 15:00:52 +0300 | [diff] [blame] | 198 | __u8 max_page; |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 199 | __u8 features[HCI_MAX_PAGES][8]; |
Johan Hedberg | 60e7732 | 2013-01-22 14:01:59 +0200 | [diff] [blame] | 200 | __u8 le_features[8]; |
Johan Hedberg | cf1d081 | 2013-01-22 14:02:00 +0200 | [diff] [blame] | 201 | __u8 le_white_list_size; |
Johan Hedberg | 9b008c0 | 2013-01-22 14:02:01 +0200 | [diff] [blame] | 202 | __u8 le_states[8]; |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 203 | __u8 commands[64]; |
Marcel Holtmann | 1143e5a | 2006-09-23 09:57:20 +0200 | [diff] [blame] | 204 | __u8 hci_ver; |
| 205 | __u16 hci_rev; |
Johan Hedberg | d5859e2 | 2011-01-25 01:19:58 +0200 | [diff] [blame] | 206 | __u8 lmp_ver; |
Marcel Holtmann | 1143e5a | 2006-09-23 09:57:20 +0200 | [diff] [blame] | 207 | __u16 manufacturer; |
Andrei Emeltchenko | 7d69230 | 2012-03-09 11:46:49 +0200 | [diff] [blame] | 208 | __u16 lmp_subver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | __u16 voice_setting; |
Marcel Holtmann | b4cb9fb | 2013-10-14 13:56:16 -0700 | [diff] [blame] | 210 | __u8 num_iac; |
Marcel Holtmann | c2f0f97 | 2015-01-12 09:21:25 -0800 | [diff] [blame] | 211 | __u8 stored_max_keys; |
| 212 | __u8 stored_num_keys; |
Johan Hedberg | 17fa4b9 | 2011-01-25 13:28:33 +0200 | [diff] [blame] | 213 | __u8 io_capability; |
Marcel Holtmann | 91c4e9b | 2012-03-11 19:27:21 -0700 | [diff] [blame] | 214 | __s8 inq_tx_power; |
Johan Hedberg | f332ec6 | 2013-03-15 17:07:11 -0500 | [diff] [blame] | 215 | __u16 page_scan_interval; |
| 216 | __u16 page_scan_window; |
| 217 | __u8 page_scan_type; |
Marcel Holtmann | 3f959d4 | 2014-02-20 11:55:56 -0800 | [diff] [blame] | 218 | __u8 le_adv_channel_map; |
Georg Lukas | 628531c | 2014-07-26 13:59:57 +0200 | [diff] [blame] | 219 | __u16 le_adv_min_interval; |
| 220 | __u16 le_adv_max_interval; |
Marcel Holtmann | 533553f | 2014-03-21 12:18:10 -0700 | [diff] [blame] | 221 | __u8 le_scan_type; |
Marcel Holtmann | bef6473 | 2013-10-11 08:23:19 -0700 | [diff] [blame] | 222 | __u16 le_scan_interval; |
| 223 | __u16 le_scan_window; |
Marcel Holtmann | 4e70c7e | 2013-10-19 07:09:13 -0700 | [diff] [blame] | 224 | __u16 le_conn_min_interval; |
| 225 | __u16 le_conn_max_interval; |
Marcel Holtmann | 04fb7d9 | 2014-06-30 12:34:36 +0200 | [diff] [blame] | 226 | __u16 le_conn_latency; |
| 227 | __u16 le_supv_timeout; |
Marcel Holtmann | a8e1bfa | 2014-12-20 16:28:40 +0100 | [diff] [blame] | 228 | __u16 le_def_tx_len; |
| 229 | __u16 le_def_tx_time; |
| 230 | __u16 le_max_tx_len; |
| 231 | __u16 le_max_tx_time; |
| 232 | __u16 le_max_rx_len; |
| 233 | __u16 le_max_rx_time; |
Lukasz Rymanowski | b9a7a61 | 2014-03-27 20:55:20 +0100 | [diff] [blame] | 234 | __u16 discov_interleaved_timeout; |
Andrzej Kaczmarek | 31ad169 | 2014-05-14 13:43:02 +0200 | [diff] [blame] | 235 | __u16 conn_info_min_age; |
| 236 | __u16 conn_info_max_age; |
Marcel Holtmann | 06f5b77 | 2013-10-19 07:09:11 -0700 | [diff] [blame] | 237 | __u8 ssp_debug_mode; |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 238 | __u8 hw_error_code; |
Johan Hedberg | 33f3572 | 2014-06-28 17:54:06 +0300 | [diff] [blame] | 239 | __u32 clock; |
Johan Hedberg | f332ec6 | 2013-03-15 17:07:11 -0500 | [diff] [blame] | 240 | |
Marcel Holtmann | 2b9be13 | 2012-03-11 19:32:12 -0700 | [diff] [blame] | 241 | __u16 devid_source; |
| 242 | __u16 devid_vendor; |
| 243 | __u16 devid_product; |
| 244 | __u16 devid_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
| 246 | __u16 pkt_type; |
Marcel Holtmann | 5b7f990 | 2007-07-11 09:51:55 +0200 | [diff] [blame] | 247 | __u16 esco_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | __u16 link_policy; |
| 249 | __u16 link_mode; |
| 250 | |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 251 | __u32 idle_timeout; |
| 252 | __u16 sniff_min_interval; |
| 253 | __u16 sniff_max_interval; |
| 254 | |
Andrei Emeltchenko | 928abaa | 2011-10-12 10:53:57 +0300 | [diff] [blame] | 255 | __u8 amp_status; |
| 256 | __u32 amp_total_bw; |
| 257 | __u32 amp_max_bw; |
| 258 | __u32 amp_min_latency; |
| 259 | __u32 amp_max_pdu; |
| 260 | __u8 amp_type; |
| 261 | __u16 amp_pal_cap; |
| 262 | __u16 amp_assoc_size; |
| 263 | __u32 amp_max_flush_to; |
| 264 | __u32 amp_be_flush_to; |
| 265 | |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 266 | struct amp_assoc loc_assoc; |
| 267 | |
Andrei Emeltchenko | 1e89cff | 2011-11-24 14:52:02 +0200 | [diff] [blame] | 268 | __u8 flow_ctl_mode; |
| 269 | |
Johan Hedberg | 9f61656 | 2011-04-28 11:28:54 -0700 | [diff] [blame] | 270 | unsigned int auto_accept_delay; |
| 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | unsigned long quirks; |
| 273 | |
| 274 | atomic_t cmd_cnt; |
| 275 | unsigned int acl_cnt; |
| 276 | unsigned int sco_cnt; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 277 | unsigned int le_cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
| 279 | unsigned int acl_mtu; |
| 280 | unsigned int sco_mtu; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 281 | unsigned int le_mtu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | unsigned int acl_pkts; |
| 283 | unsigned int sco_pkts; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 284 | unsigned int le_pkts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Andrei Emeltchenko | 350ee4c | 2011-12-07 15:56:51 +0200 | [diff] [blame] | 286 | __u16 block_len; |
| 287 | __u16 block_mtu; |
| 288 | __u16 num_blocks; |
| 289 | __u16 block_cnt; |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | unsigned long acl_last_tx; |
| 292 | unsigned long sco_last_tx; |
Ville Tervo | 6ed58ec | 2011-02-10 22:38:48 -0300 | [diff] [blame] | 293 | unsigned long le_last_tx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Marcel Holtmann | f48fd9c | 2010-03-20 15:20:04 +0100 | [diff] [blame] | 295 | struct workqueue_struct *workqueue; |
Johan Hedberg | 6ead1bb | 2013-01-14 22:33:50 +0200 | [diff] [blame] | 296 | struct workqueue_struct *req_workqueue; |
Marcel Holtmann | f48fd9c | 2010-03-20 15:20:04 +0100 | [diff] [blame] | 297 | |
Johan Hedberg | ab81cbf | 2010-12-15 13:53:18 +0200 | [diff] [blame] | 298 | struct work_struct power_on; |
Johan Hedberg | 3243553 | 2011-11-07 22:16:04 +0200 | [diff] [blame] | 299 | struct delayed_work power_off; |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 300 | struct work_struct error_reset; |
Johan Hedberg | ab81cbf | 2010-12-15 13:53:18 +0200 | [diff] [blame] | 301 | |
Johan Hedberg | 16ab91a | 2011-11-07 22:16:02 +0200 | [diff] [blame] | 302 | __u16 discov_timeout; |
| 303 | struct delayed_work discov_off; |
| 304 | |
Johan Hedberg | 7d78525 | 2011-12-15 00:47:39 +0200 | [diff] [blame] | 305 | struct delayed_work service_cache; |
| 306 | |
Marcel Holtmann | 65cc2b4 | 2014-06-16 12:30:56 +0200 | [diff] [blame] | 307 | struct delayed_work cmd_timer; |
Marcel Holtmann | b78752c | 2010-08-08 23:06:53 -0400 | [diff] [blame] | 308 | |
| 309 | struct work_struct rx_work; |
Gustavo F. Padovan | c347b76 | 2011-12-14 23:53:47 -0200 | [diff] [blame] | 310 | struct work_struct cmd_work; |
Gustavo F. Padovan | 3eff45e | 2011-12-15 00:50:02 -0200 | [diff] [blame] | 311 | struct work_struct tx_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | struct sk_buff_head rx_q; |
| 314 | struct sk_buff_head raw_q; |
| 315 | struct sk_buff_head cmd_q; |
| 316 | |
Johan Hedberg | b6ddb63 | 2013-04-02 13:34:31 +0300 | [diff] [blame] | 317 | struct sk_buff *recv_evt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | struct sk_buff *sent_cmd; |
Suraj Sumangala | cd4c539 | 2010-07-14 13:02:16 +0530 | [diff] [blame] | 319 | struct sk_buff *reassembly[NUM_REASSEMBLY]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | |
Thomas Gleixner | a6a67ef | 2009-07-26 08:18:19 +0000 | [diff] [blame] | 321 | struct mutex req_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | wait_queue_head_t req_wait_q; |
| 323 | __u32 req_status; |
| 324 | __u32 req_result; |
Johan Hedberg | a5040ef | 2011-01-10 13:28:59 +0200 | [diff] [blame] | 325 | |
Johan Hedberg | 70db83c | 2014-08-08 09:37:16 +0300 | [diff] [blame] | 326 | void *smp_data; |
Johan Hedberg | ef8efe4 | 2014-08-13 15:12:32 +0300 | [diff] [blame] | 327 | void *smp_bredr_data; |
Johan Hedberg | 2e58ef3 | 2011-11-08 20:40:15 +0200 | [diff] [blame] | 328 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 329 | struct discovery_state discovery; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | struct hci_conn_hash conn_hash; |
Andre Guedes | 5c136e9 | 2014-01-30 18:22:05 -0300 | [diff] [blame] | 331 | |
| 332 | struct list_head mgmt_pending; |
David Miller | ea4bd8b | 2010-07-30 21:54:49 -0700 | [diff] [blame] | 333 | struct list_head blacklist; |
Johan Hedberg | 6659358 | 2014-07-09 12:59:14 +0300 | [diff] [blame] | 334 | struct list_head whitelist; |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 335 | struct list_head uuids; |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 336 | struct list_head link_keys; |
Vinicius Costa Gomes | b899efa | 2012-02-02 21:08:00 -0300 | [diff] [blame] | 337 | struct list_head long_term_keys; |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 338 | struct list_head identity_resolving_keys; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 339 | struct list_head remote_oob_data; |
Marcel Holtmann | d2ab0ac | 2014-02-27 20:37:30 -0800 | [diff] [blame] | 340 | struct list_head le_white_list; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 341 | struct list_head le_conn_params; |
Andre Guedes | 77a77a3 | 2014-02-26 20:21:46 -0300 | [diff] [blame] | 342 | struct list_head pend_le_conns; |
Johan Hedberg | 66f8455 | 2014-07-04 12:37:18 +0300 | [diff] [blame] | 343 | struct list_head pend_le_reports; |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | struct hci_dev_stats stat; |
| 346 | |
Andrei Emeltchenko | 70f23020 | 2010-12-01 16:58:25 +0200 | [diff] [blame] | 347 | atomic_t promisc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Marcel Holtmann | ca325f6 | 2010-02-08 16:22:31 +0100 | [diff] [blame] | 349 | struct dentry *debugfs; |
| 350 | |
Marcel Holtmann | a91f2e3 | 2006-07-03 10:02:41 +0200 | [diff] [blame] | 351 | struct device dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
Marcel Holtmann | 611b30f | 2009-06-08 14:41:38 +0200 | [diff] [blame] | 353 | struct rfkill *rfkill; |
| 354 | |
Marcel Holtmann | 111902f | 2014-06-21 04:53:17 +0200 | [diff] [blame] | 355 | unsigned long dbg_flags; |
Andre Guedes | d23264a | 2011-11-25 20:53:38 -0300 | [diff] [blame] | 356 | unsigned long dev_flags; |
| 357 | |
Andre Guedes | 7ba8b4b | 2012-02-03 17:47:59 -0300 | [diff] [blame] | 358 | struct delayed_work le_scan_disable; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 359 | struct delayed_work le_scan_restart; |
Andre Guedes | 7ba8b4b | 2012-02-03 17:47:59 -0300 | [diff] [blame] | 360 | |
Johan Hedberg | 8fa1909 | 2012-10-19 20:57:49 +0300 | [diff] [blame] | 361 | __s8 adv_tx_power; |
Johan Hedberg | 3f0f524 | 2012-11-08 01:23:00 +0100 | [diff] [blame] | 362 | __u8 adv_data[HCI_MAX_AD_LENGTH]; |
| 363 | __u8 adv_data_len; |
Marcel Holtmann | f8e808b | 2013-10-16 00:16:47 -0700 | [diff] [blame] | 364 | __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; |
| 365 | __u8 scan_rsp_data_len; |
Johan Hedberg | 8fa1909 | 2012-10-19 20:57:49 +0300 | [diff] [blame] | 366 | |
Johan Hedberg | 863efaf | 2014-02-22 19:06:32 +0200 | [diff] [blame] | 367 | __u8 irk[16]; |
Johan Hedberg | d6bfd59 | 2014-02-23 19:42:20 +0200 | [diff] [blame] | 368 | __u32 rpa_timeout; |
| 369 | struct delayed_work rpa_expired; |
Marcel Holtmann | 2b5224d | 2014-02-23 20:39:22 -0800 | [diff] [blame] | 370 | bdaddr_t rpa; |
Johan Hedberg | 863efaf | 2014-02-22 19:06:32 +0200 | [diff] [blame] | 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | int (*open)(struct hci_dev *hdev); |
| 373 | int (*close)(struct hci_dev *hdev); |
| 374 | int (*flush)(struct hci_dev *hdev); |
Marcel Holtmann | f41c70c | 2012-11-12 14:02:14 +0900 | [diff] [blame] | 375 | int (*setup)(struct hci_dev *hdev); |
Marcel Holtmann | 7bd8f09 | 2013-10-11 06:19:18 -0700 | [diff] [blame] | 376 | int (*send)(struct hci_dev *hdev, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | void (*notify)(struct hci_dev *hdev, unsigned int evt); |
Marcel Holtmann | c7741d1 | 2015-01-28 11:09:55 -0800 | [diff] [blame] | 378 | void (*hw_error)(struct hci_dev *hdev, u8 code); |
Marcel Holtmann | 24c457e | 2014-07-02 00:53:47 +0200 | [diff] [blame] | 379 | int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | }; |
| 381 | |
Andrei Emeltchenko | 53502d6 | 2012-10-10 17:38:27 +0300 | [diff] [blame] | 382 | #define HCI_PHY_HANDLE(handle) (handle & 0xff) |
| 383 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | struct hci_conn { |
| 385 | struct list_head list; |
| 386 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 387 | atomic_t refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 389 | bdaddr_t dst; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 390 | __u8 dst_type; |
Marcel Holtmann | 662e882 | 2013-10-13 05:23:59 -0700 | [diff] [blame] | 391 | bdaddr_t src; |
Marcel Holtmann | e7c4096 | 2013-10-13 03:57:39 -0700 | [diff] [blame] | 392 | __u8 src_type; |
Johan Hedberg | cb1d68f | 2014-02-28 12:54:16 +0200 | [diff] [blame] | 393 | bdaddr_t init_addr; |
| 394 | __u8 init_addr_type; |
| 395 | bdaddr_t resp_addr; |
| 396 | __u8 resp_addr_type; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 397 | __u16 handle; |
| 398 | __u16 state; |
| 399 | __u8 mode; |
| 400 | __u8 type; |
Johan Hedberg | 40bef30 | 2014-07-16 11:42:27 +0300 | [diff] [blame] | 401 | __u8 role; |
Johan Hedberg | a0c808b | 2012-01-16 09:49:58 +0200 | [diff] [blame] | 402 | bool out; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 403 | __u8 attempt; |
| 404 | __u8 dev_class[3]; |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 405 | __u8 features[HCI_MAX_PAGES][8]; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 406 | __u16 pkt_type; |
| 407 | __u16 link_policy; |
Waldemar Rymarkiewicz | 13d3931 | 2011-04-28 12:07:55 +0200 | [diff] [blame] | 408 | __u8 key_type; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 409 | __u8 auth_type; |
| 410 | __u8 sec_level; |
| 411 | __u8 pending_sec_level; |
| 412 | __u8 pin_length; |
Vinicius Costa Gomes | 726b4ff | 2011-07-08 18:31:45 -0300 | [diff] [blame] | 413 | __u8 enc_key_size; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 414 | __u8 io_capability; |
Johan Hedberg | 92a2525 | 2012-09-06 18:39:26 +0300 | [diff] [blame] | 415 | __u32 passkey_notify; |
| 416 | __u8 passkey_entered; |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 417 | __u16 disc_timeout; |
Johan Hedberg | 09ae260 | 2014-07-06 13:41:15 +0300 | [diff] [blame] | 418 | __u16 conn_timeout; |
Frédéric Dalleau | 10c62dd | 2013-08-19 14:23:59 +0200 | [diff] [blame] | 419 | __u16 setting; |
Andre Guedes | 1e406ee | 2014-01-30 18:22:04 -0300 | [diff] [blame] | 420 | __u16 le_conn_min_interval; |
| 421 | __u16 le_conn_max_interval; |
Marcel Holtmann | e04fde6 | 2014-06-23 11:40:04 +0200 | [diff] [blame] | 422 | __u16 le_conn_interval; |
| 423 | __u16 le_conn_latency; |
| 424 | __u16 le_supv_timeout; |
Alfonso Acosta | fd45ada | 2014-10-07 08:44:11 +0000 | [diff] [blame] | 425 | __u8 le_adv_data[HCI_MAX_AD_LENGTH]; |
| 426 | __u8 le_adv_data_len; |
Andrzej Kaczmarek | 5ae76a9 | 2014-05-08 15:32:08 +0200 | [diff] [blame] | 427 | __s8 rssi; |
Andrzej Kaczmarek | 5a134fa | 2014-05-09 21:35:28 +0200 | [diff] [blame] | 428 | __s8 tx_power; |
Andrzej Kaczmarek | d0455ed | 2014-05-14 13:43:05 +0200 | [diff] [blame] | 429 | __s8 max_tx_power; |
Johan Hedberg | 51a8efd | 2012-01-16 06:10:31 +0200 | [diff] [blame] | 430 | unsigned long flags; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 431 | |
Johan Hedberg | 33f3572 | 2014-06-28 17:54:06 +0300 | [diff] [blame] | 432 | __u32 clock; |
| 433 | __u16 clock_accuracy; |
| 434 | |
Andrzej Kaczmarek | dd98380 | 2014-05-14 13:43:03 +0200 | [diff] [blame] | 435 | unsigned long conn_info_timestamp; |
| 436 | |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 437 | __u8 remote_cap; |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 438 | __u8 remote_auth; |
Andrei Emeltchenko | 3161ae1 | 2012-09-27 17:26:11 +0300 | [diff] [blame] | 439 | __u8 remote_id; |
Johan Hedberg | 03b555e | 2011-01-04 15:40:05 +0200 | [diff] [blame] | 440 | |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 441 | unsigned int sent; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 442 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | struct sk_buff_head data_q; |
Gustavo F. Padovan | 2c33c06 | 2011-12-14 13:02:51 -0200 | [diff] [blame] | 444 | struct list_head chan_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Gustavo F. Padovan | 19c40e3 | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 446 | struct delayed_work disc_work; |
Johan Hedberg | 7bc18d9 | 2013-10-16 18:11:39 +0300 | [diff] [blame] | 447 | struct delayed_work auto_accept_work; |
Johan Hedberg | a74a84f | 2013-10-16 18:11:40 +0300 | [diff] [blame] | 448 | struct delayed_work idle_work; |
Johan Hedberg | 9489eca | 2014-02-28 17:45:46 +0200 | [diff] [blame] | 449 | struct delayed_work le_conn_timeout; |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 450 | |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 451 | struct device dev; |
Marcel Holtmann | 23b9ceb | 2014-12-20 17:13:41 +0100 | [diff] [blame] | 452 | struct dentry *debugfs; |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | struct hci_dev *hdev; |
| 455 | void *l2cap_data; |
| 456 | void *sco_data; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 457 | struct amp_mgr *amp_mgr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
| 459 | struct hci_conn *link; |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 460 | |
| 461 | void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); |
| 462 | void (*security_cfm_cb) (struct hci_conn *conn, u8 status); |
| 463 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | }; |
| 465 | |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 466 | struct hci_chan { |
| 467 | struct list_head list; |
Andrei Emeltchenko | 42c4e53 | 2012-10-10 17:38:28 +0300 | [diff] [blame] | 468 | __u16 handle; |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 469 | struct hci_conn *conn; |
| 470 | struct sk_buff_head data_q; |
| 471 | unsigned int sent; |
Mat Martineau | 168df8e | 2012-10-23 15:24:13 -0700 | [diff] [blame] | 472 | __u8 state; |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 473 | }; |
| 474 | |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 475 | struct hci_conn_params { |
| 476 | struct list_head list; |
Johan Hedberg | 93450c7 | 2014-07-04 12:37:17 +0300 | [diff] [blame] | 477 | struct list_head action; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 478 | |
| 479 | bdaddr_t addr; |
| 480 | u8 addr_type; |
| 481 | |
| 482 | u16 conn_min_interval; |
| 483 | u16 conn_max_interval; |
Marcel Holtmann | f044eb0 | 2014-06-29 16:43:26 +0200 | [diff] [blame] | 484 | u16 conn_latency; |
| 485 | u16 supervision_timeout; |
Andre Guedes | 9fcb18e | 2014-02-26 20:21:48 -0300 | [diff] [blame] | 486 | |
| 487 | enum { |
| 488 | HCI_AUTO_CONN_DISABLED, |
Johan Hedberg | a3451d2 | 2014-07-02 17:37:27 +0300 | [diff] [blame] | 489 | HCI_AUTO_CONN_REPORT, |
Marcel Holtmann | 4b9e7e7 | 2014-07-23 21:55:23 +0200 | [diff] [blame] | 490 | HCI_AUTO_CONN_DIRECT, |
Andre Guedes | 9fcb18e | 2014-02-26 20:21:48 -0300 | [diff] [blame] | 491 | HCI_AUTO_CONN_ALWAYS, |
| 492 | HCI_AUTO_CONN_LINK_LOSS, |
| 493 | } auto_connect; |
Johan Hedberg | f161dd4 | 2014-08-15 21:06:54 +0300 | [diff] [blame] | 494 | |
| 495 | struct hci_conn *conn; |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 496 | }; |
| 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | extern struct list_head hci_dev_list; |
| 499 | extern struct list_head hci_cb_list; |
| 500 | extern rwlock_t hci_dev_list_lock; |
| 501 | extern rwlock_t hci_cb_list_lock; |
| 502 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 503 | /* ----- HCI interface to upper protocols ----- */ |
Joe Perches | e74e58f | 2013-09-23 11:37:36 -0700 | [diff] [blame] | 504 | int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 505 | void l2cap_connect_cfm(struct hci_conn *hcon, u8 status); |
| 506 | int l2cap_disconn_ind(struct hci_conn *hcon); |
| 507 | void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); |
| 508 | int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); |
| 509 | int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 510 | |
Joe Perches | e74e58f | 2013-09-23 11:37:36 -0700 | [diff] [blame] | 511 | int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); |
| 512 | void sco_connect_cfm(struct hci_conn *hcon, __u8 status); |
| 513 | void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason); |
| 514 | int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 515 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | /* ----- Inquiry cache ----- */ |
Andrei Emeltchenko | 70f23020 | 2010-12-01 16:58:25 +0200 | [diff] [blame] | 517 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
| 518 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 520 | static inline void discovery_init(struct hci_dev *hdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | { |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 522 | hdev->discovery.state = DISCOVERY_STOPPED; |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 523 | INIT_LIST_HEAD(&hdev->discovery.all); |
| 524 | INIT_LIST_HEAD(&hdev->discovery.unknown); |
| 525 | INIT_LIST_HEAD(&hdev->discovery.resolve); |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 526 | hdev->discovery.report_invalid_rssi = true; |
Jakub Pawlowski | 37eab04 | 2014-12-05 10:55:55 +0100 | [diff] [blame] | 527 | hdev->discovery.rssi = HCI_RSSI_INVALID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 530 | static inline void hci_discovery_filter_clear(struct hci_dev *hdev) |
| 531 | { |
Marcel Holtmann | da25cf6 | 2014-12-05 13:03:35 +0100 | [diff] [blame] | 532 | hdev->discovery.report_invalid_rssi = true; |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 533 | hdev->discovery.rssi = HCI_RSSI_INVALID; |
| 534 | hdev->discovery.uuid_count = 0; |
| 535 | kfree(hdev->discovery.uuids); |
| 536 | hdev->discovery.uuids = NULL; |
Jakub Pawlowski | 2d28cfe | 2015-02-01 23:07:54 -0800 | [diff] [blame] | 537 | hdev->discovery.scan_start = 0; |
| 538 | hdev->discovery.scan_duration = 0; |
Marcel Holtmann | 0256325 | 2014-12-05 11:45:21 +0100 | [diff] [blame] | 539 | } |
| 540 | |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 541 | bool hci_discovery_active(struct hci_dev *hdev); |
| 542 | |
Johan Hedberg | ff9ef57 | 2012-01-04 14:23:45 +0200 | [diff] [blame] | 543 | void hci_discovery_set_state(struct hci_dev *hdev, int state); |
| 544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | static inline int inquiry_cache_empty(struct hci_dev *hdev) |
| 546 | { |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 547 | return list_empty(&hdev->discovery.all); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | static inline long inquiry_cache_age(struct hci_dev *hdev) |
| 551 | { |
Johan Hedberg | 3088351 | 2012-01-04 14:16:21 +0200 | [diff] [blame] | 552 | struct discovery_state *c = &hdev->discovery; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | return jiffies - c->timestamp; |
| 554 | } |
| 555 | |
| 556 | static inline long inquiry_entry_age(struct inquiry_entry *e) |
| 557 | { |
| 558 | return jiffies - e->timestamp; |
| 559 | } |
| 560 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 561 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 562 | bdaddr_t *bdaddr); |
Johan Hedberg | 561aafb | 2012-01-04 13:31:59 +0200 | [diff] [blame] | 563 | struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 564 | bdaddr_t *bdaddr); |
Johan Hedberg | 30dc78e | 2012-01-04 15:44:20 +0200 | [diff] [blame] | 565 | struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 566 | bdaddr_t *bdaddr, |
| 567 | int state); |
Johan Hedberg | a3d4e20 | 2012-01-09 00:53:02 +0200 | [diff] [blame] | 568 | void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 569 | struct inquiry_entry *ie); |
Marcel Holtmann | af58925 | 2014-07-01 14:11:20 +0200 | [diff] [blame] | 570 | u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, |
| 571 | bool name_known); |
Andre Guedes | 1f9b9a5 | 2013-04-30 15:29:27 -0300 | [diff] [blame] | 572 | void hci_inquiry_cache_flush(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
| 574 | /* ----- HCI Connections ----- */ |
| 575 | enum { |
| 576 | HCI_CONN_AUTH_PEND, |
Waldemar Rymarkiewicz | 19f8def | 2011-05-31 15:49:25 +0200 | [diff] [blame] | 577 | HCI_CONN_REAUTH_PEND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | HCI_CONN_ENCRYPT_PEND, |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 579 | HCI_CONN_RSWITCH_PEND, |
| 580 | HCI_CONN_MODE_CHANGE_PEND, |
Marcel Holtmann | e73439d | 2010-07-26 10:06:00 -0400 | [diff] [blame] | 581 | HCI_CONN_SCO_SETUP_PEND, |
Johan Hedberg | b644ba3 | 2012-01-17 21:48:47 +0200 | [diff] [blame] | 582 | HCI_CONN_MGMT_CONNECTED, |
Johan Hedberg | 58a681e | 2012-01-16 06:47:28 +0200 | [diff] [blame] | 583 | HCI_CONN_SSP_ENABLED, |
Marcel Holtmann | eb9a8f3 | 2014-01-15 22:37:38 -0800 | [diff] [blame] | 584 | HCI_CONN_SC_ENABLED, |
Marcel Holtmann | abf76ba | 2014-01-31 16:24:28 -0800 | [diff] [blame] | 585 | HCI_CONN_AES_CCM, |
Johan Hedberg | 58a681e | 2012-01-16 06:47:28 +0200 | [diff] [blame] | 586 | HCI_CONN_POWER_SAVE, |
| 587 | HCI_CONN_REMOTE_OOB, |
Johan Hedberg | af6a9c3 | 2014-06-24 13:15:53 +0300 | [diff] [blame] | 588 | HCI_CONN_FLUSH_KEY, |
Johan Hedberg | 4dae279 | 2014-06-24 17:03:50 +0300 | [diff] [blame] | 589 | HCI_CONN_ENCRYPT, |
| 590 | HCI_CONN_AUTH, |
| 591 | HCI_CONN_SECURE, |
| 592 | HCI_CONN_FIPS, |
Johan Hedberg | fe59a05 | 2014-07-01 19:14:12 +0300 | [diff] [blame] | 593 | HCI_CONN_STK_ENCRYPT, |
Johan Hedberg | 977f8fc | 2014-07-17 15:35:39 +0300 | [diff] [blame] | 594 | HCI_CONN_AUTH_INITIATOR, |
Johan Hedberg | f94b665 | 2014-08-18 00:41:44 +0300 | [diff] [blame] | 595 | HCI_CONN_DROP, |
Alfonso Acosta | 89cbb06 | 2014-10-11 21:44:47 +0000 | [diff] [blame] | 596 | HCI_CONN_PARAM_REMOVAL_PEND, |
Johan Hedberg | fe8bc5a | 2014-08-14 12:33:17 +0300 | [diff] [blame] | 597 | HCI_CONN_NEW_LINK_KEY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | }; |
| 599 | |
Johan Hedberg | aa64a8b | 2012-01-18 21:33:12 +0200 | [diff] [blame] | 600 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) |
| 601 | { |
| 602 | struct hci_dev *hdev = conn->hdev; |
Gustavo Padovan | c3c7ea6 | 2012-05-23 04:04:20 -0300 | [diff] [blame] | 603 | return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && |
| 604 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); |
Johan Hedberg | aa64a8b | 2012-01-18 21:33:12 +0200 | [diff] [blame] | 605 | } |
| 606 | |
Marcel Holtmann | eb9a8f3 | 2014-01-15 22:37:38 -0800 | [diff] [blame] | 607 | static inline bool hci_conn_sc_enabled(struct hci_conn *conn) |
| 608 | { |
| 609 | struct hci_dev *hdev = conn->hdev; |
| 610 | return test_bit(HCI_SC_ENABLED, &hdev->dev_flags) && |
| 611 | test_bit(HCI_CONN_SC_ENABLED, &conn->flags); |
| 612 | } |
| 613 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) |
| 615 | { |
| 616 | struct hci_conn_hash *h = &hdev->conn_hash; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 617 | list_add_rcu(&c->list, &h->list); |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 618 | switch (c->type) { |
| 619 | case ACL_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | h->acl_num++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 621 | break; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 622 | case AMP_LINK: |
| 623 | h->amp_num++; |
| 624 | break; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 625 | case LE_LINK: |
| 626 | h->le_num++; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 627 | if (c->role == HCI_ROLE_SLAVE) |
| 628 | h->le_num_slave++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 629 | break; |
| 630 | case SCO_LINK: |
| 631 | case ESCO_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | h->sco_num++; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 633 | break; |
| 634 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) |
| 638 | { |
| 639 | struct hci_conn_hash *h = &hdev->conn_hash; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 640 | |
| 641 | list_del_rcu(&c->list); |
| 642 | synchronize_rcu(); |
| 643 | |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 644 | switch (c->type) { |
| 645 | case ACL_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | h->acl_num--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 647 | break; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 648 | case AMP_LINK: |
| 649 | h->amp_num--; |
| 650 | break; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 651 | case LE_LINK: |
| 652 | h->le_num--; |
Johan Hedberg | f8218dc | 2014-07-16 11:56:08 +0300 | [diff] [blame] | 653 | if (c->role == HCI_ROLE_SLAVE) |
| 654 | h->le_num_slave--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 655 | break; |
| 656 | case SCO_LINK: |
| 657 | case ESCO_LINK: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | h->sco_num--; |
Ville Tervo | fcd89c0 | 2011-02-10 22:38:47 -0300 | [diff] [blame] | 659 | break; |
| 660 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | } |
| 662 | |
Luiz Augusto von Dentz | 52087a7 | 2011-08-17 16:23:00 +0300 | [diff] [blame] | 663 | static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) |
| 664 | { |
| 665 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 666 | switch (type) { |
| 667 | case ACL_LINK: |
| 668 | return h->acl_num; |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 669 | case AMP_LINK: |
| 670 | return h->amp_num; |
Luiz Augusto von Dentz | 52087a7 | 2011-08-17 16:23:00 +0300 | [diff] [blame] | 671 | case LE_LINK: |
| 672 | return h->le_num; |
| 673 | case SCO_LINK: |
| 674 | case ESCO_LINK: |
| 675 | return h->sco_num; |
| 676 | default: |
| 677 | return 0; |
| 678 | } |
| 679 | } |
| 680 | |
Johan Hedberg | f4f0750 | 2014-02-24 14:52:16 +0200 | [diff] [blame] | 681 | static inline unsigned int hci_conn_count(struct hci_dev *hdev) |
| 682 | { |
| 683 | struct hci_conn_hash *c = &hdev->conn_hash; |
| 684 | |
| 685 | return c->acl_num + c->amp_num + c->sco_num + c->le_num; |
| 686 | } |
| 687 | |
Marcel Holtmann | 845472e8 | 2014-11-03 05:16:08 +0100 | [diff] [blame] | 688 | static inline __u8 hci_conn_lookup_type(struct hci_dev *hdev, __u16 handle) |
| 689 | { |
| 690 | struct hci_conn_hash *h = &hdev->conn_hash; |
| 691 | struct hci_conn *c; |
| 692 | __u8 type = INVALID_LINK; |
| 693 | |
| 694 | rcu_read_lock(); |
| 695 | |
| 696 | list_for_each_entry_rcu(c, &h->list, list) { |
| 697 | if (c->handle == handle) { |
| 698 | type = c->type; |
| 699 | break; |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | rcu_read_unlock(); |
| 704 | |
| 705 | return type; |
| 706 | } |
| 707 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 709 | __u16 handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | { |
| 711 | struct hci_conn_hash *h = &hdev->conn_hash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | struct hci_conn *c; |
| 713 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 714 | rcu_read_lock(); |
| 715 | |
| 716 | list_for_each_entry_rcu(c, &h->list, list) { |
| 717 | if (c->handle == handle) { |
| 718 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 720 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 722 | rcu_read_unlock(); |
| 723 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | return NULL; |
| 725 | } |
| 726 | |
| 727 | static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 728 | __u8 type, bdaddr_t *ba) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | { |
| 730 | struct hci_conn_hash *h = &hdev->conn_hash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | struct hci_conn *c; |
| 732 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 733 | rcu_read_lock(); |
| 734 | |
| 735 | list_for_each_entry_rcu(c, &h->list, list) { |
| 736 | if (c->type == type && !bacmp(&c->dst, ba)) { |
| 737 | rcu_read_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 739 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 741 | |
| 742 | rcu_read_unlock(); |
| 743 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | return NULL; |
| 745 | } |
| 746 | |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 747 | static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, |
Szymon Janc | adc4266 | 2011-02-17 16:42:00 +0100 | [diff] [blame] | 748 | __u8 type, __u16 state) |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 749 | { |
| 750 | struct hci_conn_hash *h = &hdev->conn_hash; |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 751 | struct hci_conn *c; |
| 752 | |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 753 | rcu_read_lock(); |
| 754 | |
| 755 | list_for_each_entry_rcu(c, &h->list, list) { |
| 756 | if (c->type == type && c->state == state) { |
| 757 | rcu_read_unlock(); |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 758 | return c; |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 759 | } |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 760 | } |
Gustavo F. Padovan | bf4c632 | 2011-12-14 22:54:12 -0200 | [diff] [blame] | 761 | |
| 762 | rcu_read_unlock(); |
| 763 | |
Marcel Holtmann | 4c67bc7 | 2006-10-15 17:30:56 +0200 | [diff] [blame] | 764 | return NULL; |
| 765 | } |
| 766 | |
Johan Hedberg | e3b679d | 2014-08-18 20:33:32 +0300 | [diff] [blame] | 767 | int hci_disconnect(struct hci_conn *conn, __u8 reason); |
Frédéric Dalleau | 2dea632 | 2013-08-19 14:24:03 +0200 | [diff] [blame] | 768 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle); |
Marcel Holtmann | e73439d | 2010-07-26 10:06:00 -0400 | [diff] [blame] | 769 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
Johan Hedberg | a5c4e30 | 2014-07-16 11:56:07 +0300 | [diff] [blame] | 771 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, |
| 772 | u8 role); |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 773 | int hci_conn_del(struct hci_conn *conn); |
| 774 | void hci_conn_hash_flush(struct hci_dev *hdev); |
| 775 | void hci_conn_check_pending(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 777 | struct hci_chan *hci_chan_create(struct hci_conn *conn); |
Andrei Emeltchenko | 9472007 | 2012-09-06 15:05:43 +0300 | [diff] [blame] | 778 | void hci_chan_del(struct hci_chan *chan); |
Gustavo F. Padovan | 2c33c06 | 2011-12-14 13:02:51 -0200 | [diff] [blame] | 779 | void hci_chan_list_flush(struct hci_conn *conn); |
Andrei Emeltchenko | 42c4e53 | 2012-10-10 17:38:28 +0300 | [diff] [blame] | 780 | struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 781 | |
Andre Guedes | 04a6c58 | 2014-02-26 20:21:44 -0300 | [diff] [blame] | 782 | struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, |
Johan Hedberg | cdd6275 | 2014-07-07 15:02:28 +0300 | [diff] [blame] | 783 | u8 dst_type, u8 sec_level, u16 conn_timeout, |
Johan Hedberg | e804d25 | 2014-07-16 11:42:28 +0300 | [diff] [blame] | 784 | u8 role); |
Andre Guedes | 04a6c58 | 2014-02-26 20:21:44 -0300 | [diff] [blame] | 785 | struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, |
| 786 | u8 sec_level, u8 auth_type); |
Frédéric Dalleau | 10c62dd | 2013-08-19 14:23:59 +0200 | [diff] [blame] | 787 | struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, |
| 788 | __u16 setting); |
Marcel Holtmann | e7c29cb | 2008-09-09 07:19:20 +0200 | [diff] [blame] | 789 | int hci_conn_check_link_mode(struct hci_conn *conn); |
Waldemar Rymarkiewicz | b3b1b06 | 2011-05-06 09:42:31 +0200 | [diff] [blame] | 790 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
Johan Hedberg | e7cafc4 | 2014-07-17 15:35:38 +0300 | [diff] [blame] | 791 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type, |
| 792 | bool initiator); |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 793 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | |
Jaikumar Ganesh | 14b12d0 | 2011-05-23 18:06:04 -0700 | [diff] [blame] | 795 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | |
Andre Guedes | 06c053f | 2014-02-26 20:21:41 -0300 | [diff] [blame] | 797 | void hci_le_conn_failed(struct hci_conn *conn, u8 status); |
| 798 | |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 799 | /* |
| 800 | * hci_conn_get() and hci_conn_put() are used to control the life-time of an |
| 801 | * "hci_conn" object. They do not guarantee that the hci_conn object is running, |
| 802 | * working or anything else. They just guarantee that the object is available |
| 803 | * and can be dereferenced. So you can use its locks, local variables and any |
| 804 | * other constant data. |
| 805 | * Before accessing runtime data, you _must_ lock the object and then check that |
| 806 | * it is still running. As soon as you release the locks, the connection might |
| 807 | * get dropped, though. |
| 808 | * |
| 809 | * On the other hand, hci_conn_hold() and hci_conn_drop() are used to control |
| 810 | * how long the underlying connection is held. So every channel that runs on the |
| 811 | * hci_conn object calls this to prevent the connection from disappearing. As |
| 812 | * long as you hold a device, you must also guarantee that you have a valid |
| 813 | * reference to the device via hci_conn_get() (or the initial reference from |
| 814 | * hci_conn_add()). |
| 815 | * The hold()/drop() ref-count is known to drop below 0 sometimes, which doesn't |
| 816 | * break because nobody cares for that. But this means, we cannot use |
| 817 | * _get()/_drop() in it, but require the caller to have a valid ref (FIXME). |
| 818 | */ |
| 819 | |
Johan Hedberg | 51bb8457 | 2014-08-15 21:06:57 +0300 | [diff] [blame] | 820 | static inline struct hci_conn *hci_conn_get(struct hci_conn *conn) |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 821 | { |
| 822 | get_device(&conn->dev); |
Johan Hedberg | 51bb8457 | 2014-08-15 21:06:57 +0300 | [diff] [blame] | 823 | return conn; |
David Herrmann | 8d12356 | 2013-04-06 20:28:39 +0200 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | static inline void hci_conn_put(struct hci_conn *conn) |
| 827 | { |
| 828 | put_device(&conn->dev); |
| 829 | } |
| 830 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | static inline void hci_conn_hold(struct hci_conn *conn) |
| 832 | { |
Andrei Emeltchenko | 71becf0 | 2012-07-19 17:03:42 +0300 | [diff] [blame] | 833 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
Andrei Emeltchenko | 38b3fef | 2012-06-15 11:50:28 +0300 | [diff] [blame] | 834 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | atomic_inc(&conn->refcnt); |
Andre Guedes | 2f304d1 | 2012-01-27 19:42:02 -0300 | [diff] [blame] | 836 | cancel_delayed_work(&conn->disc_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | } |
| 838 | |
David Herrmann | 76a68ba | 2013-04-06 20:28:37 +0200 | [diff] [blame] | 839 | static inline void hci_conn_drop(struct hci_conn *conn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | { |
Andrei Emeltchenko | 71becf0 | 2012-07-19 17:03:42 +0300 | [diff] [blame] | 841 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
Andrei Emeltchenko | 38b3fef | 2012-06-15 11:50:28 +0300 | [diff] [blame] | 842 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | if (atomic_dec_and_test(&conn->refcnt)) { |
Marcel Holtmann | 04837f6 | 2006-07-03 10:02:33 +0200 | [diff] [blame] | 844 | unsigned long timeo; |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 845 | |
| 846 | switch (conn->type) { |
| 847 | case ACL_LINK: |
| 848 | case LE_LINK: |
Johan Hedberg | a74a84f | 2013-10-16 18:11:40 +0300 | [diff] [blame] | 849 | cancel_delayed_work(&conn->idle_work); |
Marcel Holtmann | 6ac5934 | 2006-09-26 09:43:48 +0200 | [diff] [blame] | 850 | if (conn->state == BT_CONNECTED) { |
Andrei Emeltchenko | 5f246e8 | 2012-06-11 11:13:07 +0300 | [diff] [blame] | 851 | timeo = conn->disc_timeout; |
Marcel Holtmann | 6ac5934 | 2006-09-26 09:43:48 +0200 | [diff] [blame] | 852 | if (!conn->out) |
Marcel Holtmann | 052b30b | 2009-04-26 20:01:22 +0200 | [diff] [blame] | 853 | timeo *= 2; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 854 | } else { |
Johan Hedberg | eb78d7e | 2014-08-18 00:41:41 +0300 | [diff] [blame] | 855 | timeo = 0; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 856 | } |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 857 | break; |
| 858 | |
| 859 | case AMP_LINK: |
| 860 | timeo = conn->disc_timeout; |
| 861 | break; |
| 862 | |
| 863 | default: |
Johan Hedberg | eb78d7e | 2014-08-18 00:41:41 +0300 | [diff] [blame] | 864 | timeo = 0; |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 865 | break; |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 866 | } |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 867 | |
Andre Guedes | 2f304d1 | 2012-01-27 19:42:02 -0300 | [diff] [blame] | 868 | cancel_delayed_work(&conn->disc_work); |
Gustavo F. Padovan | 19c40e3 | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 869 | queue_delayed_work(conn->hdev->workqueue, |
Andrei Emeltchenko | 716e4ab | 2012-10-10 17:38:31 +0300 | [diff] [blame] | 870 | &conn->disc_work, timeo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | } |
| 872 | } |
| 873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | /* ----- HCI Devices ----- */ |
David Herrmann | dc946bd | 2012-01-07 15:47:24 +0100 | [diff] [blame] | 875 | static inline void hci_dev_put(struct hci_dev *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | { |
Andrei Emeltchenko | 376261a | 2012-09-06 15:05:45 +0300 | [diff] [blame] | 877 | BT_DBG("%s orig refcnt %d", d->name, |
| 878 | atomic_read(&d->dev.kobj.kref.refcount)); |
| 879 | |
David Herrmann | 4c724c7 | 2012-01-07 15:47:23 +0100 | [diff] [blame] | 880 | put_device(&d->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | } |
| 882 | |
David Herrmann | dc946bd | 2012-01-07 15:47:24 +0100 | [diff] [blame] | 883 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | { |
Andrei Emeltchenko | 376261a | 2012-09-06 15:05:45 +0300 | [diff] [blame] | 885 | BT_DBG("%s orig refcnt %d", d->name, |
| 886 | atomic_read(&d->dev.kobj.kref.refcount)); |
| 887 | |
David Herrmann | 4c724c7 | 2012-01-07 15:47:23 +0100 | [diff] [blame] | 888 | get_device(&d->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | return d; |
| 890 | } |
| 891 | |
Gustavo F. Padovan | 09fd0de | 2011-06-17 13:03:21 -0300 | [diff] [blame] | 892 | #define hci_dev_lock(d) mutex_lock(&d->lock) |
| 893 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | |
David Herrmann | aa2b86d | 2012-02-09 21:58:30 +0100 | [diff] [blame] | 895 | #define to_hci_dev(d) container_of(d, struct hci_dev, dev) |
David Herrmann | 3dc0732 | 2012-02-09 21:58:33 +0100 | [diff] [blame] | 896 | #define to_hci_conn(c) container_of(c, struct hci_conn, dev) |
David Herrmann | aa2b86d | 2012-02-09 21:58:30 +0100 | [diff] [blame] | 897 | |
David Herrmann | 155961e | 2012-02-09 21:58:32 +0100 | [diff] [blame] | 898 | static inline void *hci_get_drvdata(struct hci_dev *hdev) |
| 899 | { |
| 900 | return dev_get_drvdata(&hdev->dev); |
| 901 | } |
| 902 | |
| 903 | static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) |
| 904 | { |
| 905 | dev_set_drvdata(&hdev->dev, data); |
| 906 | } |
| 907 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | struct hci_dev *hci_dev_get(int index); |
Johan Hedberg | 0c0afed | 2012-11-01 13:27:26 +0200 | [diff] [blame] | 909 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | |
| 911 | struct hci_dev *hci_alloc_dev(void); |
| 912 | void hci_free_dev(struct hci_dev *hdev); |
| 913 | int hci_register_dev(struct hci_dev *hdev); |
David Herrmann | 5973563 | 2011-10-26 10:43:19 +0200 | [diff] [blame] | 914 | void hci_unregister_dev(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | int hci_suspend_dev(struct hci_dev *hdev); |
| 916 | int hci_resume_dev(struct hci_dev *hdev); |
Marcel Holtmann | 75e0569 | 2014-11-02 08:15:38 +0100 | [diff] [blame] | 917 | int hci_reset_dev(struct hci_dev *hdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | int hci_dev_open(__u16 dev); |
| 919 | int hci_dev_close(__u16 dev); |
| 920 | int hci_dev_reset(__u16 dev); |
| 921 | int hci_dev_reset_stat(__u16 dev); |
| 922 | int hci_dev_cmd(unsigned int cmd, void __user *arg); |
| 923 | int hci_get_dev_list(void __user *arg); |
| 924 | int hci_get_dev_info(void __user *arg); |
| 925 | int hci_get_conn_list(void __user *arg); |
| 926 | int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); |
Marcel Holtmann | 40be492 | 2008-07-14 20:13:50 +0200 | [diff] [blame] | 927 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | int hci_inquiry(void __user *arg); |
| 929 | |
Johan Hedberg | dcc36c1 | 2014-07-09 12:59:13 +0300 | [diff] [blame] | 930 | struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *list, |
| 931 | bdaddr_t *bdaddr, u8 type); |
| 932 | int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type); |
| 933 | int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type); |
| 934 | void hci_bdaddr_list_clear(struct list_head *list); |
Marcel Holtmann | d2ab0ac | 2014-02-27 20:37:30 -0800 | [diff] [blame] | 935 | |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 936 | struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, |
| 937 | bdaddr_t *addr, u8 addr_type); |
Marcel Holtmann | 51d167c | 2014-07-01 12:11:04 +0200 | [diff] [blame] | 938 | struct hci_conn_params *hci_conn_params_add(struct hci_dev *hdev, |
| 939 | bdaddr_t *addr, u8 addr_type); |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 940 | void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type); |
Johan Hedberg | 373110c | 2014-07-02 17:37:25 +0300 | [diff] [blame] | 941 | void hci_conn_params_clear_all(struct hci_dev *hdev); |
Johan Hedberg | 55af49a | 2014-07-02 17:37:26 +0300 | [diff] [blame] | 942 | void hci_conn_params_clear_disabled(struct hci_dev *hdev); |
Andre Guedes | 15819a7 | 2014-02-03 13:56:18 -0300 | [diff] [blame] | 943 | |
Johan Hedberg | 501f882 | 2014-07-04 12:37:26 +0300 | [diff] [blame] | 944 | struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, |
| 945 | bdaddr_t *addr, |
| 946 | u8 addr_type); |
Andre Guedes | 77a77a3 | 2014-02-26 20:21:46 -0300 | [diff] [blame] | 947 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 948 | void hci_uuids_clear(struct hci_dev *hdev); |
Johan Hedberg | 2aeb9a1 | 2011-01-04 12:08:51 +0200 | [diff] [blame] | 949 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 950 | void hci_link_keys_clear(struct hci_dev *hdev); |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 951 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
Johan Hedberg | 567fa2a | 2014-06-24 13:15:48 +0300 | [diff] [blame] | 952 | struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, |
Johan Hedberg | 7652ff6 | 2014-06-24 13:15:49 +0300 | [diff] [blame] | 953 | bdaddr_t *bdaddr, u8 *val, u8 type, |
| 954 | u8 pin_len, bool *persistent); |
Johan Hedberg | ca9142b | 2014-02-19 14:57:44 +0200 | [diff] [blame] | 955 | struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 35d7027 | 2014-02-19 14:57:47 +0200 | [diff] [blame] | 956 | u8 addr_type, u8 type, u8 authenticated, |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 957 | u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand); |
Johan Hedberg | f3a73d9 | 2014-05-29 15:02:59 +0300 | [diff] [blame] | 958 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 959 | u8 addr_type, u8 role); |
Johan Hedberg | e0b2b27 | 2014-02-18 17:14:31 +0200 | [diff] [blame] | 960 | int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type); |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 961 | void hci_smp_ltks_clear(struct hci_dev *hdev); |
Johan Hedberg | 55ed8ca1 | 2011-01-17 14:41:05 +0200 | [diff] [blame] | 962 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
| 963 | |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 964 | struct smp_irk *hci_find_irk_by_rpa(struct hci_dev *hdev, bdaddr_t *rpa); |
| 965 | struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 966 | u8 addr_type); |
Johan Hedberg | ca9142b | 2014-02-19 14:57:44 +0200 | [diff] [blame] | 967 | struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 968 | u8 addr_type, u8 val[16], bdaddr_t *rpa); |
Johan Hedberg | a7ec733 | 2014-02-18 17:14:35 +0200 | [diff] [blame] | 969 | void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type); |
Johan Hedberg | 970c4e4 | 2014-02-18 10:19:33 +0200 | [diff] [blame] | 970 | void hci_smp_irks_clear(struct hci_dev *hdev); |
| 971 | |
Johan Hedberg | 35f7498 | 2014-02-18 17:14:32 +0200 | [diff] [blame] | 972 | void hci_remote_oob_data_clear(struct hci_dev *hdev); |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 973 | struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 974 | bdaddr_t *bdaddr, u8 bdaddr_type); |
Marcel Holtmann | 0798872 | 2014-01-10 02:07:29 -0800 | [diff] [blame] | 975 | int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 976 | u8 bdaddr_type, u8 *hash192, u8 *rand192, |
Johan Hedberg | 81328d5 | 2014-10-26 20:33:47 +0100 | [diff] [blame] | 977 | u8 *hash256, u8 *rand256); |
Johan Hedberg | 6928a92 | 2014-10-26 20:46:09 +0100 | [diff] [blame] | 978 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 979 | u8 bdaddr_type); |
Szymon Janc | 2763eda | 2011-03-22 13:12:22 +0100 | [diff] [blame] | 980 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
| 982 | |
Marcel Holtmann | e1a2617 | 2013-10-10 16:52:43 -0700 | [diff] [blame] | 983 | int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb); |
Suraj Sumangala | 9981151 | 2010-07-14 13:02:19 +0530 | [diff] [blame] | 984 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); |
Marcel Holtmann | ef22201 | 2007-07-11 06:42:04 +0200 | [diff] [blame] | 985 | |
David Herrmann | 0ac7e70 | 2011-10-08 14:58:47 +0200 | [diff] [blame] | 986 | void hci_init_sysfs(struct hci_dev *hdev); |
Marcel Holtmann | a67e899 | 2009-05-02 18:24:06 -0700 | [diff] [blame] | 987 | void hci_conn_init_sysfs(struct hci_conn *conn); |
Marcel Holtmann | b219e3a | 2006-07-06 12:38:46 +0200 | [diff] [blame] | 988 | void hci_conn_add_sysfs(struct hci_conn *conn); |
| 989 | void hci_conn_del_sysfs(struct hci_conn *conn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | |
David Herrmann | 6935e0f | 2012-03-09 15:53:42 +0100 | [diff] [blame] | 991 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | |
| 993 | /* ----- LMP capabilities ----- */ |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 994 | #define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT) |
| 995 | #define lmp_rswitch_capable(dev) ((dev)->features[0][0] & LMP_RSWITCH) |
| 996 | #define lmp_hold_capable(dev) ((dev)->features[0][0] & LMP_HOLD) |
| 997 | #define lmp_sniff_capable(dev) ((dev)->features[0][0] & LMP_SNIFF) |
| 998 | #define lmp_park_capable(dev) ((dev)->features[0][1] & LMP_PARK) |
| 999 | #define lmp_inq_rssi_capable(dev) ((dev)->features[0][3] & LMP_RSSI_INQ) |
| 1000 | #define lmp_esco_capable(dev) ((dev)->features[0][3] & LMP_ESCO) |
| 1001 | #define lmp_bredr_capable(dev) (!((dev)->features[0][4] & LMP_NO_BREDR)) |
| 1002 | #define lmp_le_capable(dev) ((dev)->features[0][4] & LMP_LE) |
| 1003 | #define lmp_sniffsubr_capable(dev) ((dev)->features[0][5] & LMP_SNIFF_SUBR) |
| 1004 | #define lmp_pause_enc_capable(dev) ((dev)->features[0][5] & LMP_PAUSE_ENC) |
| 1005 | #define lmp_ext_inq_capable(dev) ((dev)->features[0][6] & LMP_EXT_INQ) |
| 1006 | #define lmp_le_br_capable(dev) (!!((dev)->features[0][6] & LMP_SIMUL_LE_BR)) |
| 1007 | #define lmp_ssp_capable(dev) ((dev)->features[0][6] & LMP_SIMPLE_PAIR) |
| 1008 | #define lmp_no_flush_capable(dev) ((dev)->features[0][6] & LMP_NO_FLUSH) |
| 1009 | #define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO) |
| 1010 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR) |
| 1011 | #define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES) |
Frédéric Dalleau | 07a5c61 | 2013-08-19 14:24:00 +0200 | [diff] [blame] | 1012 | #define lmp_transp_capable(dev) ((dev)->features[0][2] & LMP_TRANSPARENT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | |
Andre Guedes | eead27d | 2011-06-30 19:20:55 -0300 | [diff] [blame] | 1014 | /* ----- Extended LMP capabilities ----- */ |
Marcel Holtmann | 53b834d2 | 2013-12-08 11:55:33 -0800 | [diff] [blame] | 1015 | #define lmp_csb_master_capable(dev) ((dev)->features[2][0] & LMP_CSB_MASTER) |
| 1016 | #define lmp_csb_slave_capable(dev) ((dev)->features[2][0] & LMP_CSB_SLAVE) |
| 1017 | #define lmp_sync_train_capable(dev) ((dev)->features[2][0] & LMP_SYNC_TRAIN) |
| 1018 | #define lmp_sync_scan_capable(dev) ((dev)->features[2][0] & LMP_SYNC_SCAN) |
Marcel Holtmann | d599158 | 2014-01-10 02:07:16 -0800 | [diff] [blame] | 1019 | #define lmp_sc_capable(dev) ((dev)->features[2][1] & LMP_SC) |
| 1020 | #define lmp_ping_capable(dev) ((dev)->features[2][1] & LMP_PING) |
Marcel Holtmann | 53b834d2 | 2013-12-08 11:55:33 -0800 | [diff] [blame] | 1021 | |
| 1022 | /* ----- Host capabilities ----- */ |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 1023 | #define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP) |
Marcel Holtmann | d599158 | 2014-01-10 02:07:16 -0800 | [diff] [blame] | 1024 | #define lmp_host_sc_capable(dev) ((dev)->features[1][0] & LMP_HOST_SC) |
Johan Hedberg | cad718e | 2013-04-17 15:00:51 +0300 | [diff] [blame] | 1025 | #define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) |
| 1026 | #define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) |
Andre Guedes | eead27d | 2011-06-30 19:20:55 -0300 | [diff] [blame] | 1027 | |
Johan Hedberg | 432df05 | 2014-08-01 11:13:31 +0300 | [diff] [blame] | 1028 | #define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ |
| 1029 | !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) |
Marcel Holtmann | 05b3c3e | 2014-12-31 14:43:18 -0800 | [diff] [blame] | 1030 | #define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ |
Johan Hedberg | 710f11c | 2014-05-26 11:21:22 +0300 | [diff] [blame] | 1031 | test_bit(HCI_SC_ENABLED, &(dev)->dev_flags)) |
Johan Hedberg | 432df05 | 2014-08-01 11:13:31 +0300 | [diff] [blame] | 1032 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | /* ----- HCI protocols ----- */ |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1034 | #define HCI_PROTO_DEFER 0x01 |
| 1035 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1036 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1037 | __u8 type, __u8 *flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1039 | switch (type) { |
| 1040 | case ACL_LINK: |
| 1041 | return l2cap_connect_ind(hdev, bdaddr); |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1042 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1043 | case SCO_LINK: |
| 1044 | case ESCO_LINK: |
Frédéric Dalleau | 20714bf | 2012-11-21 10:51:12 +0100 | [diff] [blame] | 1045 | return sco_connect_ind(hdev, bdaddr, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1047 | default: |
| 1048 | BT_ERR("unknown link type %d", type); |
| 1049 | return -EINVAL; |
| 1050 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) |
| 1054 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1055 | switch (conn->type) { |
| 1056 | case ACL_LINK: |
| 1057 | case LE_LINK: |
| 1058 | l2cap_connect_cfm(conn, status); |
| 1059 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1061 | case SCO_LINK: |
| 1062 | case ESCO_LINK: |
| 1063 | sco_connect_cfm(conn, status); |
| 1064 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1065 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1066 | default: |
| 1067 | BT_ERR("unknown link type %d", conn->type); |
| 1068 | break; |
| 1069 | } |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 1070 | |
| 1071 | if (conn->connect_cfm_cb) |
| 1072 | conn->connect_cfm_cb(conn, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | } |
| 1074 | |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1075 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
| 1076 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1077 | if (conn->type != ACL_LINK && conn->type != LE_LINK) |
| 1078 | return HCI_ERROR_REMOTE_USER_TERM; |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1079 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1080 | return l2cap_disconn_ind(conn); |
Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1085 | switch (conn->type) { |
| 1086 | case ACL_LINK: |
| 1087 | case LE_LINK: |
| 1088 | l2cap_disconn_cfm(conn, reason); |
| 1089 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1091 | case SCO_LINK: |
| 1092 | case ESCO_LINK: |
| 1093 | sco_disconn_cfm(conn, reason); |
| 1094 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1095 | |
Andrei Emeltchenko | bd1eb66 | 2012-10-10 17:38:30 +0300 | [diff] [blame] | 1096 | /* L2CAP would be handled for BREDR chan */ |
| 1097 | case AMP_LINK: |
| 1098 | break; |
| 1099 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1100 | default: |
| 1101 | BT_ERR("unknown link type %d", conn->type); |
| 1102 | break; |
| 1103 | } |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 1104 | |
| 1105 | if (conn->disconn_cfm_cb) |
| 1106 | conn->disconn_cfm_cb(conn, reason); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) |
| 1110 | { |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1111 | __u8 encrypt; |
| 1112 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1113 | if (conn->type != ACL_LINK && conn->type != LE_LINK) |
| 1114 | return; |
| 1115 | |
Johan Hedberg | 51a8efd | 2012-01-16 06:10:31 +0200 | [diff] [blame] | 1116 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1117 | return; |
| 1118 | |
Johan Hedberg | 4dae279 | 2014-06-24 17:03:50 +0300 | [diff] [blame] | 1119 | encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1120 | l2cap_security_cfm(conn, status, encrypt); |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 1121 | |
| 1122 | if (conn->security_cfm_cb) |
| 1123 | conn->security_cfm_cb(conn, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | } |
| 1125 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1126 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, |
| 1127 | __u8 encrypt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1128 | { |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1129 | if (conn->type != ACL_LINK && conn->type != LE_LINK) |
| 1130 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | |
Ulisses Furquim | 686ebf2 | 2011-12-21 10:11:33 -0200 | [diff] [blame] | 1132 | l2cap_security_cfm(conn, status, encrypt); |
Johan Hedberg | e9a416b | 2011-02-19 12:05:56 -0300 | [diff] [blame] | 1133 | |
| 1134 | if (conn->security_cfm_cb) |
| 1135 | conn->security_cfm_cb(conn, status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | /* ----- HCI callbacks ----- */ |
| 1139 | struct hci_cb { |
| 1140 | struct list_head list; |
| 1141 | |
| 1142 | char *name; |
| 1143 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1144 | void (*security_cfm) (struct hci_conn *conn, __u8 status, |
| 1145 | __u8 encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | void (*key_change_cfm) (struct hci_conn *conn, __u8 status); |
| 1147 | void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role); |
| 1148 | }; |
| 1149 | |
| 1150 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) |
| 1151 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1152 | struct hci_cb *cb; |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1153 | __u8 encrypt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | |
| 1155 | hci_proto_auth_cfm(conn, status); |
| 1156 | |
Johan Hedberg | 51a8efd | 2012-01-16 06:10:31 +0200 | [diff] [blame] | 1157 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1158 | return; |
| 1159 | |
Johan Hedberg | 4dae279 | 2014-06-24 17:03:50 +0300 | [diff] [blame] | 1160 | encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1161 | |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1162 | read_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1163 | list_for_each_entry(cb, &hci_cb_list, list) { |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1164 | if (cb->security_cfm) |
| 1165 | cb->security_cfm(conn, status, encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | } |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1167 | read_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | } |
| 1169 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1170 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, |
| 1171 | __u8 encrypt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1173 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | |
Marcel Holtmann | 435fef2 | 2009-02-09 03:55:28 +0100 | [diff] [blame] | 1175 | if (conn->sec_level == BT_SECURITY_SDP) |
| 1176 | conn->sec_level = BT_SECURITY_LOW; |
| 1177 | |
Vinicius Costa Gomes | 88167ae | 2011-06-09 18:50:51 -0300 | [diff] [blame] | 1178 | if (conn->pending_sec_level > conn->sec_level) |
| 1179 | conn->sec_level = conn->pending_sec_level; |
| 1180 | |
Marcel Holtmann | 9719f8a | 2008-07-14 20:13:45 +0200 | [diff] [blame] | 1181 | hci_proto_encrypt_cfm(conn, status, encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1183 | read_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1184 | list_for_each_entry(cb, &hci_cb_list, list) { |
Marcel Holtmann | 8c1b235 | 2009-01-15 21:58:04 +0100 | [diff] [blame] | 1185 | if (cb->security_cfm) |
| 1186 | cb->security_cfm(conn, status, encrypt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1187 | } |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1188 | read_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) |
| 1192 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1193 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1195 | read_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1196 | list_for_each_entry(cb, &hci_cb_list, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | if (cb->key_change_cfm) |
| 1198 | cb->key_change_cfm(conn, status); |
| 1199 | } |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1200 | read_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | } |
| 1202 | |
Waldemar Rymarkiewicz | 5a9d0a3 | 2011-06-07 11:18:06 +0200 | [diff] [blame] | 1203 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, |
| 1204 | __u8 role) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | { |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1206 | struct hci_cb *cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1208 | read_lock(&hci_cb_list_lock); |
Denis Kirjanov | 711584e | 2012-10-22 17:22:01 +0400 | [diff] [blame] | 1209 | list_for_each_entry(cb, &hci_cb_list, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | if (cb->role_switch_cfm) |
| 1211 | cb->role_switch_cfm(conn, status, role); |
| 1212 | } |
Gustavo F. Padovan | f20d09d | 2011-12-22 16:30:27 -0200 | [diff] [blame] | 1213 | read_unlock(&hci_cb_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | } |
| 1215 | |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1216 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) |
| 1217 | { |
Johan Hedberg | 84d9d07 | 2012-03-26 14:21:41 +0300 | [diff] [blame] | 1218 | size_t parsed = 0; |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1219 | |
Johan Hedberg | 6c0c331 | 2012-03-26 14:21:42 +0300 | [diff] [blame] | 1220 | if (data_len < 2) |
| 1221 | return false; |
| 1222 | |
Johan Hedberg | 84d9d07 | 2012-03-26 14:21:41 +0300 | [diff] [blame] | 1223 | while (parsed < data_len - 1) { |
| 1224 | u8 field_len = data[0]; |
Johan Hedberg | 6759a67 | 2012-01-15 20:51:14 +0200 | [diff] [blame] | 1225 | |
| 1226 | if (field_len == 0) |
| 1227 | break; |
| 1228 | |
| 1229 | parsed += field_len + 1; |
| 1230 | |
| 1231 | if (parsed > data_len) |
| 1232 | break; |
| 1233 | |
| 1234 | if (data[1] == type) |
| 1235 | return true; |
| 1236 | |
| 1237 | data += field_len + 1; |
| 1238 | } |
| 1239 | |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
Johan Hedberg | 301cb2d | 2014-02-18 10:19:34 +0200 | [diff] [blame] | 1243 | static inline bool hci_bdaddr_is_rpa(bdaddr_t *bdaddr, u8 addr_type) |
| 1244 | { |
Andre Guedes | dbbfa2a | 2014-06-25 16:44:45 -0300 | [diff] [blame] | 1245 | if (addr_type != ADDR_LE_DEV_RANDOM) |
Johan Hedberg | 301cb2d | 2014-02-18 10:19:34 +0200 | [diff] [blame] | 1246 | return false; |
| 1247 | |
| 1248 | if ((bdaddr->b[5] & 0xc0) == 0x40) |
| 1249 | return true; |
| 1250 | |
| 1251 | return false; |
| 1252 | } |
| 1253 | |
Johan Hedberg | c46245b | 2014-07-02 17:37:33 +0300 | [diff] [blame] | 1254 | static inline bool hci_is_identity_address(bdaddr_t *addr, u8 addr_type) |
| 1255 | { |
| 1256 | if (addr_type == ADDR_LE_DEV_PUBLIC) |
| 1257 | return true; |
| 1258 | |
| 1259 | /* Check for Random Static address type */ |
| 1260 | if ((addr->b[5] & 0xc0) == 0xc0) |
| 1261 | return true; |
| 1262 | |
| 1263 | return false; |
| 1264 | } |
| 1265 | |
Johan Hedberg | 2426f3a | 2014-02-18 17:14:36 +0200 | [diff] [blame] | 1266 | static inline struct smp_irk *hci_get_irk(struct hci_dev *hdev, |
| 1267 | bdaddr_t *bdaddr, u8 addr_type) |
| 1268 | { |
| 1269 | if (!hci_bdaddr_is_rpa(bdaddr, addr_type)) |
| 1270 | return NULL; |
| 1271 | |
| 1272 | return hci_find_irk_by_rpa(hdev, bdaddr); |
| 1273 | } |
| 1274 | |
Andre Guedes | d4905f2 | 2014-06-25 21:52:52 -0300 | [diff] [blame] | 1275 | static inline int hci_check_conn_params(u16 min, u16 max, u16 latency, |
| 1276 | u16 to_multiplier) |
| 1277 | { |
| 1278 | u16 max_latency; |
| 1279 | |
| 1280 | if (min > max || min < 6 || max > 3200) |
| 1281 | return -EINVAL; |
| 1282 | |
| 1283 | if (to_multiplier < 10 || to_multiplier > 3200) |
| 1284 | return -EINVAL; |
| 1285 | |
| 1286 | if (max >= to_multiplier * 8) |
| 1287 | return -EINVAL; |
| 1288 | |
| 1289 | max_latency = (to_multiplier * 8 / max) - 1; |
| 1290 | if (latency > 499 || latency > max_latency) |
| 1291 | return -EINVAL; |
| 1292 | |
| 1293 | return 0; |
| 1294 | } |
| 1295 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1296 | int hci_register_cb(struct hci_cb *hcb); |
| 1297 | int hci_unregister_cb(struct hci_cb *hcb); |
| 1298 | |
Marcel Holtmann | 899de76 | 2014-07-11 05:51:58 +0200 | [diff] [blame] | 1299 | bool hci_req_pending(struct hci_dev *hdev); |
Johan Hedberg | 3119ae9 | 2013-03-05 20:37:44 +0200 | [diff] [blame] | 1300 | |
Johan Hedberg | 75e84b7 | 2013-04-02 13:35:04 +0300 | [diff] [blame] | 1301 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1302 | const void *param, u32 timeout); |
Johan Hedberg | 7b1abbb | 2013-04-03 21:54:47 +0300 | [diff] [blame] | 1303 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1304 | const void *param, u8 event, u32 timeout); |
Johan Hedberg | 75e84b7 | 2013-04-02 13:35:04 +0300 | [diff] [blame] | 1305 | |
Johan Hedberg | 07dc93d | 2013-04-19 10:14:51 +0300 | [diff] [blame] | 1306 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, |
| 1307 | const void *param); |
Luiz Augusto von Dentz | 73d80de | 2011-11-02 15:52:01 +0200 | [diff] [blame] | 1308 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); |
Gustavo F. Padovan | 0d861d8 | 2010-05-01 16:15:35 -0300 | [diff] [blame] | 1309 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | |
Marcel Holtmann | a9de924 | 2007-10-20 13:33:56 +0200 | [diff] [blame] | 1311 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | /* ----- HCI Sockets ----- */ |
Marcel Holtmann | 470fe1b | 2012-02-20 14:50:30 +0100 | [diff] [blame] | 1314 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); |
| 1315 | void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); |
Marcel Holtmann | cd82e61 | 2012-02-20 20:34:38 +0100 | [diff] [blame] | 1316 | void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1317 | |
Marcel Holtmann | 040030e | 2012-02-20 14:50:37 +0100 | [diff] [blame] | 1318 | void hci_sock_dev_event(struct hci_dev *hdev, int event); |
| 1319 | |
Johan Hedberg | 0381101 | 2010-12-08 00:21:06 +0200 | [diff] [blame] | 1320 | /* Management interface */ |
Andre Guedes | 591f47f | 2012-04-24 21:02:49 -0300 | [diff] [blame] | 1321 | #define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR)) |
| 1322 | #define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \ |
| 1323 | BIT(BDADDR_LE_RANDOM)) |
| 1324 | #define DISCOV_TYPE_INTERLEAVED (BIT(BDADDR_BREDR) | \ |
| 1325 | BIT(BDADDR_LE_PUBLIC) | \ |
| 1326 | BIT(BDADDR_LE_RANDOM)) |
Andre Guedes | f39799f | 2012-02-17 20:39:35 -0300 | [diff] [blame] | 1327 | |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1328 | /* These LE scan and inquiry parameters were chosen according to LE General |
| 1329 | * Discovery Procedure specification. |
| 1330 | */ |
| 1331 | #define DISCOV_LE_SCAN_WIN 0x12 |
| 1332 | #define DISCOV_LE_SCAN_INT 0x12 |
Lukasz Rymanowski | 3d5a76f | 2014-03-27 20:55:21 +0100 | [diff] [blame] | 1333 | #define DISCOV_LE_TIMEOUT 10240 /* msec */ |
Lukasz Rymanowski | ae55f59 | 2014-03-27 20:55:19 +0100 | [diff] [blame] | 1334 | #define DISCOV_INTERLEAVED_TIMEOUT 5120 /* msec */ |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1335 | #define DISCOV_INTERLEAVED_INQUIRY_LEN 0x04 |
| 1336 | #define DISCOV_BREDR_INQUIRY_LEN 0x08 |
Jakub Pawlowski | 4b0e0ce | 2015-02-01 23:07:55 -0800 | [diff] [blame] | 1337 | #define DISCOV_LE_RESTART_DELAY msecs_to_jiffies(200) /* msec */ |
Andre Guedes | 0d8cc93 | 2013-04-30 15:29:31 -0300 | [diff] [blame] | 1338 | |
Johan Hedberg | 0381101 | 2010-12-08 00:21:06 +0200 | [diff] [blame] | 1339 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); |
Johan Hedberg | 91a668b | 2014-07-09 13:28:26 +0300 | [diff] [blame] | 1340 | int mgmt_new_settings(struct hci_dev *hdev); |
Marcel Holtmann | bf6b56d | 2013-10-06 23:55:45 -0700 | [diff] [blame] | 1341 | void mgmt_index_added(struct hci_dev *hdev); |
| 1342 | void mgmt_index_removed(struct hci_dev *hdev); |
Marcel Holtmann | 3eec705 | 2013-10-06 23:55:46 -0700 | [diff] [blame] | 1343 | void mgmt_set_powered_failed(struct hci_dev *hdev, int err); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1344 | int mgmt_powered(struct hci_dev *hdev, u8 powered); |
Johan Hedberg | bc6d2d0 | 2014-07-10 12:09:08 +0300 | [diff] [blame] | 1345 | int mgmt_update_adv_data(struct hci_dev *hdev); |
Marcel Holtmann | d1967ff | 2013-10-15 10:57:40 -0700 | [diff] [blame] | 1346 | void mgmt_discoverable_timeout(struct hci_dev *hdev); |
Marcel Holtmann | dc4a5ee | 2013-10-15 10:15:57 -0700 | [diff] [blame] | 1347 | void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, |
| 1348 | bool persistent); |
Alfonso Acosta | 48ec92f | 2014-10-07 08:44:10 +0000 | [diff] [blame] | 1349 | void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn, |
| 1350 | u32 flags, u8 *name, u8 name_len); |
Marcel Holtmann | 9b80ec5 | 2013-10-06 23:55:50 -0700 | [diff] [blame] | 1351 | void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 12d4a3b | 2014-02-24 14:52:18 +0200 | [diff] [blame] | 1352 | u8 link_type, u8 addr_type, u8 reason, |
| 1353 | bool mgmt_connected); |
Marcel Holtmann | 7892924 | 2013-10-06 23:55:47 -0700 | [diff] [blame] | 1354 | void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1355 | u8 link_type, u8 addr_type, u8 status); |
Marcel Holtmann | 445608d | 2013-10-06 23:55:48 -0700 | [diff] [blame] | 1356 | void mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
| 1357 | u8 addr_type, u8 status); |
Marcel Holtmann | ce0e4a0 | 2013-10-15 14:26:20 -0700 | [diff] [blame] | 1358 | void mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); |
Marcel Holtmann | e669cf8 | 2013-10-15 14:26:21 -0700 | [diff] [blame] | 1359 | void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1360 | u8 status); |
Marcel Holtmann | 3eb3852 | 2013-10-15 14:26:22 -0700 | [diff] [blame] | 1361 | void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1362 | u8 status); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1363 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | 39adbff | 2014-03-20 08:18:14 +0200 | [diff] [blame] | 1364 | u8 link_type, u8 addr_type, u32 value, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1365 | u8 confirm_hint); |
Johan Hedberg | 744cf19 | 2011-11-08 20:40:14 +0200 | [diff] [blame] | 1366 | int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1367 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1368 | int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1369 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1370 | int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1371 | u8 link_type, u8 addr_type); |
Brian Gix | 604086b | 2011-11-23 08:28:33 -0800 | [diff] [blame] | 1372 | int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1373 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 272d90d | 2012-02-09 15:26:12 +0200 | [diff] [blame] | 1374 | int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Gustavo F. Padovan | 0412468 | 2012-03-08 01:25:00 -0300 | [diff] [blame] | 1375 | u8 link_type, u8 addr_type, u8 status); |
Johan Hedberg | 92a2525 | 2012-09-06 18:39:26 +0300 | [diff] [blame] | 1376 | int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1377 | u8 link_type, u8 addr_type, u32 passkey, |
| 1378 | u8 entered); |
Johan Hedberg | e1e930f | 2014-09-08 17:09:49 -0700 | [diff] [blame] | 1379 | void mgmt_auth_failed(struct hci_conn *conn, u8 status); |
Marcel Holtmann | 464996a | 2013-10-15 14:26:24 -0700 | [diff] [blame] | 1380 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); |
Marcel Holtmann | 3e24856 | 2013-10-15 14:26:25 -0700 | [diff] [blame] | 1381 | void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); |
Marcel Holtmann | 4e1b024 | 2013-10-15 14:26:26 -0700 | [diff] [blame] | 1382 | void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, |
| 1383 | u8 status); |
Marcel Holtmann | 7667da3 | 2013-10-15 14:26:27 -0700 | [diff] [blame] | 1384 | void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); |
Marcel Holtmann | 4d2d279 | 2014-01-10 02:07:26 -0800 | [diff] [blame] | 1385 | void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192, |
Johan Hedberg | 38da170 | 2014-11-17 20:52:20 +0200 | [diff] [blame] | 1386 | u8 *rand192, u8 *hash256, u8 *rand256, |
| 1387 | u8 status); |
Marcel Holtmann | 901801b | 2013-10-06 23:55:51 -0700 | [diff] [blame] | 1388 | void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
Marcel Holtmann | af58925 | 2014-07-01 14:11:20 +0200 | [diff] [blame] | 1389 | u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, |
| 1390 | u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len); |
Marcel Holtmann | 9cf12ae | 2013-10-06 23:55:52 -0700 | [diff] [blame] | 1391 | void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, |
| 1392 | u8 addr_type, s8 rssi, u8 *name, u8 name_len); |
Marcel Holtmann | 2f1e063 | 2013-10-06 23:55:53 -0700 | [diff] [blame] | 1393 | void mgmt_discovering(struct hci_dev *hdev, u8 discovering); |
Johan Hedberg | 84c61d9 | 2014-08-01 11:13:30 +0300 | [diff] [blame] | 1394 | bool mgmt_powering_down(struct hci_dev *hdev); |
Marcel Holtmann | 53ac6ab | 2014-03-09 23:38:42 -0700 | [diff] [blame] | 1395 | void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent); |
Johan Hedberg | 95fbac8 | 2014-02-19 15:18:31 +0200 | [diff] [blame] | 1396 | void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk); |
Marcel Holtmann | 53ac6ab | 2014-03-09 23:38:42 -0700 | [diff] [blame] | 1397 | void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk, |
| 1398 | bool persistent); |
Andre Guedes | ffb5a827 | 2014-07-01 18:10:11 -0300 | [diff] [blame] | 1399 | void mgmt_new_conn_param(struct hci_dev *hdev, bdaddr_t *bdaddr, |
Johan Hedberg | f4869e2 | 2014-07-02 17:37:32 +0300 | [diff] [blame] | 1400 | u8 bdaddr_type, u8 store_hint, u16 min_interval, |
| 1401 | u16 max_interval, u16 latency, u16 timeout); |
Marcel Holtmann | 5976e60 | 2013-10-06 04:08:14 -0700 | [diff] [blame] | 1402 | void mgmt_reenable_advertising(struct hci_dev *hdev); |
Johan Hedberg | f4a407b | 2014-02-18 21:41:34 +0200 | [diff] [blame] | 1403 | void mgmt_smp_complete(struct hci_conn *conn, bool complete); |
Vinicius Costa Gomes | 346af67 | 2012-02-02 21:08:02 -0300 | [diff] [blame] | 1404 | |
Johan Hedberg | 7d6ca69 | 2014-07-02 17:37:31 +0300 | [diff] [blame] | 1405 | u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, |
| 1406 | u16 to_multiplier); |
Marcel Holtmann | fe39c7b | 2014-02-27 16:00:28 -0800 | [diff] [blame] | 1407 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand, |
Vinicius Costa Gomes | a7a595f | 2011-06-09 18:50:47 -0300 | [diff] [blame] | 1408 | __u8 ltk[16]); |
Andre Guedes | 2519a1f | 2011-11-07 11:45:24 -0300 | [diff] [blame] | 1409 | |
Johan Hedberg | a1f4c31 | 2014-02-27 14:05:41 +0200 | [diff] [blame] | 1410 | void hci_copy_identity_address(struct hci_dev *hdev, bdaddr_t *bdaddr, |
| 1411 | u8 *bdaddr_type); |
Johan Hedberg | ebd3a74 | 2014-02-23 19:42:21 +0200 | [diff] [blame] | 1412 | |
Frédéric Dalleau | 5d4d62f | 2013-08-19 14:23:57 +0200 | [diff] [blame] | 1413 | #define SCO_AIRMODE_MASK 0x0003 |
| 1414 | #define SCO_AIRMODE_CVSD 0x0000 |
| 1415 | #define SCO_AIRMODE_TRANSP 0x0003 |
| 1416 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | #endif /* __HCI_CORE_H */ |