hci.h 33 KB

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