Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH] Fix starting security procedures when not needed
From: Luiz Augusto von Dentz @ 2011-05-10 10:21 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1304984994-14114-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Vinicius,

On Tue, May 10, 2011 at 2:49 AM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> The default value of sec_level when setting *any* option
> using bt_io_set() was BT_SECURITY_MEDIUM. This was causing
> the security procedure being started in some situations that
> it should not.
> ---
>  btio/btio.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/btio/btio.c b/btio/btio.c
> index a3cf38a..df028a6 100644
> --- a/btio/btio.c
> +++ b/btio/btio.c
> @@ -659,7 +659,6 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
>        /* Set defaults */
>        opts->defer = DEFAULT_DEFER_TIMEOUT;
>        opts->master = -1;
> -       opts->sec_level = BT_IO_SEC_MEDIUM;
>        opts->mode = L2CAP_MODE_BASIC;
>        opts->flushable = -1;

I believe this was on purpose so that if you want another security
level you need to force it when using BtIO, this could be set in the
kernel by default but since it already uses LOW that could break some
applications.


-- 
Luiz Augusto von Dentz
Computer Engineer

^ permalink raw reply

* [PATCH] Adjust SPARQL queries to the changes in call history
From: Slawomir Bochenski @ 2011-05-10  8:48 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Slawomir Bochenski

Currently nmo:Call resources put to the Tracker by commhistory do not use
the same nco:PhoneNumber as the one bound to the nco:PersonContact. This
patch introduces matching contacts by actual phone number, thus returning
proper contact data regardless of this commhistory change.
---
 plugins/phonebook-tracker.c |   74 ++++++++++++++++++++++++++++++------------
 1 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index d72c04e..1b2cec2 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -231,7 +231,7 @@
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
+	"?_ncontact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_ncontact ; "					\
 	"nmo:isAnswered false ;"					\
@@ -239,9 +239,11 @@
 	"?_contact a nco:PersonContact . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . "				\
 "} UNION { "								\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_number . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_unb_contact ; "					\
 	"nmo:isAnswered false ;"					\
@@ -250,7 +252,9 @@
 	"nco:hasPhoneNumber ?_number . } "				\
 	"OPTIONAL {?_contact a nco:PersonContact ; "			\
 	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number. } "			\
+	"?_role nco:hasPhoneNumber ?_number. "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . }"				\
 	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
 "} "									\
 "} "									\
@@ -288,7 +292,9 @@
 		"nmo:isAnswered false ."				\
 		"?c a nco:PersonContact . "				\
 		"?c nco:hasAffiliation ?a . "				\
-		"?a nco:hasPhoneNumber ?h . "				\
+		"?a nco:hasPhoneNumber ?no . "				\
+		"?h maemo:localPhoneNumber ?num . "				\
+		"?no maemo:localPhoneNumber ?num . "				\
 	"} "								\
 	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
 
@@ -368,7 +374,7 @@
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
+	"?_ncontact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_ncontact ; "					\
 	"nmo:isAnswered true ;"						\
@@ -376,9 +382,11 @@
 	"?_contact a nco:PersonContact . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
 "} UNION { "								\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_number . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_unb_contact ; "					\
 	"nmo:isAnswered true ;"						\
@@ -387,7 +395,9 @@
 	"nco:hasPhoneNumber ?_number . } "				\
 	"OPTIONAL {?_contact a nco:PersonContact ; "			\
 	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number. } "			\
+	"?_role nco:hasPhoneNumber ?_number. "				\
+	"?_number maemo:localPhoneNumber ?_realnum ."				\
+	"?_other maemo:localPhoneNumber ?_realnum . }"				\
 	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
 "} "									\
 "} "\
@@ -424,7 +434,9 @@
 		"nmo:isAnswered true ."					\
 		"?c a nco:PersonContact . "				\
 		"?c nco:hasAffiliation ?a . "				\
-		"?a nco:hasPhoneNumber ?h . "				\
+		"?a nco:hasPhoneNumber ?no . "				\
+		"?h maemo:localPhoneNumber ?num . "				\
+		"?no maemo:localPhoneNumber ?num . "				\
 	"}"								\
 	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
 
@@ -503,16 +515,18 @@
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
+	"?_ncontact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:to ?_ncontact ; "						\
 	"nmo:isSent true . "						\
 	"?_contact a nco:PersonContact . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . "				\
 "} UNION { "								\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_number . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:to ?_unb_contact ; "					\
 	"nmo:isSent true . "						\
@@ -520,7 +534,9 @@
 	"nco:hasPhoneNumber ?_number . } "				\
 	"OPTIONAL {?_contact a nco:PersonContact ; "			\
 	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number. } "			\
+	"?_role nco:hasPhoneNumber ?_number. "				\
+	"?_other maemo:localPhoneNumber ?_realnum ."				\
+	"?_number maemo:localPhoneNumber ?_realnum . }"				\
 	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
 "} "									\
 "} "									\
@@ -554,7 +570,9 @@
 		"nmo:isSent true . "					\
 		"?c a nco:PersonContact . "				\
 		"?c nco:hasAffiliation ?a . "				\
-		"?a nco:hasPhoneNumber ?h . "				\
+		"?a nco:hasPhoneNumber ?no . "				\
+		"?h maemo:localPhoneNumber ?num . "				\
+		"?no maemo:localPhoneNumber ?num . "				\
 	"}"								\
 	"} GROUP BY ?call ORDER BY DESC(nmo:sentDate(?call))"
 
@@ -633,16 +651,18 @@
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
+	"?_ncontact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:to ?_ncontact ; "						\
 	"nmo:isSent true . "						\
 	"?_contact a nco:PersonContact . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . "				\
 "} UNION { "								\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_number . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:to ?_unb_contact ; "					\
 	"nmo:isSent true . "						\
@@ -650,7 +670,9 @@
 	"nco:hasPhoneNumber ?_number . } "				\
 	"OPTIONAL {?_contact a nco:PersonContact ; "			\
 	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number. } "			\
+	"?_role nco:hasPhoneNumber ?_number. "				\
+	"?_other maemo:localPhoneNumber ?_realnum ."				\
+	"?_number maemo:localPhoneNumber ?_realnum . }"				\
 	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
@@ -663,16 +685,18 @@
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
+	"?_ncontact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_ncontact ; "					\
 	"nmo:isSent false . "						\
 	"?_contact a nco:PersonContact . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
+	"?_other maemo:localPhoneNumber ?_realnum . "				\
+	"?_number maemo:localPhoneNumber ?_realnum . "				\
 "} UNION { "								\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_number . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
 	"?_call a nmo:Call ; "						\
 	"nmo:from ?_unb_contact ; "					\
 	"nmo:isSent false . "						\
@@ -680,7 +704,9 @@
 	"nco:hasPhoneNumber ?_number . } "				\
 	"OPTIONAL {?_contact a nco:PersonContact ; "			\
 	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number. } "			\
+	"?_role nco:hasPhoneNumber ?_number. "				\
+	"?_other maemo:localPhoneNumber ?_realnum ."				\
+	"?_number maemo:localPhoneNumber ?_realnum . }"				\
 	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
 "} "									\
 "} "									\
@@ -713,7 +739,9 @@
 			"nmo:isSent true . "				\
 			"?c a nco:PersonContact . "			\
 			"?c nco:hasAffiliation ?a . "			\
-			"?a nco:hasPhoneNumber ?h . "			\
+			"?a nco:hasPhoneNumber ?no . "			\
+			"?h maemo:localPhoneNumber ?num . "			\
+			"?no maemo:localPhoneNumber ?num . "			\
 		"}UNION {"						\
 			"?c a nco:Contact . "				\
 			"?c nco:hasPhoneNumber ?h . "			\
@@ -736,7 +764,9 @@
 			"nmo:isSent false . "				\
 			"?c a nco:PersonContact . "			\
 			"?c nco:hasAffiliation ?a . "			\
-			"?a nco:hasPhoneNumber ?h . "			\
+			"?a nco:hasPhoneNumber ?no . "			\
+			"?h maemo:localPhoneNumber ?num . "			\
+			"?no maemo:localPhoneNumber ?num . "			\
 		"}"							\
 	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
 
@@ -887,7 +917,9 @@
 		"nmo:isAnswered false ."				\
 		"?c a nco:PersonContact . "				\
 		"?c nco:hasAffiliation ?a . "				\
-		"?a nco:hasPhoneNumber ?h . "				\
+		"?a nco:hasPhoneNumber ?no . "				\
+		"?h maemo:localPhoneNumber ?num . "				\
+		"?no maemo:localPhoneNumber ?num . "				\
 	"} "								\
 	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call)) "	\
 	"LIMIT 40"
-- 
1.7.4.1


^ permalink raw reply related

* Re: HDP: Any Bluez Sample C code for Health sink?
From: Phaneeth Kumar @ 2011-05-10  1:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <53036801-BEF0-4088-BE8B-BFE7A1C6F1AA@signove.com>



> > Hi All,

> > 
> > I am new to the whole DBus way of accessing API and the  Bluez  Health API. I 
>am 
>
> > trying to build a generic HDP sink in C and I am   totally lost.
> > All the sample codes that I find are in Python and  scripting isn't really an 
>
> > option for this application.
> > Is there  any sample C code available that uses Bluez in general and HDP 
> >  interface in Bluez in particular?
> 
> It is not a textbook example, but  Antidote's HDP plug-in does use HDP D-Bus
> API and it is written in  C:
> 
> http://gitorious.org/antidote/antidote/blobs/master/src/communication/plugin
> 
> bluez/plugin_bluez.c  and other sources in the same folder.

Thanks José and Elvis.


Regards,
Phaneeth


^ permalink raw reply

* [PATCH] Fix starting security procedures when not needed
From: Vinicius Costa Gomes @ 2011-05-09 23:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

The default value of sec_level when setting *any* option
using bt_io_set() was BT_SECURITY_MEDIUM. This was causing
the security procedure being started in some situations that
it should not.
---
 btio/btio.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/btio/btio.c b/btio/btio.c
index a3cf38a..df028a6 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -659,7 +659,6 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 	/* Set defaults */
 	opts->defer = DEFAULT_DEFER_TIMEOUT;
 	opts->master = -1;
-	opts->sec_level = BT_IO_SEC_MEDIUM;
 	opts->mode = L2CAP_MODE_BASIC;
 	opts->flushable = -1;
 
-- 
1.7.4.3


^ permalink raw reply related

* Re: [PATCH] Fix starting the security procedure when setting the MTU
From: Vinicius Costa Gomes @ 2011-05-09 23:48 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1304963788-2926-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Johan,

On 14:56 Mon 09 May, Vinicius Costa Gomes wrote:
> The default security level of btio is BT_IO_SEC_MEDIUM, and for
> LE links this would cause encryption to be started. So, we set the
> security level to LOW (a no-op) and the MTU to the desired value.
> ---
>  attrib/gattrib.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 

Please ignore this patch. As discussed on IRC, I will send a patch
that fixes the actual problem.


Cheers,
-- 
Vinicius

^ permalink raw reply

* [PATCH] btusb: Device ids for ath3k on Pegatron Lucid tablets
From: Andy Ross @ 2011-05-09 23:11 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan, linux-bluetooth

MeeGo has been carrying this patch for a while, and I'd forgotten
about it until it accidentally got dropped.  I think I remember
finding the IDs on a mailing list, but as of now they're still
unmerged and I can't find the original source.  Device IDs for ath3k
bluetooth on the WeTab/ExoPC.

Andy

