Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH 1/4] android/audio: Prefix error log with "a2dp"
From: Luiz Augusto von Dentz @ 2014-01-09 12:06 UTC (permalink / raw)
  To: Lukasz Rymanowski
  Cc: linux-bluetooth@vger.kernel.org, Szymon Janc, Johan Hedberg
In-Reply-To: <1389267956-2297-2-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Thu, Jan 9, 2014 at 1:45 PM, Lukasz Rymanowski
<lukasz.rymanowski@tieto.com> wrote:
> ---
>  android/hal-audio.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/android/hal-audio.c b/android/hal-audio.c
> index 59a8269..7a7c111 100644
> --- a/android/hal-audio.c
> +++ b/android/hal-audio.c
> @@ -423,7 +423,8 @@ static bool create_audio_ipc(void)
>         sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
>         if (sk < 0) {
>                 err = errno;
> -               error("Failed to create socket: %d (%s)", err, strerror(err));
> +               error("a2dp: Failed to create socket: %d (%s)", err,
> +                                                               strerror(err));
>                 return false;
>         }
>
> @@ -435,13 +436,14 @@ static bool create_audio_ipc(void)
>
>         if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
>                 err = errno;
> -               error("Failed to bind socket: %d (%s)", err, strerror(err));
> +               error("a2dp: Failed to bind socket: %d (%s)", err,
> +                                                               strerror(err));
>                 goto failed;
>         }
>
>         if (listen(sk, 1) < 0) {
>                 err = errno;
> -               error("Failed to listen on the socket: %d (%s)", err,
> +               error("a2dp: Failed to listen on the socket: %d (%s)", err,
>                                                                 strerror(err));
>                 goto failed;
>         }
> @@ -449,7 +451,7 @@ static bool create_audio_ipc(void)
>         audio_sk = accept(sk, NULL, NULL);
>         if (audio_sk < 0) {
>                 err = errno;
> -               error("Failed to accept socket: %d (%s)", err, strerror(err));
> +               error("a2dp: Failed to accept socket: %d (%s)", err, strerror(err));
>                 goto failed;
>         }
>
> @@ -470,7 +472,7 @@ static void *ipc_handler(void *data)
>
>         while (!done) {
>                 if(!create_audio_ipc()) {
> -                       error("Failed to create listening socket");
> +                       error("a2dp: Failed to create listening socket");
>                         sleep(1);
>                         continue;
>                 }
> @@ -511,7 +513,7 @@ static int audio_open(const hw_module_t *module, const char *name,
>         DBG("");
>
>         if (strcmp(name, AUDIO_HARDWARE_INTERFACE)) {
> -               error("interface %s not matching [%s]", name,
> +               error("ad2p: interface %s not matching [%s]", name,
>                                                 AUDIO_HARDWARE_INTERFACE);
>                 return -EINVAL;
>         }
> @@ -547,7 +549,7 @@ static int audio_open(const hw_module_t *module, const char *name,
>         err = pthread_create(&ipc_th, NULL, ipc_handler, NULL);
>         if (err < 0) {
>                 ipc_th = 0;
> -               error("Failed to start Audio IPC thread: %d (%s)",
> +               error("a2dp: Failed to start Audio IPC thread: %d (%s)",
>                                                         -err, strerror(-err));
>                 return (-err);
>         }
> --
> 1.8.4

I prefer you use the term Audio as prefix e.g. Audo: Failed to start
IPC thread as this may be used for more than just A2DP.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH 4/4] android/audio: Add audio_ipc_cmd
From: Lukasz Rymanowski @ 2014-01-09 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, szymon.janc, johan.hedberg, Lukasz Rymanowski
In-Reply-To: <1389267956-2297-1-git-send-email-lukasz.rymanowski@tieto.com>

Adds function to handle send/receive on audio_sk

---
 android/Makefile.am |   1 +
 android/hal-audio.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 166 insertions(+), 2 deletions(-)

diff --git a/android/Makefile.am b/android/Makefile.am
index 0a32a95..94e5329 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -117,6 +117,7 @@ android_android_tester_LDFLAGS = -pthread
 noinst_LTLIBRARIES += android/libaudio-internal.la
 
 android_libaudio_internal_la_SOURCES = android/audio-msg.h \
+					android/hal-msg.h \
 					android/hal-audio.c \
 					android/hardware/audio.h \
 					android/hardware/audio_effect.h \
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 95efa89..e515f53 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -31,12 +31,14 @@
 
 #include "audio-msg.h"
 #include "hal-log.h"
+#include "hal-msg.h"
 
 static int audio_sk = -1;
 static bool close_thread = false;
 
 static pthread_t ipc_th = 0;
 static pthread_mutex_t close_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t sk_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 struct a2dp_audio_dev {
 	struct audio_hw_device dev;
@@ -412,13 +414,174 @@ static int audio_close(hw_device_t *device)
 	return 0;
 }
 
-static int open_endpoint_cmd(void)
+static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len,
+			void *param, size_t *rsp_len, void *rsp, int *fd)
 {
-	DBG("Not Implemented");
+	ssize_t ret;
+	struct msghdr msg;
+	struct iovec iv[2];
+	struct hal_hdr cmd;
+	char cmsgbuf[CMSG_SPACE(sizeof(int))];
+	struct hal_status s;
+	size_t s_len = sizeof(s);
+
+	if (audio_sk < 0) {
+		error("a2dp: Invalid cmd socket passed to audio_sk");
+		goto failed;
+	}
+
+	if (!rsp || !rsp_len) {
+		memset(&s, 0, s_len);
+		rsp_len = &s_len;
+		rsp = &s;
+	}
+
+	memset(&msg, 0, sizeof(msg));
+	memset(&cmd, 0, sizeof(cmd));
+
+	cmd.service_id = service_id;
+	cmd.opcode = opcode;
+	cmd.len = len;
+
+	iv[0].iov_base = &cmd;
+	iv[0].iov_len = sizeof(cmd);
+
+	iv[1].iov_base = param;
+	iv[1].iov_len = len;
+
+	msg.msg_iov = iv;
+	msg.msg_iovlen = 2;
+
+	pthread_mutex_lock(&sk_mutex);
+
+	ret = sendmsg(audio_sk, &msg, 0);
+	if (ret < 0) {
+		error("a2dp: Sending command failed:%s", strerror(errno));
+		pthread_mutex_unlock(&sk_mutex);
+		goto failed;
+	}
+
+	/* socket was shutdown */
+	if (ret == 0) {
+		error("a2dp: Command socket closed");
+		goto failed;
+	}
+
+	memset(&msg, 0, sizeof(msg));
+	memset(&cmd, 0, sizeof(cmd));
+
+	iv[0].iov_base = &cmd;
+	iv[0].iov_len = sizeof(cmd);
+
+	iv[1].iov_base = rsp;
+	iv[1].iov_len = *rsp_len;
+
+	msg.msg_iov = iv;
+	msg.msg_iovlen = 2;
+
+	if (fd) {
+		memset(cmsgbuf, 0, sizeof(cmsgbuf));
+		msg.msg_control = cmsgbuf;
+		msg.msg_controllen = sizeof(cmsgbuf);
+	}
+
+	ret = recvmsg(audio_sk, &msg, 0);
+	if (ret < 0) {
+		error("a2dp: Receiving command response failed:%s",
+							strerror(errno));
+		pthread_mutex_unlock(&sk_mutex);
+		goto failed;
+	}
+
+	pthread_mutex_unlock(&sk_mutex);
+
+	if (ret < (ssize_t) sizeof(cmd)) {
+		error("a2dp: Too small response received(%zd bytes)", ret);
+		goto failed;
+	}
+
+	if (cmd.service_id != service_id) {
+		error("a2dp: Invalid service id (%u vs %u)", cmd.service_id,
+								service_id);
+		goto failed;
+	}
+
+	if (ret != (ssize_t) (sizeof(cmd) + cmd.len)) {
+		error("a2dp: Malformed response received(%zd bytes)", ret);
+		goto failed;
+	}
+
+	if (cmd.opcode != opcode && cmd.opcode != AUDIO_OP_STATUS) {
+		error("a2dp: Invalid opcode received (%u vs %u)",
+						cmd.opcode, opcode);
+		goto failed;
+	}
+
+	if (cmd.opcode == AUDIO_OP_STATUS) {
+		struct hal_status *s = rsp;
+
+		if (sizeof(*s) != cmd.len) {
+			error("a2dp: Invalid status length");
+			goto failed;
+		}
+
+		if (s->code == AUDIO_STATUS_SUCCESS) {
+			error("a2dp: Invalid success status response");
+			goto failed;
+		}
+
+		return s->code;
+	}
+
+	/* Receive auxiliary data in msg */
+	if (fd) {
+		struct cmsghdr *cmsg;
+
+		*fd = -1;
+
+		for (cmsg = CMSG_FIRSTHDR(&msg); cmsg;
+					cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+			if (cmsg->cmsg_level == SOL_SOCKET
+					&& cmsg->cmsg_type == SCM_RIGHTS) {
+				memcpy(fd, CMSG_DATA(cmsg), sizeof(int));
+				break;
+			}
+		}
+	}
+
+	if (rsp_len)
+		*rsp_len = cmd.len;
 
+	return AUDIO_STATUS_SUCCESS;
+
+failed:
+	/* Some serious issue happen on IPC - recover */
+	shutdown(audio_sk, SHUT_RDWR);
 	return AUDIO_STATUS_FAILED;
 }
 
+static int open_endpoint_cmd(void)
+{
+	struct audio_rsp_open rsp;
+	uint8_t buf[sizeof(struct audio_cmd_open) +
+						sizeof(struct audio_preset)];
+	size_t rsp_len = sizeof(rsp);
+	int result;
+
+	DBG("");
+
+	memset(&buf, 0, sizeof(buf));
+
+	/* TODO: Fill in buf here with smth */
+
+	result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN, sizeof(buf), buf,
+							&rsp_len, &rsp, NULL);
+
+	/*TODO: Read response and store endoint id */
+
+	return result;
+}
+
 static bool create_audio_ipc(void)
 {
 	struct sockaddr_un addr;
-- 
1.8.4


^ permalink raw reply related

* [PATCH 3/4] android/audio: Add skeleton for open_endpoint_cmd function
From: Lukasz Rymanowski @ 2014-01-09 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, szymon.janc, johan.hedberg, Lukasz Rymanowski
In-Reply-To: <1389267956-2297-1-git-send-email-lukasz.rymanowski@tieto.com>

---
 android/hal-audio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 4a12bcb..95efa89 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -412,6 +412,13 @@ static int audio_close(hw_device_t *device)
 	return 0;
 }
 
+static int open_endpoint_cmd(void)
+{
+	DBG("Not Implemented");
+
+	return AUDIO_STATUS_FAILED;
+}
+
 static bool create_audio_ipc(void)
 {
 	struct sockaddr_un addr;
@@ -478,7 +485,10 @@ static void *ipc_handler(void *data)
 
 		DBG("Audio IPC: Connected");
 
-		/* TODO: Register ENDPOINT here */
+		if (open_endpoint_cmd() == AUDIO_STATUS_FAILED) {
+			error("a2dp: failed to open endpoint");
+			continue;
+		}
 
 		memset(&pfd, 0, sizeof(pfd));
 		pfd.fd = audio_sk;
-- 
1.8.4


^ permalink raw reply related

* [PATCH 2/4] android/audio: Change mainloop handle in ipc_handler
From: Lukasz Rymanowski @ 2014-01-09 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, szymon.janc, johan.hedberg, Lukasz Rymanowski
In-Reply-To: <1389267956-2297-1-git-send-email-lukasz.rymanowski@tieto.com>

Make sure we wait 1 sec  after each loop iteration.
It is important in case of failure that we do not overload cpu.

---
 android/hal-audio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 7a7c111..4a12bcb 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -465,15 +465,14 @@ failed:
 
 static void *ipc_handler(void *data)
 {
-	bool done = false;
 	struct pollfd pfd;
+	bool done;
 
 	DBG("");
 
-	while (!done) {
+	for (done = false; !done; sleep(1)) {
 		if(!create_audio_ipc()) {
 			error("a2dp: Failed to create listening socket");
-			sleep(1);
 			continue;
 		}
 
-- 
1.8.4


^ permalink raw reply related

* [PATCH 1/4] android/audio: Prefix error log with "a2dp"
From: Lukasz Rymanowski @ 2014-01-09 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, szymon.janc, johan.hedberg, Lukasz Rymanowski
In-Reply-To: <1389267956-2297-1-git-send-email-lukasz.rymanowski@tieto.com>

---
 android/hal-audio.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 59a8269..7a7c111 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -423,7 +423,8 @@ static bool create_audio_ipc(void)
 	sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
 	if (sk < 0) {
 		err = errno;
-		error("Failed to create socket: %d (%s)", err, strerror(err));
+		error("a2dp: Failed to create socket: %d (%s)", err,
+								strerror(err));
 		return false;
 	}
 
@@ -435,13 +436,14 @@ static bool create_audio_ipc(void)
 
 	if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		err = errno;
-		error("Failed to bind socket: %d (%s)", err, strerror(err));
+		error("a2dp: Failed to bind socket: %d (%s)", err,
+								strerror(err));
 		goto failed;
 	}
 
 	if (listen(sk, 1) < 0) {
 		err = errno;
-		error("Failed to listen on the socket: %d (%s)", err,
+		error("a2dp: Failed to listen on the socket: %d (%s)", err,
 								strerror(err));
 		goto failed;
 	}
@@ -449,7 +451,7 @@ static bool create_audio_ipc(void)
 	audio_sk = accept(sk, NULL, NULL);
 	if (audio_sk < 0) {
 		err = errno;
-		error("Failed to accept socket: %d (%s)", err, strerror(err));
+		error("a2dp: Failed to accept socket: %d (%s)", err, strerror(err));
 		goto failed;
 	}
 
@@ -470,7 +472,7 @@ static void *ipc_handler(void *data)
 
 	while (!done) {
 		if(!create_audio_ipc()) {
-			error("Failed to create listening socket");
+			error("a2dp: Failed to create listening socket");
 			sleep(1);
 			continue;
 		}
@@ -511,7 +513,7 @@ static int audio_open(const hw_module_t *module, const char *name,
 	DBG("");
 
 	if (strcmp(name, AUDIO_HARDWARE_INTERFACE)) {
-		error("interface %s not matching [%s]", name,
+		error("ad2p: interface %s not matching [%s]", name,
 						AUDIO_HARDWARE_INTERFACE);
 		return -EINVAL;
 	}
@@ -547,7 +549,7 @@ static int audio_open(const hw_module_t *module, const char *name,
 	err = pthread_create(&ipc_th, NULL, ipc_handler, NULL);
 	if (err < 0) {
 		ipc_th = 0;
-		error("Failed to start Audio IPC thread: %d (%s)",
+		error("a2dp: Failed to start Audio IPC thread: %d (%s)",
 							-err, strerror(-err));
 		return (-err);
 	}
-- 
1.8.4


^ permalink raw reply related

* [PATCH 0/4] Next skeleton patches for audio plugin
From: Lukasz Rymanowski @ 2014-01-09 11:45 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, szymon.janc, johan.hedberg, Lukasz Rymanowski

Those patches adds function to handle send/receive msg on audio IPC.
Also do some small changes.

Not that since we do not yet support AUDIO_OP_OPEN, audio socket will be
reseted just after connect.

Lukasz Rymanowski (4):
  android/audio: Prefix error log with "a2dp"
  android/audio: Change mainloop handle in ipc_handler
  android/audio: Add skeleton for open_endpoint_cmd function
  android/audio: Add audio_ipc_cmd

 android/Makefile.am |   1 +
 android/hal-audio.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 186 insertions(+), 11 deletions(-)

-- 
1.8.4


^ permalink raw reply

* [PATCH 4/4] android/tester: Multi property check for test case
From: Grzegorz Kolodziejczyk @ 2014-01-09 11:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389265295-3344-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This patch allows to check multiple properties for test case. Properties
can be prioritized to allow check if they'll come in right order. Now
properties aren't treated as a "single" callback. In future in one
callback multiple properties can come.
---
 android/android-tester.c | 525 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 381 insertions(+), 144 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a29c982..1c538e2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -43,13 +43,19 @@
 
 #include "utils.h"
 
+struct priority_property {
+	bt_property_t prop;
+	int prio;
+};
+
 struct generic_data {
 	int expected_adapter_status;
 	uint32_t expect_settings_set;
 	int expected_cb_count;
 	bt_property_t set_property;
-	bt_property_t expected_property;
 	bt_callbacks_t expected_hal_cb;
+	struct priority_property *expected_properties;
+	uint8_t expected_properties_num;
 };
 
 struct socket_data {
@@ -91,6 +97,7 @@ struct test_data {
 	bool test_init_done;
 
 	int cb_count;
+	GSList *expected_properties_list;
 };
 
 static char exec_dir[PATH_MAX + 1];
@@ -185,9 +192,18 @@ static void expected_status_init(struct test_data *data)
 static void test_property_init(struct test_data *data)
 {
 	const struct generic_data *test_data = data->test_data;
+	GSList *l = data->expected_properties_list;
+	int i;
 
-	if (!test_data->expected_property.type)
+	if (!test_data->expected_hal_cb.adapter_properties_cb) {
 		data->property_checked = true;
+		return;
+	}
+
+	for (i = 0; i < test_data->expected_properties_num; i++)
+		l = g_slist_prepend(l, &(test_data->expected_properties[i]));
+
+	data->expected_properties_list = l;
 }
 
 static void init_test_conditions(struct test_data *data)
@@ -212,6 +228,73 @@ static void check_expected_status(uint8_t status)
 		tester_test_failed();
 }
 
+static int locate_property(gconstpointer expected_data,
+						gconstpointer received_prop)
+{
+	bt_property_t rec_prop = *((bt_property_t *)received_prop);
+	bt_property_t exp_prop =
+			((struct priority_property *)expected_data)->prop;
+
+	if (exp_prop.type && (exp_prop.type != rec_prop.type))
+		return 1;
+	if (exp_prop.len && (exp_prop.len != rec_prop.len))
+		return 1;
+	if (exp_prop.val && memcmp(exp_prop.val, rec_prop.val, exp_prop.len))
+		return 1;
+
+	return 0;
+}
+
+static int compare_priorities(gconstpointer prop_list, gconstpointer priority)
+{
+	int prio = GPOINTER_TO_INT(priority);
+	int comp_prio = ((struct priority_property *)prop_list)->prio;
+
+	if (prio > comp_prio)
+		return 0;
+
+	return 1;
+}
+
+static bool check_prop_priority(int rec_prop_prio)
+{
+	struct test_data *data = tester_get_data();
+	GSList *l = data->expected_properties_list;
+
+	if (!rec_prop_prio || !g_slist_length(l))
+		return true;
+
+	if (g_slist_find_custom(l, GINT_TO_POINTER(rec_prop_prio),
+							&compare_priorities))
+		return false;
+
+	return true;
+}
+
+static void check_expected_property(bt_property_t received_prop)
+{
+	struct test_data *data = tester_get_data();
+	int rec_prio;
+	GSList *l = data->expected_properties_list;
+	GSList *found_exp_prop;
+
+	found_exp_prop = g_slist_find_custom(l, &received_prop,
+							&locate_property);
+
+	if (found_exp_prop) {
+		rec_prio = ((struct priority_property *)
+						(found_exp_prop->data))->prio;
+		if (check_prop_priority(rec_prio))
+			l = g_slist_remove(l, found_exp_prop->data);
+	}
+
+	if (g_slist_length(l))
+		return;
+
+	data->property_checked = true;
+	test_update_state();
+}
+
 static bool check_test_property(bt_property_t received_prop,
 						bt_property_t expected_prop)
 {
@@ -625,27 +708,18 @@ static void device_found_cb(int num_properties, bt_property_t *properties)
 	if (data->test_init_done && test->expected_hal_cb.device_found_cb) {
 		test->expected_hal_cb.device_found_cb(num_properties,
 								properties);
-		check_cb_count();
 	}
 }
 
 static void check_count_properties_cb(bt_status_t status, int num_properties,
 						bt_property_t *properties)
 {
-	struct test_data *data = tester_get_data();
+	int i;
 
-	data->cb_count--;
+	for (i = 0; i < num_properties; i++)
+		check_expected_property(properties[i]);
 }
 
-static void getprop_success_cb(bt_status_t status, int num_properties,
-						bt_property_t *properties)
-{
-	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-
-	if (check_test_property(properties[0], test->expected_property))
-		data->cb_count--;
-}
 
 static void adapter_properties_cb(bt_status_t status, int num_properties,
 						bt_property_t *properties)
@@ -658,21 +732,87 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
 		test->expected_hal_cb.adapter_properties_cb(
 							status, num_properties,
 							properties);
-		check_cb_count();
 	}
 }
 
+static bt_bdaddr_t enable_done_bdaddr_val = {
+	.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 },
+};
+static const char enable_done_bdname_val[] = "";
+static bt_uuid_t enable_done_uuids_val = {
+	.uu = { 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
+					0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb},
+};
+static uint32_t enable_done_cod_val = 0;
+static bt_device_type_t enable_done_tod_val = BT_DEVICE_DEVTYPE_BREDR;
+static bt_scan_mode_t enable_done_scanmode_val = BT_SCAN_MODE_NONE;
+static uint32_t enable_done_disctimeout_val = 120;
+
+static struct priority_property enable_done_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDADDR,
+	.prop.len = sizeof(enable_done_bdaddr_val),
+	.prop.val = &enable_done_bdaddr_val,
+	.prio = 1,
+	},
+	{
+	.prop.type = BT_PROPERTY_BDNAME,
+	.prop.len = sizeof(enable_done_bdname_val) - 1,
+	.prop.val = &enable_done_bdname_val,
+	.prio = 2,
+	},
+	{
+	.prop.type = BT_PROPERTY_UUIDS,
+	.prop.len = sizeof(enable_done_uuids_val),
+	.prop.val = &enable_done_uuids_val,
+	.prio = 3,
+	},
+	{
+	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
+	.prop.len = sizeof(enable_done_cod_val),
+	.prop.val = &enable_done_cod_val,
+	.prio = 4,
+	},
+	{
+	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
+	.prop.len = sizeof(enable_done_tod_val),
+	.prop.val = &enable_done_tod_val,
+	.prio = 5,
+	},
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.len = sizeof(enable_done_scanmode_val),
+	.prop.val = &enable_done_scanmode_val,
+	.prio = 6,
+	},
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+	.prop.len = 0,
+	.prop.val = NULL,
+	.prio = 7,
+	},
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.prop.len = sizeof(enable_done_disctimeout_val),
+	.prop.val = &enable_done_disctimeout_val,
+	.prio = 8,
+	},
+};
+
 static const struct generic_data bluetooth_enable_success_test = {
 	.expected_hal_cb.adapter_state_changed_cb = enable_success_cb,
 	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_cb_count = 9,
+	.expected_cb_count = 1,
+	.expected_properties_num = 8,
+	.expected_properties = enable_done_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
 };
 
 static const struct generic_data bluetooth_enable_done_test = {
 	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_cb_count = 8,
 	.expected_adapter_status = BT_STATUS_DONE,
+	.expected_properties_num = 8,
+	.expected_properties = enable_done_props,
 };
 
 static const struct generic_data bluetooth_disable_success_test = {
@@ -683,94 +823,148 @@ static const struct generic_data bluetooth_disable_success_test = {
 
 static char test_set_bdname[] = "test_bdname_set";
 
+static struct priority_property setprop_bdname_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDNAME,
+	.prop.val = test_set_bdname,
+	.prop.len = sizeof(test_set_bdname) - 1,
+	.prio = 0,
+	},
+};
+
 static const struct generic_data bluetooth_setprop_bdname_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_BDNAME,
-	.expected_property.val = test_set_bdname,
-	.expected_property.len = sizeof(test_set_bdname) - 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = setprop_bdname_props,
 };
 
 static bt_scan_mode_t test_setprop_scanmode_val =
 					BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
 
+static struct priority_property setprop_scanmode_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.val = &test_setprop_scanmode_val,
+	.prop.len = sizeof(bt_scan_mode_t),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_scanmode_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = setprop_scanmode_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
-	.expected_property.val = &test_setprop_scanmode_val,
-	.expected_property.len = sizeof(bt_scan_mode_t),
 };
 
 static uint32_t test_setprop_disctimeout_val = 120;
 
+static struct priority_property setprop_disctimeout_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.prop.val = &test_setprop_disctimeout_val,
+	.prop.len = sizeof(test_setprop_disctimeout_val),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = setprop_disctimeout_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
-	.expected_property.val = &test_setprop_disctimeout_val,
-	.expected_property.len = sizeof(test_setprop_disctimeout_val),
+};
+
+static bt_bdaddr_t test_getprop_bdaddr_val = {
+	.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 }
+};
+
+static struct priority_property getprop_bdaddr_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDADDR,
+	.prop.val = &test_getprop_bdaddr_val,
+	.prop.len = sizeof(test_getprop_bdaddr_val),
+	},
 };
 
 static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_bdaddr_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_BDADDR,
