All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] android/tester: Add action to verify encryption change
@ 2014-09-03  9:02 Jakub Tyszkowski
  2014-09-03  9:02 ` [PATCH 2/8] android/tester: Allow HIDHost to use custom sdp response Jakub Tyszkowski
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-09-03  9:02 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

When encryption change is verified encryption flag is cleared so we can
detect another encryption change when device reconnects during execution
of another step in the same test case.
---
 android/tester-main.c | 38 ++++++++++++++++++++++++++++++++++++++
 android/tester-main.h |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/android/tester-main.c b/android/tester-main.c
index f5f46fb..34a71ac 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -28,6 +28,8 @@ static gint scheduled_cbacks_num;
 #define EMULATOR_SIGNAL_TIMEOUT 2 /* in seconds */
 #define EMULATOR_SIGNAL "emulator_started"
 
+static const uint8_t hci_encr_change_hdr[] = { 0x04, 0x08, 0x04, 0x00 };
+
 static gboolean check_callbacks_called(gpointer user_data)
 {
 	/*
@@ -213,6 +215,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 test_data *t_data = tester_get_data();
+
+	/*
+	 * Expected data: header (4 octets) + conn. handle (2 octets) +
+	 * encryption flag (1 octet)
+	 */
+	if (len < sizeof(hci_encr_change_hdr) + 3)
+		return true;
+
+	/* Verify header, skip conn. handle and check encryption */
+	if (!memcmp(hci_encr_change_hdr, data, sizeof(hci_encr_change_hdr)))
+		t_data->is_encrypted = ((uint8_t *)data)[6] ? true : false;
+
+	return true;
+}
+
 static void read_info_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -250,6 +271,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();
 }
 
@@ -1804,6 +1829,19 @@ void emu_add_l2cap_server_action(void)
 	schedule_action_verification(step);
 }
 
+void bt_verify_encryption_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step *step = g_new0(struct step, 1);
+
+	step->action_status = data->is_encrypted ? BT_STATUS_SUCCESS :
+								BT_STATUS_FAIL;
+
+	data->is_encrypted = 0;
+
+	schedule_action_verification(step);
+}
+
 static void rfcomm_connect_cb(uint16_t handle, uint16_t cid, void *user_data,
 								bool status)
 {
diff --git a/android/tester-main.h b/android/tester-main.h
index 46aacce..cb8300d 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -331,6 +331,7 @@ struct test_data {
 	pid_t bluetoothd_pid;
 
 	struct queue *pdus;
+	bool is_encrypted;
 };
 
 /*
@@ -477,3 +478,4 @@ void bt_ssp_reply_accept_action(void);
 void bt_cancel_bond_action(void);
 void bt_remove_bond_action(void);
 void set_default_ssp_request_handler(void);
+void bt_verify_encryption_action(void);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-09-04 11:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03  9:02 [PATCH 1/8] android/tester: Add action to verify encryption change Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 2/8] android/tester: Allow HIDHost to use custom sdp response Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 3/8] android/tester: Add case verifying encryption on HIDHost Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 4/8] android/tester: Fix HIDHost cases sending fixed tid sdp responses Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 5/8] emulator/btdev: Overwrite default feature mask when SPP is toggled Jakub Tyszkowski
2014-09-03  9:39   ` Johan Hedberg
2014-09-03 13:34     ` Tyszkowski Jakub
2014-09-04 10:54       ` Tyszkowski Jakub
2014-09-04 11:09         ` Johan Hedberg
2014-09-04 11:57           ` Tyszkowski Jakub
2014-09-03  9:02 ` [PATCH 6/8] android/tester: Enable SSP in emulator by default Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 7/8] android/tester: Add support for rejected connections Jakub Tyszkowski
2014-09-03  9:02 ` [PATCH 8/8] android/tester: Add Hidhost rejecting connection case Jakub Tyszkowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.