hciemu.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: LGPL-2.1-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2012-2014 Intel Corporation. All rights reserved.
  7. *
  8. *
  9. */
  10. #include <stdbool.h>
  11. #include <stdint.h>
  12. struct hciemu;
  13. struct hciemu_client;
  14. enum hciemu_type {
  15. HCIEMU_TYPE_BREDRLE,
  16. HCIEMU_TYPE_BREDR,
  17. HCIEMU_TYPE_LE,
  18. HCIEMU_TYPE_LEGACY,
  19. HCIEMU_TYPE_BREDRLE50,
  20. HCIEMU_TYPE_BREDRLE52,
  21. };
  22. enum hciemu_hook_type {
  23. HCIEMU_HOOK_PRE_CMD,
  24. HCIEMU_HOOK_POST_CMD,
  25. HCIEMU_HOOK_PRE_EVT,
  26. HCIEMU_HOOK_POST_EVT,
  27. };
  28. struct hciemu *hciemu_new(enum hciemu_type type);
  29. struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num);
  30. struct hciemu *hciemu_ref(struct hciemu *hciemu);
  31. void hciemu_unref(struct hciemu *hciemu);
  32. struct hciemu_client *hciemu_get_client(struct hciemu *hciemu, int num);
  33. struct bthost *hciemu_client_host(struct hciemu_client *client);
  34. const uint8_t *hciemu_client_bdaddr(struct hciemu_client *client);
  35. typedef void (*hciemu_debug_func_t)(const char *str, void *user_data);
  36. typedef void (*hciemu_destroy_func_t)(void *user_data);
  37. bool hciemu_set_debug(struct hciemu *hciemu, hciemu_debug_func_t callback,
  38. void *user_data, hciemu_destroy_func_t destroy);
  39. struct bthost *hciemu_client_get_host(struct hciemu *hciemu);
  40. const char *hciemu_get_address(struct hciemu *hciemu);
  41. uint8_t *hciemu_get_features(struct hciemu *hciemu);
  42. const uint8_t *hciemu_get_central_bdaddr(struct hciemu *hciemu);
  43. const uint8_t *hciemu_get_client_bdaddr(struct hciemu *hciemu);
  44. uint8_t hciemu_get_central_scan_enable(struct hciemu *hciemu);
  45. uint8_t hciemu_get_central_le_scan_enable(struct hciemu *hciemu);
  46. void hciemu_set_central_le_states(struct hciemu *hciemu,
  47. const uint8_t *le_states);
  48. typedef void (*hciemu_command_func_t)(uint16_t opcode, const void *data,
  49. uint8_t len, void *user_data);
  50. typedef bool (*hciemu_hook_func_t)(const void *data, uint16_t len,
  51. void *user_data);
  52. bool hciemu_add_central_post_command_hook(struct hciemu *hciemu,
  53. hciemu_command_func_t function, void *user_data);
  54. bool hciemu_clear_central_post_command_hooks(struct hciemu *hciemu);
  55. int hciemu_add_hook(struct hciemu *hciemu, enum hciemu_hook_type type,
  56. uint16_t opcode, hciemu_hook_func_t function,
  57. void *user_data);
  58. bool hciemu_del_hook(struct hciemu *hciemu, enum hciemu_hook_type type,
  59. uint16_t opcode);