Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 2/2] Bluetooth: Deal with USB devices that are faking CSR vendor
From: Marcel Holtmann @ 2014-01-03 11:02 UTC (permalink / raw)
  To: linux-bluetooth

There exists a set of Bluetooth USB devices that show up on the USB
bus as 0a12:0001 and identify themselves as devices from CSR. However
they are not. When sending Read Local Version command they now have
a split personality and say they are from Broadcom.

  < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
  > HCI Event: Command Complete (0x0e) plen 12
      Read Local Version Information (0x04|0x0001) ncmd 1
      status 0x00
      HCI Version: 2.0 (0x3) HCI Revision: 0x3000
      LMP Version: 2.0 (0x3) LMP Subversion: 0x420b
      Manufacturer: Broadcom Corporation (15)

The assumption is that they are neither CSR nor Broadcom based devices
and that they are designed and manufactured by someone else.

For the most parts they follow the Bluetooth HCI specification and
can be used as standard Bluetooth devices. However they have the
minor problem that the Delete Stored Link Key command is not working
as it should.

During the Bluetooth controller setup, this command is needed if
stored link keys are supported. For these devices it has to be
assumed that this is broken and so just set a quirk to clearly
indicate the behavior. After that the setup can just proceed.

Now the trick part is to detect these faulty devices since we do
not want to punish all CSR and all Broadcom devices. The original
devices do actually work according to the specification.

What is known so far is that these broken devices set the USB bcdDevice
revision information to 1.0 or less.

T:  Bus=02 Lev=01 Prnt=01 Port=08 Cnt=03 Dev#=  9 Spd=12   MxCh= 0
D:  Ver= 2.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev= 1.00
S:  Manufacturer=Bluetooth v2.0
S:  Product=Bluetooth V2.0 Dongle

T:  Bus=05 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0a12 ProdID=0001 Rev= 0.07

In case of CSR devices, the bcdDevice revision contains the firmware
build ID and that is normally a higher value. If the bcdDevice revision
is 1.0 or less, then an extra setup stage is checking if Read Local
Version returns CSR manufacturer information. If not then it will be
assumed that this is a broken device and the Delete Stored Link Key
command will be marked as broken.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 drivers/bluetooth/btusb.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index bfbcc5a772a6..e7b36beca42c 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -964,6 +964,45 @@ static int btusb_setup_bcm92035(struct hci_dev *hdev)
 	return 0;
 }
 
+static int btusb_setup_csr(struct hci_dev *hdev)
+{
+	struct hci_rp_read_local_version *rp;
+	struct sk_buff *skb;
+	int ret;
+
+	BT_DBG("%s", hdev->name);
+
+	skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
+			     HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		BT_ERR("Reading local version failed (%ld)", -PTR_ERR(skb));
+		return -PTR_ERR(skb);
+	}
+
+	rp = (struct hci_rp_read_local_version *) skb->data;
+
+	if (!rp->status) {
+		if (le16_to_cpu(rp->manufacturer) != 10) {
+			/* Clear the reset quirk since this is not an actual
+			 * early Bluetooth 1.1 device from CSR.
+			 */
+			clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+
+			/* These fake CSR controllers have all a broken
+			 * stored link key handling and so just disable it.
+			 */
+			set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY,
+				&hdev->quirks);
+		}
+	}
+
+	ret = -bt_to_errno(rp->status);
+
+	kfree_skb(skb);
+
+	return ret;
+}
+
 struct intel_version {
 	u8 status;
 	u8 hw_platform;
@@ -1464,10 +1503,15 @@ static int btusb_probe(struct usb_interface *intf,
 
 	if (id->driver_info & BTUSB_CSR) {
 		struct usb_device *udev = data->udev;
+		u16 bcdDevice = le16_to_cpu(udev->descriptor.bcdDevice);
 
 		/* Old firmware would otherwise execute USB reset */
-		if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
+		if (bcdDevice < 0x117)
 			set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
+
+		/* Fake CSR devices with broken commands */
+		if (bcdDevice <= 0x100)
+			hdev->setup = btusb_setup_csr;
 	}
 
 	if (id->driver_info & BTUSB_SNIFFER) {
-- 
1.8.4.2


^ permalink raw reply related

* Re: [PATCH BlueZ v2 01/10] android/ipc: Add initial code for audio IPC
From: Luiz Augusto von Dentz @ 2014-01-03 11:09 UTC (permalink / raw)
  To: Andrei Emeltchenko, Luiz Augusto von Dentz,
	linux-bluetooth@vger.kernel.org
In-Reply-To: <20140103105642.GA9809@aemeltch-MOBL1>

Hi Andrei,

On Fri, Jan 3, 2014 at 12:56 PM, Andrei Emeltchenko
<andrei.emeltchenko.news@gmail.com> wrote:
> Hi Luiz,
>
> On Thu, Jan 02, 2014 at 01:58:25PM +0200, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> This add initial code for listen and accept connections on the abstract
>> socket defined for the audio IPC.
>> ---
>> v2: Split audio IPC services for HAL services and fix invalid messages or
>> disconnections causing the daemon to exit. The audio HAL is independent of
>> bluetooth and should only affect A2DP service.
>>
>>  android/hal-msg.h |  1 +
>>  android/ipc.c     | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
>>  android/ipc.h     |  3 +++
>>  3 files changed, 76 insertions(+), 6 deletions(-)
>>
>> diff --git a/android/hal-msg.h b/android/hal-msg.h
>> index c351501..b14eced 100644
>> --- a/android/hal-msg.h
>> +++ b/android/hal-msg.h
>> @@ -24,6 +24,7 @@
>>  #define BLUEZ_HAL_MTU 1024
>>
>>  static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
>> +static const char BLUEZ_AUDIO_SK_PATH[] = "\0bluez_audio_socket";
>>
>>  struct hal_hdr {
>>       uint8_t  service_id;
>> diff --git a/android/ipc.c b/android/ipc.c
>> index 9e8ccc3..4c5a77e 100644
>> --- a/android/ipc.c
>> +++ b/android/ipc.c
>> @@ -49,6 +49,7 @@ static struct service_handler services[HAL_SERVICE_ID_MAX + 1];
>>
>>  static GIOChannel *cmd_io = NULL;
>>  static GIOChannel *notif_io = NULL;
>> +static GIOChannel *audio_io = NULL;
>>
>>  static void ipc_handle_msg(const void *buf, ssize_t len)
>>  {
>> @@ -145,7 +146,8 @@ static gboolean notif_watch_cb(GIOChannel *io, GIOCondition cond,
>>       return FALSE;
>>  }
>>
>> -static GIOChannel *connect_hal(GIOFunc connect_cb)
>> +static GIOChannel *ipc_connect(const char *path, size_t size,
>> +                                                     GIOFunc connect_cb)
>>  {
>
> Does it make sense for better understanding to split patch to two parts:
> one is changing connect_hal to ipc_connect and another adding audio ipc?

Well, it is quite self contained and the functionality doesn't change
much as Im just passing the path of the socket to function that is
static instead of copying connect_hal so I considered it too trivial
to have it separated. Note that sometimes we do bother to split even
trivial changes when the patches get way too big and convoluted to be
able to spot this minor details, this patch though has less than 100
lines changes.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: BLE for Android
From: bill dr @ 2014-01-03 11:39 UTC (permalink / raw)
  To: Andrei Emeltchenko, Luiz Augusto von Dentz, bill dr,
	linux-bluetooth@vger.kernel.org
In-Reply-To: <20140103110209.GB9809@aemeltch-MOBL1>

Hi all,
Thank you Luiz and Andrei for your responses.

@Andrei : I am aware that the latest android version supports "as best
as it can" BLE. But I have a constaint to use 4.1 Android only.


That lead us to my second question : what should I do to add such support ?

If I have understood correctly the HAL Bluetooth (in Bluez package) is
different from Android HAL.
so to have BLE support in Android 4.1 I have to:

1- Adding the last Bluez package and compile it.
2- make changes to Android Bluetooth HAL or just add a JNI interface
wrapping the Bluetooth HAL one ?
3- make changes to system service to support BLE.
4- make changes to Android SDK to export these changes to developpers.

Is it correct ? is there more straightforward way ?
especially about the second point and the confusion between Bluetooth
HAL and Android HAL.
Thank you for your help.

Regards,
Bilel

2014/1/3 Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>:
> Hi all,
>
> On Tue, Dec 31, 2013 at 02:02:59PM +0200, Luiz Augusto von Dentz wrote:
>> Hi,
>>
>> On Tue, Dec 31, 2013 at 1:47 PM, bill dr <bilel.dr@gmail.com> wrote:
>> > Hi,
>> >
>> > I am trying to port BLE into a 4.1.1 android device.
>
> There is no sense to make this work, use the latest Android instead, many
> things should be already working ...
>
> Best regards
> Andrei Emeltchenko
>
>> > I found that bluez git repository contains an android directory.
>> > Could you explain me or point me to any link or document that explain
>> > how to use this directory. Is there any HAL implementation already
>> > done. Or this directory contains only "bluedroid" code ?
>> >
>> > Thank you !
>>
>> Checkout the README:
>> https://git.kernel.org/cgit/bluetooth/bluez.git/tree/android/README
>>
>> It is a clean implementation of bluetooth HAL, so no bluedroid code
>> bellow the HAL interface, above HAL is considered Android itself even
>> though it may actually contain bluetooth specific bits here and there.
>> Btw, we are almost ready to start looking at the BLE HAL.
>>
>>
>>
>> --
>> Luiz Augusto von Dentz
>> --
>> 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

* Re: BLE for Android
From: Andrei Emeltchenko @ 2014-01-03 11:55 UTC (permalink / raw)
  To: bill dr; +Cc: Luiz Augusto von Dentz, linux-bluetooth@vger.kernel.org
In-Reply-To: <CAHTi60E1Qo1XNM+hyaMo9zWbVpNoKYqD8L4MtdbqPEZ43yJWuA@mail.gmail.com>

Hi Bilel,

On Fri, Jan 03, 2014 at 12:39:04PM +0100, bill dr wrote:
> Hi all,
> Thank you Luiz and Andrei for your responses.
> 
> @Andrei : I am aware that the latest android version supports "as best
> as it can" BLE. But I have a constaint to use 4.1 Android only.
> 
> 
> That lead us to my second question : what should I do to add such support ?
> 
> If I have understood correctly the HAL Bluetooth (in Bluez package) is
> different from Android HAL.

There is no Bluetooth HAL in Android 4.1, HAL appeared when Android moved
to Bluedroid stack in version 4.2.

> so to have BLE support in Android 4.1 I have to:
> 
> 1- Adding the last Bluez package and compile it.
> 2- make changes to Android Bluetooth HAL or just add a JNI interface
> wrapping the Bluetooth HAL one ?
> 3- make changes to system service to support BLE.
> 4- make changes to Android SDK to export these changes to developpers.

Looks too much work for nothing.

> Is it correct ? is there more straightforward way ?
> especially about the second point and the confusion between Bluetooth
> HAL and Android HAL.

Forget about HAL, hack JNI ....

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* Re: BLE for Android
From: bill dr @ 2014-01-03 12:02 UTC (permalink / raw)
  To: Andrei Emeltchenko, bill dr, Luiz Augusto von Dentz,
	linux-bluetooth@vger.kernel.org
In-Reply-To: <20140103115518.GC9809@aemeltch-MOBL1>

2014/1/3 Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>:
> Hi Bilel,
>
> On Fri, Jan 03, 2014 at 12:39:04PM +0100, bill dr wrote:
>> Hi all,
>> Thank you Luiz and Andrei for your responses.
>>
>> @Andrei : I am aware that the latest android version supports "as best
>> as it can" BLE. But I have a constaint to use 4.1 Android only.
>>
>>
>> That lead us to my second question : what should I do to add such support ?
>>
>> If I have understood correctly the HAL Bluetooth (in Bluez package) is
>> different from Android HAL.
>
> There is no Bluetooth HAL in Android 4.1, HAL appeared when Android moved
> to Bluedroid stack in version 4.2.
>

OK I got it. Indeed, my confusion comes from bluedroid

>> so to have BLE support in Android 4.1 I have to:
>>
>> 1- Adding the last Bluez package and compile it.
>> 2- make changes to Android Bluetooth HAL or just add a JNI interface
>> wrapping the Bluetooth HAL one ?
>> 3- make changes to system service to support BLE.
>> 4- make changes to Android SDK to export these changes to developpers.
>
> Looks too much work for nothing.

isn't it required to have a proper support ?
indeed it is too munch work. is there any alternative ?

>
>> Is it correct ? is there more straightforward way ?
>> especially about the second point and the confusion between Bluetooth
>> HAL and Android HAL.
>
> Forget about HAL, hack JNI ....

OK.

>
> Best regards
> Andrei Emeltchenko
>

Thank you.

^ permalink raw reply

* [PATCH 1/3] btinfo: Add missing socket close() on exit
From: Andrei Emeltchenko @ 2014-01-03 12:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 tools/btinfo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/btinfo.c b/tools/btinfo.c
index 0f0dfad..aa4df5a 100644
--- a/tools/btinfo.c
+++ b/tools/btinfo.c
@@ -359,6 +359,8 @@ int main(int argc, char *argv[])
 
 			if (ioctl(fd, HCIDEVDOWN, hci_info.dev_id) < 0)
 				perror("Failed to power down controller");
+
+			close(fd);
 		}
 	}
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 2/3] btmon: Fix memory leak
From: Andrei Emeltchenko @ 2014-01-03 12:54 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388753686-29400-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Dynamic memory stored in company allocated through function
hwdb_get_company shall be freed.
---
 monitor/packet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index c991d04..b271cae 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -408,18 +408,20 @@ static void print_addr(const char *label, const uint8_t *addr,
 		if (!hwdb_get_company(addr, &company))
 			company = NULL;
 
-		if (company)
+		if (company) {
 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
 					" (%s)", label, addr[5], addr[4],
 							addr[3], addr[2],
 							addr[1], addr[0],
 							company);
-		else
+			free(company);
+		} else {
 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
 					" (OUI %2.2X-%2.2X-%2.2X)", label,
 						addr[5], addr[4], addr[3],
 						addr[2], addr[1], addr[0],
 						addr[5], addr[4], addr[3]);
+		}
 		break;
 	case 0x01:
 		switch ((addr[5] & 0xc0) >> 6) {
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 3/3] btproxy: Fix closing invalid file descriptor
From: Andrei Emeltchenko @ 2014-01-03 12:54 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388753686-29400-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Instead of invalid file descriptor dst_fd close src_fd.
---
 tools/btproxy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/btproxy.c b/tools/btproxy.c
index 3c7c48f..1573587 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -659,7 +659,7 @@ int main(int argc, char *argv[])
 
 		dst_fd = open_vhci(0x00);
 		if (dst_fd < 0) {
-			close(dst_fd);
+			close(src_fd);
 			return EXIT_FAILURE;
 		}
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCHv2] btdev: Return Command Status for Authentication Requested
From: Andrei Emeltchenko @ 2014-01-03 13:45 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20131223170651.GA17118@x220.p-661hnu-f1>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add support for "Authentication Requested" command
---
 emulator/btdev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 93361cd..0349f8a 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -269,6 +269,7 @@ static void set_bredr_commands(struct btdev *btdev)
 	btdev->commands[0]  |= 0x80;	/* Cancel Create Connection */
 	btdev->commands[1]  |= 0x01;	/* Accept Connection Request */
 	btdev->commands[1]  |= 0x02;	/* Reject Connection Request */
+	btdev->commands[1]  |= 0x80;	/* Authentication Requested */
 	btdev->commands[2]  |= 0x08;	/* Remote Name Request */
 	btdev->commands[2]  |= 0x10;	/* Cancel Remote Name Request */
 	btdev->commands[2]  |= 0x20;	/* Read Remote Supported Features */
@@ -1202,6 +1203,12 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
 		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
 		break;
 
+	case BT_HCI_CMD_AUTH_REQUESTED:
+		if (btdev->type == BTDEV_TYPE_LE)
+			goto unsupported;
+		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
+		break;
+
 	case BT_HCI_CMD_REMOTE_NAME_REQUEST:
 		if (btdev->type == BTDEV_TYPE_LE)
 			goto unsupported;
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH] android/tester: Fix NULL dereference.
From: Johan Hedberg @ 2014-01-03 13:48 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1388744333-17014-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Fri, Jan 03, 2014, Andrei Emeltchenko wrote:
> NULL pointer data->if_bluetooth will be dereferenced without return.
> ---
>  android/android-tester.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android/tester: Fix NULL dereference in socket setup
From: Johan Hedberg @ 2014-01-03 13:48 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1388744774-17418-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Fri, Jan 03, 2014, Andrei Emeltchenko wrote:
> Add return statement to avoid NULL dereference in socket setup.
> ---
>  android/android-tester.c | 2 ++
>  1 file changed, 2 insertions(+)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 1/3] btinfo: Add missing socket close() on exit
From: Johan Hedberg @ 2014-01-03 13:53 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1388753686-29400-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Fri, Jan 03, 2014, Andrei Emeltchenko wrote:
> ---
>  tools/btinfo.c | 2 ++
>  1 file changed, 2 insertions(+)

All three patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCHv2] btdev: Return Command Status for Authentication Requested
From: Johan Hedberg @ 2014-01-03 14:00 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1388756754-30760-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Fri, Jan 03, 2014, Andrei Emeltchenko wrote:
> Add support for "Authentication Requested" command
> ---
>  emulator/btdev.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/emulator/btdev.c b/emulator/btdev.c
> index 93361cd..0349f8a 100644
> --- a/emulator/btdev.c
> +++ b/emulator/btdev.c
> @@ -269,6 +269,7 @@ static void set_bredr_commands(struct btdev *btdev)
>  	btdev->commands[0]  |= 0x80;	/* Cancel Create Connection */
>  	btdev->commands[1]  |= 0x01;	/* Accept Connection Request */
>  	btdev->commands[1]  |= 0x02;	/* Reject Connection Request */
> +	btdev->commands[1]  |= 0x80;	/* Authentication Requested */
>  	btdev->commands[2]  |= 0x08;	/* Remote Name Request */
>  	btdev->commands[2]  |= 0x10;	/* Cancel Remote Name Request */
>  	btdev->commands[2]  |= 0x20;	/* Read Remote Supported Features */
> @@ -1202,6 +1203,12 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
>  		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
>  		break;
>  
> +	case BT_HCI_CMD_AUTH_REQUESTED:
> +		if (btdev->type == BTDEV_TYPE_LE)
> +			goto unsupported;
> +		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
> +		break;
> +
>  	case BT_HCI_CMD_REMOTE_NAME_REQUEST:
>  		if (btdev->type == BTDEV_TYPE_LE)
>  			goto unsupported;

I'd rather wait with this one until you've got a full set of patches
that also implement the link key request event and the rest of the
pairing procedure (if the link key request is followed by a negative
link key reply).

Johan

^ permalink raw reply

* A problem with "rfcomm bind" and wvdial
From: Andrey Vihrov @ 2014-01-03 18:24 UTC (permalink / raw)
  To: linux-bluetooth


[-- Attachment #1.1: Type: text/plain, Size: 1643 bytes --]

Hello,

I'm writing to this mailing list because I was told on IRC that it's the
best place to discuss Linux Bluetooth problems, and I want to report
one.

I have a Nokia N70 phone which I use as a modem through Bluetooth. Up
until recently (~half a year ago), my workflow to establish a connection
was to

a) Call "rfcomm bind /dev/rfcomm0 <addr> <channel>" at system start (in
the past I also used /etc/bluetooth/rfcomm.conf, but that stopped
working at some point)
b) Run wvdial, which will open /dev/rfcomm0 as a modem/serial port

Now, however, when I run wvdial, I get

  Cannot open /dev/rfcomm0: Transport endpoint is not connected

I have found empirically that if I use "rfcomm connect" instead of
"rfcomm bind", and then run wvdial, then it works fine. Thus, it would
seem that the connection is not established automatically when an
application opens /dev/rfcomm0.

I have reproduced this on Arch Linux with BlueZ 5.13 and the
linux-bluetooth kernel. I'm also attaching logs of bluetoothd, btmon and
hcidump at the moment when wvdial is run.

Regarding the btmon log, I've observed that wvdial reports the
"Transport endpoint is not connected" error nearly at the same time as
the first

> HCI Event: Command Status (0x0f) plen 4                                                                                                                        [hci0] 3.436738
      Create Connection (0x01|0x0005) ncmd 1
        Status: Success (0x00)

is printed, and the rest of the log is printed when wvdial has already
exited.

Thanks in advance,

-- 
Andrey Vihrov <andrey.vihrov@gmail.com>


[-- Attachment #1.2: bluetoothd --]
[-- Type: text/plain, Size: 11783 bytes --]

bluetoothd[4444]: Bluetooth daemon 5.13
bluetoothd[4444]: src/main.c:parse_config() parsing main.conf
bluetoothd[4444]: src/main.c:parse_config() discovto=0
bluetoothd[4444]: src/main.c:parse_config() pairto=0
bluetoothd[4444]: src/main.c:parse_config() Key file does not have key 'AutoConnectTimeout'
bluetoothd[4444]: src/main.c:parse_config() name=%h
bluetoothd[4444]: src/main.c:parse_config() Key file does not have key 'Class'
bluetoothd[4444]: src/main.c:parse_config() Key file does not have key 'DeviceID'
bluetoothd[4444]: src/main.c:parse_config() Key file does not have key 'ReverseServiceDiscovery'
bluetoothd[4444]: src/adapter.c:adapter_init() sending read version command
bluetoothd[4444]: Starting SDP server
bluetoothd[4444]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:050d
bluetoothd[4444]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[4444]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading a2dp plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading avrcp plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading input plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading hog plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading gatt plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[4444]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[4444]: src/plugin.c:plugin_init() Loading plugins /usr/lib/bluetooth/plugins
bluetoothd[4444]: profiles/input/suspend-dummy.c:suspend_init() 
bluetoothd[4444]: profiles/input/suspend-dummy.c:suspend_init() Created suspend-dummy FIFO on /tmp/hogsuspend
bluetoothd[4444]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[4444]: plugins/hostname.c:read_dmi_fallback() chassis: laptop
bluetoothd[4444]: plugins/hostname.c:read_dmi_fallback() major: 0x01 minor: 0x03
bluetoothd[4444]: src/main.c:main() Entering main loop
bluetoothd[4444]: plugins/hostname.c:property_changed() static hostname: tenshi
bluetoothd[4444]: plugins/hostname.c:property_changed() pretty hostname: 
bluetoothd[4444]: plugins/hostname.c:property_changed() chassis: laptop
bluetoothd[4444]: Bluetooth management interface 1.4 initialized
bluetoothd[4444]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[4444]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[4444]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 2 op 0 soft 0 hard 0
bluetoothd[4444]: src/adapter.c:read_commands_complete() Number of commands: 42
bluetoothd[4444]: src/adapter.c:read_commands_complete() Number of events: 21
bluetoothd[4444]: src/adapter.c:read_index_list_complete() Number of controllers: 1
bluetoothd[4444]: src/adapter.c:read_index_list_complete() Found index 0
bluetoothd[4444]: src/adapter.c:index_added() index 0
bluetoothd[4444]: src/adapter.c:btd_adapter_new() System name: %h
bluetoothd[4444]: src/adapter.c:btd_adapter_new() Major class: 0
bluetoothd[4444]: src/adapter.c:btd_adapter_new() Minor class: 0
bluetoothd[4444]: src/adapter.c:btd_adapter_new() Modalias: usb:v1D6Bp0246d050D
bluetoothd[4444]: src/adapter.c:btd_adapter_new() Discoverable timeout: 0 seconds
bluetoothd[4444]: src/adapter.c:btd_adapter_new() Pairable timeout: 0 seconds
bluetoothd[4444]: src/adapter.c:index_added() sending read info command for index 0
bluetoothd[4444]: src/adapter.c:read_info_complete() index 0 status 0x00
bluetoothd[4444]: src/adapter.c:clear_uuids() sending clear uuids command for index 0
bluetoothd[4444]: src/attrib-server.c:btd_adapter_gatt_server_start() Start GATT server in hci0
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0001
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0004
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0006
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0007
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0008
bluetoothd[4444]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10001
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001800-0000-1000-8000-00805f9
bluetoothd[4444]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[4444]: src/attrib-server.c:attrib_db_add_new() handle=0x0010
bluetoothd[4444]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10002
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001801-0000-1000-8000-00805f9
bluetoothd[4444]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[4444]: profiles/audio/a2dp.c:media_server_probe() path /org/bluez/hci0
bluetoothd[4444]: plugins/hostname.c:hostname_probe() 
bluetoothd[4444]: plugins/hostname.c:update_name() name: tenshi
bluetoothd[4444]: src/adapter.c:adapter_set_name() name: tenshi
bluetoothd[4444]: src/adapter.c:adapter_set_name() alias: tenshi
bluetoothd[4444]: src/adapter.c:set_name() sending set local name command for index 0
bluetoothd[4444]: plugins/hostname.c:update_class() major: 0x01 minor: 0x03
bluetoothd[4444]: src/adapter.c:btd_adapter_set_class() class: major 1 minor 3
bluetoothd[4444]: src/adapter.c:set_dev_class() sending set device class command for index 0
bluetoothd[4444]: profiles/network/manager.c:panu_server_probe() path /org/bluez/hci0
bluetoothd[4444]: profiles/network/server.c:server_register() Registered interface org.bluez.NetworkServer1 on path /org/bluez/hci0
bluetoothd[4444]: profiles/network/manager.c:gn_server_probe() path /org/bluez/hci0
bluetoothd[4444]: profiles/network/manager.c:nap_server_probe() path /org/bluez/hci0
bluetoothd[4444]: profiles/audio/avrcp.c:avrcp_controller_server_probe() path /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10003
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000017-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110e-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110f-0000-1000-8000-00805f9
bluetoothd[4444]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[4444]: profiles/audio/avrcp.c:avrcp_target_server_probe() path /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10004
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000017-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110c-0000-1000-8000-00805f9
bluetoothd[4444]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000110e-0000-1000-8000-00805f9
bluetoothd[4444]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[4444]: profiles/audio/a2dp.c:a2dp_sink_server_probe() path /org/bluez/hci0
bluetoothd[4444]: profiles/audio/a2dp.c:a2dp_source_server_probe() path /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:btd_adapter_unblock_address() hci0 00:00:00:00:00:00
bluetoothd[4444]: src/device.c:device_create_from_storage() address 00:1B:33:57:E1:03
bluetoothd[4444]: src/device.c:device_new() address 00:1B:33:57:E1:03
bluetoothd[4444]: src/device.c:device_new() Creating device /org/bluez/hci0/dev_00_1B_33_57_E1_03
bluetoothd[4444]: src/device.c:device_probe_profiles() Probing profiles for device 00:1B:33:57:E1:03
bluetoothd[4444]: src/device.c:device_set_bonded() bonded 1
bluetoothd[4444]: src/adapter.c:load_link_keys() hci0 keys 1 debug_keys 0
bluetoothd[4444]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[4444]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[4444]: src/adapter.c:set_did() hci0 source 2 vendor 1d6b product 246 version 50d
bluetoothd[4444]: src/adapter.c:adapter_register() Adapter /org/bluez/hci0 registered
bluetoothd[4444]: src/adapter.c:set_dev_class() sending set device class command for index 0
bluetoothd[4444]: src/adapter.c:set_name() sending set local name command for index 0
bluetoothd[4444]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[4444]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[4444]: src/adapter.c:set_discoverable() sending set mode command for index 0
bluetoothd[4444]: src/adapter.c:load_link_keys_complete() link keys loaded for hci0
bluetoothd[4444]: src/adapter.c:property_set_mode() sending Set Powered command for index 0
bluetoothd[4444]: src/adapter.c:dev_class_changed_callback() Class: 0x00010c
bluetoothd[4444]: src/attrib-server.c:attrib_db_update() handle=0x0008
bluetoothd[4444]: src/adapter.c:property_set_mode_complete() Success (0x00)
bluetoothd[4444]: src/adapter.c:new_settings_callback() Settings: 0x0000009b
bluetoothd[4444]: src/adapter.c:settings_changed() Changed settings: 0x00000001
bluetoothd[4444]: src/adapter.c:adapter_start() adapter /org/bluez/hci0 has been enabled
bluetoothd[4444]: src/adapter.c:connected_callback() hci0 device 00:1B:33:57:E1:03 connected eir_len 8
bluetoothd[4444]: src/adapter.c:dev_disconnected() Device 00:1B:33:57:E1:03 disconnected, reason 2
bluetoothd[4444]: src/adapter.c:adapter_remove_connection() 
bluetoothd[4444]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:1B:33:57:E1:03 type 0 status 0xe
bluetoothd[4444]: src/device.c:device_bonding_complete() bonding (nil) status 0x0e
bluetoothd[4444]: src/device.c:device_bonding_failed() status 14
bluetoothd[4444]: src/adapter.c:resume_discovery() 

[-- Attachment #1.3: btmon --]
[-- Type: text/plain, Size: 11197 bytes --]

Bluetooth monitor ver 5.13
= New Index: 00:1F:E2:D9:95:A4 (BR/EDR,USB,hci0)                                                                                                                 [hci0] 0.040271
< HCI Command: Create Connection (0x01|0x0005) plen 13                                                                                                           [hci0] 3.434535
        Address: 00:1B:33:57:E1:03 (Nokia Danmark A/S)
        Packet type: 0xcc18
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
        Role switch: Allow slave (0x01)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        [hci0] 3.436738
      Create Connection (0x01|0x0005) ncmd 1
        Status: Success (0x00)
> HCI Event: Connect Complete (0x03) plen 11                                                                                                                     [hci0] 6.455010
        Status: Success (0x00)
        Handle: 11
        Address: 00:1B:33:57:E1:03 (Nokia Danmark A/S)
        Link type: ACL (0x01)
        Encryption: Disabled (0x00)
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2                                                                                               [hci0] 6.455259
        Handle: 11
> HCI Event: Read Remote Supported Features (0x0b) plen 11                                                                                                       [hci0] 6.456931
        Status: Success (0x00)
        Handle: 11
        Features: 0xbf 0xee 0x0f 0x46 0x98 0x19 0x00 0x00
          3 slot packets
          5 slot packets
          Encryption
          Slot offset
          Timing accuracy
          Role switch
          Sniff mode
          Power control requests
          Channel quality driven data rate (CQDDR)
          SCO link
          HV3 packets
          u-law log synchronous data
          A-law log synchronous data
          CVSD synchronous data
          Paging parameter negotiation
          Power control
          Transparent synchronous data
          Enhanced Data Rate ACL 2 Mbps mode
          Enhanced Data Rate ACL 3 Mbps mode
          RSSI with inquiry results
          AFH capable slave
          AFH classification slave
          3-slot Enhanced Data Rate ACL packets
          5-slot Enhanced Data Rate ACL packets
          AFH capable master
          AFH classification master
< ACL Data TX: Handle 11 flags 0x02 dlen 10                                                                                                                      [hci0] 6.457022
      L2CAP: Information Request (0x0a) ident 1 len 2
        Type: Extended features supported (0x0002)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        [hci0] 6.458891
      Read Remote Supported Features (0x01|0x001b) ncmd 1
        Status: Success (0x00)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10                                                                                                         [hci0] 6.458911
        Address: 00:1B:33:57:E1:03 (Nokia Danmark A/S)
        Page scan repetition mode: R2 (0x02)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x0000
> HCI Event: Command Status (0x0f) plen 4                                                                                                                        [hci0] 6.459915
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7                                                                                                      [hci0] 6.475926
        Address: 00:1B:33:57:E1:03 (Nokia Danmark A/S)
        Page scan repetition mode: R1 (0x01)
> HCI Event: Max Slots Change (0x1b) plen 3                                                                                                                      [hci0] 6.477917
        Handle: 11
        Max slots: 5
> HCI Event: Remote Name Req Complete (0x07) plen 255                                                                                                            [hci0] 6.534004
        Status: Success (0x00)
        Address: 00:1B:33:57:E1:03 (Nokia Danmark A/S)
        Name: Mokona
@ Device Connected: 00:1B:33:57:E1:03 (0) flags 0x0000
        07 09 4d 6f 6b 6f 6e 61                          ..Mokona        
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                           [hci0] 6.685951
        Num handles: 1
        Handle: 11
        Count: 1
> ACL Data RX: Handle 11 flags 0x02 dlen 16                                                                                                                      [hci0] 6.689951
      L2CAP: Information Response (0x0b) ident 1 len 8
        Type: Extended features supported (0x0002)
        Result: Success (0x0000)
        Features: 0x00000003
          Flow control mode
          Retransmission mode
< ACL Data TX: Handle 11 flags 0x02 dlen 12                                                                                                                      [hci0] 6.690033
      L2CAP: Connection Request (0x02) ident 2 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> ACL Data RX: Handle 11 flags 0x02 dlen 10                                                                                                                      [hci0] 6.698952
      L2CAP: Information Request (0x0a) ident 1 len 2
        Type: Extended features supported (0x0002)
< ACL Data TX: Handle 11 flags 0x02 dlen 16                                                                                                                      [hci0] 6.699033
      L2CAP: Information Response (0x0b) ident 1 len 8
        Type: Extended features supported (0x0002)
        Result: Success (0x0000)
        Features: 0x000002b8
          Enhanced Retransmission Mode
          Streaming Mode
          FCS Option
          Fixed Channels
          Unicast Connectionless Data Reception
> ACL Data RX: Handle 11 flags 0x02 dlen 16                                                                                                                      [hci0] 6.700917
      L2CAP: Connection Response (0x03) ident 2 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< ACL Data TX: Handle 11 flags 0x02 dlen 16                                                                                                                      [hci0] 6.700987
      L2CAP: Configure Request (0x04) ident 3 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01)
          MTU: 1013
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                           [hci0] 6.702942
        Num handles: 1
        Handle: 11
        Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 12                                                                                                                      [hci0] 6.707953
      L2CAP: Configure Request (0x04) ident 2 len 4
        Destination CID: 64
        Flags: 0x0000
< ACL Data TX: Handle 11 flags 0x02 dlen 18                                                                                                                      [hci0] 6.708040
      L2CAP: Configure Response (0x05) ident 2 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01)
          MTU: 672
> ACL Data RX: Handle 11 flags 0x02 dlen 18                                                                                                                      [hci0] 6.708953
      L2CAP: Configure Response (0x05) ident 3 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01)
          MTU: 672
< ACL Data TX: Handle 11 flags 0x02 dlen 8                                                                                                                       [hci0] 6.709118
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
        03 3f 01 1c                                      .?..            
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                           [hci0] 6.712024
        Num handles: 1
        Handle: 11
        Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 8                                                                                                                       [hci0] 6.715916
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
        03 73 01 d7                                      .s..            
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                           [hci0] 6.936047
        Num handles: 1
        Handle: 11
        Count: 1
> ACL Data RX: Handle 11 flags 0x02 dlen 12                                                                                                                      [hci0] 8.730078
      L2CAP: Disconnection Request (0x06) ident 3 len 4
        Destination CID: 64
        Source CID: 64
< ACL Data TX: Handle 11 flags 0x02 dlen 12                                                                                                                      [hci0] 8.730170
      L2CAP: Disconnection Response (0x07) ident 3 len 4
        Destination CID: 64
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                           [hci0] 8.936081
        Num handles: 1
        Handle: 11
        Count: 1
< HCI Command: Disconnect (0x01|0x0006) plen 3                                                                                                                  [hci0] 10.732120
        Handle: 11
        Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                       [hci0] 10.735276
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                                  [hci0] 10.898262
        Status: Success (0x00)
        Handle: 11
        Reason: Connection Terminated By Local Host (0x16)
@ Device Disconnected: 00:1B:33:57:E1:03 (0) reason 2

[-- Attachment #1.4: hcidump --]
[-- Type: text/plain, Size: 3809 bytes --]

HCI sniffer - Bluetooth packet analyzer ver 5.13
device: hci0 snap_len: 1500 filter: 0xffffffffffffffff
< HCI Command: Create Connection (0x01|0x0005) plen 13
    bdaddr 00:1B:33:*:*:* ptype 0xcc18 rswitch 0x01 clkoffset 0x0000
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 
> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x00 handle 11 bdaddr 00:1B:33:*:*:* type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
    handle 11
> HCI Event: Read Remote Supported Features (0x0b) plen 11
    status 0x00 handle 11
    Features: 0xbf 0xee 0x0f 0x46 0x98 0x19 0x00 0x00
< ACL data: handle 11 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
> HCI Event: Command Status (0x0f) plen 4
    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
    bdaddr 00:1B:33:*:*:* mode 2 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
    bdaddr 00:1B:33:*:*:* mode 1
> HCI Event: Max Slots Change (0x1b) plen 3
    handle 11 slots 5
> HCI Event: Remote Name Req Complete (0x07) plen 255
    status 0x00 bdaddr 00:1B:33:*:*:* name 'Mokona'
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 1
> ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x0003
        Flow control mode
        Retransmission mode
< ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Connect req: psm 3 scid 0x0040
> ACL data: handle 11 flags 0x02 dlen 10
    L2CAP(s): Info req: type 2
< ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
      Extended feature mask 0x02b8
        Enhanced Retransmission mode
        Streaming mode
        FCS Option
        Fixed Channels
        Unicast Connectless Data Reception
> ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
      Connection successful
< ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
      MTU 1013 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 2
> ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 0
< ACL data: handle 11 flags 0x02 dlen 18
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
      MTU 672 
> ACL data: handle 11 flags 0x02 dlen 18
    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
      MTU 672 
< ACL data: handle 11 flags 0x02 dlen 8
    L2CAP(d): cid 0x0040 len 4 [psm 3]
      RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 2
> ACL data: handle 11 flags 0x02 dlen 8
    L2CAP(d): cid 0x0040 len 4 [psm 3]
      RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7 
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 1
> ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn req: dcid 0x0040 scid 0x0040
< ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0040
> HCI Event: Number of Completed Packets (0x13) plen 5
    handle 11 packets 1
< HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 11 reason 0x13
    Reason: Remote User Terminated Connection
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x16
    Reason: Connection Terminated by Local Host

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: [PATCH 2/3] btmon: Fix memory leak
From: Marcel Holtmann @ 2014-01-03 18:30 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1388753686-29400-2-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> Dynamic memory stored in company allocated through function
> hwdb_get_company shall be freed.
> ---
> monitor/packet.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/monitor/packet.c b/monitor/packet.c
> index c991d04..b271cae 100644
> --- a/monitor/packet.c
> +++ b/monitor/packet.c
> @@ -408,18 +408,20 @@ static void print_addr(const char *label, const uint8_t *addr,
> 		if (!hwdb_get_company(addr, &company))
> 			company = NULL;
> 
> -		if (company)
> +		if (company) {
> 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
> 					" (%s)", label, addr[5], addr[4],
> 							addr[3], addr[2],
> 							addr[1], addr[0],
> 							company);
> -		else
> +			free(company);

good catch. I totally forgot about the fact that the memory is allocated.

> +		} else {
> 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
> 					" (OUI %2.2X-%2.2X-%2.2X)", label,
> 						addr[5], addr[4], addr[3],
> 						addr[2], addr[1], addr[0],
> 						addr[5], addr[4], addr[3]);
> +		}
> 		break;

In userspace we do not require the else statement to be enclose by { } if the if part is as well. We usually don’t.

Regards

Marcel


^ permalink raw reply

* Re: [PATCHv2] btdev: Return Command Status for Authentication Requested
From: Marcel Holtmann @ 2014-01-03 18:35 UTC (permalink / raw)
  To: Johan Hedberg
  Cc: Andrei Emeltchenko, linux-bluetooth@vger.kernel.org development
In-Reply-To: <20140103140046.GA12036@x220.p-661hnu-f1>

Hi Johan,

>> Add support for "Authentication Requested" command
>> ---
>> emulator/btdev.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>> 
>> diff --git a/emulator/btdev.c b/emulator/btdev.c
>> index 93361cd..0349f8a 100644
>> --- a/emulator/btdev.c
>> +++ b/emulator/btdev.c
>> @@ -269,6 +269,7 @@ static void set_bredr_commands(struct btdev *btdev)
>> 	btdev->commands[0]  |= 0x80;	/* Cancel Create Connection */
>> 	btdev->commands[1]  |= 0x01;	/* Accept Connection Request */
>> 	btdev->commands[1]  |= 0x02;	/* Reject Connection Request */
>> +	btdev->commands[1]  |= 0x80;	/* Authentication Requested */
>> 	btdev->commands[2]  |= 0x08;	/* Remote Name Request */
>> 	btdev->commands[2]  |= 0x10;	/* Cancel Remote Name Request */
>> 	btdev->commands[2]  |= 0x20;	/* Read Remote Supported Features */
>> @@ -1202,6 +1203,12 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
>> 		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
>> 		break;
>> 
>> +	case BT_HCI_CMD_AUTH_REQUESTED:
>> +		if (btdev->type == BTDEV_TYPE_LE)
>> +			goto unsupported;
>> +		cmd_status(btdev, BT_HCI_ERR_SUCCESS, opcode);
>> +		break;
>> +
>> 	case BT_HCI_CMD_REMOTE_NAME_REQUEST:
>> 		if (btdev->type == BTDEV_TYPE_LE)
>> 			goto unsupported;
> 
> I'd rather wait with this one until you've got a full set of patches
> that also implement the link key request event and the rest of the
> pairing procedure (if the link key request is followed by a negative
> link key reply).

since we do not install btvirt, I am fine if we even have incomplete functionality in it. However in this case we need to track if pairing is active. And also timeout the pairing. Otherwise everything will be blocked after one attempt.

So at minimum we need to store the current auth request state + start a timeout to make it timeout and send the auth failed event.

Regards

Marcel


^ permalink raw reply

* [PATCH BlueZ 00/12] Fixes detected by clang
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

Hi,

The patches on this set (except for the last patch) fix issues detected while
building BlueZ with clang. Note that these fixes were only compile tested (I
did run "make check" but it obviously does not cover code touched by these
patches). For strncat/sprintf/sscanf related patches, I did some tests with
sample code to make sure the changes worked as expected.

The last patch is a fix that I think should be inoffensive (unless there is
some clever hack going on there that I could not see.)

BTW, I've been experimenting with Travis CI for automatically running
build/unit tests for commits made on my personal development tree:
https://travis-ci.org/lizardo/bluez-devel. Enabling builds with clang (along
with gcc) was a one-line change to the configuration file. I plan in near
future to also run functional tests (right now it just runs "make check" and
"make distcheck")

Best Regards,
Anderson Lizardo

Anderson Lizardo (12):
  tools: Fix strncat() usage in hciconfig/hcitool
  avrcp: Remove unnecessary "if (...)"
  health: Fix struct mcap_csp "csp_req" field type
  attrib: Fix sprintf() format specification
  core: Fix sscanf() format specification
  tools: Fix unaligned memory access on smp-tester
  tools: Fix possible uninitialized variable in obexctl
  android/client: Fix incorrect usage of bt_state_t2str()
  android/client: Remove duplicate "const" specifier
  android/client: Use memcpy() for getting CMSG_DATA()
  android/client: Fix uninitialized "sock_fd" variable
  android/system-emulator: Remove useless "static" qualifier

 android/client/if-bt.c      |  2 +-
 android/client/if-hh.c      | 16 ++++++++--------
 android/client/if-pan.c     |  8 ++++----
 android/client/if-sock.c    |  8 +++-----
 android/system-emulator.c   |  3 +--
 profiles/audio/avrcp.c      |  2 +-
 profiles/health/mcap_sync.c |  2 +-
 src/adapter.c               | 12 ++++++------
 src/attrib-server.c         |  2 +-
 tools/hciconfig.c           | 21 ++++++++++++++-------
 tools/hcitool.c             | 23 +++++++++++++++--------
 tools/obexctl.c             |  6 ++----
 tools/smp-tester.c          | 16 +++++++++++-----
 13 files changed, 68 insertions(+), 53 deletions(-)

-- 
1.8.3.2


^ permalink raw reply

* [PATCH BlueZ 01/12] tools: Fix strncat() usage in hciconfig/hcitool
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

According to strncat() manpage:

"If src contains n or more characters, strncat() writes n+1 characters
to dest (n from src plus the terminating null byte).  Therefore, the
size of dest must be at least strlen(dest)+n+1"

While the current usage of strncat() cannot cause an overflow, if a
bigger string is added to the switch()'s without increasing the static
buffer, it would overflow by one byte due to the incorrect size
calculation.

Fixes clang errors like:

tools/hciconfig.c:827:33: error: the value of the size argument in
'strncat' is too large, might lead to a buffer overflow
[-Werror,-Wstrncat-size]
---
 tools/hciconfig.c | 21 ++++++++++++++-------
 tools/hcitool.c   | 23 +++++++++++++++--------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index fe45167..6c7f8ed 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -824,25 +824,32 @@ static char *get_minor_device_name(int major, int minor)
 		case 0:
 			break;
 		case 1:
-			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Joystick",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 2:
-			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Gamepad",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 3:
-			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Remote control",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 4:
-			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Sensing device",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 5:
-			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Digitizer tablet",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 6:
-			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Card reader",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		default:
-			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "(reserved)",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		}
 		if (strlen(cls_str) > 0)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index f2e4fa4..d85ece1 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -336,25 +336,32 @@ static char *get_minor_device_name(int major, int minor)
 		case 0:
 			break;
 		case 1:
