hci.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  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. /* HCI dev events */
  27. #define HCI_DEV_REG 1
  28. #define HCI_DEV_UNREG 2
  29. #define HCI_DEV_UP 3
  30. #define HCI_DEV_DOWN 4
  31. #define HCI_DEV_SUSPEND 5
  32. #define HCI_DEV_RESUME 6
  33. /* HCI notify events */
  34. #define HCI_NOTIFY_CONN_ADD 1
  35. #define HCI_NOTIFY_CONN_DEL 2
  36. #define HCI_NOTIFY_VOICE_SETTING 3
  37. /* HCI bus types */
  38. #define HCI_VIRTUAL 0
  39. #define HCI_USB 1
  40. #define HCI_PCCARD 2
  41. #define HCI_UART 3
  42. #define HCI_RS232 4
  43. #define HCI_PCI 5
  44. #define HCI_SDIO 6
  45. /* HCI controller types */
  46. #define HCI_BREDR 0x00
  47. #define HCI_AMP 0x01
  48. /* HCI device quirks */
  49. enum {
  50. HCI_QUIRK_NO_RESET,
  51. HCI_QUIRK_RAW_DEVICE,
  52. HCI_QUIRK_FIXUP_BUFFER_SIZE
  53. };
  54. /* HCI device flags */
  55. enum {
  56. HCI_UP,
  57. HCI_INIT,
  58. HCI_RUNNING,
  59. HCI_PSCAN,
  60. HCI_ISCAN,
  61. HCI_AUTH,
  62. HCI_ENCRYPT,
  63. HCI_INQUIRY,
  64. HCI_RAW,
  65. HCI_SETUP,
  66. HCI_AUTO_OFF,
  67. HCI_MGMT,
  68. HCI_PAIRABLE,
  69. HCI_SERVICE_CACHE,
  70. HCI_LINK_KEYS,
  71. HCI_DEBUG_KEYS,
  72. HCI_RESET,
  73. };
  74. /* HCI ioctl defines */
  75. #define HCIDEVUP _IOW('H', 201, int)
  76. #define HCIDEVDOWN _IOW('H', 202, int)
  77. #define HCIDEVRESET _IOW('H', 203, int)
  78. #define HCIDEVRESTAT _IOW('H', 204, int)
  79. #define HCIGETDEVLIST _IOR('H', 210, int)
  80. #define HCIGETDEVINFO _IOR('H', 211, int)
  81. #define HCIGETCONNLIST _IOR('H', 212, int)
  82. #define HCIGETCONNINFO _IOR('H', 213, int)
  83. #define HCIGETAUTHINFO _IOR('H', 215, int)
  84. #define HCISETRAW _IOW('H', 220, int)
  85. #define HCISETSCAN _IOW('H', 221, int)
  86. #define HCISETAUTH _IOW('H', 222, int)
  87. #define HCISETENCRYPT _IOW('H', 223, int)
  88. #define HCISETPTYPE _IOW('H', 224, int)
  89. #define HCISETLINKPOL _IOW('H', 225, int)
  90. #define HCISETLINKMODE _IOW('H', 226, int)
  91. #define HCISETACLMTU _IOW('H', 227, int)
  92. #define HCISETSCOMTU _IOW('H', 228, int)
  93. #define HCIBLOCKADDR _IOW('H', 230, int)
  94. #define HCIUNBLOCKADDR _IOW('H', 231, int)
  95. #define HCIINQUIRY _IOR('H', 240, int)
  96. /* HCI timeouts */
  97. #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */
  98. #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */
  99. #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
  100. #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
  101. #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
  102. #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */
  103. /* HCI data types */
  104. #define HCI_COMMAND_PKT 0x01
  105. #define HCI_ACLDATA_PKT 0x02
  106. #define HCI_SCODATA_PKT 0x03
  107. #define HCI_EVENT_PKT 0x04
  108. #define HCI_VENDOR_PKT 0xff
  109. /* HCI packet types */
  110. #define HCI_DM1 0x0008
  111. #define HCI_DM3 0x0400
  112. #define HCI_DM5 0x4000
  113. #define HCI_DH1 0x0010
  114. #define HCI_DH3 0x0800
  115. #define HCI_DH5 0x8000
  116. #define HCI_HV1 0x0020
  117. #define HCI_HV2 0x0040
  118. #define HCI_HV3 0x0080
  119. #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
  120. #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
  121. /* eSCO packet types */
  122. #define ESCO_HV1 0x0001
  123. #define ESCO_HV2 0x0002
  124. #define ESCO_HV3 0x0004
  125. #define ESCO_EV3 0x0008
  126. #define ESCO_EV4 0x0010
  127. #define ESCO_EV5 0x0020
  128. #define ESCO_2EV3 0x0040
  129. #define ESCO_3EV3 0x0080
  130. #define ESCO_2EV5 0x0100
  131. #define ESCO_3EV5 0x0200
  132. #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3)
  133. #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
  134. /* ACL flags */
  135. #define ACL_START_NO_FLUSH 0x00
  136. #define ACL_CONT 0x01
  137. #define ACL_START 0x02
  138. #define ACL_ACTIVE_BCAST 0x04
  139. #define ACL_PICO_BCAST 0x08
  140. /* Baseband links */
  141. #define SCO_LINK 0x00
  142. #define ACL_LINK 0x01
  143. #define ESCO_LINK 0x02
  144. /* Low Energy links do not have defined link type. Use invented one */
  145. #define LE_LINK 0x80
  146. /* LMP features */
  147. #define LMP_3SLOT 0x01
  148. #define LMP_5SLOT 0x02
  149. #define LMP_ENCRYPT 0x04
  150. #define LMP_SOFFSET 0x08
  151. #define LMP_TACCURACY 0x10
  152. #define LMP_RSWITCH 0x20
  153. #define LMP_HOLD 0x40
  154. #define LMP_SNIFF 0x80
  155. #define LMP_PARK 0x01
  156. #define LMP_RSSI 0x02
  157. #define LMP_QUALITY 0x04
  158. #define LMP_SCO 0x08
  159. #define LMP_HV2 0x10
  160. #define LMP_HV3 0x20
  161. #define LMP_ULAW 0x40
  162. #define LMP_ALAW 0x80
  163. #define LMP_CVSD 0x01
  164. #define LMP_PSCHEME 0x02
  165. #define LMP_PCONTROL 0x04
  166. #define LMP_RSSI_INQ 0x40
  167. #define LMP_ESCO 0x80
  168. #define LMP_EV4 0x01
  169. #define LMP_EV5 0x02
  170. #define LMP_LE 0x40
  171. #define LMP_SNIFF_SUBR 0x02
  172. #define LMP_PAUSE_ENC 0x04
  173. #define LMP_EDR_ESCO_2M 0x20
  174. #define LMP_EDR_ESCO_3M 0x40
  175. #define LMP_EDR_3S_ESCO 0x80
  176. #define LMP_EXT_INQ 0x01
  177. #define LMP_SIMPLE_PAIR 0x08
  178. #define LMP_NO_FLUSH 0x40
  179. #define LMP_LSTO 0x01
  180. #define LMP_INQ_TX_PWR 0x02
  181. /* Connection modes */
  182. #define HCI_CM_ACTIVE 0x0000
  183. #define HCI_CM_HOLD 0x0001
  184. #define HCI_CM_SNIFF 0x0002
  185. #define HCI_CM_PARK 0x0003
  186. /* Link policies */
  187. #define HCI_LP_RSWITCH 0x0001
  188. #define HCI_LP_HOLD 0x0002
  189. #define HCI_LP_SNIFF 0x0004
  190. #define HCI_LP_PARK 0x0008
  191. /* Link modes */
  192. #define HCI_LM_ACCEPT 0x8000
  193. #define HCI_LM_MASTER 0x0001
  194. #define HCI_LM_AUTH 0x0002
  195. #define HCI_LM_ENCRYPT 0x0004
  196. #define HCI_LM_TRUSTED 0x0008
  197. #define HCI_LM_RELIABLE 0x0010
  198. #define HCI_LM_SECURE 0x0020
  199. /* Authentication types */
  200. #define HCI_AT_NO_BONDING 0x00
  201. #define HCI_AT_NO_BONDING_MITM 0x01
  202. #define HCI_AT_DEDICATED_BONDING 0x02
  203. #define HCI_AT_DEDICATED_BONDING_MITM 0x03
  204. #define HCI_AT_GENERAL_BONDING 0x04
  205. #define HCI_AT_GENERAL_BONDING_MITM 0x05
  206. /* Link Key types */
  207. #define HCI_LK_COMBINATION 0x00
  208. #define HCI_LK_LOCAL_UNIT 0x01
  209. #define HCI_LK_REMOTE_UNIT 0x02
  210. #define HCI_LK_DEBUG_COMBINATION 0x03
  211. #define HCI_LK_UNAUTH_COMBINATION 0x04
  212. #define HCI_LK_AUTH_COMBINATION 0x05
  213. #define HCI_LK_CHANGED_COMBINATION 0x06
  214. /* ----- HCI Commands ---- */
  215. #define HCI_OP_NOP 0x0000
  216. #define HCI_OP_INQUIRY 0x0401
  217. struct hci_cp_inquiry {
  218. __u8 lap[3];
  219. __u8 length;
  220. __u8 num_rsp;
  221. } __packed;
  222. #define HCI_OP_INQUIRY_CANCEL 0x0402
  223. #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
  224. #define HCI_OP_CREATE_CONN 0x0405
  225. struct hci_cp_create_conn {
  226. bdaddr_t bdaddr;
  227. __le16 pkt_type;
  228. __u8 pscan_rep_mode;
  229. __u8 pscan_mode;
  230. __le16 clock_offset;
  231. __u8 role_switch;
  232. } __packed;
  233. #define HCI_OP_DISCONNECT 0x0406
  234. struct hci_cp_disconnect {
  235. __le16 handle;
  236. __u8 reason;
  237. } __packed;
  238. #define HCI_OP_ADD_SCO 0x0407
  239. struct hci_cp_add_sco {
  240. __le16 handle;
  241. __le16 pkt_type;
  242. } __packed;
  243. #define HCI_OP_CREATE_CONN_CANCEL 0x0408
  244. struct hci_cp_create_conn_cancel {
  245. bdaddr_t bdaddr;
  246. } __packed;
  247. #define HCI_OP_ACCEPT_CONN_REQ 0x0409
  248. struct hci_cp_accept_conn_req {
  249. bdaddr_t bdaddr;
  250. __u8 role;
  251. } __packed;
  252. #define HCI_OP_REJECT_CONN_REQ 0x040a
  253. struct hci_cp_reject_conn_req {
  254. bdaddr_t bdaddr;
  255. __u8 reason;
  256. } __packed;
  257. #define HCI_OP_LINK_KEY_REPLY 0x040b
  258. struct hci_cp_link_key_reply {
  259. bdaddr_t bdaddr;
  260. __u8 link_key[16];
  261. } __packed;
  262. #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c
  263. struct hci_cp_link_key_neg_reply {
  264. bdaddr_t bdaddr;
  265. } __packed;
  266. #define HCI_OP_PIN_CODE_REPLY 0x040d
  267. struct hci_cp_pin_code_reply {
  268. bdaddr_t bdaddr;
  269. __u8 pin_len;
  270. __u8 pin_code[16];
  271. } __packed;
  272. struct hci_rp_pin_code_reply {
  273. __u8 status;
  274. bdaddr_t bdaddr;
  275. } __packed;
  276. #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
  277. struct hci_cp_pin_code_neg_reply {
  278. bdaddr_t bdaddr;
  279. } __packed;
  280. struct hci_rp_pin_code_neg_reply {
  281. __u8 status;
  282. bdaddr_t bdaddr;
  283. } __packed;
  284. #define HCI_OP_CHANGE_CONN_PTYPE 0x040f
  285. struct hci_cp_change_conn_ptype {
  286. __le16 handle;
  287. __le16 pkt_type;
  288. } __packed;
  289. #define HCI_OP_AUTH_REQUESTED 0x0411
  290. struct hci_cp_auth_requested {
  291. __le16 handle;
  292. } __packed;
  293. #define HCI_OP_SET_CONN_ENCRYPT 0x0413
  294. struct hci_cp_set_conn_encrypt {
  295. __le16 handle;
  296. __u8 encrypt;
  297. } __packed;
  298. #define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415
  299. struct hci_cp_change_conn_link_key {
  300. __le16 handle;
  301. } __packed;
  302. #define HCI_OP_REMOTE_NAME_REQ 0x0419
  303. struct hci_cp_remote_name_req {
  304. bdaddr_t bdaddr;
  305. __u8 pscan_rep_mode;
  306. __u8 pscan_mode;
  307. __le16 clock_offset;
  308. } __packed;
  309. #define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a
  310. struct hci_cp_remote_name_req_cancel {
  311. bdaddr_t bdaddr;
  312. } __packed;
  313. #define HCI_OP_READ_REMOTE_FEATURES 0x041b
  314. struct hci_cp_read_remote_features {
  315. __le16 handle;
  316. } __packed;
  317. #define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c
  318. struct hci_cp_read_remote_ext_features {
  319. __le16 handle;
  320. __u8 page;
  321. } __packed;
  322. #define HCI_OP_READ_REMOTE_VERSION 0x041d
  323. struct hci_cp_read_remote_version {
  324. __le16 handle;
  325. } __packed;
  326. #define HCI_OP_SETUP_SYNC_CONN 0x0428
  327. struct hci_cp_setup_sync_conn {
  328. __le16 handle;
  329. __le32 tx_bandwidth;
  330. __le32 rx_bandwidth;
  331. __le16 max_latency;
  332. __le16 voice_setting;
  333. __u8 retrans_effort;
  334. __le16 pkt_type;
  335. } __packed;
  336. #define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429
  337. struct hci_cp_accept_sync_conn_req {
  338. bdaddr_t bdaddr;
  339. __le32 tx_bandwidth;
  340. __le32 rx_bandwidth;
  341. __le16 max_latency;
  342. __le16 content_format;
  343. __u8 retrans_effort;
  344. __le16 pkt_type;
  345. } __packed;
  346. #define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a
  347. struct hci_cp_reject_sync_conn_req {
  348. bdaddr_t bdaddr;
  349. __u8 reason;
  350. } __packed;
  351. #define HCI_OP_IO_CAPABILITY_REPLY 0x042b
  352. struct hci_cp_io_capability_reply {
  353. bdaddr_t bdaddr;
  354. __u8 capability;
  355. __u8 oob_data;
  356. __u8 authentication;
  357. } __packed;
  358. #define HCI_OP_USER_CONFIRM_REPLY 0x042c
  359. struct hci_cp_user_confirm_reply {
  360. bdaddr_t bdaddr;
  361. } __packed;
  362. struct hci_rp_user_confirm_reply {
  363. __u8 status;
  364. bdaddr_t bdaddr;
  365. } __packed;
  366. #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
  367. #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
  368. struct hci_cp_remote_oob_data_reply {
  369. bdaddr_t bdaddr;
  370. __u8 hash[16];
  371. __u8 randomizer[16];
  372. } __packed;
  373. #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
  374. struct hci_cp_remote_oob_data_neg_reply {
  375. bdaddr_t bdaddr;
  376. } __packed;
  377. #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
  378. struct hci_cp_io_capability_neg_reply {
  379. bdaddr_t bdaddr;
  380. __u8 reason;
  381. } __packed;
  382. #define HCI_OP_SNIFF_MODE 0x0803
  383. struct hci_cp_sniff_mode {
  384. __le16 handle;
  385. __le16 max_interval;
  386. __le16 min_interval;
  387. __le16 attempt;
  388. __le16 timeout;
  389. } __packed;
  390. #define HCI_OP_EXIT_SNIFF_MODE 0x0804
  391. struct hci_cp_exit_sniff_mode {
  392. __le16 handle;
  393. } __packed;
  394. #define HCI_OP_ROLE_DISCOVERY 0x0809
  395. struct hci_cp_role_discovery {
  396. __le16 handle;
  397. } __packed;
  398. struct hci_rp_role_discovery {
  399. __u8 status;
  400. __le16 handle;
  401. __u8 role;
  402. } __packed;
  403. #define HCI_OP_SWITCH_ROLE 0x080b
  404. struct hci_cp_switch_role {
  405. bdaddr_t bdaddr;
  406. __u8 role;
  407. } __packed;
  408. #define HCI_OP_READ_LINK_POLICY 0x080c
  409. struct hci_cp_read_link_policy {
  410. __le16 handle;
  411. } __packed;
  412. struct hci_rp_read_link_policy {
  413. __u8 status;
  414. __le16 handle;
  415. __le16 policy;
  416. } __packed;
  417. #define HCI_OP_WRITE_LINK_POLICY 0x080d
  418. struct hci_cp_write_link_policy {
  419. __le16 handle;
  420. __le16 policy;
  421. } __packed;
  422. struct hci_rp_write_link_policy {
  423. __u8 status;
  424. __le16 handle;
  425. } __packed;
  426. #define HCI_OP_READ_DEF_LINK_POLICY 0x080e
  427. struct hci_rp_read_def_link_policy {
  428. __u8 status;
  429. __le16 policy;
  430. } __packed;
  431. #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f
  432. struct hci_cp_write_def_link_policy {
  433. __le16 policy;
  434. } __packed;
  435. #define HCI_OP_SNIFF_SUBRATE 0x0811
  436. struct hci_cp_sniff_subrate {
  437. __le16 handle;
  438. __le16 max_latency;
  439. __le16 min_remote_timeout;
  440. __le16 min_local_timeout;
  441. } __packed;
  442. #define HCI_OP_SET_EVENT_MASK 0x0c01
  443. struct hci_cp_set_event_mask {
  444. __u8 mask[8];
  445. } __packed;
  446. #define HCI_OP_RESET 0x0c03
  447. #define HCI_OP_SET_EVENT_FLT 0x0c05
  448. struct hci_cp_set_event_flt {
  449. __u8 flt_type;
  450. __u8 cond_type;
  451. __u8 condition[0];
  452. } __packed;
  453. /* Filter types */
  454. #define HCI_FLT_CLEAR_ALL 0x00
  455. #define HCI_FLT_INQ_RESULT 0x01
  456. #define HCI_FLT_CONN_SETUP 0x02
  457. /* CONN_SETUP Condition types */
  458. #define HCI_CONN_SETUP_ALLOW_ALL 0x00
  459. #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
  460. #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
  461. /* CONN_SETUP Conditions */
  462. #define HCI_CONN_SETUP_AUTO_OFF 0x01
  463. #define HCI_CONN_SETUP_AUTO_ON 0x02
  464. #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
  465. struct hci_cp_delete_stored_link_key {
  466. bdaddr_t bdaddr;
  467. __u8 delete_all;
  468. } __packed;
  469. #define HCI_MAX_NAME_LENGTH 248
  470. #define HCI_OP_WRITE_LOCAL_NAME 0x0c13
  471. struct hci_cp_write_local_name {
  472. __u8 name[HCI_MAX_NAME_LENGTH];
  473. } __packed;
  474. #define HCI_OP_READ_LOCAL_NAME 0x0c14
  475. struct hci_rp_read_local_name {
  476. __u8 status;
  477. __u8 name[HCI_MAX_NAME_LENGTH];
  478. } __packed;
  479. #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
  480. #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18
  481. #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a
  482. #define SCAN_DISABLED 0x00
  483. #define SCAN_INQUIRY 0x01
  484. #define SCAN_PAGE 0x02
  485. #define HCI_OP_READ_AUTH_ENABLE 0x0c1f
  486. #define HCI_OP_WRITE_AUTH_ENABLE 0x0c20
  487. #define AUTH_DISABLED 0x00
  488. #define AUTH_ENABLED 0x01
  489. #define HCI_OP_READ_ENCRYPT_MODE 0x0c21
  490. #define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22
  491. #define ENCRYPT_DISABLED 0x00
  492. #define ENCRYPT_P2P 0x01
  493. #define ENCRYPT_BOTH 0x02
  494. #define HCI_OP_READ_CLASS_OF_DEV 0x0c23
  495. struct hci_rp_read_class_of_dev {
  496. __u8 status;
  497. __u8 dev_class[3];
  498. } __packed;
  499. #define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24
  500. struct hci_cp_write_class_of_dev {
  501. __u8 dev_class[3];
  502. } __packed;
  503. #define HCI_OP_READ_VOICE_SETTING 0x0c25
  504. struct hci_rp_read_voice_setting {
  505. __u8 status;
  506. __le16 voice_setting;
  507. } __packed;
  508. #define HCI_OP_WRITE_VOICE_SETTING 0x0c26
  509. struct hci_cp_write_voice_setting {
  510. __le16 voice_setting;
  511. } __packed;
  512. #define HCI_OP_HOST_BUFFER_SIZE 0x0c33
  513. struct hci_cp_host_buffer_size {
  514. __le16 acl_mtu;
  515. __u8 sco_mtu;
  516. __le16 acl_max_pkt;
  517. __le16 sco_max_pkt;
  518. } __packed;
  519. #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
  520. #define HCI_MAX_EIR_LENGTH 240
  521. #define HCI_OP_WRITE_EIR 0x0c52
  522. struct hci_cp_write_eir {
  523. uint8_t fec;
  524. uint8_t data[HCI_MAX_EIR_LENGTH];
  525. } __packed;
  526. #define HCI_OP_READ_SSP_MODE 0x0c55
  527. struct hci_rp_read_ssp_mode {
  528. __u8 status;
  529. __u8 mode;
  530. } __packed;
  531. #define HCI_OP_WRITE_SSP_MODE 0x0c56
  532. struct hci_cp_write_ssp_mode {
  533. __u8 mode;
  534. } __packed;
  535. #define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
  536. struct hci_rp_read_local_oob_data {
  537. __u8 status;
  538. __u8 hash[16];
  539. __u8 randomizer[16];
  540. } __packed;
  541. #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
  542. #define HCI_OP_READ_LOCAL_VERSION 0x1001
  543. struct hci_rp_read_local_version {
  544. __u8 status;
  545. __u8 hci_ver;
  546. __le16 hci_rev;
  547. __u8 lmp_ver;
  548. __le16 manufacturer;
  549. __le16 lmp_subver;
  550. } __packed;
  551. #define HCI_OP_READ_LOCAL_COMMANDS 0x1002
  552. struct hci_rp_read_local_commands {
  553. __u8 status;
  554. __u8 commands[64];
  555. } __packed;
  556. #define HCI_OP_READ_LOCAL_FEATURES 0x1003
  557. struct hci_rp_read_local_features {
  558. __u8 status;
  559. __u8 features[8];
  560. } __packed;
  561. #define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004
  562. struct hci_rp_read_local_ext_features {
  563. __u8 status;
  564. __u8 page;
  565. __u8 max_page;
  566. __u8 features[8];
  567. } __packed;
  568. #define HCI_OP_READ_BUFFER_SIZE 0x1005
  569. struct hci_rp_read_buffer_size {
  570. __u8 status;
  571. __le16 acl_mtu;
  572. __u8 sco_mtu;
  573. __le16 acl_max_pkt;
  574. __le16 sco_max_pkt;
  575. } __packed;
  576. #define HCI_OP_READ_BD_ADDR 0x1009
  577. struct hci_rp_read_bd_addr {
  578. __u8 status;
  579. bdaddr_t bdaddr;
  580. } __packed;
  581. #define HCI_OP_LE_SET_EVENT_MASK 0x2001
  582. struct hci_cp_le_set_event_mask {
  583. __u8 mask[8];
  584. } __packed;
  585. #define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
  586. struct hci_rp_le_read_buffer_size {
  587. __u8 status;
  588. __le16 le_mtu;
  589. __u8 le_max_pkt;
  590. } __packed;
  591. #define HCI_OP_LE_CREATE_CONN 0x200d
  592. struct hci_cp_le_create_conn {
  593. __le16 scan_interval;
  594. __le16 scan_window;
  595. __u8 filter_policy;
  596. __u8 peer_addr_type;
  597. bdaddr_t peer_addr;
  598. __u8 own_address_type;
  599. __le16 conn_interval_min;
  600. __le16 conn_interval_max;
  601. __le16 conn_latency;
  602. __le16 supervision_timeout;
  603. __le16 min_ce_len;
  604. __le16 max_ce_len;
  605. } __packed;
  606. #define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
  607. #define HCI_OP_LE_CONN_UPDATE 0x2013
  608. struct hci_cp_le_conn_update {
  609. __le16 handle;
  610. __le16 conn_interval_min;
  611. __le16 conn_interval_max;
  612. __le16 conn_latency;
  613. __le16 supervision_timeout;
  614. __le16 min_ce_len;
  615. __le16 max_ce_len;
  616. } __packed;
  617. /* ---- HCI Events ---- */
  618. #define HCI_EV_INQUIRY_COMPLETE 0x01
  619. #define HCI_EV_INQUIRY_RESULT 0x02
  620. struct inquiry_info {
  621. bdaddr_t bdaddr;
  622. __u8 pscan_rep_mode;
  623. __u8 pscan_period_mode;
  624. __u8 pscan_mode;
  625. __u8 dev_class[3];
  626. __le16 clock_offset;
  627. } __packed;
  628. #define HCI_EV_CONN_COMPLETE 0x03
  629. struct hci_ev_conn_complete {
  630. __u8 status;
  631. __le16 handle;
  632. bdaddr_t bdaddr;
  633. __u8 link_type;
  634. __u8 encr_mode;
  635. } __packed;
  636. #define HCI_EV_CONN_REQUEST 0x04
  637. struct hci_ev_conn_request {
  638. bdaddr_t bdaddr;
  639. __u8 dev_class[3];
  640. __u8 link_type;
  641. } __packed;
  642. #define HCI_EV_DISCONN_COMPLETE 0x05
  643. struct hci_ev_disconn_complete {
  644. __u8 status;
  645. __le16 handle;
  646. __u8 reason;
  647. } __packed;
  648. #define HCI_EV_AUTH_COMPLETE 0x06
  649. struct hci_ev_auth_complete {
  650. __u8 status;
  651. __le16 handle;
  652. } __packed;
  653. #define HCI_EV_REMOTE_NAME 0x07
  654. struct hci_ev_remote_name {
  655. __u8 status;
  656. bdaddr_t bdaddr;
  657. __u8 name[HCI_MAX_NAME_LENGTH];
  658. } __packed;
  659. #define HCI_EV_ENCRYPT_CHANGE 0x08
  660. struct hci_ev_encrypt_change {
  661. __u8 status;
  662. __le16 handle;
  663. __u8 encrypt;
  664. } __packed;
  665. #define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09
  666. struct hci_ev_change_link_key_complete {
  667. __u8 status;
  668. __le16 handle;
  669. } __packed;
  670. #define HCI_EV_REMOTE_FEATURES 0x0b
  671. struct hci_ev_remote_features {
  672. __u8 status;
  673. __le16 handle;
  674. __u8 features[8];
  675. } __packed;
  676. #define HCI_EV_REMOTE_VERSION 0x0c
  677. struct hci_ev_remote_version {
  678. __u8 status;
  679. __le16 handle;
  680. __u8 lmp_ver;
  681. __le16 manufacturer;
  682. __le16 lmp_subver;
  683. } __packed;
  684. #define HCI_EV_QOS_SETUP_COMPLETE 0x0d
  685. struct hci_qos {
  686. __u8 service_type;
  687. __u32 token_rate;
  688. __u32 peak_bandwidth;
  689. __u32 latency;
  690. __u32 delay_variation;
  691. } __packed;
  692. struct hci_ev_qos_setup_complete {
  693. __u8 status;
  694. __le16 handle;
  695. struct hci_qos qos;
  696. } __packed;
  697. #define HCI_EV_CMD_COMPLETE 0x0e
  698. struct hci_ev_cmd_complete {
  699. __u8 ncmd;
  700. __le16 opcode;
  701. } __packed;
  702. #define HCI_EV_CMD_STATUS 0x0f
  703. struct hci_ev_cmd_status {
  704. __u8 status;
  705. __u8 ncmd;
  706. __le16 opcode;
  707. } __packed;
  708. #define HCI_EV_ROLE_CHANGE 0x12
  709. struct hci_ev_role_change {
  710. __u8 status;
  711. bdaddr_t bdaddr;
  712. __u8 role;
  713. } __packed;
  714. #define HCI_EV_NUM_COMP_PKTS 0x13
  715. struct hci_ev_num_comp_pkts {
  716. __u8 num_hndl;
  717. /* variable length part */
  718. } __packed;
  719. #define HCI_EV_MODE_CHANGE 0x14
  720. struct hci_ev_mode_change {
  721. __u8 status;
  722. __le16 handle;
  723. __u8 mode;
  724. __le16 interval;
  725. } __packed;
  726. #define HCI_EV_PIN_CODE_REQ 0x16
  727. struct hci_ev_pin_code_req {
  728. bdaddr_t bdaddr;
  729. } __packed;
  730. #define HCI_EV_LINK_KEY_REQ 0x17
  731. struct hci_ev_link_key_req {
  732. bdaddr_t bdaddr;
  733. } __packed;
  734. #define HCI_EV_LINK_KEY_NOTIFY 0x18
  735. struct hci_ev_link_key_notify {
  736. bdaddr_t bdaddr;
  737. __u8 link_key[16];
  738. __u8 key_type;
  739. } __packed;
  740. #define HCI_EV_CLOCK_OFFSET 0x1c
  741. struct hci_ev_clock_offset {
  742. __u8 status;
  743. __le16 handle;
  744. __le16 clock_offset;
  745. } __packed;
  746. #define HCI_EV_PKT_TYPE_CHANGE 0x1d
  747. struct hci_ev_pkt_type_change {
  748. __u8 status;
  749. __le16 handle;
  750. __le16 pkt_type;
  751. } __packed;
  752. #define HCI_EV_PSCAN_REP_MODE 0x20
  753. struct hci_ev_pscan_rep_mode {
  754. bdaddr_t bdaddr;
  755. __u8 pscan_rep_mode;
  756. } __packed;
  757. #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
  758. struct inquiry_info_with_rssi {
  759. bdaddr_t bdaddr;
  760. __u8 pscan_rep_mode;
  761. __u8 pscan_period_mode;
  762. __u8 dev_class[3];
  763. __le16 clock_offset;
  764. __s8 rssi;
  765. } __packed;
  766. struct inquiry_info_with_rssi_and_pscan_mode {
  767. bdaddr_t bdaddr;
  768. __u8 pscan_rep_mode;
  769. __u8 pscan_period_mode;
  770. __u8 pscan_mode;
  771. __u8 dev_class[3];
  772. __le16 clock_offset;
  773. __s8 rssi;
  774. } __packed;
  775. #define HCI_EV_REMOTE_EXT_FEATURES 0x23
  776. struct hci_ev_remote_ext_features {
  777. __u8 status;
  778. __le16 handle;
  779. __u8 page;
  780. __u8 max_page;
  781. __u8 features[8];
  782. } __packed;
  783. #define HCI_EV_SYNC_CONN_COMPLETE 0x2c
  784. struct hci_ev_sync_conn_complete {
  785. __u8 status;
  786. __le16 handle;
  787. bdaddr_t bdaddr;
  788. __u8 link_type;
  789. __u8 tx_interval;
  790. __u8 retrans_window;
  791. __le16 rx_pkt_len;
  792. __le16 tx_pkt_len;
  793. __u8 air_mode;
  794. } __packed;
  795. #define HCI_EV_SYNC_CONN_CHANGED 0x2d
  796. struct hci_ev_sync_conn_changed {
  797. __u8 status;
  798. __le16 handle;
  799. __u8 tx_interval;
  800. __u8 retrans_window;
  801. __le16 rx_pkt_len;
  802. __le16 tx_pkt_len;
  803. } __packed;
  804. #define HCI_EV_SNIFF_SUBRATE 0x2e
  805. struct hci_ev_sniff_subrate {
  806. __u8 status;
  807. __le16 handle;
  808. __le16 max_tx_latency;
  809. __le16 max_rx_latency;
  810. __le16 max_remote_timeout;
  811. __le16 max_local_timeout;
  812. } __packed;
  813. #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f
  814. struct extended_inquiry_info {
  815. bdaddr_t bdaddr;
  816. __u8 pscan_rep_mode;
  817. __u8 pscan_period_mode;
  818. __u8 dev_class[3];
  819. __le16 clock_offset;
  820. __s8 rssi;
  821. __u8 data[240];
  822. } __packed;
  823. #define HCI_EV_IO_CAPA_REQUEST 0x31
  824. struct hci_ev_io_capa_request {
  825. bdaddr_t bdaddr;
  826. } __packed;
  827. #define HCI_EV_IO_CAPA_REPLY 0x32
  828. struct hci_ev_io_capa_reply {
  829. bdaddr_t bdaddr;
  830. __u8 capability;
  831. __u8 oob_data;
  832. __u8 authentication;
  833. } __packed;
  834. #define HCI_EV_USER_CONFIRM_REQUEST 0x33
  835. struct hci_ev_user_confirm_req {
  836. bdaddr_t bdaddr;
  837. __le32 passkey;
  838. } __packed;
  839. #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
  840. struct hci_ev_remote_oob_data_request {
  841. bdaddr_t bdaddr;
  842. } __packed;
  843. #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
  844. struct hci_ev_simple_pair_complete {
  845. __u8 status;
  846. bdaddr_t bdaddr;
  847. } __packed;
  848. #define HCI_EV_REMOTE_HOST_FEATURES 0x3d
  849. struct hci_ev_remote_host_features {
  850. bdaddr_t bdaddr;
  851. __u8 features[8];
  852. } __packed;
  853. #define HCI_EV_LE_META 0x3e
  854. struct hci_ev_le_meta {
  855. __u8 subevent;
  856. } __packed;
  857. /* Low energy meta events */
  858. #define HCI_EV_LE_CONN_COMPLETE 0x01
  859. struct hci_ev_le_conn_complete {
  860. __u8 status;
  861. __le16 handle;
  862. __u8 role;
  863. __u8 bdaddr_type;
  864. bdaddr_t bdaddr;
  865. __le16 interval;
  866. __le16 latency;
  867. __le16 supervision_timeout;
  868. __u8 clk_accurancy;
  869. } __packed;
  870. /* Internal events generated by Bluetooth stack */
  871. #define HCI_EV_STACK_INTERNAL 0xfd
  872. struct hci_ev_stack_internal {
  873. __u16 type;
  874. __u8 data[0];
  875. } __packed;
  876. #define HCI_EV_SI_DEVICE 0x01
  877. struct hci_ev_si_device {
  878. __u16 event;
  879. __u16 dev_id;
  880. } __packed;
  881. #define HCI_EV_SI_SECURITY 0x02
  882. struct hci_ev_si_security {
  883. __u16 event;
  884. __u16 proto;
  885. __u16 subproto;
  886. __u8 incoming;
  887. } __packed;
  888. /* ---- HCI Packet structures ---- */
  889. #define HCI_COMMAND_HDR_SIZE 3
  890. #define HCI_EVENT_HDR_SIZE 2
  891. #define HCI_ACL_HDR_SIZE 4
  892. #define HCI_SCO_HDR_SIZE 3
  893. struct hci_command_hdr {
  894. __le16 opcode; /* OCF & OGF */
  895. __u8 plen;
  896. } __packed;
  897. struct hci_event_hdr {
  898. __u8 evt;
  899. __u8 plen;
  900. } __packed;
  901. struct hci_acl_hdr {
  902. __le16 handle; /* Handle & Flags(PB, BC) */
  903. __le16 dlen;
  904. } __packed;
  905. struct hci_sco_hdr {
  906. __le16 handle;
  907. __u8 dlen;
  908. } __packed;
  909. #ifdef __KERNEL__
  910. #include <linux/skbuff.h>
  911. static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
  912. {
  913. return (struct hci_event_hdr *) skb->data;
  914. }
  915. static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
  916. {
  917. return (struct hci_acl_hdr *) skb->data;
  918. }
  919. static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
  920. {
  921. return (struct hci_sco_hdr *) skb->data;
  922. }
  923. #endif
  924. /* Command opcode pack/unpack */
  925. #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
  926. #define hci_opcode_ogf(op) (op >> 10)
  927. #define hci_opcode_ocf(op) (op & 0x03ff)
  928. /* ACL handle and flags pack/unpack */
  929. #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
  930. #define hci_handle(h) (h & 0x0fff)
  931. #define hci_flags(h) (h >> 12)
  932. /* ---- HCI Sockets ---- */
  933. /* Socket options */
  934. #define HCI_DATA_DIR 1
  935. #define HCI_FILTER 2
  936. #define HCI_TIME_STAMP 3
  937. /* CMSG flags */
  938. #define HCI_CMSG_DIR 0x0001
  939. #define HCI_CMSG_TSTAMP 0x0002
  940. struct sockaddr_hci {
  941. sa_family_t hci_family;
  942. unsigned short hci_dev;
  943. unsigned short hci_channel;
  944. };
  945. #define HCI_DEV_NONE 0xffff
  946. #define HCI_CHANNEL_RAW 0
  947. #define HCI_CHANNEL_CONTROL 1
  948. struct hci_filter {
  949. unsigned long type_mask;
  950. unsigned long event_mask[2];
  951. __le16 opcode;
  952. };
  953. struct hci_ufilter {
  954. __u32 type_mask;
  955. __u32 event_mask[2];
  956. __le16 opcode;
  957. };
  958. #define HCI_FLT_TYPE_BITS 31
  959. #define HCI_FLT_EVENT_BITS 63
  960. #define HCI_FLT_OGF_BITS 63
  961. #define HCI_FLT_OCF_BITS 127
  962. /* ---- HCI Ioctl requests structures ---- */
  963. struct hci_dev_stats {
  964. __u32 err_rx;
  965. __u32 err_tx;
  966. __u32 cmd_tx;
  967. __u32 evt_rx;
  968. __u32 acl_tx;
  969. __u32 acl_rx;
  970. __u32 sco_tx;
  971. __u32 sco_rx;
  972. __u32 byte_rx;
  973. __u32 byte_tx;
  974. };
  975. struct hci_dev_info {
  976. __u16 dev_id;
  977. char name[8];
  978. bdaddr_t bdaddr;
  979. __u32 flags;
  980. __u8 type;
  981. __u8 features[8];
  982. __u32 pkt_type;
  983. __u32 link_policy;
  984. __u32 link_mode;
  985. __u16 acl_mtu;
  986. __u16 acl_pkts;
  987. __u16 sco_mtu;
  988. __u16 sco_pkts;
  989. struct hci_dev_stats stat;
  990. };
  991. struct hci_conn_info {
  992. __u16 handle;
  993. bdaddr_t bdaddr;
  994. __u8 type;
  995. __u8 out;
  996. __u16 state;
  997. __u32 link_mode;
  998. };
  999. struct hci_dev_req {
  1000. __u16 dev_id;
  1001. __u32 dev_opt;
  1002. };
  1003. struct hci_dev_list_req {
  1004. __u16 dev_num;
  1005. struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
  1006. };
  1007. struct hci_conn_list_req {
  1008. __u16 dev_id;
  1009. __u16 conn_num;
  1010. struct hci_conn_info conn_info[0];
  1011. };
  1012. struct hci_conn_info_req {
  1013. bdaddr_t bdaddr;
  1014. __u8 type;
  1015. struct hci_conn_info conn_info[0];
  1016. };
  1017. struct hci_auth_info_req {
  1018. bdaddr_t bdaddr;
  1019. __u8 type;
  1020. };
  1021. struct hci_inquiry_req {
  1022. __u16 dev_id;
  1023. __u16 flags;
  1024. __u8 lap[3];
  1025. __u8 length;
  1026. __u8 num_rsp;
  1027. };
  1028. #define IREQ_CACHE_FLUSH 0x0001
  1029. #endif /* __HCI_H */