Linux bluetooth development
 help / color / mirror / Atom feed
* Re: Authentication Rejected when pairing stereo headset
From: Andrey Voropaev @ 2012-12-20 10:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121220093840.GA21122@aemeltch-MOBL1>

On Thu, Dec 20, 2012 at 10:38 AM, Andrei Emeltchenko
<andrei.emeltchenko.news@gmail.com> wrote:
>
> The patch is below:
>
> commit 7a7f1e7c857959f5298020969741e389f21edbae
> Author: Hemant Gupta <hemant.gupta@stericsson.com>
> Date:   Mon Jan 16 13:34:29 2012 +0530
>
>     Bluetooth: Send correct response to IO Capability Request
>
>     This patch sends correct IO Capability response to remote device
>     in case Local Device supports KeyBoardDisplay IO Capability as
>     this capability is not valid as per BT spec for IO capability
>     Request Reply Command.
>     This capability is mapped to DisplayYesNo which is in accordance
>     with BT spec.
>
>     Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
>     Acked-by: Marcel Holtmann <marcel@holtmann.org>
>     Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
>
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 6fb9016..041a35e 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2965,7 +2965,10 @@ static inline void hci_io_capa_request_evt(struct
> hci_dev *hdev, struct sk_buff
>                 struct hci_cp_io_capability_reply cp;
>
>                 bacpy(&cp.bdaddr, &ev->bdaddr);
> -               cp.capability = conn->io_capability;
> +               /* Change the IO capability from KeyboardDisplay
> +                * to DisplayYesNo as it is not supported by BT spec. */
> +               cp.capability = (conn->io_capability == 0x04) ?
> +                                               0x01 :
> conn->io_capability;
>                 conn->auth_type = hci_get_auth_req(conn);
>                 cp.authentication = conn->auth_type;

Interesting. This patch is present in the sources for 3.5.7 kernel
that I have. But somehow it does not work. Fixing simple-agent did
work though.

Andrei

^ permalink raw reply

* Re: Authentication Rejected when pairing stereo headset
From: Andrey Voropaev @ 2012-12-20 10:22 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121220093742.GA6548@x220>

On Thu, Dec 20, 2012 at 10:37 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> An quicker way for you to overcome the issue is to change the user space
> side pairing call to pass "DisplayYesNo" instead of "KeyboardDisplay" to
> BlueZ. I.e. edit the simple-agent script, find the (two) occurrences of
> "KeyboardDisplay" and change them to "DisplayYesNo" and try to pair
> again.

Thanks. This trick worked (though there was only 1 KeyboardDisplay).
I've paired the device and now hcitool con reports

Connections:
    < ACL 00:1A:7D:25:2C:A4 handle 43 state 1 lm MASTER AUTH ENCRYPT


And I get

hcitool info 00:1A:7D:25:2C:A4
Requesting information ...
    BD Address:  00:1A:7D:25:2C:A4
    OUI Company: cyber-blue(HK)Ltd (00-1A-7D)
    Device Name: BTH220
    LMP Version: 2.1 (0x4) LMP Subversion: 0x14fa
    Manufacturer: Cambridge Silicon Radio (10)
    Features page 0: 0xff 0xfe 0x0f 0xc6 0x8b 0xef 0x59 0x83
        <3-slot packets> <5-slot packets> <encryption> <slot offset>
        <timing accuracy> <role switch> <hold mode> <sniff mode>
        <RSSI> <channel quality> <SCO link> <HV2 packets>
        <HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme>
        <power control> <transparent SCO> <EDR ACL 2 Mbps>
        <EDR ACL 3 Mbps> <inquiry with RSSI> <extended SCO>
        <EV4 packets> <EV5 packets> <AFH cap. slave> <3-slot EDR ACL>
        <5-slot EDR ACL> <sniff subrating> <pause encryption>
        <AFH cap. master> <EDR eSCO 2 Mbps> <EDR eSCO 3 Mbps>
        <3-slot EDR eSCO> <extended inquiry> <simple pairing>
        <encapsulated PDU> <non-flush flag> <LSTO> <inquiry TX power>
        <extended features>
    Features page 1: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00

But seems like Alsa still does not see it. I've added

 pcm.bluetooth {
  type bluetooth
  device 00:1A:7D:25:2C:A4
  profile "auto"
 }


to /etc/asound.conf, restarted alsasound, but bluetooth does not show
up among available outputs. Well, I'm almost there. The Skype has
"bluetooth" in the list of devices and it works. Just mplayer does not
want to work with option

 -ao alsa:device=bluetooth


Probably there's some capabilities problem. Any advice here? :) Sorry ...

^ permalink raw reply

* Re: Authentication Rejected when pairing stereo headset
From: Andrei Emeltchenko @ 2012-12-20  9:38 UTC (permalink / raw)
  To: Andrey Voropaev; +Cc: linux-bluetooth
In-Reply-To: <CAFOXTdf9qrtXD0GPDBFLhLX66QGQCgF_VzyS8WWz5xTAH8+0zQ@mail.gmail.com>

Hi Andrey,

On Thu, Dec 20, 2012 at 10:27:15AM +0100, Andrey Voropaev wrote:
> On Thu, Dec 20, 2012 at 10:19 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> > First of all, please don't do top posting. It messes up the thread,
> > especially when mixed with inline quoting.
> 
> Sorry. First time replying to list from gmail. Didn't pay attention to
> that little mark at the bottom of the editor :)
> 
> > Actually the hcidump helped a lot. It shows an issue on the kernel side:
> >
> >  < HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
> >      bdaddr 00:1A:7D:25:2C:A4 capability 0x04 oob 0x00 auth 0x03
> >      Capability: Reserved (OOB data not present)
> >      Authentication: Dedicated Bonding (MITM Protection)
> >  > HCI Event: Command Complete (0x0e) plen 10
> >      IO Capability Request Reply (0x01|0x002b) ncmd 1
> >      status 0x12 bdaddr 00:1A:7D:25:2C:A4
> >      Error: Invalid HCI Command Parameters
> >
> > The IO capability value 0x04 that the kernel is responding with is
> > invalid and shouldn't be sent to the controller. This was already fixed
> > quite long time ago (about 1 year ago) by the following patch from
> > Hemant Gupta: "Bluetooth: Send correct response to IO Capability Request"
> >
> > It adds the following code to the IO capability handling to avoid 0x04
> > from being sent:
> >
> >         /* Change the IO capability from KeyboardDisplay
> >          * to DisplayYesNo as it is not supported by BT spec. */
> >         cp.capability = (conn->io_capability == 0x04) ?
> >                                         0x01 : conn->io_capability;
> >
> > It seems however that your kernel is missing this patch and the right
> > way forward would be to include it.
> 
> I'm using Gentoo with "stable" version 3.5.7. Can you please tell me
> which file shall contain this patch? I'll try to find "development"
> version of kernel that contains it.

The patch is below:

commit 7a7f1e7c857959f5298020969741e389f21edbae
Author: Hemant Gupta <hemant.gupta@stericsson.com>
Date:   Mon Jan 16 13:34:29 2012 +0530

    Bluetooth: Send correct response to IO Capability Request
    
    This patch sends correct IO Capability response to remote device
    in case Local Device supports KeyBoardDisplay IO Capability as
    this capability is not valid as per BT spec for IO capability
    Request Reply Command.
    This capability is mapped to DisplayYesNo which is in accordance
    with BT spec.
    
    Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
    Acked-by: Marcel Holtmann <marcel@holtmann.org>
    Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6fb9016..041a35e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2965,7 +2965,10 @@ static inline void hci_io_capa_request_evt(struct
hci_dev *hdev, struct sk_buff
                struct hci_cp_io_capability_reply cp;
 
                bacpy(&cp.bdaddr, &ev->bdaddr);
-               cp.capability = conn->io_capability;
+               /* Change the IO capability from KeyboardDisplay
+                * to DisplayYesNo as it is not supported by BT spec. */
+               cp.capability = (conn->io_capability == 0x04) ?
+                                               0x01 :
conn->io_capability;
                conn->auth_type = hci_get_auth_req(conn);
                cp.authentication = conn->auth_type;


Best regards 
Andrei Emeltchenko 
> --
> 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

^ permalink raw reply related

* Re: Authentication Rejected when pairing stereo headset
From: Johan Hedberg @ 2012-12-20  9:37 UTC (permalink / raw)
  To: Andrey Voropaev; +Cc: linux-bluetooth
In-Reply-To: <CAFOXTdf9qrtXD0GPDBFLhLX66QGQCgF_VzyS8WWz5xTAH8+0zQ@mail.gmail.com>

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

Hi Andrey,

On Thu, Dec 20, 2012, Andrey Voropaev wrote:
> > Actually the hcidump helped a lot. It shows an issue on the kernel side:
> >
> >  < HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
> >      bdaddr 00:1A:7D:25:2C:A4 capability 0x04 oob 0x00 auth 0x03
> >      Capability: Reserved (OOB data not present)
> >      Authentication: Dedicated Bonding (MITM Protection)
> >  > HCI Event: Command Complete (0x0e) plen 10
> >      IO Capability Request Reply (0x01|0x002b) ncmd 1
> >      status 0x12 bdaddr 00:1A:7D:25:2C:A4
> >      Error: Invalid HCI Command Parameters
> >
> > The IO capability value 0x04 that the kernel is responding with is
> > invalid and shouldn't be sent to the controller. This was already fixed
> > quite long time ago (about 1 year ago) by the following patch from
> > Hemant Gupta: "Bluetooth: Send correct response to IO Capability Request"
> >
> > It adds the following code to the IO capability handling to avoid 0x04
> > from being sent:
> >
> >         /* Change the IO capability from KeyboardDisplay
> >          * to DisplayYesNo as it is not supported by BT spec. */
> >         cp.capability = (conn->io_capability == 0x04) ?
> >                                         0x01 : conn->io_capability;
> >
> > It seems however that your kernel is missing this patch and the right
> > way forward would be to include it.
> 
> I'm using Gentoo with "stable" version 3.5.7. Can you please tell me
> which file shall contain this patch? I'll try to find "development"
> version of kernel that contains it.

The file involved is net/bluetooth/hci_event.c. I've attached the patch
to this email.

An quicker way for you to overcome the issue is to change the user space
side pairing call to pass "DisplayYesNo" instead of "KeyboardDisplay" to
BlueZ. I.e. edit the simple-agent script, find the (two) occurrences of
"KeyboardDisplay" and change them to "DisplayYesNo" and try to pair
again.

Johan

[-- Attachment #2: 0001-Bluetooth-Send-correct-response-to-IO-Capability-Req.patch --]
[-- Type: text/plain, Size: 1459 bytes --]

>From 7a7f1e7c857959f5298020969741e389f21edbae Mon Sep 17 00:00:00 2001
From: Hemant Gupta <hemant.gupta@stericsson.com>
Date: Mon, 16 Jan 2012 13:34:29 +0530
Subject: [PATCH] Bluetooth: Send correct response to IO Capability Request

This patch sends correct IO Capability response to remote device
in case Local Device supports KeyBoardDisplay IO Capability as
this capability is not valid as per BT spec for IO capability
Request Reply Command.
This capability is mapped to DisplayYesNo which is in accordance
with BT spec.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_event.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6fb9016..041a35e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2965,7 +2965,10 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
 		struct hci_cp_io_capability_reply cp;
 
 		bacpy(&cp.bdaddr, &ev->bdaddr);
-		cp.capability = conn->io_capability;
+		/* Change the IO capability from KeyboardDisplay
+		 * to DisplayYesNo as it is not supported by BT spec. */
+		cp.capability = (conn->io_capability == 0x04) ?
+						0x01 : conn->io_capability;
 		conn->auth_type = hci_get_auth_req(conn);
 		cp.authentication = conn->auth_type;
 
-- 
1.8.0.2


^ permalink raw reply related

* Re: Authentication Rejected when pairing stereo headset
From: Andrey Voropaev @ 2012-12-20  9:27 UTC (permalink / raw)
  To: Andrey Voropaev, linux-bluetooth
In-Reply-To: <20121220091943.GA5862@x220>

On Thu, Dec 20, 2012 at 10:19 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> First of all, please don't do top posting. It messes up the thread,
> especially when mixed with inline quoting.

Sorry. First time replying to list from gmail. Didn't pay attention to
that little mark at the bottom of the editor :)

> Actually the hcidump helped a lot. It shows an issue on the kernel side:
>
>  < HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
>      bdaddr 00:1A:7D:25:2C:A4 capability 0x04 oob 0x00 auth 0x03
>      Capability: Reserved (OOB data not present)
>      Authentication: Dedicated Bonding (MITM Protection)
>  > HCI Event: Command Complete (0x0e) plen 10
>      IO Capability Request Reply (0x01|0x002b) ncmd 1
>      status 0x12 bdaddr 00:1A:7D:25:2C:A4
>      Error: Invalid HCI Command Parameters
>
> The IO capability value 0x04 that the kernel is responding with is
> invalid and shouldn't be sent to the controller. This was already fixed
> quite long time ago (about 1 year ago) by the following patch from
> Hemant Gupta: "Bluetooth: Send correct response to IO Capability Request"
>
> It adds the following code to the IO capability handling to avoid 0x04
> from being sent:
>
>         /* Change the IO capability from KeyboardDisplay
>          * to DisplayYesNo as it is not supported by BT spec. */
>         cp.capability = (conn->io_capability == 0x04) ?
>                                         0x01 : conn->io_capability;
>
> It seems however that your kernel is missing this patch and the right
> way forward would be to include it.

I'm using Gentoo with "stable" version 3.5.7. Can you please tell me
which file shall contain this patch? I'll try to find "development"
version of kernel that contains it.

^ permalink raw reply

* Re: Authentication Rejected when pairing stereo headset
From: Johan Hedberg @ 2012-12-20  9:19 UTC (permalink / raw)
  To: Andrey Voropaev; +Cc: linux-bluetooth
In-Reply-To: <CAFOXTde8iSouGKEVZKG-egvPUr4LAyLnFigVa6avhpqTjXNq8A@mail.gmail.com>

Hi Andrey,

First of all, please don't do top posting. It messes up the thread,
especially when mixed with inline quoting.

On Thu, Dec 20, 2012, Andrey Voropaev wrote:
> I've copied the output from hcidump -w to http://vandal.sdf-eu.org/hcidump.file
>
> So far, I'm not sure how to add -d switch to bluetoothd. It is started
> via dbus and this monster is not familiar to me. Can you please tell
> me, which file should I edit to add the switch?

Actually the hcidump helped a lot. It shows an issue on the kernel side:

 < HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
     bdaddr 00:1A:7D:25:2C:A4 capability 0x04 oob 0x00 auth 0x03
     Capability: Reserved (OOB data not present)
     Authentication: Dedicated Bonding (MITM Protection)
 > HCI Event: Command Complete (0x0e) plen 10
     IO Capability Request Reply (0x01|0x002b) ncmd 1
     status 0x12 bdaddr 00:1A:7D:25:2C:A4
     Error: Invalid HCI Command Parameters

The IO capability value 0x04 that the kernel is responding with is
invalid and shouldn't be sent to the controller. This was already fixed
quite long time ago (about 1 year ago) by the following patch from
Hemant Gupta: "Bluetooth: Send correct response to IO Capability Request"

It adds the following code to the IO capability handling to avoid 0x04
from being sent:

        /* Change the IO capability from KeyboardDisplay
         * to DisplayYesNo as it is not supported by BT spec. */
        cp.capability = (conn->io_capability == 0x04) ?
                                        0x01 : conn->io_capability;

It seems however that your kernel is missing this patch and the right
way forward would be to include it.

Johan

^ permalink raw reply

* Re: Authentication Rejected when pairing stereo headset
From: Andrey Voropaev @ 2012-12-20  9:02 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121220080447.GA561@x220>

I've copied the output from hcidump -w to http://vandal.sdf-eu.org/hcidump.file

So far, I'm not sure how to add -d switch to bluetoothd. It is started
via dbus and this monster is not familiar to me. Can you please tell
me, which file should I edit to add the switch?

Andrey

On Thu, Dec 20, 2012 at 9:04 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Andrey,
>
> On Thu, Dec 20, 2012, Andrey Voropaev wrote:
>> when I try 'simple-agent hci0 XX:XX:XX' I always get error
>>
>> Creating device failed: org.bluez.Error.AuthenticationRejected:
>> Authentication Rejected
>>
>> I'm doing everything as root, so what could be the reason for
>> "Authentication Rejected"? Incompatible hardware? Wrong configuration?
>>
>> In which direction should I be searching?
>
> The bluetoothd debug logs (run with -d switch) would be interesting as
> well as the HCI level trace (for which you can use e.g. hcidump).
>
> Johan

^ permalink raw reply

* Re: Authentication Rejected when pairing stereo headset
From: Johan Hedberg @ 2012-12-20  8:04 UTC (permalink / raw)
  To: Andrey Voropaev; +Cc: linux-bluetooth
In-Reply-To: <CAFOXTdcaRvGHesU_J7rW93Yp_5d438+x5xryCzAhY9QQL_-Y4Q@mail.gmail.com>

Hi Andrey,

On Thu, Dec 20, 2012, Andrey Voropaev wrote:
> when I try 'simple-agent hci0 XX:XX:XX' I always get error
> 
> Creating device failed: org.bluez.Error.AuthenticationRejected:
> Authentication Rejected
> 
> I'm doing everything as root, so what could be the reason for
> "Authentication Rejected"? Incompatible hardware? Wrong configuration?
> 
> In which direction should I be searching?

The bluetoothd debug logs (run with -d switch) would be interesting as
well as the HCI level trace (for which you can use e.g. hcidump).

Johan

^ permalink raw reply

* Re: Question for setting IO capability parameter for RegisterAgent
From: Johan Hedberg @ 2012-12-20  7:55 UTC (permalink / raw)
  To: Xian Pan; +Cc: linux-bluetooth
In-Reply-To: <679160B2-3B1E-4D5E-978E-E3358F6126E9@gmail.com>

Hi Xian,

On Wed, Dec 19, 2012, Xian Pan wrote:
> I confuse the relationship between the 4 pairing mode in SSP with the
> IO capability parameter for the agent. From the agent-api.txt file,
> the capability parameter can have 5 values: DisplayOnly, DisplayYesNo,
> KeyboardOnly, NoInputNoOutput and KeyboardDisplay. I think there are
> only 4 pairing mode in SSP: just works, numeric comparison, out of
> band, and passkey entry. How the 5 IO capabilities can map to those 4
> pairing modes?

Low Energy SMP based pairing introduces the additional KeyboardDisplay
IO capability. If you want to support LE it's recommended you provide
that as your agent capability and BlueZ will then automatically
downgrade it to DisplayYesNo for BR/EDR (SSP) pairing and use it as is
for LE SMP pairing.

Johan

^ permalink raw reply

* Re: [PATCH] gdbus: Fix double free when calling g_dbus_remove_all_watches
From: Tomasz Bursztyka @ 2012-12-20  7:46 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth
In-Reply-To: <CAMOw1v40+w62ToR4SKnNLnKfLzBSz_MKK1fXwoW66z7cXbTw4A@mail.gmail.com>

Hi Lucas,

> @@ -309,6 +309,9 @@ static void filter_data_call_and_free(struct filter_data *data)
>                  g_free(cb);
>          }
>
> +       g_slist_free(data->callbacks);
> +       data->callbacks = NULL;
> +
>
> why not just removing the g_free(cb)  above?
>

