bthost.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* SPDX-License-Identifier: LGPL-2.1-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2011-2012 Intel Corporation
  7. * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
  8. *
  9. *
  10. */
  11. #include <stdint.h>
  12. #include <sys/uio.h>
  13. typedef void (*bthost_send_func) (const struct iovec *iov, int iovlen,
  14. void *user_data);
  15. struct bthost;
  16. struct bthost *bthost_create(void);
  17. void bthost_destroy(struct bthost *bthost);
  18. typedef void (*bthost_ready_cb) (void);
  19. void bthost_notify_ready(struct bthost *bthost, bthost_ready_cb cb);
  20. typedef void (*bthost_debug_func_t)(const char *str, void *user_data);
  21. typedef void (*bthost_destroy_func_t)(void *user_data);
  22. bool bthost_set_debug(struct bthost *bthost, bthost_debug_func_t callback,
  23. void *user_data, bthost_destroy_func_t destroy);
  24. void bthost_debug(struct bthost *bthost, const char *format, ...)
  25. __attribute__((format(printf, 2, 3)));
  26. void bthost_set_send_handler(struct bthost *bthost, bthost_send_func handler,
  27. void *user_data);
  28. void bthost_receive_h4(struct bthost *bthost, const void *data, uint16_t len);
  29. typedef void (*bthost_cmd_complete_cb) (uint16_t opcode, uint8_t status,
  30. const void *param, uint8_t len,
  31. void *user_data);
  32. void bthost_set_cmd_complete_cb(struct bthost *bthost,
  33. bthost_cmd_complete_cb cb, void *user_data);
  34. typedef void (*bthost_new_conn_cb) (uint16_t handle, void *user_data);
  35. void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb,
  36. void *user_data);
  37. void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr,
  38. uint8_t addr_type);
  39. void bthost_hci_ext_connect(struct bthost *bthost, const uint8_t *bdaddr,
  40. uint8_t addr_type);
  41. void bthost_hci_disconnect(struct bthost *bthost, uint16_t handle,
  42. uint8_t reason);
  43. typedef void (*bthost_cid_hook_func_t)(const void *data, uint16_t len,
  44. void *user_data);
  45. void bthost_add_cid_hook(struct bthost *bthost, uint16_t handle, uint16_t cid,
  46. bthost_cid_hook_func_t func, void *user_data);
  47. void bthost_send_cid(struct bthost *bthost, uint16_t handle, uint16_t cid,
  48. const void *data, uint16_t len);
  49. void bthost_send_cid_v(struct bthost *bthost, uint16_t handle, uint16_t cid,
  50. const struct iovec *iov, int iovcnt);
  51. typedef void (*bthost_l2cap_rsp_cb) (uint8_t code, const void *data,
  52. uint16_t len, void *user_data);
  53. bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
  54. const void *data, uint16_t len,
  55. bthost_l2cap_rsp_cb cb, void *user_data);
  56. void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
  57. void bthost_set_adv_data(struct bthost *bthost, const uint8_t *data,
  58. uint8_t len);
  59. void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
  60. void bthost_set_ext_adv_data(struct bthost *bthost, const uint8_t *data,
  61. uint8_t len);
  62. void bthost_set_ext_adv_params(struct bthost *bthost);
  63. void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable);
  64. void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
  65. void bthost_write_le_host_supported(struct bthost *bthost, uint8_t mode);
  66. void bthost_request_auth(struct bthost *bthost, uint16_t handle);
  67. void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle,
  68. const uint8_t ltk[16]);
  69. typedef void (*bthost_l2cap_connect_cb) (uint16_t handle, uint16_t cid,
  70. void *user_data);
  71. typedef void (*bthost_l2cap_disconnect_cb) (void *user_data);
  72. void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
  73. bthost_l2cap_connect_cb func,
  74. bthost_l2cap_disconnect_cb disconn_func,
  75. void *user_data);
  76. void bthost_set_sc_support(struct bthost *bthost, bool enable);
  77. void bthost_set_pin_code(struct bthost *bthost, const uint8_t *pin,
  78. uint8_t pin_len);
  79. void bthost_set_io_capability(struct bthost *bthost, uint8_t io_capability);
  80. uint8_t bthost_get_io_capability(struct bthost *bthost);
  81. void bthost_set_auth_req(struct bthost *bthost, uint8_t auth_req);
  82. uint8_t bthost_get_auth_req(struct bthost *bthost);
  83. void bthost_set_reject_user_confirm(struct bthost *bthost, bool reject);
  84. bool bthost_get_reject_user_confirm(struct bthost *bthost);
  85. bool bthost_bredr_capable(struct bthost *bthost);
  86. uint64_t bthost_conn_get_fixed_chan(struct bthost *bthost, uint16_t handle);
  87. typedef void (*bthost_rfcomm_connect_cb) (uint16_t handle, uint16_t cid,
  88. void *user_data, bool status);
  89. void bthost_add_rfcomm_server(struct bthost *bthost, uint8_t channel,
  90. bthost_rfcomm_connect_cb func, void *user_data);
  91. bool bthost_connect_rfcomm(struct bthost *bthost, uint16_t handle,
  92. uint8_t channel, bthost_rfcomm_connect_cb func,
  93. void *user_data);
  94. typedef void (*bthost_rfcomm_chan_hook_func_t) (const void *data, uint16_t len,
  95. void *user_data);
  96. void bthost_add_rfcomm_chan_hook(struct bthost *bthost, uint16_t handle,
  97. uint8_t channel,
  98. bthost_rfcomm_chan_hook_func_t func,
  99. void *user_data);
  100. void bthost_send_rfcomm_data(struct bthost *bthost, uint16_t handle,
  101. uint8_t channel, const void *data,
  102. uint16_t len);
  103. void bthost_start(struct bthost *bthost);
  104. /* LE SMP support */
  105. void *smp_start(struct bthost *bthost);
  106. void smp_stop(void *smp_data);
  107. void *smp_conn_add(void *smp_data, uint16_t handle,
  108. const uint8_t *ia, uint8_t ia_type,
  109. const uint8_t *ra, uint8_t ra_type, bool conn_init);
  110. void smp_conn_del(void *conn_data);
  111. void smp_conn_encrypted(void *conn_data, uint8_t encrypt);
  112. void smp_data(void *conn_data, const void *data, uint16_t len);
  113. void smp_bredr_data(void *conn_data, const void *data, uint16_t len);
  114. int smp_get_ltk(void *smp_data, uint64_t rand, uint16_t ediv, uint8_t *ltk);
  115. void smp_pair(void *conn_data, uint8_t io_cap, uint8_t auth_req);