-	.expected_property.val = NULL,
-	.expected_property.len = sizeof(bt_bdaddr_t),
 };
 
 static char test_bdname[] = "test_bdname_setget";
 
+static struct priority_property getprop_bdname_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDNAME,
+	.prop.val = &test_bdname,
+	.prop.len = sizeof(test_bdname) - 1,
+	},
+};
+
 static const struct generic_data bluetooth_getprop_bdname_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_bdname_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_BDNAME,
-	.expected_property.val = test_bdname,
-	.expected_property.len = sizeof(test_bdname) - 1,
 };
 
 static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
 			0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
 			0x00, 0x00 };
 
+static struct priority_property setprop_uuid_prop[] = {
+	{
+	.prop.type = BT_PROPERTY_UUIDS,
+	.prop.val = &setprop_uuids,
+	.prop.len = sizeof(setprop_uuids),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_UUIDS,
-	.set_property.val = &setprop_uuids,
-	.set_property.len = sizeof(setprop_uuids),
 };
 
 static uint32_t setprop_class_of_device = 0;
 
+static struct priority_property setprop_cod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
+	.prop.val = &setprop_class_of_device,
+	.prop.len = sizeof(setprop_class_of_device),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_cod_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
-	.set_property.val = &setprop_class_of_device,
-	.set_property.len = sizeof(setprop_class_of_device),
 };
 
 static bt_device_type_t setprop_type_of_device = BT_DEVICE_DEVTYPE_BREDR;
 
+static struct priority_property setprop_tod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
+	.prop.val = &setprop_type_of_device,
+	.prop.len = sizeof(setprop_type_of_device),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_tod_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
-	.set_property.val = &setprop_type_of_device,
-	.set_property.len = sizeof(setprop_type_of_device),
 };
 
 static int32_t setprop_remote_rssi = 0;
 
+static struct priority_property setprop_remote_rssi_props[] = {
+	{
+	.prop.type = BT_PROPERTY_REMOTE_RSSI,
+	.prop.val = &setprop_remote_rssi,
+	.prop.len = sizeof(setprop_remote_rssi),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_REMOTE_RSSI,
-	.set_property.val = &setprop_remote_rssi,
-	.set_property.len = sizeof(setprop_remote_rssi),
 };
 
 static bt_service_record_t setprop_remote_service = {
@@ -779,91 +973,136 @@ static bt_service_record_t setprop_remote_service = {
 	.name = "bt_name",
 };
 
+static struct priority_property setprop_service_record_props[] = {
+	{
+	.prop.type = BT_PROPERTY_SERVICE_RECORD,
+	.prop.val = &setprop_remote_service,
+	.prop.len = sizeof(setprop_remote_service),
+	},
+};
+
 static const struct generic_data
 			bluetooth_setprop_service_record_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_SERVICE_RECORD,
-	.set_property.val = &setprop_remote_service,
-	.set_property.len = sizeof(setprop_remote_service),
 };
 
 static bt_bdaddr_t setprop_bdaddr = {
 	.address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
 };
 
+static struct priority_property setprop_bdaddr_props[] = {
+	{
+	.prop.type = BT_PROPERTY_BDADDR,
+	.prop.val = &setprop_bdaddr,
+	.prop.len = sizeof(setprop_bdaddr),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_BDADDR,
-	.set_property.val = &setprop_bdaddr,
-	.set_property.len = sizeof(setprop_bdaddr),
 };
 
 static bt_scan_mode_t setprop_scanmode_connectable = BT_SCAN_MODE_CONNECTABLE;
 
+static struct priority_property setprop_scanmode_connectable_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.val = &setprop_scanmode_connectable,
+	.prop.len = sizeof(setprop_scanmode_connectable),
+	},
+};
+
 static const struct generic_data
 			bluetooth_setprop_scanmode_connectable_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = setprop_scanmode_connectable_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
