uint32_t role_bmp;
int last_handle;
int connecting;
- a_bdaddr awaiting_bdaddr[HCI_HANDLES_MAX];
+ bdaddr_t awaiting_bdaddr[HCI_HANDLES_MAX];
} lm;
uint8_t event_mask[8];
static void bt_hci_mod_timer_1280ms(QEMUTimer *timer, int period)
{
- qemu_mod_timer(timer, qemu_get_clock(vm_clock) +
+ qemu_mod_timer(timer, qemu_get_clock_ns(vm_clock) +
muldiv64(period << 7, get_ticks_per_sec(), 100));
}
if (master) {
link->acl_mode = acl_active;
hci->lm.handle[hci->lm.last_handle].acl_mode_timer =
- qemu_new_timer(vm_clock, bt_hci_mode_tick, link);
+ qemu_new_timer_ns(vm_clock, bt_hci_mode_tick, link);
}
}
}
}
-static int bt_hci_connect(struct bt_hci_s *hci, a_bdaddr *bdaddr)
+static int bt_hci_connect(struct bt_hci_s *hci, bdaddr_t *bdaddr)
{
struct bt_device_s *slave;
struct bt_link_s link;
}
static void bt_hci_connection_reject_event(struct bt_hci_s *hci,
- a_bdaddr *bdaddr)
+ bdaddr_t *bdaddr)
{
evt_conn_complete params;
static void bt_hci_connection_accept(struct bt_hci_s *hci,
struct bt_device_s *host)
{
- struct bt_hci_link_s *link = qemu_mallocz(sizeof(struct bt_hci_link_s));
+ struct bt_hci_link_s *link = g_malloc0(sizeof(struct bt_hci_link_s));
evt_conn_complete params;
uint16_t handle;
uint8_t status = HCI_SUCCESS;
tries);
if (!tries) {
- qemu_free(link);
+ g_free(link);
bt_hci_connection_reject(hci, host, HCI_REJECTED_LIMITED_RESOURCES);
status = HCI_NO_CONNECTION;
goto complete;
* that's been cancelled by the host in the meantime and immediately
* try to detach the link and send a Connection Complete. */
static int bt_hci_lmp_connection_ready(struct bt_hci_s *hci,
- a_bdaddr *bdaddr)
+ bdaddr_t *bdaddr)
{
int i;
/* We are the slave, we get to clean this burden */
link = (struct bt_hci_link_s *) btlink;
- qemu_free(link);
+ g_free(link);
complete:
bt_hci_lmp_link_teardown(hci, handle);
uint16_t handle = link->handle;
evt_disconn_complete params;
- qemu_free(link);
+ g_free(link);
bt_hci_lmp_link_teardown(hci, handle);
¶ms, EVT_DISCONN_COMPLETE_SIZE);
}
-static int bt_hci_name_req(struct bt_hci_s *hci, a_bdaddr *bdaddr)
+static int bt_hci_name_req(struct bt_hci_s *hci, bdaddr_t *bdaddr)
{
struct bt_device_s *slave;
evt_remote_name_req_complete params;
static int bt_hci_version_req(struct bt_hci_s *hci, uint16_t handle)
{
- struct bt_device_s *slave;
evt_read_remote_version_complete params;
if (bt_hci_handle_bad(hci, handle))
return -ENODEV;
- slave = bt_hci_remote_dev(hci, handle);
+ bt_hci_remote_dev(hci, handle);
bt_hci_event_status(hci, HCI_SUCCESS);
bt_hci_event_status(hci, HCI_SUCCESS);
- qemu_mod_timer(link->acl_mode_timer, qemu_get_clock(vm_clock) +
+ qemu_mod_timer(link->acl_mode_timer, qemu_get_clock_ns(vm_clock) +
muldiv64(interval * 625, get_ticks_per_sec(), 1000000));
bt_hci_lmp_mode_change_master(hci, link->link, mode, interval);
hci->device.inquiry_scan = 0;
hci->device.page_scan = 0;
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = NULL;
hci->device.class[0] = 0x00;
hci->device.class[1] = 0x00;
}
static inline void bt_hci_event_complete_conn_cancel(struct bt_hci_s *hci,
- uint8_t status, a_bdaddr *bd_addr)
+ uint8_t status, bdaddr_t *bd_addr)
{
create_conn_cancel_rp params = {
.status = status,
}
static inline void bt_hci_event_complete_name_cancel(struct bt_hci_s *hci,
- a_bdaddr *bd_addr)
+ bdaddr_t *bd_addr)
{
remote_name_req_cancel_rp params = {
.status = HCI_INVALID_PARAMETERS,
LENGTH_CHECK(change_local_name);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
- hci->device.lmp_name = qemu_strndup(PARAM(change_local_name, name),
+ g_free((void *) hci->device.lmp_name);
+ hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
sizeof(PARAM(change_local_name, name)));
bt_hci_event_complete_status(hci, HCI_SUCCESS);
break;
const uint8_t *data, int length)
{
struct bt_hci_s *hci = hci_from_info(info);
- struct bt_link_s *link;
uint16_t handle;
int datalen;
handle = acl_handle((data[1] << 8) | data[0]);
datalen = data[2];
- data += 3;
length -= 3;
if (bt_hci_handle_bad(hci, handle)) {
__FUNCTION__, handle);
return;
}
- handle &= ~HCI_HANDLE_OFFSET;
if (datalen > length) {
fprintf(stderr, "%s: SCO packet too short (%iB < %iB)\n",
return;
}
- link = hci->lm.handle[handle].link;
/* TODO */
/* TODO: increase counter and send EVT_NUM_COMP_PKTS if synchronous
{
struct bt_hci_s *hci = hci_from_info(info);
- bacpy(&hci->device.bd_addr, (const a_bdaddr *) bd_addr);
+ bacpy(&hci->device.bd_addr, (const bdaddr_t *) bd_addr);
return 0;
}
struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net)
{
- struct bt_hci_s *s = qemu_mallocz(sizeof(struct bt_hci_s));
+ struct bt_hci_s *s = g_malloc0(sizeof(struct bt_hci_s));
- s->lm.inquiry_done = qemu_new_timer(vm_clock, bt_hci_inquiry_done, s);
- s->lm.inquiry_next = qemu_new_timer(vm_clock, bt_hci_inquiry_next, s);
+ s->lm.inquiry_done = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_done, s);
+ s->lm.inquiry_next = qemu_new_timer_ns(vm_clock, bt_hci_inquiry_next, s);
s->conn_accept_timer =
- qemu_new_timer(vm_clock, bt_hci_conn_accept_timeout, s);
+ qemu_new_timer_ns(vm_clock, bt_hci_conn_accept_timeout, s);
s->evt_packet = bt_hci_evt_packet;
s->evt_submit = bt_hci_evt_submit;
bt_device_done(&hci->device);
if (hci->device.lmp_name)
- qemu_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
/* Be gentle and send DISCONNECT to all connected peers and those
* currently waiting for us to accept or reject a connection request.
qemu_free_timer(hci->lm.inquiry_next);
qemu_free_timer(hci->conn_accept_timer);
- qemu_free(hci);
+ g_free(hci);
}