summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/dbus-manager.c10
-rw-r--r--hcid/main.c23
2 files changed, 27 insertions, 6 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index 68c732f5..695b3112 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -103,6 +103,7 @@ static DBusHandlerResult find_adapter(DBusConnection *conn,
{
DBusMessage *reply;
char path[MAX_PATH_LENGTH], *path_ptr = path;
+ struct hci_dev_info di;
const char *pattern;
int dev_id;
@@ -115,6 +116,12 @@ static DBusHandlerResult find_adapter(DBusConnection *conn,
if (dev_id < 0)
return error_no_such_adapter(conn, msg);
+ if (hci_devinfo(dev_id, &di) < 0)
+ return error_no_such_adapter(conn, msg);
+
+ if (hci_test_bit(HCI_RAW, &di.flags))
+ return error_no_such_adapter(conn, msg);
+
reply = dbus_message_new_method_return(msg);
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
@@ -177,6 +184,9 @@ static DBusHandlerResult list_adapters(DBusConnection *conn,
if (hci_devinfo(dr->dev_id, &di) < 0)
continue;
+ if (hci_test_bit(HCI_RAW, &di.flags))
+ continue;
+
snprintf(path, sizeof(path), "%s/%s", BASE_PATH, di.name);
dbus_message_iter_append_basic(&array_iter,
diff --git a/hcid/main.c b/hcid/main.c
index b58861a6..61d2fecd 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -523,14 +523,14 @@ static void init_device(int dev_id)
if (ioctl(dd, HCIDEVUP, dev_id) < 0 && errno != EALREADY) {
error("Can't init device hci%d: %s (%d)",
dev_id, strerror(errno), errno);
- exit(1);
+ goto fail;
}
if (hci_devinfo(dev_id, &di) < 0)
- exit(1);
+ goto fail;
if (hci_test_bit(HCI_RAW, &di.flags))
- exit(0);
+ goto done;
if (hcid.offmode == HCID_OFFMODE_DEVDOWN) {
char mode[16];
@@ -538,20 +538,31 @@ static void init_device(int dev_id)
if (read_device_mode(&di.bdaddr, mode, sizeof(mode)) == 0 &&
strcmp(mode, "off") == 0) {
ioctl(dd, HCIDEVDOWN, dev_id);
- exit(0);
+ goto done;
}
}
+done:
hci_close_dev(dd);
-
exit(0);
+
+fail:
+ hci_close_dev(dd);
+ exit(1);
}
static void device_devreg_setup(int dev_id)
{
+ struct hci_dev_info di;
+
if (hcid.auto_init)
init_device(dev_id);
- hcid_dbus_register_device(dev_id);
+
+ if (hci_devinfo(dev_id, &di) < 0)
+ return;
+
+ if (!hci_test_bit(HCI_RAW, &di.flags))
+ hcid_dbus_register_device(dev_id);
}
static void device_devup_setup(int dev_id)