void ubertooth_stop(struct libusb_device_handle *devh) { /* make sure xfers are not active */ if(rx_xfer != NULL) libusb_cancel_transfer(rx_xfer); if (devh != NULL) { cmd_stop(devh); libusb_release_interface(devh, 0); } libusb_close(devh); libusb_exit(NULL); #if defined(USE_PCAP) if (h_pcap_bredr) { btbb_pcap_close(h_pcap_bredr); h_pcap_bredr = NULL; } if (h_pcap_le) { lell_pcap_close(h_pcap_le); h_pcap_le = NULL; } #endif if (h_pcapng_bredr) { btbb_pcapng_close(h_pcapng_bredr); h_pcapng_bredr = NULL; } if (h_pcapng_le) { lell_pcapng_close(h_pcapng_le); h_pcapng_le = NULL; } }
int btbb_pcap_create_file(const char *filename, btbb_pcap_handle ** ph) { int retval = 0; btbb_pcap_handle * handle = malloc( sizeof(btbb_pcap_handle) ); if (handle) { memset(handle, 0, sizeof(*handle)); #ifdef PCAP_TSTAMP_PRECISION_NANO handle->pcap = pcap_open_dead_with_tstamp_precision(DLT_BLUETOOTH_BREDR_BB, 400, PCAP_TSTAMP_PRECISION_NANO); #else handle->pcap = pcap_open_dead(DLT_BLUETOOTH_BREDR_BB, 400); #endif if (handle->pcap) { handle->dumper = pcap_dump_open(handle->pcap, filename); if (handle->dumper) { *ph = handle; } else { pcap_perror(handle->pcap, "PCAP error:"); retval = -PCAP_FILE_NOT_ALLOWED; goto fail; } } else { retval = -PCAP_INVALID_HANDLE; goto fail; } } else { retval = -PCAP_NO_MEMORY; goto fail; } return retval; fail: (void) btbb_pcap_close( handle ); return retval; }