36 #include "BTIoctl.hpp"
37 #include "HCIIoctl.hpp"
58 static int hci_open_dev(
const uint16_t
dev_id,
const uint16_t
channel) noexcept;
59 static int hci_close_dev(
int dd) noexcept;
61 std::recursive_mutex mtx_write;
62 std::atomic<int> socket_descriptor;
63 std::atomic<bool> interrupt_flag;
64 std::atomic<pthread_t> tid_read;
79 void close() noexcept;
81 bool isOpen() const noexcept {
return 0 <= socket_descriptor; }
87 inline std::recursive_mutex &
mutex_write() noexcept {
return mtx_write; }
96 static inline void setu32_bit(
int nr,
void *addr) noexcept
98 *((uint32_t *) addr + (nr >> 5)) |= (1 << (nr & 31));
101 static inline void clearu32_bit(
int nr,
void *addr) noexcept
103 *((uint32_t *) addr + (nr >> 5)) &= ~(1 << (nr & 31));
106 static inline int testu32_bit(
int nr,
void *addr) noexcept
108 return *((uint32_t *) addr + (nr >> 5)) & (1 << (nr & 31));
114 bzero(f,
sizeof(*f));
118 setu32_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
122 clearu32_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
126 return testu32_bit((t == HCI_VENDOR_PKT) ? 0 : (t & HCI_FLT_TYPE_BITS), &f->type_mask);
130 memset((
void *) &f->type_mask, 0xff,
sizeof(f->type_mask));
134 setu32_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
138 clearu32_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
142 return testu32_bit((e & HCI_FLT_EVENT_BITS), &f->event_mask);
146 memset((
void *) f->event_mask, 0xff,
sizeof(f->event_mask));
158 return (f->opcode == opcode);