From: Eder Ruiz Maria <eder.ruiz@xxxxxxxxxxxxx> --- src/shared/hciemu.c | 30 ++++++++++++++++++++++++++++++ src/shared/hciemu.h | 14 ++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c index a0b347c..76fd449 100644 --- a/src/shared/hciemu.c +++ b/src/shared/hciemu.c @@ -389,3 +389,33 @@ bool hciemu_add_master_post_command_hook(struct hciemu *hciemu, return true; } + +int hciemu_add_hook(struct hciemu *hciemu, enum hciemu_hook_type type, + uint16_t opcode, hciemu_hook_func_t function, + void *user_data) +{ + enum btdev_hook_type hook_type; + + if (!hciemu) + return -1; + + switch (type) { + case HCIEMU_HOOK_PRE_CMD: + hook_type = BTDEV_HOOK_PRE_CMD; + break; + case HCIEMU_HOOK_POST_CMD: + hook_type = BTDEV_HOOK_POST_CMD; + break; + case HCIEMU_HOOK_PRE_EVT: + hook_type = BTDEV_HOOK_PRE_EVT; + break; + case HCIEMU_HOOK_POST_EVT: + hook_type = BTDEV_HOOK_POST_EVT; + break; + default: + return -1; + } + + return btdev_add_hook(hciemu->master_dev, hook_type, opcode, function, + user_data); +} diff --git a/src/shared/hciemu.h b/src/shared/hciemu.h index a473c0e..899acb0 100644 --- a/src/shared/hciemu.h +++ b/src/shared/hciemu.h @@ -32,6 +32,13 @@ enum hciemu_type { HCIEMU_TYPE_LE, }; +enum hciemu_hook_type { + HCIEMU_HOOK_PRE_CMD, + HCIEMU_HOOK_POST_CMD, + HCIEMU_HOOK_PRE_EVT, + HCIEMU_HOOK_POST_EVT, +}; + struct hciemu *hciemu_new(enum hciemu_type type); struct hciemu *hciemu_ref(struct hciemu *hciemu); @@ -47,5 +54,12 @@ const uint8_t *hciemu_get_client_bdaddr(struct hciemu *hciemu); typedef void (*hciemu_command_func_t)(uint16_t opcode, const void *data, uint8_t len, void *user_data); +typedef bool (*hciemu_hook_func_t)(const void *data, uint16_t len, + void *user_data); + bool hciemu_add_master_post_command_hook(struct hciemu *hciemu, hciemu_command_func_t function, void *user_data); + +int hciemu_add_hook(struct hciemu *hciemu, enum hciemu_hook_type type, + uint16_t opcode, hciemu_hook_func_t function, + void *user_data); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html