Linux bluetooth development
 help / color / mirror / Atom feed
From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Subject: [PATCH 3/5] android/tester: Add encryption change callback
Date: Fri,  3 Oct 2014 15:08:41 +0200	[thread overview]
Message-ID: <1412341723-8415-3-git-send-email-jakub.tyszkowski@tieto.com> (raw)
In-Reply-To: <1412341723-8415-1-git-send-email-jakub.tyszkowski@tieto.com>

This is needed for  encryption verification.
---
 android/tester-main.c | 25 +++++++++++++++++++++++++
 android/tester-main.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/android/tester-main.c b/android/tester-main.c
index c637fd5..d5ebe16 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -104,6 +104,8 @@ static struct {
 
 	/* Emulator callbacks */
 	DBG_CB(CB_EMU_CONFIRM_SEND_DATA),
+	DBG_CB(CB_EMU_ENCRYPTION_ENABLED),
+	DBG_CB(CB_EMU_ENCRYPTION_DISABLED),
 };
 
 static gboolean check_callbacks_called(gpointer user_data)
@@ -291,6 +293,25 @@ static void mgmt_debug(const char *str, void *user_data)
 	tester_print("%s%s", prefix, str);
 }
 
+static bool hciemu_post_encr_hook(const void *data, uint16_t len,
+							void *user_data)
+{
+	struct step *step = g_new0(struct step, 1);
+
+	/*
+	 * Expected data: status (1 octet) + conn. handle (2 octets) +
+	 * encryption flag (1 octet)
+	 */
+	if (len < 4)
+		return true;
+
+	step->callback = ((uint8_t *)data)[3] ? CB_EMU_ENCRYPTION_ENABLED :
+						CB_EMU_ENCRYPTION_DISABLED;
+
+	schedule_callback_verification(step);
+	return true;
+}
+
 static void read_info_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -328,6 +349,10 @@ static void read_info_callback(uint8_t status, uint16_t length,
 		return;
 	}
 
+	/* set hook for encryption change */
+	hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_EVT, 0x08,
+						hciemu_post_encr_hook, NULL);
+
 	tester_pre_setup_complete();
 }
 
diff --git a/android/tester-main.h b/android/tester-main.h
index 6245381..e96ad24 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -400,6 +400,8 @@ typedef enum {
 
 	/* Emulator callbacks */
 	CB_EMU_CONFIRM_SEND_DATA,
+	CB_EMU_ENCRYPTION_ENABLED,
+	CB_EMU_ENCRYPTION_DISABLED,
 } expected_bt_callback_t;
 
 struct test_data {
-- 
1.9.1


  parent reply	other threads:[~2014-10-03 13:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 13:08 [PATCH 1/5] android/tester: Rename and expose callback verification function Jakub Tyszkowski
2014-10-03 13:08 ` [PATCH 2/5] android/tester: Improve HIDHost data sending verification Jakub Tyszkowski
2014-10-03 13:08 ` Jakub Tyszkowski [this message]
2014-10-03 13:08 ` [PATCH 4/5] android/tester: Add case verifying encryption on HIDHost Jakub Tyszkowski
2014-10-03 13:08 ` [PATCH 5/5] android/tester: Add case for reconnecting HID keyboard device Jakub Tyszkowski
2014-10-06 11:35 ` [PATCH 1/5] android/tester: Rename and expose callback verification function Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412341723-8415-3-git-send-email-jakub.tyszkowski@tieto.com \
    --to=jakub.tyszkowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox