hci.h 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015
  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. #define HCI_MAX_AMP_ASSOC_SIZE 672
  29. #define HCI_MAX_CSB_DATA_SIZE 252
  30. /* HCI dev events */
  31. #define HCI_DEV_REG 1
  32. #define HCI_DEV_UNREG 2
  33. #define HCI_DEV_UP 3
  34. #define HCI_DEV_DOWN 4
  35. #define HCI_DEV_SUSPEND 5
  36. #define HCI_DEV_RESUME 6
  37. #define HCI_DEV_OPEN 7
  38. #define HCI_DEV_CLOSE 8
  39. #define HCI_DEV_SETUP 9
  40. /* HCI notify events */
  41. #define HCI_NOTIFY_CONN_ADD 1
  42. #define HCI_NOTIFY_CONN_DEL 2
  43. #define HCI_NOTIFY_VOICE_SETTING 3
  44. /* HCI bus types */
  45. #define HCI_VIRTUAL 0
  46. #define HCI_USB 1
  47. #define HCI_PCCARD 2
  48. #define HCI_UART 3
  49. #define HCI_RS232 4
  50. #define HCI_PCI 5
  51. #define HCI_SDIO 6
  52. /* HCI controller types */
  53. #define HCI_BREDR 0x00
  54. #define HCI_AMP 0x01
  55. /* First BR/EDR Controller shall have ID = 0 */
  56. #define AMP_ID_BREDR 0x00
  57. /* AMP controller types */
  58. #define AMP_TYPE_BREDR 0x00
  59. #define AMP_TYPE_80211 0x01
  60. /* AMP controller status */
  61. #define AMP_STATUS_POWERED_DOWN 0x00
  62. #define AMP_STATUS_BLUETOOTH_ONLY 0x01
  63. #define AMP_STATUS_NO_CAPACITY 0x02
  64. #define AMP_STATUS_LOW_CAPACITY 0x03
  65. #define AMP_STATUS_MEDIUM_CAPACITY 0x04
  66. #define AMP_STATUS_HIGH_CAPACITY 0x05
  67. #define AMP_STATUS_FULL_CAPACITY 0x06
  68. /* HCI device quirks */
  69. enum {
  70. /* When this quirk is set, the HCI Reset command is send when
  71. * closing the transport instead of when opening it.
  72. *
  73. * This quirk must be set before hci_register_dev is called.
  74. */
  75. HCI_QUIRK_RESET_ON_CLOSE,
  76. /* When this quirk is set, the device is turned into a raw-only
  77. * device and it will stay in unconfigured state.
  78. *
  79. * This quirk must be set before hci_register_dev is called.
  80. */
  81. HCI_QUIRK_RAW_DEVICE,
  82. /* When this quirk is set, the buffer sizes reported by
  83. * HCI Read Buffer Size command are corrected if invalid.
  84. *
  85. * This quirk must be set before hci_register_dev is called.
  86. */
  87. HCI_QUIRK_FIXUP_BUFFER_SIZE,
  88. /* When this quirk is set, then a controller that does not
  89. * indicate support for Inquiry Result with RSSI is assumed to
  90. * support it anyway. Some early Bluetooth 1.2 controllers had
  91. * wrongly configured local features that will require forcing
  92. * them to enable this mode. Getting RSSI information with the
  93. * inquiry responses is preferred since it allows for a better
  94. * user expierence.
  95. *
  96. * This quirk must be set before hci_register_dev is called.
  97. */
  98. HCI_QUIRK_FIXUP_INQUIRY_MODE,
  99. /* When this quirk is set, then the HCI Read Local Supported
  100. * Commands command is not supported. In general Bluetooth 1.2
  101. * and later controllers should support this command. However
  102. * some controllers indicate Bluetooth 1.2 support, but do
  103. * not support this command.
  104. *
  105. * This quirk must be set before hci_register_dev is called.
  106. */
  107. HCI_QUIRK_BROKEN_LOCAL_COMMANDS,
  108. /* When this quirk is set, then no stored link key handling
  109. * is performed. This is mainly due to the fact that the
  110. * HCI Delete Stored Link Key command is advertised, but
  111. * not supported.
  112. *
  113. * This quirk must be set before hci_register_dev is called.
  114. */
  115. HCI_QUIRK_BROKEN_STORED_LINK_KEY,
  116. /* When this quirk is set, an external configuration step
  117. * is required and will be indicated with the controller
  118. * configuation.
  119. *
  120. * This quirk can be set before hci_register_dev is called or
  121. * during the hdev->setup vendor callback.
  122. */
  123. HCI_QUIRK_EXTERNAL_CONFIG,
  124. /* When this quirk is set, the public Bluetooth address
  125. * initially reported by HCI Read BD Address command
  126. * is considered invalid. Controller configuration is
  127. * required before this device can be used.
  128. *
  129. * This quirk can be set before hci_register_dev is called or
  130. * during the hdev->setup vendor callback.
  131. */
  132. HCI_QUIRK_INVALID_BDADDR,
  133. /* When this quirk is set, the duplicate filtering during
  134. * scanning is based on Bluetooth devices addresses. To allow
  135. * RSSI based updates, restart scanning if needed.
  136. *
  137. * This quirk can be set before hci_register_dev is called or
  138. * during the hdev->setup vendor callback.
  139. */
  140. HCI_QUIRK_STRICT_DUPLICATE_FILTER,
  141. /* When this quirk is set, LE scan and BR/EDR inquiry is done
  142. * simultaneously, otherwise it's interleaved.
  143. *
  144. * This quirk can be set before hci_register_dev is called or
  145. * during the hdev->setup vendor callback.
  146. */
  147. HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
  148. /* When this quirk is set, the enabling of diagnostic mode is
  149. * not persistent over HCI Reset. Every time the controller
  150. * is brought up it needs to be reprogrammed.
  151. *
  152. * This quirk can be set before hci_register_dev is called or
  153. * during the hdev->setup vendor callback.
  154. */
  155. HCI_QUIRK_NON_PERSISTENT_DIAG,
  156. };
  157. /* HCI device flags */
  158. enum {
  159. HCI_UP,
  160. HCI_INIT,
  161. HCI_RUNNING,
  162. HCI_PSCAN,
  163. HCI_ISCAN,
  164. HCI_AUTH,
  165. HCI_ENCRYPT,
  166. HCI_INQUIRY,
  167. HCI_RAW,
  168. HCI_RESET,
  169. };
  170. /* HCI socket flags */
  171. enum {
  172. HCI_SOCK_TRUSTED,
  173. HCI_MGMT_INDEX_EVENTS,
  174. HCI_MGMT_UNCONF_INDEX_EVENTS,
  175. HCI_MGMT_EXT_INDEX_EVENTS,
  176. HCI_MGMT_GENERIC_EVENTS,
  177. HCI_MGMT_OOB_DATA_EVENTS,
  178. };
  179. /*
  180. * BR/EDR and/or LE controller flags: the flags defined here should represent
  181. * states from the controller.
  182. */
  183. enum {
  184. HCI_SETUP,
  185. HCI_CONFIG,
  186. HCI_AUTO_OFF,
  187. HCI_RFKILLED,
  188. HCI_MGMT,
  189. HCI_BONDABLE,
  190. HCI_SERVICE_CACHE,
  191. HCI_KEEP_DEBUG_KEYS,
  192. HCI_USE_DEBUG_KEYS,
  193. HCI_UNREGISTER,
  194. HCI_UNCONFIGURED,
  195. HCI_USER_CHANNEL,
  196. HCI_EXT_CONFIGURED,
  197. HCI_LE_ADV,
  198. HCI_LE_SCAN,
  199. HCI_SSP_ENABLED,
  200. HCI_SC_ENABLED,
  201. HCI_SC_ONLY,
  202. HCI_PRIVACY,
  203. HCI_RPA_EXPIRED,
  204. HCI_RPA_RESOLVING,
  205. HCI_HS_ENABLED,
  206. HCI_LE_ENABLED,
  207. HCI_ADVERTISING,
  208. HCI_ADVERTISING_CONNECTABLE,
  209. HCI_ADVERTISING_INSTANCE,
  210. HCI_CONNECTABLE,
  211. HCI_DISCOVERABLE,
  212. HCI_LIMITED_DISCOVERABLE,
  213. HCI_LINK_SECURITY,
  214. HCI_PERIODIC_INQ,
  215. HCI_FAST_CONNECTABLE,
  216. HCI_BREDR_ENABLED,
  217. HCI_LE_SCAN_INTERRUPTED,
  218. HCI_DUT_MODE,
  219. HCI_VENDOR_DIAG,
  220. HCI_FORCE_BREDR_SMP,
  221. HCI_FORCE_STATIC_ADDR,
  222. __HCI_NUM_FLAGS,
  223. };
  224. /* HCI timeouts */
  225. #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  226. #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */
  227. #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */
  228. #define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  229. #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */
  230. #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  231. #define HCI_POWER_OFF_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
  232. #define HCI_LE_CONN_TIMEOUT msecs_to_jiffies(20000) /* 20 seconds */
  233. #define HCI_LE_AUTOCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
  234. /* HCI data types */
  235. #define HCI_COMMAND_PKT 0x01
  236. #define HCI_ACLDATA_PKT 0x02
  237. #define HCI_SCODATA_PKT 0x03
  238. #define HCI_EVENT_PKT 0x04
  239. #define HCI_DIAG_PKT 0xf0
  240. #define HCI_VENDOR_PKT 0xff
  241. /* HCI packet types */
  242. #define HCI_DM1 0x0008
  243. #define HCI_DM3 0x0400
  244. #define HCI_DM5 0x4000
  245. #define HCI_DH1 0x0010
  246. #define HCI_DH3 0x0800
  247. #define HCI_DH5 0x8000
  248. #define HCI_HV1 0x0020
  249. #define HCI_HV2 0x0040
  250. #define HCI_HV3 0x0080
  251. #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
  252. #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
  253. /* eSCO packet types */
  254. #define ESCO_HV1 0x0001
  255. #define ESCO_HV2 0x0002
  256. #define ESCO_HV3 0x0004
  257. #define ESCO_EV3 0x0008
  258. #define ESCO_EV4 0x0010
  259. #define ESCO_EV5 0x0020
  260. #define ESCO_2EV3 0x0040
  261. #define ESCO_3EV3 0x0080
  262. #define ESCO_2EV5 0x0100
  263. #define ESCO_3EV5 0x0200
  264. #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
  265. #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
  266. /* ACL flags */
  267. #define ACL_START_NO_FLUSH 0x00
  268. #define ACL_CONT 0x01
  269. #define ACL_START 0x02
  270. #define ACL_COMPLETE 0x03
  271. #define ACL_ACTIVE_BCAST 0x04
  272. #define ACL_PICO_BCAST 0x08
  273. /* Baseband links */
  274. #define SCO_LINK 0x00
  275. #define ACL_LINK 0x01
  276. #define ESCO_LINK 0x02
  277. /* Low Energy links do not have defined link type. Use invented one */
  278. #define LE_LINK 0x80
  279. #define AMP_LINK 0x81
  280. #define INVALID_LINK 0xff
  281. /* LMP features */
  282. #define LMP_3SLOT 0x01
  283. #define LMP_5SLOT 0x02
  284. #define LMP_ENCRYPT 0x04
  285. #define LMP_SOFFSET 0x08
  286. #define LMP_TACCURACY 0x10
  287. #define LMP_RSWITCH 0x20
  288. #define LMP_HOLD 0x40
  289. #define LMP_SNIFF 0x80
  290. #define LMP_PARK 0x01
  291. #define LMP_RSSI 0x02
  292. #define LMP_QUALITY 0x04
  293. #define LMP_SCO 0x08
  294. #define LMP_HV2 0x10
  295. #define LMP_HV3 0x20
  296. #define LMP_ULAW 0x40
  297. #define LMP_ALAW 0x80
  298. #define LMP_CVSD 0x01
  299. #define LMP_PSCHEME 0x02
  300. #define LMP_PCONTROL 0x04
  301. #define LMP_TRANSPARENT 0x08
  302. #define LMP_RSSI_INQ 0x40
  303. #define LMP_ESCO 0x80
  304. #define LMP_EV4 0x01
  305. #define LMP_EV5 0x02
  306. #define LMP_NO_BREDR 0x20
  307. #define LMP_LE 0x40
  308. #define LMP_SNIFF_SUBR 0x02
  309. #define LMP_PAUSE_ENC 0x04
  310. #define LMP_EDR_ESCO_2M 0x20
  311. #define LMP_EDR_ESCO_3M 0x40
  312. #define LMP_EDR_3S_ESCO 0x80
  313. #define LMP_EXT_INQ 0x01
  314. #define LMP_SIMUL_LE_BR 0x02
  315. #define LMP_SIMPLE_PAIR 0x08
  316. #define LMP_NO_FLUSH 0x40
  317. #define LMP_LSTO 0x01
  318. #define LMP_INQ_TX_PWR 0x02
  319. #define LMP_EXTFEATURES 0x80
  320. /* Extended LMP features */
  321. #define LMP_CSB_MASTER 0x01
  322. #define LMP_CSB_SLAVE 0x02
  323. #define LMP_SYNC_TRAIN 0x04
  324. #define LMP_SYNC_SCAN 0x08
  325. #define LMP_SC 0x01
  326. #define LMP_PING 0x02
  327. /* Host features */
  328. #define LMP_HOST_SSP 0x01
  329. #define LMP_HOST_LE 0x02
  330. #define LMP_HOST_LE_BREDR 0x04
  331. #define LMP_HOST_SC 0x08
  332. /* LE features */
  333. #define HCI_LE_ENCRYPTION 0x01
  334. #define HCI_LE_CONN_PARAM_REQ_PROC 0x02
  335. #define HCI_LE_SLAVE_FEATURES 0x08
  336. #define HCI_LE_PING 0x10
  337. #define HCI_LE_DATA_LEN_EXT 0x20
  338. #define HCI_LE_EXT_SCAN_POLICY 0x80
  339. /* Connection modes */
  340. #define HCI_CM_ACTIVE 0x0000
  341. #define HCI_CM_HOLD 0x0001
  342. #define HCI_CM_SNIFF 0x0002
  343. #define HCI_CM_PARK 0x0003
  344. /* Link policies */
  345. #define HCI_LP_RSWITCH 0x0001
  346. #define HCI_LP_HOLD 0x0002
  347. #define HCI_LP_SNIFF 0x0004
  348. #define HCI_LP_PARK 0x0008
  349. /* Link modes */
  350. #define HCI_LM_ACCEPT 0x8000
  351. #define HCI_LM_MASTER 0x0001
  352. #define HCI_LM_AUTH 0x0002
  353. #define HCI_LM_ENCRYPT 0x0004
  354. #define HCI_LM_TRUSTED 0x0008
  355. #define HCI_LM_RELIABLE 0x0010
  356. #define HCI_LM_SECURE 0x0020
  357. #define HCI_LM_FIPS 0x0040
  358. /* Authentication types */
  359. #define HCI_AT_NO_BONDING 0x00
  360. #define HCI_AT_NO_BONDING_MITM 0x01
  361. #define HCI_AT_DEDICATED_BONDING 0x02
  362. #define HCI_AT_DEDICATED_BONDING_MITM 0x03
  363. #define HCI_AT_GENERAL_BONDING 0x04
  364. #define HCI_AT_GENERAL_BONDING_MITM 0x05
  365. /* I/O capabilities */
  366. #define HCI_IO_DISPLAY_ONLY 0x00
  367. #define HCI_IO_DISPLAY_YESNO 0x01
  368. #define HCI_IO_KEYBOARD_ONLY 0x02
  369. #define HCI_IO_NO_INPUT_OUTPUT 0x03
  370. /* Link Key types */
  371. #define HCI_LK_COMBINATION 0x00
  372. #define HCI_LK_LOCAL_UNIT 0x01
  373. #define HCI_LK_REMOTE_UNIT 0x02
  374. #define HCI_LK_DEBUG_COMBINATION 0x03
  375. #define HCI_LK_UNAUTH_COMBINATION_P192 0x04
  376. #define HCI_LK_AUTH_COMBINATION_P192 0x05
  377. #define HCI_LK_CHANGED_COMBINATION 0x06
  378. #define HCI_LK_UNAUTH_COMBINATION_P256 0x07
  379. #define HCI_LK_AUTH_COMBINATION_P256 0x08
  380. /* ---- HCI Error Codes ---- */
  381. #define HCI_ERROR_UNKNOWN_CONN_ID 0x02
  382. #define HCI_ERROR_AUTH_FAILURE 0x05
  383. #define HCI_ERROR_MEMORY_EXCEEDED 0x07
  384. #define HCI_ERROR_CONNECTION_TIMEOUT 0x08
  385. #define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d
  386. #define HCI_ERROR_REJ_BAD_ADDR 0x0f
  387. #define HCI_ERROR_REMOTE_USER_TERM 0x13
  388. #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
  389. #define HCI_ERROR_REMOTE_POWER_OFF 0x15
  390. #define HCI_ERROR_LOCAL_HOST_TERM 0x16
  391. #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
  392. #define HCI_ERROR_INVALID_LL_PARAMS 0x1E
  393. #define HCI_ERROR_ADVERTISING_TIMEOUT 0x3c
  394. /* Flow control modes */
  395. #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
  396. #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
  397. /* The core spec defines 127 as the "not available" value */
  398. #define HCI_TX_POWER_INVALID 127
  399. #define HCI_RSSI_INVALID 127
  400. #define HCI_ROLE_MASTER 0x00
  401. #define HCI_ROLE_SLAVE 0x01
  402. /* Extended Inquiry Response field types */
  403. #define EIR_FLAGS 0x01 /* flags */
  404. #define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
  405. #define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
  406. #define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
  407. #define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
  408. #define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
  409. #define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
  410. #define EIR_NAME_SHORT 0x08 /* shortened local name */
  411. #define EIR_NAME_COMPLETE 0x09 /* complete local name */
  412. #define EIR_TX_POWER 0x0A /* transmit power level */
  413. #define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
  414. #define EIR_SSP_HASH_C192 0x0E /* Simple Pairing Hash C-192 */
  415. #define EIR_SSP_RAND_R192 0x0F /* Simple Pairing Randomizer R-192 */
  416. #define EIR_DEVICE_ID 0x10 /* device ID */
  417. #define EIR_APPEARANCE 0x19 /* Device appearance */
  418. #define EIR_LE_BDADDR 0x1B /* LE Bluetooth device address */
  419. #define EIR_LE_ROLE 0x1C /* LE role */
  420. #define EIR_SSP_HASH_C256 0x1D /* Simple Pairing Hash C-256 */
  421. #define EIR_SSP_RAND_R256 0x1E /* Simple Pairing Rand R-256 */
  422. #define EIR_LE_SC_CONFIRM 0x22 /* LE SC Confirmation Value */
  423. #define EIR_LE_SC_RANDOM 0x23 /* LE SC Random Value */
  424. /* Low Energy Advertising Flags */
  425. #define LE_AD_LIMITED 0x01 /* Limited Discoverable */
  426. #define LE_AD_GENERAL 0x02 /* General Discoverable */
  427. #define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
  428. #define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
  429. #define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
  430. /* ----- HCI Commands ---- */
  431. #define HCI_OP_NOP 0x0000
  432. #define HCI_OP_INQUIRY 0x0401
  433. struct hci_cp_inquiry {
  434. __u8 lap[3];
  435. __u8 length;
  436. __u8 num_rsp;
  437. } __packed;
  438. #define HCI_OP_INQUIRY_CANCEL 0x0402
  439. #define HCI_OP_PERIODIC_INQ 0x0403
  440. #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
  441. #define HCI_OP_CREATE_CONN 0x0405
  442. struct hci_cp_create_conn {
  443. bdaddr_t bdaddr;
  444. __le16 pkt_type;
  445. __u8 pscan_rep_mode;
  446. __u8 pscan_mode;
  447. __le16 clock_offset;
  448. __u8 role_switch;
  449. } __packed;
  450. #define HCI_OP_DISCONNECT 0x0406
  451. struct hci_cp_disconnect {
  452. __le16 handle;
  453. __u8 reason;
  454. } __packed;
  455. #define HCI_OP_ADD_SCO 0x0407
  456. struct hci_cp_add_sco {
  457. __le16 handle;
  458. __le16 pkt_type;
  459. } __packed;
  460. #define HCI_OP_CREATE_CONN_CANCEL 0x0408
  461. struct hci_cp_create_conn_cancel {
  462. bdaddr_t bdaddr;
  463. } __packed;
  464. #define HCI_OP_ACCEPT_CONN_REQ 0x0409
  465. struct hci_cp_accept_conn_req {
  466. bdaddr_t bdaddr;
  467. __u8 role;
  468. } __packed;
  469. #define HCI_OP_REJECT_CONN_REQ 0x040a
  470. struct hci_cp_reject_conn_req {
  471. bdaddr_t bdaddr;
  472. __u8 reason;
  473. } __packed;
  474. #define HCI_OP_LINK_KEY_REPLY 0x040b
  475. struct hci_cp_link_key_reply {
  476. bdaddr_t bdaddr;
  477. __u8 link_key[HCI_LINK_KEY_SIZE];
  478. } __packed;
  479. #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
  480. struct hci_cp_link_key_neg_reply {
  481. bdaddr_t bdaddr;
  482. } __packed;
  483. #define HCI_OP_PIN_CODE_REPLY 0x040d
  484. struct hci_cp_pin_code_reply {
  485. bdaddr_t bdaddr;
  486. __u8 pin_len;
  487. __u8 pin_code[16];
  488. } __packed;
  489. struct hci_rp_pin_code_reply {
  490. __u8 status;
  491. bdaddr_t bdaddr;
  492. } __packed;
  493. #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
  494. struct hci_cp_pin_code_neg_reply {
  495. bdaddr_t bdaddr;
  496. } __packed;
  497. struct hci_rp_pin_code_neg_reply {
  498. __u8 status;
  499. bdaddr_t bdaddr;
  500. } __packed;
  501. #define HCI_OP_CHANGE_CONN_PTYPE 0x040f
  502. struct hci_cp_change_conn_ptype {
  503. __le16 handle;
  504. __le16 pkt_type;
  505. } __packed;
  506. #define HCI_OP_AUTH_REQUESTED 0x0411
  507. struct hci_cp_auth_requested {
  508. __le16 handle;
  509. } __packed;
  510. #define HCI_OP_SET_CONN_ENCRYPT 0x0413
  511. struct hci_cp_set_conn_encrypt {
  512. __le16 handle;
  513. __u8 encrypt;
  514. } __packed;
  515. #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
  516. struct hci_cp_change_conn_link_key {
  517. __le16 handle;
  518. } __packed;
  519. #define HCI_OP_REMOTE_NAME_REQ 0x0419
  520. struct hci_cp_remote_name_req {
  521. bdaddr_t bdaddr;
  522. __u8 pscan_rep_mode;
  523. __u8 pscan_mode;
  524. __le16 clock_offset;
  525. } __packed;
  526. #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
  527. struct hci_cp_remote_name_req_cancel {
  528. bdaddr_t bdaddr;
  529. } __packed;
  530. #define HCI_OP_READ_REMOTE_FEATURES 0x041b
  531. struct hci_cp_read_remote_features {
  532. __le16 handle;
  533. } __packed;
  534. #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
  535. struct hci_cp_read_remote_ext_features {
  536. __le16 handle;
  537. __u8 page;
  538. } __packed;
  539. #define HCI_OP_READ_REMOTE_VERSION 0x041d
  540. struct hci_cp_read_remote_version {
  541. __le16 handle;
  542. } __packed;
  543. #define HCI_OP_READ_CLOCK_OFFSET 0x041f
  544. struct hci_cp_read_clock_offset {
  545. __le16 handle;
  546. } __packed;
  547. #define HCI_OP_SETUP_SYNC_CONN 0x0428
  548. struct hci_cp_setup_sync_conn {
  549. __le16 handle;
  550. __le32 tx_bandwidth;
  551. __le32 rx_bandwidth;
  552. __le16 max_latency;
  553. __le16 voice_setting;
  554. __u8 retrans_effort;
  555. __le16 pkt_type;
  556. } __packed;
  557. #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
  558. struct hci_cp_accept_sync_conn_req {
  559. bdaddr_t bdaddr;
  560. __le32 tx_bandwidth;
  561. __le32 rx_bandwidth;
  562. __le16 max_latency;
  563. __le16 content_format;
  564. __u8 retrans_effort;
  565. __le16 pkt_type;
  566. } __packed;
  567. #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
  568. struct hci_cp_reject_sync_conn_req {
  569. bdaddr_t bdaddr;
  570. __u8 reason;
  571. } __packed;
  572. #define HCI_OP_IO_CAPABILITY_REPLY 0x042b
  573. struct hci_cp_io_capability_reply {
  574. bdaddr_t bdaddr;
  575. __u8 capability;
  576. __u8 oob_data;
  577. __u8 authentication;
  578. } __packed;
  579. #define HCI_OP_USER_CONFIRM_REPLY 0x042c
  580. struct hci_cp_user_confirm_reply {
  581. bdaddr_t bdaddr;
  582. } __packed;
  583. struct hci_rp_user_confirm_reply {
  584. __u8 status;
  585. bdaddr_t bdaddr;
  586. } __packed;
  587. #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
  588. #define HCI_OP_USER_PASSKEY_REPLY 0x042e
  589. struct hci_cp_user_passkey_reply {
  590. bdaddr_t bdaddr;
  591. __le32 passkey;
  592. } __packed;
  593. #define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f
  594. #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
  595. struct hci_cp_remote_oob_data_reply {
  596. bdaddr_t bdaddr;
  597. __u8 hash[16];
  598. __u8 rand[16];
  599. } __packed;
  600. #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
  601. struct hci_cp_remote_oob_data_neg_reply {
  602. bdaddr_t bdaddr;
  603. } __packed;
  604. #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
  605. struct hci_cp_io_capability_neg_reply {
  606. bdaddr_t bdaddr;
  607. __u8 reason;
  608. } __packed;
  609. #define HCI_OP_CREATE_PHY_LINK 0x0435
  610. struct hci_cp_create_phy_link {
  611. __u8 phy_handle;
  612. __u8 key_len;
  613. __u8 key_type;
  614. __u8 key[HCI_AMP_LINK_KEY_SIZE];
  615. } __packed;
  616. #define HCI_OP_ACCEPT_PHY_LINK 0x0436
  617. struct hci_cp_accept_phy_link {
  618. __u8 phy_handle;
  619. __u8 key_len;
  620. __u8 key_type;
  621. __u8 key[HCI_AMP_LINK_KEY_SIZE];
  622. } __packed;
  623. #define HCI_OP_DISCONN_PHY_LINK 0x0437
  624. struct hci_cp_disconn_phy_link {
  625. __u8 phy_handle;
  626. __u8 reason;
  627. } __packed;
  628. struct ext_flow_spec {
  629. __u8 id;
  630. __u8 stype;
  631. __le16 msdu;
  632. __le32 sdu_itime;
  633. __le32 acc_lat;
  634. __le32 flush_to;
  635. } __packed;
  636. #define HCI_OP_CREATE_LOGICAL_LINK 0x0438
  637. #define HCI_OP_ACCEPT_LOGICAL_LINK 0x0439
  638. struct hci_cp_create_accept_logical_link {
  639. __u8 phy_handle;
  640. struct ext_flow_spec tx_flow_spec;
  641. struct ext_flow_spec rx_flow_spec;
  642. } __packed;
  643. #define HCI_OP_DISCONN_LOGICAL_LINK 0x043a
  644. struct hci_cp_disconn_logical_link {
  645. __le16 log_handle;
  646. } __packed;
  647. #define HCI_OP_LOGICAL_LINK_CANCEL 0x043b
  648. struct hci_cp_logical_link_cancel {
  649. __u8 phy_handle;
  650. __u8 flow_spec_id;
  651. } __packed;
  652. struct hci_rp_logical_link_cancel {
  653. __u8 status;
  654. __u8 phy_handle;
  655. __u8 flow_spec_id;
  656. } __packed;
  657. #define HCI_OP_SET_CSB 0x0441
  658. struct hci_cp_set_csb {
  659. __u8 enable;
  660. __u8 lt_addr;
  661. __u8 lpo_allowed;
  662. __le16 packet_type;
  663. __le16 interval_min;
  664. __le16 interval_max;
  665. __le16 csb_sv_tout;
  666. } __packed;
  667. struct hci_rp_set_csb {
  668. __u8 status;
  669. __u8 lt_addr;
  670. __le16 interval;
  671. } __packed;
  672. #define HCI_OP_START_SYNC_TRAIN 0x0443
  673. #define HCI_OP_REMOTE_OOB_EXT_DATA_REPLY 0x0445
  674. struct hci_cp_remote_oob_ext_data_reply {
  675. bdaddr_t bdaddr;
  676. __u8 hash192[16];
  677. __u8 rand192[16];
  678. __u8 hash256[16];
  679. __u8 rand256[16];
  680. } __packed;
  681. #define HCI_OP_SNIFF_MODE 0x0803
  682. struct hci_cp_sniff_mode {
  683. __le16 handle;
  684. __le16 max_interval;
  685. __le16 min_interval;
  686. __le16 attempt;
  687. __le16 timeout;
  688. } __packed;
  689. #define HCI_OP_EXIT_SNIFF_MODE 0x0804
  690. struct hci_cp_exit_sniff_mode {
  691. __le16 handle;
  692. } __packed;
  693. #define HCI_OP_ROLE_DISCOVERY 0x0809
  694. struct hci_cp_role_discovery {
  695. __le16 handle;
  696. } __packed;
  697. struct hci_rp_role_discovery {
  698. __u8 status;
  699. __le16 handle;
  700. __u8 role;
  701. } __packed;
  702. #define HCI_OP_SWITCH_ROLE 0x080b
  703. struct hci_cp_switch_role {
  704. bdaddr_t bdaddr;
  705. __u8 role;
  706. } __packed;
  707. #define HCI_OP_READ_LINK_POLICY 0x080c
  708. struct hci_cp_read_link_policy {
  709. __le16 handle;
  710. } __packed;
  711. struct hci_rp_read_link_policy {
  712. __u8 status;
  713. __le16 handle;
  714. __le16 policy;
  715. } __packed;
  716. #define HCI_OP_WRITE_LINK_POLICY 0x080d
  717. struct hci_cp_write_link_policy {
  718. __le16 handle;
  719. __le16 policy;
  720. } __packed;
  721. struct hci_rp_write_link_policy {
  722. __u8 status;
  723. __le16 handle;
  724. } __packed;
  725. #define HCI_OP_READ_DEF_LINK_POLICY 0x080e
  726. struct hci_rp_read_def_link_policy {
  727. __u8 status;
  728. __le16 policy;
  729. } __packed;
  730. #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
  731. struct hci_cp_write_def_link_policy {
  732. __le16 policy;
  733. } __packed;
  734. #define HCI_OP_SNIFF_SUBRATE 0x0811
  735. struct hci_cp_sniff_subrate {
  736. __le16 handle;
  737. __le16 max_latency;
  738. __le16 min_remote_timeout;
  739. __le16 min_local_timeout;
  740. } __packed;
  741. #define HCI_OP_SET_EVENT_MASK 0x0c01
  742. #define HCI_OP_RESET 0x0c03
  743. #define HCI_OP_SET_EVENT_FLT 0x0c05
  744. struct hci_cp_set_event_flt {
  745. __u8 flt_type;
  746. __u8 cond_type;
  747. __u8 condition[0];
  748. } __packed;
  749. /* Filter types */
  750. #define HCI_FLT_CLEAR_ALL 0x00
  751. #define HCI_FLT_INQ_RESULT 0x01
  752. #define HCI_FLT_CONN_SETUP 0x02
  753. /* CONN_SETUP Condition types */
  754. #define HCI_CONN_SETUP_ALLOW_ALL 0x00
  755. #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
  756. #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
  757. /* CONN_SETUP Conditions */
  758. #define HCI_CONN_SETUP_AUTO_OFF 0x01
  759. #define HCI_CONN_SETUP_AUTO_ON 0x02
  760. #define HCI_OP_READ_STORED_LINK_KEY 0x0c0d
  761. struct hci_cp_read_stored_link_key {
  762. bdaddr_t bdaddr;
  763. __u8 read_all;
  764. } __packed;
  765. struct hci_rp_read_stored_link_key {
  766. __u8 status;
  767. __u8 max_keys;
  768. __u8 num_keys;
  769. } __packed;
  770. #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
  771. struct hci_cp_delete_stored_link_key {
  772. bdaddr_t bdaddr;
  773. __u8 delete_all;
  774. } __packed;
  775. struct hci_rp_delete_stored_link_key {
  776. __u8 status;
  777. __u8 num_keys;
  778. } __packed;
  779. #define HCI_MAX_NAME_LENGTH 248
  780. #define HCI_OP_WRITE_LOCAL_NAME 0x0c13
  781. struct hci_cp_write_local_name {
  782. __u8 name[HCI_MAX_NAME_LENGTH];
  783. } __packed;
  784. #define HCI_OP_READ_LOCAL_NAME 0x0c14
  785. struct hci_rp_read_local_name {
  786. __u8 status;
  787. __u8 name[HCI_MAX_NAME_LENGTH];
  788. } __packed;
  789. #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
  790. #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
  791. #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
  792. #define SCAN_DISABLED 0x00
  793. #define SCAN_INQUIRY 0x01
  794. #define SCAN_PAGE 0x02
  795. #define HCI_OP_READ_AUTH_ENABLE 0x0c1f
  796. #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
  797. #define AUTH_DISABLED 0x00
  798. #define AUTH_ENABLED 0x01
  799. #define HCI_OP_READ_ENCRYPT_MODE 0x0c21
  800. #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
  801. #define ENCRYPT_DISABLED 0x00
  802. #define ENCRYPT_P2P 0x01
  803. #define ENCRYPT_BOTH 0x02
  804. #define HCI_OP_READ_CLASS_OF_DEV 0x0c23
  805. struct hci_rp_read_class_of_dev {
  806. __u8 status;
  807. __u8 dev_class[3];
  808. } __packed;
  809. #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
  810. struct hci_cp_write_class_of_dev {
  811. __u8 dev_class[3];
  812. } __packed;
  813. #define HCI_OP_READ_VOICE_SETTING 0x0c25
  814. struct hci_rp_read_voice_setting {
  815. __u8 status;
  816. __le16 voice_setting;
  817. } __packed;
  818. #define HCI_OP_WRITE_VOICE_SETTING 0x0c26
  819. struct hci_cp_write_voice_setting {
  820. __le16 voice_setting;
  821. } __packed;
  822. #define HCI_OP_HOST_BUFFER_SIZE 0x0c33
  823. struct hci_cp_host_buffer_size {
  824. __le16 acl_mtu;
  825. __u8 sco_mtu;
  826. __le16 acl_max_pkt;
  827. __le16 sco_max_pkt;
  828. } __packed;
  829. #define HCI_OP_READ_NUM_SUPPORTED_IAC 0x0c38
  830. struct hci_rp_read_num_supported_iac {
  831. __u8 status;
  832. __u8 num_iac;
  833. } __packed;
  834. #define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
  835. #define HCI_OP_WRITE_CURRENT_IAC_LAP 0x0c3a
  836. struct hci_cp_write_current_iac_lap {
  837. __u8 num_iac;
  838. __u8 iac_lap[6];
  839. } __packed;
  840. #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
  841. #define HCI_MAX_EIR_LENGTH 240
  842. #define HCI_OP_WRITE_EIR 0x0c52
  843. struct hci_cp_write_eir {
  844. __u8 fec;
  845. __u8 data[HCI_MAX_EIR_LENGTH];
  846. } __packed;
  847. #define HCI_OP_READ_SSP_MODE 0x0c55
  848. struct hci_rp_read_ssp_mode {
  849. __u8 status;
  850. __u8 mode;
  851. } __packed;
  852. #define HCI_OP_WRITE_SSP_MODE 0x0c56
  853. struct hci_cp_write_ssp_mode {
  854. __u8 mode;
  855. } __packed;
  856. #define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
  857. struct hci_rp_read_local_oob_data {
  858. __u8 status;
  859. __u8 hash[16];
  860. __u8 rand[16];
  861. } __packed;
  862. #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
  863. struct hci_rp_read_inq_rsp_tx_power {
  864. __u8 status;
  865. __s8 tx_power;
  866. } __packed;
  867. #define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63
  868. #define HCI_OP_READ_LOCATION_DATA 0x0c64
  869. #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
  870. struct hci_rp_read_flow_control_mode {
  871. __u8 status;
  872. __u8 mode;
  873. } __packed;
  874. #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d
  875. struct hci_cp_write_le_host_supported {
  876. __u8 le;
  877. __u8 simul;
  878. } __packed;
  879. #define HCI_OP_SET_RESERVED_LT_ADDR 0x0c74
  880. struct hci_cp_set_reserved_lt_addr {
  881. __u8 lt_addr;
  882. } __packed;
  883. struct hci_rp_set_reserved_lt_addr {
  884. __u8 status;
  885. __u8 lt_addr;
  886. } __packed;
  887. #define HCI_OP_DELETE_RESERVED_LT_ADDR 0x0c75
  888. struct hci_cp_delete_reserved_lt_addr {
  889. __u8 lt_addr;
  890. } __packed;
  891. struct hci_rp_delete_reserved_lt_addr {
  892. __u8 status;
  893. __u8 lt_addr;
  894. } __packed;
  895. #define HCI_OP_SET_CSB_DATA 0x0c76
  896. struct hci_cp_set_csb_data {
  897. __u8 lt_addr;
  898. __u8 fragment;
  899. __u8 data_length;
  900. __u8 data[HCI_MAX_CSB_DATA_SIZE];
  901. } __packed;
  902. struct hci_rp_set_csb_data {
  903. __u8 status;
  904. __u8 lt_addr;
  905. } __packed;
  906. #define HCI_OP_READ_SYNC_TRAIN_PARAMS 0x0c77
  907. #define HCI_OP_WRITE_SYNC_TRAIN_PARAMS 0x0c78
  908. struct hci_cp_write_sync_train_params {
  909. __le16 interval_min;
  910. __le16 interval_max;
  911. __le32 sync_train_tout;
  912. __u8 service_data;
  913. } __packed;
  914. struct hci_rp_write_sync_train_params {
  915. __u8 status;
  916. __le16 sync_train_int;
  917. } __packed;
  918. #define HCI_OP_READ_SC_SUPPORT 0x0c79
  919. struct hci_rp_read_sc_support {
  920. __u8 status;
  921. __u8 support;
  922. } __packed;
  923. #define HCI_OP_WRITE_SC_SUPPORT 0x0c7a
  924. struct hci_cp_write_sc_support {
  925. __u8 support;
  926. } __packed;
  927. #define HCI_OP_READ_LOCAL_OOB_EXT_DATA 0x0c7d
  928. struct hci_rp_read_local_oob_ext_data {
  929. __u8 status;
  930. __u8 hash192[16];
  931. __u8 rand192[16];
  932. __u8 hash256[16];
  933. __u8 rand256[16];
  934. } __packed;
  935. #define HCI_OP_READ_LOCAL_VERSION 0x1001
  936. struct hci_rp_read_local_version {
  937. __u8 status;
  938. __u8 hci_ver;
  939. __le16 hci_rev;
  940. __u8 lmp_ver;
  941. __le16 manufacturer;
  942. __le16 lmp_subver;
  943. } __packed;
  944. #define HCI_OP_READ_LOCAL_COMMANDS 0x1002
  945. struct hci_rp_read_local_commands {
  946. __u8 status;
  947. __u8 commands[64];
  948. } __packed;
  949. #define HCI_OP_READ_LOCAL_FEATURES 0x1003
  950. struct hci_rp_read_local_features {
  951. __u8 status;
  952. __u8 features[8];
  953. } __packed;
  954. #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
  955. struct hci_cp_read_local_ext_features {
  956. __u8 page;
  957. } __packed;
  958. struct hci_rp_read_local_ext_features {
  959. __u8 status;
  960. __u8 page;
  961. __u8 max_page;
  962. __u8 features[8];
  963. } __packed;
  964. #define HCI_OP_READ_BUFFER_SIZE 0x1005
  965. struct hci_rp_read_buffer_size {
  966. __u8 status;
  967. __le16 acl_mtu;
  968. __u8 sco_mtu;
  969. __le16 acl_max_pkt;
  970. __le16 sco_max_pkt;
  971. } __packed;
  972. #define HCI_OP_READ_BD_ADDR 0x1009
  973. struct hci_rp_read_bd_addr {
  974. __u8 status;
  975. bdaddr_t bdaddr;
  976. } __packed;
  977. #define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
  978. struct hci_rp_read_data_block_size {
  979. __u8 status;
  980. __le16 max_acl_len;
  981. __le16 block_len;
  982. __le16 num_blocks;
  983. } __packed;
  984. #define HCI_OP_READ_LOCAL_CODECS 0x100b
  985. #define HCI_OP_READ_PAGE_SCAN_ACTIVITY 0x0c1b
  986. struct hci_rp_read_page_scan_activity {
  987. __u8 status;
  988. __le16 interval;
  989. __le16 window;
  990. } __packed;
  991. #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
  992. struct hci_cp_write_page_scan_activity {
  993. __le16 interval;
  994. __le16 window;
  995. } __packed;
  996. #define HCI_OP_READ_TX_POWER 0x0c2d
  997. struct hci_cp_read_tx_power {
  998. __le16 handle;
  999. __u8 type;
  1000. } __packed;
  1001. struct hci_rp_read_tx_power {
  1002. __u8 status;
  1003. __le16 handle;
  1004. __s8 tx_power;
  1005. } __packed;
  1006. #define HCI_OP_READ_PAGE_SCAN_TYPE 0x0c46
  1007. struct hci_rp_read_page_scan_type {
  1008. __u8 status;
  1009. __u8 type;
  1010. } __packed;
  1011. #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
  1012. #define PAGE_SCAN_TYPE_STANDARD 0x00
  1013. #define PAGE_SCAN_TYPE_INTERLACED 0x01
  1014. #define HCI_OP_READ_RSSI 0x1405
  1015. struct hci_cp_read_rssi {
  1016. __le16 handle;
  1017. } __packed;
  1018. struct hci_rp_read_rssi {
  1019. __u8 status;
  1020. __le16 handle;
  1021. __s8 rssi;
  1022. } __packed;
  1023. #define HCI_OP_READ_CLOCK 0x1407
  1024. struct hci_cp_read_clock {
  1025. __le16 handle;
  1026. __u8 which;
  1027. } __packed;
  1028. struct hci_rp_read_clock {
  1029. __u8 status;
  1030. __le16 handle;
  1031. __le32 clock;
  1032. __le16 accuracy;
  1033. } __packed;
  1034. #define HCI_OP_READ_ENC_KEY_SIZE 0x1408
  1035. struct hci_cp_read_enc_key_size {
  1036. __le16 handle;
  1037. } __packed;
  1038. struct hci_rp_read_enc_key_size {
  1039. __u8 status;
  1040. __le16 handle;
  1041. __u8 key_size;
  1042. } __packed;
  1043. #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409
  1044. struct hci_rp_read_local_amp_info {
  1045. __u8 status;
  1046. __u8 amp_status;
  1047. __le32 total_bw;
  1048. __le32 max_bw;
  1049. __le32 min_latency;
  1050. __le32 max_pdu;
  1051. __u8 amp_type;
  1052. __le16 pal_cap;
  1053. __le16 max_assoc_size;
  1054. __le32 max_flush_to;
  1055. __le32 be_flush_to;
  1056. } __packed;
  1057. #define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a
  1058. struct hci_cp_read_local_amp_assoc {
  1059. __u8 phy_handle;
  1060. __le16 len_so_far;
  1061. __le16 max_len;
  1062. } __packed;
  1063. struct hci_rp_read_local_amp_assoc {
  1064. __u8 status;
  1065. __u8 phy_handle;
  1066. __le16 rem_len;
  1067. __u8 frag[0];
  1068. } __packed;
  1069. #define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b
  1070. struct hci_cp_write_remote_amp_assoc {
  1071. __u8 phy_handle;
  1072. __le16 len_so_far;
  1073. __le16 rem_len;
  1074. __u8 frag[0];
  1075. } __packed;
  1076. struct hci_rp_write_remote_amp_assoc {
  1077. __u8 status;
  1078. __u8 phy_handle;
  1079. } __packed;
  1080. #define HCI_OP_GET_MWS_TRANSPORT_CONFIG 0x140c
  1081. #define HCI_OP_ENABLE_DUT_MODE 0x1803
  1082. #define HCI_OP_WRITE_SSP_DEBUG_MODE 0x1804
  1083. #define HCI_OP_LE_SET_EVENT_MASK 0x2001
  1084. struct hci_cp_le_set_event_mask {
  1085. __u8 mask[8];
  1086. } __packed;
  1087. #define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
  1088. struct hci_rp_le_read_buffer_size {
  1089. __u8 status;
  1090. __le16 le_mtu;
  1091. __u8 le_max_pkt;
  1092. } __packed;
  1093. #define HCI_OP_LE_READ_LOCAL_FEATURES 0x2003
  1094. struct hci_rp_le_read_local_features {
  1095. __u8 status;
  1096. __u8 features[8];
  1097. } __packed;
  1098. #define HCI_OP_LE_SET_RANDOM_ADDR 0x2005
  1099. #define HCI_OP_LE_SET_ADV_PARAM 0x2006
  1100. struct hci_cp_le_set_adv_param {
  1101. __le16 min_interval;
  1102. __le16 max_interval;
  1103. __u8 type;
  1104. __u8 own_address_type;
  1105. __u8 direct_addr_type;
  1106. bdaddr_t direct_addr;
  1107. __u8 channel_map;
  1108. __u8 filter_policy;
  1109. } __packed;
  1110. #define HCI_OP_LE_READ_ADV_TX_POWER 0x2007
  1111. struct hci_rp_le_read_adv_tx_power {
  1112. __u8 status;
  1113. __s8 tx_power;
  1114. } __packed;
  1115. #define HCI_MAX_AD_LENGTH 31
  1116. #define HCI_OP_LE_SET_ADV_DATA 0x2008
  1117. struct hci_cp_le_set_adv_data {
  1118. __u8 length;
  1119. __u8 data[HCI_MAX_AD_LENGTH];
  1120. } __packed;
  1121. #define HCI_OP_LE_SET_SCAN_RSP_DATA 0x2009
  1122. struct hci_cp_le_set_scan_rsp_data {
  1123. __u8 length;
  1124. __u8 data[HCI_MAX_AD_LENGTH];
  1125. } __packed;
  1126. #define HCI_OP_LE_SET_ADV_ENABLE 0x200a
  1127. #define LE_SCAN_PASSIVE 0x00
  1128. #define LE_SCAN_ACTIVE 0x01
  1129. #define HCI_OP_LE_SET_SCAN_PARAM 0x200b
  1130. struct hci_cp_le_set_scan_param {
  1131. __u8 type;
  1132. __le16 interval;
  1133. __le16 window;
  1134. __u8 own_address_type;
  1135. __u8 filter_policy;
  1136. } __packed;
  1137. #define LE_SCAN_DISABLE 0x00
  1138. #define LE_SCAN_ENABLE 0x01
  1139. #define LE_SCAN_FILTER_DUP_DISABLE 0x00
  1140. #define LE_SCAN_FILTER_DUP_ENABLE 0x01
  1141. #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
  1142. struct hci_cp_le_set_scan_enable {
  1143. __u8 enable;
  1144. __u8 filter_dup;
  1145. } __packed;
  1146. #define HCI_LE_USE_PEER_ADDR 0x00
  1147. #define HCI_LE_USE_WHITELIST 0x01
  1148. #define HCI_OP_LE_CREATE_CONN 0x200d
  1149. struct hci_cp_le_create_conn {
  1150. __le16 scan_interval;
  1151. __le16 scan_window;
  1152. __u8 filter_policy;
  1153. __u8 peer_addr_type;
  1154. bdaddr_t peer_addr;
  1155. __u8 own_address_type;
  1156. __le16 conn_interval_min;
  1157. __le16 conn_interval_max;
  1158. __le16 conn_latency;
  1159. __le16 supervision_timeout;
  1160. __le16 min_ce_len;
  1161. __le16 max_ce_len;
  1162. } __packed;
  1163. #define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
  1164. #define HCI_OP_LE_READ_WHITE_LIST_SIZE 0x200f
  1165. struct hci_rp_le_read_white_list_size {
  1166. __u8 status;
  1167. __u8 size;
  1168. } __packed;
  1169. #define HCI_OP_LE_CLEAR_WHITE_LIST 0x2010
  1170. #define HCI_OP_LE_ADD_TO_WHITE_LIST 0x2011
  1171. struct hci_cp_le_add_to_white_list {
  1172. __u8 bdaddr_type;
  1173. bdaddr_t bdaddr;
  1174. } __packed;
  1175. #define HCI_OP_LE_DEL_FROM_WHITE_LIST 0x2012
  1176. struct hci_cp_le_del_from_white_list {
  1177. __u8 bdaddr_type;
  1178. bdaddr_t bdaddr;
  1179. } __packed;
  1180. #define HCI_OP_LE_CONN_UPDATE 0x2013
  1181. struct hci_cp_le_conn_update {
  1182. __le16 handle;
  1183. __le16 conn_interval_min;
  1184. __le16 conn_interval_max;
  1185. __le16 conn_latency;
  1186. __le16 supervision_timeout;
  1187. __le16 min_ce_len;
  1188. __le16 max_ce_len;
  1189. } __packed;
  1190. #define HCI_OP_LE_READ_REMOTE_FEATURES 0x2016
  1191. struct hci_cp_le_read_remote_features {
  1192. __le16 handle;
  1193. } __packed;
  1194. #define HCI_OP_LE_START_ENC 0x2019
  1195. struct hci_cp_le_start_enc {
  1196. __le16 handle;
  1197. __le64 rand;
  1198. __le16 ediv;
  1199. __u8 ltk[16];
  1200. } __packed;
  1201. #define HCI_OP_LE_LTK_REPLY 0x201a
  1202. struct hci_cp_le_ltk_reply {
  1203. __le16 handle;
  1204. __u8 ltk[16];
  1205. } __packed;
  1206. struct hci_rp_le_ltk_reply {
  1207. __u8 status;
  1208. __le16 handle;
  1209. } __packed;
  1210. #define HCI_OP_LE_LTK_NEG_REPLY 0x201b
  1211. struct hci_cp_le_ltk_neg_reply {
  1212. __le16 handle;
  1213. } __packed;
  1214. struct hci_rp_le_ltk_neg_reply {
  1215. __u8 status;
  1216. __le16 handle;
  1217. } __packed;
  1218. #define HCI_OP_LE_READ_SUPPORTED_STATES 0x201c
  1219. struct hci_rp_le_read_supported_states {
  1220. __u8 status;
  1221. __u8 le_states[8];
  1222. } __packed;
  1223. #define HCI_OP_LE_CONN_PARAM_REQ_REPLY 0x2020
  1224. struct hci_cp_le_conn_param_req_reply {
  1225. __le16 handle;
  1226. __le16 interval_min;
  1227. __le16 interval_max;
  1228. __le16 latency;
  1229. __le16 timeout;
  1230. __le16 min_ce_len;
  1231. __le16 max_ce_len;
  1232. } __packed;
  1233. #define HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY 0x2021
  1234. struct hci_cp_le_conn_param_req_neg_reply {
  1235. __le16 handle;
  1236. __u8 reason;
  1237. } __packed;
  1238. #define HCI_OP_LE_SET_DATA_LEN 0x2022
  1239. struct hci_cp_le_set_data_len {
  1240. __le16 handle;
  1241. __le16 tx_len;
  1242. __le16 tx_time;
  1243. } __packed;
  1244. struct hci_rp_le_set_data_len {
  1245. __u8 status;
  1246. __le16 handle;
  1247. } __packed;
  1248. #define HCI_OP_LE_READ_DEF_DATA_LEN 0x2023
  1249. struct hci_rp_le_read_def_data_len {
  1250. __u8 status;
  1251. __le16 tx_len;
  1252. __le16 tx_time;
  1253. } __packed;
  1254. #define HCI_OP_LE_WRITE_DEF_DATA_LEN 0x2024
  1255. struct hci_cp_le_write_def_data_len {
  1256. __le16 tx_len;
  1257. __le16 tx_time;
  1258. } __packed;
  1259. #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f
  1260. struct hci_rp_le_read_max_data_len {
  1261. __u8 status;
  1262. __le16 tx_len;
  1263. __le16 tx_time;
  1264. __le16 rx_len;
  1265. __le16 rx_time;
  1266. } __packed;
  1267. /* ---- HCI Events ---- */
  1268. #define HCI_EV_INQUIRY_COMPLETE 0x01
  1269. #define HCI_EV_INQUIRY_RESULT 0x02
  1270. struct inquiry_info {
  1271. bdaddr_t bdaddr;
  1272. __u8 pscan_rep_mode;
  1273. __u8 pscan_period_mode;
  1274. __u8 pscan_mode;
  1275. __u8 dev_class[3];
  1276. __le16 clock_offset;
  1277. } __packed;
  1278. #define HCI_EV_CONN_COMPLETE 0x03
  1279. struct hci_ev_conn_complete {
  1280. __u8 status;
  1281. __le16 handle;
  1282. bdaddr_t bdaddr;
  1283. __u8 link_type;
  1284. __u8 encr_mode;
  1285. } __packed;
  1286. #define HCI_EV_CONN_REQUEST 0x04
  1287. struct hci_ev_conn_request {
  1288. bdaddr_t bdaddr;
  1289. __u8 dev_class[3];
  1290. __u8 link_type;
  1291. } __packed;
  1292. #define HCI_EV_DISCONN_COMPLETE 0x05
  1293. struct hci_ev_disconn_complete {
  1294. __u8 status;
  1295. __le16 handle;
  1296. __u8 reason;
  1297. } __packed;
  1298. #define HCI_EV_AUTH_COMPLETE 0x06
  1299. struct hci_ev_auth_complete {
  1300. __u8 status;
  1301. __le16 handle;
  1302. } __packed;
  1303. #define HCI_EV_REMOTE_NAME 0x07
  1304. struct hci_ev_remote_name {
  1305. __u8 status;
  1306. bdaddr_t bdaddr;
  1307. __u8 name[HCI_MAX_NAME_LENGTH];
  1308. } __packed;
  1309. #define HCI_EV_ENCRYPT_CHANGE 0x08
  1310. struct hci_ev_encrypt_change {
  1311. __u8 status;
  1312. __le16 handle;
  1313. __u8 encrypt;
  1314. } __packed;
  1315. #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
  1316. struct hci_ev_change_link_key_complete {
  1317. __u8 status;
  1318. __le16 handle;
  1319. } __packed;
  1320. #define HCI_EV_REMOTE_FEATURES 0x0b
  1321. struct hci_ev_remote_features {
  1322. __u8 status;
  1323. __le16 handle;
  1324. __u8 features[8];
  1325. } __packed;
  1326. #define HCI_EV_REMOTE_VERSION 0x0c
  1327. struct hci_ev_remote_version {
  1328. __u8 status;
  1329. __le16 handle;
  1330. __u8 lmp_ver;
  1331. __le16 manufacturer;
  1332. __le16 lmp_subver;
  1333. } __packed;
  1334. #define HCI_EV_QOS_SETUP_COMPLETE 0x0d
  1335. struct hci_qos {
  1336. __u8 service_type;
  1337. __u32 token_rate;
  1338. __u32 peak_bandwidth;
  1339. __u32 latency;
  1340. __u32 delay_variation;
  1341. } __packed;
  1342. struct hci_ev_qos_setup_complete {
  1343. __u8 status;
  1344. __le16 handle;
  1345. struct hci_qos qos;
  1346. } __packed;
  1347. #define HCI_EV_CMD_COMPLETE 0x0e
  1348. struct hci_ev_cmd_complete {
  1349. __u8 ncmd;
  1350. __le16 opcode;
  1351. } __packed;
  1352. #define HCI_EV_CMD_STATUS 0x0f
  1353. struct hci_ev_cmd_status {
  1354. __u8 status;
  1355. __u8 ncmd;
  1356. __le16 opcode;
  1357. } __packed;
  1358. #define HCI_EV_HARDWARE_ERROR 0x10
  1359. struct hci_ev_hardware_error {
  1360. __u8 code;
  1361. } __packed;
  1362. #define HCI_EV_ROLE_CHANGE 0x12
  1363. struct hci_ev_role_change {
  1364. __u8 status;
  1365. bdaddr_t bdaddr;
  1366. __u8 role;
  1367. } __packed;
  1368. #define HCI_EV_NUM_COMP_PKTS 0x13
  1369. struct hci_comp_pkts_info {
  1370. __le16 handle;
  1371. __le16 count;
  1372. } __packed;
  1373. struct hci_ev_num_comp_pkts {
  1374. __u8 num_hndl;
  1375. struct hci_comp_pkts_info handles[0];
  1376. } __packed;
  1377. #define HCI_EV_MODE_CHANGE 0x14
  1378. struct hci_ev_mode_change {
  1379. __u8 status;
  1380. __le16 handle;
  1381. __u8 mode;
  1382. __le16 interval;
  1383. } __packed;
  1384. #define HCI_EV_PIN_CODE_REQ 0x16
  1385. struct hci_ev_pin_code_req {
  1386. bdaddr_t bdaddr;
  1387. } __packed;
  1388. #define HCI_EV_LINK_KEY_REQ 0x17
  1389. struct hci_ev_link_key_req {
  1390. bdaddr_t bdaddr;
  1391. } __packed;
  1392. #define HCI_EV_LINK_KEY_NOTIFY 0x18
  1393. struct hci_ev_link_key_notify {
  1394. bdaddr_t bdaddr;
  1395. __u8 link_key[HCI_LINK_KEY_SIZE];
  1396. __u8 key_type;
  1397. } __packed;
  1398. #define HCI_EV_CLOCK_OFFSET 0x1c
  1399. struct hci_ev_clock_offset {
  1400. __u8 status;
  1401. __le16 handle;
  1402. __le16 clock_offset;
  1403. } __packed;
  1404. #define HCI_EV_PKT_TYPE_CHANGE 0x1d
  1405. struct hci_ev_pkt_type_change {
  1406. __u8 status;
  1407. __le16 handle;
  1408. __le16 pkt_type;
  1409. } __packed;
  1410. #define HCI_EV_PSCAN_REP_MODE 0x20
  1411. struct hci_ev_pscan_rep_mode {
  1412. bdaddr_t bdaddr;
  1413. __u8 pscan_rep_mode;
  1414. } __packed;
  1415. #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
  1416. struct inquiry_info_with_rssi {
  1417. bdaddr_t bdaddr;
  1418. __u8 pscan_rep_mode;
  1419. __u8 pscan_period_mode;
  1420. __u8 dev_class[3];
  1421. __le16 clock_offset;
  1422. __s8 rssi;
  1423. } __packed;
  1424. struct inquiry_info_with_rssi_and_pscan_mode {
  1425. bdaddr_t bdaddr;
  1426. __u8 pscan_rep_mode;
  1427. __u8 pscan_period_mode;
  1428. __u8 pscan_mode;
  1429. __u8 dev_class[3];
  1430. __le16 clock_offset;
  1431. __s8 rssi;
  1432. } __packed;
  1433. #define HCI_EV_REMOTE_EXT_FEATURES 0x23
  1434. struct hci_ev_remote_ext_features {
  1435. __u8 status;
  1436. __le16 handle;
  1437. __u8 page;
  1438. __u8 max_page;
  1439. __u8 features[8];
  1440. } __packed;
  1441. #define HCI_EV_SYNC_CONN_COMPLETE 0x2c
  1442. struct hci_ev_sync_conn_complete {
  1443. __u8 status;
  1444. __le16 handle;
  1445. bdaddr_t bdaddr;
  1446. __u8 link_type;
  1447. __u8 tx_interval;
  1448. __u8 retrans_window;
  1449. __le16 rx_pkt_len;
  1450. __le16 tx_pkt_len;
  1451. __u8 air_mode;
  1452. } __packed;
  1453. #define HCI_EV_SYNC_CONN_CHANGED 0x2d
  1454. struct hci_ev_sync_conn_changed {
  1455. __u8 status;
  1456. __le16 handle;
  1457. __u8 tx_interval;
  1458. __u8 retrans_window;
  1459. __le16 rx_pkt_len;
  1460. __le16 tx_pkt_len;
  1461. } __packed;
  1462. #define HCI_EV_SNIFF_SUBRATE 0x2e
  1463. struct hci_ev_sniff_subrate {
  1464. __u8 status;
  1465. __le16 handle;
  1466. __le16 max_tx_latency;
  1467. __le16 max_rx_latency;
  1468. __le16 max_remote_timeout;
  1469. __le16 max_local_timeout;
  1470. } __packed;
  1471. #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
  1472. struct extended_inquiry_info {
  1473. bdaddr_t bdaddr;
  1474. __u8 pscan_rep_mode;
  1475. __u8 pscan_period_mode;
  1476. __u8 dev_class[3];
  1477. __le16 clock_offset;
  1478. __s8 rssi;
  1479. __u8 data[240];
  1480. } __packed;
  1481. #define HCI_EV_KEY_REFRESH_COMPLETE 0x30
  1482. struct hci_ev_key_refresh_complete {
  1483. __u8 status;
  1484. __le16 handle;
  1485. } __packed;
  1486. #define HCI_EV_IO_CAPA_REQUEST 0x31
  1487. struct hci_ev_io_capa_request {
  1488. bdaddr_t bdaddr;
  1489. } __packed;
  1490. #define HCI_EV_IO_CAPA_REPLY 0x32
  1491. struct hci_ev_io_capa_reply {
  1492. bdaddr_t bdaddr;
  1493. __u8 capability;
  1494. __u8 oob_data;
  1495. __u8 authentication;
  1496. } __packed;
  1497. #define HCI_EV_USER_CONFIRM_REQUEST 0x33
  1498. struct hci_ev_user_confirm_req {
  1499. bdaddr_t bdaddr;
  1500. __le32 passkey;
  1501. } __packed;
  1502. #define HCI_EV_USER_PASSKEY_REQUEST 0x34
  1503. struct hci_ev_user_passkey_req {
  1504. bdaddr_t bdaddr;
  1505. } __packed;
  1506. #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
  1507. struct hci_ev_remote_oob_data_request {
  1508. bdaddr_t bdaddr;
  1509. } __packed;
  1510. #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
  1511. struct hci_ev_simple_pair_complete {
  1512. __u8 status;
  1513. bdaddr_t bdaddr;
  1514. } __packed;
  1515. #define HCI_EV_USER_PASSKEY_NOTIFY 0x3b
  1516. struct hci_ev_user_passkey_notify {
  1517. bdaddr_t bdaddr;
  1518. __le32 passkey;
  1519. } __packed;
  1520. #define HCI_KEYPRESS_STARTED 0
  1521. #define HCI_KEYPRESS_ENTERED 1
  1522. #define HCI_KEYPRESS_ERASED 2
  1523. #define HCI_KEYPRESS_CLEARED 3
  1524. #define HCI_KEYPRESS_COMPLETED 4
  1525. #define HCI_EV_KEYPRESS_NOTIFY 0x3c
  1526. struct hci_ev_keypress_notify {
  1527. bdaddr_t bdaddr;
  1528. __u8 type;
  1529. } __packed;
  1530. #define HCI_EV_REMOTE_HOST_FEATURES 0x3d
  1531. struct hci_ev_remote_host_features {
  1532. bdaddr_t bdaddr;
  1533. __u8 features[8];
  1534. } __packed;
  1535. #define HCI_EV_LE_META 0x3e
  1536. struct hci_ev_le_meta {
  1537. __u8 subevent;
  1538. } __packed;
  1539. #define HCI_EV_PHY_LINK_COMPLETE 0x40
  1540. struct hci_ev_phy_link_complete {
  1541. __u8 status;
  1542. __u8 phy_handle;
  1543. } __packed;
  1544. #define HCI_EV_CHANNEL_SELECTED 0x41
  1545. struct hci_ev_channel_selected {
  1546. __u8 phy_handle;
  1547. } __packed;
  1548. #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42
  1549. struct hci_ev_disconn_phy_link_complete {
  1550. __u8 status;
  1551. __u8 phy_handle;
  1552. __u8 reason;
  1553. } __packed;
  1554. #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45
  1555. struct hci_ev_logical_link_complete {
  1556. __u8 status;
  1557. __le16 handle;
  1558. __u8 phy_handle;
  1559. __u8 flow_spec_id;
  1560. } __packed;
  1561. #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46
  1562. struct hci_ev_disconn_logical_link_complete {
  1563. __u8 status;
  1564. __le16 handle;
  1565. __u8 reason;
  1566. } __packed;
  1567. #define HCI_EV_NUM_COMP_BLOCKS 0x48
  1568. struct hci_comp_blocks_info {
  1569. __le16 handle;
  1570. __le16 pkts;
  1571. __le16 blocks;
  1572. } __packed;
  1573. struct hci_ev_num_comp_blocks {
  1574. __le16 num_blocks;
  1575. __u8 num_hndl;
  1576. struct hci_comp_blocks_info handles[0];
  1577. } __packed;
  1578. #define HCI_EV_SYNC_TRAIN_COMPLETE 0x4F
  1579. struct hci_ev_sync_train_complete {
  1580. __u8 status;
  1581. } __packed;
  1582. #define HCI_EV_SLAVE_PAGE_RESP_TIMEOUT 0x54
  1583. #define HCI_EV_LE_CONN_COMPLETE 0x01
  1584. struct hci_ev_le_conn_complete {
  1585. __u8 status;
  1586. __le16 handle;
  1587. __u8 role;
  1588. __u8 bdaddr_type;
  1589. bdaddr_t bdaddr;
  1590. __le16 interval;
  1591. __le16 latency;
  1592. __le16 supervision_timeout;
  1593. __u8 clk_accurancy;
  1594. } __packed;
  1595. /* Advertising report event types */
  1596. #define LE_ADV_IND 0x00
  1597. #define LE_ADV_DIRECT_IND 0x01
  1598. #define LE_ADV_SCAN_IND 0x02
  1599. #define LE_ADV_NONCONN_IND 0x03
  1600. #define LE_ADV_SCAN_RSP 0x04
  1601. #define ADDR_LE_DEV_PUBLIC 0x00
  1602. #define ADDR_LE_DEV_RANDOM 0x01
  1603. #define HCI_EV_LE_ADVERTISING_REPORT 0x02
  1604. struct hci_ev_le_advertising_info {
  1605. __u8 evt_type;
  1606. __u8 bdaddr_type;
  1607. bdaddr_t bdaddr;
  1608. __u8 length;
  1609. __u8 data[0];
  1610. } __packed;
  1611. #define HCI_EV_LE_CONN_UPDATE_COMPLETE 0x03
  1612. struct hci_ev_le_conn_update_complete {
  1613. __u8 status;
  1614. __le16 handle;
  1615. __le16 interval;
  1616. __le16 latency;
  1617. __le16 supervision_timeout;
  1618. } __packed;
  1619. #define HCI_EV_LE_REMOTE_FEAT_COMPLETE 0x04
  1620. struct hci_ev_le_remote_feat_complete {
  1621. __u8 status;
  1622. __le16 handle;
  1623. __u8 features[8];
  1624. } __packed;
  1625. #define HCI_EV_LE_LTK_REQ 0x05
  1626. struct hci_ev_le_ltk_req {
  1627. __le16 handle;
  1628. __le64 rand;
  1629. __le16 ediv;
  1630. } __packed;
  1631. #define HCI_EV_LE_REMOTE_CONN_PARAM_REQ 0x06
  1632. struct hci_ev_le_remote_conn_param_req {
  1633. __le16 handle;
  1634. __le16 interval_min;
  1635. __le16 interval_max;
  1636. __le16 latency;
  1637. __le16 timeout;
  1638. } __packed;
  1639. #define HCI_EV_LE_DATA_LEN_CHANGE 0x07
  1640. struct hci_ev_le_data_len_change {
  1641. __le16 handle;
  1642. __le16 tx_len;
  1643. __le16 tx_time;
  1644. __le16 rx_len;
  1645. __le16 rx_time;
  1646. } __packed;
  1647. #define HCI_EV_LE_DIRECT_ADV_REPORT 0x0B
  1648. struct hci_ev_le_direct_adv_info {
  1649. __u8 evt_type;
  1650. __u8 bdaddr_type;
  1651. bdaddr_t bdaddr;
  1652. __u8 direct_addr_type;
  1653. bdaddr_t direct_addr;
  1654. __s8 rssi;
  1655. } __packed;
  1656. /* Internal events generated by Bluetooth stack */
  1657. #define HCI_EV_STACK_INTERNAL 0xfd
  1658. struct hci_ev_stack_internal {
  1659. __u16 type;
  1660. __u8 data[0];
  1661. } __packed;
  1662. #define HCI_EV_SI_DEVICE 0x01
  1663. struct hci_ev_si_device {
  1664. __u16 event;
  1665. __u16 dev_id;
  1666. } __packed;
  1667. #define HCI_EV_SI_SECURITY 0x02
  1668. struct hci_ev_si_security {
  1669. __u16 event;
  1670. __u16 proto;
  1671. __u16 subproto;
  1672. __u8 incoming;
  1673. } __packed;
  1674. /* ---- HCI Packet structures ---- */
  1675. #define HCI_COMMAND_HDR_SIZE 3
  1676. #define HCI_EVENT_HDR_SIZE 2
  1677. #define HCI_ACL_HDR_SIZE 4
  1678. #define HCI_SCO_HDR_SIZE 3
  1679. struct hci_command_hdr {
  1680. __le16 opcode; /* OCF & OGF */
  1681. __u8 plen;
  1682. } __packed;
  1683. struct hci_event_hdr {
  1684. __u8 evt;
  1685. __u8 plen;
  1686. } __packed;
  1687. struct hci_acl_hdr {
  1688. __le16 handle; /* Handle & Flags(PB, BC) */
  1689. __le16 dlen;
  1690. } __packed;
  1691. struct hci_sco_hdr {
  1692. __le16 handle;
  1693. __u8 dlen;
  1694. } __packed;
  1695. static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
  1696. {
  1697. return (struct hci_event_hdr *) skb->data;
  1698. }
  1699. static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
  1700. {
  1701. return (struct hci_acl_hdr *) skb->data;
  1702. }
  1703. static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
  1704. {
  1705. return (struct hci_sco_hdr *) skb->data;
  1706. }
  1707. /* Command opcode pack/unpack */
  1708. #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10)))
  1709. #define hci_opcode_ogf(op) (op >> 10)
  1710. #define hci_opcode_ocf(op) (op & 0x03ff)
  1711. /* ACL handle and flags pack/unpack */
  1712. #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12)))
  1713. #define hci_handle(h) (h & 0x0fff)
  1714. #define hci_flags(h) (h >> 12)
  1715. #endif /* __HCI_H */