>From ff4a4cdbbb847901bd5e64e2510f2c0cda11497b Mon Sep 17 00:00:00 2001
From: Andy Ross <andy.ross@windriver.com>
Date: Mon, 9 May 2011 15:59:49 -0700
Subject: [PATCH] btusb: Device ids for ath3k on Pegatron Lucid tablets

New ath3k device IDs used on the Pegatron Lucid (ExoPC and WeTab) units.

Signed-off-by: Andy Ross <andy.ross@windriver.com>
---
 drivers/bluetooth/ath3k.c |    1 +
 drivers/bluetooth/btusb.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6dcd55a..c719935 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -38,6 +38,7 @@ static struct usb_device_id ath3k_table[] = {

 	/* Atheros AR3011 with sflash firmware*/
 	{ USB_DEVICE(0x0CF3, 0x3002) },
+	{ USB_DEVICE(0x13d3, 0x3304) },

 	/* Atheros AR9285 Malbec with sflash firmware */
 	{ USB_DEVICE(0x03F0, 0x311D) },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 700a384..1d92c65 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -101,6 +101,7 @@ static struct usb_device_id blacklist_table[] = {

 	/* Atheros 3011 with sflash firmware */
 	{ USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
+	{ USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },

 	/* Atheros AR9285 Malbec with sflash firmware */
 	{ USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
-- 
1.7.1

^ permalink raw reply related

* Re: BT 3.0 HS Support in BlueZ
From: Gustavo F. Padovan @ 2011-05-09 22:52 UTC (permalink / raw)
  To: Mat Martineau; +Cc: Arun Kumar SINGH, Anurag Gupta, pkrystad, linux-bluetooth
In-Reply-To: <alpine.DEB.2.00.1105051548540.4213@localhost6.localdomain6>

Hi Mat,

* Mat Martineau <mathewm@codeaurora.org> [2011-05-05 16:27:17 -0700]:

> 
> On Thu, 5 May 2011, Gustavo F. Padovan wrote:
> 
> > Hi Arun,
> >
> > * Arun Kumar SINGH <arunkr.singh@stericsson.com> [2011-05-05 09:26:58 +0200]:
> >
> >> Hi Gustavo,
> >>
> >>>> Does anybody know if
> >>> bluetooth 3.0 HS spec is
> >>> supported in BlueZ?
> >>>> Is AMP supported in BlueZ?
> >>>
> >>> There is two different
> >>> implementations, one by
> >>> Atheros and another by QuIC.
> >>> Both never reach upstream,
> >>> if you look to the list logs
> >>> you will find them.
> >>
> >>
> >> Any hopes of getting this unified version upstream anytime in near future? I guess this has been on the cards for some time now given that merge process started last august.
> >
> > I'm interested in have this on the stack but it doesn't depend on me.
> > Patches for this are not arriving to the mailing list. Actually we had no real
> > feedback for AMP since the meeting in Boston.
> 
> Gustavo, Arun:
> 
> We do still plan to upstream our Bluetooth 3.0 + HS implementation.  I 
> will start work on upstreaming later this month, but I need to merge 
> in all of the recent L2CAP refactoring changes.
> 
> Also note that Qualcomm and Atheros have announced a merger.
> 
> You can find the kernel AMP implementation in the codeaurora.org 
> Android git trees:
> 
> git://codeaurora.org/kernel/msm.git
> https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git;a=summary
> 
> The android-msm-2.6.35 and msm-2.6.38 branches contain the AMP code.
> 
> 
> Please let me know if you have any other questions about AMP.

Isn't Extended Flow Specification a required feature for AMP? I haven't seen
it in your implementation.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* [PATCH] Fix starting the security procedure when setting the MTU
From: Vinicius Costa Gomes @ 2011-05-09 17:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

The default security level of btio is BT_IO_SEC_MEDIUM, and for
LE links this would cause encryption to be started. So, we set the
security level to LOW (a no-op) and the MTU to the desired value.
---
 attrib/gattrib.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 8c15e52..55ec645 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -540,6 +540,7 @@ gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
 
 	if (!bt_io_set(attrib->io, BT_IO_L2CAP, NULL,
 			BT_IO_OPT_OMTU, mtu,
+			BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
 			BT_IO_OPT_INVALID))
 		return FALSE;
 
-- 
1.7.4.3


^ permalink raw reply related

* [PATCH] Fix a crash when creating a device from storage
From: Vinicius Costa Gomes @ 2011-05-09 17:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

The list "services" is just a list of the object paths of the
registered services that a device has. When we want to store
the primary services information we need to store the "primaries"
list, that contain all the primary services information.
---
 src/device.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/device.c b/src/device.c
index b0a6542..9b8591b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1567,7 +1567,7 @@ static void store_services(struct btd_device *device)
 {
 	struct btd_adapter *adapter = device->adapter;
 	bdaddr_t dba, sba;
-	char *str = primary_list_to_string(device->services);
+	char *str = primary_list_to_string(device->primaries);
 
 	adapter_get_address(adapter, &sba);
 	device_get_address(device, &dba);
-- 
1.7.4.3


^ permalink raw reply related

* Re: [oss-security] Bluetooth: l2cap and rfcomm: fix 1 byte infoleak to userspace.
From: Vasiliy Kulikov @ 2011-05-09 14:31 UTC (permalink / raw)
  To: Filip Palian
  Cc: Marcel Holtmann, Gustavo F. Padovan, David S. Miller,
	linux-bluetooth, netdev, linux-kernel, security
In-Reply-To: <BANLkTik7WyQ977-+8XapTgBrVRMyexyHKg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

On Sun, May 08, 2011 at 21:57 +0200, Filip Palian wrote:
> Structures "l2cap_conninfo" and "rfcomm_conninfo" have one padding
> byte each. This byte in "cinfo" is copied to userspace uninitialized.

Your mail client mangles the patch, it should contain original
identation tabs, not spaces.  Please see Documentation/email-clients.txt.

> patch no.1:

Don't send 2 patches as one email.  Either send 2 email or merge them
into one patch (if they are similar changes).  You'll ease maintainers'
work.

> Found by Marek Kroemeke and Filip Palian.

Please see Documentation/SubmittingPatches, chapter 12 to find out how
to sign the patch.

And please don't crosspost to oss-security and LKML - send a separate
email to o-s with a short description of a bug and a link to the LKML
thread.  LKML thread is a place to argue and discuss the solution, but
o-s subscribers are probably not interested in such a discussion.

Thanks,

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: HDP: Any Bluez Sample C code for Health sink?
From: Elvis Pfützenreuter @ 2011-05-09 12:11 UTC (permalink / raw)
  To: Phaneeth Kumar; +Cc: linux-bluetooth
In-Reply-To: <492322.54247.qm@web111608.mail.gq1.yahoo.com>

On 8 May 2011, at 20:56 , Phaneeth Kumar wrote:

> Hi All,
> 
> I am new to the whole DBus way of accessing API and the  Bluez Health API. I am 
> trying to build a generic HDP sink in C and I am  totally lost.
> All the sample codes that I find are in Python and scripting isn't really an 
> option for this application.
> Is there any sample C code available that uses Bluez in general and HDP 
> interface in Bluez in particular?

It is not a textbook example, but Antidote's HDP plug-in does use HDP D-Bus
API and it is written in C:

http://gitorious.org/antidote/antidote/blobs/master/src/communication/plugin

bluez/plugin_bluez.c and other sources in the same folder.

^ permalink raw reply

* RE: [PATCH v5] staging: Add ST-Ericsson CG2900 driver
From: Par-Gunnar HJALMDAHL @ 2011-05-09 12:07 UTC (permalink / raw)
  To: Greg KH
  Cc: Greg Kroah-Hartman, devel@driverdev.osuosl.org, Linus Walleij,
	Mathieu Poirier, Linus WALLEIJ, Arnd Bergmann, Vitaly Wool,
	Marcel Holtmann, linux-kernel@vger.kernel.org, Lukasz Rymanowski,
	linux-bluetooth@vger.kernel.org, Pavan Savoy, Lee Jones, Alan Cox,
	Par-Gunnar Hjalmdahl
In-Reply-To: <20110503174937.GA18622@kroah.com>

> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: den 3 maj 2011 19:50
>=20
> What changed in this version?  It still doesn't apply properly to the
> linux-next tree, which shows me that I don't think anything really
> changed here.
>=20

What I changed from v4 was in particular to adapt to changes to mfd.
The mfd device data name had been changed from platform_data (plus length)
to mfd_data. This was modified cg2900_chip.c and stlc2690.c.
In connection to this I also modified so we used the function mfd_get_data
to retrieve the platform data.
There had also been one parameter removed in the call to tty->ops->tiocmget
so I had to modify the call in hci_ldisc as well.

> Can you rediff it so it properly applies (i.e. why are you adding your
> driver to the middle of drivers/staging/Makefile and not at the end
> which is where it properly belongs?) and resend it?

I will do another try, but I honestly do not know why it doesn't apply.
The reason for the placement in the makefile I do not remember at the
moment, probably just a simple mistake from my part. I agree that I
should have placed it last in the file.

Thanks,
/P-G

^ permalink raw reply

* [PATCH 3/3] client: add support for reusing session for the same client
From: Luiz Augusto von Dentz @ 2011-05-09  8:21 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1304929298-1586-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

If the a client owning a session attempt to send a new file just reuse
the same session instead of trying to connect again.
---
 client/session.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 client/session.h |    1 +
 2 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/client/session.c b/client/session.c
index e8915cf..266d00c 100644
--- a/client/session.c
+++ b/client/session.c
@@ -87,6 +87,8 @@ struct agent_data {
 	struct pending_data *pending;
 };
 
+static GSList *sessions = NULL;
+
 static void session_prepare_put(struct session_data *session, GError *err,
 								void *data);
 static void session_terminate_transfer(struct session_data *session,
@@ -199,8 +201,11 @@ static void session_free(struct session_data *session)
 		dbus_connection_unref(session->conn);
 	}
 
+	sessions = g_slist_remove(sessions, session);
+
 	g_free(session->callback);
 	g_free(session->path);
+	g_free(session->service);
 	g_free(session->owner);
 	g_free(session);
 }
@@ -245,6 +250,8 @@ static void rfcomm_callback(GIOChannel *io, GError *err, gpointer user_data)
 
 	session->obex = obex;
 
+	sessions = g_slist_prepend(sessions, session);
+
 done:
 	callback->func(callback->session, err, callback->data);
 
@@ -446,6 +453,19 @@ static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
 	return sdp;
 }
 
+static gboolean connection_complete(gpointer data)
+{
+	struct callback_data *cb = data;
+
+	cb->func(cb->session, 0, cb->data);
+
+	session_unref(cb->session);
+
+	g_free(cb);
+
+	return FALSE;
+}
+
 static void owner_disconnected(DBusConnection *connection, void *user_data)
 {
 	struct session_data *session = user_data;
@@ -474,6 +494,43 @@ int session_set_owner(struct session_data *session, const char *name,
 	return 0;
 }
 
+static struct session_data *session_find(const char *source,
+						const char *destination,
+						const char *service,
+						uint8_t channel,
+						const char *owner)
+{
+	GSList *l;
+
+	for (l = sessions; l; l = l->next) {
+		struct session_data *session = l->data;
+		bdaddr_t adr;
+
+		if (source) {
+			str2ba(source, &adr);
+			if (bacmp(&session->src, &adr))
+				continue;
+		}
+
+		str2ba(destination, &adr);
+		if (bacmp(&session->dst, &adr))
+			continue;
+
+		if (g_strcmp0(service, session->service))
+			continue;
+
+		if (channel && session->channel != channel)
+			continue;
+
+		if (g_strcmp0(owner, session->owner))
+			continue;
+
+		return session;
+	}
+
+	return NULL;
+}
+
 struct session_data *session_create(const char *source,
 						const char *destination,
 						const char *service,
@@ -489,6 +546,12 @@ struct session_data *session_create(const char *source,
 	if (destination == NULL)
 		return NULL;
 
+	session = session_find(source, destination, service, channel, owner);
+	if (session) {
+		session_ref(session);
+		goto proceed;
+	}
+
 	session = g_try_malloc0(sizeof(*session));
 	if (session == NULL)
 		return NULL;
@@ -508,6 +571,7 @@ struct session_data *session_create(const char *source,
 		str2ba(source, &session->src);
 
 	str2ba(destination, &session->dst);
+	session->service = g_strdup(service);
 
 	if (!g_ascii_strncasecmp(service, "OPP", 3)) {
 		sdp_uuid16_create(&session->uuid, OBEX_OBJPUSH_SVCLASS_ID);
@@ -529,9 +593,10 @@ struct session_data *session_create(const char *source,
 		return NULL;
 	}
 
+proceed:
 	callback = g_try_malloc0(sizeof(*callback));
 	if (callback == NULL) {
-		session_free(session);
+		session_unref(session);
 		return NULL;
 	}
 
@@ -539,7 +604,10 @@ struct session_data *session_create(const char *source,
 	callback->func = function;
 	callback->data = user_data;
 
-	if (session->channel > 0) {
+	if (session->obex) {
+		g_idle_add(connection_complete, callback);
+		err = 0;
+	} else if (session->channel > 0) {
 		session->io = rfcomm_connect(&session->src, &session->dst,
 							session->channel,
 							rfcomm_callback,
@@ -552,7 +620,7 @@ struct session_data *session_create(const char *source,
 	}
 
 	if (err < 0) {
-		session_free(session);
+		session_unref(session);
 		g_free(callback);
 		return NULL;
 	}
diff --git a/client/session.h b/client/session.h
index eee439f..6f8a434 100644
--- a/client/session.h
+++ b/client/session.h
@@ -36,6 +36,7 @@ struct session_data {
 	bdaddr_t src;
 	bdaddr_t dst;
 	uint8_t channel;
+	char *service;		/* Service friendly name */
 	const char *target;	/* OBEX Target UUID */
 	int target_len;
 	uuid_t uuid;		/* Bluetooth Service Class */
-- 
1.7.1


^ permalink raw reply related

* [PATCH 2/3] client: fix not canceling connection request if client exit bus
From: Luiz Augusto von Dentz @ 2011-05-09  8:21 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1304929298-1586-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

There is no point on proceeding with sdp/rfcomm connections if client
exit the bus.
---
 client/main.c    |   23 +++++-----
 client/session.c |  121 ++++++++++++++++++++++++++++++++++-------------------
 client/session.h |    9 +++-
 3 files changed, 95 insertions(+), 58 deletions(-)

diff --git a/client/main.c b/client/main.c
index 20d56d2..478181c 100644
--- a/client/main.c
+++ b/client/main.c
@@ -86,6 +86,7 @@ static void create_callback(struct session_data *session, GError *err,
 	if (session->target != NULL) {
 		session_register(session);
 		session_set_owner(session, data->sender, owner_exit);
+
 		g_dbus_send_reply(data->connection, data->message,
 				DBUS_TYPE_OBJECT_PATH, &session->path,
 				DBUS_TYPE_INVALID);
@@ -165,6 +166,7 @@ static DBusMessage *send_files(DBusConnection *connection,
 	GPtrArray *files;
 	struct send_data *data;
 	const char *agent, *source = NULL, *dest = NULL, *target = NULL;
+	const char *sender;
 	uint8_t channel = 0;
 
 	dbus_message_iter_init(message, &iter);
@@ -201,6 +203,8 @@ static DBusMessage *send_files(DBusConnection *connection,
 				"org.openobex.Error.InvalidArguments", NULL);
 	}
 
+	sender = dbus_message_get_sender(message);
+
 	data = g_try_malloc0(sizeof(*data));
 	if (data == NULL) {
 		g_ptr_array_free(files, TRUE);
@@ -210,12 +214,12 @@ static DBusMessage *send_files(DBusConnection *connection,
 
 	data->connection = dbus_connection_ref(connection);
 	data->message = dbus_message_ref(message);
-	data->sender = g_strdup(dbus_message_get_sender(message));
+	data->sender = g_strdup(sender);
 	data->agent = g_strdup(agent);
 	data->files = files;
 
-	session = session_create(source, dest, "OPP", channel, create_callback,
-				data);
+	session = session_create(source, dest, "OPP", channel, sender,
+							create_callback, data);
 	if (session != NULL) {
 		sessions = g_slist_append(sessions, session);
 		return NULL;
@@ -269,8 +273,6 @@ static void pull_session_callback(struct session_data *session,
 		goto done;
 	}
 
-	session_set_owner(session, data->sender, owner_exit);
-
 	session_pull(session, "text/x-vcard", data->filename,
 						pull_complete_callback, data);
 
@@ -320,7 +322,7 @@ static DBusMessage *pull_business_card(DBusConnection *connection,
 	data->sender = g_strdup(dbus_message_get_sender(message));
 	data->filename = g_strdup(name);
 
-	session = session_create(source, dest, "OPP", channel,
+	session = session_create(source, dest, "OPP", channel, data->sender,
 					pull_session_callback, data);
 	if (session != NULL) {
 		sessions = g_slist_append(sessions, session);
@@ -382,8 +384,8 @@ static DBusMessage *create_session(DBusConnection *connection,
 	data->message = dbus_message_ref(message);
 	data->sender = g_strdup(dbus_message_get_sender(message));
 
-	session = session_create(source, dest, target, channel,
-					create_callback, data);
+	session = session_create(source, dest, target, channel, data->sender,
+							create_callback, data);
 	if (session != NULL) {
 		sessions = g_slist_append(sessions, session);
 		return NULL;
@@ -471,7 +473,6 @@ static void capability_session_callback(struct session_data *session,
 		goto done;
 	}
 
-	session_set_owner(session, data->sender, owner_exit);
 	session_pull(session, "x-obex/capability", NULL,
 				capabilities_complete_callback, data);
 
@@ -513,8 +514,8 @@ static DBusMessage *get_capabilities(DBusConnection *connection,
 	if (!target)
 		target = "OPP";
 
-	session = session_create(source, dest, target, channel,
-				capability_session_callback, data);
+	session = session_create(source, dest, target, channel, data->sender,
+					capability_session_callback, data);
 	if (session != NULL) {
 		sessions = g_slist_append(sessions, session);
 		return NULL;
diff --git a/client/session.c b/client/session.c
index ceda3f4..e8915cf 100644
--- a/client/session.c
+++ b/client/session.c
@@ -169,6 +169,9 @@ static void session_unregistered(struct session_data *session)
 					SESSION_INTERFACE);
 
 	DBG("Session(%p) unregistered %s", session, session->path);
+
+	g_free(session->path);
+	session->path = NULL;
 }
 
 static void session_free(struct session_data *session)
@@ -223,6 +226,8 @@ static void rfcomm_callback(GIOChannel *io, GError *err, gpointer user_data)
 	GwObex *obex;
 	int fd;
 
+	DBG("");
+
 	if (err != NULL) {
 		error("%s", err->message);
 		goto done;
@@ -255,6 +260,8 @@ static GIOChannel *rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
 	GIOChannel *io;
 	GError *err = NULL;
 
+	DBG("");
+
 	io = bt_io_connect(BT_IO_RFCOMM, function, user_data, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_DEST_BDADDR, dst,
@@ -273,6 +280,7 @@ static void search_callback(uint8_t type, uint16_t status,
 			uint8_t *rsp, size_t size, void *user_data)
 {
 	struct callback_data *callback = user_data;
+	struct session_data *session = callback->session;
 	unsigned int scanned, bytesleft = size;
 	int seqlen = 0;
 	uint8_t dataType, channel = 0;
@@ -325,23 +333,26 @@ static void search_callback(uint8_t type, uint16_t status,
 	if (channel == 0)
 		goto failed;
 
-	callback->session->channel = channel;
+	session->channel = channel;
 
-	callback->session->io = rfcomm_connect(&callback->session->src,
-						&callback->session->dst,
-						channel, rfcomm_callback,
-						callback);
-	if (callback->session->io != NULL) {
+	g_io_channel_set_close_on_unref(session->io, FALSE);
+	g_io_channel_unref(session->io);
+
+	session->io = rfcomm_connect(&session->src, &session->dst, channel,
+					rfcomm_callback, callback);
+	if (session->io != NULL) {
 		sdp_close(callback->sdp);
 		return;
 	}
 
 failed:
-	sdp_close(callback->sdp);
+	g_io_channel_shutdown(session->io, TRUE, NULL);
+	g_io_channel_unref(session->io);
+	session->io = NULL;
 
 	g_set_error(&gerr, OBEX_IO_ERROR, -EIO,
 					"Unable to find service record");
-	callback->func(callback->session, gerr, callback->data);
+	callback->func(session, gerr, callback->data);
 	g_clear_error(&gerr);
 
 	session_unref(callback->session);
@@ -366,6 +377,7 @@ static gboolean service_callback(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
 	struct callback_data *callback = user_data;
+	struct session_data *session = callback->session;
 	sdp_list_t *search, *attrid;
 	uint32_t range = 0x0000ffff;
 	GError *gerr = NULL;
@@ -395,7 +407,9 @@ static gboolean service_callback(GIOChannel *io, GIOCondition cond,
 	return FALSE;
 
 failed:
-	sdp_close(callback->sdp);
+	g_io_channel_shutdown(session->io, TRUE, NULL);
+	g_io_channel_unref(session->io);
+	session->io = NULL;
 
 	g_set_error(&gerr, OBEX_IO_ERROR, -EIO,
 					"Unable to find service record");
@@ -410,6 +424,7 @@ failed:
 static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
 					GIOFunc function, gpointer user_data)
 {
+	struct callback_data *cb = user_data;
 	sdp_session_t *sdp;
 	GIOChannel *io;
 
@@ -426,15 +441,46 @@ static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
 	g_io_add_watch(io, G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
 							function, user_data);
 
-	g_io_channel_unref(io);
+	cb->session->io = io;
 
 	return sdp;
 }
 
+static void owner_disconnected(DBusConnection *connection, void *user_data)
+{
+	struct session_data *session = user_data;
+
+	DBG("");
+
+	session_shutdown(session);
+}
+
+int session_set_owner(struct session_data *session, const char *name,
+			GDBusWatchFunction func)
+{
+	if (session == NULL)
+		return -EINVAL;
+
+	if (session->watch)
+		g_dbus_remove_watch(session->conn, session->watch);
+
+	session->watch = g_dbus_add_disconnect_watch(session->conn, name, func,
+							session, NULL);
+	if (session->watch == 0)
+		return -EINVAL;
+
+	session->owner = g_strdup(name);
+
+	return 0;
+}
+
 struct session_data *session_create(const char *source,
-			const char *destination, const char *target,
-			uint8_t channel, session_callback_t function,
-			void *user_data)
+						const char *destination,
+						const char *service,
+						uint8_t channel,
+						const char *owner,
+						session_callback_t function,
+						void *user_data)
 {
 	struct session_data *session;
 	struct callback_data *callback;
@@ -463,21 +509,21 @@ struct session_data *session_create(const char *source,
 
 	str2ba(destination, &session->dst);
 
-	if (!g_ascii_strncasecmp(target, "OPP", 3)) {
+	if (!g_ascii_strncasecmp(service, "OPP", 3)) {
 		sdp_uuid16_create(&session->uuid, OBEX_OBJPUSH_SVCLASS_ID);
-	} else if (!g_ascii_strncasecmp(target, "FTP", 3)) {
+	} else if (!g_ascii_strncasecmp(service, "FTP", 3)) {
 		sdp_uuid16_create(&session->uuid, OBEX_FILETRANS_SVCLASS_ID);
 		session->target = OBEX_FTP_UUID;
 		session->target_len = OBEX_FTP_UUID_LEN;
-	} else if (!g_ascii_strncasecmp(target, "PBAP", 4)) {
+	} else if (!g_ascii_strncasecmp(service, "PBAP", 4)) {
 		sdp_uuid16_create(&session->uuid, PBAP_PSE_SVCLASS_ID);
 		session->target = OBEX_PBAP_UUID;
 		session->target_len = OBEX_PBAP_UUID_LEN;
-	} else if (!g_ascii_strncasecmp(target, "SYNC", 4)) {
+	} else if (!g_ascii_strncasecmp(service, "SYNC", 4)) {
 		sdp_uuid16_create(&session->uuid, IRMC_SYNC_SVCLASS_ID);
 		session->target = OBEX_SYNC_UUID;
 		session->target_len = OBEX_SYNC_UUID_LEN;
-	} else if (!g_ascii_strncasecmp(target, "PCSUITE", 7)) {
+	} else if (!g_ascii_strncasecmp(service, "PCSUITE", 7)) {
 		sdp_uuid128_create(&session->uuid, pcsuite_uuid);
 	} else {
 		return NULL;
@@ -511,6 +557,9 @@ struct session_data *session_create(const char *source,
 		return NULL;
 	}
 
+	if (owner)
+		session_set_owner(session, owner, owner_disconnected);
+
 	return session;
 }
 
@@ -523,6 +572,16 @@ void session_shutdown(struct session_data *session)
 	/* Unregister any pending transfer */
 	g_slist_foreach(session->pending, (GFunc) transfer_unregister, NULL);
 
+	/* Unregister interfaces */
+	if (session->path)
+		session_unregistered(session);
+
+	/* Shutdown io */
+	if (session->io) {
+		int fd = g_io_channel_unix_get_fd(session->io);
+		shutdown(fd, SHUT_RDWR);
+	}
+
 	session_unref(session);
 }
 
@@ -586,13 +645,6 @@ static DBusMessage *release_agent(DBusConnection *connection,
 	return dbus_message_new_method_return(message);
 }
 
-static void owner_disconnected(DBusConnection *connection, void *user_data)
-{
-	struct session_data *session = user_data;
-
-	session_shutdown(session);
-}
-
 static void append_entry(DBusMessageIter *dict,
 				const char *key, int type, void *val)
 {
@@ -1466,25 +1518,6 @@ const char *session_get_agent(struct session_data *session)
 	return agent->name;
 }
 
-int session_set_owner(struct session_data *session, const char *name,
-			GDBusWatchFunction func)
-{
-	if (session == NULL)
-		return -EINVAL;
-
-	if (session->watch != 0)
-		return -EALREADY;
-
-	session->watch = g_dbus_add_disconnect_watch(session->conn, name, func,
-							session, NULL);
-	if (session->watch == 0)
-		return -EINVAL;
-
-	session->owner = g_strdup(name);
-
-	return 0;
-}
-
 const char *session_get_owner(struct session_data *session)
 {
 	if (session == NULL)
diff --git a/client/session.h b/client/session.h
index 546849e..eee439f 100644
--- a/client/session.h
+++ b/client/session.h
@@ -56,9 +56,12 @@ typedef void (*session_callback_t) (struct session_data *session,
 					GError *err, void *user_data);
 
 struct session_data *session_create(const char *source,
-			const char *destination, const char *target,
-			uint8_t channel, session_callback_t function,
-			void *user_data);
+						const char *destination,
+						const char *service,
+						uint8_t channel,
+						const char *owner,
+						session_callback_t function,
+						void *user_data);
 
 struct session_data *session_ref(struct session_data *session);
 void session_unref(struct session_data *session);
-- 
1.7.1


^ permalink raw reply related

* [PATCH 1/3] client: remove unused variable
From: Luiz Augusto von Dentz @ 2011-05-09  8:21 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

---
 client/session.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/client/session.c b/client/session.c
index 88eae8d..ceda3f4 100644
--- a/client/session.c
+++ b/client/session.c
@@ -516,10 +516,7 @@ struct session_data *session_create(const char *source,
 
 void session_shutdown(struct session_data *session)
 {
-	struct transfer_data *transfer;
-
 	DBG("%p", session);
-	transfer = session->pending ? session->pending->data : NULL;
 
 	session_ref(session);
 
-- 
1.7.1


^ permalink raw reply related

* HDP: Any Bluez Sample C code for Health sink?
From: Phaneeth Kumar @ 2011-05-08 23:56 UTC (permalink / raw)
  To: linux-bluetooth

Hi All,

I am new to the whole DBus way of accessing API and the  Bluez Health API. I am 
trying to build a generic HDP sink in C and I am  totally lost.
All the sample codes that I find are in Python and scripting isn't really an 
option for this application.
Is there any sample C code available that uses Bluez in general and HDP 
interface in Bluez in particular?

Thanks for your help!

Phaneeth

^ permalink raw reply

* Bluetooth: l2cap and rfcomm: fix 1 byte infoleak to userspace.
From: Filip Palian @ 2011-05-08 19:57 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan, David S. Miller,
	linux-bluetooth, netdev, linux-kernel
  Cc: security, oss-security

Hi,

Structures "l2cap_conninfo" and "rfcomm_conninfo" have one padding
byte each. This byte in "cinfo" is copied to userspace uninitialized.

patch no.1:
-- cut --
--- a/net/bluetooth/l2cap_sock.c        2011-05-04 03:59:13.000000000 +0100
+++ b/net/bluetooth/l2cap_sock.c        2011-05-08 18:57:20.000000000 +0100
@@ -446,6 +446,7 @@ static int l2cap_sock_getsockopt_old(str
                        break;
                }

+               memset(&cinfo, 0, sizeof(cinfo));
                cinfo.hci_handle = l2cap_pi(sk)->conn->hcon->handle;
                memcpy(cinfo.dev_class, l2cap_pi(sk)->conn->hcon->dev_class, 3);

-- cut --

patch no.2:
-- cut --
--- a/net/bluetooth/rfcomm/sock.c       2011-05-04 03:59:13.000000000 +0100
+++ b/net/bluetooth/rfcomm/sock.c       2011-05-08 19:00:24.000000000 +0100
@@ -787,6 +787,7 @@ static int rfcomm_sock_getsockopt_old(st

                l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk;

+               memset(&cinfo, 0, sizeof(cinfo));
                cinfo.hci_handle = l2cap_pi(l2cap_sk)->conn->hcon->handle;
                memcpy(cinfo.dev_class,
l2cap_pi(l2cap_sk)->conn->hcon->dev_class, 3);
-- cut --

Found by Marek Kroemeke and Filip Palian. Special thanks to Vasiliy
Kulikov for verifying this bug.


Best regards.

^ permalink raw reply

* [PATCH] Fix endian conversion for appparams in pbap client
From: Bartosz Szatkowski @ 2011-05-08 18:00 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bartosz Szatkowski

---
 client/pbap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/client/pbap.c b/client/pbap.c
index 837419c..dee85c8 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -312,6 +312,7 @@ static void read_return_apparam(struct session_data *session,
 			if (hdr->len == PHONEBOOKSIZE_LEN) {
 				guint16 val;
 				memcpy(&val, hdr->val, sizeof(val));
+                                val = get_be16(&val);
 				*phone_book_size = val;
 			}
 			break;
-- 
1.7.5.rc3


^ permalink raw reply related

* Adapter stored link keys
From: Bastien Nocera @ 2011-05-08 14:21 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

Heya,

I updated my KeyOnAdapter property patch, and cooked up a few related
patches.

This is the test I intend on making work:
- pair keyboard
- set KeyOnAdapter value to TRUE
- check that key is indeed on the adapter using the hciconfig readkeys
command, and the bluetoothd output
- stop bluetoothd
- remove all mentions of keyboard from /var/lib/bluetooth (or nuke
directory)
- start bluetoothd
- check that debug output mentions the key still being on the adapter
- turn on keyboard, make sure it still connects without triggering a
link_key_request event.

If the above works, can we agree that we should add KeyOnAdapter to
bluez, and get front-ends to use it?

Cheers

[-- Attachment #2: 0001-hciconfig-Add-command-to-trigger-key-read.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

>From 82626d66ddb556d555c5c668d4b80188bce8ab46 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 8 May 2011 14:53:50 +0100
Subject: [PATCH 1/3] hciconfig: Add command to trigger key read

Add support for "hci_read_stored_link_key" command to trigger
reading linkkeys from the adapter. Whether keys are read will be
listed in bluetoothd's debug output.
---
 tools/hciconfig.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index cbd0d0e..19b9b7e 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -1016,6 +1016,41 @@ static void cmd_putkey(int ctl, int hdev, char *opt)
 	hci_close_dev(dd);
 }
 
+static void cmd_readkeys(int ctl, int hdev, char *opt)
+{
+	struct hci_dev_info di;
+	bdaddr_t bdaddr;
+	int dd, ret;
+
+	dd = hci_open_dev(hdev);
+	if (dd < 0) {
+		fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
+						hdev, strerror(errno), errno);
+		exit(1);
+	}
+
+	if (hci_devinfo(hdev, &di) < 0) {
+		fprintf(stderr, "Can't get device info for hci%d: %s (%d)\n",
+						hdev, strerror(errno), errno);
+		exit(1);
+	}
+
+	if (opt != NULL) {
+		str2ba(opt, &bdaddr);
+		ret = hci_read_stored_link_key (dd, &bdaddr, 0, 1000);
+	} else {
+		ret = hci_read_stored_link_key (dd, &bdaddr, 1, 1000);
+	}
+
+	if (ret < 0) {
+		fprintf(stderr, "Can't write stored link key on hci%d: %s (%d)\n",
+						hdev, strerror(errno), errno);
+		exit(1);
+	}
+
+	hci_close_dev(dd);
+}
+
 static void cmd_delkey(int ctl, int hdev, char *opt)
 {
 	bdaddr_t bdaddr;
@@ -1923,6 +1958,7 @@ static struct {
 	{ "aclmtu",	cmd_aclmtu,	"<mtu:pkt>",	"Set ACL MTU and number of packets" },
 	{ "scomtu",	cmd_scomtu,	"<mtu:pkt>",	"Set SCO MTU and number of packets" },
 	{ "putkey",	cmd_putkey,	"<bdaddr>",	"Store link key on the device" },
+	{ "readkeys",	cmd_readkeys,	"[bdaddr]",	"Read link keys from the device" },
 	{ "delkey",	cmd_delkey,	"<bdaddr>",	"Delete link key from the device" },
 	{ "oobdata",	cmd_oob_data,	0,		"Display local OOB data" },
 	{ "commands",	cmd_commands,	0,		"Display supported commands" },
-- 
1.7.5.1


[-- Attachment #3: 0002-hciops-Add-comment-about-ignored-link-key-value.patch --]
[-- Type: text/x-patch, Size: 1186 bytes --]

>From b341dfe715fd90313848fde0b93f188c6c88a66d Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 8 May 2011 14:55:17 +0100
Subject: [PATCH 2/3] hciops: Add comment about ignored link key value

As per spec, the key value is useless and will be ignored,
in the return_link_keys() event callback, so mention that clearly.
---
 plugins/hciops.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 49dd48d..9caf2c1 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -1030,7 +1030,6 @@ static void return_link_keys(int index, void *ptr)
 	struct dev_info *dev = &devs[index];
 	evt_return_link_keys *evt = ptr;
 	uint8_t num = evt->num_keys;
-	unsigned char key[16];
 	char da[18];
 	bdaddr_t dba;
 	int i;
@@ -1041,7 +1040,10 @@ static void return_link_keys(int index, void *ptr)
 
 	for (i = 0; i < num; i++) {
 		bacpy(&dba, ptr); ba2str(&dba, da);
-		memcpy(key, ptr + 6, 16);
+		/* Ignore 16 bytes long key. From Core 2.1+EDR spec:
+		 * The link keys value parameter shall always contain
+		 * the value of zero.
+		 */
 
 		DBG("hci%d returned key for %s", index, da);
 
-- 
1.7.5.1


[-- Attachment #4: 0003-Add-KeyOnAdapter-property-to-devices.patch --]
[-- Type: text/x-patch, Size: 9771 bytes --]

>From 1a624e5be5f1e87b9958956d4e495198e8450505 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 8 May 2011 15:14:18 +0100
Subject: [PATCH 3/3] Add KeyOnAdapter property to devices

The KeyOnAdapter property will be true if the linkkey comes from
the adapter storage, rather than the local filesystem storage.

This makes it possible for front-ends to add linkkeys to the
adapter itself for keyboard and mice to automatically work
when dual-booting under other OSes.
---
 doc/device-api.txt |   16 ++++++++
 plugins/hciops.c   |   32 ++++++++++++++++
 src/adapter.c      |   22 +++++++++++
 src/adapter.h      |    6 +++
 src/device.c       |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/device.h       |    2 +
 src/event.c        |    1 +
 7 files changed, 185 insertions(+), 0 deletions(-)

diff --git a/doc/device-api.txt b/doc/device-api.txt
index d1feb18..37aa1ed 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -165,6 +165,22 @@ Properties	string Address [readonly]
 			drivers will also be removed and no new ones will
 			be probed as long as the device is blocked.
 
+		boolean KeyOnAdapter [readwrite]
+
+			Whether the linkkey for the device is available
+			on the adapter. This will be FALSE if the device
+			is not paired, or the key is not available on
+			the adapter (and just on the filesystem).
+
+			Setting this to TRUE, will write the key to the
+			adapter, returning an error if the adapter
+			does not support this.
+
+			Note that the key is not removed from the local
+			filesystem storage, as, once on the adapter, it
+			will lack linkkey type information, which is
+			required for Bluetooth 2.1 devices.
+
 		string Alias [readwrite]
 
 			The name alias for the remote device. The alias can
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 9caf2c1..3070a7f 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -3803,6 +3803,36 @@ static int hciops_remove_remote_oob_data(int index, bdaddr_t *bdaddr)
 	return 0;
 }
 
+static int hciops_put_key (int index, bdaddr_t bdaddr, uint8_t *key)
+{
+	int dd, err;
+
+	dd = hci_open_dev(index);
+	if (dd < 0)
+		return -EIO;
+
+	err = hci_write_stored_link_key(dd, &bdaddr, key, 0);
+
+	hci_close_dev(dd);
+
+	return -err;
+}
+
+static int hciops_del_key (int index, bdaddr_t bdaddr)
+{
+	int dd, err;
+
+	dd = hci_open_dev(index);
+	if (dd < 0)
+		return -EIO;
+
+	err = hci_delete_stored_link_key(dd, &bdaddr, 0, 0);
+
+	hci_close_dev(dd);
+
+	return -err;
+}
+
 static struct btd_adapter_ops hci_ops = {
 	.setup = hciops_setup,
 	.cleanup = hciops_cleanup,
@@ -3842,6 +3872,8 @@ static struct btd_adapter_ops hci_ops = {
 	.read_local_oob_data = hciops_read_local_oob_data,
 	.add_remote_oob_data = hciops_add_remote_oob_data,
 	.remove_remote_oob_data = hciops_remove_remote_oob_data,
+	.put_key = hciops_put_key,
+	.del_key = hciops_del_key,
 };
 
 static int hciops_init(void)
diff --git a/src/adapter.c b/src/adapter.c
index 76fc01b..d7023a0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3594,3 +3594,25 @@ int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 {
 	return adapter_ops->remove_remote_oob_data(adapter->dev_id, bdaddr);
 }
+
+int btd_adapter_put_key (struct btd_adapter *adapter, bdaddr_t bdaddr, uint8_t *key)
+{
+	if (!adapter_ops)
+		return -EINVAL;
+
+	if (!adapter->up)
+		return -EINVAL;
+
+	return adapter_ops->put_key(adapter->dev_id, bdaddr, key);
+}
+
+int btd_adapter_del_key (struct btd_adapter *adapter, bdaddr_t bdaddr)
+{
+	if (!adapter_ops)
+		return -EINVAL;
+
+	if (!adapter->up)
+		return -EINVAL;
+
+	return adapter_ops->del_key(adapter->dev_id, bdaddr);
+}
diff --git a/src/adapter.h b/src/adapter.h
index 9406b9b..de8a62b 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -221,6 +221,8 @@ struct btd_adapter_ops {
 	int (*add_remote_oob_data) (int index, bdaddr_t *bdaddr, uint8_t *hash,
 							uint8_t *randomizer);
 	int (*remove_remote_oob_data) (int index, bdaddr_t *bdaddr);
+	int (*put_key) (int index, bdaddr_t bdaddr, uint8_t *key);
+	int (*del_key) (int index, bdaddr_t bdaddr);
 };
 
 int btd_register_adapter_ops(struct btd_adapter_ops *ops, gboolean priority);
@@ -277,3 +279,7 @@ int btd_adapter_add_remote_oob_data(struct btd_adapter *adapter,
 
 int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 							bdaddr_t *bdaddr);
+int btd_adapter_put_key (struct btd_adapter *adapter,
+					bdaddr_t bdaddr,
+					uint8_t *key);
+int btd_adapter_del_key (struct btd_adapter *adapter, bdaddr_t bdaddr);
diff --git a/src/device.c b/src/device.c
index b0a6542..f3de5f5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -135,6 +135,7 @@ struct btd_device {
 	gboolean	trusted;
 	gboolean	paired;
 	gboolean	blocked;
+	gboolean        key_on_adapter;
 
 	gboolean	authorizing;
 	gint		ref;
@@ -233,6 +234,11 @@ gboolean device_is_paired(struct btd_device *device)
 	return device->paired;
 }
 
+gboolean device_linkkey_is_on_adapter(struct btd_device *device)
+{
+	return device->key_on_adapter;
+}
+
 gboolean device_is_trusted(struct btd_device *device)
 {
 	return device->trusted;
@@ -306,6 +312,10 @@ static DBusMessage *get_properties(DBusConnection *conn,
 	boolean = device_is_paired(device);
 	dict_append_entry(&dict, "Paired", DBUS_TYPE_BOOLEAN, &boolean);
 
+	/* KeyOnAdapter */
+	boolean = device_linkkey_is_on_adapter(device);
+	dict_append_entry(&dict, "KeyOnAdapter", DBUS_TYPE_BOOLEAN, &boolean);
+
 	/* Trusted */
 	boolean = device_is_trusted(device);
 	dict_append_entry(&dict, "Trusted", DBUS_TYPE_BOOLEAN, &boolean);
@@ -404,6 +414,80 @@ static DBusMessage *set_trust(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+static int device_put_key_on_adapter(DBusConnection *conn, struct btd_device *device)
+{
+	int err;
+	bdaddr_t src;
+	unsigned char linkkey[16];
+
+	if (device->key_on_adapter)
+		return 0;
+	if (!device->paired)
+		return 0;
+
+	adapter_get_address(device->adapter, &src);
+	if (read_link_key(&src, &device->bdaddr, linkkey, NULL) < 0)
+		return -ENOKEY;
+
+	err = btd_adapter_put_key(device->adapter, device->bdaddr, linkkey);
+	if (err < 0)
+		return -err;
+
+	device->key_on_adapter = TRUE;
+
+	emit_property_changed(conn, device->path, DEVICE_INTERFACE, "KeyOnAdapter",
+					DBUS_TYPE_BOOLEAN, &device->key_on_adapter);
+
+	return 0;
+}
+
+static int device_del_key_on_adapter(DBusConnection *conn, struct btd_device *device)
+{
+	int err;
+
+	if (!device->key_on_adapter)
+		return 0;
+
+	err = btd_adapter_del_key(device->adapter, device->bdaddr);
+	if (err < 0)
+		return err;
+
+	device->key_on_adapter = FALSE;
+
+	emit_property_changed(conn, device->path, DEVICE_INTERFACE, "KeyOnAdapter",
+					DBUS_TYPE_BOOLEAN, &device->key_on_adapter);
+
+	return 0;
+}
+
+static DBusMessage *set_key_on_adapter(DBusConnection *conn, DBusMessage *msg,
+						gboolean value, void *data)
+{
+	struct btd_device *device = data;
+	int err;
+
+	if (value)
+		err = device_put_key_on_adapter(conn, device);
+	else
+		err = device_del_key_on_adapter(conn, device);
+
+	switch (-err) {
+	case 0:
+		return dbus_message_new_method_return(msg);
+	case EINVAL:
+		return g_dbus_create_error(msg,
+					ERROR_INTERFACE ".NotSupported",
+					"Adapter lacks storage support");
+	case ENOKEY:
+		return g_dbus_create_error(msg,
+					ERROR_INTERFACE ".Failed",
+					"Device is paired but link key is not available");
+	default:
+		return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
+						"%s", strerror(-err));
+	}
+}
+
 static void driver_remove(struct btd_device_driver *driver,
 						struct btd_device *device)
 {
@@ -552,6 +636,15 @@ static DBusMessage *set_property(DBusConnection *conn,
 		dbus_message_iter_get_basic(&sub, &value);
 
 		return set_blocked(conn, msg, value, data);
+	} else if (g_str_equal("KeyOnAdapter", property)) {
+		dbus_bool_t value;
+
+		if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_BOOLEAN)
+			return btd_error_invalid_args(msg);
+
+		dbus_message_iter_get_basic(&sub, &value);
+
+		return set_key_on_adapter(conn, msg, value, data);
 	}
 
 	return btd_error_invalid_args(msg);
@@ -1920,6 +2013,19 @@ void device_set_paired(struct btd_device *device, gboolean value)
 				DBUS_TYPE_BOOLEAN, &value);
 }
 
+void device_set_key_on_adapter(struct btd_device *device, gboolean value)
+{
+	DBusConnection *conn = get_dbus_connection();
+
+	if (device->key_on_adapter == value)
+		return;
+
+	device->key_on_adapter = value;
+
+	emit_property_changed(conn, device->path, DEVICE_INTERFACE, "KeyOnAdapter",
+				DBUS_TYPE_BOOLEAN, &value);
+}
+
 static void device_agent_removed(struct agent *agent, void *user_data)
 {
 	struct btd_device *device = user_data;
diff --git a/src/device.h b/src/device.h
index d59b8eb..0326e24 100644
--- a/src/device.h
+++ b/src/device.h
@@ -69,7 +69,9 @@ gboolean device_is_busy(struct btd_device *device);
 gboolean device_is_temporary(struct btd_device *device);
 gboolean device_is_paired(struct btd_device *device);
 gboolean device_is_trusted(struct btd_device *device);
+gboolean device_linkkey_is_on_adapter(struct btd_device *device);
 void device_set_paired(struct btd_device *device, gboolean paired);
+void device_set_key_on_adapter(struct btd_device *device, gboolean key_on_adapter);
 void device_set_temporary(struct btd_device *device, gboolean temporary);
 void device_set_type(struct btd_device *device, device_type_t type);
 gboolean device_is_connected(struct btd_device *device);
diff --git a/src/event.c b/src/event.c
index cf68711..fd35c08 100644
--- a/src/event.c
+++ b/src/event.c
@@ -691,4 +691,5 @@ void btd_event_returned_link_key(bdaddr_t *local, bdaddr_t *peer)
 		return;
 
 	device_set_paired(device, TRUE);
+	device_set_key_on_adapter(device, TRUE);
 }
-- 
1.7.5.1


^ permalink raw reply related

* Re: BT 3.0 HS Support in BlueZ
From: Arun K. Singh @ 2011-05-08 12:27 UTC (permalink / raw)
  To: Mat Martineau
  Cc: Gustavo F. Padovan, Arun Kumar SINGH, Anurag Gupta, pkrystad,
	linux-bluetooth
In-Reply-To: <alpine.DEB.2.00.1105051548540.4213@localhost6.localdomain6>

Hi Mat, Gustavo,

> Gustavo, Arun:
> We do still plan to upstream our Bluetooth 3.0 + HS implementation.  I will
> start work on upstreaming later this month, but I need to merge in all of
> the recent L2CAP refactoring changes.

Good to know this. As I understand there have been quite some changes
and organisation in l2cap layer which may warrant subtle changes in
your AMP implementation. If its quite some work, may be we can come up
with a kind of TODO list and try to do a work split? Eitherways I will
come back with some thoughts after going thru existing below
implementation.

> Please let me know if you have any other questions about AMP.
Sure will come back in case stuck anywhere.

Thanks,
Arun

^ permalink raw reply

* Re: [PATCH v2 3/3] Add sixaxis plugin: USB pairing and LEDs settings
From: Bastien Nocera @ 2011-05-07 16:57 UTC (permalink / raw)
  To: Antonio Ospite
  Cc: linux-bluetooth, linux-input, Jim Paris, Ranulf Doswell,
	Pascal A . Brisset, Marcin Tolysz, Christian Birchinger,
	Filipe Lopes, Alan Ott, Mikko Virkkila
In-Reply-To: <20110507011412.ba0ad1e9.ospite@studenti.unina.it>

On Sat, 2011-05-07 at 01:14 +0200, Antonio Ospite wrote:
> On Fri, 06 May 2011 02:14:38 +0100
> Bastien Nocera <hadess@hadess.net> wrote:
> 
> > On Fri, 2011-02-25 at 11:04 +0100, Antonio Ospite wrote:
> > > +                       [AC_LANG_PROGRAM([[
> > > +                               #include <sys/ioctl.h>
> > > +                               #include <linux/hidraw.h>
> > > +                               #if ! (defined(HIDIOCSFEATURE) &&
> > > defined(HIDIOCGFEATURE))
> > > +                               #error "HIDIOCSFEATURE and
> > > HIDIOCGFEATURE are required (linux-libc-dev >= 2.6.3x)"
> > > +                               #endif
> > > +                               ]], 
> > 
> > The only part of the patch I have a problem with is this one.
> > 
> > I'd rather the code had:
> > #ifndef HIDIOCSFEATURE
> > #define HIDIOCSFEATURE bleh
> > #endif
> > 
> > And gracefully handled the ioctl not being available on the running
> > kernel (eg. "Not handling plugged in Sixaxis joypad because the kernel
> > lacks HIDIOCSFEATURE support").
> >
> 
> Thinking twice about that, maybe I haven't fully understood what you
> mean.
> 
> Do you want that the plugin can be enabled and _compiled_ on _older_
> kernels as well?

No, the plugin can be built with older kernel headers. The kernel
headers are shipped as part of the glibc, and should offer a "stable"
interface to the Linux kernel. The Debian way of shipping supposed glibc
kernel headers which actually come from the running kernel is something
that's frowned upon.

> Because about compiling on _supported_ ones and then _running_ it on
> _older_ ones, well, the ioctl return values are already checked and
> they should just (gracefully?) fail on unsupported kernels. But I'll
> double check this scenario.
> 
> If you want indeed it to be _compiled_ on older kernels and nonetheless
> still work on supported ones, I think we just have to copy the iotcls
> request defines from hidraw.h if they are not defined but I still don't
> know if I like that.

Again, it's not compiling against older kernels. but compiling against
older kernel headers, which is a wildly different thing.

I'd like the plugin to be enabled, even if building with older kernel
headers, as those have no relation to the capabilities of the running
kernel.

It would also make the whole thing easier to test (just install a newer
kernel with the patches merged in, and voila, working sisaxis pairing).

Cheers


^ permalink raw reply

* Re: btusb not working in 2.6.38.4
From: Andrej Podzimek @ 2011-05-07 16:50 UTC (permalink / raw)
  To: linux-bluetooth, stable, greg
In-Reply-To: <20110428051124.GC2214@joana>

[-- Attachment #1: Type: text/plain, Size: 3379 bytes --]

> Hi Andrej,
>
> * Andrej Podzimek<andrej@podzimek.org>  [2011-04-28 01:22:02 +0200]:
>
>> Hello,
>>
>> after a recent kernel update on Arch Linux (2.6.38.4), I can see the following problem in dmesg:
>>
>> ------------[ cut here ]------------
>> WARNING: at lib/kobject.c:595 kobject_put+0x40/0x50()
>> Hardware name: To Be Filled By O.E.M.
>> kobject: '(null)' (ffff88023f60d5a0): is not initialized, yet kobject_put() is being called.
>> Modules linked in: btusb(+) bluetooth rfkill usbhid hid button i2c_i801 i2c_core r8169 mii iTCO_wdt iTCO_vendor_support psmouse sg serio_raw evdev pcspkr ip_tables ip6_tables x_tables tpm_tis tpm tpm_bios w83627ehf hwmon_vid coretemp ext4 mbcache jbd2 crc16 dm_mod usb_storage raid456 async_raid6_recov async_pq raid6_pq async_xor xor async_memcpy async_tx md_mod uhci_hcd xhci_hcd ehci_hcd usbcore sd_mod crc_t10dif ahci libahci libata scsi_mod cpufreq_ondemand acpi_cpufreq freq_table processor mperf i7core_edac edac_core
>> Pid: 1820, comm: modprobe Not tainted 2.6.38-ARCH #1
>> Call Trace:
>>    [<ffffffff8103a86b>] ? warn_slowpath_common+0x7b/0xc0
>>    [<ffffffff8103a965>] ? warn_slowpath_fmt+0x45/0x50
>>    [<ffffffff81248d3f>] ? skb_dequeue+0x5f/0x80
>>    [<ffffffff8116b6f0>] ? kobject_put+0x40/0x50
>>    [<ffffffffa025f85c>] ? btusb_probe+0x57c/0x5e0 [btusb]
>>    [<ffffffffa00b85d5>] ? usb_probe_interface+0xe5/0x1e0 [usbcore]
>>    [<ffffffff81215aaf>] ? driver_probe_device+0x6f/0x190
>>    [<ffffffff81215c63>] ? __driver_attach+0x93/0xa0
>>    [<ffffffff81215bd0>] ? __driver_attach+0x0/0xa0
>>    [<ffffffff81214b23>] ? bus_for_each_dev+0x53/0x80
>>    [<ffffffff812153f8>] ? bus_add_driver+0x188/0x260
>>    [<ffffffff81215e3a>] ? driver_register+0x6a/0x130
>>    [<ffffffffa00b748a>] ? usb_register_driver+0x8a/0x180 [usbcore]
>>    [<ffffffffa011c000>] ? btusb_init+0x0/0x1000 [btusb]
>>    [<ffffffff810001dc>] ? do_one_initcall+0x3c/0x170
>>    [<ffffffff8106db3a>] ? sys_init_module+0xda/0x230
>>    [<ffffffff8100243b>] ? system_call_fastpath+0x16/0x1b
>> ---[ end trace 9c4648061ddb0b67 ]---
>>
>> Presumably, Bluetooth does not seem to work at all (i.e., hciconfig -a does not output anything).
>>
>> The output from lsusb -v relevant to the specific device is attached.
>>
>> The device worked 100% flawlessly with 2.6.38.3. I had an a2dp headset and a mouse paired with it, both of which worked perfectly fine in parallel.
>
> The only Bluetooth change in 2.6.38.4 is: https://lkml.org/lkml/2011/4/19/406
> However I don't think this patch is causing this issue. Do you care to patch -R it
> and test?
> If the problem is somewhere else we have to go with a bisect, there are only
> 70 patches, so it shouldn't take to long.
>
> Greg, any idea on that? Are there similar reports of warnings for 2.6.38.4?

Hello,

I'm sorry for this false positive. It was just a typical PEBKAC. The machine runs a WiFi access point and requires ath9k from compat-wireless (since the mainline ath9k can do no better than 2 Mb/s in AP mode). I installed compat-wireless as usual, but forgot to run scripts/driver-select. Consequently, all drivers (including Bluetooth, namely btusb) got replaced. So the backtrace was caused by using btusb from compat-wireless (April 26 2011) with kernel 2.6.38.4. The problem does *not* occur in a standard vanilla kernel.

Andrej


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5804 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] client: fix not canceling connection request if client exit bus
From: Luiz Augusto von Dentz @ 2011-05-07 13:58 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20110506171550.GA30648@piper>

Hi Vinicius,

On Fri, May 6, 2011 at 8:15 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> Hi Luiz,
>
> On 13:43 Fri 06 May, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>>
>> There is no point on proceeding with sdp/rfcomm connections if client
>> exit the bus.
>> ---
>>  client/main.c    |   23 +++++----
>>  client/session.c |  144 ++++++++++++++++++++++++++++++++++++------------------
>>  client/session.h |   10 +++-
>>  3 files changed, 115 insertions(+), 62 deletions(-)
>>
>> diff --git a/client/main.c b/client/main.c
>> index 20d56d2..478181c 100644
>> --- a/client/main.c
>> +++ b/client/main.c
>> @@ -86,6 +86,7 @@ static void create_callback(struct session_data *session, GError *err,
>>       if (session->target != NULL) {
>>               session_register(session);
>>               session_set_owner(session, data->sender, owner_exit);
>> +
>>               g_dbus_send_reply(data->connection, data->message,
>>                               DBUS_TYPE_OBJECT_PATH, &session->path,
>>                               DBUS_TYPE_INVALID);
>> @@ -165,6 +166,7 @@ static DBusMessage *send_files(DBusConnection *connection,
>>       GPtrArray *files;
>>       struct send_data *data;
>>       const char *agent, *source = NULL, *dest = NULL, *target = NULL;
>> +     const char *sender;
>>       uint8_t channel = 0;
>>
>>       dbus_message_iter_init(message, &iter);
>> @@ -201,6 +203,8 @@ static DBusMessage *send_files(DBusConnection *connection,
>>                               "org.openobex.Error.InvalidArguments", NULL);
>>       }
>>
>> +     sender = dbus_message_get_sender(message);
>> +
>>       data = g_try_malloc0(sizeof(*data));
>>       if (data == NULL) {
>>               g_ptr_array_free(files, TRUE);
>> @@ -210,12 +214,12 @@ static DBusMessage *send_files(DBusConnection *connection,
>>
>>       data->connection = dbus_connection_ref(connection);
>>       data->message = dbus_message_ref(message);
>> -     data->sender = g_strdup(dbus_message_get_sender(message));
>> +     data->sender = g_strdup(sender);
>>       data->agent = g_strdup(agent);
>>       data->files = files;
>>
>> -     session = session_create(source, dest, "OPP", channel, create_callback,
>> -                             data);
>> +     session = session_create(source, dest, "OPP", channel, sender,
>> +                                                     create_callback, data);
>>       if (session != NULL) {
>>               sessions = g_slist_append(sessions, session);
>>               return NULL;
>> @@ -269,8 +273,6 @@ static void pull_session_callback(struct session_data *session,
>>               goto done;
>>       }
>>
>> -     session_set_owner(session, data->sender, owner_exit);
>> -
>>       session_pull(session, "text/x-vcard", data->filename,
>>                                               pull_complete_callback, data);
>>
>> @@ -320,7 +322,7 @@ static DBusMessage *pull_business_card(DBusConnection *connection,
>>       data->sender = g_strdup(dbus_message_get_sender(message));
>>       data->filename = g_strdup(name);
>>
>> -     session = session_create(source, dest, "OPP", channel,
>> +     session = session_create(source, dest, "OPP", channel, data->sender,
>>                                       pull_session_callback, data);
>>       if (session != NULL) {
>>               sessions = g_slist_append(sessions, session);
>> @@ -382,8 +384,8 @@ static DBusMessage *create_session(DBusConnection *connection,
>>       data->message = dbus_message_ref(message);
>>       data->sender = g_strdup(dbus_message_get_sender(message));
>>
>> -     session = session_create(source, dest, target, channel,
>> -                                     create_callback, data);
>> +     session = session_create(source, dest, target, channel, data->sender,
>> +                                                     create_callback, data);
>>       if (session != NULL) {
>>               sessions = g_slist_append(sessions, session);
>>               return NULL;
>> @@ -471,7 +473,6 @@ static void capability_session_callback(struct session_data *session,
>>               goto done;
>>       }
>>
>> -     session_set_owner(session, data->sender, owner_exit);
>>       session_pull(session, "x-obex/capability", NULL,
>>                               capabilities_complete_callback, data);
>>
>> @@ -513,8 +514,8 @@ static DBusMessage *get_capabilities(DBusConnection *connection,
>>       if (!target)
>>               target = "OPP";
>>
>> -     session = session_create(source, dest, target, channel,
>> -                             capability_session_callback, data);
>> +     session = session_create(source, dest, target, channel, data->sender,
>> +                                     capability_session_callback, data);
>>       if (session != NULL) {
>>               sessions = g_slist_append(sessions, session);
>>               return NULL;
>> diff --git a/client/session.c b/client/session.c
>> index 88eae8d..8c41858 100644
>> --- a/client/session.c
>> +++ b/client/session.c
>> @@ -169,6 +169,9 @@ static void session_unregistered(struct session_data *session)
>>                                       SESSION_INTERFACE);
>>
>>       DBG("Session(%p) unregistered %s", session, session->path);
>> +
>> +     g_free(session->path);
>> +     session->path = NULL;
>>  }
>>
>>  static void session_free(struct session_data *session)
>> @@ -199,6 +202,7 @@ static void session_free(struct session_data *session)
>>       g_free(session->callback);
>>       g_free(session->path);
>>       g_free(session->owner);
>> +     g_free(session->service);
>>       g_free(session);
>>  }
>>
>> @@ -223,6 +227,8 @@ static void rfcomm_callback(GIOChannel *io, GError *err, gpointer user_data)
>>       GwObex *obex;
>>       int fd;
>>
>> +     DBG("");
>> +
>>       if (err != NULL) {
>>               error("%s", err->message);
>>               goto done;
>> @@ -255,6 +261,8 @@ static GIOChannel *rfcomm_connect(const bdaddr_t *src, const bdaddr_t *dst,
>>       GIOChannel *io;
>>       GError *err = NULL;
>>
>> +     DBG("");
>> +
>>       io = bt_io_connect(BT_IO_RFCOMM, function, user_data, NULL, &err,
>>                               BT_IO_OPT_SOURCE_BDADDR, src,
>>                               BT_IO_OPT_DEST_BDADDR, dst,
>> @@ -273,6 +281,7 @@ static void search_callback(uint8_t type, uint16_t status,
>>                       uint8_t *rsp, size_t size, void *user_data)
>>  {
>>       struct callback_data *callback = user_data;
>> +     struct session_data *session = callback->session;
>>       unsigned int scanned, bytesleft = size;
>>       int seqlen = 0;
>>       uint8_t dataType, channel = 0;
>> @@ -325,23 +334,26 @@ static void search_callback(uint8_t type, uint16_t status,
>>       if (channel == 0)
>>               goto failed;
>>
>> -     callback->session->channel = channel;
>> +     session->channel = channel;
>>
>> -     callback->session->io = rfcomm_connect(&callback->session->src,
>> -                                             &callback->session->dst,
>> -                                             channel, rfcomm_callback,
>> -                                             callback);
>> -     if (callback->session->io != NULL) {
>> +     g_io_channel_set_close_on_unref(session->io, FALSE);
>> +     g_io_channel_unref(session->io);
>> +
>> +     session->io = rfcomm_connect(&session->src, &session->dst, channel,
>> +                                     rfcomm_callback, callback);
>> +     if (session->io != NULL) {
>>               sdp_close(callback->sdp);
>>               return;
>>       }
>>
>>  failed:
>> -     sdp_close(callback->sdp);
>> +     g_io_channel_shutdown(session->io, TRUE, NULL);
>> +     g_io_channel_unref(session->io);
>> +     session->io = NULL;
>>
>>       g_set_error(&gerr, OBEX_IO_ERROR, -EIO,
>>                                       "Unable to find service record");
>> -     callback->func(callback->session, gerr, callback->data);
>> +     callback->func(session, gerr, callback->data);
>>       g_clear_error(&gerr);
>>
>>       session_unref(callback->session);
>> @@ -366,6 +378,7 @@ static gboolean service_callback(GIOChannel *io, GIOCondition cond,
>>                                                       gpointer user_data)
>>  {
>>       struct callback_data *callback = user_data;
>> +     struct session_data *session = callback->session;
>>       sdp_list_t *search, *attrid;
>>       uint32_t range = 0x0000ffff;
>>       GError *gerr = NULL;
>> @@ -395,7 +408,9 @@ static gboolean service_callback(GIOChannel *io, GIOCondition cond,
>>       return FALSE;
>>
>>  failed:
>> -     sdp_close(callback->sdp);
>> +     g_io_channel_shutdown(session->io, TRUE, NULL);
>> +     g_io_channel_unref(session->io);
>> +     session->io = NULL;
>>
>>       g_set_error(&gerr, OBEX_IO_ERROR, -EIO,
>>                                       "Unable to find service record");
>> @@ -410,6 +425,7 @@ failed:
>>  static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
>>                                       GIOFunc function, gpointer user_data)
>>  {
>> +     struct callback_data *cb = user_data;
>>       sdp_session_t *sdp;
>>       GIOChannel *io;
>>
>> @@ -426,15 +442,59 @@ static sdp_session_t *service_connect(const bdaddr_t *src, const bdaddr_t *dst,
>>       g_io_add_watch(io, G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
>>                                                       function, user_data);
>>
>> -     g_io_channel_unref(io);
>> +     cb->session->io = io;
>>
>>       return sdp;
>>  }
>>
>> +static gboolean connection_complete(gpointer data)
>> +{
>> +     struct callback_data *cb = data;
>> +
>> +     cb->func(cb->session, 0, cb->data);
>> +
>> +     session_unref(cb->session);
>> +
>> +     g_free(cb);
>> +
>> +     return FALSE;
>> +}
>> +
>> +static void owner_disconnected(DBusConnection *connection, void *user_data)
>> +{
>> +     struct session_data *session = user_data;
>> +
>> +     DBG("");
>> +
>> +     session_shutdown(session);
>> +}
>> +
>> +int session_set_owner(struct session_data *session, const char *name,
>> +                     GDBusWatchFunction func)
>> +{
>> +     if (session == NULL)
>> +             return -EINVAL;
>> +
>> +     if (session->watch)
>> +             g_dbus_remove_watch(session->conn, session->watch);
>> +
>> +     session->watch = g_dbus_add_disconnect_watch(session->conn, name, func,
>> +                                                     session, NULL);
>> +     if (session->watch == 0)
>> +             return -EINVAL;
>> +
>> +     session->owner = g_strdup(name);
>> +
>> +     return 0;
>> +}
>> +
>>  struct session_data *session_create(const char *source,
>> -                     const char *destination, const char *target,
>> -                     uint8_t channel, session_callback_t function,
>> -                     void *user_data)
>> +                                             const char *destination,
>> +                                             const char *service,
>> +                                             uint8_t channel,
>> +                                             const char *owner,
>> +                                             session_callback_t function,
>> +                                             void *user_data)
>>  {
>>       struct session_data *session;
>>       struct callback_data *callback;
>> @@ -462,22 +522,23 @@ struct session_data *session_create(const char *source,
>>               str2ba(source, &session->src);
>>
>>       str2ba(destination, &session->dst);
>> +     session->service = g_strdup(service);
>>
>> -     if (!g_ascii_strncasecmp(target, "OPP", 3)) {
>> +     if (!g_ascii_strncasecmp(service, "OPP", 3)) {
>>               sdp_uuid16_create(&session->uuid, OBEX_OBJPUSH_SVCLASS_ID);
>> -     } else if (!g_ascii_strncasecmp(target, "FTP", 3)) {
>> +     } else if (!g_ascii_strncasecmp(service, "FTP", 3)) {
>>               sdp_uuid16_create(&session->uuid, OBEX_FILETRANS_SVCLASS_ID);
>>               session->target = OBEX_FTP_UUID;
>>               session->target_len = OBEX_FTP_UUID_LEN;
>> -     } else if (!g_ascii_strncasecmp(target, "PBAP", 4)) {
>> +     } else if (!g_ascii_strncasecmp(service, "PBAP", 4)) {
>>               sdp_uuid16_create(&session->uuid, PBAP_PSE_SVCLASS_ID);
>>               session->target = OBEX_PBAP_UUID;
>>               session->target_len = OBEX_PBAP_UUID_LEN;
>> -     } else if (!g_ascii_strncasecmp(target, "SYNC", 4)) {
>> +     } else if (!g_ascii_strncasecmp(service, "SYNC", 4)) {
>>               sdp_uuid16_create(&session->uuid, IRMC_SYNC_SVCLASS_ID);
>>               session->target = OBEX_SYNC_UUID;
>>               session->target_len = OBEX_SYNC_UUID_LEN;
>> -     } else if (!g_ascii_strncasecmp(target, "PCSUITE", 7)) {
>> +     } else if (!g_ascii_strncasecmp(service, "PCSUITE", 7)) {
>>               sdp_uuid128_create(&session->uuid, pcsuite_uuid);
>>       } else {
>>               return NULL;
>> @@ -493,7 +554,10 @@ struct session_data *session_create(const char *source,
>>       callback->func = function;
>>       callback->data = user_data;
>>
>> -     if (session->channel > 0) {
>> +     if (session->obex) {
>> +             g_idle_add(connection_complete, callback);
>> +             err = 0;
>> +     } else if (session->channel > 0) {
>>               session->io = rfcomm_connect(&session->src, &session->dst,
>>                                                       session->channel,
>>                                                       rfcomm_callback,
>> @@ -511,21 +575,31 @@ struct session_data *session_create(const char *source,
>>               return NULL;
>>       }
>>
>> +     if (owner)
>> +             session_set_owner(session, owner, owner_disconnected);
>> +
>>       return session;
>>  }
>>
>>  void session_shutdown(struct session_data *session)
>>  {
>> -     struct transfer_data *transfer;
>> -
>>       DBG("%p", session);
>> -     transfer = session->pending ? session->pending->data : NULL;
>>
>>       session_ref(session);
>>
>>       /* Unregister any pending transfer */
>>       g_slist_foreach(session->pending, (GFunc) transfer_unregister, NULL);
>>
>> +     /* Unregister interfaces */
>> +     if (session->path)
>> +             session_unregistered(session);
>> +
>> +     /* Shutdown io */
>> +     if (session->io) {
>> +             int fd = g_io_channel_unix_get_fd(session->io);
>> +             shutdown(fd, SHUT_RDWR);
>> +     }
>> +
>>       session_unref(session);
>>  }
>>
>> @@ -589,13 +663,6 @@ static DBusMessage *release_agent(DBusConnection *connection,
>>       return dbus_message_new_method_return(message);
>>  }
>>
>> -static void owner_disconnected(DBusConnection *connection, void *user_data)
>> -{
>> -     struct session_data *session = user_data;
>> -
>> -     session_shutdown(session);
>> -}
>> -
>>  static void append_entry(DBusMessageIter *dict,
>>                               const char *key, int type, void *val)
>>  {
>> @@ -1469,25 +1536,6 @@ const char *session_get_agent(struct session_data *session)
>>       return agent->name;
>>  }
>>
>> -int session_set_owner(struct session_data *session, const char *name,
>> -                     GDBusWatchFunction func)
>> -{
>> -     if (session == NULL)
>> -             return -EINVAL;
>> -
>> -     if (session->watch != 0)
>> -             return -EALREADY;
>> -
>> -     session->watch = g_dbus_add_disconnect_watch(session->conn, name, func,
>> -                                                     session, NULL);
>> -     if (session->watch == 0)
>> -             return -EINVAL;
>> -
>> -     session->owner = g_strdup(name);
>> -
>> -     return 0;
>> -}
>> -
>>  const char *session_get_owner(struct session_data *session)
>>  {
>>       if (session == NULL)
>> diff --git a/client/session.h b/client/session.h
>> index 546849e..6f8a434 100644
>> --- a/client/session.h
>> +++ b/client/session.h
>> @@ -36,6 +36,7 @@ struct session_data {
>>       bdaddr_t src;
>>       bdaddr_t dst;
>>       uint8_t channel;
>> +     char *service;          /* Service friendly name */
>
> Shouldn't adding the "service" field (and related changes) be on a separate
> patch?

Yep, gonna split this, thanks for catching this.

>>       const char *target;     /* OBEX Target UUID */
>>       int target_len;
>>       uuid_t uuid;            /* Bluetooth Service Class */
>> @@ -56,9 +57,12 @@ typedef void (*session_callback_t) (struct session_data *session,
>>                                       GError *err, void *user_data);
>>
>>  struct session_data *session_create(const char *source,
>> -                     const char *destination, const char *target,
>> -                     uint8_t channel, session_callback_t function,
>> -                     void *user_data);
>> +                                             const char *destination,
>> +                                             const char *service,
>> +                                             uint8_t channel,
>> +                                             const char *owner,
>> +                                             session_callback_t function,
>> +                                             void *user_data);
>>
>>  struct session_data *session_ref(struct session_data *session);
>>  void session_unref(struct session_data *session);
>> --
>> 1.7.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Cheers,
> --
> Vinicius
>



-- 
Luiz Augusto von Dentz
Computer Engineer

^ permalink raw reply

* Re: RFC: First pass at pretty hostname support
From: Bastien Nocera @ 2011-05-07  6:56 UTC (permalink / raw)
  To: BlueZ development
In-Reply-To: <1304701117.16101.40.camel@novo.hadess.net>

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

On Fri, 2011-05-06 at 17:58 +0100, Bastien Nocera wrote:
> Most of the details are in the patch.
> 
> I just wanted to mention that:
> "Bastien's desktop": good
> "novo-0": bad
> 
> Ideas on how to implement the TODO items would be appreciated. I'm
> currently thinking that a plugin to monitor the pretty hostname would be
> the cleaner way. It would even allow us to change the adapter name on
> the fly if the hostname (rather than the pretty hostname) changed.
> 
> Cheers

And with the correct patch...

[-- Attachment #2: 0001-Use-Pretty-hostname-for-the-adapter-name.patch --]
[-- Type: text/x-patch, Size: 4254 bytes --]

>From 76eef22b0cc2e99724fbac05d6d4cb054337b795 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 6 May 2011 17:48:56 +0100
Subject: [PATCH] Use "Pretty hostname" for the adapter name

systemd exports a "pretty hostname" through /etc/machine-info[1],
as well as through a D-Bus service[2]. This pretty hostname should be
used to name the adapter in a way that's more dynamic and user-friendly
than the current "static hostname" use.

[1]: http://0pointer.de/public/systemd-man/machine-info.html
[2]: http://www.freedesktop.org/wiki/Software/systemd/hostnamed

TODO:
- Add option not to write the adapter name, so it can be changed
  automatically
- Make the default adapter (and not hci0) have the shorter pretty name
  (eg. through plug/unplug, "My laptop 1" could be the name for the
   default adapter, we don't want that)
- Monitor /etc/machine-info, or listen to the hostname service signals
  for changes
---
 src/adapter.c |   20 ++++++++++++++++++++
 src/hcid.h    |    1 +
 src/main.c    |   32 ++++++++++++++++++++++++++++++++
 src/main.conf |    8 +++++---
 4 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 76fc01b..1ef6e36 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -183,7 +183,10 @@ static void dev_info_free(struct remote_dev_info *dev)
 
 /*
  * Device name expansion
+ *   %h - hostname
  *   %d - device id
+ *   %p - pretty hostname
+ *   %i - device id if different from 0, empty otherwise
  */
 static char *expand_name(char *dst, int size, char *str, int dev_id)
 {
@@ -209,6 +212,19 @@ static char *expand_name(char *dst, int size, char *str, int dev_id)
 				opt = main_opts.host_name;
 				break;
 
+			case 'p':
+				opt = main_opts.pretty_host_name;
+				if (!opt)
+					opt = main_opts.host_name;
+				break;
+
+			case 'i':
+				if (dev_id > 0) {
+					sprintf(buf, "%d", dev_id);
+					opt = buf;
+				}
+				break;
+
 			case '%':
 				dst[np++] = str[sp++];
 				/* fall through */
@@ -236,6 +252,10 @@ static char *expand_name(char *dst, int size, char *str, int dev_id)
 		}
 	}
 	dst[np] = '\0';
+
+	/* Remove leading and trailing whitespaces */
+	g_strstrip(dst);
+
 	return dst;
 }
 
diff --git a/src/hcid.h b/src/hcid.h
index 856723b..b2a3b0a 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -25,6 +25,7 @@
 
 struct main_opts {
 	char		host_name[40];
+	char           *pretty_host_name;
 	unsigned long	flags;
 	char		*name;
 	uint32_t	class;
diff --git a/src/main.c b/src/main.c
index c454327..4a336ba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -234,6 +234,35 @@ static void parse_config(GKeyFile *config)
 						HCI_LP_HOLD | HCI_LP_PARK;
 }
 
+static char *read_pretty_host_name (void)
+{
+	char *contents, *ret;
+	char **lines;
+	guint i;
+
+	ret = NULL;
+
+	if (g_file_get_contents("/etc/machine-info",
+			&contents, NULL, NULL) == FALSE) {
+		return NULL;
+	}
+	lines = g_strsplit_set(contents, "\r\n", 0);
+	g_free(contents);
+
+	if (lines == NULL)
+		return NULL;
+
+	for (i = 0; lines[i] != NULL; i++) {
+		if (g_str_has_prefix(lines[i], "PRETTY_HOSTNAME=")) {
+			ret = g_strdup(lines[i] + strlen("PRETTY_HOSTNAME="));
+			break;
+		}
+	}
+
+	g_strfreev(lines);
+	return ret;
+}
+
 static void init_defaults(void)
 {
 	/* Default HCId settings */
@@ -248,6 +277,7 @@ static void init_defaults(void)
 
 	if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 1) < 0)
 		strcpy(main_opts.host_name, "noname");
+	main_opts.pretty_host_name = read_pretty_host_name();
 }
 
 static GMainLoop *event_loop;
@@ -501,6 +531,8 @@ int main(int argc, char *argv[])
 	if (config)
 		g_key_file_free(config);
 
+	g_free (main_opts.pretty_host_name);
+
 	info("Exit");
 
 	__btd_log_cleanup();
diff --git a/src/main.conf b/src/main.conf
index 8cd132f..bedd5c7 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -4,9 +4,11 @@
 #DisablePlugins = network,input
 
 # Default adaper name
-# %h - substituted for hostname
-# %d - substituted for adapter id
-Name = %h-%d
+# %h - hostname
+# %d - adapter id
+# %p - pretty hostname (if available, hostname otherwise)
+# %i - device id if different from 0, empty otherwise
+Name = %p %i
 
 # Default device class. Only the major and minor device class bits are
 # considered.
-- 
1.7.5


^ permalink raw reply related

* Re: [PATCH v2 3/3] Add sixaxis plugin: USB pairing and LEDs settings
From: Antonio Ospite @ 2011-05-06 23:14 UTC (permalink / raw)
  To: Bastien Nocera
  Cc: linux-bluetooth, linux-input, Jim Paris, Ranulf Doswell,
	Pascal A . Brisset, Marcin Tolysz, Christian Birchinger,
	Filipe Lopes, Alan Ott, Mikko Virkkila
In-Reply-To: <1304644488.16101.28.camel@novo.hadess.net>

[-- Attachment #1: Type: text/plain, Size: 1890 bytes --]

On Fri, 06 May 2011 02:14:38 +0100
Bastien Nocera <hadess@hadess.net> wrote:

> On Fri, 2011-02-25 at 11:04 +0100, Antonio Ospite wrote:
> > +                       [AC_LANG_PROGRAM([[
> > +                               #include <sys/ioctl.h>
> > +                               #include <linux/hidraw.h>
> > +                               #if ! (defined(HIDIOCSFEATURE) &&
> > defined(HIDIOCGFEATURE))
> > +                               #error "HIDIOCSFEATURE and
> > HIDIOCGFEATURE are required (linux-libc-dev >= 2.6.3x)"
> > +                               #endif
> > +                               ]], 
> 
> The only part of the patch I have a problem with is this one.
> 
> I'd rather the code had:
> #ifndef HIDIOCSFEATURE
> #define HIDIOCSFEATURE bleh
> #endif
> 
> And gracefully handled the ioctl not being available on the running
> kernel (eg. "Not handling plugged in Sixaxis joypad because the kernel
> lacks HIDIOCSFEATURE support").
>

Thinking twice about that, maybe I haven't fully understood what you
mean.

Do you want that the plugin can be enabled and _compiled_ on _older_
kernels as well?

Because about compiling on _supported_ ones and then _running_ it on
_older_ ones, well, the ioctl return values are already checked and
they should just (gracefully?) fail on unsupported kernels. But I'll
double check this scenario.

If you want indeed it to be _compiled_ on older kernels and nonetheless
still work on supported ones, I think we just have to copy the iotcls
request defines from hidraw.h if they are not defined but I still don't
know if I like that.

Regards,
   Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox