* Re: [PATCH BlueZ] core: Do not call the callback on btd_cancel_authorization
From: Johan Hedberg @ 2012-10-26 11:58 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1351252089-19329-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Fri, Oct 26, 2012, Luiz Augusto von Dentz wrote:
> btd_cancel_authorization should work like g_source_remove and not attempt
> to reach the callback as its maybe already invalid or lead to double free
> situations such as this:
>
> Invalid write of size 4
> at 0x13D480: connection_lost (avdtp.c:1102)
> by 0x13F37A: session_cb (avdtp.c:2281)
> by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x122B21: main (main.c:551)
> Address 0x6512ac0 is 32 bytes inside a block of size 1,184 free'd
> at 0x4A07786: free (vg_replace_malloc.c:446)
> by 0x4C8150E: g_free (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x13D4A9: connection_lost (avdtp.c:1216)
> by 0x13D55E: auth_cb (avdtp.c:2471)
> by 0x17E99A: service_auth_cancel (adapter.c:1021)
> by 0x183C67: btd_cancel_authorization (adapter.c:3358)
> by 0x13D477: connection_lost (avdtp.c:1098)
> by 0x13F37A: session_cb (avdtp.c:2281)
> by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x122B21: main (main.c:551)
> ---
> src/adapter.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ] core: Do not call the callback on btd_cancel_authorization
From: Luiz Augusto von Dentz @ 2012-10-26 11:48 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
btd_cancel_authorization should work like g_source_remove and not attempt
to reach the callback as its maybe already invalid or lead to double free
situations such as this:
Invalid write of size 4
at 0x13D480: connection_lost (avdtp.c:1102)
by 0x13F37A: session_cb (avdtp.c:2281)
by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x122B21: main (main.c:551)
Address 0x6512ac0 is 32 bytes inside a block of size 1,184 free'd
at 0x4A07786: free (vg_replace_malloc.c:446)
by 0x4C8150E: g_free (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x13D4A9: connection_lost (avdtp.c:1216)
by 0x13D55E: auth_cb (avdtp.c:2471)
by 0x17E99A: service_auth_cancel (adapter.c:1021)
by 0x183C67: btd_cancel_authorization (adapter.c:3358)
by 0x13D477: connection_lost (avdtp.c:1098)
by 0x13F37A: session_cb (avdtp.c:2281)
by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x122B21: main (main.c:551)
---
src/adapter.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 54b1a64..32cc0a2 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3355,7 +3355,10 @@ int btd_cancel_authorization(guint id)
g_queue_remove(auth->adapter->auths, auth);
- service_auth_cancel(auth);
+ if (auth->agent != NULL)
+ agent_cancel(auth->agent);
+
+ g_free(auth);
return 0;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH v9 5/5] hcitool: Retrieve names from cache directory
From: Frédéric Danis @ 2012-10-26 10:08 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351246097-22285-1-git-send-email-frederic.danis@linux.intel.com>
---
Makefile.tools | 2 +-
tools/hcitool.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/Makefile.tools b/Makefile.tools
index ec79cea..f7c85ef 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -28,7 +28,7 @@ tools_hciconfig_LDADD = lib/libbluetooth-private.la
tools_hcitool_SOURCES = tools/hcitool.c src/oui.h src/oui.c \
src/textfile.h src/textfile.c
-tools_hcitool_LDADD = lib/libbluetooth-private.la
+tools_hcitool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
tools_sdptool_SOURCES = tools/sdptool.c src/sdp-xml.h src/sdp-xml.c
tools_sdptool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
diff --git a/tools/hcitool.c b/tools/hcitool.c
index aefbd68..a05e31f 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -40,6 +40,8 @@
#include <sys/socket.h>
#include <signal.h>
+#include <glib.h>
+
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
@@ -409,13 +411,32 @@ static char *major_classes[] = {
static char *get_device_name(const bdaddr_t *local, const bdaddr_t *peer)
{
- char filename[PATH_MAX + 1], addr[18];
+ char filename[PATH_MAX + 1];
+ char local_addr[18], peer_addr[18];
+ GKeyFile *key_file;
+ char *str = NULL;
+ int len;
+
+ ba2str(local, local_addr);
+ ba2str(peer, peer_addr);
+
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local_addr,
+ peer_addr);
+ filename[PATH_MAX] = '\0';
+ key_file = g_key_file_new();
+
+ if (g_key_file_load_from_file(key_file, filename, 0, NULL)) {
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str) {
+ len = strlen(str);
+ if (len > HCI_MAX_NAME_LENGTH)
+ str[HCI_MAX_NAME_LENGTH] = '\0';
+ }
+ }
- ba2str(local, addr);
- create_name(filename, PATH_MAX, STORAGEDIR, addr, "names");
+ g_key_file_free(key_file);
- ba2str(peer, addr);
- return textfile_get(filename, addr);
+ return str;
}
/* Display local devices */
--
1.7.9.5
^ permalink raw reply related
* [PATCH v9 4/5] input: Retrieve device name from device object
From: Frédéric Danis @ 2012-10-26 10:08 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351246097-22285-1-git-send-email-frederic.danis@linux.intel.com>
---
profiles/input/device.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index fbc3d6f..108be39 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -777,7 +777,7 @@ static struct input_device *input_device_new(struct btd_device *device,
{
struct btd_adapter *adapter = device_get_adapter(device);
struct input_device *idev;
- char name[249], src_addr[18], dst_addr[18];
+ char name[HCI_MAX_NAME_LENGTH + 1];
idev = g_new0(struct input_device, 1);
bacpy(&idev->src, adapter_get_address(adapter));
@@ -787,11 +787,8 @@ static struct input_device *input_device_new(struct btd_device *device,
idev->handle = handle;
idev->disable_sdp = disable_sdp;
- ba2str(&idev->src, src_addr);
- ba2str(&idev->dst, dst_addr);
-
- if (read_device_name(src_addr, dst_addr, device_get_addr_type(device),
- name) == 0)
+ device_get_name(device, name, HCI_MAX_NAME_LENGTH);
+ if (strlen(name) > 0)
idev->name = g_strdup(name);
if (g_dbus_register_interface(btd_get_dbus_connection(),
--
1.7.9.5
^ permalink raw reply related
* [PATCH v9 3/5] dbusoob: Set device name in device object
From: Frédéric Danis @ 2012-10-26 10:08 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351246097-22285-1-git-send-email-frederic.danis@linux.intel.com>
---
plugins/dbusoob.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 5c5b6ef..82cd304 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -191,9 +191,11 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
return TRUE;
}
-static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
+static gboolean store_data(struct btd_adapter *adapter, const char *address,
+ struct oob_data *data)
{
bdaddr_t bdaddr;
+ struct btd_device *device;
str2ba(data->addr, &bdaddr);
@@ -203,13 +205,14 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
return FALSE;
}
+ device = adapter_get_device(adapter, address);
+
if (data->class)
write_remote_class(adapter_get_address(adapter), &bdaddr,
data->class);
if (data->name)
- write_device_name(adapter_get_address(adapter), &bdaddr, 0,
- data->name);
+ device_set_name(device, data->name);
return TRUE;
}
@@ -245,7 +248,7 @@ static DBusMessage *add_remote_data(DBusConnection *conn, DBusMessage *msg,
if (!parse_data(&data, &remote_data))
return btd_error_invalid_args(msg);
- if (!store_data(adapter, &remote_data))
+ if (!store_data(adapter, remote_data.addr, &remote_data))
return btd_error_failed(msg, "Request failed");
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v9 2/5] device: Retrieve name from storage
From: Frédéric Danis @ 2012-10-26 10:08 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351246097-22285-1-git-send-email-frederic.danis@linux.intel.com>
Try to retrieve name from device info file.
If that fails fall back to the cache and save it to device info file.
When device name is updated, save it.
---
src/device.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 101 insertions(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index bc7f8dd..9749bfd 100644
--- a/src/device.c
+++ b/src/device.c
@@ -76,6 +76,9 @@
#define DISCONNECT_TIMER 2
#define DISCOVERY_TIMER 2
+#define INFO_PATH STORAGEDIR "/%s/%s/info"
+#define CACHE_PATH STORAGEDIR "/%s/cache/%s"
+
struct btd_disconnect_data {
guint id;
disconnect_watch watch;
@@ -202,6 +205,36 @@ static uint16_t uuid_list[] = {
0
};
+static void store_device_info(struct btd_device *device)
+{
+ GKeyFile *key_file;
+ char filename[PATH_MAX + 1];
+ char adapter_addr[18];
+ char device_addr[18];
+ char *str;
+ gsize length = 0;
+
+ if (device->temporary)
+ return;
+
+ key_file = g_key_file_new();
+
+ g_key_file_set_string(key_file, "General", "Name", device->name);
+
+ ba2str(adapter_get_address(device->adapter), adapter_addr);
+ ba2str(&device->bdaddr, device_addr);
+ snprintf(filename, PATH_MAX, INFO_PATH, adapter_addr, device_addr);
+ filename[PATH_MAX] = '\0';
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ str = g_key_file_to_data(key_file, &length, NULL);
+ g_file_set_contents(filename, str, length, NULL);
+ g_free(str);
+
+ g_key_file_free(key_file);
+}
+
static void browse_request_free(struct browse_req *req)
{
if (req->listener_id)
@@ -1564,6 +1597,70 @@ static void device_set_version(struct btd_device *device, uint16_t value)
DEVICE_INTERFACE, "Version");
}
+static char *load_cached_name(struct btd_device *device, const char *local,
+ const gchar *peer)
+{
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ char *str = NULL;
+ int len;
+
+ snprintf(filename, PATH_MAX, CACHE_PATH, local, peer);
+ filename[PATH_MAX] = '\0';
+
+ key_file = g_key_file_new();
+
+ if (!g_key_file_load_from_file(key_file, filename, 0, NULL))
+ goto failed;
+
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str) {
+ len = strlen(str);
+ if (len > HCI_MAX_NAME_LENGTH)
+ str[HCI_MAX_NAME_LENGTH] = '\0';
+ }
+
+failed:
+ g_key_file_free(key_file);
+
+ return str;
+}
+
+static void load_info(struct btd_device *device, const gchar *local,
+ const gchar *peer)
+{
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ char *str;
+ gboolean store_needed = FALSE;
+
+ snprintf(filename, PATH_MAX, INFO_PATH, local, peer);
+ filename[PATH_MAX] = '\0';
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+ /* Load device name from storage info file, if that fails fall back to
+ * the cache.
+ */
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str == NULL) {
+ str = load_cached_name(device, local, peer);
+ if (str)
+ store_needed = TRUE;
+ }
+
+ if (str) {
+ strcpy(device->name, str);
+ g_free(str);
+ }
+
+ if (store_needed)
+ store_device_info(device);
+
+ g_key_file_free(key_file);
+}
+
struct btd_device *device_create(struct btd_adapter *adapter,
const gchar *address, uint8_t bdaddr_type)
{
@@ -1600,7 +1697,8 @@ struct btd_device *device_create(struct btd_adapter *adapter,
src = adapter_get_address(adapter);
ba2str(src, srcaddr);
- read_device_name(srcaddr, address, bdaddr_type, device->name);
+ load_info(device, srcaddr, address);
+
if (read_device_alias(srcaddr, address, bdaddr_type, alias,
sizeof(alias)) == 0)
device->alias = g_strdup(alias);
@@ -1640,6 +1738,8 @@ void device_set_name(struct btd_device *device, const char *name)
strncpy(device->name, name, MAX_NAME_LENGTH);
+ store_device_info(device);
+
g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
DEVICE_INTERFACE, "Name");
--
1.7.9.5
^ permalink raw reply related
* [PATCH v9 1/5] doc: Update settings-storage.txt
From: Frédéric Danis @ 2012-10-26 10:08 UTC (permalink / raw)
To: linux-bluetooth
Device name should be saved in device info file.
---
doc/settings-storage.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 93184d1..1174d44 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -132,6 +132,8 @@ Long term key) related to a remote device.
[General] group contains:
+ Name String Remote device friendly name
+
Alias String Alias name
Class String Device class in hexadecimal,
--
1.7.9.5
^ permalink raw reply related
* [PATCH v8 5/5] hcitool: Retrieve names from cache directory
From: Frédéric Danis @ 2012-10-26 9:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351243505-20702-1-git-send-email-frederic.danis@linux.intel.com>
---
Makefile.tools | 2 +-
tools/hcitool.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/Makefile.tools b/Makefile.tools
index ec79cea..f7c85ef 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -28,7 +28,7 @@ tools_hciconfig_LDADD = lib/libbluetooth-private.la
tools_hcitool_SOURCES = tools/hcitool.c src/oui.h src/oui.c \
src/textfile.h src/textfile.c
-tools_hcitool_LDADD = lib/libbluetooth-private.la
+tools_hcitool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
tools_sdptool_SOURCES = tools/sdptool.c src/sdp-xml.h src/sdp-xml.c
tools_sdptool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
diff --git a/tools/hcitool.c b/tools/hcitool.c
index aefbd68..a05e31f 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -40,6 +40,8 @@
#include <sys/socket.h>
#include <signal.h>
+#include <glib.h>
+
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
@@ -409,13 +411,32 @@ static char *major_classes[] = {
static char *get_device_name(const bdaddr_t *local, const bdaddr_t *peer)
{
- char filename[PATH_MAX + 1], addr[18];
+ char filename[PATH_MAX + 1];
+ char local_addr[18], peer_addr[18];
+ GKeyFile *key_file;
+ char *str = NULL;
+ int len;
+
+ ba2str(local, local_addr);
+ ba2str(peer, peer_addr);
+
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local_addr,
+ peer_addr);
+ filename[PATH_MAX] = '\0';
+ key_file = g_key_file_new();
+
+ if (g_key_file_load_from_file(key_file, filename, 0, NULL)) {
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str) {
+ len = strlen(str);
+ if (len > HCI_MAX_NAME_LENGTH)
+ str[HCI_MAX_NAME_LENGTH] = '\0';
+ }
+ }
- ba2str(local, addr);
- create_name(filename, PATH_MAX, STORAGEDIR, addr, "names");
+ g_key_file_free(key_file);
- ba2str(peer, addr);
- return textfile_get(filename, addr);
+ return str;
}
/* Display local devices */
--
1.7.9.5
^ permalink raw reply related
* [PATCH v8 4/5] input: Retrieve device name from device object
From: Frédéric Danis @ 2012-10-26 9:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351243505-20702-1-git-send-email-frederic.danis@linux.intel.com>
---
profiles/input/device.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index fbc3d6f..108be39 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -777,7 +777,7 @@ static struct input_device *input_device_new(struct btd_device *device,
{
struct btd_adapter *adapter = device_get_adapter(device);
struct input_device *idev;
- char name[249], src_addr[18], dst_addr[18];
+ char name[HCI_MAX_NAME_LENGTH + 1];
idev = g_new0(struct input_device, 1);
bacpy(&idev->src, adapter_get_address(adapter));
@@ -787,11 +787,8 @@ static struct input_device *input_device_new(struct btd_device *device,
idev->handle = handle;
idev->disable_sdp = disable_sdp;
- ba2str(&idev->src, src_addr);
- ba2str(&idev->dst, dst_addr);
-
- if (read_device_name(src_addr, dst_addr, device_get_addr_type(device),
- name) == 0)
+ device_get_name(device, name, HCI_MAX_NAME_LENGTH);
+ if (strlen(name) > 0)
idev->name = g_strdup(name);
if (g_dbus_register_interface(btd_get_dbus_connection(),
--
1.7.9.5
^ permalink raw reply related
* [PATCH v8 3/5] dbusoob: Set device name in device object
From: Frédéric Danis @ 2012-10-26 9:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351243505-20702-1-git-send-email-frederic.danis@linux.intel.com>
---
plugins/dbusoob.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 5c5b6ef..82cd304 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -191,9 +191,11 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
return TRUE;
}
-static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
+static gboolean store_data(struct btd_adapter *adapter, const char *address,
+ struct oob_data *data)
{
bdaddr_t bdaddr;
+ struct btd_device *device;
str2ba(data->addr, &bdaddr);
@@ -203,13 +205,14 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
return FALSE;
}
+ device = adapter_get_device(adapter, address);
+
if (data->class)
write_remote_class(adapter_get_address(adapter), &bdaddr,
data->class);
if (data->name)
- write_device_name(adapter_get_address(adapter), &bdaddr, 0,
- data->name);
+ device_set_name(device, data->name);
return TRUE;
}
@@ -245,7 +248,7 @@ static DBusMessage *add_remote_data(DBusConnection *conn, DBusMessage *msg,
if (!parse_data(&data, &remote_data))
return btd_error_invalid_args(msg);
- if (!store_data(adapter, &remote_data))
+ if (!store_data(adapter, remote_data.addr, &remote_data))
return btd_error_failed(msg, "Request failed");
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v8 2/5] device: Retrieve name from storage
From: Frédéric Danis @ 2012-10-26 9:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351243505-20702-1-git-send-email-frederic.danis@linux.intel.com>
Try to retrieve name from device info file.
If that fails fall back to the cache and save it to device info file.
When device name is updated, save it.
---
src/device.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 98 insertions(+), 1 deletion(-)
diff --git a/src/device.c b/src/device.c
index bc7f8dd..d27fd31 100644
--- a/src/device.c
+++ b/src/device.c
@@ -76,6 +76,9 @@
#define DISCONNECT_TIMER 2
#define DISCOVERY_TIMER 2
+#define INFO_PATH STORAGEDIR "/%s/%s/info"
+#define CACHE_PATH STORAGEDIR "/%s/cache/%s"
+
struct btd_disconnect_data {
guint id;
disconnect_watch watch;
@@ -202,6 +205,33 @@ static uint16_t uuid_list[] = {
0
};
+static void store_device_info(struct btd_device *device)
+{
+ GKeyFile *key_file;
+ char filename[PATH_MAX + 1];
+ char adapter_addr[18];
+ char device_addr[18];
+ char *str;
+ gsize length = 0;
+
+ key_file = g_key_file_new();
+
+ g_key_file_set_string(key_file, "General", "Name", device->name);
+
+ ba2str(adapter_get_address(device->adapter), adapter_addr);
+ ba2str(&device->bdaddr, device_addr);
+ snprintf(filename, PATH_MAX, INFO_PATH, adapter_addr, device_addr);
+ filename[PATH_MAX] = '\0';
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ str = g_key_file_to_data(key_file, &length, NULL);
+ g_file_set_contents(filename, str, length, NULL);
+ g_free(str);
+
+ g_key_file_free(key_file);
+}
+
static void browse_request_free(struct browse_req *req)
{
if (req->listener_id)
@@ -1564,6 +1594,70 @@ static void device_set_version(struct btd_device *device, uint16_t value)
DEVICE_INTERFACE, "Version");
}
+static char *load_cached_name(struct btd_device *device, const char *local,
+ const gchar *peer)
+{
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ char *str = NULL;
+ int len;
+
+ snprintf(filename, PATH_MAX, CACHE_PATH, local, peer);
+ filename[PATH_MAX] = '\0';
+
+ key_file = g_key_file_new();
+
+ if (!g_key_file_load_from_file(key_file, filename, 0, NULL))
+ goto failed;
+
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str) {
+ len = strlen(str);
+ if (len > HCI_MAX_NAME_LENGTH)
+ str[HCI_MAX_NAME_LENGTH] = '\0';
+ }
+
+failed:
+ g_key_file_free(key_file);
+
+ return str;
+}
+
+static void load_info(struct btd_device *device, const gchar *local,
+ const gchar *peer)
+{
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ char *str;
+ gboolean store_needed = FALSE;
+
+ snprintf(filename, PATH_MAX, INFO_PATH, local, peer);
+ filename[PATH_MAX] = '\0';
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+ /* Load device name from storage info file, if that fails fall back to
+ * the cache.
+ */
+ str = g_key_file_get_string(key_file, "General", "Name", NULL);
+ if (str == NULL) {
+ str = load_cached_name(device, local, peer);
+ if (str)
+ store_needed = TRUE;
+ }
+
+ if (str) {
+ strcpy(device->name, str);
+ g_free(str);
+ }
+
+ if (store_needed)
+ store_device_info(device);
+
+ g_key_file_free(key_file);
+}
+
struct btd_device *device_create(struct btd_adapter *adapter,
const gchar *address, uint8_t bdaddr_type)
{
@@ -1600,7 +1694,8 @@ struct btd_device *device_create(struct btd_adapter *adapter,
src = adapter_get_address(adapter);
ba2str(src, srcaddr);
- read_device_name(srcaddr, address, bdaddr_type, device->name);
+ load_info(device, srcaddr, address);
+
if (read_device_alias(srcaddr, address, bdaddr_type, alias,
sizeof(alias)) == 0)
device->alias = g_strdup(alias);
@@ -1640,6 +1735,8 @@ void device_set_name(struct btd_device *device, const char *name)
strncpy(device->name, name, MAX_NAME_LENGTH);
+ store_device_info(device);
+
g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
DEVICE_INTERFACE, "Name");
--
1.7.9.5
^ permalink raw reply related
* [PATCH v8 1/5] doc: Update settings-storage.txt
From: Frédéric Danis @ 2012-10-26 9:25 UTC (permalink / raw)
To: linux-bluetooth
Device name should be saved in device info file.
---
doc/settings-storage.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 93184d1..1174d44 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -132,6 +132,8 @@ Long term key) related to a remote device.
[General] group contains:
+ Name String Remote device friendly name
+
Alias String Alias name
Class String Device class in hexadecimal,
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ v3] AVDTP: Do not keep a internal reference
From: Luiz Augusto von Dentz @ 2012-10-26 8:30 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Don't initialize reference with 1, instead always start disconnect timer
when reference drops to 0, so in case nobody reclaims the session it
automatically disconnect after 1 second and frees the memory.
---
v2: Fix with stream_setup flag being ignored in disconnect_timeout
v3: Do avrcp_free on connection_lost to avoid having dangling sessions in
disconnected state waiting the timeout to be freed.
audio/avdtp.c | 211 +++++++++++++++++++++++++---------------------------------
1 file changed, 89 insertions(+), 122 deletions(-)
diff --git a/audio/avdtp.c b/audio/avdtp.c
index bd91cb6..9a5dbe6 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -387,8 +387,7 @@ struct avdtp_stream {
/* Structure describing an AVDTP connection between two devices */
struct avdtp {
- int ref;
- int free_lock;
+ unsigned int ref;
uint16_t version;
@@ -657,50 +656,6 @@ static gboolean stream_open_timeout(gpointer user_data)
return FALSE;
}
-static gboolean disconnect_timeout(gpointer user_data)
-{
- struct avdtp *session = user_data;
- struct audio_device *dev;
- gboolean stream_setup;
-
- session->dc_timer = 0;
- stream_setup = session->stream_setup;
- session->stream_setup = FALSE;
-
- dev = manager_get_device(&session->server->src, &session->dst, FALSE);
-
- if (dev && dev->sink && stream_setup)
- sink_setup_stream(dev->sink, session);
- else if (dev && dev->source && stream_setup)
- source_setup_stream(dev->source, session);
- else
- connection_lost(session, ETIMEDOUT);
-
- return FALSE;
-}
-
-static void remove_disconnect_timer(struct avdtp *session)
-{
- g_source_remove(session->dc_timer);
- session->dc_timer = 0;
- session->stream_setup = FALSE;
-}
-
-static void set_disconnect_timer(struct avdtp *session)
-{
- if (session->dc_timer)
- remove_disconnect_timer(session);
-
- if (session->device_disconnect) {
- session->dc_timer = g_idle_add(disconnect_timeout, session);
- return;
- }
-
- session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
- disconnect_timeout,
- session);
-}
-
void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id)
{
err->category = category;
@@ -780,8 +735,9 @@ static void avdtp_set_state(struct avdtp *session,
}
}
-static void stream_free(struct avdtp_stream *stream)
+static void stream_free(void *data)
{
+ struct avdtp_stream *stream = data;
struct avdtp_remote_sep *rsep;
stream->lsep->info.inuse = 0;
@@ -1144,37 +1100,39 @@ static int avdtp_cancel_authorization(struct avdtp *session)
return err;
session->auth_id = 0;
+ avdtp_unref(session);
return 0;
}
-static void connection_lost(struct avdtp *session, int err)
+static void sep_free(gpointer data)
{
- char address[18];
-
- ba2str(&session->dst, address);
- DBG("Disconnected from %s", address);
+ struct avdtp_remote_sep *sep = data;
- if (err != EACCES)
- avdtp_cancel_authorization(session);
+ g_slist_free_full(sep->caps, g_free);
+ g_free(sep);
+}
- session->free_lock = 1;
+static void remove_disconnect_timer(struct avdtp *session)
+{
+ g_source_remove(session->dc_timer);
+ session->dc_timer = 0;
+ session->stream_setup = FALSE;
+}
- finalize_discovery(session, err);
+static void avdtp_free(void *data)
+{
+ struct avdtp *session = data;
- g_slist_foreach(session->streams, (GFunc) release_stream, session);
- session->streams = NULL;
+ DBG("%p", session);
- session->free_lock = 0;
+ g_slist_free_full(session->streams, stream_free);
if (session->io) {
g_io_channel_shutdown(session->io, FALSE, NULL);
g_io_channel_unref(session->io);
- session->io = NULL;
}
- avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
-
if (session->io_id) {
g_source_remove(session->io_id);
session->io_id = 0;
@@ -1183,69 +1141,91 @@ static void connection_lost(struct avdtp *session, int err)
if (session->dc_timer)
remove_disconnect_timer(session);
- if (session->ref != 1)
- error("connection_lost: ref count not 1 after all callbacks");
- else
- avdtp_unref(session);
+ if (session->req)
+ pending_req_free(session->req);
+
+ g_slist_free_full(session->seps, sep_free);
+
+ g_free(session->buf);
+
+ g_free(session);
}
-static void sep_free(gpointer data)
+static gboolean disconnect_timeout(gpointer user_data)
{
- struct avdtp_remote_sep *sep = data;
+ struct avdtp *session = user_data;
+ struct audio_device *dev;
+ gboolean stream_setup;
- g_slist_free_full(sep->caps, g_free);
- g_free(sep);
+ session->dc_timer = 0;
+
+ stream_setup = session->stream_setup;
+ session->stream_setup = FALSE;
+ dev = manager_get_device(&session->server->src, &session->dst, FALSE);
+
+ if (dev && dev->sink && stream_setup)
+ sink_setup_stream(dev->sink, session);
+ else if (dev && dev->source && stream_setup)
+ source_setup_stream(dev->source, session);
+ else
+ connection_lost(session, ETIMEDOUT);
+
+ return FALSE;
}
-void avdtp_unref(struct avdtp *session)
+static void set_disconnect_timer(struct avdtp *session)
{
- struct avdtp_server *server;
+ if (session->dc_timer)
+ remove_disconnect_timer(session);
- if (!session)
+ if (session->device_disconnect) {
+ session->dc_timer = g_idle_add(disconnect_timeout, session);
return;
+ }
- session->ref--;
+ session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
+ disconnect_timeout,
+ session);
+}
- DBG("%p: ref=%d", session, session->ref);
+static void connection_lost(struct avdtp *session, int err)
+{
+ struct avdtp_server *server = session->server;
+ char address[18];
- if (session->ref == 1) {
- if (session->state == AVDTP_SESSION_STATE_CONNECTING &&
- session->io) {
- avdtp_cancel_authorization(session);
- g_io_channel_shutdown(session->io, TRUE, NULL);
- g_io_channel_unref(session->io);
- session->io = NULL;
- avdtp_set_state(session,
- AVDTP_SESSION_STATE_DISCONNECTED);
- }
+ ba2str(&session->dst, address);
+ DBG("Disconnected from %s", address);
- if (session->io)
- set_disconnect_timer(session);
- else if (!session->free_lock) /* Drop the local ref if we
- aren't connected */
- session->ref--;
- }
+ if (err != EACCES)
+ avdtp_cancel_authorization(session);
- if (session->ref > 0)
- return;
+ g_slist_foreach(session->streams, (GFunc) release_stream, session);
+ session->streams = NULL;
- server = session->server;
+ finalize_discovery(session, err);
- DBG("%p: freeing session and removing from list", session);
+ avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
- if (session->dc_timer)
- remove_disconnect_timer(session);
+ if (session->ref > 0)
+ return;
server->sessions = g_slist_remove(server->sessions, session);
+ avdtp_free(session);
+}
- if (session->req)
- pending_req_free(session->req);
+void avdtp_unref(struct avdtp *session)
+{
+ if (!session)
+ return;
- g_slist_free_full(session->seps, sep_free);
+ session->ref--;
- g_free(session->buf);
+ DBG("%p: ref=%d", session, session->ref);
- g_free(session);
+ if (session->ref > 0)
+ return;
+
+ set_disconnect_timer(session);
}
struct avdtp *avdtp_ref(struct avdtp *session)
@@ -2231,12 +2211,6 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
goto failed;
}
- if (session->ref == 1 && !session->streams && !session->req)
- set_disconnect_timer(session);
-
- if (session->streams && session->dc_timer)
- remove_disconnect_timer(session);
-
if (session->req && session->req->collided) {
DBG("Collision detected");
goto next;
@@ -2383,7 +2357,7 @@ static struct avdtp *avdtp_get_internal(const bdaddr_t *src, const bdaddr_t *dst
session->server = server;
bacpy(&session->dst, dst);
- session->ref = 1;
+ set_disconnect_timer(session);
/* We don't use avdtp_set_state() here since this isn't a state change
* but just setting of the initial state */
session->state = AVDTP_SESSION_STATE_DISCONNECTED;
@@ -2490,6 +2464,8 @@ static void auth_cb(DBusError *derr, void *user_data)
struct avdtp *session = user_data;
GError *err = NULL;
+ avdtp_unref(session);
+
if (derr && dbus_error_is_set(derr)) {
error("Access denied: %s", derr->message);
connection_lost(session, EACCES);
@@ -2578,10 +2554,12 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
auth_cb, session);
if (session->auth_id == 0) {
avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
- avdtp_unref(session);
goto drop;
}
+ /* Disable disconnect timer while authorizing */
+ avdtp_ref(session);
+
dev->auto_connect = auto_connect;
return;
@@ -3949,23 +3927,12 @@ proceed:
void avdtp_exit(const bdaddr_t *src)
{
struct avdtp_server *server;
- GSList *l;
server = find_server(servers, src);
if (!server)
return;
- l = server->sessions;
- while (l) {
- struct avdtp *session = l->data;
-
- l = l->next;
- /* value of l pointer should be updated before invoking
- * connection_lost since it internally uses avdtp_unref
- * which operates on server->session list as well
- */
- connection_lost(session, -ECONNABORTED);
- }
+ g_slist_free_full(server->sessions, avdtp_free);
servers = g_slist_remove(servers, server);
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH BlueZ] core: Fix memory leak
From: Johan Hedberg @ 2012-10-26 8:01 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1351238216-7583-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Fri, Oct 26, 2012, Luiz Augusto von Dentz wrote:
> 1,262 (64 direct, 1,198 indirect) bytes in 1 blocks are definitely lost in loss record 280 of 290
> at 0x4A0881C: malloc (vg_replace_malloc.c:270)
> by 0x4C813FE: g_malloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C95801: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C95D55: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C746AA: g_key_file_new (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x18136C: load_config (adapter.c:2620)
> by 0x18353B: adapter_init (adapter.c:2708)
> by 0x17E62E: btd_manager_register_adapter (manager.c:337)
> by 0x191171: mgmt_event.part.36 (mgmt.c:1081)
> by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
> ---
> src/adapter.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v0] network: Remove unnecessary field from connect_req
From: Johan Hedberg @ 2012-10-26 8:00 UTC (permalink / raw)
To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz
In-Reply-To: <1351230929-4484-1-git-send-email-mikel.astiz.oss@gmail.com>
Hi Mikel,
On Fri, Oct 26, 2012, Mikel Astiz wrote:
> The device pointer in struct connect_req can be completely removed since
> the callback already receives such pointer, and the network_peer takes
> care of the device refcounting.
> ---
> profiles/network/manager.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ] core: Fix memory leak
From: Luiz Augusto von Dentz @ 2012-10-26 7:56 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1,262 (64 direct, 1,198 indirect) bytes in 1 blocks are definitely lost in loss record 280 of 290
at 0x4A0881C: malloc (vg_replace_malloc.c:270)
by 0x4C813FE: g_malloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C95801: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C95D55: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C746AA: g_key_file_new (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x18136C: load_config (adapter.c:2620)
by 0x18353B: adapter_init (adapter.c:2708)
by 0x17E62E: btd_manager_register_adapter (manager.c:337)
by 0x191171: mgmt_event.part.36 (mgmt.c:1081)
by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
---
src/adapter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index c7b8c7f..54b1a64 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2684,6 +2684,8 @@ static void load_config(struct btd_adapter *adapter)
mgmt_set_connectable(adapter->dev_id, TRUE);
mgmt_set_discoverable(adapter->dev_id, adapter->discoverable,
adapter->discov_timeout);
+
+ g_key_file_free(key_file);
}
gboolean adapter_init(struct btd_adapter *adapter, gboolean up)
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH BlueZ 07/11] AVRCP: Add initial support for controller player
From: Johan Hedberg @ 2012-10-26 7:44 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1351173554-28039-7-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Thu, Oct 25, 2012, Luiz Augusto von Dentz wrote:
> This also bump controller record to 1.3.
> ---
> Makefile.am | 1 +
> audio/avrcp.c | 686 +++++++++++++++++++++++++++++++++++++++++++++++++--------
> audio/player.c | 404 +++++++++++++++++++++++++++++++++
> audio/player.h | 46 ++++
> 4 files changed, 1047 insertions(+), 90 deletions(-)
> create mode 100644 audio/player.c
> create mode 100644 audio/player.h
I've applied patches 1-6 but this one is just huge. Isn't there some
easy way you could split it up a bit? Also, the necessary D-Bus API
documentation changes seem to be missing.
Johan
^ permalink raw reply
* [PATCH v0] network: Remove unnecessary field from connect_req
From: Mikel Astiz @ 2012-10-26 5:55 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The device pointer in struct connect_req can be completely removed since
the callback already receives such pointer, and the network_peer takes
care of the device refcounting.
---
profiles/network/manager.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index ad52885..8d0dc4d 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -48,7 +48,6 @@
static gboolean conf_security = TRUE;
struct connect_req {
- struct btd_device *device;
struct btd_profile *profile;
btd_profile_cb cb;
};
@@ -84,9 +83,7 @@ static void connect_profile_cb(struct btd_device *device, int err,
{
struct connect_req *req = data;
- req->cb(req->profile, req->device, err);
-
- btd_device_unref(req->device);
+ req->cb(req->profile, device, err);
g_free(req);
}
@@ -100,14 +97,12 @@ static int connect_profile(struct btd_device *dev, struct btd_profile *profile,
DBG("path %s id %u", device_get_path(dev), id);
req = g_new0(struct connect_req, 1);
- req->device = btd_device_ref(dev);
req->profile = profile;
req->cb = cb;
err = connection_connect(dev, BNEP_SVC_PANU, NULL, connect_profile_cb,
req);
if (err < 0) {
- btd_device_unref(req->device);
g_free(req);
return err;
}
--
1.7.11.7
^ permalink raw reply related
* Re: [RFC 10/18] cyclingspeed: Add DBus.Properties for org.bluez.CyclingSpeed interface
From: Lucas De Marchi @ 2012-10-26 4:49 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1351176228-5789-11-git-send-email-andrzej.kaczmarek@tieto.com>
On Thu, Oct 25, 2012 at 12:43 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> ---
> profiles/cyclingspeed/cyclingspeed.c | 99 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 98 insertions(+), 1 deletion(-)
>
> diff --git a/profiles/cyclingspeed/cyclingspeed.c b/profiles/cyclingspeed/cyclingspeed.c
> index f7ffd2e..4f48121 100644
> --- a/profiles/cyclingspeed/cyclingspeed.c
> +++ b/profiles/cyclingspeed/cyclingspeed.c
> @@ -43,6 +43,7 @@
>
> #define CYCLINGSPEED_MANAGER_INTERFACE "org.bluez.CyclingSpeedManager"
> #define CYCLINGSPEED_WATCHER_INTERFACE "org.bluez.CyclingSpeedWatcher"
> +#define CYCLINGSPEED_INTERFACE "org.bluez.CyclingSpeed"
>
> #define WHEEL_REV_SUPPORT 0x01
> #define CRANK_REV_SUPPORT 0x02
> @@ -102,6 +103,21 @@ struct characteristic {
>
> static GSList *csc_adapters = NULL;
>
> +static const char * const location_enum[] = {
> + "other", "top-of-shoe", "in-shoe", "hip", "front-wheel", "left-crank",
> + "right-crank", "left-pedal", "right-pedal", "front-hub",
> + "rear-dropout", "chainstay", "rear-wheel", "rear-hub"
> +};
> +
> +static const gchar *location2str(uint8_t value)
> +{
> + if (value < G_N_ELEMENTS(location_enum))
> + return location_enum[value];
> +
> + info("Body Sensor Location [%d] is RFU", value);
> + return location_enum[0];
> +}
> +
> static gint cmp_adapter(gconstpointer a, gconstpointer b)
> {
> const struct csc_adapter *cadapter = a;
> @@ -687,6 +703,74 @@ void csc_adapter_unregister(struct btd_adapter *adapter)
> CYCLINGSPEED_MANAGER_INTERFACE);
> }
>
> +static gboolean property_get_location(const GDBusPropertyTable *property,
> + DBusMessageIter *iter, void *data)
> +{
> + struct csc *csc = data;
> + char *loc;
> +
> + if (!csc->has_location)
> + return FALSE;
> +
> + loc = g_strdup(location2str(csc->location));
> +
> + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &loc);
> +
> + g_free(loc);
you don't need to dup/free the string
Lucas De Marchi
^ permalink raw reply
* BLE GATT subscriber example?
From: Couch, Kelly J @ 2012-10-26 4:24 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
I'm interested in building a C application that utilizes BLE GATT via DBUS. However, I have been unable to identify a good source of documentation or example that demonstrates how.
I want to enable the following capabilities:
Pairing - Working...
Subscribe to:
Attribute/characteristic change notifications.
Connect/disconnect notifications
Any suggestions are greatly appreciated.
-Kelly
^ permalink raw reply
* Re: [PATCH] systemd: prevent duplicate logging messages in journal
From: Marcel Holtmann @ 2012-10-25 23:30 UTC (permalink / raw)
To: Marti Raudsepp; +Cc: linux-bluetooth
In-Reply-To: <1349884769-5157-1-git-send-email-marti@juffo.org>
Hi Marti,
> By default, both stdout and syslog messages go to the systemd journal,
> which results in duplicate messages being logged.
> ---
> src/bluetooth.service.in | 1 +
> 1 file changed, 1 insertion(+)
patch has been applied.
Regards
Marcel
^ permalink raw reply
* [PATCH] Bluetooth: Fix error status when pairing fails
From: Paulo Sérgio @ 2012-10-25 19:55 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Paulo Sérgio
In-Reply-To: <1351192136-6925-1-git-send-email-paulo.sergio@openbossa.org>
When pairing fails due to wrong confirm value, the management layer
doesn't report a proper error status. It sends
MGMT_STATUS_CONNECT_FAILED instead of MGMT_STATUS_AUTH_FAILED.
Most of management functions that receive a status as a parameter
expects for it to be encoded as a HCI status. But when a SMP pairing
fails, the SMP layer sends the SMP reason as the error status to the
management layer.
This commit maps all SMP reasons to HCI_ERROR_AUTH_FAILURE, which will
be converted to MGMT_STATUS_AUTH_FAILED in the management layer.
Reported-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
Reviewed-by: João Paulo Rechi Vita <jprvita@openbossa.org>
Signed-off-by: Paulo Sérgio <paulo.sergio@openbossa.org>
---
Please, disconsider the previous patch. It had a wrong commit message.
PS: This is my first patch.
net/bluetooth/smp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b542c5d..b3b7cc0 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -266,7 +266,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type,
- hcon->dst_type, reason);
+ hcon->dst_type, HCI_ERROR_AUTH_FAILURE);
cancel_delayed_work_sync(&conn->security_timer);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17b5]
From: Jeff Cook @ 2012-10-25 19:17 UTC (permalink / raw)
To: Anderson Lizardo, gustavo
Cc: marcel, johan.hedberg, linux-bluetooth, linux-kernel
In-Reply-To: <CAJdJm_NrmfU17aQDmO0hbihV673Of0iFnLqk4=-sPh=g44eixA@mail.gmail.com>
On 10/24/2012 06:20 AM, Anderson Lizardo wrote:
> Hi Jeff,
>
> On Wed, Oct 24, 2012 at 5:29 AM, Jeff Cook <jeff@deserettechnology.com> wrote:
>> Hello all,
>>
>> Please see included patch. First-time submitter so let me know if I did
>> something wrong.
>
> Just one more suggestion (adding to Gustavo's comments), you may want to read:
>
> http://www.kernel.org/doc/Documentation/SubmittingPatches
>
> Specially sections 12 and 15.
Thanks for the help everyone. I did skim SubmittingPatches prior to
submission, but dropped off before sections 12 and 15; the information
seemed outdated since it made no mention of git by the time I stopped
reading (around section 9 or so), so I looked elsewhere.
I will resubmit according to the information in Section 15. Do I need to
add something like "try 2" to the patch's subject line, or is it okay
without that?
^ permalink raw reply
* [PATCH] Bluetooth: Fix error message when pairing fails
From: Paulo Sérgio @ 2012-10-25 19:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Paulo Sérgio
When pairing fails due to wrong confirm value, the management layer
doesn't report a proper error message. It sends a
MGMT_STATUS_CONNECT_FAILED instead of a MGMT_STATUS_AUTH_FAILED.
Most of management functions that receive a status as a parameter
expects for it to be encoded as a HCI status. But when a SMP pairing
fails, the SMP layer sends the SMP reason as the error status to the
management layer.
This commit maps all SMP reasons to HCI_ERROR_AUTH_FAILURE, which will
be converted to MGMT_STATUS_AUTH_FAILED in the management layer.
Reported-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
Reviewed-by: João Paulo Rechi Vita <jprvita@openbossa.org>
Signed-off-by: Paulo Sérgio <paulo.sergio@openbossa.org>
---
net/bluetooth/smp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index b542c5d..b3b7cc0 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -266,7 +266,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type,
- hcon->dst_type, reason);
+ hcon->dst_type, HCI_ERROR_AUTH_FAILURE);
cancel_delayed_work_sync(&conn->security_timer);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 5/6] Bluetooth: mgmt: Add support for switching to LE peripheral mode
From: Vinicius Costa Gomes @ 2012-10-25 18:48 UTC (permalink / raw)
To: Anderson Lizardo, Marcel Holtmann, linux-bluetooth
In-Reply-To: <20121025150754.GA5845@x220>
Hi Johan,
On 18:07 Thu 25 Oct, Johan Hedberg wrote:
> Hi Vinicius,
>
> On Thu, Oct 25, 2012, Vinicius Costa Gomes wrote:
> > > On Thu, Oct 25, 2012, Johan Hedberg wrote:
> > > > This will need some more thinking. We could add a new mgmt command for
> > > > that, or if you wanna go crazy why not map this to the L2CAP socket
> > > > interface's connect() system call. I.e. if LE GAP is in peripheral mode
> > > > instead of doing HCI_LE_Create_Connection or just failing with "not
> > > > allowed" a socket connect() would simply trigger directed advertising to
> > > > the device in question and deliver the successful connection in the same
> > > > way as a central role triggered connect would do (unless we time out
> > > > waiting for the remote device to connect). Now that I think of this
> > > > second option it actually sounds quite natural and not so crazy after
> > > > all :)
> > >
> > > There's on problem with this though: we'd still be undirected
> > > connectable between doing mgmt_set_le(peripheral) and issuing the socket
> > > connect(). So maybe we might need to introduce a mgmt_set_le_connectable
> > > command and a "le-connectable" setting after all (that could only be set
> > > in peripheral mode).
> >
> > Why not sending undirected connectable events when there's an active
> > listen()?
>
> But we always have that, don't we? (the GATT server socket). Or are you
> saying that bluetoothd could close its GATT server socket before
> switching to peripheral mode and that would ensure that the kernel
> doesn't enable connectable advertising?
Right now bluetoothd always has a listen() active, yes. But remember
that that listen() was added only to help testing, in the case that
BlueZ always initiates connections that listen() is not needed.
What I am thinking is having more control about when to advertise, for
example, each profile that needs the peripheral role would increase the
reference of a listener, when all the references are dropped I stop
advertising.
>
> Johan
Cheers,
--
Vinicius
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox