From: David Scherba <dscherba@codeaurora.org>
To: linux-bluetooth@vger.kernel.org
Cc: johan.hedberg@gmail.com, marcel@holtmann.org,
rshaffer@codeaurora.org, David Scherba <dscherba@codeaurora.org>
Subject: [PATCH 1/1] Use HCI device type to gate BR/EDR-specific HCI commands
Date: Tue, 10 Aug 2010 15:51:44 -0400 [thread overview]
Message-ID: <1281469904-30408-1-git-send-email-dscherba@codeaurora.org> (raw)
In-Reply-To: <20100810191616.GA26091@jh-x301>
Use the hci_dev_info structure member 'type' to classify whether a HCI device
is BR/EDR, or not. If not, gate BR/EDR-specific HCI commands.
---
plugins/hciops.c | 20 +++++++++++++-------
src/adapter.c | 2 +-
src/hcid.h | 8 ++++++++
src/security.c | 4 ++--
4 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 3e3e172..9c97c5a 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -85,7 +85,7 @@ static void device_devup_setup(int index)
if (hci_devinfo(index, &di) < 0)
return;
- if (hci_test_bit(HCI_RAW, &di.flags))
+ if (ignore_device(&di))
return;
dd = hci_open_dev(index);
@@ -122,6 +122,7 @@ static void device_devup_setup(int index)
static void init_device(int index)
{
struct hci_dev_req dr;
+ struct hci_dev_info di;
pid_t pid;
int dd, err;
@@ -159,12 +160,17 @@ static void init_device(int index)
index, strerror(err), err);
}
- /* Set link policy */
- dr.dev_opt = main_opts.link_policy;
- if (ioctl(dd, HCISETLINKPOL, (unsigned long) &dr) < 0 &&
+ /* Set link policy for BR/EDR HCI devices */
+ if (hci_devinfo(index, &di) < 0)
+ goto fail;
+
+ if (!ignore_device(&di)) {
+ dr.dev_opt = main_opts.link_policy;
+ if (ioctl(dd, HCISETLINKPOL, (unsigned long) &dr) < 0 &&
errno != ENETDOWN) {
- error("Can't set link policy on hci%d: %s (%d)",
- index, strerror(errno), errno);
+ error("Can't set link policy on hci%d: %s (%d)",
+ index, strerror(errno), errno);
+ }
}
/* Start HCI device */
@@ -196,7 +202,7 @@ static void device_devreg_setup(int index)
devup = hci_test_bit(HCI_UP, &di.flags);
- if (!hci_test_bit(HCI_RAW, &di.flags))
+ if (!ignore_device(&di))
manager_register_adapter(index, devup);
}
diff --git a/src/adapter.c b/src/adapter.c
index af44a59..fc1e123 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2300,7 +2300,7 @@ int adapter_start(struct btd_adapter *adapter)
if (hci_devinfo(adapter->dev_id, &di) < 0)
return -errno;
- if (hci_test_bit(HCI_RAW, &di.flags)) {
+ if (ignore_device(&di)) {
dev->ignore = 1;
return -1;
}
diff --git a/src/hcid.h b/src/hcid.h
index 9c5f1d6..50bdb65 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -23,6 +23,9 @@
*
*/
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+
/* When all services should trust a remote device */
#define GLOBAL_TRUST "[all]"
@@ -99,3 +102,8 @@ void rfkill_exit(void);
void __probe_servers(const char *adapter);
void __remove_servers(const char *adapter);
+
+static inline int ignore_device(struct hci_dev_info *di)
+{
+ return hci_test_bit(HCI_RAW, &di->flags) || di->type >> 4 != HCI_BREDR;
+}
diff --git a/src/security.c b/src/security.c
index ca394e1..667f1f1 100644
--- a/src/security.c
+++ b/src/security.c
@@ -999,7 +999,7 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond,
ioctl(dev, HCIGETDEVINFO, (void *) di);
- if (hci_test_bit(HCI_RAW, &di->flags))
+ if (ignore_device(di))
return TRUE;
switch (eh->evt) {
@@ -1185,7 +1185,7 @@ void start_security_manager(int hdev)
io_data[hdev].channel = chan;
io_data[hdev].pin_length = -1;
- if (hci_test_bit(HCI_RAW, &di->flags))
+ if (ignore_device(di))
return;
bacpy(&cp.bdaddr, BDADDR_ANY);
--
1.7.0.2
--
David Scherba
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2010-08-10 19:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-10 15:15 [PATCH v2 0/2] Use HCI device type to determine suitability of HCI commands David Scherba
2010-08-10 15:15 ` [PATCH 1/2] Remove non-functional hci_devinfo calls in init_device() David Scherba
2010-08-10 19:20 ` Johan Hedberg
2010-08-10 15:15 ` [PATCH 2/2] Use HCI device type to gate BR/EDR-specific HCI commands David Scherba
2010-08-10 15:44 ` David Scherba
2010-08-10 15:45 ` David Scherba
2010-08-10 19:16 ` Johan Hedberg
2010-08-10 19:49 ` David Scherba
2010-08-10 19:51 ` David Scherba [this message]
2010-08-10 20:15 ` [PATCH 1/1] " Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1281469904-30408-1-git-send-email-dscherba@codeaurora.org \
--to=dscherba@codeaurora.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=rshaffer@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.