hci.h 46 KB

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