From: "Claudio Takahasi" <cktakahasi@gmail.com>
To: "BlueZ development" <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode
Date: Tue, 31 Jul 2007 11:34:59 -0300 [thread overview]
Message-ID: <e1effdeb0707310734w7004e158te4b82dfea931bb40@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]
Hi Marcel,
here is the patch to avoid register the D-Bus adapter path when the
RAW flag is active.
ListAdapters and FindAdapter were fixed too.
Claudio
--
---------------------------------------------------------
Claudio Takahasi
Instituto Nokia de Tecnologia - INdT
[-- Attachment #2: raw02.patch --]
[-- Type: text/x-diff, Size: 3243 bytes --]
Index: hcid/dbus-manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-manager.c,v
retrieving revision 1.68
diff -u -r1.68 dbus-manager.c
--- hcid/dbus-manager.c 4 May 2007 15:32:27 -0000 1.68
+++ hcid/dbus-manager.c 31 Jul 2007 14:18:56 -0000
@@ -103,6 +103,7 @@
{
DBusMessage *reply;
char path[MAX_PATH_LENGTH], *path_ptr = path;
+ struct hci_dev_info di;
const char *pattern;
int dev_id;
@@ -115,6 +116,9 @@
if (dev_id < 0)
return error_no_such_adapter(conn, msg);
+ if ((hci_devinfo(dev_id, &di) < 0) || 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;
@@ -174,7 +178,8 @@
char path[MAX_PATH_LENGTH], *path_ptr = path;
struct hci_dev_info di;
- if (hci_devinfo(dr->dev_id, &di) < 0)
+ if ((hci_devinfo(dr->dev_id, &di) < 0) ||
+ hci_test_bit(HCI_RAW, &di.flags))
continue;
snprintf(path, sizeof(path), "%s/%s", BASE_PATH, di.name);
Index: hcid/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/main.c,v
retrieving revision 1.98
diff -u -r1.98 main.c
--- hcid/main.c 31 Jul 2007 12:27:23 -0000 1.98
+++ hcid/main.c 31 Jul 2007 14:18:57 -0000
@@ -495,9 +495,8 @@
exit(0);
}
-static void init_device(int dev_id)
+static void init_device(struct hci_dev_info *di)
{
- struct hci_dev_info di;
int dd;
/* Do initialization in the separate process */
@@ -507,41 +506,39 @@
break;
case -1:
error("Fork failed. Can't init device hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
+ di->dev_id, strerror(errno), errno);
default:
return;
}
- dd = hci_open_dev(dev_id);
+ dd = hci_open_dev(di->dev_id);
if (dd < 0) {
error("Can't open device hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
+ di->dev_id, strerror(errno), errno);
exit(1);
}
/* Start HCI device */
- if (ioctl(dd, HCIDEVUP, dev_id) < 0 && errno != EALREADY) {
+ if (ioctl(dd, HCIDEVUP, di->dev_id) < 0 && errno != EALREADY) {
error("Can't init device hci%d: %s (%d)",
- dev_id, strerror(errno), errno);
+ di->dev_id, strerror(errno), errno);
+ hci_close_dev(dd);
exit(1);
}
- if (hci_devinfo(dev_id, &di) < 0)
- exit(1);
-
- if (hci_test_bit(HCI_RAW, &di.flags))
- exit(0);
+ if (hci_test_bit(HCI_RAW, &di->flags))
+ goto done;
if (hcid.offmode == HCID_OFFMODE_DEVDOWN) {
char mode[16];
- if (read_device_mode(&di.bdaddr, mode, sizeof(mode)) == 0 &&
+ if (read_device_mode(&di->bdaddr, mode, sizeof(mode)) == 0 &&
strcmp(mode, "off") == 0) {
- ioctl(dd, HCIDEVDOWN, dev_id);
- exit(0);
+ ioctl(dd, HCIDEVDOWN, di->dev_id);
+ goto done;
}
}
-
+done:
hci_close_dev(dd);
exit(0);
@@ -549,9 +546,16 @@
static void device_devreg_setup(int dev_id)
{
+ struct hci_dev_info di;
+
+ if (hci_devinfo(dev_id, &di) < 0)
+ return;
+
if (hcid.auto_init)
- init_device(dev_id);
- hcid_dbus_register_device(dev_id);
+ init_device(&di);
+
+ if (!hci_test_bit(HCI_RAW, &di.flags))
+ hcid_dbus_register_device(dev_id);
}
static void device_devup_setup(int dev_id)
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
next reply other threads:[~2007-07-31 14:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-31 14:34 Claudio Takahasi [this message]
2007-08-01 13:56 ` [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode Claudio Takahasi
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=e1effdeb0707310734w7004e158te4b82dfea931bb40@mail.gmail.com \
--to=cktakahasi@gmail.com \
--cc=bluez-devel@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox