Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH] Bluetooth: hidp: make sure input buffers are big enough
From: Jiri Kosina @ 2014-02-17 14:07 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan
  Cc: David Herrmann, open list:HID CORE LAYER,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <alpine.LNX.2.00.1402051648470.8614@pobox.suse.cz>

On Wed, 5 Feb 2014, Jiri Kosina wrote:

> > >>>>> just got back to this, finally ... did you have time to work on this at
> > >>>>> all, or should I just start from scratch?
> > >>>> 
> > >>>> Sorry, no. Fosdem is this weekend and I needed to get my code ready
> > >>>> for that. But I'll finally have time again next week.
> > >>> 
> > >>> Okay, thanks. I then guess we should proceed with this bandaid (double
> > >>> allocation) for 3.14
> > >> 
> > >> It would be really nice if we could get the HIDP patch into 3.14-rc2
> > >> and backported to stable. There have been quite a bunch of reports now
> > >> and I dislike adding a GFP_ATOMIC allocation in HID core. 
> > > 
> > > I agree with David; Gustavo, what is your take on this, please?
> > 
> > I leave this up to Gustavo to get this into wireless tree for 3.14-rc2.
> > 
> > Acked-by: Marcel Holtmann <marcel@holtmann.org>
> 
> Thanks a lot.
> 
> Gustavo, what is your take on this please? I can take it through hid.git 
> in case you don't have anything else queued for -rc2.

... ping?

In case this doesn't get reacted upon by the end of the week, I am 
inclined to take it through hid.git.

Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCH 1/2] Bluetooth: Restrict long term keys to public and static addresses
From: Johan Hedberg @ 2014-02-17 13:59 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1392584346-64921-1-git-send-email-marcel@holtmann.org>

Hi Marcel,

On Sun, Feb 16, 2014, Marcel Holtmann wrote:
> The long term keys should be associated with an identity address. Valid
> identity addresses are public addresses or static addresses. So only
> allow these two as valid address information for long term keys.
> 
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
>  net/bluetooth/mgmt.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

Both patches have been applied to bluetooth-next. Thanks.

Johan

^ permalink raw reply

* Re: [PATCHv2] emulator/bthost: Check length of received RFCOMM UIH frames
From: Johan Hedberg @ 2014-02-17 13:51 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392643682-12370-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Mon, Feb 17, 2014, Marcin Kraglak wrote:
> Add correct calculation of frame length. If frame is too short, ignore it.
> ---
>  emulator/bthost.c | 38 ++++++++++++++++++++++++++++++--------
>  1 file changed, 30 insertions(+), 8 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] android: Fix for BT Turn off while pairing
From: Szymon Janc @ 2014-02-17 13:46 UTC (permalink / raw)
  To: Lukasz Rymanowski; +Cc: linux-bluetooth
In-Reply-To: <1392288692-5917-1-git-send-email-lukasz.rymanowski@tieto.com>

Hi Łukasz,

On Thursday 13 of February 2014 11:51:32 Lukasz Rymanowski wrote:
> This patch fix an issue when Android disables BT during ongoing
> paring. In this case mgmt did not accept any commands and BT gets
> in some unknown state.
> Since Android turns off BT anyway, it is ok to just cancel all
> the mgmt requests before send power off command.
> ---
>  android/bluetooth.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index ff41627..ad8cfec 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -2907,6 +2907,9 @@ static void handle_disable_cmd(const void *buf, uint16_t len)
>  		goto reply;
>  	}
>  
> +	/* Cancel all pending requests. Need it in case of ongoing paring */
> +	mgmt_cancel_index(mgmt_if, adapter.index);
> +
>  	if (!set_mode(MGMT_OP_SET_POWERED, 0x00)) {
>  		status = HAL_STATUS_FAILED;
>  		goto reply;

Applied, thanks. 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCHv2] emulator/bthost: Check length of received RFCOMM UIH frames
From: Marcin Kraglak @ 2014-02-17 13:28 UTC (permalink / raw)
  To: linux-bluetooth

Add correct calculation of frame length. If frame is too short, ignore it.
---
 emulator/bthost.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index ab90f4c..6fbabe8 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1760,17 +1760,30 @@ static void rfcomm_mcc_recv(struct bthost *bthost, struct btconn *conn,
 			struct l2conn *l2conn, const void *data, uint16_t len)
 {
 	const struct rfcomm_mcc *mcc = data;
+	const struct rfcomm_msc *msc;
+	const struct rfcomm_pn *pn;
+
+	if (len < sizeof(*mcc))
+		return;
 
 	switch (RFCOMM_GET_MCC_TYPE(mcc->type)) {
 	case RFCOMM_MSC:
+		if (len - sizeof(*mcc) < sizeof(*msc))
+			break;
+
+		msc = data + sizeof(*mcc);
+
 		rfcomm_msc_recv(bthost, conn, l2conn,
-						RFCOMM_TEST_CR(mcc->type) / 2,
-						data + sizeof(*mcc));
+				RFCOMM_TEST_CR(mcc->type) / 2, msc);
 		break;
 	case RFCOMM_PN:
+		if (len - sizeof(*mcc) < sizeof(*pn))
+			break;
+
+		pn = data + sizeof(*mcc);
+
 		rfcomm_pn_recv(bthost, conn, l2conn,
-					RFCOMM_TEST_CR(mcc->type) / 2,
-					data + sizeof(*mcc));
+				RFCOMM_TEST_CR(mcc->type) / 2, pn);
 		break;
 	default:
 		break;
@@ -1781,18 +1794,27 @@ static void rfcomm_uih_recv(struct bthost *bthost, struct btconn *conn,
 				struct l2conn *l2conn, const void *data,
 				uint16_t len)
 {
-	const struct rfcomm_cmd *hdr = data;
+	const struct rfcomm_hdr *hdr = data;
+	uint16_t hdr_len;
 	const void *p;
 
+	if (len < sizeof(*hdr))
+		return;
+
 	if (RFCOMM_GET_DLCI(hdr->address))
 		return;
 
 	if (RFCOMM_TEST_EA(hdr->length))
-		p = data + sizeof(struct rfcomm_hdr);
+		hdr_len = sizeof(*hdr);
 	else
-		p = data + sizeof(struct rfcomm_hdr) + sizeof(uint8_t);
+		hdr_len = sizeof(*hdr) + sizeof(uint8_t);
+
+	if (len < hdr_len)
+		return;
+
+	p = data + hdr_len;
 
-	rfcomm_mcc_recv(bthost, conn, l2conn, p, p - data);
+	rfcomm_mcc_recv(bthost, conn, l2conn, p, len - hdr_len);
 }
 
 static void process_rfcomm(struct bthost *bthost, struct btconn *conn,
-- 
1.8.3.1


^ permalink raw reply related

* Re: [PATCH] btsnoop: Remove unused local function and macro
From: Luiz Augusto von Dentz @ 2014-02-17 12:02 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391812080-19529-2-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

On Sat, Feb 8, 2014 at 12:27 AM, Andre Guedes
<andre.guedes@openbossa.org> wrote:
> ---
>  tools/btsnoop.c | 13 -------------
>  1 file changed, 13 deletions(-)
>
> diff --git a/tools/btsnoop.c b/tools/btsnoop.c
> index a65d8c5..260dfdb 100644
> --- a/tools/btsnoop.c
> +++ b/tools/btsnoop.c
> @@ -40,19 +40,6 @@
>
>  #include "monitor/btsnoop.h"
>
> -static inline uint64_t ntoh64(uint64_t n)
> -{
> -       uint64_t h;
> -       uint64_t tmp = ntohl(n & 0x00000000ffffffff);
> -
> -       h = ntohl(n >> 32);
> -       h |= tmp << 32;
> -
> -       return h;
> -}
> -
> -#define hton64(x)     ntoh64(x)
> -
>  struct btsnoop_hdr {
>         uint8_t         id[8];          /* Identification Pattern */
>         uint32_t        version;        /* Version Number = 1 */
> --
> 1.8.5.3

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH 0/5] Fixes for memory leaks
From: Luiz Augusto von Dentz @ 2014-02-17 12:02 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391812125-19594-1-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

On Sat, Feb 8, 2014 at 12:28 AM, Andre Guedes
<andre.guedes@openbossa.org> wrote:
> Hi all,
>
> This patch set fixes some memory leaks reported by clang static analyzer.
> There is no relation between patches of this set so they can be applied
> independently.
>
> BR,
>
> Andre
>
>
> Andre Guedes (5):
>   hcitool: Fix memory leak in cmd_info
>   hcidump: Fix memory leak
>   cltest: Fix memory leak
>   amptest: Fix memory leak
>   rctest: Fix memory leak
>
>  tools/amptest.c | 12 ++++++++----
>  tools/cltest.c  |  5 +++--
>  tools/hcidump.c |  9 +++++++--
>  tools/hcitool.c |  3 +++
>  tools/rctest.c  |  5 ++++-
>  5 files changed, 25 insertions(+), 9 deletions(-)
>
> --
> 1.8.5.3

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] health: Fix HealthDevice dbus registration
From: Luiz Augusto von Dentz @ 2014-02-17 12:01 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391812080-19529-1-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

On Sat, Feb 8, 2014 at 12:27 AM, Andre Guedes
<andre.guedes@openbossa.org> wrote:
> For some reason, HealthDevice property table wasn't been registered.
> ---
>  profiles/health/hdp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
> index 622d95b..48dad52 100644
> --- a/profiles/health/hdp.c
> +++ b/profiles/health/hdp.c
> @@ -2145,7 +2145,8 @@ static struct hdp_device *create_health_device(struct btd_device *device)
>         if (!g_dbus_register_interface(btd_get_dbus_connection(),
>                                         path, HEALTH_DEVICE,
>                                         health_device_methods,
> -                                       health_device_signals, NULL,
> +                                       health_device_signals,
> +                                       health_device_properties,
>                                         dev, health_device_destroy)) {
>                 error("D-Bus failed to register %s interface", HEALTH_DEVICE);
>                 goto fail;
> --
> 1.8.5.3

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH BlueZ 1/3] gdbus: Fix memory leak
From: Anderson Lizardo @ 2014-02-17 11:56 UTC (permalink / raw)
  To: BlueZ development; +Cc: Anderson Lizardo
In-Reply-To: <1392052498-9229-1-git-send-email-anderson.lizardo@openbossa.org>

Hi,

On Mon, Feb 10, 2014 at 1:14 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> data->conn and data->path must be destroyed before freeing "data".
> ---
>  gdbus/object.c |    2 ++
>  1 file changed, 2 insertions(+)

ping.

-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ permalink raw reply

* Re: [PATCH BlueZ 1/3] lib/sdp: Add missing Service Class ID for GAP
From: Anderson Lizardo @ 2014-02-17 11:55 UTC (permalink / raw)
  To: BlueZ development; +Cc: Anderson Lizardo
In-Reply-To: <1391804086-14428-1-git-send-email-anderson.lizardo@openbossa.org>

Hi,

On Fri, Feb 7, 2014 at 4:14 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Also reorder last ID so the list remains ordered.
> ---
>  lib/sdp.c |    3 ++-
>  lib/sdp.h |    7 ++++---
>  2 files changed, 6 insertions(+), 4 deletions(-)

ping.

-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ permalink raw reply

* Re: [PATCH 5/6] tools/rfcomm-tester: Add RFCOMM client read test case
From: Johan Hedberg @ 2014-02-17 11:32 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392205301-4204-6-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> +	sk = g_io_channel_unix_get_fd(io);
> +
> +
> +	if (client_data->data_len != read(sk, buf, client_data->data_len)) {

Coding style with the two consecutive empty lines above. Also consider a
separate ssize_t ret variable before the length comparison.

Johan

^ permalink raw reply

* Re: [PATCH 1/6] emulator/bthost: Add api to handle RFCOMM data on bthost
From: Johan Hedberg @ 2014-02-17 11:31 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392205301-4204-2-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> With this change user can handle data received on RFCOMM connection.
> ---
>  emulator/bthost.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>  emulator/bthost.h |  8 +++++++
>  2 files changed, 74 insertions(+), 4 deletions(-)
> 
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index 8447817..92ae08a 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -126,6 +126,13 @@ struct cid_hook {
>  	struct cid_hook *next;
>  };
>  
> +struct channel_hook {

Since this is RFCOMM specific and the concept of channels exists also
with L2CAP I'd include "rfcomm" somewhere in the struct name.

> @@ -232,6 +240,12 @@ static void btconn_free(struct btconn *conn)
>  		conn->cid_hooks = hook->next;
>  		free(hook);
>  	}
> +	while (conn->channel_hooks) {

Coding style: empty line before the while statement.

> +void bthost_add_channel_hook(struct bthost *bthost, uint16_t handle,
> +					uint8_t channel,
> +					bthost_channel_hook_func_t func,
> +					void *user_data);

Here you should also have "rfcomm" somewhere in the name since it's
RFCOMM specific and we don't people to confuse this with L2CAP.

Johan

^ permalink raw reply

* Re: [PATCH 2/6] tools/rfcomm-tester: Add RFCOMM client write test case
From: Johan Hedberg @ 2014-02-17 11:29 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392205301-4204-3-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> This will test sending data through RFCOMM socket from client to server.
> ---
>  tools/rfcomm-tester.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/rfcomm-tester.c b/tools/rfcomm-tester.c
> index 44df7e7..80448cb 100644
> --- a/tools/rfcomm-tester.c
> +++ b/tools/rfcomm-tester.c
> @@ -57,6 +57,9 @@ struct rfcomm_client_data {
>  	uint8_t server_channel;
>  	uint8_t client_channel;
>  	int expected_connect_err;
> +	const uint8_t *send_data;
> +	const uint8_t *read_data;
> +	uint16_t data_len;
>  };
>  
>  struct rfcomm_server_data {
> @@ -294,6 +297,15 @@ const struct rfcomm_client_data connect_success = {
>  	.client_channel = 0x0c
>  };
>  
> +const uint8_t data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
> +
> +const struct rfcomm_client_data connect_send_success = {
> +	.server_channel = 0x0c,
> +	.client_channel = 0x0c,
> +	.data_len = sizeof(data),
> +	.send_data = data
> +};
> +
>  const struct rfcomm_client_data connect_nval = {
>  	.server_channel = 0x0c,
>  	.client_channel = 0x0e,
> @@ -389,6 +401,13 @@ static gboolean rc_connect_cb(GIOChannel *io, GIOCondition cond,
>  		return false;
>  	}
>  
> +	if (client_data->send_data) {
> +		if (client_data->data_len != write(sk, client_data->send_data,
> +							client_data->data_len))

I'd rather have a separate ssize_t ret variable before the comparison
here.

> +static void client_hook_func(const void *data, uint16_t len,
> +							void *user_data)
> +{
> +	struct test_data *test_data = tester_get_data();
> +	const struct rfcomm_client_data *client_data = test_data->test_data;
> +
> +	if (memcmp(client_data->send_data, data, len))

Missing check of client_data->data_len == len before the memcmp?

Johan

^ permalink raw reply

* Re: [PATCH 3/6] tools/rfcomm-tester: Add RFCOMM server write test case
From: Johan Hedberg @ 2014-02-17 11:28 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392205301-4204-4-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> This will check data write from server to client.
> ---
>  tools/rfcomm-tester.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/tools/rfcomm-tester.c b/tools/rfcomm-tester.c
> index 80448cb..1c2563d 100644
> --- a/tools/rfcomm-tester.c
> +++ b/tools/rfcomm-tester.c
> @@ -66,6 +66,9 @@ struct rfcomm_server_data {
>  	uint8_t server_channel;
>  	uint8_t client_channel;
>  	bool expected_status;
> +	const uint8_t *send_data;
> +	const uint8_t *read_data;
> +	uint16_t data_len;

> +static void server_hook_func(const void *data, uint16_t len,
> +							void *user_data)
> +{
> +	struct test_data *test_data = tester_get_data();
> +	const struct rfcomm_server_data *server_data = test_data->test_data;
> +
> +	if (memcmp(server_data->send_data, data, len))

Don't you have to first check that server_data->data_len == len?

> +	if (server_data->send_data) {
> +		if (server_data->data_len != write(new_sk,
> +							server_data->send_data,
> +							server_data->data_len))

This looks ugly. I'd create a separate ssize_t ret variable, assing the
return value from write to it and then compare with data_len.

Johan

^ permalink raw reply

* Re: [PATCH 4/6] emulator/bthost: Add function to send RFCOMM UIH frames from bthost
From: Johan Hedberg @ 2014-02-17 11:26 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1392205301-4204-5-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Wed, Feb 12, 2014, Marcin Kraglak wrote:
> This will make RFCOMM UIH frame and fill with data passed by user.
> ---
>  emulator/bthost.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  emulator/bthost.h |  3 +++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index 92ae08a..6f3e538 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -2174,6 +2174,49 @@ void bthost_add_channel_hook(struct bthost *bthost, uint16_t handle,
>  	conn->channel_hooks = hook;
>  }
>  
> +void bthost_send_uih(struct bthost *bthost, uint16_t handle, uint16_t cid,
> +			uint8_t channel, const void *data, uint16_t len)

Could we call this something like bthost_send_rfcomm() or
bthost_send_rfcomm_data() for clarity?

I also don't like the fact that you have to pass both cid and channel to
this function. Would it not be better to store enough RFCOMM specific
context and be able to lookup the necessary info just based on the
channel?

> +	hdr = (struct rfcomm_hdr *)uih_frame;

Coding style here (space before the variable name).

Johan

^ permalink raw reply

* [PATCH BlueZ 4/4] build: Move unit tests build rules to Makefile.unit
From: Luiz Augusto von Dentz @ 2014-02-17  9:47 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392630452-22411-1-git-send-email-luiz.dentz@gmail.com>

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

---
 Makefile.am   | 99 +----------------------------------------------------------
 Makefile.unit | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 98 deletions(-)
 create mode 100644 Makefile.unit

diff --git a/Makefile.am b/Makefile.am
index f261535..12c6316 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -178,10 +178,10 @@ EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
 			profiles/input/input.conf profiles/proximity/proximity.conf
 
 test_scripts =
-unit_tests =
 
 include Makefile.tools
 include Makefile.obexd
+include Makefile.unit
 include android/Makefile.am
 
 if HID2HCI
@@ -223,103 +223,6 @@ AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
 AM_CPPFLAGS = -I$(builddir)/lib -I$(srcdir)/gdbus
 
 
-unit_tests += unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
-
-unit_test_eir_SOURCES = unit/test-eir.c src/eir.c src/uuid-helper.c
-unit_test_eir_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_test_uuid_SOURCES = unit/test-uuid.c
-unit_test_uuid_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_test_textfile_SOURCES = unit/test-textfile.c src/textfile.h src/textfile.c
-unit_test_textfile_LDADD = @GLIB_LIBS@
-
-unit_test_crc_SOURCES = unit/test-crc.c monitor/crc.h monitor/crc.c
-unit_test_crc_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-ringbuf unit/test-queue
-
-unit_test_ringbuf_SOURCES = unit/test-ringbuf.c \
-				src/shared/util.h src/shared/util.c \
-				src/shared/ringbuf.h src/shared/ringbuf.c
-unit_test_ringbuf_LDADD = @GLIB_LIBS@
-
-unit_test_queue_SOURCES = unit/test-queue.c \
-				src/shared/util.h src/shared/util.c \
-				src/shared/queue.h src/shared/queue.c
-unit_test_queue_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-mgmt
-
-unit_test_mgmt_SOURCES = unit/test-mgmt.c \
-				src/shared/io.h src/shared/io-glib.c \
-				src/shared/queue.h src/shared/queue.c \
-				src/shared/util.h src/shared/util.c \
-				src/shared/mgmt.h src/shared/mgmt.c
-unit_test_mgmt_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-sdp
-
-unit_test_sdp_SOURCES = unit/test-sdp.c \
-				src/shared/util.h src/shared/util.c \
-				src/sdpd.h src/sdpd-database.c \
-				src/sdpd-service.c src/sdpd-request.c
-unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_tests += unit/test-avdtp
-
-unit_test_avdtp_SOURCES = unit/test-avdtp.c \
-				src/shared/util.h src/shared/util.c \
-				src/log.h src/log.c \
-				src/shared/avdtp.c src/shared/avdtp.h
-unit_test_avdtp_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-avctp
-
-unit_test_avctp_SOURCES = unit/test-avctp.c \
-				src/shared/util.h src/shared/util.c \
-				src/log.h src/log.c \
-				src/shared/avctp.c src/shared/avctp.h
-unit_test_avctp_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-gdbus-client
-
-unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
-unit_test_gdbus_client_LDADD = gdbus/libgdbus-internal.la \
-				@GLIB_LIBS@ @DBUS_LIBS@
-
-unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \
-			unit/test-gobex-transfer unit/test-gobex-apparam
-
-unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
-						unit/test-gobex.c
-unit_test_gobex_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
-						unit/test-gobex-packet.c
-unit_test_gobex_packet_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
-						unit/test-gobex-header.c
-unit_test_gobex_header_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
-						unit/test-gobex-transfer.c
-unit_test_gobex_transfer_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
-						unit/test-gobex-apparam.c
-unit_test_gobex_apparam_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-lib
-
-unit_test_lib_SOURCES = unit/test-lib.c
-unit_test_lib_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-noinst_PROGRAMS += $(unit_tests)
-
-TESTS = $(unit_tests)
-
 pkgconfigdir = $(libdir)/pkgconfig
 
 if LIBRARY
diff --git a/Makefile.unit b/Makefile.unit
new file mode 100644
index 0000000..1d1893e
--- /dev/null
+++ b/Makefile.unit
@@ -0,0 +1,98 @@
+unit_tests =
+
+unit_tests += unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
+
+unit_test_eir_SOURCES = unit/test-eir.c src/eir.c src/uuid-helper.c
+unit_test_eir_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_test_uuid_SOURCES = unit/test-uuid.c
+unit_test_uuid_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_test_textfile_SOURCES = unit/test-textfile.c src/textfile.h src/textfile.c
+unit_test_textfile_LDADD = @GLIB_LIBS@
+
+unit_test_crc_SOURCES = unit/test-crc.c monitor/crc.h monitor/crc.c
+unit_test_crc_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-ringbuf unit/test-queue
+
+unit_test_ringbuf_SOURCES = unit/test-ringbuf.c \
+				src/shared/util.h src/shared/util.c \
+				src/shared/ringbuf.h src/shared/ringbuf.c
+unit_test_ringbuf_LDADD = @GLIB_LIBS@
+
+unit_test_queue_SOURCES = unit/test-queue.c \
+				src/shared/util.h src/shared/util.c \
+				src/shared/queue.h src/shared/queue.c
+unit_test_queue_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-mgmt
+
+unit_test_mgmt_SOURCES = unit/test-mgmt.c \
+				src/shared/io.h src/shared/io-glib.c \
+				src/shared/queue.h src/shared/queue.c \
+				src/shared/util.h src/shared/util.c \
+				src/shared/mgmt.h src/shared/mgmt.c
+unit_test_mgmt_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-sdp
+
+unit_test_sdp_SOURCES = unit/test-sdp.c \
+				src/shared/util.h src/shared/util.c \
+				src/sdpd.h src/sdpd-database.c \
+				src/sdpd-service.c src/sdpd-request.c
+unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_tests += unit/test-avdtp
+
+unit_test_avdtp_SOURCES = unit/test-avdtp.c \
+				src/shared/util.h src/shared/util.c \
+				src/log.h src/log.c \
+				src/shared/avdtp.c src/shared/avdtp.h
+unit_test_avdtp_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-avctp
+
+unit_test_avctp_SOURCES = unit/test-avctp.c \
+				src/shared/util.h src/shared/util.c \
+				src/log.h src/log.c \
+				src/shared/avctp.c src/shared/avctp.h
+unit_test_avctp_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-gdbus-client
+
+unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
+unit_test_gdbus_client_LDADD = gdbus/libgdbus-internal.la \
+				@GLIB_LIBS@ @DBUS_LIBS@
+
+unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \
+			unit/test-gobex-transfer unit/test-gobex-apparam
+
+unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+						unit/test-gobex.c
+unit_test_gobex_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+						unit/test-gobex-packet.c
+unit_test_gobex_packet_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+						unit/test-gobex-header.c
+unit_test_gobex_header_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+						unit/test-gobex-transfer.c
+unit_test_gobex_transfer_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+						unit/test-gobex-apparam.c
+unit_test_gobex_apparam_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-lib
+
+unit_test_lib_SOURCES = unit/test-lib.c
+unit_test_lib_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+noinst_PROGRAMS += $(unit_tests)
+
+TESTS = $(unit_tests)
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 3/4] shared: Move AVDTP implementation
From: Luiz Augusto von Dentz @ 2014-02-17  9:47 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392630452-22411-1-git-send-email-luiz.dentz@gmail.com>

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

This moves AVDTP implementation to shared since it does already contain
some unit tests it can be reused by e.g. audio plugin.
---
 Makefile.am                     | 2 +-
 android/Makefile.am             | 2 +-
 android/a2dp.c                  | 2 +-
 {android => src/shared}/avdtp.c | 0
 {android => src/shared}/avdtp.h | 0
 unit/test-avdtp.c               | 2 +-
 6 files changed, 4 insertions(+), 4 deletions(-)
 rename {android => src/shared}/avdtp.c (100%)
 rename {android => src/shared}/avdtp.h (100%)

diff --git a/Makefile.am b/Makefile.am
index a80c390..f261535 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -271,7 +271,7 @@ unit_tests += unit/test-avdtp
 unit_test_avdtp_SOURCES = unit/test-avdtp.c \
 				src/shared/util.h src/shared/util.c \
 				src/log.h src/log.c \
-				android/avdtp.c android/avdtp.h
+				src/shared/avdtp.c src/shared/avdtp.h
 unit_test_avdtp_LDADD = @GLIB_LIBS@
 
 unit_tests += unit/test-avctp
diff --git a/android/Makefile.am b/android/Makefile.am
index d1b3119..50b5a3b 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -31,11 +31,11 @@ android_bluetoothd_SOURCES = android/main.c \
 				src/shared/hfp.h src/shared/hfp.c \
 				src/shared/avctp.h src/shared/avctp.c \
 				src/shared/avrcp.h src/shared/avrcp.c \
+				src/shared/avdtp.h src/shared/avdtp.c \
 				android/bluetooth.h android/bluetooth.c \
 				android/hidhost.h android/hidhost.c \
 				android/ipc.h android/ipc.c \
 				android/audio-ipc.h android/audio-ipc.c \
-				android/avdtp.h android/avdtp.c \
 				android/a2dp.h android/a2dp.c \
 				android/avrcp.h android/avrcp.c \
 				android/socket.h android/socket.c \
diff --git a/android/a2dp.c b/android/a2dp.c
index 5d7dc78..f0a28ed 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -39,12 +39,12 @@
 #include "lib/sdp_lib.h"
 #include "profiles/audio/a2dp-codecs.h"
 #include "src/log.h"
+#include "src/shared/avdtp.h"
 #include "a2dp.h"
 #include "hal-msg.h"
 #include "ipc.h"
 #include "utils.h"
 #include "bluetooth.h"
-#include "avdtp.h"
 #include "avrcp.h"
 #include "audio-msg.h"
 #include "audio-ipc.h"
diff --git a/android/avdtp.c b/src/shared/avdtp.c
similarity index 100%
rename from android/avdtp.c
rename to src/shared/avdtp.c
diff --git a/android/avdtp.h b/src/shared/avdtp.h
similarity index 100%
rename from android/avdtp.h
rename to src/shared/avdtp.h
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 8fe5ce3..d8137f2 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -37,7 +37,7 @@
 
 #include "src/shared/util.h"
 #include "src/log.h"
-#include "android/avdtp.h"
+#include "src/shared/avdtp.h"
 
 struct test_pdu {
 	bool valid;
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 2/4] shared: Move AVCTP implementation
From: Luiz Augusto von Dentz @ 2014-02-17  9:47 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392630452-22411-1-git-send-email-luiz.dentz@gmail.com>

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

This moves AVCTP implementation to shared since it does already contain
some unit tests it can be reused by e.g. audio plugin.
---
 Makefile.am                     | 2 +-
 android/Makefile.am             | 2 +-
 {android => src/shared}/avctp.c | 0
 {android => src/shared}/avctp.h | 0
 src/shared/avrcp.c              | 2 +-
 unit/test-avctp.c               | 2 +-
 6 files changed, 4 insertions(+), 4 deletions(-)
 rename {android => src/shared}/avctp.c (100%)
 rename {android => src/shared}/avctp.h (100%)

diff --git a/Makefile.am b/Makefile.am
index 11f2aa1..a80c390 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -279,7 +279,7 @@ unit_tests += unit/test-avctp
 unit_test_avctp_SOURCES = unit/test-avctp.c \
 				src/shared/util.h src/shared/util.c \
 				src/log.h src/log.c \
-				android/avctp.c android/avctp.h
+				src/shared/avctp.c src/shared/avctp.h
 unit_test_avctp_LDADD = @GLIB_LIBS@
 
 unit_tests += unit/test-gdbus-client
diff --git a/android/Makefile.am b/android/Makefile.am
index 3cc0687..d1b3119 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -29,6 +29,7 @@ android_bluetoothd_SOURCES = android/main.c \
 				src/shared/mgmt.h src/shared/mgmt.c \
 				src/shared/ringbuf.h src/shared/ringbuf.c \
 				src/shared/hfp.h src/shared/hfp.c \
+				src/shared/avctp.h src/shared/avctp.c \
 				src/shared/avrcp.h src/shared/avrcp.c \
 				android/bluetooth.h android/bluetooth.c \
 				android/hidhost.h android/hidhost.c \
@@ -36,7 +37,6 @@ android_bluetoothd_SOURCES = android/main.c \
 				android/audio-ipc.h android/audio-ipc.c \
 				android/avdtp.h android/avdtp.c \
 				android/a2dp.h android/a2dp.c \
-				android/avctp.h android/avctp.c \
 				android/avrcp.h android/avrcp.c \
 				android/socket.h android/socket.c \
 				android/pan.h android/pan.c \
diff --git a/android/avctp.c b/src/shared/avctp.c
similarity index 100%
rename from android/avctp.c
rename to src/shared/avctp.c
diff --git a/android/avctp.h b/src/shared/avctp.h
similarity index 100%
rename from android/avctp.h
rename to src/shared/avctp.h
diff --git a/src/shared/avrcp.c b/src/shared/avrcp.c
index 32bd703..1325284 100644
--- a/src/shared/avrcp.c
+++ b/src/shared/avrcp.c
@@ -32,7 +32,7 @@
 
 #include "src/log.h"
 
-#include "android/avctp.h"
+#include "avctp.h"
 #include "avrcp.h"
 
 struct avrcp {
diff --git a/unit/test-avctp.c b/unit/test-avctp.c
index be1dfd7..83bf2c5 100644
--- a/unit/test-avctp.c
+++ b/unit/test-avctp.c
@@ -38,7 +38,7 @@
 #include "src/shared/util.h"
 #include "src/log.h"
 
-#include "android/avctp.h"
+#include "src/shared/avctp.h"
 
 struct test_pdu {
 	bool valid;
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 1/4] shared: Add initial AVRCP code
From: Luiz Augusto von Dentz @ 2014-02-17  9:47 UTC (permalink / raw)
  To: linux-bluetooth

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

The patch makes AVRCP to be transport agnostic so that it can be used in
with socket pair to build unit tests.

The idea is that all AVRCP specific logic will stay on src/shared/avrcp
and connecting handling elsewhere.
---
 android/Android.mk              |  1 +
 android/Makefile.am             |  1 +
 android/avrcp.c                 | 42 ++++++++++++-----------
 src/shared/avrcp.c              | 75 +++++++++++++++++++++++++++++++++++++++++
 {android => src/shared}/avrcp.h | 13 ++++---
 5 files changed, 108 insertions(+), 24 deletions(-)
 create mode 100644 src/shared/avrcp.c
 copy {android => src/shared}/avrcp.h (65%)

diff --git a/android/Android.mk b/android/Android.mk
index 2481a2c..eadf6d4 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -39,6 +39,7 @@ LOCAL_SRC_FILES := \
 	bluez/android/avdtp.c \
 	bluez/android/a2dp.c \
 	bluez/android/avctp.c \
+	bluez/android/avrcp-lib.c \
 	bluez/android/avrcp.c \
 	bluez/android/pan.c \
 	bluez/android/handsfree.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 1913b42..3cc0687 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -29,6 +29,7 @@ android_bluetoothd_SOURCES = android/main.c \
 				src/shared/mgmt.h src/shared/mgmt.c \
 				src/shared/ringbuf.h src/shared/ringbuf.c \
 				src/shared/hfp.h src/shared/hfp.c \
+				src/shared/avrcp.h src/shared/avrcp.c \
 				android/bluetooth.h android/bluetooth.c \
 				android/hidhost.h android/hidhost.c \
 				android/ipc.h android/ipc.c \
diff --git a/android/avrcp.c b/android/avrcp.c
index b8304f5..65b3417 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -32,12 +32,12 @@
 #include "lib/bluetooth.h"
 #include "lib/sdp.h"
 #include "lib/sdp_lib.h"
+#include "src/shared/avrcp.h"
 #include "src/log.h"
 #include "bluetooth.h"
 #include "avrcp.h"
 #include "hal-msg.h"
 #include "ipc.h"
-#include "avctp.h"
 
 #define L2CAP_PSM_AVCTP 0x17
 
@@ -53,7 +53,7 @@ static GIOChannel *server = NULL;
 
 struct avrcp_device {
 	bdaddr_t	dst;
-	struct avctp	*session;
+	struct avrcp	*session;
 	GIOChannel	*io;
 };
 
@@ -133,7 +133,7 @@ static void avrcp_device_free(void *data)
 	struct avrcp_device *dev = data;
 
 	if (dev->session)
-		avctp_shutdown(dev->session);
+		avrcp_shutdown(dev->session);
 
 	if (dev->io) {
 		g_io_channel_shutdown(dev->io, FALSE, NULL);
@@ -168,6 +168,17 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
 	return bacmp(&dev->dst, dst);
 }
 
+static struct avrcp_device *avrcp_device_find(const bdaddr_t *dst)
+{
+	GSList *l;
+
+	l = g_slist_find_custom(devices, dst, device_cmp);
+	if (!l)
+		return NULL;
+
+	return l->data;
+}
+
 static void disconnect_cb(void *data)
 {
 	struct avrcp_device *dev = data;
@@ -186,7 +197,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	char address[18];
 	uint16_t imtu, omtu;
 	GError *gerr = NULL;
-	GSList *l;
 	int fd;
 
 	if (err) {
@@ -209,9 +219,8 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 
 	ba2str(&dst, address);
 
-	l = g_slist_find_custom(devices, &dst, device_cmp);
-	if (l) {
-		dev = l->data;
+	dev = avrcp_device_find(&dst);
+	if (dev) {
 		if (dev->session) {
 			error("Unexpected connection");
 			return;
@@ -222,17 +231,17 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	}
 
 	fd = g_io_channel_unix_get_fd(chan);
-	dev->session = avctp_new(fd, imtu, omtu, 0x0100);
 
+	dev->session = avrcp_new(fd, imtu, omtu, 0x0100);
 	if (!dev->session) {
 		avrcp_device_free(dev);
 		return;
 	}
 
-	avctp_set_destroy_cb(dev->session, disconnect_cb, dev);
+	avrcp_set_destroy_cb(dev->session, disconnect_cb, dev);
 
 	/* FIXME: get the real name of the device */
-	avctp_init_uinput(dev->session, "bluetooth", address);
+	avrcp_init_uinput(dev->session, "bluetooth", address);
 
 	g_io_channel_set_close_on_unref(chan, FALSE);
 
@@ -331,12 +340,10 @@ void bt_avrcp_connect(const bdaddr_t *dst)
 {
 	struct avrcp_device *dev;
 	char addr[18];
-	GSList *l;
 
 	DBG("");
 
-	l = g_slist_find_custom(devices, dst, device_cmp);
-	if (l)
+	if (avrcp_device_find(dst))
 		return;
 
 	dev = avrcp_device_new(dst);
@@ -352,18 +359,15 @@ void bt_avrcp_connect(const bdaddr_t *dst)
 void bt_avrcp_disconnect(const bdaddr_t *dst)
 {
 	struct avrcp_device *dev;
-	GSList *l;
 
 	DBG("");
 
-	l = g_slist_find_custom(devices, dst, device_cmp);
-	if (!l)
+	dev = avrcp_device_find(dst);
+	if (!dev)
 		return;
 
-	dev = l->data;
-
 	if (dev->session) {
-		avctp_shutdown(dev->session);
+		avrcp_shutdown(dev->session);
 		return;
 	}
 
diff --git a/src/shared/avrcp.c b/src/shared/avrcp.c
new file mode 100644
index 0000000..32bd703
--- /dev/null
+++ b/src/shared/avrcp.c
@@ -0,0 +1,75 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdbool.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+
+#include "src/log.h"
+
+#include "android/avctp.h"
+#include "avrcp.h"
+
+struct avrcp {
+	struct avctp	*session;
+};
+
+void avrcp_shutdown(struct avrcp *session)
+{
+	if (session->session)
+		avctp_shutdown(session->session);
+
+	g_free(session);
+}
+
+struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
+{
+	struct avrcp *session;
+
+	session = g_new0(struct avrcp, 1);
+
+	session->session = avctp_new(fd, imtu, omtu, version);
+	if (!session->session) {
+		g_free(session);
+		return NULL;
+	}
+
+	return session;
+}
+
+void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
+							void *user_data)
+{
+	avctp_set_destroy_cb(session->session, cb, user_data);
+}
+
+int avrcp_init_uinput(struct avrcp *session, const char *name,
+							const char *address)
+{
+	return avctp_init_uinput(session->session, name, address);
+}
diff --git a/android/avrcp.h b/src/shared/avrcp.h
similarity index 65%
copy from android/avrcp.h
copy to src/shared/avrcp.h
index 1fcd953..7955d56 100644
--- a/android/avrcp.h
+++ b/src/shared/avrcp.h
@@ -2,7 +2,7 @@
  *
  *  BlueZ - Bluetooth protocol stack for Linux
  *
- *  Copyright (C) 2013-2014  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
  *
  *
  *  This library is free software; you can redistribute it and/or
@@ -21,8 +21,11 @@
  *
  */
 
-bool bt_avrcp_register(const bdaddr_t *addr);
-void bt_avrcp_unregister(void);
+typedef void (*avrcp_destroy_cb_t) (void *user_data);
 
-void bt_avrcp_connect(const bdaddr_t *dst);
-void bt_avrcp_disconnect(const bdaddr_t *dst);
+struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
+void avrcp_shutdown(struct avrcp *session);
+void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
+							void *user_data);
+int avrcp_init_uinput(struct avrcp *session, const char *name,
+							const char *address);
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH BlueZ 8/8] doc/obex-api: Update documentation
From: Andrei Emeltchenko @ 2014-02-17  7:24 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth, patrick.ohly
In-Reply-To: <1392393184-15266-8-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Fri, Feb 14, 2014 at 05:53:04PM +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds Suspend and Resume methods and 'suspended' value as status in
> the Transfer interface documentation.
> ---
>  doc/obex-api.txt | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/doc/obex-api.txt b/doc/obex-api.txt
> index 1f22fea..0f57ce1 100644
> --- a/doc/obex-api.txt
> +++ b/doc/obex-api.txt
> @@ -90,12 +90,26 @@ Methods		void Cancel()
>  					 org.bluez.obex.Error.InProgress
>  					 org.bluez.obex.Error.Failed
>  
> +		void Suspend()
> +
> +			Suspend transference.

would transfer sound better then transference ?

Best regards 
Andrei Emeltchenko 

> +
> +			Possible errors: org.bluez.obex.Error.NotAuthorized
> +					 org.bluez.obex.Error.NotInProgress
> +
> +		void Resume()
> +
> +			Resume transference.
> +
> +			Possible errors: org.bluez.obex.Error.NotAuthorized
> +					 org.bluez.obex.Error.NotInProgress
> +
>  Properties	string Status [readonly]
>  
>  			Inform the current status of the transfer.
>  
> -			Possible values: "queued", "active", "complete" or
> -					"error"
> +			Possible values: "queued", "active", "suspended",
> +					"complete" or "error"
>  
>  		object Session [readonly]
>  
> -- 
> 1.8.5.3
> 
> --
> 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

* [RFC v5] doc: Add management commands and events for privacy support
From: Marcel Holtmann @ 2014-02-16 21:06 UTC (permalink / raw)
  To: linux-bluetooth

---
 doc/mgmt-api.txt | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 175 insertions(+)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index ed9618b877fd..5a4172dfa004 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -213,6 +213,7 @@ Read Controller Information Command
 		11	Advertising
 		12	Secure Connections
 		13	Debug Keys
+		14	Privacy
 
 	This command generates a Command Complete event on success or
 	a Command Status event on failure.
@@ -730,6 +731,17 @@ Load Long Term Keys Command
 	again upon the receiption of New Long Term Key events since the
 	kernel updates its list automatically.
 
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	Unresolvable random addresses and resolvable random addresses are
+	not valid and will be rejected.
+
 	Currently defined Key_Type values are:
 
 		0x00	Unauthenticated key
@@ -1386,6 +1398,15 @@ Set Static Address Command
 	The special BDADDR_ANY address (00:00:00:00:00:00) can be used
 	to disable the static address.
 
+	When a controller has a public address (which is required for
+	all dual-mode controllers), this address is not used. Only when
+	the controller information reports BDADDR_ANY (00:00:00:00:00:00),
+	it is required to configure a static address first.
+
+	If privacy mode is enabled and the controller is single mode
+	LE only without a public address, the static random address is
+	used as identity address.
+
 	This command generates a Command Complete event on success or a
 	Command Status event on failure.
 
@@ -1475,6 +1496,76 @@ Set Debug Keys Command
 				Invalid Index
 
 
+Set Privacy Command
+===================
+
+	Command Code:		0x002F
+	Controller Index:	<controller id>
+	Command Parameters:	Privacy (1 Octet)
+				Identity_Resolving_Key (16 Octets)
+	Return Parameters:	Current_Settings (4 Octets)
+
+	This command is used to enable Low Energy Privacy feature using
+	resolvable private addresses.
+
+	The value 0x00 disables privacy mode, the value 0x01 enables
+	privacy mode.
+
+	When the controller has a public address (mandatory for dual-mode
+	controllers) it is used as identity address. In case the controller
+	is single mode LE only without a public address, it is required
+	to configure a static random andress first. The privacy mode can
+	only be enabled when an identity address is available.
+
+	The Identity_Resolving_Key is the local key assigned for the local
+	resolvable private address.
+
+	Possible errors:	Busy
+				Not Supported
+				Invalid Parameters
+				Invalid Index
+
+
+Load Identity Resolving Keys Command
+====================================
+
+	Command Code:		0x0030
+	Controller Index:	<controller id>
+	Command Parameters:	Key_Count (2 Octets)
+				Key1 {
+					Address (6 Octets)
+					Address_Type (1 Octet)
+					Value (16 Octets)
+				}
+				Key2 {  }
+				...
+	Return Parameters:
+
+	This command is used to feed the kernel with currently known
+	identity resolving keys. The command does not need to be called
+	again upon the receiption of New Identity Resolving Key events
+	since the kernel updates its list automatically.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	Unresolvable random addresses and resolvable random addresses are
+	not valid and will be rejected.
+
+	This command can be used when the controller is not powered.
+
+	This command generates a Command Complete event on success or
+	a Command Status event on failure.
+
+	Possible errors:	Invalid Parameters
+				Invalid Index
+
+
 Command Complete Event
 ======================
 
@@ -1643,6 +1734,18 @@ Event Parameters	Store_Hint (1 Octet)
 	to store the key persistently or not (e.g. this would not be set
 	if the authentication requirement was "No Bonding").
 
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	For unresolvable random addresses and resolvable random addresses
+	without identity information and identity resolving key, the
+	Store_Hint will be set to not store the long term key.
+
 	Currently defined Key_Type values are:
 
 		0x00	Unauthenticated key
@@ -1675,6 +1778,11 @@ Event Parameters	Address (6 Octets)
 	This event indicates that a successful baseband connection has
 	been created to the remote device.
 
+	The EIR_Data might contain the LE Bluetooth Device Address type
+	providing the identity address and identity address type. For
+	random resolvable address where the identity resolving key is
+	known, the identity information will be provided this way.
+
 
 Device Disconnected Event
 =========================
@@ -1828,6 +1936,11 @@ Event Parameters	Address (6 Octets)
 	false-positives for this flag so user space should be able to
 	handle getting something else as a PIN Request when pairing.
 
+	The EIR_Data might contain the LE Bluetooth Device Address type
+	providing the identity address and identity address type. For
+	random resolvable address where the identity resolving key is
+	known, the identity information will be provided this way.
+
 
 Discovering Event
 =================
@@ -1904,3 +2017,65 @@ Event Parameters	Address (6 Octets)
 	The Passkey parameter indicates the passkey to be shown to the
 	user whereas the Entered parameter indicates how many characters
 	the user has entered on the remote side.
+
+
+Device Resolved Event
+=====================
+
+Event Code		0x0018
+Controller Index:	<controller id>
+Event Parameters	Address (6 Octets)
+			Address_Type (1 Octet)
+			Flags (4 Octets)
+			EIR_Data_Length (2 Octets)
+			EIR_Data (0-65535 Octets)
+
+	This event indicates that a random resolvable address has been
+	resolved into an identity of the device.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	Reserved (not in use)
+		2	LE Random
+
+	The following bits are defined for the Flags parameter:
+		0	Reserved (not in use)
+		1	Reserved (not in use)
+
+	During pairing the remote device can provide identity information
+	and identity resolving key. In that case this event will provide
+	the new identity information matching the random resolvable address.
+
+	This event can also be send at any time a new random resolvable
+	address has been found and during scanning and then successfully
+	resolved into an identity.
+
+	The EIR_Data contains the LE Bluetooth Device Address type
+	providing the identity address and identity address type.
+
+
+New Identity Resolving Key Event
+================================
+
+Event Code		0x0019
+Controller Index	<controller id>
+Event Parameters	Store_Hint (1 Octet)
+			Key {
+				Address (6 Octets)
+				Address_Type (1 Octet)
+				Value (16 Octets)
+			}
+
+	This event indicates that a new identity resolving key has been
+	generated for a remote device.
+
+	The Store_Hint parameter indicates whether the host is expected
+	to store the key persistently or not.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH 11/11] android/tester: Make bt_callbacks thread-safe
From: Szymon Janc @ 2014-02-16 21:04 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Anderson Lizardo, Andrzej Kaczmarek, BlueZ development
In-Reply-To: <EF441CC3-EFCF-4A2A-8ADF-D9F6FF262E4D@holtmann.org>

Hi Marcel and Anderson,

On Sunday 02 of February 2014 08:55:49 Marcel Holtmann wrote:
> Hi Anderson,
> 
> >> This patch adds wrappers for BT HAL callback which execute them in main
> >> thread instead of notification_handler() thread. Otherwise test
> >> execution is prone to race conditions since we do not provide any
> >> locking mechanism for tester.
> > 
> > In my opinion, this is becoming too messy. I'm getting races even
> > inside the emulator code: sometimes bthost->ncmd becomes zero before a
> > HCI command is sent by the emulated host because the Command Status /
> > Command Complete comes after the command is written to the socket, but
> > before bthost->ncmd is decremented.
> > 
> > Also try running android-tester under valgrind. At least for me, I get
> > a few failures that I don't have when running without valgrind (at
> > least one in HIDHost apparently due to if_bluetooth->enable() not
> > being called on test setup and thus the tests rely on finishing before
> > the controller is powered off by the kernel after initialization).
> > 
> > IMHO, the best approach would be to keep all HAL API usage in a
> > separate process, and keep android-tester single-threaded. Of course,
> > this could extra complexity for the required IPC between
> > android-tester and this new process...
> > 
> > Again, I'm not familiar with how HAL API works, all this is just based
> > on my failed attempt to make android-tester run reliably under
> > valgrind.
> 
> I have to agree. We might better spawn processes for this. Our emulator code
> was never designed to be thread safe and never will be. We are just hiding
> the real problem here and it will break somewhere else later on.

I think using g_idle_add to have checks executes in right thread context 
pretty clear and easy to follow. Spawning processes will require dedicated IPC 
that will wrap either HAL or emulator and that will be quite complicated 
comparing to using g_idle_add. Jakub did some initial implementation for this 
and it adds ~800 sloc (and will be more in future...).

So I would go with using g_idle_add but refactor propose patch to emphasize 
that those are tests checks that execute in mainloop context, not HAL 
callbacks.

-- 
BR
Szymon Janc

^ permalink raw reply

* [PATCH 2/2] Bluetooth: Fix sending wrong store hint for new long term keys
From: Marcel Holtmann @ 2014-02-16 20:59 UTC (permalink / raw)
  To: linux-bluetooth

The long term keys should only be stored when they belong to an
indentity address. The identity address can either be a public
address or a random static address.

For all other addresses (unresovable or resolvable) tell userspace
that the long term key is not persistent.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e7746690d620..58d2f9bf241f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2685,6 +2685,7 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 {
 	struct smp_ltk *key, *old_key;
 	bool master = ltk_type_master(type);
+	u8 persistent;
 
 	old_key = hci_find_ltk_by_addr(hdev, bdaddr, addr_type, master);
 	if (old_key)
@@ -2708,8 +2709,13 @@ int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
 	if (!new_key)
 		return 0;
 
+	if (addr_type == ADDR_LE_DEV_RANDOM && (bdaddr->b[5] & 0xc0) != 0xc0)
+		persistent = 0;
+	else
+		persistent = 1;
+
 	if (type == HCI_SMP_LTK || type == HCI_SMP_LTK_SLAVE)
-		mgmt_new_ltk(hdev, key, 1);
+		mgmt_new_ltk(hdev, key, persistent);
 
 	return 0;
 }
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH 1/2] Bluetooth: Restrict long term keys to public and static addresses
From: Marcel Holtmann @ 2014-02-16 20:59 UTC (permalink / raw)
  To: linux-bluetooth

The long term keys should be associated with an identity address. Valid
identity addresses are public addresses or static addresses. So only
allow these two as valid address information for long term keys.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/mgmt.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ce7ef339b1c4..70bef3d5db57 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4162,9 +4162,19 @@ static bool ltk_is_valid(struct mgmt_ltk_info *key)
 {
 	if (key->master != 0x00 && key->master != 0x01)
 		return false;
-	if (!bdaddr_type_is_le(key->addr.type))
-		return false;
-	return true;
+
+	switch (key->addr.type) {
+	case BDADDR_LE_PUBLIC:
+		return true;
+
+	case BDADDR_LE_RANDOM:
+		/* Two most significant bits shall be set */
+		if ((key->addr.bdaddr.b[5] & 0xc0) != 0xc0)
+			return false;
+		return true;
+	}
+
+	return false;
 }
 
 static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
-- 
1.8.5.3


^ permalink raw reply related

* [RFC v4] doc: Add management commands and events for privacy support
From: Marcel Holtmann @ 2014-02-16 20:13 UTC (permalink / raw)
  To: linux-bluetooth

---
 doc/mgmt-api.txt | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 175 insertions(+)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 697336092798..554ff2b706cd 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -213,6 +213,7 @@ Read Controller Information Command
 		11	Advertising
 		12	Secure Connections
 		13	Debug Keys
+		14	Privacy
 
 	This command generates a Command Complete event on success or
 	a Command Status event on failure.
@@ -730,6 +731,17 @@ Load Long Term Keys Command
 	again upon the receiption of New Long Term Key events since the
 	kernel updates its list automatically.
 
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	Unresolvable random addresses and resolvable random addresses are
+	not valid and will be rejected.
+
 	Currently defined Key_Type values are:
 
 		0x00	Unauthenticated key
@@ -1386,6 +1398,15 @@ Set Static Address Command
 	The special BDADDR_ANY address (00:00:00:00:00:00) can be used
 	to disable the static address.
 
+	When a controller has a public address (which is required for
+	all dual-mode controllers), this address is not used. Only when
+	the controller information reports BDADDR_ANY (00:00:00:00:00:00),
+	it is required to configure a static address first.
+
+	If privacy mode is enabled and the controller is single mode
+	LE only without a public address, the static random address is
+	used as identity address.
+
 	This command generates a Command Complete event on success or a
 	Command Status event on failure.
 
@@ -1475,6 +1496,76 @@ Set Debug Keys Command
 				Invalid Index
 
 
+Set Privacy Command
+===================
+
+	Command Code:		0x002F
+	Controller Index:	<controller id>
+	Command Parameters:	Privacy (1 Octet)
+				Identity_Resolving_Key (16 Octets)
+	Return Parameters:	Current_Settings (4 Octets)
+
+	This command is used to enable Low Energy Privacy feature using
+	resolvable private addresses.
+
+	The value 0x00 disables privacy mode, the value 0x01 enables
+	privacy mode.
+
+	When the controller has a public address (mandatory for dual-mode
+	controllers) it is used as identity address. In case the controller
+	is single mode LE only without a public address, it is required
+	to configure a static random andress first. The privacy mode can
+	only be enabled when an identity address is available.
+
+	The Identity_Resolving_Key is the local key assigned for the local
+	resolvable private address.
+
+	Possible errors:	Busy
+				Not Supported
+				Invalid Parameters
+				Invalid Index
+
+
+Load Identity Resolving Keys Command
+====================================
+
+	Command Code:		0x0030
+	Controller Index:	<controller id>
+	Command Parameters:	Key_Count (2 Octets)
+				Key1 {
+					Address (6 Octets)
+					Address_Type (1 Octet)
+					Value (16 Octets)
+				}
+				Key2 {  }
+				...
+	Return Parameters:
+
+	This command is used to feed the kernel with currently known
+	identity resolving keys. The command does not need to be called
+	again upon the receiption of New Identity Resolving Key events
+	since the kernel updates its list automatically.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	Unresolvable random addresses and resolvable random addresses are
+	not valid and will be rejected.
+
+	This command can be used when the controller is not powered.
+
+	This command generates a Command Complete event on success or
+	a Command Status event on failure.
+
+	Possible errors:	Invalid Parameters
+				Invalid Index
+
+
 Command Complete Event
 ======================
 
@@ -1640,6 +1731,18 @@ Event Parameters	Store_Hint (1 Octet)
 	to store the key persistently or not (e.g. this would not be set
 	if the authentication requirement was "No Bonding").
 
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
+
+	For unresolvable random addresses and resolvable random addresses
+	without identity information and identity resolving key, the
+	long term key will not be provided.
+
 	Currently defined Key_Type values are:
 
 		0x00	Unauthenticated key
@@ -1669,6 +1772,11 @@ Event Parameters	Address (6 Octets)
 	This event indicates that a successful baseband connection has
 	been created to the remote device.
 
+	The EIR_Data might contain the LE Bluetooth Device Address type
+	providing the identity address and identity address type. For
+	random resolvable address where the identity resolving key is
+	known, the identity information will be provided this way.
+
 
 Device Disconnected Event
 =========================
@@ -1822,6 +1930,11 @@ Event Parameters	Address (6 Octets)
 	false-positives for this flag so user space should be able to
 	handle getting something else as a PIN Request when pairing.
 
+	The EIR_Data might contain the LE Bluetooth Device Address type
+	providing the identity address and identity address type. For
+	random resolvable address where the identity resolving key is
+	known, the identity information will be provided this way.
+
 
 Discovering Event
 =================
@@ -1898,3 +2011,65 @@ Event Parameters	Address (6 Octets)
 	The Passkey parameter indicates the passkey to be shown to the
 	user whereas the Entered parameter indicates how many characters
 	the user has entered on the remote side.
+
+
+Device Resolved Event
+=====================
+
+Event Code		0x0018
+Controller Index:	<controller id>
+Event Parameters	Address (6 Octets)
+			Address_Type (1 Octet)
+			Flags (4 Octets)
+			EIR_Data_Length (2 Octets)
+			EIR_Data (0-65535 Octets)
+
+	This event indicates that a random resolvable address has been
+	resolved into an identity of the device.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	Reserved (not in use)
+		2	LE Random
+
+	The following bits are defined for the Flags parameter:
+		0	Reserved (not in use)
+		1	Reserved (not in use)
+
+	During pairing the remote device can provide identity information
+	and identity resolving key. In that case this event will provide
+	the new identity information matching the random resolvable address.
+
+	This event can also be send at any time a new random resolvable
+	address has been found and during scanning and then successfully
+	resolved into an identity.
+
+	The EIR_Data contains the LE Bluetooth Device Address type
+	providing the identity address and identity address type.
+
+
+New Identity Resolving Key Event
+================================
+
+Event Code		0x0019
+Controller Index	<controller id>
+Event Parameters	Store_Hint (1 Octet)
+			Key {
+				Address (6 Octets)
+				Address_Type (1 Octet)
+				Value (16 Octets)
+			}
+
+	This event indicates that a new identity resolving key has been
+	generated for a remote device.
+
+	The Store_Hint parameter indicates whether the host is expected
+	to store the key persistently or not.
+
+	Possible values for the Address_Type parameter:
+		0	Reserved (not in use)
+		1	LE Public
+		2	LE Random
+
+	The provided Address and Address_Type are the identity of
+	a device. So either its public address or static random address.
-- 
1.8.5.3


^ 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