-	.expected_property.val = &setprop_scanmode_connectable,
-	.expected_property.len = sizeof(setprop_scanmode_connectable),
 };
 
 static bt_bdaddr_t setprop_bonded_devices = {
 	.address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
 };
 
+static struct priority_property setprop_bonded_devices_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+	.prop.val = &setprop_bonded_devices,
+	.prop.len = sizeof(setprop_bonded_devices),
+	},
+};
+
 static const struct generic_data
 			bluetooth_setprop_bonded_devices_invalid_test = {
 	.expected_adapter_status = BT_STATUS_FAIL,
-	.set_property.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
-	.set_property.val = &setprop_bonded_devices,
-	.set_property.len = sizeof(setprop_bonded_devices),
 };
 
 static uint32_t getprop_cod = 0;
 
+static struct priority_property getprop_cod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
+	.prop.val = &getprop_cod,
+	.prop.len = sizeof(getprop_cod),
+	},
+};
+
 static const struct generic_data bluetooth_getprop_cod_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_cod_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
-	.expected_property.val = &getprop_cod,
-	.expected_property.len = sizeof(getprop_cod),
 };
 
 static bt_device_type_t getprop_tod = BT_DEVICE_DEVTYPE_BREDR;
 
+static struct priority_property getprop_tod_props[] = {
+	{
+	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
+	.prop.val = &getprop_tod,
+	.prop.len = sizeof(getprop_tod),
+	},
+};
+
 static const struct generic_data bluetooth_getprop_tod_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_tod_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
-	.expected_property.val = &getprop_tod,
-	.expected_property.len = sizeof(getprop_tod),
 };
 
 static bt_scan_mode_t getprop_scanmode = BT_SCAN_MODE_NONE;
 
+static struct priority_property getprop_scanmode_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.val = &getprop_scanmode,
+	.prop.len = sizeof(getprop_scanmode),
+	},
+};
+
 static const struct generic_data bluetooth_getprop_scanmode_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_scanmode_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
-	.expected_property.val = &getprop_scanmode,
-	.expected_property.len = sizeof(getprop_scanmode),
 };
 
 static uint32_t getprop_disctimeout_val = 120;
 
+static struct priority_property getprop_disctimeout_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.prop.val = &getprop_disctimeout_val,
+	.prop.len = sizeof(getprop_disctimeout_val),
+	},
+};
+
 static const struct generic_data bluetooth_getprop_disctimeout_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_disctimeout_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
-	.expected_property.val = &getprop_disctimeout_val,
-	.expected_property.len = sizeof(getprop_disctimeout_val),
 };
 
 static bt_uuid_t getprop_uuids = {
@@ -871,33 +1110,51 @@ static bt_uuid_t getprop_uuids = {
 					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB },
 };
 
+static struct priority_property getprop_uuids_props[] = {
+	{
+	.prop.type = BT_PROPERTY_UUIDS,
+	.prop.val = &getprop_uuids,
+	.prop.len = sizeof(getprop_uuids),
+	},
+};
+
 static const struct generic_data bluetooth_getprop_uuids_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_uuids_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_UUIDS,
-	.expected_property.val = &getprop_uuids,
-	.expected_property.len = sizeof(getprop_uuids),
+};
+
+static struct priority_property getprop_bondeddev_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+	.prop.val = NULL,
+	.prop.len = 0,
+	},
 };
 
 static const struct generic_data bluetooth_getprop_bondeddev_success_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = getprop_bondeddev_props,
 	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_property.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
-	.expected_property.val = NULL,
-	.expected_property.len = 0,
 };
 
 static bt_scan_mode_t setprop_scanmode_none = BT_SCAN_MODE_NONE;
 
+static struct priority_property setprop_scanmode_none_props[] = {
+	{
+	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.prop.val = &setprop_scanmode_none,
+	.prop.len = sizeof(setprop_scanmode_none),
+	},
+};
+
 static const struct generic_data bluetooth_setprop_scanmode_none_done_test = {
-	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
-	.expected_cb_count = 1,
+	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
+	.expected_properties_num = 1,
+	.expected_properties = setprop_scanmode_none_props,
 	.expected_adapter_status = BT_STATUS_DONE,
-	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
-	.expected_property.val = &setprop_scanmode_none,
-	.expected_property.len = sizeof(setprop_scanmode_none),
 };
 
 static const struct generic_data bluetooth_discovery_start_success_test = {
@@ -1122,22 +1379,19 @@ static void test_disable(const void *test_data)
 static void test_setprop_bdname_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_bdname_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
 
 	adapter_status = data->if_bluetooth->set_adapter_property(prop);
-
 	check_expected_status(adapter_status);
 }
 
 static void test_setprop_scanmode_succes(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_scanmode_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1149,8 +1403,7 @@ static void test_setprop_scanmode_succes(const void *test_data)
 static void test_setprop_disctimeout_succes(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_disctimeout_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1162,8 +1415,7 @@ static void test_setprop_disctimeout_succes(const void *test_data)
 static void test_getprop_bdaddr_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = setprop_bdaddr_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1175,8 +1427,7 @@ static void test_getprop_bdaddr_success(const void *test_data)
 static void test_getprop_bdname_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(getprop_bdname_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1187,12 +1438,10 @@ static void test_getprop_bdname_success(const void *test_data)
 	adapter_status = data->if_bluetooth->get_adapter_property((*prop).type);
 	check_expected_status(adapter_status);
 }
-
 static void test_setprop_uuid_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_uuid_prop[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1204,8 +1453,7 @@ static void test_setprop_uuid_invalid(const void *test_data)
 static void test_setprop_cod_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_cod_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1230,8 +1478,7 @@ static void test_setprop_tod_invalid(const void *test_data)
 static void test_setprop_rssi_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_remote_rssi_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1243,8 +1490,7 @@ static void test_setprop_rssi_invalid(const void *test_data)
 static void test_setprop_service_record_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_service_record_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1256,8 +1502,7 @@ static void test_setprop_service_record_invalid(const void *test_data)
 static void test_setprop_bdaddr_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_bdaddr_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1269,8 +1514,8 @@ static void test_setprop_bdaddr_invalid(const void *test_data)
 static void test_setprop_scanmode_connectable_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop =
+				&(setprop_scanmode_connectable_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1282,8 +1527,7 @@ static void test_setprop_scanmode_connectable_success(const void *test_data)
 static void test_setprop_bonded_devices_invalid(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_bonded_devices_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1295,8 +1539,7 @@ static void test_setprop_bonded_devices_invalid(const void *test_data)
 static void test_getprop_cod_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = setprop_cod_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1308,8 +1551,7 @@ static void test_getprop_cod_success(const void *test_data)
 static void test_getprop_tod_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = setprop_tod_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1321,8 +1563,7 @@ static void test_getprop_tod_success(const void *test_data)
 static void test_getprop_scanmode_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = setprop_scanmode_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1334,8 +1575,7 @@ static void test_getprop_scanmode_success(const void *test_data)
 static void test_getprop_disctimeout_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = setprop_disctimeout_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1347,8 +1587,7 @@ static void test_getprop_disctimeout_success(const void *test_data)
 static void test_getprop_uuids_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = getprop_uuids_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1360,8 +1599,7 @@ static void test_getprop_uuids_success(const void *test_data)
 static void test_getprop_bondeddev_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t prop = test->expected_property;
+	const bt_property_t prop = getprop_bondeddev_props[0].prop;
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
@@ -1373,8 +1611,7 @@ static void test_getprop_bondeddev_success(const void *test_data)
 static void test_setprop_scanmode_none_done(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
-	const struct generic_data *test = data->test_data;
-	const bt_property_t *prop = &test->expected_property;
+	const bt_property_t *prop = &(setprop_scanmode_none_props[0].prop);
 	bt_status_t adapter_status;
 
 	init_test_conditions(data);
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 3/4] android/tester: Add test case state handling
From: Grzegorz Kolodziejczyk @ 2014-01-09 11:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389265295-3344-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This patch make test state handling more stable by avoiding errors like
i.e. double free of memory in teardown phase. Double state set is
undesirable for test case and may cause errors. Now after every
condition change, test state is checked if it can set test state to pass.
In some places of test fail, returns are added to avoid furhter code
execution.
---
 android/android-tester.c | 43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a63d836..a29c982 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -147,10 +147,10 @@ static void check_cb_count(void)
 	if (!data->test_init_done)
 		return;
 
-	if (data->cb_count == 0)
+	if (data->cb_count == 0) {
 		data->cb_count_checked = true;
-
-	test_update_state();
+		test_update_state();
+	}
 }
 
 static void expected_cb_count_init(struct test_data *data)
@@ -205,12 +205,11 @@ static void check_expected_status(uint8_t status)
 	struct test_data *data = tester_get_data();
 	const struct generic_data *test_data = data->test_data;
 
-	if (test_data->expected_adapter_status == status)
+	if (test_data->expected_adapter_status == status) {
 		data->status_checked = true;
-	else
+		test_update_state();
+	} else
 		tester_test_failed();
-
-	test_update_state();
 }
 
 static bool check_test_property(bt_property_t received_prop,
@@ -467,6 +466,7 @@ static void enable_success_cb(bt_state_t state)
 	if (state == BT_STATE_ON) {
 		setup_powered_emulated_remote();
 		data->cb_count--;
+		check_cb_count();
 	}
 }
 
@@ -474,8 +474,10 @@ static void disable_success_cb(bt_state_t state)
 {
 	struct test_data *data = tester_get_data();
 
-	if (state == BT_STATE_OFF)
+	if (state == BT_STATE_OFF) {
 		data->cb_count--;
+		check_cb_count();
+	}
 }
 
 static void adapter_state_changed_cb(bt_state_t state)
@@ -486,7 +488,6 @@ static void adapter_state_changed_cb(bt_state_t state)
 	if (data->test_init_done &&
 			test->expected_hal_cb.adapter_state_changed_cb) {
 		test->expected_hal_cb.adapter_state_changed_cb(state);
-		check_cb_count();
 		return;
 	}
 
@@ -498,8 +499,10 @@ static void discovery_start_success_cb(bt_discovery_state_t state)
 {
 	struct test_data *data = tester_get_data();
 
-	if (state == BT_DISCOVERY_STARTED)
+	if (state == BT_DISCOVERY_STARTED) {
 		data->cb_count--;
+		check_cb_count();
+	}
 }
 
 static void discovery_start_done_cb(bt_discovery_state_t state)
@@ -509,6 +512,8 @@ static void discovery_start_done_cb(bt_discovery_state_t state)
 
 	status = data->if_bluetooth->start_discovery();
 	data->cb_count--;
+
+	check_cb_count();
 	check_expected_status(status);
 }
 
@@ -523,8 +528,10 @@ static void discovery_stop_success_cb(bt_discovery_state_t state)
 		data->cb_count--;
 		return;
 	}
-	if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1)
+	if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
 		data->cb_count--;
+		check_cb_count();
+	}
 }
 
 static void discovery_device_found_state_changed_cb(bt_discovery_state_t state)
@@ -535,8 +542,10 @@ static void discovery_device_found_state_changed_cb(bt_discovery_state_t state)
 		data->cb_count--;
 		return;
 	}
-	if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1)
+	if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
 		data->cb_count--;
+		check_cb_count();
+	}
 }
 
 static void discovery_state_changed_cb(bt_discovery_state_t state)
@@ -546,7 +555,6 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
 
 	if (test && test->expected_hal_cb.discovery_state_changed_cb) {
 		test->expected_hal_cb.discovery_state_changed_cb(state);
-		check_cb_count();
 	}
 }
 
@@ -564,9 +572,12 @@ static void discovery_device_found_cb(int num_properties,
 	bt_property_t received_prop;
 
 	data->cb_count--;
+	check_cb_count();
 
-	if (num_properties < 1)
+	if (num_properties < 1) {
 		tester_test_failed();
+		return;
+	}
 
 	bdaddr2android((const bdaddr_t *) remote_bdaddr, &emu_remote_bdaddr);
 
@@ -599,8 +610,10 @@ static void discovery_device_found_cb(int num_properties,
 			break;
 		}
 
-		if (!check_test_property(received_prop, expected_prop))
+		if (!check_test_property(received_prop, expected_prop)) {
 			tester_test_failed();
+			return;
+		}
 	}
 }
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 2/4] android/tester: Use common property check function for all test props
From: Grzegorz Kolodziejczyk @ 2014-01-09 11:01 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389265295-3344-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

This patch makes discovery device found test case to use generic
property check method.
---
 android/android-tester.c | 73 ++++++++++++++++--------------------------------
 1 file changed, 24 insertions(+), 49 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 4f733e1..a63d836 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -110,35 +110,6 @@ static void test_update_state(void)
 	tester_test_passed();
 }
 
-static void test_device_property(bt_property_t *property,
-			bt_property_type_t type, const void *value, int len)
-{
-	if (value == NULL) {
-		tester_warn("NULL property passed");
-		tester_test_failed();
-		return;
-	}
-
-	if (property->type != type) {
-		tester_warn("Wrong remote property type %d, expected %d",
-							type, property->type);
-		tester_test_failed();
-		return;
-	}
-
-	if (property->len != len) {
-		tester_warn("Wrong remote property len %d, expected %d",
-							len, property->len);
-		tester_test_failed();
-		return;
-	}
-
-	if (memcmp(property->val, value, len)) {
-		tester_warn("Wrong remote property value");
-		tester_test_failed();
-	}
-}
-
 static void test_mgmt_settings_set(struct test_data *data)
 {
 	data->mgmt_settings_set = true;
@@ -583,12 +554,14 @@ static void discovery_device_found_cb(int num_properties,
 						bt_property_t *properties)
 {
 	struct test_data *data = tester_get_data();
-	const uint8_t *remote_bdaddr =
-					hciemu_get_client_bdaddr(data->hciemu);
-	const uint32_t emu_remote_type = BT_DEVICE_DEVTYPE_BREDR;
-	const int32_t emu_remote_rssi = -60;
+	uint8_t *remote_bdaddr =
+			(uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+	uint32_t emu_remote_type = BT_DEVICE_DEVTYPE_BREDR;
+	int32_t emu_remote_rssi = -60;
 	bt_bdaddr_t emu_remote_bdaddr;
 	int i;
+	bt_property_t expected_prop;
+	bt_property_t received_prop;
 
 	data->cb_count--;
 
@@ -598,34 +571,36 @@ static void discovery_device_found_cb(int num_properties,
 	bdaddr2android((const bdaddr_t *) remote_bdaddr, &emu_remote_bdaddr);
 
 	for (i = 0; i < num_properties; i++) {
-		int prop_len;
-		const void *prop_data;
+		received_prop = properties[i];
 
 		switch (properties[i].type) {
 		case BT_PROPERTY_BDADDR:
-			prop_len = sizeof(emu_remote_bdaddr);
-			prop_data = &emu_remote_bdaddr;
-
+			expected_prop.type = BT_PROPERTY_BDADDR;
+			expected_prop.len = sizeof(emu_remote_bdaddr);
+			expected_prop.val = &emu_remote_bdaddr;
 			break;
-		case BT_PROPERTY_TYPE_OF_DEVICE:
-			prop_len = sizeof(emu_remote_type);
-			prop_data = &emu_remote_type;
 
+		case BT_PROPERTY_TYPE_OF_DEVICE:
+			expected_prop.type = BT_PROPERTY_TYPE_OF_DEVICE;
+			expected_prop.len = sizeof(emu_remote_type);
+			expected_prop.val = &emu_remote_type;
 			break;
-		case BT_PROPERTY_REMOTE_RSSI:
-			prop_len = sizeof(emu_remote_rssi);
-			prop_data = &emu_remote_rssi;
 
+		case BT_PROPERTY_REMOTE_RSSI:
+			expected_prop.type = BT_PROPERTY_REMOTE_RSSI;
+			expected_prop.len = sizeof(emu_remote_rssi);
+			expected_prop.val = &emu_remote_rssi;
 			break;
-		default:
-			prop_len = 0;
-			prop_data = NULL;
 
+		default:
+			expected_prop.type = 0;
+			expected_prop.len = 0;
+			expected_prop.val = NULL;
 			break;
 		}
 
-		test_device_property(&properties[i], properties[i].type,
-							prop_data, prop_len);
+		if (!check_test_property(received_prop, expected_prop))
+			tester_test_failed();
 	}
 }
 
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 1/4] android/tester: Remove redundant whitespace
From: Grzegorz Kolodziejczyk @ 2014-01-09 11:01 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/android-tester.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a448ab5..4f733e1 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -189,7 +189,6 @@ static void expected_cb_count_init(struct test_data *data)
 	data->cb_count = test_data->expected_cb_count;
 
 	check_cb_count();
-
 }
 
 static void mgmt_cb_init(struct test_data *data)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH] android/haltest: Silence static analyzers
