summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-01-29 23:30:04 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-01-29 23:30:04 +0000
commit601655969dc1dc85696f8aa94cf68a6433228be7 (patch)
treeced077f141c741c61763053685f941454b305dd8
parente6589c0f2a6d1dd3060a86a27d859c8fb08bf278 (diff)
Skip devices in raw mode
-rw-r--r--src/hci.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/hci.c b/src/hci.c
index 822c7db4..088574f1 100644
--- a/src/hci.c
+++ b/src/hci.c
@@ -453,51 +453,58 @@ int hci_for_each_dev(int flag, int (*func)(int s, int dev_id, long arg), long ar
struct hci_dev_list_req *dl;
struct hci_dev_req *dr;
int dev_id = -1;
- int s, i;
+ int i, sk;
- s = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
- if (s < 0)
+ sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+ if (sk < 0)
return -1;
dl = malloc(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl));
if (!dl) {
- close(s);
+ close(sk);
return -1;
}
dl->dev_num = HCI_MAX_DEV;
dr = dl->dev_req;
- if (ioctl(s, HCIGETDEVLIST, (void *)dl))
+ if (ioctl(sk, HCIGETDEVLIST, (void *) dl))
goto done;
- for (i=0; i < dl->dev_num; i++, dr++) {
+ for (i = 0; i < dl->dev_num; i++, dr++) {
if (hci_test_bit(flag, &dr->dev_opt))
- if (!func || func(s, dr->dev_id, arg)) {
+ if (!func || func(sk, dr->dev_id, arg)) {
dev_id = dr->dev_id;
break;
}
}
done:
- close(s);
+ close(sk);
free(dl);
return dev_id;
}
-static int __other_bdaddr(int s, int dev_id, long arg)
+static int __other_bdaddr(int sk, int dev_id, long arg)
{
- struct hci_dev_info di = {dev_id: dev_id};
- if (ioctl(s, HCIGETDEVINFO, (void *) &di))
+ struct hci_dev_info di = { dev_id: dev_id };
+
+ if (ioctl(sk, HCIGETDEVINFO, (void *) &di))
return 0;
+
+ if (hci_test_bit(HCI_RAW, &di.flags))
+ return 0;
+
return bacmp((bdaddr_t *) arg, &di.bdaddr);
}
-static int __same_bdaddr(int s, int dev_id, long arg)
+static int __same_bdaddr(int sk, int dev_id, long arg)
{
- struct hci_dev_info di = {dev_id: dev_id};
- if (ioctl(s, HCIGETDEVINFO, (void *) &di))
+ struct hci_dev_info di = { dev_id: dev_id };
+
+ if (ioctl(sk, HCIGETDEVINFO, (void *) &di))
return 0;
+
return !bacmp((bdaddr_t *) arg, &di.bdaddr);
}