Reputation: 771
I'm doing some experiments with bluetooth on linux (Arch Linux), and apparently the lap
parameter that I'm passing to hci_inquiry
is being ignored.
With the following code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/l2cap.h>
int main(int argc, char** argv) {
inquiry_info *ii = NULL;
int max_rsp, num_rsp;
int dev_id, sock, len, flags;
int i;
char addr[19] = { 0 };
char name[248] = { 0 };
dev_id = hci_get_route(NULL);
sock = hci_open_dev( dev_id );
if (dev_id < 0 || sock < 0) {
perror("opening socket");
exit(1);
}
len = 3;
max_rsp = 255;
flags = IREQ_CACHE_FLUSH;
ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
uint8_t lap[3] = { 0x00, 0x8b, 0x9e };
num_rsp = hci_inquiry(dev_id, len, max_rsp, lap, &ii, flags);
printf("%i\n", num_rsp);
free( ii );
close( sock );
return 0;
}
When I run this while capturing the bluetooth interface communication with Wireshark, I see that the inquiry is being sent with a LAP of 0x9e8b33
, no matter what I pass as lap
.
I'm trying to understand: why is this parameter apparently ignored? And how could I make it send the inquiry using the given LAP of 0x9e8b00
?
EDIT: Using libusb
to claim the USB Bluetooth adapter and directly send the Inquiry, I managed to make it issue inquiries with the correct LAP. So the adapter I'm using is perfectly capable of issuing such inquiries. I still don't know however why the controller seems to ignore/override the LAP when using hci_inquiry
and how to do so without taking over the whole USB BT adapter.
Upvotes: 0
Views: 28