I did so to avoid filter_data_free() to go through the list once again,
but indeed if the list is not going to be big, it's superfluous then.

Tomasz

^ permalink raw reply

* Authentication Rejected when pairing stereo headset
From: Andrey Voropaev @ 2012-12-20  7:41 UTC (permalink / raw)
  To: linux-bluetooth

Hi! I'm trying to pair my bluetooth headset BTH220. In PC I have USB dongle

# hciconfig -a
hci0:   Type: BR/EDR  Bus: USB
   BD Address: 00:02:5B:00:1C:7B  ACL MTU: 310:10  SCO MTU: 64:8
   UP RUNNING PSCAN
   RX bytes:12771 acl:0 sco:0 events:221 errors:0
   TX bytes:1431 acl:0 sco:0 commands:96 errors:0
   Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x59 0x83
   Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
   Link policy: RSWITCH HOLD SNIFF PARK
   Link mode: SLAVE ACCEPT
   Name: 'vandal-0'
   Class: 0x420100
   Service Classes: Networking, Telephony
   Device Class: Computer, Uncategorized
   HCI Version: 2.1 (0x4)  Revision: 0x149c
   LMP Version: 2.1 (0x4)  Subversion: 0x149c
   Manufacturer: Cambridge Silicon Radio (10)


But when I try 'simple-agent hci0 XX:XX:XX' I always get error

