hci.h 18 KB

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