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
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
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);
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);