Esempio n. 1
0
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;
	}
}
Esempio n. 2
0
static int
lell_pcap_create_file_dlt(const char *filename, int dlt, lell_pcap_handle ** ph)
{
	int retval = 0;
	lell_pcap_handle * handle = malloc( sizeof(lell_pcap_handle) );
	if (handle) {
		memset(handle, 0, sizeof(*handle));
#ifdef PCAP_TSTAMP_PRECISION_NANO
		handle->pcap = pcap_open_dead_with_tstamp_precision(dlt,
								    400,
								    PCAP_TSTAMP_PRECISION_NANO);
#else
                handle->pcap = pcap_open_dead(dlt, 400);
#endif
		if (handle->pcap) {
			handle->dumper = pcap_dump_open(handle->pcap, filename);
			if (handle->dumper) {
				handle->dlt = dlt;
				*ph = handle;
			}
			else {
				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) lell_pcap_close( handle );
	return retval;
}