hci.h 23 KB

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