Creating device failed: org.bluez.Error.AuthenticationRejected:
Authentication Rejected


I'm doing everything as root, so what could be the reason for
"Authentication Rejected"? Incompatible hardware? Wrong configuration?

In which direction should I be searching?

Thank you
Andrei Voropaev

^ permalink raw reply

* Question for setting IO capability parameter for RegisterAgent
From: Xian Pan @ 2012-12-20  2:18 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

I confuse the relationship between the 4 pairing mode in SSP with the IO capability parameter for the agent. From the agent-api.txt file, the capability parameter can have 5 values: DisplayOnly, DisplayYesNo, KeyboardOnly, NoInputNoOutput and KeyboardDisplay. I think there are only 4 pairing mode in SSP: just works, numeric comparison, out of band, and passkey entry. How the 5 IO capabilities can map to those 4 pairing modes?

Thanks a lot.

BEST
Xian

^ permalink raw reply

* Re: [PATCH] monitor: Fix crash in btmon
From: Marcel Holtmann @ 2012-12-20  1:31 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1355923202-16648-1-git-send-email-frederic.danis@linux.intel.com>

Hi Fred,

> When retrieving SDP records from keyboard btmon crashes (see below).
> 
> The tid_list in sdp.c is filled up by SDP Service search request,
> as Service Search responses are treated as invalid and do not free
> tid_list entries.
> 
> This is due to passing last fragment instead of complete frame to
> l2cap_frame().

patch has been applied.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH BlueZ 8/8] hog: Rename hog_device_unregister
From: Johan Hedberg @ 2012-12-19 22:01 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1355924526-961-1-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

On Wed, Dec 19, 2012, Andre Guedes wrote:
> This patch renames hog_device_unregister function to hog_unregister_
> device.
> ---
>  profiles/input/hog.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] gdbus: Fix double free when calling g_dbus_remove_all_watches
From: Lucas De Marchi @ 2012-12-19 17:50 UTC (permalink / raw)
  To: Tomasz Bursztyka; +Cc: linux-bluetooth
In-Reply-To: <1355918497-21944-1-git-send-email-tomasz.bursztyka@linux.intel.com>

On Wed, Dec 19, 2012 at 10:01 AM, Tomasz Bursztyka
<tomasz.bursztyka@linux.intel.com> wrote:
> Valgrind output:
> ==21779== Invalid free() / delete / delete[] / realloc()
> ==21779==    at 0x4A080BC: free (vg_replace_malloc.c:427)
> ==21779==    by 0x406700: filter_data_free (watch.c:285)
> ==21779==    by 0x406D92: g_dbus_remove_all_watches (watch.c:315)
> ==21779==    by 0x408787: connman_interface_finalize (interface.c:99)
> ==21779==    by 0x40EA14: main (main.c:113)
> ==21779==  Address 0x6893810 is 0 bytes inside a block of size 56 free'd
> ==21779==    at 0x4A080BC: free (vg_replace_malloc.c:427)
> ==21779==    by 0x406D81: g_dbus_remove_all_watches (watch.c:309)
> ==21779==    by 0x408787: connman_interface_finalize (interface.c:99)
> ==21779==    by 0x40EA14: main (main.c:113)
> ---
> Hi Johan,
>
> I finally put the valgrind output, since backtrace is actually useless:
>
> *** glibc detected *** ./project: double free or corruption (fasttop): 0x000000000075b5a0 ***
> ======= Backtrace: =========
> /lib64/libc.so.6(+0x7adf5)[0x7f6701e5adf5]
> ./project[0x4066b1]
> ./project[0x406d43]
> ./project[0x408738]
> ./project[0x40e9a5]
> /lib64/libc.so.6(__libc_start_main+0xfd)[0x7f6701e024bd]
> ./project[0x4053f9]
>
> Anyway, this bug was never found before for a good reason: no projects (but mine) uses g_dbus_remove_all_watches()
>
>  gdbus/watch.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gdbus/watch.c b/gdbus/watch.c
> index 9e4f994..9451d5d 100644
> --- a/gdbus/watch.c
> +++ b/gdbus/watch.c
> @@ -309,6 +309,9 @@ static void filter_data_call_and_free(struct filter_data *data)
>                 g_free(cb);
>         }
>
> +       g_slist_free(data->callbacks);
> +       data->callbacks = NULL;
> +


why not just removing the g_free(cb)  above?


Lucas De Marchi

^ permalink raw reply

* Re: [PATCH v5 11/16] sbc: Add SBC_MSBC flag to enable 15 block encoding
From: Marcel Holtmann @ 2012-12-19 17:41 UTC (permalink / raw)
  To: Frédéric Dalleau; +Cc: linux-bluetooth
In-Reply-To: <1355497417-10357-12-git-send-email-frederic.dalleau@linux.intel.com>

Hi Fred,

> The sbc API provides a flag parameter which is currently unused. This patch
> defines the SBC_MSBC flag. The meaning of this flag is to encode 15 blocks.
> ---
>  sbc/sbc.c |   35 +++++++++++++++++++++++++++--------
>  sbc/sbc.h |    3 +++
>  2 files changed, 30 insertions(+), 8 deletions(-)

I rather have it done with

	sbc_init_msbc(sbc_t *sbc, unsigned long flags);

Regards

Marcel



^ permalink raw reply

* Re: [PATCH BlueZ] build: Check for UDEV before setting rulesdir/rules_DATA
From: Anderson Lizardo @ 2012-12-19 15:05 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1355925987.1827.5.camel@aeonflux>

Hi Marcel,

On Wed, Dec 19, 2012 at 10:06 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> On a side note, you fix has the issue that EXTRA_DIST is now skipped and
> that means it would have broken make distcheck by not including the
> actual rule file.

Sorry about that. I actually seen this error (it causes a "cp
tools/hid2hci.rules tools/hid2hci.rules"). But I thought it was due to
another patch that I was going to send, that removed but forgot to
retest.

I'll pay more attention next time ;)

Thanks,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH BlueZ 1/2] audio: Fix not releasing all references to btd_adapter
From: Johan Hedberg @ 2012-12-19 14:41 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1355927348-19430-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Wed, Dec 19, 2012, Luiz Augusto von Dentz wrote:
> A2DP server now take a reference to btd_adapter which needs to be
> released properly once the adapter is unplugged.
> ---
>  profiles/audio/a2dp.c    | 44 +++++++++++++++++++++++++++++++++++---------
>  profiles/audio/a2dp.h    |  3 ++-
>  profiles/audio/manager.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
>  3 files changed, 81 insertions(+), 14 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] a2dp: Fix server unregister
From: Szymon Janc @ 2012-12-19 14:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZ+e7Wh4c2Cnexqi8KF01oFNruzFQBcLop=aaGROA3E8DQ@mail.gmail.com>