From: Andrei Emeltchenko @ 2014-01-09 10:45 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389259565-995-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

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

This makes code more readable and silence static analyzers which think
that pipe and fd are close two times.
---
 android/android-tester.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a448ab5..c14cc19 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -445,7 +445,7 @@ static void emulator(int pipe, int hci_index)
 
 	close(pipe);
 	close(fd);
-	bluetoothd_start(hci_index);
+	return bluetoothd_start(hci_index);
 
 failed:
 	close(pipe);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] shared: Fix clearing of IO handlers
From: Szymon Janc @ 2014-01-09 10:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

If NULL callback is passed to io_set_read/write_handler don't add watch
for it and just clear struct io memebers. This was resulting in
write/read_callback being call in loop due to fd being never written
or read.
---
 src/shared/io-glib.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
index 010dc71..443132e 100644
--- a/src/shared/io-glib.c
+++ b/src/shared/io-glib.c
@@ -142,8 +142,13 @@ bool io_set_read_handler(struct io *io, io_callback_func_t callback,
 	if (!io)
 		return false;
 
-	if (io->read_watch > 0)
+	if (io->read_watch > 0) {
 		g_source_remove(io->read_watch);
+		io->read_watch = 0;
+	}
+
+	if (!callback)
+		goto done;
 
 	io->read_watch = g_io_add_watch_full(io->channel, G_PRIORITY_DEFAULT,
 				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
@@ -151,6 +156,7 @@ bool io_set_read_handler(struct io *io, io_callback_func_t callback,
 	if (io->read_watch == 0)
 		return false;
 
+done:
 	io->read_callback = callback;
 	io->read_destroy = destroy;
 	io->read_data = user_data;
@@ -191,8 +197,13 @@ bool io_set_write_handler(struct io *io, io_callback_func_t callback,
 	if (!io)
 		return false;
 
-	if (io->write_watch > 0)
+	if (io->write_watch > 0) {
 		g_source_remove(io->write_watch);
+		io->write_watch = 0;
+	}
+
+	if (!callback)
+		goto done;
 
 	io->write_watch = g_io_add_watch_full(io->channel, G_PRIORITY_DEFAULT,
 				G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
@@ -200,6 +211,7 @@ bool io_set_write_handler(struct io *io, io_callback_func_t callback,
 	if (io->write_watch == 0)
 		return false;
 
+done:
 	io->write_callback = callback;
 	io->write_destroy = destroy;
 	io->write_data = user_data;
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH 1/2] android/bluetooth: Set default adapter name on first start
From: Szymon Janc @ 2014-01-09  9:32 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389256760-10832-1-git-send-email-szymon.janc@tieto.com>

On Thursday 09 of January 2014 09:39:19 Szymon Janc wrote:
> On first start always set name to default name. Adapter name is
> updated on start only if current name is different.
> ---
>  android/bluetooth.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 9da988b..6aad9b5 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -50,6 +50,8 @@
>  #include "utils.h"
>  #include "bluetooth.h"
>  
> +#define DEFAULT_ADAPTER_NAME "BlueZ for Android"
> +
>  #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
>  
>  #define DEVICE_ID_SOURCE	0x0002	/* USB */
> @@ -1734,15 +1736,17 @@ static void read_info_complete(uint8_t status, uint16_t length,
>  
>  	if (!bacmp(&adapter.bdaddr, BDADDR_ANY)) {
>  		bacpy(&adapter.bdaddr, &rp->bdaddr);
> -		adapter.name = g_strdup((const char *) rp->name);
> +		adapter.name = g_strdup(DEFAULT_ADAPTER_NAME);
>  		store_adapter_config();
> -		set_adapter_name(rp->name, strlen((char *)rp->name));
>  	} else if (bacmp(&adapter.bdaddr, &rp->bdaddr)) {
>  		error("Bluetooth address mismatch");
>  		err = -ENODEV;
>  		goto failed;
>  	}
>  
> +	if (g_strcmp0(adapter.name, (const char *) rp->name))
> +		set_adapter_name((uint8_t *)adapter.name, strlen(adapter.name));
> +
>  	/* Store adapter information */
>  	adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
>  						(rp->dev_class[2] << 16);
> 

Both patches are now pushed upstream.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCH] android/haltest: Fix double file close
From: Andrei Emeltchenko @ 2014-01-09  9:26 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 android/android-tester.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index a448ab5..f5f8c62 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -443,8 +443,6 @@ static void emulator(int pipe, int hci_index)
 	if (len <= 0 || (strcmp(buf, "ctl.start=bluetoothd")))
 		goto failed;
 
-	close(pipe);
-	close(fd);
 	bluetoothd_start(hci_index);
 
 failed:
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH] btproxy: Fix double close
From: Andrei Emeltchenko @ 2014-01-09  9:01 UTC (permalink / raw)
  To: linux-bluetooth

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

setup_streams() already makes close()
---
 tools/btproxy.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/btproxy.c b/tools/btproxy.c
index 1573587..f872326 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -411,11 +411,8 @@ static void server_callback(int fd, uint32_t events, void *user_data)
 
 	printf("New client connected\n");
 
-	if (!setup_streams(src_fd, src_type_rx, src_type_tx,  dst_fd)) {
-		close(dst_fd);
-		close(src_fd);
+	if (!setup_streams(src_fd, src_type_rx, src_type_tx,  dst_fd))
 		return;
-	}
 
 	client_active = true;
 }
-- 
1.8.3.2


^ permalink raw reply related

* Re: [RFCv4 0/5] SSP MITM protection
From: Timo Müller @ 2014-01-09  8:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Timo Mueller
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>

Timo Mueller wrote, On 19.12.2013 14:08:
> From: Timo Mueller <timo.mueller@bmw-carit.de>
> 
> Hi,
> 
> this is a rebased version of the rfc v3. I've successfully tested
> these changes in the last couple of months at the UPF #46 in Vienna,
> with the CE4A golden device and the bluetooth PTS (where applicable).
> 
> At the UPF I've tested remotely initiated pairing with different io
> capabilities, as well locally initiated pairing. Regardless of the
> bonding mode, the protocol chosen in ssp has been consistent when
> being responder and also when being initiator. Pairing tests have been
> successful in all 22 test sessions.
> 
> The configuration I used for testing was as follows:
> bluez: 5.9-154-gf7773c7
> kernel: v3.12-rc3-65-gf927318
> with the remaining patches from [RFC BlueZ v3 0/8] SSP MITM protection
> 
> I used the same configuration to test the patches with the CE4A golden
> device. Pairing here has been working as expected with all
> combinations of io capabilities, bonding mode and intiator role.
> 
> Lastly I've successfully ran the applicable GAP tests with the
> bluetooth PTS on this rebased version and the current head of
> bluez. Unfortunately the interesting bonding test cases are not yet
> implemented with the test suite. So I could only make sure general
> functionality is preserved.
> 
> from the original cover letter:
> The way the kernel handles MITM Protection during pairing is
> inconsistent: General Bonding and Dedicated Bonding are not treated
> equally.
> <snip>
> Therefore, the safest choice is to always request MITM Protection,
> also for General Bonding [1]. The proposal here is to do this for both
> incoming (patch 6/8) and outgoing (patch 7/8) procedures, as it was
> previously done for Dedicated Bonding. This "conservative" approach is
> smart enough to fall back to not using MITM Protection if the IO
> capabilities don't allow it (this policy already existed before for
> Dedicated Bonding, see patch 5/8).
> <snip>
> 
> Best regards
> Timo
> 
> Mikel Astiz (3):
>   Bluetooth: Refactor hci_get_auth_req()
>   Bluetooth: Refactor code for outgoing dedicated bonding
>   Bluetooth: Request MITM Protection when initiator
> 
> Timo Mueller (2):
>   Bluetooth: Use MITM Protection when IO caps allow it
>   Bluetooth: Add management command to relax MITM Protection
> 
>  include/net/bluetooth/hci.h  |  3 ++-
>  include/net/bluetooth/mgmt.h |  3 +++
>  net/bluetooth/hci_event.c    | 57 ++++++++++++++++++++++++++++----------------
>  net/bluetooth/mgmt.c         | 50 ++++++++++++++++++++++++++++++++++----
>  4 files changed, 87 insertions(+), 26 deletions(-)
> 

Ping

^ permalink raw reply

* [PATCH 2/2] android/bluetooth: Set major and minor class od device
From: Szymon Janc @ 2014-01-09  8:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1389256760-10832-1-git-send-email-szymon.janc@tieto.com>

Currently this is hardcoded to Phone/Smartphone.
---
 android/bluetooth.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 6aad9b5..a43eecb 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -58,6 +58,9 @@
 #define DEVICE_ID_VENDOR	0x1d6b	/* Linux Foundation */
 #define DEVICE_ID_PRODUCT	0x0247	/* BlueZ for Android */
 
+#define ADAPTER_MAJOR_CLASS 0x02 /* Phone */
+#define ADAPTER_MINOR_CLASS 0x03 /* Smartphone */
+
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
 
@@ -1703,6 +1706,26 @@ static void load_devices_info(bt_bluetooth_ready cb)
 	g_key_file_free(key_file);
 }
 
+static void set_adapter_class(void)
+{
+	struct mgmt_cp_set_dev_class cp;
+
+	memset(&cp, 0, sizeof(cp));
+
+	/*
+	 * kernel assign the major and minor numbers straight to dev_class[0]
+	 * and dev_class[1] without considering the proper bit shifting.
+	 */
+	cp.major = ADAPTER_MAJOR_CLASS & 0x1f;
+	cp.minor = ADAPTER_MINOR_CLASS << 2;
+
+	if (mgmt_send(mgmt_if, MGMT_OP_SET_DEV_CLASS, adapter.index,
+					sizeof(cp), &cp, NULL, NULL, NULL) > 0)
+		return;
+
+	error("Failed to set class of device");
+}
+
 static void read_info_complete(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -1747,6 +1770,8 @@ static void read_info_complete(uint8_t status, uint16_t length,
 	if (g_strcmp0(adapter.name, (const char *) rp->name))
 		set_adapter_name((uint8_t *)adapter.name, strlen(adapter.name));
 
+	set_adapter_class();
+
 	/* Store adapter information */
 	adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
 						(rp->dev_class[2] << 16);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/2] android/bluetooth: Set default adapter name on first start
From: Szymon Janc @ 2014-01-09  8:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

On first start always set name to default name. Adapter name is
updated on start only if current name is different.
---
 android/bluetooth.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 9da988b..6aad9b5 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -50,6 +50,8 @@
 #include "utils.h"
 #include "bluetooth.h"
 
+#define DEFAULT_ADAPTER_NAME "BlueZ for Android"
+
 #define DUT_MODE_FILE "/sys/kernel/debug/bluetooth/hci%u/dut_mode"
 
 #define DEVICE_ID_SOURCE	0x0002	/* USB */
@@ -1734,15 +1736,17 @@ static void read_info_complete(uint8_t status, uint16_t length,
 
 	if (!bacmp(&adapter.bdaddr, BDADDR_ANY)) {
 		bacpy(&adapter.bdaddr, &rp->bdaddr);
-		adapter.name = g_strdup((const char *) rp->name);
+		adapter.name = g_strdup(DEFAULT_ADAPTER_NAME);
 		store_adapter_config();
-		set_adapter_name(rp->name, strlen((char *)rp->name));
 	} else if (bacmp(&adapter.bdaddr, &rp->bdaddr)) {
 		error("Bluetooth address mismatch");
 		err = -ENODEV;
 		goto failed;
 	}
 
+	if (g_strcmp0(adapter.name, (const char *) rp->name))
+		set_adapter_name((uint8_t *)adapter.name, strlen(adapter.name));
+
 	/* Store adapter information */
 	adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
 						(rp->dev_class[2] << 16);
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH] android: Fix bluetoothd installation path
From: Andrei Emeltchenko @ 2014-01-09  8:36 UTC (permalink / raw)
  To: Szymon Janc; +Cc: Andrzej Kaczmarek, linux-bluetooth
In-Reply-To: <1482934.Q0UzPI5uvD@athlon>

Hi All,

On Wed, Jan 08, 2014 at 05:57:22PM +0100, Szymon Janc wrote:
> Hi Andrzej,
> 
> On Wednesday 08 January 2014 17:42:01 Andrzej Kaczmarek wrote:
> > This patch removes explicit LOCAL_MODULE_PATH definition for bluetoothd
> > and bluetoothd-snoop modules which caused both binaries to be installed
> > in /system/xbin instead of /system/bin folder.
> > ---
> >  android/Android.mk | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/android/Android.mk b/android/Android.mk
> > index 16339b1..8eb918e 100644
> > --- a/android/Android.mk
> > +++ b/android/Android.mk
> > @@ -75,7 +75,6 @@ $(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
> > 
> >  $(foreach file,$(lib_headers), $(shell ln -sf ../$(file)
> > $(LOCAL_PATH)/../lib/bluetooth/$(file)))
> > 
> > -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)

I would better change this to:

LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)

Best regards 
Andrei Emeltchenko 

> >  LOCAL_MODULE_TAGS := optional
> >  LOCAL_MODULE := bluetoothd
> > 
> > @@ -264,7 +263,6 @@ LOCAL_C_INCLUDES := \
> > 
> >  LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> > 
> > -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> >  LOCAL_MODULE_TAGS := optional
> >  LOCAL_MODULE := bluetoothd-snoop
> 
> Applied, thanks.
> 
> -- 
> Szymon K. Janc
> szymon.janc@gmail.com
> --
> 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: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2014-01-08 21:36 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Marcel Holtmann,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <20131230145250.GA16904@earth.universe>

On Monday 30 December 2013 15:52:51 Sebastian Reichel wrote:
> > > > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> > > > extensions"); +MODULE_LICENSE("GPL");
> > > > +MODULE_AUTHOR("Ville Tervo");
> > > > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> > > > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> > > > +MODULE_FIRMWARE(FW_NAME_TI1271);
> > > > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> > > > +MODULE_FIRMWARE(FW_NAME_CSR);
> > >=20
> > > Do we actually have all these firmware files still
> > > available. If not, then focus on the ones we have.
> >=20
> > Firmware files are available for download from nemo project:
> >=20
> > https://api.merproject.org/public/source/nemo:devel:hw:ti:om
> > ap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
> > https://api.merproject.org/public/source/nemo:devel:hw:ti:o
> > map3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0
> > m6.tar.gz
>=20
> Would be nice to have them added to the linux-firmware.git.
>=20
> -- Sebastian

Can somebody send firmware files for inclusion to linux-firmware?

=2D-=20
Pali Roh=C3=A1r
pali.rohar@gmail.com

^ permalink raw reply

* Re: [PATCH] Bluetooth: Fix outgoing authentication requirement check
From: Marcel Holtmann @ 2014-01-08 19:00 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1389192039-29493-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> The check for HIGH security level dates back to pre-mgmt times when a
> raw L2CAP socket with HIGH security level was used to trigger dedicated
> bonding. For legacy pairing checking for the security level was the only
> way to catch the need to authenticate in all scenarios. With mgmt
> however, the pair_device command does not use HIGH security but MEDIUM
> security. Therefore, the existing code would never trigger
> authentication for a non-SSP connection without an MITM requirement
> (e.g. if user space provided a NoInputNoOutput IO capability). In such a
> scenario the mgmt_pair_device command would return success without
> actually triggering any kind of pairing.
> 
> This patch updates the authentication requirement check to also consider
> MEDIUM security level, and thereby ensures that mgmt_pair_device will
> always trigger authentication.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> This one should probably get a Cc: stable flag. It's also a
> pre-requisite for the first mgmt-tester pairing test case that was
> recently added to user space git.
> 
> net/bluetooth/hci_event.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

I want to give this some time to get tested via bluetooth-next before we mark this as to be backported to stable.

Regards

Marcel


^ permalink raw reply

* Re: pull request: bluetooth-next 2014-01-07
From: John W. Linville @ 2014-01-08 18:45 UTC (permalink / raw)
  To: Gustavo Padovan, linux-wireless, linux-bluetooth, linux-kernel
In-Reply-To: <20140107152251.GA24183@joana>

On Tue, Jan 07, 2014 at 01:22:51PM -0200, Gustavo Padovan wrote:
> Hi John,
> 
> More patches to 3.14. The bulk of changes here is the 6LoWPAN support for
> Bluetooth LE Devices. The commits that touches net/ieee802154/ are already
> acked by David Miller. Other than that we have some RFCOMM fixes and
> improvements plus fixes and clean ups all over the tree.
> 
> Please pull, or let me know of any concerns you have.
> 
> 	Gustavo
> 
> ---
> The following changes since commit 71fb419724fadab4efdf98210aa3fe053bd81d29:
> 
>   Bluetooth: Fix handling of L2CAP Command Reject over LE (2013-12-10 01:15:44 -0800)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git for-upstream
> 
> for you to fetch changes up to e825eb1d7e06f616003c17e2e8e421c2e5e44142:
> 
>   Bluetooth: Fix 6loWPAN peer lookup (2014-01-07 11:32:15 -0200)

Pulling now...

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH] android: Fix bluetoothd installation path
From: Szymon Janc @ 2014-01-08 16:57 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1389199321-26623-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Wednesday 08 January 2014 17:42:01 Andrzej Kaczmarek wrote:
> This patch removes explicit LOCAL_MODULE_PATH definition for bluetoothd
> and bluetoothd-snoop modules which caused both binaries to be installed
> in /system/xbin instead of /system/bin folder.
> ---
>  android/Android.mk | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 16339b1..8eb918e 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -75,7 +75,6 @@ $(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
> 
>  $(foreach file,$(lib_headers), $(shell ln -sf ../$(file)
> $(LOCAL_PATH)/../lib/bluetooth/$(file)))
> 
> -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
>  LOCAL_MODULE_TAGS := optional
>  LOCAL_MODULE := bluetoothd
> 
> @@ -264,7 +263,6 @@ LOCAL_C_INCLUDES := \
> 
>  LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> 
> -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
>  LOCAL_MODULE_TAGS := optional
>  LOCAL_MODULE := bluetoothd-snoop

Applied, thanks.

-- 
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply

* [PATCH] android: Fix bluetoothd installation path
From: Andrzej Kaczmarek @ 2014-01-08 16:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

This patch removes explicit LOCAL_MODULE_PATH definition for bluetoothd
and bluetoothd-snoop modules which caused both binaries to be installed
in /system/xbin instead of /system/bin folder.
---
 android/Android.mk | 2 --
 1 file changed, 2 deletions(-)

diff --git a/android/Android.mk b/android/Android.mk
index 16339b1..8eb918e 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -75,7 +75,6 @@ $(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
 
 $(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/../lib/bluetooth/$(file)))
 
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := bluetoothd
 
@@ -264,7 +263,6 @@ LOCAL_C_INCLUDES := \
 
 LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
 
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := bluetoothd-snoop
 
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH v2] android/audio: Add listener thread on the Audio HAL socket
From: Luiz Augusto von Dentz @ 2014-01-08 15:47 UTC (permalink / raw)
  To: Lukasz Rymanowski
  Cc: linux-bluetooth@vger.kernel.org, Szymon Janc, Johan Hedberg