-			strncat(cls_str, "Joystick", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Joystick",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 2:
-			strncat(cls_str, "Gamepad", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Gamepad",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 3:
-			strncat(cls_str, "Remote control", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Remote control",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 4:
-			strncat(cls_str, "Sensing device", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Sensing device",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		case 5:
-			strncat(cls_str, "Digitizer tablet", sizeof(cls_str) - strlen(cls_str));
-		break;
+			strncat(cls_str, "Digitizer tablet",
+					sizeof(cls_str) - strlen(cls_str) - 1);
+			break;
 		case 6:
-			strncat(cls_str, "Card reader", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "Card reader",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		default:
-			strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
+			strncat(cls_str, "(reserved)",
+					sizeof(cls_str) - strlen(cls_str) - 1);
 			break;
 		}
 		if (strlen(cls_str) > 0)
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 02/12] avrcp: Remove unnecessary "if (...)"
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

There is already a "if (type != 0x03 && type != 0x02)" check earlier on
the code, so a plain "if (...) else ..." is enough.

Fixes clang error:

profiles/audio/avrcp.c:2211:12: error: variable 'item' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
---
 profiles/audio/avrcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 2eb2ad6..8d4309a 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2208,7 +2208,7 @@ static gboolean avrcp_list_items_rsp(struct avctp *conn, uint8_t *operands,
 
 		if (type == 0x03)
 			item = parse_media_element(session, &operands[i], len);
-		else if (type == 0x02)
+		else
 			item = parse_media_folder(session, &operands[i], len);
 
 		if (item) {
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 03/12] health: Fix struct mcap_csp "csp_req" field type
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

The values to which this field is set have nothing to do with MCAPCtrl.

Fixes clang error:

profiles/health/mcap_sync.c:767:24: error: comparison of constant 17
with expression of type 'MCAPCtrl' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
---
 profiles/health/mcap_sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/health/mcap_sync.c b/profiles/health/mcap_sync.c
index 0d9f17d..7c35e4a 100644
--- a/profiles/health/mcap_sync.c
+++ b/profiles/health/mcap_sync.c
@@ -55,7 +55,7 @@ struct mcap_csp {
 	guint		remote_caps;	/* CSP-Slave: remote master got caps */
 	guint		rem_req_acc;	/* CSP-Slave: accuracy required by master */
 	guint		ind_expected;	/* CSP-Master: indication expected */
-	MCAPCtrl	csp_req;	/* CSP-Master: Request control flag */
+	uint8_t		csp_req;	/* CSP-Master: Request control flag */
 	guint		ind_timer;	/* CSP-Slave: indication timer */
 	guint		set_timer;	/* CSP-Slave: delayed set timer */
 	void		*set_data;	/* CSP-Slave: delayed set data */
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 04/12] attrib: Fix sprintf() format specification
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

Fixes clang error:

src/attrib-server.c:916:26: error: format specifies type 'unsigned char'
but the argument has type 'uint16_t' (aka 'unsigned short')
[-Werror,-Wformat]
---
 src/attrib-server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index a6f1066..a7ee55d 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -913,7 +913,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
 		g_key_file_load_from_file(key_file, filename, 0, NULL);
 
 		sprintf(group, "%hu", handle);
-		sprintf(value, "%hhX", cccval);
+		sprintf(value, "%hX", cccval);
 		g_key_file_set_string(key_file, group, "Value", value);
 
 		data = g_key_file_to_data(key_file, &length, NULL);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 05/12] core: Fix sscanf() format specification
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

Also change the type of the "handle" variable so it is compatible with
the "%hu" specification used for sprintf() on the same function.

Fixes clang error:

src/adapter.c:3550:24: error: format specifies type 'unsigned short' but
the argument has type 'int' [-Werror,-Wformat]
---
 src/adapter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 9480103..230f3ce 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3515,16 +3515,16 @@ static void convert_ccc_entry(char *key, char *value, void *user_data)
 	char *src_addr = user_data;
 	char dst_addr[18];
 	char type = BDADDR_BREDR;
-	int handle, ret;
+	uint16_t handle;
+	int ret, err;
 	char filename[PATH_MAX + 1];
 	GKeyFile *key_file;
 	struct stat st;
-	int err;
 	char group[6];
 	char *data;
 	gsize length = 0;
 
-	ret = sscanf(key, "%17s#%hhu#%04X", dst_addr, &type, &handle);
+	ret = sscanf(key, "%17s#%hhu#%04hX", dst_addr, &type, &handle);
 	if (ret < 3)
 		return;
 
@@ -3565,16 +3565,16 @@ static void convert_gatt_entry(char *key, char *value, void *user_data)
 	char *src_addr = user_data;
 	char dst_addr[18];
 	char type = BDADDR_BREDR;
-	int handle, ret;
+	uint16_t handle;
+	int ret, err;
 	char filename[PATH_MAX + 1];
 	GKeyFile *key_file;
 	struct stat st;
-	int err;
 	char group[6];
 	char *data;
 	gsize length = 0;
 
-	ret = sscanf(key, "%17s#%hhu#%04X", dst_addr, &type, &handle);
+	ret = sscanf(key, "%17s#%hhu#%04hX", dst_addr, &type, &handle);
 	if (ret < 3)
 		return;
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 06/12] tools: Fix unaligned memory access on smp-tester
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

Fixes clang errors like:

tools/smp-tester.c:263:11: error: cast from 'uint8_t *' (aka 'unsigned
char *') to 'u128 *' increases required alignment from 1 to 8
[-Werror,-Wcast-align]
---
 tools/smp-tester.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index 685d379..20429a9 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -233,10 +233,16 @@ typedef struct {
 	uint64_t a, b;
 } u128;
 
-static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
+static inline void u128_xor(void *r, const void *p, const void *q)
 {
-	r->a = p->a ^ q->a;
-	r->b = p->b ^ q->b;
+	const u128 pp = bt_get_unaligned((const u128 *) p);
+	const u128 qq = bt_get_unaligned((const u128 *) q);
+	u128 rr;
+
+	rr.a = pp.a ^ qq.a;
+	rr.b = pp.b ^ qq.b;
+
+	bt_put_unaligned(rr, (u128 *) r);
 }
 
 static int smp_c1(uint8_t r[16], uint8_t res[16])
@@ -260,7 +266,7 @@ static int smp_c1(uint8_t r[16], uint8_t res[16])
 	baswap((bdaddr_t *) (p2 + 10), (bdaddr_t *) data->ra);
 
 	/* res = r XOR p1 */
-	u128_xor((u128 *) res, (u128 *) r, (u128 *) p1);
+	u128_xor(res, r, p1);
 
 	/* res = e(k, res) */
 	err = smp_e(data->smp_tk, res, res);
@@ -268,7 +274,7 @@ static int smp_c1(uint8_t r[16], uint8_t res[16])
 		return err;
 
 	/* res = res XOR p2 */
-	u128_xor((u128 *) res, (u128 *) res, (u128 *) p2);
+	u128_xor(res, res, p2);
 
 	/* res = e(k, res) */
 	return smp_e(data->smp_tk, res, res);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 07/12] tools: Fix possible uninitialized variable in obexctl
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

On set_default_session(), if g_dbus_proxy_get_property() returns FALSE,
desc will be uninitialized. Given that this function already checks for
NULL proxy internally, it is enough to check whether it fails (and if
so, set a default prompt without destination).

Fixes this clang error:

tools/obexctl.c:439:6: error: variable 'desc' is used uninitialized
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
---
 tools/obexctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/obexctl.c b/tools/obexctl.c
index 2e38298..f0d5438 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -431,14 +431,12 @@ static void set_default_session(GDBusProxy *proxy)
 
 	default_session = proxy;
 
-	if (proxy == NULL) {
+	if (!g_dbus_proxy_get_property(proxy, "Destination", &iter)) {
 		desc = g_strdup(PROMPT_ON);
 		goto done;
 	}
 
-	if (g_dbus_proxy_get_property(proxy, "Destination", &iter))
-		dbus_message_iter_get_basic(&iter, &desc);
-
+	dbus_message_iter_get_basic(&iter, &desc);
 	desc = g_strdup_printf(COLOR_BLUE "[%s]" COLOR_OFF "# ", desc);
 
 done:
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 08/12] android/client: Fix incorrect usage of bt_state_t2str()
From: Anderson Lizardo @ 2014-01-04  1:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1388800528-10699-1-git-send-email-anderson.lizardo@openbossa.org>

Fixes clang error:

android/client/if-bt.c:313:54: error: implicit conversion from
enumeration type 'bt_status_t' to different enumeration type
'bt_state_t' [-Werror,-Wenum-conversion]
---
 android/client/if-bt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 10b79f1..6771df4 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -310,7 +310,7 @@ static void dut_mode_recv_cb(uint16_t opcode, uint8_t *buf, uint8_t len)
 #if PLATFORM_SDK_VERSION > 17
 static void le_test_mode_cb(bt_status_t status, uint16_t num_packets)
 {
-	haltest_info("%s %s %d\n", __func__, bt_state_t2str(status),
+	haltest_info("%s %s %d\n", __func__, bt_status_t2str(status),
 								num_packets);
 }
 #endif
-- 
1.8.3.2


^ permalink raw reply related


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