hci.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  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_VHCI 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. /* HCI device quirks */
  45. enum {
  46. HCI_QUIRK_RESET_ON_INIT,
  47. HCI_QUIRK_RAW_DEVICE,
  48. HCI_QUIRK_FIXUP_BUFFER_SIZE
  49. };
  50. /* HCI device flags */
  51. enum {
  52. HCI_UP,
  53. HCI_INIT,
  54. HCI_RUNNING,
  55. HCI_PSCAN,
  56. HCI_ISCAN,
  57. HCI_AUTH,
  58. HCI_ENCRYPT,
  59. HCI_INQUIRY,
  60. HCI_RAW,
  61. HCI_SECMGR
  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 HCISETRAW _IOW('H', 220, int)
  73. #define HCISETSCAN _IOW('H', 221, int)
  74. #define HCISETAUTH _IOW('H', 222, int)
  75. #define HCISETENCRYPT _IOW('H', 223, int)
  76. #define HCISETPTYPE _IOW('H', 224, int)
  77. #define HCISETLINKPOL _IOW('H', 225, int)
  78. #define HCISETLINKMODE _IOW('H', 226, int)
  79. #define HCISETACLMTU _IOW('H', 227, int)
  80. #define HCISETSCOMTU _IOW('H', 228, int)
  81. #define HCISETSECMGR _IOW('H', 230, 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_IDLE_TIMEOUT (6000) /* 6 seconds */
  87. #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
  88. /* HCI Packet types */
  89. #define HCI_COMMAND_PKT 0x01
  90. #define HCI_ACLDATA_PKT 0x02
  91. #define HCI_SCODATA_PKT 0x03
  92. #define HCI_EVENT_PKT 0x04
  93. #define HCI_VENDOR_PKT 0xff
  94. /* HCI Packet types */
  95. #define HCI_DM1 0x0008
  96. #define HCI_DM3 0x0400
  97. #define HCI_DM5 0x4000
  98. #define HCI_DH1 0x0010
  99. #define HCI_DH3 0x0800
  100. #define HCI_DH5 0x8000
  101. #define HCI_HV1 0x0020
  102. #define HCI_HV2 0x0040
  103. #define HCI_HV3 0x0080
  104. #define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3)
  105. #define ACL_PTYPE_MASK (~SCO_PTYPE_MASK)
  106. /* ACL flags */
  107. #define ACL_CONT 0x01
  108. #define ACL_START 0x02
  109. #define ACL_ACTIVE_BCAST 0x04
  110. #define ACL_PICO_BCAST 0x08
  111. /* Baseband links */
  112. #define SCO_LINK 0x00
  113. #define ACL_LINK 0x01
  114. /* LMP features */
  115. #define LMP_3SLOT 0x01
  116. #define LMP_5SLOT 0x02
  117. #define LMP_ENCRYPT 0x04
  118. #define LMP_SOFFSET 0x08
  119. #define LMP_TACCURACY 0x10
  120. #define LMP_RSWITCH 0x20
  121. #define LMP_HOLD 0x40
  122. #define LMP_SNIFF 0x80
  123. #define LMP_PARK 0x01
  124. #define LMP_RSSI 0x02
  125. #define LMP_QUALITY 0x04
  126. #define LMP_SCO 0x08
  127. #define LMP_HV2 0x10
  128. #define LMP_HV3 0x20
  129. #define LMP_ULAW 0x40
  130. #define LMP_ALAW 0x80
  131. #define LMP_CVSD 0x01
  132. #define LMP_PSCHEME 0x02
  133. #define LMP_PCONTROL 0x04
  134. #define LMP_SNIFF_SUBR 0x02
  135. /* Connection modes */
  136. #define HCI_CM_ACTIVE 0x0000
  137. #define HCI_CM_HOLD 0x0001
  138. #define HCI_CM_SNIFF 0x0002
  139. #define HCI_CM_PARK 0x0003
  140. /* Link policies */
  141. #define HCI_LP_RSWITCH 0x0001
  142. #define HCI_LP_HOLD 0x0002
  143. #define HCI_LP_SNIFF 0x0004
  144. #define HCI_LP_PARK 0x0008
  145. /* Link modes */
  146. #define HCI_LM_ACCEPT 0x8000
  147. #define HCI_LM_MASTER 0x0001
  148. #define HCI_LM_AUTH 0x0002
  149. #define HCI_LM_ENCRYPT 0x0004
  150. #define HCI_LM_TRUSTED 0x0008
  151. #define HCI_LM_RELIABLE 0x0010
  152. #define HCI_LM_SECURE 0x0020
  153. /* ----- HCI Commands ---- */
  154. /* OGF & OCF values */
  155. /* Informational Parameters */
  156. #define OGF_INFO_PARAM 0x04
  157. #define OCF_READ_LOCAL_VERSION 0x0001
  158. struct hci_rp_read_loc_version {
  159. __u8 status;
  160. __u8 hci_ver;
  161. __le16 hci_rev;
  162. __u8 lmp_ver;
  163. __le16 manufacturer;
  164. __le16 lmp_subver;
  165. } __attribute__ ((packed));
  166. #define OCF_READ_LOCAL_FEATURES 0x0003
  167. struct hci_rp_read_local_features {
  168. __u8 status;
  169. __u8 features[8];
  170. } __attribute__ ((packed));
  171. #define OCF_READ_BUFFER_SIZE 0x0005
  172. struct hci_rp_read_buffer_size {
  173. __u8 status;
  174. __le16 acl_mtu;
  175. __u8 sco_mtu;
  176. __le16 acl_max_pkt;
  177. __le16 sco_max_pkt;
  178. } __attribute__ ((packed));
  179. #define OCF_READ_BD_ADDR 0x0009
  180. struct hci_rp_read_bd_addr {
  181. __u8 status;
  182. bdaddr_t bdaddr;
  183. } __attribute__ ((packed));
  184. /* Host Controller and Baseband */
  185. #define OGF_HOST_CTL 0x03
  186. #define OCF_RESET 0x0003
  187. #define OCF_READ_AUTH_ENABLE 0x001F
  188. #define OCF_WRITE_AUTH_ENABLE 0x0020
  189. #define AUTH_DISABLED 0x00
  190. #define AUTH_ENABLED 0x01
  191. #define OCF_READ_ENCRYPT_MODE 0x0021
  192. #define OCF_WRITE_ENCRYPT_MODE 0x0022
  193. #define ENCRYPT_DISABLED 0x00
  194. #define ENCRYPT_P2P 0x01
  195. #define ENCRYPT_BOTH 0x02
  196. #define OCF_WRITE_CA_TIMEOUT 0x0016
  197. #define OCF_WRITE_PG_TIMEOUT 0x0018
  198. #define OCF_WRITE_SCAN_ENABLE 0x001A
  199. #define SCAN_DISABLED 0x00
  200. #define SCAN_INQUIRY 0x01
  201. #define SCAN_PAGE 0x02
  202. #define OCF_SET_EVENT_FLT 0x0005
  203. struct hci_cp_set_event_flt {
  204. __u8 flt_type;
  205. __u8 cond_type;
  206. __u8 condition[0];
  207. } __attribute__ ((packed));
  208. /* Filter types */
  209. #define HCI_FLT_CLEAR_ALL 0x00
  210. #define HCI_FLT_INQ_RESULT 0x01
  211. #define HCI_FLT_CONN_SETUP 0x02
  212. /* CONN_SETUP Condition types */
  213. #define HCI_CONN_SETUP_ALLOW_ALL 0x00
  214. #define HCI_CONN_SETUP_ALLOW_CLASS 0x01
  215. #define HCI_CONN_SETUP_ALLOW_BDADDR 0x02
  216. /* CONN_SETUP Conditions */
  217. #define HCI_CONN_SETUP_AUTO_OFF 0x01
  218. #define HCI_CONN_SETUP_AUTO_ON 0x02
  219. #define OCF_READ_CLASS_OF_DEV 0x0023
  220. struct hci_rp_read_dev_class {
  221. __u8 status;
  222. __u8 dev_class[3];
  223. } __attribute__ ((packed));
  224. #define OCF_WRITE_CLASS_OF_DEV 0x0024
  225. struct hci_cp_write_dev_class {
  226. __u8 dev_class[3];
  227. } __attribute__ ((packed));
  228. #define OCF_READ_VOICE_SETTING 0x0025
  229. struct hci_rp_read_voice_setting {
  230. __u8 status;
  231. __le16 voice_setting;
  232. } __attribute__ ((packed));
  233. #define OCF_WRITE_VOICE_SETTING 0x0026
  234. struct hci_cp_write_voice_setting {
  235. __le16 voice_setting;
  236. } __attribute__ ((packed));
  237. #define OCF_HOST_BUFFER_SIZE 0x0033
  238. struct hci_cp_host_buffer_size {
  239. __le16 acl_mtu;
  240. __u8 sco_mtu;
  241. __le16 acl_max_pkt;
  242. __le16 sco_max_pkt;
  243. } __attribute__ ((packed));
  244. /* Link Control */
  245. #define OGF_LINK_CTL 0x01
  246. #define OCF_CREATE_CONN 0x0005
  247. struct hci_cp_create_conn {
  248. bdaddr_t bdaddr;
  249. __le16 pkt_type;
  250. __u8 pscan_rep_mode;
  251. __u8 pscan_mode;
  252. __le16 clock_offset;
  253. __u8 role_switch;
  254. } __attribute__ ((packed));
  255. #define OCF_ACCEPT_CONN_REQ 0x0009
  256. struct hci_cp_accept_conn_req {
  257. bdaddr_t bdaddr;
  258. __u8 role;
  259. } __attribute__ ((packed));
  260. #define OCF_REJECT_CONN_REQ 0x000a
  261. struct hci_cp_reject_conn_req {
  262. bdaddr_t bdaddr;
  263. __u8 reason;
  264. } __attribute__ ((packed));
  265. #define OCF_DISCONNECT 0x0006
  266. struct hci_cp_disconnect {
  267. __le16 handle;
  268. __u8 reason;
  269. } __attribute__ ((packed));
  270. #define OCF_ADD_SCO 0x0007
  271. struct hci_cp_add_sco {
  272. __le16 handle;
  273. __le16 pkt_type;
  274. } __attribute__ ((packed));
  275. #define OCF_INQUIRY 0x0001
  276. struct hci_cp_inquiry {
  277. __u8 lap[3];
  278. __u8 length;
  279. __u8 num_rsp;
  280. } __attribute__ ((packed));
  281. #define OCF_INQUIRY_CANCEL 0x0002
  282. #define OCF_LINK_KEY_REPLY 0x000B
  283. struct hci_cp_link_key_reply {
  284. bdaddr_t bdaddr;
  285. __u8 link_key[16];
  286. } __attribute__ ((packed));
  287. #define OCF_LINK_KEY_NEG_REPLY 0x000C
  288. struct hci_cp_link_key_neg_reply {
  289. bdaddr_t bdaddr;
  290. } __attribute__ ((packed));
  291. #define OCF_PIN_CODE_REPLY 0x000D
  292. struct hci_cp_pin_code_reply {
  293. bdaddr_t bdaddr;
  294. __u8 pin_len;
  295. __u8 pin_code[16];
  296. } __attribute__ ((packed));
  297. #define OCF_PIN_CODE_NEG_REPLY 0x000E
  298. struct hci_cp_pin_code_neg_reply {
  299. bdaddr_t bdaddr;
  300. } __attribute__ ((packed));
  301. #define OCF_CHANGE_CONN_PTYPE 0x000F
  302. struct hci_cp_change_conn_ptype {
  303. __le16 handle;
  304. __le16 pkt_type;
  305. } __attribute__ ((packed));
  306. #define OCF_AUTH_REQUESTED 0x0011
  307. struct hci_cp_auth_requested {
  308. __le16 handle;
  309. } __attribute__ ((packed));
  310. #define OCF_SET_CONN_ENCRYPT 0x0013
  311. struct hci_cp_set_conn_encrypt {
  312. __le16 handle;
  313. __u8 encrypt;
  314. } __attribute__ ((packed));
  315. #define OCF_CHANGE_CONN_LINK_KEY 0x0015
  316. struct hci_cp_change_conn_link_key {
  317. __le16 handle;
  318. } __attribute__ ((packed));
  319. #define OCF_READ_REMOTE_FEATURES 0x001B
  320. struct hci_cp_read_remote_features {
  321. __le16 handle;
  322. } __attribute__ ((packed));
  323. #define OCF_READ_REMOTE_VERSION 0x001D
  324. struct hci_cp_read_remote_version {
  325. __le16 handle;
  326. } __attribute__ ((packed));
  327. /* Link Policy */
  328. #define OGF_LINK_POLICY 0x02
  329. #define OCF_SNIFF_MODE 0x0003
  330. struct hci_cp_sniff_mode {
  331. __le16 handle;
  332. __le16 max_interval;
  333. __le16 min_interval;
  334. __le16 attempt;
  335. __le16 timeout;
  336. } __attribute__ ((packed));
  337. #define OCF_EXIT_SNIFF_MODE 0x0004
  338. struct hci_cp_exit_sniff_mode {
  339. __le16 handle;
  340. } __attribute__ ((packed));
  341. #define OCF_ROLE_DISCOVERY 0x0009
  342. struct hci_cp_role_discovery {
  343. __le16 handle;
  344. } __attribute__ ((packed));
  345. struct hci_rp_role_discovery {
  346. __u8 status;
  347. __le16 handle;
  348. __u8 role;
  349. } __attribute__ ((packed));
  350. #define OCF_READ_LINK_POLICY 0x000C
  351. struct hci_cp_read_link_policy {
  352. __le16 handle;
  353. } __attribute__ ((packed));
  354. struct hci_rp_read_link_policy {
  355. __u8 status;
  356. __le16 handle;
  357. __le16 policy;
  358. } __attribute__ ((packed));
  359. #define OCF_SWITCH_ROLE 0x000B
  360. struct hci_cp_switch_role {
  361. bdaddr_t bdaddr;
  362. __u8 role;
  363. } __attribute__ ((packed));
  364. #define OCF_WRITE_LINK_POLICY 0x000D
  365. struct hci_cp_write_link_policy {
  366. __le16 handle;
  367. __le16 policy;
  368. } __attribute__ ((packed));
  369. struct hci_rp_write_link_policy {
  370. __u8 status;
  371. __le16 handle;
  372. } __attribute__ ((packed));
  373. #define OCF_SNIFF_SUBRATE 0x0011
  374. struct hci_cp_sniff_subrate {
  375. __le16 handle;
  376. __le16 max_latency;
  377. __le16 min_remote_timeout;
  378. __le16 min_local_timeout;
  379. } __attribute__ ((packed));
  380. /* Status params */
  381. #define OGF_STATUS_PARAM 0x05
  382. /* Testing commands */
  383. #define OGF_TESTING_CMD 0x3E
  384. /* Vendor specific commands */
  385. #define OGF_VENDOR_CMD 0x3F
  386. /* ---- HCI Events ---- */
  387. #define HCI_EV_INQUIRY_COMPLETE 0x01
  388. #define HCI_EV_INQUIRY_RESULT 0x02
  389. struct inquiry_info {
  390. bdaddr_t bdaddr;
  391. __u8 pscan_rep_mode;
  392. __u8 pscan_period_mode;
  393. __u8 pscan_mode;
  394. __u8 dev_class[3];
  395. __le16 clock_offset;
  396. } __attribute__ ((packed));
  397. #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22
  398. struct inquiry_info_with_rssi {
  399. bdaddr_t bdaddr;
  400. __u8 pscan_rep_mode;
  401. __u8 pscan_period_mode;
  402. __u8 dev_class[3];
  403. __le16 clock_offset;
  404. __s8 rssi;
  405. } __attribute__ ((packed));
  406. struct inquiry_info_with_rssi_and_pscan_mode {
  407. bdaddr_t bdaddr;
  408. __u8 pscan_rep_mode;
  409. __u8 pscan_period_mode;
  410. __u8 pscan_mode;
  411. __u8 dev_class[3];
  412. __le16 clock_offset;
  413. __s8 rssi;
  414. } __attribute__ ((packed));
  415. #define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2F
  416. struct extended_inquiry_info {
  417. bdaddr_t bdaddr;
  418. __u8 pscan_rep_mode;
  419. __u8 pscan_period_mode;
  420. __u8 dev_class[3];
  421. __le16 clock_offset;
  422. __s8 rssi;
  423. __u8 data[240];
  424. } __attribute__ ((packed));
  425. #define HCI_EV_CONN_COMPLETE 0x03
  426. struct hci_ev_conn_complete {
  427. __u8 status;
  428. __le16 handle;
  429. bdaddr_t bdaddr;
  430. __u8 link_type;
  431. __u8 encr_mode;
  432. } __attribute__ ((packed));
  433. #define HCI_EV_CONN_REQUEST 0x04
  434. struct hci_ev_conn_request {
  435. bdaddr_t bdaddr;
  436. __u8 dev_class[3];
  437. __u8 link_type;
  438. } __attribute__ ((packed));
  439. #define HCI_EV_DISCONN_COMPLETE 0x05
  440. struct hci_ev_disconn_complete {
  441. __u8 status;
  442. __le16 handle;
  443. __u8 reason;
  444. } __attribute__ ((packed));
  445. #define HCI_EV_AUTH_COMPLETE 0x06
  446. struct hci_ev_auth_complete {
  447. __u8 status;
  448. __le16 handle;
  449. } __attribute__ ((packed));
  450. #define HCI_EV_ENCRYPT_CHANGE 0x08
  451. struct hci_ev_encrypt_change {
  452. __u8 status;
  453. __le16 handle;
  454. __u8 encrypt;
  455. } __attribute__ ((packed));
  456. #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
  457. struct hci_ev_change_conn_link_key_complete {
  458. __u8 status;
  459. __le16 handle;
  460. } __attribute__ ((packed));
  461. #define HCI_EV_QOS_SETUP_COMPLETE 0x0D
  462. struct hci_qos {
  463. __u8 service_type;
  464. __u32 token_rate;
  465. __u32 peak_bandwidth;
  466. __u32 latency;
  467. __u32 delay_variation;
  468. } __attribute__ ((packed));
  469. struct hci_ev_qos_setup_complete {
  470. __u8 status;
  471. __le16 handle;
  472. struct hci_qos qos;
  473. } __attribute__ ((packed));
  474. #define HCI_EV_CMD_COMPLETE 0x0E
  475. struct hci_ev_cmd_complete {
  476. __u8 ncmd;
  477. __le16 opcode;
  478. } __attribute__ ((packed));
  479. #define HCI_EV_CMD_STATUS 0x0F
  480. struct hci_ev_cmd_status {
  481. __u8 status;
  482. __u8 ncmd;
  483. __le16 opcode;
  484. } __attribute__ ((packed));
  485. #define HCI_EV_NUM_COMP_PKTS 0x13
  486. struct hci_ev_num_comp_pkts {
  487. __u8 num_hndl;
  488. /* variable length part */
  489. } __attribute__ ((packed));
  490. #define HCI_EV_ROLE_CHANGE 0x12
  491. struct hci_ev_role_change {
  492. __u8 status;
  493. bdaddr_t bdaddr;
  494. __u8 role;
  495. } __attribute__ ((packed));
  496. #define HCI_EV_MODE_CHANGE 0x14
  497. struct hci_ev_mode_change {
  498. __u8 status;
  499. __le16 handle;
  500. __u8 mode;
  501. __le16 interval;
  502. } __attribute__ ((packed));
  503. #define HCI_EV_PIN_CODE_REQ 0x16
  504. struct hci_ev_pin_code_req {
  505. bdaddr_t bdaddr;
  506. } __attribute__ ((packed));
  507. #define HCI_EV_LINK_KEY_REQ 0x17
  508. struct hci_ev_link_key_req {
  509. bdaddr_t bdaddr;
  510. } __attribute__ ((packed));
  511. #define HCI_EV_LINK_KEY_NOTIFY 0x18
  512. struct hci_ev_link_key_notify {
  513. bdaddr_t bdaddr;
  514. __u8 link_key[16];
  515. __u8 key_type;
  516. } __attribute__ ((packed));
  517. #define HCI_EV_REMOTE_FEATURES 0x0B
  518. struct hci_ev_remote_features {
  519. __u8 status;
  520. __le16 handle;
  521. __u8 features[8];
  522. } __attribute__ ((packed));
  523. #define HCI_EV_REMOTE_VERSION 0x0C
  524. struct hci_ev_remote_version {
  525. __u8 status;
  526. __le16 handle;
  527. __u8 lmp_ver;
  528. __le16 manufacturer;
  529. __le16 lmp_subver;
  530. } __attribute__ ((packed));
  531. #define HCI_EV_CLOCK_OFFSET 0x01C
  532. struct hci_ev_clock_offset {
  533. __u8 status;
  534. __le16 handle;
  535. __le16 clock_offset;
  536. } __attribute__ ((packed));
  537. #define HCI_EV_PSCAN_REP_MODE 0x20
  538. struct hci_ev_pscan_rep_mode {
  539. bdaddr_t bdaddr;
  540. __u8 pscan_rep_mode;
  541. } __attribute__ ((packed));
  542. #define HCI_EV_SNIFF_SUBRATE 0x2E
  543. struct hci_ev_sniff_subrate {
  544. __u8 status;
  545. __le16 handle;
  546. __le16 max_tx_latency;
  547. __le16 max_rx_latency;
  548. __le16 max_remote_timeout;
  549. __le16 max_local_timeout;
  550. } __attribute__ ((packed));
  551. /* Internal events generated by Bluetooth stack */
  552. #define HCI_EV_STACK_INTERNAL 0xFD
  553. struct hci_ev_stack_internal {
  554. __u16 type;
  555. __u8 data[0];
  556. } __attribute__ ((packed));
  557. #define HCI_EV_SI_DEVICE 0x01
  558. struct hci_ev_si_device {
  559. __u16 event;
  560. __u16 dev_id;
  561. } __attribute__ ((packed));
  562. #define HCI_EV_SI_SECURITY 0x02
  563. struct hci_ev_si_security {
  564. __u16 event;
  565. __u16 proto;
  566. __u16 subproto;
  567. __u8 incoming;
  568. } __attribute__ ((packed));
  569. /* ---- HCI Packet structures ---- */
  570. #define HCI_COMMAND_HDR_SIZE 3
  571. #define HCI_EVENT_HDR_SIZE 2
  572. #define HCI_ACL_HDR_SIZE 4
  573. #define HCI_SCO_HDR_SIZE 3
  574. struct hci_command_hdr {
  575. __le16 opcode; /* OCF & OGF */
  576. __u8 plen;
  577. } __attribute__ ((packed));
  578. struct hci_event_hdr {
  579. __u8 evt;
  580. __u8 plen;
  581. } __attribute__ ((packed));
  582. struct hci_acl_hdr {
  583. __le16 handle; /* Handle & Flags(PB, BC) */
  584. __le16 dlen;
  585. } __attribute__ ((packed));
  586. struct hci_sco_hdr {
  587. __le16 handle;
  588. __u8 dlen;
  589. } __attribute__ ((packed));
  590. /* Command opcode pack/unpack */
  591. #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
  592. #define hci_opcode_ogf(op) (op >> 10)
  593. #define hci_opcode_ocf(op) (op & 0x03ff)
  594. /* ACL handle and flags pack/unpack */
  595. #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))
  596. #define hci_handle(h) (h & 0x0fff)
  597. #define hci_flags(h) (h >> 12)
  598. /* ---- HCI Sockets ---- */
  599. /* Socket options */
  600. #define HCI_DATA_DIR 1
  601. #define HCI_FILTER 2
  602. #define HCI_TIME_STAMP 3
  603. /* CMSG flags */
  604. #define HCI_CMSG_DIR 0x0001
  605. #define HCI_CMSG_TSTAMP 0x0002
  606. struct sockaddr_hci {
  607. sa_family_t hci_family;
  608. unsigned short hci_dev;
  609. };
  610. #define HCI_DEV_NONE 0xffff
  611. struct hci_filter {
  612. unsigned long type_mask;
  613. unsigned long event_mask[2];
  614. __u16 opcode;
  615. };
  616. struct hci_ufilter {
  617. __u32 type_mask;
  618. __u32 event_mask[2];
  619. __u16 opcode;
  620. };
  621. #define HCI_FLT_TYPE_BITS 31
  622. #define HCI_FLT_EVENT_BITS 63
  623. #define HCI_FLT_OGF_BITS 63
  624. #define HCI_FLT_OCF_BITS 127
  625. /* ---- HCI Ioctl requests structures ---- */
  626. struct hci_dev_stats {
  627. __u32 err_rx;
  628. __u32 err_tx;
  629. __u32 cmd_tx;
  630. __u32 evt_rx;
  631. __u32 acl_tx;
  632. __u32 acl_rx;
  633. __u32 sco_tx;
  634. __u32 sco_rx;
  635. __u32 byte_rx;
  636. __u32 byte_tx;
  637. };
  638. struct hci_dev_info {
  639. __u16 dev_id;
  640. char name[8];
  641. bdaddr_t bdaddr;
  642. __u32 flags;
  643. __u8 type;
  644. __u8 features[8];
  645. __u32 pkt_type;
  646. __u32 link_policy;
  647. __u32 link_mode;
  648. __u16 acl_mtu;
  649. __u16 acl_pkts;
  650. __u16 sco_mtu;
  651. __u16 sco_pkts;
  652. struct hci_dev_stats stat;
  653. };
  654. struct hci_conn_info {
  655. __u16 handle;
  656. bdaddr_t bdaddr;
  657. __u8 type;
  658. __u8 out;
  659. __u16 state;
  660. __u32 link_mode;
  661. };
  662. struct hci_dev_req {
  663. __u16 dev_id;
  664. __u32 dev_opt;
  665. };
  666. struct hci_dev_list_req {
  667. __u16 dev_num;
  668. struct hci_dev_req dev_req[0]; /* hci_dev_req structures */
  669. };
  670. struct hci_conn_list_req {
  671. __u16 dev_id;
  672. __u16 conn_num;
  673. struct hci_conn_info conn_info[0];
  674. };
  675. struct hci_conn_info_req {
  676. bdaddr_t bdaddr;
  677. __u8 type;
  678. struct hci_conn_info conn_info[0];
  679. };
  680. struct hci_inquiry_req {
  681. __u16 dev_id;
  682. __u16 flags;
  683. __u8 lap[3];
  684. __u8 length;
  685. __u8 num_rsp;
  686. };
  687. #define IREQ_CACHE_FLUSH 0x0001
  688. #endif /* __HCI_H */