In-Reply-To: <1389194371-14595-1-git-send-email-lukasz.rymanowski@tieto.com>

Hi Lukasz,

On Wed, Jan 8, 2014 at 5:19 PM, Lukasz Rymanowski
<lukasz.rymanowski@tieto.com> wrote:
> This patch add thread which is reponsible for listen on audio HAL
> socket, open a2dp endpoint(s) and maintain socket.
> When bluetooth daemon goes down, HAL audio plugin starts to listen on Audio HAL
> socket again.
>
> ---
>  android/Makefile.am |   5 ++-
>  android/hal-audio.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 129 insertions(+), 2 deletions(-)
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 8810369..88ffa7f 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -112,7 +112,8 @@ android_android_tester_LDFLAGS = -pthread
>
>  noinst_LTLIBRARIES += android/libaudio-internal.la
>
> -android_libaudio_internal_la_SOURCES = android/hal-audio.c \
> +android_libaudio_internal_la_SOURCES = androdid/audio-msg.h \
> +                                       android/hal-audio.c \
>                                         android/hardware/audio.h \
>                                         android/hardware/audio_effect.h \
>                                         android/hardware/hardware.h \
> @@ -120,6 +121,8 @@ android_libaudio_internal_la_SOURCES = android/hal-audio.c \
>
>  android_libaudio_internal_la_CFLAGS = -I$(srcdir)/android
>
> +android_libaudio_internal_la_LDFLAGS = -pthread
> +
>  endif
>
>  EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
> diff --git a/android/hal-audio.c b/android/hal-audio.c
> index 1743b42..12d3e0d 100644
> --- a/android/hal-audio.c
> +++ b/android/hal-audio.c
> @@ -16,15 +16,28 @@
>   */
>
>  #include <errno.h>
> +#include <pthread.h>
> +#include <poll.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <sys/socket.h>
> +#include <sys/un.h>
> +#include <unistd.h>
>
>  #include <hardware/audio.h>
>  #include <hardware/hardware.h>
>
> +#include "audio-msg.h"
>  #include "hal-log.h"
>
> +static int audio_sk = -1;
> +static bool close_thread = false;
> +
> +static pthread_t bt_watcher_th = 0;
> +static pthread_mutex_t sk_mutex = PTHREAD_MUTEX_INITIALIZER;
> +static pthread_mutex_t close_mutex = PTHREAD_MUTEX_INITIALIZER;
> +
>  struct a2dp_audio_dev {
>         struct audio_hw_device dev;
>         struct audio_stream_out *out;
> @@ -384,15 +397,117 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
>
>  static int audio_close(hw_device_t *device)
>  {
> +       struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)device;
> +
>         DBG("");
> -       free(device);
> +
> +       pthread_mutex_lock(&close_mutex);
> +       shutdown(audio_sk, SHUT_RDWR);
> +       close_thread = true;
> +       pthread_mutex_unlock(&close_mutex);
> +
> +       pthread_join(bt_watcher_th, NULL);
> +
> +       free(a2dp_dev);
>         return 0;
>  }
>
> +static bool create_audio_ipc(void)
> +{
> +       struct sockaddr_un addr;
> +       int err;
> +       int sk;
> +
> +       DBG("");
> +
> +       sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
> +       if (sk < 0) {
> +               err = errno;
> +               error("Failed to create socket: %d (%s)", err, strerror(err));
> +               return false;
> +       }
> +
> +       memset(&addr, 0, sizeof(addr));
> +       addr.sun_family = AF_UNIX;
> +
> +       memcpy(addr.sun_path, BLUEZ_AUDIO_SK_PATH,
> +                                       sizeof(BLUEZ_AUDIO_SK_PATH));
> +
> +       if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> +               err = errno;
> +               error("Failed to bind socket: %d (%s)", err, strerror(err));
> +               goto failed;
> +       }
> +
> +       if (listen(sk, 1) < 0) {
> +               err = errno;
> +               error("Failed to listen on the socket: %d (%s)", err,
> +                                                               strerror(err));
> +               goto failed;
> +       }
> +
> +       audio_sk = accept(sk, NULL, NULL);
> +       if (audio_sk < 0) {
> +               err = errno;
> +               error("Failed to accept socket: %d (%s)", err, strerror(err));
> +               goto failed;
> +       }
> +
> +       close(sk);
> +       return true;
> +
> +failed:
> +       close(sk);
> +       return false;
> +}
> +
> +static void *bluetoothd_watcher_thread(void *data)
> +{
> +       bool done = false;
> +       struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *) data;
> +       struct pollfd pfd;
> +
> +       DBG("");
> +
> +       while (!done) {
> +               if(!create_audio_ipc()) {
> +                       error("Failed to create listening socket");
> +                       sleep(1);
> +                       continue;
> +               }
> +
> +               DBG("Audio IPC: Connected");
> +
> +               /* TODO: Register ENDPOINT here */
> +
> +               memset(&pfd, 0, sizeof(pfd));
> +               pfd.fd = audio_sk;
> +               pfd.events = POLLHUP | POLLERR | POLLNVAL;
> +
> +               /* Check if socket is still alive. Empty while loop.*/
> +               while (poll(&pfd, 1, -1) < 0 && errno == EINTR);
> +
> +               if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
> +                       info("Audio HAL: Socket closed");
> +                       audio_sk = -1;
> +               }
> +
> +               /*Check if audio_dev is closed */
> +               pthread_mutex_lock(&close_mutex);
> +               done = close_thread;
> +               close_thread = false;
> +               pthread_mutex_unlock(&close_mutex);
> +       }
> +
> +       info("Closing bluetooth_watcher thread");
> +       return NULL;
> +}
> +
>  static int audio_open(const hw_module_t *module, const char *name,
>                                                         hw_device_t **device)
>  {
>         struct a2dp_audio_dev *a2dp_dev;
> +       int err;
>
>         DBG("");
>
> @@ -430,6 +545,15 @@ static int audio_open(const hw_module_t *module, const char *name,
>          * audio_hw_device. We will rely on this later in the code.*/
>         *device = &a2dp_dev->dev.common;
>
> +       err = pthread_create(&bt_watcher_th, NULL, bluetoothd_watcher_thread,
> +                                                                       NULL);
> +       if (err < 0) {
> +               bt_watcher_th = 0;
> +               error("Failed to start bluetoothd watcher thread: %d (%s)",
> +                                                       -err, strerror(-err));
> +               return (-err);
> +       }
> +
>         return 0;
>  }
>
> --
> 1.8.4

Pushed after stripping out some code not really used and fix a type in
Makefile.am.


-- 
Luiz Augusto von Dentz

^ permalink raw reply


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