On Wednesday 19 of December 2012 16:12:39 Luiz Augusto von Dentz wrote:
> Hi Szymon,

Hi Luiz,

> 
> On Wed, Dec 19, 2012 at 3:51 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> > When removing sink or source unregister its sep and sdp record. When
> > both sink and source are unregistered also unregister a2dp server.
> > ---
> >  profiles/audio/a2dp.c    | 48 +++++++++++++++++++++++++++++++++++++++---------
> >  profiles/audio/a2dp.h    |  3 ++-
> >  profiles/audio/manager.c | 14 ++++++++++++++
> >  3 files changed, 55 insertions(+), 10 deletions(-)
> >
> > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
> > index 145b1aa..3ec8b43 100644
> > --- a/profiles/audio/a2dp.c
> > +++ b/profiles/audio/a2dp.c
> > @@ -1224,7 +1224,20 @@ static void a2dp_unregister_sep(struct a2dp_sep *sep)
> >         g_free(sep);
> >  }
> >
> > -void a2dp_unregister(struct btd_adapter *adapter)
> > +static void a2dp_unregister(struct a2dp_server *server)
> > +{
> > +       if (server->sink_enabled || server->source_enabled)
> > +               return;
> > +
> > +       avdtp_exit(server->adapter);
> > +
> > +       servers = g_slist_remove(servers, server);
> > +
> > +       btd_adapter_unref(server->adapter);
> > +       g_free(server);
> > +}
> > +
> > +void a2dp_source_unregister(struct btd_adapter *adapter)
> >  {
> >         struct a2dp_server *server;
> >
> > @@ -1232,22 +1245,39 @@ void a2dp_unregister(struct btd_adapter *adapter)
> >         if (!server)
> >                 return;
> >
> > -       g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
> > +       server->source_enabled = FALSE;
> > +
> >         g_slist_free_full(server->sources,
> >                                         (GDestroyNotify) a2dp_unregister_sep);
> > +       server->sources = NULL;
> >
> > -       avdtp_exit(adapter);
> > +       if (server->source_record_id > 0) {
> > +               remove_record_from_server(server->source_record_id);
> > +               server->source_record_id = 0;
> > +       }
> >
> > -       servers = g_slist_remove(servers, server);
> > +       a2dp_unregister(server);
> > +}
> >
> > -       if (server->source_record_id)
> > -               remove_record_from_server(server->source_record_id);
> > +void a2dp_sink_unregister(struct btd_adapter *adapter)
> > +{
> > +       struct a2dp_server *server;
> > +
> > +       server = find_server(servers, adapter);
> > +       if (!server)
> > +               return;
> > +
> > +       server->sink_enabled = FALSE;
> > +
> > +       g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
> > +       server->sinks = NULL;
> >
> > -       if (server->sink_record_id)
> > +       if (server->sink_record_id > 0) {
> >                 remove_record_from_server(server->sink_record_id);
> > +               server->sink_record_id = 0;
> > +       }
> >
> > -       btd_adapter_unref(server->adapter);
> > -       g_free(server);
> > +       a2dp_unregister(server);
> >  }
> >
> >  struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
> > diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h
> > index 54c3bf3..af5c27d 100644
> > --- a/profiles/audio/a2dp.h
> > +++ b/profiles/audio/a2dp.h
> > @@ -66,7 +66,8 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
> >
> >  int a2dp_source_register(struct btd_adapter *adapter, GKeyFile *config);
> >  int a2dp_sink_register(struct btd_adapter *adapter, GKeyFile *config);
> > -void a2dp_unregister(struct btd_adapter *adapter);
> > +void a2dp_source_unregister(struct btd_adapter *adapter);
> > +void a2dp_sink_unregister(struct btd_adapter *adapter);
> >
> >  struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
> >                                 uint8_t codec, gboolean delay_reporting,
> > diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
> > index b6b2385..5e30fa8 100644
> > --- a/profiles/audio/manager.c
> > +++ b/profiles/audio/manager.c
> > @@ -348,6 +348,12 @@ static int a2dp_source_server_probe(struct btd_profile *p,
> >         return a2dp_source_register(adapter, config);
> >  }
> >
> > +static void a2dp_source_server_remove(struct btd_profile *p,
> > +                                               struct btd_adapter *adapter)
> > +{
> > +       a2dp_source_unregister(adapter);
> > +}
> > +
> >  static int a2dp_sink_server_probe(struct btd_profile *p,
> >                                                 struct btd_adapter *adapter)
> >  {
> > @@ -365,6 +371,12 @@ static int a2dp_sink_server_probe(struct btd_profile *p,
> >         return a2dp_sink_register(adapter, config);
> >  }
> >
> > +static void a2dp_sink_server_remove(struct btd_profile *p,
> > +                                               struct btd_adapter *adapter)
> > +{
> > +       a2dp_sink_unregister(adapter);
> > +}
> > +
> >  static int avrcp_server_probe(struct btd_profile *p,
> >                                                 struct btd_adapter *adapter)
> >  {
> > @@ -446,6 +458,7 @@ static struct btd_profile a2dp_source_profile = {
> >         .disconnect     = a2dp_source_disconnect,
> >
> >         .adapter_probe  = a2dp_source_server_probe,
> > +       .adapter_remove = a2dp_source_server_remove,
> >  };
> >
> >  static struct btd_profile a2dp_sink_profile = {
> > @@ -461,6 +474,7 @@ static struct btd_profile a2dp_sink_profile = {
> >         .disconnect     = a2dp_sink_disconnect,
> >
> >         .adapter_probe  = a2dp_sink_server_probe,
> > +       .adapter_remove = a2dp_sink_server_remove,
> >  };
> >
> >  static struct btd_profile avrcp_profile = {
> > --
> > 1.8.0
> 
> I have a very similar fix to push, I end up doing it because the whole
> btd_adapter reference got broken so I would like to push it if you
> don't mind.

I don't :-)

-- 
BR
Szymon Janc

^ permalink raw reply

* [PATCH BlueZ 2/2] audio: Remove adapter list
From: Luiz Augusto von Dentz @ 2012-12-19 14:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1355927348-19430-1-git-send-email-luiz.dentz@gmail.com>

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

btd_adapter is directly referenced by the drivers so there is no point
on keeping a list just for the audio adapters.
---
 profiles/audio/manager.c | 180 ++++++-----------------------------------------
 1 file changed, 21 insertions(+), 159 deletions(-)

diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index bb5688f..9ad3bf6 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -75,7 +75,6 @@ struct audio_adapter {
 };
 
 static GKeyFile *config = NULL;
-static GSList *adapters = NULL;
 static GSList *devices = NULL;
 
 static struct enabled_interfaces enabled = {
@@ -84,19 +83,6 @@ static struct enabled_interfaces enabled = {
 	.control	= TRUE,
 };
 
-static struct audio_adapter *find_adapter(GSList *list,
-					struct btd_adapter *btd_adapter)
-{
-	for (; list; list = list->next) {
-		struct audio_adapter *adapter = list->data;
-
-		if (adapter->btd_adapter == btd_adapter)
-			return adapter;
-	}
-
-	return NULL;
-}
-
 static struct audio_device *get_audio_dev(struct btd_device *device)
 {
 	return manager_get_audio_device(device, TRUE);
@@ -284,191 +270,66 @@ static int avrcp_control_disconnect(struct btd_device *dev,
 	return control_disconnect(audio_dev);
 }
 
-static struct audio_adapter *audio_adapter_ref(struct audio_adapter *adp)
-{
-	adp->ref++;
-
-	DBG("%p: ref=%d", adp, adp->ref);
-
-	return adp;
-}
-
-static void audio_adapter_unref(struct audio_adapter *adp)
-{
-	adp->ref--;
-
-	DBG("%p: ref=%d", adp, adp->ref);
-
-	if (adp->ref > 0)
-		return;
-
-	adapters = g_slist_remove(adapters, adp);
-	btd_adapter_unref(adp->btd_adapter);
-	g_free(adp);
-}
-
-static struct audio_adapter *audio_adapter_create(struct btd_adapter *adapter)
-{
-	struct audio_adapter *adp;
-
-	adp = g_new0(struct audio_adapter, 1);
-	adp->btd_adapter = btd_adapter_ref(adapter);
-
-	return audio_adapter_ref(adp);
-}
-
-static struct audio_adapter *audio_adapter_get(struct btd_adapter *adapter)
-{
-	struct audio_adapter *adp;
-
-	adp = find_adapter(adapters, adapter);
-	if (!adp) {
-		adp = audio_adapter_create(adapter);
-		adapters = g_slist_append(adapters, adp);
-	} else
-		audio_adapter_ref(adp);
-
-	return adp;
-}
-
 static int a2dp_source_server_probe(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-	int err;
-
-	DBG("path %s", path);
-
-	adp = audio_adapter_get(adapter);
-	if (!adp)
-		return -EINVAL;
-
-	err = a2dp_source_register(adapter, config);
-	if (err < 0)
-		audio_adapter_unref(adp);
+	DBG("path %s", adapter_get_path(adapter));
 
-	return err;
+	return a2dp_source_register(adapter, config);
 }
 
 static void a2dp_source_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-
-	DBG("path %s", path);
-
-	adp = find_adapter(adapters, adapter);
-	if (!adp)
-		return;
+	DBG("path %s", adapter_get_path(adapter));
 
 	a2dp_source_unregister(adapter);
-	audio_adapter_unref(adp);
 }
 
 static int a2dp_sink_server_probe(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-	int err;
-
-	DBG("path %s", path);
-
-	adp = audio_adapter_get(adapter);
-	if (!adp)
-		return -EINVAL;
-
-	err = a2dp_sink_register(adapter, config);
-	if (err < 0)
-		audio_adapter_unref(adp);
+	DBG("path %s", adapter_get_path(adapter));
 
-	return err;
+	return a2dp_sink_register(adapter, config);
 }
 
 static void a2dp_sink_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-
-	DBG("path %s", path);
-
-	adp = find_adapter(adapters, adapter);
-	if (!adp)
-		return;
+	DBG("path %s", adapter_get_path(adapter));
 
 	a2dp_sink_unregister(adapter);
-	audio_adapter_unref(adp);
 }
 
 static int avrcp_server_probe(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-	int err;
-
-	DBG("path %s", path);
-
-	adp = audio_adapter_get(adapter);
-	if (!adp)
-		return -EINVAL;
-
-	err = avrcp_register(adapter, config);
-	if (err < 0)
-		audio_adapter_unref(adp);
+	DBG("path %s", adapter_get_path(adapter));
 
-	return err;
+	return avrcp_register(adapter, config);
 }
 
 static void avrcp_server_remove(struct btd_profile *p,
 						struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	const gchar *path = adapter_get_path(adapter);
-
-	DBG("path %s", path);
-
-	adp = find_adapter(adapters, adapter);
-	if (!adp)
-		return;
+	DBG("path %s", adapter_get_path(adapter));
 
-	avrcp_unregister(adapter);
-	audio_adapter_unref(adp);
+	return avrcp_unregister(adapter);
 }
 
 static int media_server_probe(struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-	int err;
-
 	DBG("path %s", adapter_get_path(adapter));
 
-	adp = audio_adapter_get(adapter);
-	if (!adp)
-		return -EINVAL;
-
-	err = media_register(adapter);
-	if (err < 0)
-		audio_adapter_unref(adp);
-
-	return err;
+	return media_register(adapter);
 }
 
 static void media_server_remove(struct btd_adapter *adapter)
 {
-	struct audio_adapter *adp;
-
 	DBG("path %s", adapter_get_path(adapter));
 
-	adp = find_adapter(adapters, adapter);
-	if (!adp)
-		return;
-
 	media_unregister(adapter);
-	audio_adapter_unref(adp);
 }
 
 static struct btd_profile a2dp_source_profile = {
@@ -643,16 +504,17 @@ struct audio_device *manager_get_audio_device(struct btd_device *device,
 	return dev;
 }
 
-void manager_set_fast_connectable(gboolean enable)
+static void set_fast_connectable(struct btd_adapter *adapter, gpointer user_data)
 {
-	GSList *l;
+	gboolean enable = GPOINTER_TO_UINT(user_data);
 
-	for (l = adapters; l != NULL; l = l->next) {
-		struct audio_adapter *adapter = l->data;
+	if (btd_adapter_set_fast_connectable(adapter, enable))
+		error("Changing fast connectable for hci%d failed",
+						adapter_get_dev_id(adapter));
+}
 
-		if (btd_adapter_set_fast_connectable(adapter->btd_adapter,
-								enable))
-			error("Changing fast connectable for hci%d failed",
-				adapter_get_dev_id(adapter->btd_adapter));
-	}
+void manager_set_fast_connectable(gboolean enable)
+{
+	manager_foreach_adapter(set_fast_connectable,
+						GUINT_TO_POINTER(enable));
 }
-- 
1.7.11.7


^ permalink raw reply related

* [PATCH BlueZ 1/2] audio: Fix not releasing all references to btd_adapter
From: Luiz Augusto von Dentz @ 2012-12-19 14:29 UTC (permalink / raw)
  To: linux-bluetooth

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

A2DP server now take a reference to btd_adapter which needs to be
released properly once the adapter is unplugged.
---
 profiles/audio/a2dp.c    | 44 +++++++++++++++++++++++++++++++++++---------
 profiles/audio/a2dp.h    |  3 ++-
 profiles/audio/manager.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 3 files changed, 81 insertions(+), 14 deletions(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 145b1aa..46f41a6 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1224,7 +1224,16 @@ static void a2dp_unregister_sep(struct a2dp_sep *sep)
 	g_free(sep);
 }
 
-void a2dp_unregister(struct btd_adapter *adapter)
+static void a2dp_server_unregister(struct a2dp_server *server)
+{
+	avdtp_exit(server->adapter);
+
+	servers = g_slist_remove(servers, server);
+	btd_adapter_unref(server->adapter);
+	g_free(server);
+}
+
+void a2dp_sink_unregister(struct btd_adapter *adapter)
 {
 	struct a2dp_server *server;
 
@@ -1233,21 +1242,38 @@ void a2dp_unregister(struct btd_adapter *adapter)
 		return;
 
 	g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
-	g_slist_free_full(server->sources,
-					(GDestroyNotify) a2dp_unregister_sep);
-
-	avdtp_exit(adapter);
 
-	servers = g_slist_remove(servers, server);
+	if (server->sink_record_id) {
+		remove_record_from_server(server->sink_record_id);
+		server->sink_record_id = 0;
+	}
 
 	if (server->source_record_id)
+		return;
+
+	a2dp_server_unregister(server);
+}
+
+void a2dp_source_unregister(struct btd_adapter *adapter)
+{
+	struct a2dp_server *server;
+
+	server = find_server(servers, adapter);
+	if (!server)
+		return;
+
+	g_slist_free_full(server->sources,
+					(GDestroyNotify) a2dp_unregister_sep);
+
+	if (server->source_record_id) {
 		remove_record_from_server(server->source_record_id);
+		server->source_record_id = 0;
+	}
 
 	if (server->sink_record_id)
-		remove_record_from_server(server->sink_record_id);
+		return;
 
-	btd_adapter_unref(server->adapter);
-	g_free(server);
+	a2dp_server_unregister(server);
 }
 
 struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h
index 54c3bf3..4819f7b 100644
--- a/profiles/audio/a2dp.h
+++ b/profiles/audio/a2dp.h
@@ -65,8 +65,9 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
 					void *user_data);
 
 int a2dp_source_register(struct btd_adapter *adapter, GKeyFile *config);
+void a2dp_source_unregister(struct btd_adapter *adapter);
 int a2dp_sink_register(struct btd_adapter *adapter, GKeyFile *config);
-void a2dp_unregister(struct btd_adapter *adapter);
+void a2dp_sink_unregister(struct btd_adapter *adapter);
 
 struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
 				uint8_t codec, gboolean delay_reporting,
diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index b6b2385..bb5688f 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -336,6 +336,7 @@ static int a2dp_source_server_probe(struct btd_profile *p,
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
+	int err;
 
 	DBG("path %s", path);
 
@@ -343,9 +344,27 @@ static int a2dp_source_server_probe(struct btd_profile *p,
 	if (!adp)
 		return -EINVAL;
 
-	audio_adapter_unref(adp); /* Referenced by a2dp server */
+	err = a2dp_source_register(adapter, config);
+	if (err < 0)
+		audio_adapter_unref(adp);
+
+	return err;
+}
+
+static void a2dp_source_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
+{
+	struct audio_adapter *adp;
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
 
-	return a2dp_source_register(adapter, config);
+	adp = find_adapter(adapters, adapter);
+	if (!adp)
+		return;
+
+	a2dp_source_unregister(adapter);
+	audio_adapter_unref(adp);
 }
 
 static int a2dp_sink_server_probe(struct btd_profile *p,
@@ -353,6 +372,7 @@ static int a2dp_sink_server_probe(struct btd_profile *p,
 {
 	struct audio_adapter *adp;
 	const gchar *path = adapter_get_path(adapter);
+	int err;
 
 	DBG("path %s", path);
 
@@ -360,9 +380,27 @@ static int a2dp_sink_server_probe(struct btd_profile *p,
 	if (!adp)
 		return -EINVAL;
 
-	audio_adapter_unref(adp); /* Referenced by a2dp server */
+	err = a2dp_sink_register(adapter, config);
+	if (err < 0)
+		audio_adapter_unref(adp);
+
+	return err;
+}
+
+static void a2dp_sink_server_remove(struct btd_profile *p,
+						struct btd_adapter *adapter)
+{
+	struct audio_adapter *adp;
+	const gchar *path = adapter_get_path(adapter);
+
+	DBG("path %s", path);
 
-	return a2dp_sink_register(adapter, config);
+	adp = find_adapter(adapters, adapter);
+	if (!adp)
+		return;
+
+	a2dp_sink_unregister(adapter);
+	audio_adapter_unref(adp);
 }
 
 static int avrcp_server_probe(struct btd_profile *p,
@@ -446,6 +484,7 @@ static struct btd_profile a2dp_source_profile = {
 	.disconnect	= a2dp_source_disconnect,
 
 	.adapter_probe	= a2dp_source_server_probe,
+	.adapter_remove	= a2dp_source_server_remove,
 };
 
 static struct btd_profile a2dp_sink_profile = {
@@ -461,6 +500,7 @@ static struct btd_profile a2dp_sink_profile = {
 	.disconnect	= a2dp_sink_disconnect,
 
 	.adapter_probe	= a2dp_sink_server_probe,
+	.adapter_remove	= a2dp_sink_server_remove,
 };
 
 static struct btd_profile avrcp_profile = {
-- 
1.7.11.7


^ permalink raw reply related

* Re: [PATCH] a2dp: Fix server unregister
From: Luiz Augusto von Dentz @ 2012-12-19 14:12 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1355925094-22695-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Wed, Dec 19, 2012 at 3:51 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> When removing sink or source unregister its sep and sdp record. When
> both sink and source are unregistered also unregister a2dp server.
> ---
>  profiles/audio/a2dp.c    | 48 +++++++++++++++++++++++++++++++++++++++---------
>  profiles/audio/a2dp.h    |  3 ++-
>  profiles/audio/manager.c | 14 ++++++++++++++
>  3 files changed, 55 insertions(+), 10 deletions(-)
>
> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
> index 145b1aa..3ec8b43 100644
> --- a/profiles/audio/a2dp.c
> +++ b/profiles/audio/a2dp.c
> @@ -1224,7 +1224,20 @@ static void a2dp_unregister_sep(struct a2dp_sep *sep)
>         g_free(sep);
>  }
>
> -void a2dp_unregister(struct btd_adapter *adapter)
> +static void a2dp_unregister(struct a2dp_server *server)
> +{
> +       if (server->sink_enabled || server->source_enabled)
> +               return;
> +
> +       avdtp_exit(server->adapter);
> +
> +       servers = g_slist_remove(servers, server);
> +
> +       btd_adapter_unref(server->adapter);
> +       g_free(server);
> +}
> +
> +void a2dp_source_unregister(struct btd_adapter *adapter)
>  {
>         struct a2dp_server *server;
>
> @@ -1232,22 +1245,39 @@ void a2dp_unregister(struct btd_adapter *adapter)
>         if (!server)
>                 return;
>
> -       g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
> +       server->source_enabled = FALSE;
> +
>         g_slist_free_full(server->sources,
>                                         (GDestroyNotify) a2dp_unregister_sep);
> +       server->sources = NULL;
>
> -       avdtp_exit(adapter);
> +       if (server->source_record_id > 0) {
> +               remove_record_from_server(server->source_record_id);
> +               server->source_record_id = 0;
> +       }
>
> -       servers = g_slist_remove(servers, server);
> +       a2dp_unregister(server);
> +}
>
> -       if (server->source_record_id)
> -               remove_record_from_server(server->source_record_id);
> +void a2dp_sink_unregister(struct btd_adapter *adapter)
> +{
> +       struct a2dp_server *server;
> +
> +       server = find_server(servers, adapter);
> +       if (!server)
> +               return;
> +
> +       server->sink_enabled = FALSE;
> +
> +       g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
> +       server->sinks = NULL;
>
> -       if (server->sink_record_id)
> +       if (server->sink_record_id > 0) {
>                 remove_record_from_server(server->sink_record_id);
> +               server->sink_record_id = 0;
> +       }
>
> -       btd_adapter_unref(server->adapter);
> -       g_free(server);
> +       a2dp_unregister(server);
>  }
>
>  struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
> diff --git a/profiles/audio/a2dp.h b/profiles/audio/a2dp.h
> index 54c3bf3..af5c27d 100644
> --- a/profiles/audio/a2dp.h
> +++ b/profiles/audio/a2dp.h
> @@ -66,7 +66,8 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
>
>  int a2dp_source_register(struct btd_adapter *adapter, GKeyFile *config);
>  int a2dp_sink_register(struct btd_adapter *adapter, GKeyFile *config);
> -void a2dp_unregister(struct btd_adapter *adapter);
> +void a2dp_source_unregister(struct btd_adapter *adapter);
> +void a2dp_sink_unregister(struct btd_adapter *adapter);
>
>  struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
>                                 uint8_t codec, gboolean delay_reporting,
> diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
> index b6b2385..5e30fa8 100644
> --- a/profiles/audio/manager.c
> +++ b/profiles/audio/manager.c
> @@ -348,6 +348,12 @@ static int a2dp_source_server_probe(struct btd_profile *p,
>         return a2dp_source_register(adapter, config);
>  }
>
> +static void a2dp_source_server_remove(struct btd_profile *p,
> +                                               struct btd_adapter *adapter)
> +{
> +       a2dp_source_unregister(adapter);
> +}
> +
>  static int a2dp_sink_server_probe(struct btd_profile *p,
>                                                 struct btd_adapter *adapter)
>  {
> @@ -365,6 +371,12 @@ static int a2dp_sink_server_probe(struct btd_profile *p,
>         return a2dp_sink_register(adapter, config);
>  }
>
> +static void a2dp_sink_server_remove(struct btd_profile *p,
> +                                               struct btd_adapter *adapter)
> +{
> +       a2dp_sink_unregister(adapter);
> +}
> +
>  static int avrcp_server_probe(struct btd_profile *p,
>                                                 struct btd_adapter *adapter)
>  {
> @@ -446,6 +458,7 @@ static struct btd_profile a2dp_source_profile = {
>         .disconnect     = a2dp_source_disconnect,
>
>         .adapter_probe  = a2dp_source_server_probe,
> +       .adapter_remove = a2dp_source_server_remove,
>  };
>
>  static struct btd_profile a2dp_sink_profile = {
> @@ -461,6 +474,7 @@ static struct btd_profile a2dp_sink_profile = {
>         .disconnect     = a2dp_sink_disconnect,
>
>         .adapter_probe  = a2dp_sink_server_probe,
> +       .adapter_remove = a2dp_sink_server_remove,
>  };
>
>  static struct btd_profile avrcp_profile = {
> --
> 1.8.0

I have a very similar fix to push, I end up doing it because the whole
btd_adapter reference got broken so I would like to push it if you
don't mind.


--
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] monitor: Fix crash in btmon
From: Marcel Holtmann @ 2012-12-19 14:07 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1355923202-16648-1-git-send-email-frederic.danis@linux.intel.com>

Hi Fred,

> When retrieving SDP records from keyboard btmon crashes (see below).
> 
> The tid_list in sdp.c is filled up by SDP Service search request,
> as Service Search responses are treated as invalid and do not free
> tid_list entries.
> 
> This is due to passing last fragment instead of complete frame to
> l2cap_frame().

please send me the binary log file privately. I like to have a look at
this in detail. What device have you tested this against?

Regards

Marcel



^ permalink raw reply

* Re: [PATCH BlueZ] build: Check for UDEV before setting rulesdir/rules_DATA
From: Marcel Holtmann @ 2012-12-19 14:06 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1355921804-12533-1-git-send-email-anderson.lizardo@openbossa.org>

Hi Anderson,

> Without this check, UDEV_DIR will be empty and an empty "/rules.d"
> directory is created on DESTDIR.
> ---
>  Makefile.am |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Makefile.am b/Makefile.am
> index a482b54..c10c1fa 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -174,6 +174,7 @@ test_scripts =
>  include Makefile.tools
>  include Makefile.obexd
>  
> +if UDEV
>  rulesdir = @UDEV_DIR@/rules.d
>  
>  udev_files =
> @@ -187,6 +188,7 @@ EXTRA_DIST += tools/hid2hci.rules
>  rules_DATA = $(foreach file,$(udev_files), tools/97-$(notdir $(file)))
>  
>  CLEANFILES += $(rules_DATA)
> +endif

great catch, but I fixed this differently by hiding this behind the
HID2HCI condition.

On a side note, you fix has the issue that EXTRA_DIST is now skipped and
that means it would have broken make distcheck by not including the
actual rule file.

Regards

Marcel



^ permalink raw reply

* Re: hci_emu and hci_vhci
From: Marcel Holtmann @ 2012-12-19 13:57 UTC (permalink / raw)
  To: Kevin Wilson; +Cc: linux-bluetooth
In-Reply-To: <CAGXs5wVmFirtMq6ZeUna7q0hfxpedMOcPEEVuD2r09Whet1Z=A@mail.gmail.com>

Hi Kevin,

> What can we test with hci_emu and hci_vhci ?
> 
> When I tried:
> modprobe hci_vhci
> and then
> ./hciemu -n 10
> 
> I see with hciconfig that a virtual device was created (it shows Bus: VIRTUAL)
> When I have no other BT physical device, which tests can I do with the virtual
> 	hci device ?
> 	
> When I try :
> hciconfig scan
> or
> hciconfig inq
> I get this answer in both cases:
> Inquiry failed: Invalid request code
> 
> Also when I set both PSCAN/ISCAN bit in it, I cannot see it when scanning
> from other machine with physical BT devices.

of course not. This one is virtual and does not magically transmit radio
waves ;)

> So I assume testing with pan --connect, etc also won't work.

If you start two entities of hciemu which each its own port number, then
you can connect between them. Of course if they are running on the same
host, then the network interfaces will not see any traffic. Local
traffic goes over the loopback interface.

> Are there any tests which we can do with a virtual
> hci device ?

Plenty of them, but you need a full piconet emulation for anything
further.

Regards

Marcel



^ 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