return -1;
}
+
+bool btdev_del_hook(struct btdev *btdev, enum btdev_hook_type type,
+ uint16_t opcode)
+{
+ int i;
+
+ if (!btdev)
+ return false;
+
+ for (i = 0; i < MAX_HOOK_ENTRIES; i++) {
+ if (btdev->hook_list[i] == NULL)
+ continue;
+
+ if (btdev->hook_list[i]->type != type ||
+ btdev->hook_list[i]->opcode != opcode)
+ continue;
+
+ free(btdev->hook_list[i]);
+ btdev->hook_list[i] = NULL;
+
+ return true;
+ }
+
+ return false;
+}
int btdev_add_hook(struct btdev *btdev, enum btdev_hook_type type,
uint16_t opcode, btdev_hook_func handler,
void *user_data);
+
+bool btdev_del_hook(struct btdev *btdev, enum btdev_hook_type type,
+ uint16_t opcode);
return btdev_add_hook(hciemu->master_dev, hook_type, opcode, function,
user_data);
}
+
+bool hciemu_del_hook(struct hciemu *hciemu, enum hciemu_hook_type type,
+ uint16_t opcode)
+{
+ enum btdev_hook_type hook_type;
+
+ if (!hciemu)
+ return false;
+
+ 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 false;
+ }
+
+ return btdev_del_hook(hciemu->master_dev, hook_type, opcode);
+}
int hciemu_add_hook(struct hciemu *hciemu, enum hciemu_hook_type type,
uint16_t opcode, hciemu_hook_func_t function,
void *user_data);
+
+bool hciemu_del_hook(struct hciemu *hciemu, enum hciemu_hook_type type,
+ uint16_t opcode);