static void test_pre_setup(const void *test_data) { struct test_data *data = tester_get_data(); data->crypto = bt_crypto_new(); if (!data->crypto) { tester_warn("Failed to setup crypto"); tester_pre_setup_failed(); return; } data->mgmt = mgmt_new_default(); if (!data->mgmt) { tester_warn("Failed to setup management interface"); bt_crypto_unref(data->crypto); tester_pre_setup_failed(); return; } if (tester_use_debug()) mgmt_set_debug(data->mgmt, mgmt_debug, "mgmt: ", NULL); mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL, read_index_list_callback, NULL, NULL); }
static void bt_att_free(struct bt_att *att) { if (att->pending_req) destroy_att_send_op(att->pending_req); if (att->pending_ind) destroy_att_send_op(att->pending_ind); io_destroy(att->io); bt_crypto_unref(att->crypto); queue_destroy(att->req_queue, NULL); queue_destroy(att->ind_queue, NULL); queue_destroy(att->write_queue, NULL); queue_destroy(att->notify_list, NULL); queue_destroy(att->disconn_list, NULL); if (att->timeout_destroy) att->timeout_destroy(att->timeout_data); if (att->debug_destroy) att->debug_destroy(att->debug_data); free(att->local_sign); free(att->remote_sign); free(att->buf); free(att); }
void smp_stop(void *smp_data) { struct smp *smp = smp_data; bt_crypto_unref(smp->crypto); free(smp); }
int main(int argc ,char *argv[]) { int exit_status; for (;;) { int opt; opt = getopt_long(argc, argv, "vh", main_options, NULL); if (opt < 0) break; switch (opt) { case 'v': printf("%s\n", VERSION); return EXIT_SUCCESS; case 'h': usage(); return EXIT_SUCCESS; default: return EXIT_FAILURE; } } if (argc - optind > 0) { fprintf(stderr, "Invalid command line parameters\n"); return EXIT_FAILURE; } mainloop_init(); mgmt = mgmt_new_default(); if (!mgmt) { fprintf(stderr, "Failed to open management socket\n"); return EXIT_FAILURE; } if (!mgmt_send(mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0, NULL, read_index_list, NULL, NULL)) { fprintf(stderr, "Failed to read index list\n"); exit_status = EXIT_FAILURE; goto done; } exit_status = mainloop_run_with_signal(signal_callback, NULL); bt_hci_unref(adv_dev); bt_hci_unref(scan_dev); bt_crypto_unref(crypto); done: mgmt_unref(mgmt); return exit_status; }
void bt_le_unref(struct bt_le *hci) { if (!hci) return; if (__sync_sub_and_fetch(&hci->ref_count, 1)) return; bt_crypto_unref(hci->crypto); mainloop_remove_fd(hci->vhci_fd); close(hci->vhci_fd); free(hci); }
static void test_post_teardown(const void *test_data) { struct test_data *data = tester_get_data(); if (data->io_id > 0) { g_source_remove(data->io_id); data->io_id = 0; } if (data->crypto) { bt_crypto_unref(data->crypto); data->crypto = NULL; } hciemu_unref(data->hciemu); data->hciemu = NULL; }