* [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode
@ 2007-07-31 14:34 Claudio Takahasi
2007-08-01 13:56 ` Claudio Takahasi
0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2007-07-31 14:34 UTC (permalink / raw)
To: BlueZ development
[-- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode
2007-07-31 14:34 [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode Claudio Takahasi
@ 2007-08-01 13:56 ` Claudio Takahasi
0 siblings, 0 replies; 2+ messages in thread
From: Claudio Takahasi @ 2007-08-01 13:56 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1: Type: text/plain, Size: 428 bytes --]
On 7/31/07, Claudio Takahasi <cktakahasi@gmail.com> wrote:
> 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
>
Hi Marcel,
here is a new version based on your suggestions.
BR,
Claudio.
[-- Attachment #2: raw03.patch --]
[-- Type: text/x-diff, Size: 2351 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 1 Aug 2007 13:52:53 -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,12 @@
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 @@
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,
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 1 Aug 2007 13:52:53 -0000
@@ -523,14 +523,14 @@
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,29 @@
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)
[-- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-01 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-31 14:34 [Bluez-devel] [PATCH]Adapter D-Bus path on raw mode Claudio Takahasi
2007-08-01 13:56 ` Claudio Takahasi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox