hci.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. /*
  2. BlueZ - Bluetooth protocol stack for Linux
  3. Copyright (C) 2000-2001 Qualcomm Incorporated
  4. Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License version 2 as
  7. published by the Free Software Foundation;
  8. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
  11. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
  12. CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
  13. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
  17. COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
  18. SOFTWARE IS DISCLAIMED.
  19. */
  20. #ifndef __HCI_H
  21. #define __HCI_H
  22. #define HCI_MAX_ACL_SIZE 1024
  23. #define HCI_MAX_SCO_SIZE 255
  24. #define HCI_MAX_EVENT_SIZE 260
  25. #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4)
  26. #define HCI_LINK_KEY_SIZE 16
  27. #define HCI_AMP_LINK_KEY_SIZE (2 * HCI_LINK_KEY_SIZE)
  28. /* HCI dev events */
  29. #define HCI_DEV_REG 1
  30. #define HCI_DEV_UNREG 2
  31. #define HCI_DEV_UP 3
  32. #define HCI_DEV_DOWN 4
  33. #define HCI_DEV_SUSPEND 5
  34. #define HCI_DEV_RESUME 6
  35. /* HCI notify events */
  36. #define HCI_NOTIFY_CONN_ADD 1
  37. #define HCI_NOTIFY_CONN_DEL 2
  38. #define HCI_NOTIFY_VOICE_SETTING 3
  39. /* HCI bus types */
  40. #define HCI_VIRTUAL 0
  41. #define HCI_USB 1
  42. #define HCI_PCCARD 2
  43. #define HCI_UART 3
  44. #define HCI_RS232 4
  45. #define HCI_PCI 5
  46. #define HCI_SDIO 6
  47. /* HCI controller types */
  48. #define HCI_BREDR 0x00
  49. #define HCI_AMP 0x01
  50. /* First BR/EDR Controller shall have ID = 0 */
  51. #define HCI_BREDR_ID 0
  52. /* AMP controller status */
  53. #define AMP_CTRL_POWERED_DOWN 0x00
  54. #define AMP_CTRL_BLUETOOTH_ONLY 0x01
  55. #define AMP_CTRL_NO_CAPACITY 0x02
  56. #define AMP_CTRL_LOW_CAPACITY 0x03
  57. #define AMP_CTRL_MEDIUM_CAPACITY 0x04
  58. #define AMP_CTRL_HIGH_CAPACITY 0x05
  59. #define AMP_CTRL_FULL_CAPACITY 0x06
  60. /* HCI device quirks */
  61. enum {
  62. HCI_QUIRK_RESET_ON_CLOSE,
  63. HCI_QUIRK_RAW_DEVICE,
  64. HCI_QUIRK_FIXUP_BUFFER_SIZE
  65. };
  66. /* HCI device flags */
  67. enum {
  68. HCI_UP,
  69. HCI_INIT,
  70. HCI_RUNNING,
  71. HCI_PSCAN,
  72. HCI_ISCAN,
  73. HCI_AUTH,
  74. HCI_ENCRYPT,
  75. HCI_INQUIRY,
  76. HCI_RAW,
  77. HCI_RESET,
  78. };
  79. /*
  80. * BR/EDR and/or LE controller flags: the flags defined here should represent
  81. * states from the controller.
  82. */
  83. enum {
  84. HCI_SETUP,
  85. HCI_AUTO_OFF,
  86. HCI_MGMT,
  87. HCI_PAIRABLE,
  88. HCI_SERVICE_CACHE,
  89. HCI_LINK_KEYS,
  90. HCI_DEBUG_KEYS,
  91. HCI_UNREGISTER,
  92. HCI_LE_SCAN,
  93. HCI_SSP_ENABLED,
  94. HCI_HS_ENABLED,
  95. HCI_LE_ENABLED,
  96. HCI_CONNECTABLE,
  97. HCI_DISCOVERABLE,
  98. HCI_LINK_SECURITY,
  99. HCI_PENDING_CLASS,
  100. HCI_PERIODIC_INQ,
  101. };
  102. /* HCI ioctl defines */
  103. #define HCIDEVUP _IOW('H', 201, int)
  104. #define HCIDEVDOWN _IOW('H', 202, int)
  105. #define HCIDEVRESET _IOW('H', 203, int)
  106. #define HCIDEVRESTAT _IOW('H', 204, int)
  107. #define HCIGETDEVLIST _IOR('H', 210, int)
  108. #define HCIGETDEVINFO _IOR('H', 211, int)
  109. #define HCIGETCONNLIST _IOR('H', 212, int)
  110. #define HCIGETCONNINFO _IOR('H', 213, int)
  111. #define HCIGETAUTHINFO _IOR('H', 215, int)
  112. #define HCISETRAW _IOW('H', 220, int)
  113. #define HCISETSCAN _IOW('H', 221, int)
  114. #define HCISETAUTH _IOW('H', 222, int)
  115. #define HCISETENCRYPT _IOW('H', 223, int)
  116. #define HCISETPTYPE _IOW('H', 224, int)
  117. #define HCISETLINKPOL _IOW('H', 225, int)
  118. #define HCISETLINKMODE _IOW('H', 226, int)
  119. #define HCISETACLMTU _IOW('H', 227, int)
  120. #define HCISETSCOMTU _IOW('H', 228, int)
  121. #define HCIBLOCKADDR _IOW('H', 230, int)
  122. #define HCIUNBLOCKADDR _IOW('H', 231, int)
  123. #define HCIINQUIRY _IOR('H', 240, int)
  124. /* HCI timeouts */
  125. #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  126. #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
  127. #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
  128. #define HCI_CMD_TIMEOUT msecs_to_jiffies(1000) /* 1 second */
  129. #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
  130. #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  131. /* HCI data types */
  132. #define HCI_COMMAND_PKT 0x01
  133. #define HCI_ACLDATA_PKT 0x02
  134. #define HCI_SCODATA_PKT 0x03
  135. #define HCI_EVENT_PKT 0x04
  136. #define HCI_VENDOR_PKT 0xff
  137. /* HCI packet types */
  138. #define HCI_DM1 0x0008
  139. #define HCI_DM3 0x0400
  140. #define HCI_DM5 0x4000
  141. #define HCI_DH1 0x0010
  142. #define HCI_DH3 0x0800
  143. #define HCI_DH5 0x8000
  144. #define HCI_HV1 0x0020
  145. #define HCI_HV2 0x0040
  146. #define HCI_HV3 0x0080
  147. #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
  148. #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
  149. /* eSCO packet types */
  150. #define ESCO_HV1 0x0001
  151. #define ESCO_HV2 0x0002
  152. #define ESCO_HV3 0x0004
  153. #define ESCO_EV3 0x0008
  154. #define ESCO_EV4 0x0010
  155. #define ESCO_EV5 0x0020
  156. #define ESCO_2EV3 0x0040
  157. #define ESCO_3EV3 0x0080
  158. #define ESCO_2EV5 0x0100
  159. #define ESCO_3EV5 0x0200
  160. #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
  161. #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
  162. /* ACL flags */
  163. #define ACL_START_NO_FLUSH 0x00
  164. #define ACL_CONT 0x01
  165. #define ACL_START 0x02
  166. #define ACL_ACTIVE_BCAST 0x04
  167. #define ACL_PICO_BCAST 0x08
  168. /* Baseband links */
  169. #define SCO_LINK 0x00
  170. #define ACL_LINK 0x01
  171. #define ESCO_LINK 0x02
  172. /* Low Energy links do not have defined link type. Use invented one */
  173. #define LE_LINK 0x80
  174. /* LMP features */
  175. #define LMP_3SLOT 0x01
  176. #define LMP_5SLOT 0x02
  177. #define LMP_ENCRYPT 0x04
  178. #define LMP_SOFFSET 0x08
  179. #define LMP_TACCURACY 0x10
  180. #define LMP_RSWITCH 0x20
  181. #define LMP_HOLD 0x40
  182. #define LMP_SNIFF 0x80
  183. #define LMP_PARK 0x01
  184. #define LMP_RSSI 0x02
  185. #define LMP_QUALITY 0x04
  186. #define LMP_SCO 0x08
  187. #define LMP_HV2 0x10
  188. #define LMP_HV3 0x20
  189. #define LMP_ULAW 0x40
  190. #define LMP_ALAW 0x80
  191. #define LMP_CVSD 0x01
  192. #define LMP_PSCHEME 0x02
  193. #define LMP_PCONTROL 0x04
  194. #define LMP_RSSI_INQ 0x40
  195. #define LMP_ESCO 0x80
  196. #define LMP_EV4 0x01
  197. #define LMP_EV5 0x02
  198. #define LMP_NO_BREDR 0x20
  199. #define LMP_LE 0x40
  200. #define LMP_SNIFF_SUBR 0x02
  201. #define LMP_PAUSE_ENC 0x04
  202. #define LMP_EDR_ESCO_2M 0x20
  203. #define LMP_EDR_ESCO_3M 0x40
  204. #define LMP_EDR_3S_ESCO 0x80
  205. #define LMP_EXT_INQ 0x01
  206. #define LMP_SIMUL_LE_BR 0x02
  207. #define LMP_SIMPLE_PAIR 0x08
  208. #define LMP_NO_FLUSH 0x40
  209. #define LMP_LSTO 0x01
  210. #define LMP_INQ_TX_PWR 0x02
  211. #define LMP_EXTFEATURES 0x80
  212. /* Extended LMP features */
  213. #define LMP_HOST_SSP 0x01
  214. #define LMP_HOST_LE 0x02
  215. #define LMP_HOST_LE_BREDR 0x04
  216. /* Connection modes */
  217. #define HCI_CM_ACTIVE 0x0000
  218. #define HCI_CM_HOLD 0x0001
  219. #define HCI_CM_SNIFF 0x0002
  220. #define HCI_CM_PARK 0x0003
  221. /* Link policies */
  222. #define HCI_LP_RSWITCH 0x0001
  223. #define HCI_LP_HOLD 0x0002
  224. #define HCI_LP_SNIFF 0x0004
  225. #define HCI_LP_PARK 0x0008
  226. /* Link modes */
  227. #define HCI_LM_ACCEPT 0x8000
  228. #define HCI_LM_MASTER 0x0001
  229. #define HCI_LM_AUTH 0x0002
  230. #define HCI_LM_ENCRYPT 0x0004
  231. #define HCI_LM_TRUSTED 0x0008
  232. #define HCI_LM_RELIABLE 0x0010
  233. #define HCI_LM_SECURE 0x0020
  234. /* Authentication types */
  235. #define HCI_AT_NO_BONDING 0x00
  236. #define HCI_AT_NO_BONDING_MITM 0x01
  237. #define HCI_AT_DEDICATED_BONDING 0x02
  238. #define HCI_AT_DEDICATED_BONDING_MITM 0x03
  239. #define HCI_AT_GENERAL_BONDING 0x04
  240. #define HCI_AT_GENERAL_BONDING_MITM 0x05
  241. /* Link Key types */
  242. #define HCI_LK_COMBINATION 0x00
  243. #define HCI_LK_LOCAL_UNIT 0x01
  244. #define HCI_LK_REMOTE_UNIT 0x02
  245. #define HCI_LK_DEBUG_COMBINATION 0x03
  246. #define HCI_LK_UNAUTH_COMBINATION 0x04
  247. #define HCI_LK_AUTH_COMBINATION 0x05
  248. #define HCI_LK_CHANGED_COMBINATION 0x06
  249. /* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */
  250. #define HCI_SMP_STK 0x80
  251. #define HCI_SMP_STK_SLAVE 0x81
  252. #define HCI_SMP_LTK 0x82
  253. #define HCI_SMP_LTK_SLAVE 0x83
  254. /* ---- HCI Error Codes ---- */
  255. #define HCI_ERROR_AUTH_FAILURE 0x05
  256. #define HCI_ERROR_CONNECTION_TIMEOUT 0x08
  257. #define HCI_ERROR_REJ_BAD_ADDR 0x0f
  258. #define HCI_ERROR_REMOTE_USER_TERM 0x13
  259. #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
  260. #define HCI_ERROR_REMOTE_POWER_OFF 0x15
  261. #define HCI_ERROR_LOCAL_HOST_TERM 0x16
  262. #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
  263. /* Flow control modes */
  264. #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
  265. #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
  266. /* Extended Inquiry Response field types */
  267. #define EIR_FLAGS 0x01 /* flags */
  268. #define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
  269. #define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
  270. #define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
  271. #define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
  272. #define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
  273. #define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
  274. #define EIR_NAME_SHORT 0x08 /* shortened local name */
  275. #define EIR_NAME_COMPLETE 0x09 /* complete local name */
  276. #define EIR_TX_POWER 0x0A /* transmit power level */
  277. #define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
  278. #define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */
  279. #define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
  280. #define EIR_DEVICE_ID 0x10 /* device ID */
  281. /* ----- HCI Commands ---- */
  282. #define HCI_OP_NOP 0x0000
  283. #define HCI_OP_INQUIRY 0x0401
  284. struct hci_cp_inquiry {
  285. __u8 lap[3];
  286. __u8 length;
  287. __u8 num_rsp;
  288. } __packed;
  289. #define HCI_OP_INQUIRY_CANCEL 0x0402
  290. #define HCI_OP_PERIODIC_INQ 0x0403
  291. #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
  292. #define HCI_OP_CREATE_CONN 0x0405
  293. struct hci_cp_create_conn {
  294. bdaddr_t bdaddr;
  295. __le16 pkt_type;
  296. __u8 pscan_rep_mode;
  297. __u8 pscan_mode;
  298. __le16 clock_offset;
  299. __u8 role_switch;
  300. } __packed;
  301. #define HCI_OP_DISCONNECT 0x0406
  302. struct hci_cp_disconnect {
  303. __le16 handle;
  304. __u8 reason;
  305. } __packed;
  306. #define HCI_OP_ADD_SCO 0x0407
  307. struct hci_cp_add_sco {
  308. __le16 handle;
  309. __le16 pkt_type;
  310. } __packed;
  311. #define HCI_OP_CREATE_CONN_CANCEL 0x0408
  312. struct hci_cp_create_conn_cancel {
  313. bdaddr_t bdaddr;
  314. } __packed;
  315. #define HCI_OP_ACCEPT_CONN_REQ 0x0409
  316. struct hci_cp_accept_conn_req {
  317. bdaddr_t bdaddr;
  318. __u8 role;
  319. } __packed;
  320. #define HCI_OP_REJECT_CONN_REQ 0x040a
  321. struct hci_cp_reject_conn_req {
  322. bdaddr_t bdaddr;
  323. __u8 reason;
  324. } __packed;
  325. #define HCI_OP_LINK_KEY_REPLY 0x040b
  326. struct hci_cp_link_key_reply {
  327. bdaddr_t bdaddr;
  328. __u8 link_key[HCI_LINK_KEY_SIZE];
  329. } __packed;
  330. #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
  331. struct hci_cp_link_key_neg_reply {
  332. bdaddr_t bdaddr;
  333. } __packed;
  334. #define HCI_OP_PIN_CODE_REPLY 0x040d
  335. struct hci_cp_pin_code_reply {
  336. bdaddr_t bdaddr;
  337. __u8 pin_len;
  338. __u8 pin_code[16];
  339. } __packed;
  340. struct hci_rp_pin_code_reply {
  341. __u8 status;
  342. bdaddr_t bdaddr;
  343. } __packed;
  344. #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
  345. struct hci_cp_pin_code_neg_reply {
  346. bdaddr_t bdaddr;
  347. } __packed;
  348. struct hci_rp_pin_code_neg_reply {
  349. __u8 status;
  350. bdaddr_t bdaddr;
  351. } __packed;
  352. #define HCI_OP_CHANGE_CONN_PTYPE 0x040f
  353. struct hci_cp_change_conn_ptype {
  354. __le16 handle;
  355. __le16 pkt_type;
  356. } __packed;
  357. #define HCI_OP_AUTH_REQUESTED 0x0411
  358. struct hci_cp_auth_requested {
  359. __le16 handle;
  360. } __packed;
  361. #define HCI_OP_SET_CONN_ENCRYPT 0x0413
  362. struct hci_cp_set_conn_encrypt {
  363. __le16 handle;
  364. __u8 encrypt;
  365. } __packed;
  366. #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
  367. struct hci_cp_change_conn_link_key {
  368. __le16 handle;
  369. } __packed;
  370. #define HCI_OP_REMOTE_NAME_REQ 0x0419
  371. struct hci_cp_remote_name_req {
  372. bdaddr_t bdaddr;
  373. __u8 pscan_rep_mode;
  374. __u8 pscan_mode;
  375. __le16 clock_offset;
  376. } __packed;
  377. #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
  378. struct hci_cp_remote_name_req_cancel {
  379. bdaddr_t bdaddr;
  380. } __packed;
  381. #define HCI_OP_READ_REMOTE_FEATURES 0x041b
  382. struct hci_cp_read_remote_features {
  383. __le16 handle;
  384. } __packed;
  385. #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
  386. struct hci_cp_read_remote_ext_features {
  387. __le16 handle;
  388. __u8 page;
  389. } __packed;
  390. #define HCI_OP_READ_REMOTE_VERSION 0x041d
  391. struct hci_cp_read_remote_version {
  392. __le16 handle;
  393. } __packed;
  394. #define HCI_OP_SETUP_SYNC_CONN 0x0428
  395. struct hci_cp_setup_sync_conn {
  396. __le16 handle;
  397. __le32 tx_bandwidth;
  398. __le32 rx_bandwidth;
  399. __le16 max_latency;
  400. __le16 voice_setting;
  401. __u8 retrans_effort;
  402. __le16 pkt_type;
  403. } __packed;
  404. #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
  405. struct hci_cp_accept_sync_conn_req {
  406. bdaddr_t bdaddr;
  407. __le32 tx_bandwidth;
  408. __le32 rx_bandwidth;
  409. __le16 max_latency;
  410. __le16 content_format;
  411. __u8 retrans_effort;
  412. __le16 pkt_type;
  413. } __packed;
  414. #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
  415. struct hci_cp_reject_sync_conn_req {
  416. bdaddr_t bdaddr;
  417. __u8 reason;
  418. } __packed;
  419. #define HCI_OP_IO_CAPABILITY_REPLY 0x042b
  420. struct hci_cp_io_capability_reply {
  421. bdaddr_t bdaddr;
  422. __u8 capability;
  423. __u8 oob_data;
  424. __u8 authentication;
  425. } __packed;
  426. #define HCI_OP_USER_CONFIRM_REPLY 0x042c
  427. struct hci_cp_user_confirm_reply {
  428. bdaddr_t bdaddr;
  429. } __packed;
  430. struct hci_rp_user_confirm_reply {
  431. __u8 status;
  432. bdaddr_t bdaddr;
  433. } __packed;
  434. #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
  435. #define HCI_OP_USER_PASSKEY_REPLY 0x042e
  436. struct hci_cp_user_passkey_reply {
  437. bdaddr_t bdaddr;
  438. __le32 passkey;
  439. } __packed;
  440. #define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f
  441. #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
  442. struct hci_cp_remote_oob_data_reply {
  443. bdaddr_t bdaddr;
  444. __u8 hash[16];
  445. __u8 randomizer[16];
  446. } __packed;
  447. #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
  448. struct hci_cp_remote_oob_data_neg_reply {
  449. bdaddr_t bdaddr;
  450. } __packed;
  451. #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
  452. struct hci_cp_io_capability_neg_reply {
  453. bdaddr_t bdaddr;
  454. __u8 reason;
  455. } __packed;
  456. #define HCI_OP_CREATE_PHY_LINK 0x0435
  457. struct hci_cp_create_phy_link {
  458. __u8 phy_handle;
  459. __u8 key_len;
  460. __u8 key_type;
  461. __u8 key[HCI_AMP_LINK_KEY_SIZE];
  462. } __packed;
  463. #define HCI_OP_ACCEPT_PHY_LINK 0x0436
  464. struct hci_cp_accept_phy_link {
  465. __u8 phy_handle;
  466. __u8 key_len;
  467. __u8 key_type;
  468. __u8 key[HCI_AMP_LINK_KEY_SIZE];
  469. } __packed;
  470. #define HCI_OP_DISCONN_PHY_LINK 0x0437
  471. struct hci_cp_disconn_phy_link {
  472. __u8 phy_handle;
  473. __u8 reason;
  474. } __packed;
  475. #define HCI_OP_SNIFF_MODE 0x0803
  476. struct hci_cp_sniff_mode {
  477. __le16 handle;
  478. __le16 max_interval;
  479. __le16 min_interval;
  480. __le16 attempt;
  481. __le16 timeout;
  482. } __packed;
  483. #define HCI_OP_EXIT_SNIFF_MODE 0x0804
  484. struct hci_cp_exit_sniff_mode {
  485. __le16 handle;
  486. } __packed;
  487. #define HCI_OP_ROLE_DISCOVERY 0x0809
  488. struct hci_cp_role_discovery {
  489. __le16 handle;
  490. } __packed;
  491. struct hci_rp_role_discovery {
  492. __u8 status;
  493. __le16 handle;
  494. __u8 role;
  495. } __packed;
  496. #define HCI_OP_SWITCH_ROLE 0x080b
  497. struct hci_cp_switch_role {
  498. bdaddr_t bdaddr;
  499. __u8 role;
  500. } __packed;
  501. #define HCI_OP_READ_LINK_POLICY 0x080c
  502. struct hci_cp_read_link_policy {
  503. __le16 handle;
  504. } __packed;
  505. struct hci_rp_read_link_policy {
  506. __u8 status;
  507. __le16 handle;
  508. __le16 policy;
  509. } __packed;
  510. #define HCI_OP_WRITE_LINK_POLICY 0x080d
  511. struct hci_cp_write_link_policy {
  512. __le16 handle;
  513. __le16 policy;
  514. } __packed;
  515. struct hci_rp_write_link_policy {
  516. __u8 status;
  517. __le16 handle;
  518. } __packed;
  519. #define HCI_OP_READ_DEF_LINK_POLICY 0x080e
  520. struct hci_rp_read_def_link_policy {
  521. __u8 status;
  522. __le16 policy;
  523. } __packed;
  524. #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
  525. struct hci_cp_write_def_link_policy {
  526. __le16 policy;
  527. } __packed;
  528. #define HCI_OP_SNIFF_SUBRATE 0x0811
  529. struct hci_cp_sniff_subrate {
  530. __le16 handle;
  531. __le16 max_latency;
  532. __le16 min_remote_timeout;
  533. __le16 min_local_timeout;
  534. } __packed;
  535. #define HCI_OP_SET_EVENT_MASK 0x0c01
  536. struct hci_cp_set_event_mask {
  537. __u8 mask[8];
  538. } __packed;
  539. #define HCI_OP_RESET 0x0c03
  540. #define HCI_OP_SET_EVENT_FLT 0x0c05
  541. struct hci_cp_set_event_flt {
  542. __u8 flt_type;
  543. __u8 cond_type;
  544. __u8 condition[0];
  545. } __packed;
  546. /* Filter types */
  547. #define HCI_FLT_CLEAR_ALL 0x00
  548. #define HCI_FLT_INQ_RESULT 0x01
  549. #define HCI_FLT_CONN_SETUP 0x02
  550. /* CONN_SETUP Condition types */
  551. #define HCI_CONN_SETUP_ALLOW_ALL 0x00
  552. #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
  553. #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
  554. /* CONN_SETUP Conditions */
  555. #define HCI_CONN_SETUP_AUTO_OFF 0x01
  556. #define HCI_CONN_SETUP_AUTO_ON 0x02
  557. #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
  558. struct hci_cp_delete_stored_link_key {
  559. bdaddr_t bdaddr;
  560. __u8 delete_all;
  561. } __packed;
  562. #define HCI_MAX_NAME_LENGTH 248
  563. #define HCI_OP_WRITE_LOCAL_NAME 0x0c13
  564. struct hci_cp_write_local_name {
  565. __u8 name[HCI_MAX_NAME_LENGTH];
  566. } __packed;
  567. #define HCI_OP_READ_LOCAL_NAME 0x0c14
  568. struct hci_rp_read_local_name {
  569. __u8 status;
  570. __u8 name[HCI_MAX_NAME_LENGTH];
  571. } __packed;
  572. #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
  573. #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
  574. #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
  575. #define SCAN_DISABLED 0x00
  576. #define SCAN_INQUIRY 0x01
  577. #define SCAN_PAGE 0x02
  578. #define HCI_OP_READ_AUTH_ENABLE 0x0c1f
  579. #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
  580. #define AUTH_DISABLED 0x00
  581. #define AUTH_ENABLED 0x01
  582. #define HCI_OP_READ_ENCRYPT_MODE 0x0c21
  583. #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
  584. #define ENCRYPT_DISABLED 0x00
  585. #define ENCRYPT_P2P 0x01
  586. #define ENCRYPT_BOTH 0x02
  587. #define HCI_OP_READ_CLASS_OF_DEV 0x0c23
  588. struct hci_rp_read_class_of_dev {
  589. __u8 status;
  590. __u8 dev_class[3];
  591. } __packed;
  592. #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
  593. struct hci_cp_write_class_of_dev {
  594. __u8 dev_class[3];
  595. } __packed;
  596. #define HCI_OP_READ_VOICE_SETTING 0x0c25
  597. struct hci_rp_read_voice_setting {
  598. __u8 status;
  599. __le16 voice_setting;
  600. } __packed;
  601. #define HCI_OP_WRITE_VOICE_SETTING 0x0c26
  602. struct hci_cp_write_voice_setting {
  603. __le16 voice_setting;
  604. } __packed;
  605. #define HCI_OP_HOST_BUFFER_SIZE 0x0c33
  606. struct hci_cp_host_buffer_size {
  607. __le16 acl_mtu;
  608. __u8 sco_mtu;
  609. __le16 acl_max_pkt;
  610. __le16 sco_max_pkt;
  611. } __packed;
  612. #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
  613. #define HCI_MAX_EIR_LENGTH 240
  614. #define HCI_OP_WRITE_EIR 0x0c52
  615. struct hci_cp_write_eir {
  616. __u8 fec;
  617. __u8 data[HCI_MAX_EIR_LENGTH];
  618. } __packed;
  619. #define HCI_OP_READ_SSP_MODE 0x0c55
  620. struct hci_rp_read_ssp_mode {
  621. __u8 status;
  622. __u8 mode;
  623. } __packed;
  624. #define HCI_OP_WRITE_SSP_MODE 0x0c56
  625. struct hci_cp_write_ssp_mode {
  626. __u8 mode;
  627. } __packed;
  628. #define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
  629. struct hci_rp_read_local_oob_data {
  630. __u8 status;
  631. __u8 hash[16];
  632. __u8 randomizer[16];
  633. } __packed;
  634. #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
  635. struct hci_rp_read_inq_rsp_tx_power {
  636. __u8 status;
  637. __s8 tx_power;
  638. } __packed;
  639. #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
  640. struct hci_rp_read_flow_control_mode {
  641. __u8 status;
  642. __u8 mode;
  643. } __packed;
  644. #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
  645. struct hci_cp_write_le_host_supported {
  646. __u8 le;
  647. __u8 simul;
  648. } __packed;
  649. #define HCI_OP_READ_LOCAL_VERSION 0x1001
  650. struct hci_rp_read_local_version {
  651. __u8 status;
  652. __u8 hci_ver;
  653. __le16 hci_rev;
  654. __u8 lmp_ver;
  655. __le16 manufacturer;
  656. __le16 lmp_subver;
  657. } __packed;
  658. #define HCI_OP_READ_LOCAL_COMMANDS 0x1002
  659. struct hci_rp_read_local_commands {
  660. __u8 status;
  661. __u8 commands[64];
  662. } __packed;
  663. #define HCI_OP_READ_LOCAL_FEATURES 0x1003
  664. struct hci_rp_read_local_features {
  665. __u8 status;
  666. __u8 features[8];
  667. } __packed;
  668. #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
  669. struct hci_cp_read_local_ext_features {
  670. __u8 page;
  671. } __packed;
  672. struct hci_rp_read_local_ext_features {
  673. __u8 status;
  674. __u8 page;
  675. __u8 max_page;
  676. __u8 features[8];
  677. } __packed;
  678. #define HCI_OP_READ_BUFFER_SIZE 0x1005
  679. struct hci_rp_read_buffer_size {
  680. __u8 status;
  681. __le16 acl_mtu;
  682. __u8 sco_mtu;
  683. __le16 acl_max_pkt;
  684. __le16 sco_max_pkt;
  685. } __packed;
  686. #define HCI_OP_READ_BD_ADDR 0x1009
  687. struct hci_rp_read_bd_addr {
  688. __u8 status;
  689. bdaddr_t bdaddr;
  690. } __packed;
  691. #define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
  692. struct hci_rp_read_data_block_size {
  693. __u8 status;
  694. __le16 max_acl_len;
  695. __le16 block_len;
  696. __le16 num_blocks;
  697. } __packed;
  698. #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
  699. struct hci_cp_write_page_scan_activity {
  700. __le16 interval;
  701. __le16 window;
  702. } __packed;
  703. #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
  704. #define PAGE_SCAN_TYPE_STANDARD 0x00
  705. #define PAGE_SCAN_TYPE_INTERLACED 0x01
  706. #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409
  707. struct hci_rp_read_local_amp_info {
  708. __u8 status;
  709. __u8 amp_status;
  710. __le32 total_bw;
  711. __le32 max_bw;
  712. __le32 min_latency;
  713. __le32 max_pdu;
  714. __u8 amp_type;
  715. __le16 pal_cap;
  716. __le16 max_assoc_size;
  717. __le32 max_flush_to;
  718. __le32 be_flush_to;
  719. } __packed;
  720. #define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a
  721. struct hci_cp_read_local_amp_assoc {
  722. __u8 phy_handle;
  723. __le16 len_so_far;
  724. __le16 max_len;
  725. } __packed;
  726. struct hci_rp_read_local_amp_assoc {
  727. __u8 status;
  728. __u8 phy_handle;
  729. __le16 rem_len;
  730. __u8 frag[0];
  731. } __packed;
  732. #define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b
  733. struct hci_cp_write_remote_amp_assoc {
  734. __u8 phy_handle;
  735. __le16 len_so_far;
  736. __le16 rem_len;
  737. __u8 frag[0];
  738. } __packed;
  739. struct hci_rp_write_remote_amp_assoc {
  740. __u8 status;
  741. __u8 phy_handle;
  742. } __packed;
  743. #define HCI_OP_LE_SET_EVENT_MASK 0x2001
  744. struct hci_cp_le_set_event_mask {
  745. __u8 mask[8];
  746. } __packed;
  747. #define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
  748. struct hci_rp_le_read_buffer_size {
  749. __u8 status;
  750. __le16 le_mtu;
  751. __u8 le_max_pkt;
  752. } __packed;
  753. #define HCI_OP_LE_SET_SCAN_PARAM 0x200b
  754. struct hci_cp_le_set_scan_param {
  755. __u8 type;
  756. __le16 interval;
  757. __le16 window;
  758. __u8 own_address_type;
  759. __u8 filter_policy;
  760. } __packed;
  761. #define LE_SCANNING_DISABLED 0x00
  762. #define LE_SCANNING_ENABLED 0x01
  763. #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
  764. struct hci_cp_le_set_scan_enable {
  765. __u8 enable;
  766. __u8 filter_dup;
  767. } __packed;
  768. #define HCI_OP_LE_CREATE_CONN 0x200d
  769. struct hci_cp_le_create_conn {
  770. __le16 scan_interval;
  771. __le16 scan_window;
  772. __u8 filter_policy;
  773. __u8 peer_addr_type;
  774. bdaddr_t peer_addr;
  775. __u8 own_address_type;
  776. __le16 conn_interval_min;
  777. __le16 conn_interval_max;
  778. __le16 conn_latency;
  779. __le16 supervision_timeout;
  780. __le16 min_ce_len;
  781. __le16 max_ce_len;
  782. } __packed;
  783. #define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
  784. #define HCI_OP_LE_CONN_UPDATE 0x2013
  785. struct hci_cp_le_conn_update {
  786. __le16 handle;
  787. __le16 conn_interval_min;
  788. __le16 conn_interval_max;
  789. __le16 conn_latency;
  790. __le16 supervision_timeout;
  791. __le16 min_ce_len;
  792. __le16 max_ce_len;
  793. } __packed;
  794. #define HCI_OP_LE_START_ENC 0x2019
  795. struct hci_cp_le_start_enc {
  796. __le16 handle;
  797. __u8 rand[8];
  798. __le16 ediv;
  799. __u8 ltk[16];
  800. } __packed;
  801. #define HCI_OP_LE_LTK_REPLY 0x201a
  802. struct hci_cp_le_ltk_reply {
  803. __le16 handle;
  804. __u8 ltk[16];
  805. } __packed;
  806. struct hci_rp_le_ltk_reply {
  807. __u8 status;
  808. __le16 handle;
  809. } __packed;
  810. #define HCI_OP_LE_LTK_NEG_REPLY 0x201b
  811. struct hci_cp_le_ltk_neg_reply {
  812. __le16 handle;
  813. } __packed;
  814. struct hci_rp_le_ltk_neg_reply {
  815. __u8 status;
  816. __le16 handle;
  817. } __packed;
  818. /* ---- HCI Events ---- */
  819. #define HCI_EV_INQUIRY_COMPLETE 0x01
  820. #define HCI_EV_INQUIRY_RESULT 0x02
  821. struct inquiry_info {
  822. bdaddr_t bdaddr;
  823. __u8 pscan_rep_mode;
  824. __u8 pscan_period_mode;
  825. __u8 pscan_mode;
  826. __u8 dev_class[3];
  827. __le16 clock_offset;
  828. } __packed;
  829. #define HCI_EV_CONN_COMPLETE 0x03
  830. struct hci_ev_conn_complete {
  831. __u8 status;
  832. __le16 handle;
  833. bdaddr_t bdaddr;
  834. __u8 link_type;
  835. __u8 encr_mode;
  836. } __packed;
  837. #define HCI_EV_CONN_REQUEST 0x04
  838. struct hci_ev_conn_request {
  839. bdaddr_t bdaddr;
  840. __u8 dev_class[3];
  841. __u8 link_type;
  842. } __packed;
  843. #define HCI_EV_DISCONN_COMPLETE 0x05
  844. struct hci_ev_disconn_complete {
  845. __u8 status;
  846. __le16 handle;
  847. __u8 reason;
  848. } __packed;
  849. #define HCI_EV_AUTH_COMPLETE 0x06
  850. struct hci_ev_auth_complete {
  851. __u8 status;
  852. __le16 handle;
  853. } __packed;
  854. #define HCI_EV_REMOTE_NAME 0x07
  855. struct hci_ev_remote_name {
  856. __u8 status;
  857. bdaddr_t bdaddr;
  858. __u8 name[HCI_MAX_NAME_LENGTH];
  859. } __packed;
  860. #define HCI_EV_ENCRYPT_CHANGE 0x08
  861. struct hci_ev_encrypt_change {
  862. __u8 status;
  863. __le16 handle;
  864. __u8 encrypt;
  865. } __packed;
  866. #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
  867. struct hci_ev_change_link_key_complete {
  868. __u8 status;
  869. __le16 handle;
  870. } __packed;
  871. #define HCI_EV_REMOTE_FEATURES 0x0b
  872. struct hci_ev_remote_features {
  873. __u8 status;
  874. __le16 handle;
  875. __u8 features[8];
  876. } __packed;
  877. #define HCI_EV_REMOTE_VERSION 0x0c
  878. struct hci_ev_remote_version {
  879. __u8 status;
  880. __le16 handle;
  881. __u8 lmp_ver;
  882. __le16 manufacturer;
  883. __le16 lmp_subver;
  884. } __packed;
  885. #define HCI_EV_QOS_SETUP_COMPLETE 0x0d
  886. struct hci_qos {
  887. __u8 service_type;
  888. __u32 token_rate;
  889. __u32 peak_bandwidth;
  890. __u32 latency;
  891. __u32 delay_variation;
  892. } __packed;
  893. struct hci_ev_qos_setup_complete {
  894. __u8 status;
  895. __le16 handle;
  896. struct hci_qos qos;
  897. } __packed;
  898. #define HCI_EV_CMD_COMPLETE 0x0e
  899. struct hci_ev_cmd_complete {
  900. __u8 ncmd;
  901. __le16 opcode;
  902. } __packed;
  903. #define HCI_EV_CMD_STATUS 0x0f
  904. struct hci_ev_cmd_status {
  905. __u8 status;
  906. __u8 ncmd;
  907. __le16 opcode;
  908. } __packed;
  909. #define HCI_EV_ROLE_CHANGE 0x12
  910. struct hci_ev_role_change {
  911. __u8 status;
  912. bdaddr_t bdaddr;
  913. __u8 role;
  914. } __packed;
  915. #define HCI_EV_NUM_COMP_PKTS 0x13
  916. struct hci_comp_pkts_info {
  917. __le16 handle;
  918. __le16 count;
  919. } __packed;
  920. struct hci_ev_num_comp_pkts {
  921. __u8 num_hndl;
  922. struct hci_comp_pkts_info handles[0];
  923. } __packed;
  924. #define HCI_EV_MODE_CHANGE 0x14
  925. struct hci_ev_mode_change {
  926. __u8 status;
  927. __le16 handle;
  928. __u8 mode;
  929. __le16 interval;
  930. } __packed;
  931. #define HCI_EV_PIN_CODE_REQ 0x16
  932. struct hci_ev_pin_code_req {
  933. bdaddr_t bdaddr;
  934. } __packed;
  935. #define HCI_EV_LINK_KEY_REQ 0x17
  936. struct hci_ev_link_key_req {
  937. bdaddr_t bdaddr;
  938. } __packed;
  939. #define HCI_EV_LINK_KEY_NOTIFY 0x18
  940. struct hci_ev_link_key_notify {
  941. bdaddr_t bdaddr;
  942. __u8 link_key[HCI_LINK_KEY_SIZE];
  943. __u8 key_type;
  944. } __packed;
  945. #define HCI_EV_CLOCK_OFFSET 0x1c
  946. struct hci_ev_clock_offset {
  947. __u8 status;
  948. __le16 handle;
  949. __le16 clock_offset;
  950. } __packed;
  951. #define HCI_EV_PKT_TYPE_CHANGE 0x1d
  952. struct hci_ev_pkt_type_change {
  953. __u8 status;
  954. __le16 handle;
  955. __le16 pkt_type;
  956. } __packed;
  957. #define HCI_EV_PSCAN_REP_MODE 0x20
  958. struct hci_ev_pscan_rep_mode {
  959. bdaddr_t bdaddr;
  960. __u8 pscan_rep_mode;
  961. } __packed;
  962. #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
  963. struct inquiry_info_with_rssi {
  964. bdaddr_t bdaddr;
  965. __u8 pscan_rep_mode;
  966. __u8 pscan_period_mode;
  967. __u8 dev_class[3];
  968. __le16 clock_offset;
  969. __s8 rssi;
  970. } __packed;
  971. struct inquiry_info_with_rssi_and_pscan_mode {
  972. bdaddr_t bdaddr;
  973. __u8 pscan_rep_mode;
  974. __u8 pscan_period_mode;
  975. __u8 pscan_mode;
  976. __u8 dev_class[3];
  977. __le16 clock_offset;
  978. __s8 rssi;
  979. } __packed;
  980. #define HCI_EV_REMOTE_EXT_FEATURES 0x23
  981. struct hci_ev_remote_ext_features {
  982. __u8 status;
  983. __le16 handle;
  984. __u8 page;
  985. __u8 max_page;
  986. __u8 features[8];
  987. } __packed;
  988. #define HCI_EV_SYNC_CONN_COMPLETE 0x2c
  989. struct hci_ev_sync_conn_complete {
  990. __u8 status;
  991. __le16 handle;
  992. bdaddr_t bdaddr;
  993. __u8 link_type;
  994. __u8 tx_interval;
  995. __u8 retrans_window;
  996. __le16 rx_pkt_len;
  997. __le16 tx_pkt_len;
  998. __u8 air_mode;
  999. } __packed;
  1000. #define HCI_EV_SYNC_CONN_CHANGED 0x2d
  1001. struct hci_ev_sync_conn_changed {
  1002. __u8 status;
  1003. __le16 handle;
  1004. __u8 tx_interval;
  1005. __u8 retrans_window;
  1006. __le16 rx_pkt_len;
  1007. __le16 tx_pkt_len;
  1008. } __packed;
  1009. #define HCI_EV_SNIFF_SUBRATE 0x2e
  1010. struct hci_ev_sniff_subrate {
  1011. __u8 status;
  1012. __le16 handle;
  1013. __le16 max_tx_latency;
  1014. __le16 max_rx_latency;
  1015. __le16 max_remote_timeout;
  1016. __le16 max_local_timeout;
  1017. } __packed;
  1018. #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
  1019. struct extended_inquiry_info {
  1020. bdaddr_t bdaddr;
  1021. __u8 pscan_rep_mode;
  1022. __u8 pscan_period_mode;
  1023. __u8 dev_class[3];
  1024. __le16 clock_offset;
  1025. __s8 rssi;
  1026. __u8 data[240];
  1027. } __packed;
  1028. #define HCI_EV_KEY_REFRESH_COMPLETE 0x30
  1029. struct hci_ev_key_refresh_complete {
  1030. __u8 status;
  1031. __le16 handle;
  1032. } __packed;
  1033. #define HCI_EV_IO_CAPA_REQUEST 0x31
  1034. struct hci_ev_io_capa_request {
  1035. bdaddr_t bdaddr;
  1036. } __packed;
  1037. #define HCI_EV_IO_CAPA_REPLY 0x32
  1038. struct hci_ev_io_capa_reply {
  1039. bdaddr_t bdaddr;
  1040. __u8 capability;
  1041. __u8 oob_data;
  1042. __u8 authentication;
  1043. } __packed;
  1044. #define HCI_EV_USER_CONFIRM_REQUEST 0x33
  1045. struct hci_ev_user_confirm_req {
  1046. bdaddr_t bdaddr;
  1047. __le32 passkey;
  1048. } __packed;
  1049. #define HCI_EV_USER_PASSKEY_REQUEST 0x34
  1050. struct hci_ev_user_passkey_req {
  1051. bdaddr_t bdaddr;
  1052. } __packed;
  1053. #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
  1054. struct hci_ev_remote_oob_data_request {
  1055. bdaddr_t bdaddr;
  1056. } __packed;
  1057. #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
  1058. struct hci_ev_simple_pair_complete {
  1059. __u8 status;
  1060. bdaddr_t bdaddr;
  1061. } __packed;
  1062. #define HCI_EV_USER_PASSKEY_NOTIFY 0x3b
  1063. struct hci_ev_user_passkey_notify {
  1064. bdaddr_t bdaddr;
  1065. __le32 passkey;
  1066. } __packed;
  1067. #define HCI_KEYPRESS_STARTED 0
  1068. #define HCI_KEYPRESS_ENTERED 1
  1069. #define HCI_KEYPRESS_ERASED 2
  1070. #define HCI_KEYPRESS_CLEARED 3
  1071. #define HCI_KEYPRESS_COMPLETED 4
  1072. #define HCI_EV_KEYPRESS_NOTIFY 0x3c
  1073. struct hci_ev_keypress_notify {
  1074. bdaddr_t bdaddr;
  1075. __u8 type;
  1076. } __packed;
  1077. #define HCI_EV_REMOTE_HOST_FEATURES 0x3d
  1078. struct hci_ev_remote_host_features {
  1079. bdaddr_t bdaddr;
  1080. __u8 features[8];
  1081. } __packed;
  1082. #define HCI_EV_LE_META 0x3e
  1083. struct hci_ev_le_meta {
  1084. __u8 subevent;
  1085. } __packed;
  1086. #define HCI_EV_PHY_LINK_COMPLETE 0x40
  1087. struct hci_ev_phy_link_complete {
  1088. __u8 status;
  1089. __u8 phy_handle;
  1090. } __packed;
  1091. #define HCI_EV_CHANNEL_SELECTED 0x41
  1092. struct hci_ev_channel_selected {
  1093. __u8 phy_handle;
  1094. } __packed;
  1095. #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42
  1096. struct hci_ev_disconn_phy_link_complete {
  1097. __u8 status;
  1098. __u8 phy_handle;
  1099. __u8 reason;
  1100. } __packed;
  1101. #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45
  1102. struct hci_ev_logical_link_complete {
  1103. __u8 status;
  1104. __le16 handle;
  1105. __u8 phy_handle;
  1106. __u8 flow_spec_id;
  1107. } __packed;
  1108. #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46
  1109. struct hci_ev_disconn_logical_link_complete {
  1110. __u8 status;
  1111. __le16 handle;
  1112. __u8 reason;
  1113. } __packed;
  1114. #define HCI_EV_NUM_COMP_BLOCKS 0x48
  1115. struct hci_comp_blocks_info {
  1116. __le16 handle;
  1117. __le16 pkts;
  1118. __le16 blocks;
  1119. } __packed;
  1120. struct hci_ev_num_comp_blocks {
  1121. __le16 num_blocks;
  1122. __u8 num_hndl;
  1123. struct hci_comp_blocks_info handles[0];
  1124. } __packed;
  1125. /* Low energy meta events */
  1126. #define LE_CONN_ROLE_MASTER 0x00
  1127. #define HCI_EV_LE_CONN_COMPLETE 0x01
  1128. struct hci_ev_le_conn_complete {
  1129. __u8 status;
  1130. __le16 handle;
  1131. __u8 role;
  1132. __u8 bdaddr_type;
  1133. bdaddr_t bdaddr;
  1134. __le16 interval;
  1135. __le16 latency;
  1136. __le16 supervision_timeout;
  1137. __u8 clk_accurancy;
  1138. } __packed;
  1139. #define HCI_EV_LE_LTK_REQ 0x05
  1140. struct hci_ev_le_ltk_req {
  1141. __le16 handle;
  1142. __u8 random[8];
  1143. __le16 ediv;
  1144. } __packed;
  1145. /* Advertising report event types */
  1146. #define ADV_IND 0x00
  1147. #define ADV_DIRECT_IND 0x01
  1148. #define ADV_SCAN_IND 0x02
  1149. #define ADV_NONCONN_IND 0x03
  1150. #define ADV_SCAN_RSP 0x04
  1151. #define ADDR_LE_DEV_PUBLIC 0x00
  1152. #define ADDR_LE_DEV_RANDOM 0x01
  1153. #define HCI_EV_LE_ADVERTISING_REPORT 0x02
  1154. struct hci_ev_le_advertising_info {
  1155. __u8 evt_type;
  1156. __u8 bdaddr_type;
  1157. bdaddr_t bdaddr;
  1158. __u8 length;
  1159. __u8 data[0];
  1160. } __packed;
  1161. /* Internal events generated by Bluetooth stack */
  1162. #define HCI_EV_STACK_INTERNAL 0xfd
  1163. struct hci_ev_stack_internal {
  1164. __u16 type;
  1165. __u8 data[0];
  1166. } __packed;
  1167. #define HCI_EV_SI_DEVICE 0x01
  1168. struct hci_ev_si_device {
  1169. __u16 event;
  1170. __u16 dev_id;
  1171. } __packed;
  1172. #define HCI_EV_SI_SECURITY 0x02
  1173. struct hci_ev_si_security {
  1174. __u16 event;
  1175. __u16 proto;
  1176. __u16 subproto;
  1177. __u8 incoming;
  1178. } __packed;
  1179. /* ---- HCI Packet structures ---- */
  1180. #define HCI_COMMAND_HDR_SIZE 3
  1181. #define HCI_EVENT_HDR_SIZE 2
  1182. #define HCI_ACL_HDR_SIZE 4
  1183. #define HCI_SCO_HDR_SIZE 3
  1184. struct hci_command_hdr {
  1185. __le16 opcode; /* OCF & OGF */
  1186. __u8 plen;
  1187. } __packed;
  1188. struct hci_event_hdr {
  1189. __u8 evt;
  1190. __u8 plen;
  1191. } __packed;
  1192. struct hci_acl_hdr {
  1193. __le16 handle; /* Handle & Flags(PB, BC) */
  1194. __le16 dlen;
  1195. } __packed;
  1196. struct hci_sco_hdr {
  1197. __le16 handle;
  1198. __u8 dlen;
  1199. } __packed;
  1200. static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
  1201. {
  1202. return (struct hci_event_hdr *) skb->data;
  1203. }
  1204. static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
  1205. {
  1206. return (struct hci_acl_hdr *) skb->data;
  1207. }
  1208. static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
  1209. {
  1210. return (struct hci_sco_hdr *) skb->data;
  1211. }
  1212. /* Command opcode pack/unpack */
  1213. #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10)))
  1214. #define hci_opcode_ogf(op) (op >> 10)
  1215. #define hci_opcode_ocf(op) (op & 0x03ff)
  1216. /* ACL handle and flags pack/unpack */
  1217. #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12)))
  1218. #define hci_handle(h) (h & 0x0fff)
  1219. #define hci_flags(h) (h >> 12)
  1220. /* ---- HCI Sockets ---- */
  1221. /* Socket options */
  1222. #define HCI_DATA_DIR 1
  1223. #define HCI_FILTER 2
  1224. #define HCI_TIME_STAMP 3
  1225. /* CMSG flags */
  1226. #define HCI_CMSG_DIR 0x0001
  1227. #define HCI_CMSG_TSTAMP 0x0002
  1228. struct sockaddr_hci {
  1229. sa_family_t hci_family;
  1230. unsigned short hci_dev;
  1231. unsigned short hci_channel;
  1232. };
  1233. #define HCI_DEV_NONE 0xffff
  1234. #define HCI_CHANNEL_RAW 0
  1235. #define HCI_CHANNEL_MONITOR 2
  1236. #define HCI_CHANNEL_CONTROL 3
  1237. struct hci_filter {
  1238. unsigned long type_mask;
  1239. unsigned long event_mask[2];
  1240. __le16 opcode;
  1241. };
  1242. struct hci_ufilter {
  1243. __u32 type_mask;
  1244. __u32 event_mask[2];
  1245. __le16 opcode;
  1246. };
  1247. #define HCI_FLT_TYPE_BITS 31
  1248. #define HCI_FLT_EVENT_BITS 63
  1249. #define HCI_FLT_OGF_BITS 63
  1250. #define HCI_FLT_OCF_BITS 127
  1251. /* ---- HCI Ioctl requests structures ---- */
  1252. struct hci_dev_stats {
  1253. __u32 err_rx;
  1254. __u32 err_tx;
  1255. __u32 cmd_tx;
  1256. __u32 evt_rx;
  1257. __u32 acl_tx;
  1258. __u32 acl_rx;
  1259. __u32 sco_tx;
  1260. __u32 sco_rx;
  1261. __u32 byte_rx;
  1262. __u32 byte_tx;
  1263. };
  1264. struct hci_dev_info {
  1265. __u16 dev_id;
  1266. char name[8];
  1267. bdaddr_t bdaddr;
  1268. __u32 flags;
  1269. __u8 type;
  1270. __u8 features[8];
  1271. __u32 pkt_type;
  1272. __u32 link_policy;
  1273. __u32 link_mode;
  1274. __u16 acl_mtu;
  1275. __u16 acl_pkts;
  1276. __u16 sco_mtu;
  1277. __u16 sco_pkts;
  1278. struct hci_dev_stats stat;
  1279. };
  1280. struct hci_conn_info {
  1281. __u16 handle;
  1282. bdaddr_t bdaddr;
  1283. __u8 type;
  1284. __u8 out;
  1285. __u16 state;
  1286. __u32 link_mode;
  1287. };
  1288. struct hci_dev_req {
  1289. __u16 dev_id;
  1290. __u32 dev_opt;
  1291. };
  1292. struct hci_dev_list_req {
  1293. __u16 dev_num;
  1294. struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
  1295. };
  1296. struct hci_conn_list_req {
  1297. __u16 dev_id;
  1298. __u16 conn_num;
  1299. struct hci_conn_info conn_info[0];
  1300. };
  1301. struct hci_conn_info_req {
  1302. bdaddr_t bdaddr;
  1303. __u8 type;
  1304. struct hci_conn_info conn_info[0];
  1305. };
  1306. struct hci_auth_info_req {
  1307. bdaddr_t bdaddr;
  1308. __u8 type;
  1309. };
  1310. struct hci_inquiry_req {
  1311. __u16 dev_id;
  1312. __u16 flags;
  1313. __u8 lap[3];
  1314. __u8 length;
  1315. __u8 num_rsp;
  1316. };
  1317. #define IREQ_CACHE_FLUSH 0x0001
  1318. extern bool enable_hs;
  1319. #endif /* __HCI_H */