* [PATCH 1/3] Bluetooth: Remove check for valid LTK authenticated parameter
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The LTK authenticated parameter is the key type of the LTK and similar
to link keys there is no need to check the currently supported values.
For possible future improvements, the kernel will only use key types
it knows about and just ignore all the other ones.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 70a3a7e917b7..8030eeb44382 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4146,8 +4146,6 @@ unlock:
static bool ltk_is_valid(struct mgmt_ltk_info *key)
{
- if (key->authenticated != 0x00 && key->authenticated != 0x01)
- return false;
if (key->master != 0x00 && key->master != 0x01)
return false;
if (!bdaddr_type_is_le(key->addr.type))
--
1.8.5.3
^ permalink raw reply related
* [PATCH 2/3] Bluetooth: Rename authentication to key_type in mgmt_ltk_info
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The field is not a boolean, it is actually a field for a key type. So
name it properly.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/mgmt.h | 2 +-
net/bluetooth/mgmt.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index dfab094fab73..4303fa90b7c1 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -182,7 +182,7 @@ struct mgmt_cp_load_link_keys {
struct mgmt_ltk_info {
struct mgmt_addr_info addr;
- __u8 authenticated;
+ __u8 type;
__u8 master;
__u8 enc_size;
__le16 ediv;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8030eeb44382..8c94841072a8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4207,7 +4207,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
type = HCI_SMP_LTK_SLAVE;
hci_add_ltk(hdev, &key->addr.bdaddr, addr_type,
- type, 0, key->authenticated, key->val,
+ type, 0, key->type, key->val,
key->enc_size, key->ediv, key->rand);
}
@@ -4648,7 +4648,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent)
ev.store_hint = persistent;
bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
- ev.key.authenticated = key->authenticated;
+ ev.key.type = key->authenticated;
ev.key.enc_size = key->enc_size;
ev.key.ediv = key->ediv;
--
1.8.5.3
^ permalink raw reply related
* [PATCH 3/3] Bluetooth: Remove __packed from struct smp_ltk
From: Marcel Holtmann @ 2014-02-01 2:42 UTC (permalink / raw)
To: linux-bluetooth
The struct smp_ltk does not need to be packed and so remove __packed.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 6854384b1f25..4e878780fa01 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -101,7 +101,7 @@ struct smp_ltk {
__le16 ediv;
u8 rand[8];
u8 val[16];
-} __packed;
+};
struct link_key {
struct list_head list;
--
1.8.5.3
^ permalink raw reply related
* [PATCH] core: Rename authentication to key_type in mgmt_ltk_info
From: Marcel Holtmann @ 2014-02-01 2:46 UTC (permalink / raw)
To: linux-bluetooth
---
lib/mgmt.h | 2 +-
src/adapter.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 58a651c1b10e..afd4e8b29ea3 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -177,7 +177,7 @@ struct mgmt_cp_load_link_keys {
struct mgmt_ltk_info {
struct mgmt_addr_info addr;
- uint8_t authenticated;
+ uint8_t type;
uint8_t master;
uint8_t enc_size;
uint16_t ediv;
diff --git a/src/adapter.c b/src/adapter.c
index 649fc7a957cf..18601eaa13dd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2444,7 +2444,7 @@ static void load_ltks(struct btd_adapter *adapter, GSList *keys)
memcpy(key->val, info->val, sizeof(info->val));
memcpy(key->rand, info->rand, sizeof(info->rand));
memcpy(&key->ediv, &info->ediv, sizeof(key->ediv));
- key->authenticated = info->authenticated;
+ key->type = info->authenticated;
key->master = info->master;
key->enc_size = info->enc_size;
}
@@ -5371,8 +5371,8 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
ba2str(&addr->bdaddr, dst);
- DBG("hci%u new LTK for %s authenticated %u enc_size %u",
- adapter->dev_id, dst, ev->key.authenticated, ev->key.enc_size);
+ DBG("hci%u new LTK for %s type %u enc_size %u",
+ adapter->dev_id, dst, ev->key.type, ev->key.enc_size);
device = btd_adapter_get_device(adapter, &addr->bdaddr, addr->type);
if (!device) {
@@ -5386,7 +5386,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
store_longtermkey(bdaddr, &key->addr.bdaddr,
key->addr.type, key->val, key->master,
- key->authenticated, key->enc_size,
+ key->type, key->enc_size,
key->ediv, key->rand);
device_set_bonded(device, TRUE);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Add constants for LTK key types
From: Marcel Holtmann @ 2014-02-01 3:02 UTC (permalink / raw)
To: linux-bluetooth
The LTK key types available right now are unauthenticated and
authenticated ones. Provide two simple constants for it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 232c07804ca8..352d3d7d06bb 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -346,6 +346,10 @@ enum {
#define HCI_SMP_LTK 0x82
#define HCI_SMP_LTK_SLAVE 0x83
+/* Long Term Key types */
+#define HCI_LTK_UNAUTH 0x00
+#define HCI_LTK_AUTH 0x01
+
/* ---- HCI Error Codes ---- */
#define HCI_ERROR_AUTH_FAILURE 0x05
#define HCI_ERROR_CONNECTION_TIMEOUT 0x08
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Add management command for Secure Connection Only Mode
From: Marcel Holtmann @ 2014-02-01 17:19 UTC (permalink / raw)
To: linux-bluetooth
With support for Secure Connections it is possible to switch the
controller into a mode that is called Secure Connections Only. In
this mode only security level 4 connections are allowed (with the
exception of security level 0 approved services).
This patch just introduces the management command and setting of the
right internal flags to enable this mode. It does not yet enforce it.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8c94841072a8..ce7ef339b1c4 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4043,7 +4043,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
{
struct mgmt_mode *cp = data;
struct pending_cmd *cmd;
- u8 status;
+ u8 val, status;
int err;
BT_DBG("request for %s", hdev->name);
@@ -4058,7 +4058,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_NOT_SUPPORTED);
- if (cp->val != 0x00 && cp->val != 0x01)
+ if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_INVALID_PARAMS);
@@ -4067,12 +4067,18 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
if (!hdev_is_powered(hdev)) {
bool changed;
- if (cp->val)
+ if (cp->val) {
changed = !test_and_set_bit(HCI_SC_ENABLED,
&hdev->dev_flags);
- else
+ if (cp->val == 0x02)
+ set_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ } else {
changed = test_and_clear_bit(HCI_SC_ENABLED,
&hdev->dev_flags);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev);
if (err < 0)
@@ -4090,7 +4096,10 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
- if (!!cp->val == test_bit(HCI_SC_ENABLED, &hdev->dev_flags)) {
+ val = !!cp->val;
+
+ if (val == test_bit(HCI_SC_ENABLED, &hdev->dev_flags) &&
+ (cp->val == 0x02) == test_bit(HCI_SC_ONLY, &hdev->dev_flags)) {
err = send_settings_rsp(sk, MGMT_OP_SET_SECURE_CONN, hdev);
goto failed;
}
@@ -4101,12 +4110,17 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
- err = hci_send_cmd(hdev, HCI_OP_WRITE_SC_SUPPORT, 1, &cp->val);
+ err = hci_send_cmd(hdev, HCI_OP_WRITE_SC_SUPPORT, 1, &val);
if (err < 0) {
mgmt_pending_remove(cmd);
goto failed;
}
+ if (cp->val == 0x02)
+ set_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ else
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+
failed:
hci_dev_unlock(hdev);
return err;
@@ -5063,19 +5077,24 @@ void mgmt_sc_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
if (status) {
u8 mgmt_err = mgmt_status(status);
- if (enable && test_and_clear_bit(HCI_SC_ENABLED,
- &hdev->dev_flags))
- new_settings(hdev, NULL);
+ if (enable) {
+ if (test_and_clear_bit(HCI_SC_ENABLED,
+ &hdev->dev_flags))
+ new_settings(hdev, NULL);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
mgmt_pending_foreach(MGMT_OP_SET_SECURE_CONN, hdev,
cmd_status_rsp, &mgmt_err);
return;
}
- if (enable)
+ if (enable) {
changed = !test_and_set_bit(HCI_SC_ENABLED, &hdev->dev_flags);
- else
+ } else {
changed = test_and_clear_bit(HCI_SC_ENABLED, &hdev->dev_flags);
+ clear_bit(HCI_SC_ONLY, &hdev->dev_flags);
+ }
mgmt_pending_foreach(MGMT_OP_SET_SECURE_CONN, hdev,
settings_rsp, &match);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Include security level 4 in connections check
From: Marcel Holtmann @ 2014-02-01 19:32 UTC (permalink / raw)
To: linux-bluetooth
This check is only used for RFCOMM connections and most likely no
RFCOMM based profile will require security level 4 secure connection
security policy. In case it ever does make sure that seucrity level 4
is treated as sufficient security level.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_conn.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 7ef5bffb61aa..801820f12226 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -860,13 +860,17 @@ int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level)
{
BT_DBG("hcon %p", conn);
- if (sec_level != BT_SECURITY_HIGH)
- return 1; /* Accept if non-secure is required */
+ /* Accept if non-secure or higher security level is required */
+ if (sec_level != BT_SECURITY_HIGH && sec_level != BT_SECURITY_FIPS)
+ return 1;
- if (conn->sec_level == BT_SECURITY_HIGH)
+ /* Accept if secure or higher security level is already present */
+ if (conn->sec_level == BT_SECURITY_HIGH ||
+ conn->sec_level == BT_SECURITY_FIPS)
return 1;
- return 0; /* Reject not secure link */
+ /* Reject not secure link */
+ return 0;
}
EXPORT_SYMBOL(hci_conn_check_secure);
--
1.8.5.3
^ permalink raw reply related
* [PATCH] Bluetooth: Track if link is using P-256 authenticated combination key
From: Marcel Holtmann @ 2014-02-01 19:52 UTC (permalink / raw)
To: linux-bluetooth
When the ACL link is using P-256 authenticated combination key, mark
the link mode as HCI_LM_FIPS.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_event.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 36c9a488ac56..d2c6878a9d6a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1998,6 +1998,10 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
conn->link_mode |= HCI_LM_ENCRYPT;
conn->sec_level = conn->pending_sec_level;
+ /* P-256 authentication key implies FIPS */
+ if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256)
+ conn->link_mode |= HCI_LM_FIPS;
+
if ((conn->type == ACL_LINK && ev->encrypt == 0x02) ||
conn->type == LE_LINK)
set_bit(HCI_CONN_AES_CCM, &conn->flags);
--
1.8.5.3
^ permalink raw reply related
* Re: [PATCH 3/3] Bluetooth: Remove use_debug_keys debugfs entry
From: Johan Hedberg @ 2014-02-02 1:48 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Anderson Lizardo, BlueZ development
In-Reply-To: <9CDEAC4F-17D1-4CB4-BB5F-91D1D793791B@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> >> Since the use of debug keys can not be identified from the current
> >> settings information, this debugfs entry is no longer.
> >
> > I believe you meant "debug keys can be identified..." and "is no
> > longer necessary.”
>
> indeed I did.
>
> Johan, in case you go ahead with applying this patch, please fix this up.
Done. All three patches in the set are now in the bluetooth-next tree.
Johan
^ permalink raw reply
* Re: [PATCH] doc: Describe the new debug keys command and setting
From: Johan Hedberg @ 2014-02-02 1:50 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391199568-55855-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> ---
> doc/mgmt-api.txt | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Remove one level of indentation from hci_encrypt_change_evt
From: Johan Hedberg @ 2014-02-02 1:57 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391214268-13443-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> The function already has an unlock label which means the one extra level
> on indentation is not useful and just makes the code more complex. So
> remove it.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_event.c | 49 ++++++++++++++++++++++++-----------------------
> 1 file changed, 25 insertions(+), 24 deletions(-)
Both patches in this set have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Bluetooth: Remove check for valid LTK authenticated parameter
From: Johan Hedberg @ 2014-02-02 2:01 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391222538-34065-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> The LTK authenticated parameter is the key type of the LTK and similar
> to link keys there is no need to check the currently supported values.
>
> For possible future improvements, the kernel will only use key types
> it knows about and just ignore all the other ones.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/mgmt.c | 2 --
> 1 file changed, 2 deletions(-)
All three patches in this set have been applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] core: Rename authentication to key_type in mgmt_ltk_info
From: Johan Hedberg @ 2014-02-02 2:01 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391222783-36848-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> ---
> lib/mgmt.h | 2 +-
> src/adapter.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add management command for Secure Connection Only Mode
From: Johan Hedberg @ 2014-02-02 2:27 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391275197-5060-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Feb 01, 2014, Marcel Holtmann wrote:
> With support for Secure Connections it is possible to switch the
> controller into a mode that is called Secure Connections Only. In
> this mode only security level 4 connections are allowed (with the
> exception of security level 0 approved services).
>
> This patch just introduces the management command and setting of the
> right internal flags to enable this mode. It does not yet enforce it.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/mgmt.c | 41 ++++++++++++++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 11 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Track if link is using P-256 authenticated combination key
From: Johan Hedberg @ 2014-02-02 2:30 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391284322-29778-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Feb 01, 2014, Marcel Holtmann wrote:
> When the ACL link is using P-256 authenticated combination key, mark
> the link mode as HCI_LM_FIPS.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_event.c | 4 ++++
> 1 file changed, 4 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add constants for LTK key types
From: Johan Hedberg @ 2014-02-02 2:31 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391223750-48812-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Fri, Jan 31, 2014, Marcel Holtmann wrote:
> The LTK key types available right now are unauthenticated and
> authenticated ones. Provide two simple constants for it.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 4 ++++
> 1 file changed, 4 insertions(+)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Include security level 4 in connections check
From: Johan Hedberg @ 2014-02-02 2:32 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1391283145-21148-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Sat, Feb 01, 2014, Marcel Holtmann wrote:
> This check is only used for RFCOMM connections and most likely no
> RFCOMM based profile will require security level 4 secure connection
> security policy. In case it ever does make sure that seucrity level 4
> is treated as sufficient security level.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_conn.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* [PATCH 00/11] Add bonding test cases
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andrzej Kaczmarek
Hi,
A bit more explanation for last patch in this series:
We've encountered random timeouts for test cases which we found to be
because of missing "credit" in bthost which queued HCI command
indefinitely. The problem here was that previous HCI command in bthost
was sent from notification_handler thread in android-tester while reply
was handled in main thread. This caused race condition in bthost code
which is not thread-safe.
A quick fix for this would be to simply change order of operations in
send_command as follows:
if (bthost->ncmd) {
bthost->ncmd--;
send_packet(bthost, pkt_data, pkt_len);
} else {
So, first decrease number of "credits" and then send packet, so command
complete received in another thread cannot overwrite this value before
it's updated. But since this does not make code thread-safe and just
hides problem temporarily, we've decided to wrap all callbacks from
notification_thread to serialize their execution in main loop.
Andrzej Kaczmarek (1):
android/tester: Make bt_callbacks thread-safe
Grzegorz Kolodziejczyk (10):
android/tester: Coding style and syntax fix
android/tester: Add create bond with PIN success test case
android/tester: Add create bond with PIN fail test case
android/tester: Add create bond with SSP sucess test case
android/tester: Add create bond with SSP fail test case
android/tester: Add create bond with no discovery test case
android/tester: Add create bond with bad addr fail test case
android/tester: Add cancel bond success test case
android/tester: Add remove bond success test case
android/tester: Add remove bond bad addr dev test case
android/android-tester.c | 809 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 763 insertions(+), 46 deletions(-)
--
1.8.5.2
^ permalink raw reply
* [PATCH 01/11] android/tester: Coding style and syntax fix
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Remove white spaces, break lines over 80 characters, redundand braces
for single statement blocks.
---
android/android-tester.c | 50 +++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 870ad8d..8071e68 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -690,9 +690,8 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
- if (test && test->expected_hal_cb.discovery_state_changed_cb) {
+ if (test && test->expected_hal_cb.discovery_state_changed_cb)
test->expected_hal_cb.discovery_state_changed_cb(state);
- }
}
static void discovery_device_found_cb(int num_properties,
@@ -837,10 +836,9 @@ static void device_found_cb(int num_properties, bt_property_t *properties)
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
- if (data->test_init_done && test->expected_hal_cb.device_found_cb) {
+ if (data->test_init_done && test->expected_hal_cb.device_found_cb)
test->expected_hal_cb.device_found_cb(num_properties,
properties);
- }
}
static void check_count_properties_cb(bt_status_t status, int num_properties,
@@ -852,7 +850,6 @@ static void check_count_properties_cb(bt_status_t status, int num_properties,
check_expected_property(properties[i]);
}
-
static void adapter_properties_cb(bt_status_t status, int num_properties,
bt_property_t *properties)
{
@@ -860,11 +857,9 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
const struct generic_data *test = data->test_data;
if (data->test_init_done &&
- test->expected_hal_cb.adapter_properties_cb) {
- test->expected_hal_cb.adapter_properties_cb(
- status, num_properties,
- properties);
- }
+ test->expected_hal_cb.adapter_properties_cb)
+ test->expected_hal_cb.adapter_properties_cb(status,
+ num_properties, properties);
}
static void remote_test_device_properties_cb(bt_status_t status,
@@ -908,10 +903,9 @@ static void remote_device_properties_cb(bt_status_t status,
const struct generic_data *test = data->test_data;
if (data->test_init_done &&
- test->expected_hal_cb.remote_device_properties_cb) {
+ test->expected_hal_cb.remote_device_properties_cb)
test->expected_hal_cb.remote_device_properties_cb(status,
bd_addr, num_properties, properties);
- }
}
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
@@ -1324,7 +1318,8 @@ static struct priority_property setprop_scanmode_none_props[] = {
},
};
-static const struct generic_data bluetooth_setprop_scanmode_none_success2_test = {
+static const struct generic_data
+ bluetooth_setprop_scanmode_none_success2_test = {
.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
.expected_properties_num = 1,
.expected_properties = setprop_scanmode_none_props,
@@ -2090,7 +2085,8 @@ static void test_enable(const void *test_data)
init_test_conditions(data);
- bdaddr2android((const bdaddr_t *)bdaddr, &enable_done_bdaddr_val.address);
+ bdaddr2android((const bdaddr_t *)bdaddr,
+ &enable_done_bdaddr_val.address);
adapter_status = data->if_bluetooth->enable();
check_expected_status(adapter_status);
@@ -2105,7 +2101,8 @@ static void test_enable_done(const void *test_data)
init_test_conditions(data);
- bdaddr2android((const bdaddr_t *)bdaddr, &enable_done_bdaddr_val.address);
+ bdaddr2android((const bdaddr_t *)bdaddr,
+ &enable_done_bdaddr_val.address);
adapter_status = data->if_bluetooth->enable();
check_expected_status(adapter_status);
@@ -2167,7 +2164,8 @@ static void test_getprop_bdaddr_success(const void *test_data)
init_test_conditions(data);
- bdaddr2android((const bdaddr_t *)bdaddr, &test_getprop_bdaddr_val.address);
+ bdaddr2android((const bdaddr_t *)bdaddr,
+ &test_getprop_bdaddr_val.address);
adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
check_expected_status(adapter_status);
@@ -3433,7 +3431,6 @@ static void emu_powered_complete(uint16_t opcode, uint8_t status,
bt_status = data->if_hid->connect(&bdaddr);
if (bt_status != BT_STATUS_SUCCESS)
tester_setup_failed();
-
}
static void setup_hidhost_connect(const void *test_data)
@@ -3632,15 +3629,20 @@ int main(int argc, char *argv[])
test_bredrle("Bluetooth Init", NULL, setup_base, test_dummy, teardown);
- test_bredrle("Bluetooth Enable - Success", &bluetooth_enable_success_test,
- setup_base, test_enable, teardown);
+ test_bredrle("Bluetooth Enable - Success",
+ &bluetooth_enable_success_test,
+ setup_base, test_enable,
+ teardown);
test_bredrle("Bluetooth Enable - Success 2",
- &bluetooth_enable_success2_test, setup_enabled_adapter,
- test_enable_done, teardown);
-
- test_bredrle("Bluetooth Disable - Success", &bluetooth_disable_success_test,
- setup_enabled_adapter, test_disable, teardown);
+ &bluetooth_enable_success2_test,
+ setup_enabled_adapter,
+ test_enable_done, teardown);
+
+ test_bredrle("Bluetooth Disable - Success",
+ &bluetooth_disable_success_test,
+ setup_enabled_adapter,
+ test_disable, teardown);
test_bredrle("Bluetooth Set BDNAME - Success",
&bluetooth_setprop_bdname_success_test,
--
1.8.5.2
^ permalink raw reply related
* [PATCH 02/11] android/tester: Add create bond with PIN success test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with PIN success test case.
---
android/android-tester.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 116 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 8071e68..761827e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -831,6 +831,22 @@ static void remote_setprop_fail_device_found_cb(int num_properties,
check_expected_status(status);
}
+static void bond_device_found_cb(int num_properties, bt_property_t *properties)
+{
+ struct test_data *data = tester_get_data();
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+ bt_status_t status;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ if (data->cb_count == 4) {
+ data->cb_count--;
+ status = data->if_bluetooth->create_bond(&remote_addr);
+ check_expected_status(status);
+ }
+}
+
static void device_found_cb(int num_properties, bt_property_t *properties)
{
struct test_data *data = tester_get_data();
@@ -908,6 +924,75 @@ static void remote_device_properties_cb(bt_status_t status,
bd_addr, num_properties, properties);
}
+static void bond_test_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct test_data *data = tester_get_data();
+
+ switch (state) {
+ case BT_BOND_STATE_NONE:
+ data->cb_count--;
+ check_cb_count();
+ break;
+ case BT_BOND_STATE_BONDING:
+ data->cb_count--;
+ break;
+ case BT_BOND_STATE_BONDED:
+ data->cb_count--;
+ check_cb_count();
+ break;
+ default:
+ break;
+ }
+}
+
+static void bond_state_changed_cb(bt_status_t status,
+ bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+
+ if (data->test_init_done && test->expected_hal_cb.bond_state_changed_cb)
+ test->expected_hal_cb.bond_state_changed_cb(status,
+ remote_bd_addr, state);
+}
+
+static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_pin_code_reply rp;
+ bdaddr_t remote_addr;
+ static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
+ const void *pin_code = pair_device_pin;
+ uint8_t pin_len = 4;
+
+ memset(&rp, 0, sizeof(rp));
+
+ data->cb_count--;
+
+ android2bdaddr(remote_bd_addr, &remote_addr);
+
+ bacpy(&rp.addr.bdaddr, &remote_addr);
+ rp.addr.type = BDADDR_BREDR;
+ rp.pin_len = pin_len;
+ memcpy(rp.pin_code, pin_code, rp.pin_len);
+
+ mgmt_reply(data->mgmt, MGMT_OP_PIN_CODE_REPLY, data->mgmt_index,
+ sizeof(rp), &rp, NULL, NULL, NULL);
+}
+
+static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+
+ if (data->test_init_done && test->expected_hal_cb.pin_request_cb)
+ test->expected_hal_cb.pin_request_cb(remote_bd_addr, bd_name,
+ cod);
+}
+
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
static char enable_done_bdname_val[] = "BlueZ for Android";
static bt_uuid_t enable_done_uuids_val = {
@@ -1930,6 +2015,14 @@ static const struct generic_data bt_dev_setprop_disctimeout_fail_test = {
.expected_adapter_status = BT_STATUS_FAIL,
};
+static const struct generic_data bt_bond_create_pin_success_test = {
+ .expected_hal_cb.device_found_cb = bond_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb = bond_test_state_changed_cb,
+ .expected_hal_cb.pin_request_cb = bond_create_pin_success_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1937,9 +2030,9 @@ static bt_callbacks_t bt_callbacks = {
.remote_device_properties_cb = remote_device_properties_cb,
.device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
- .pin_request_cb = NULL,
.ssp_request_cb = NULL,
- .bond_state_changed_cb = NULL,
+ .pin_request_cb = pin_request_cb,
+ .bond_state_changed_cb = bond_state_changed_cb,
.acl_state_changed_cb = NULL,
.thread_evt_cb = NULL,
.dut_mode_recv_cb = NULL,
@@ -2667,6 +2760,22 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_pin_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
+ const void *pin = pair_device_pin;
+ uint8_t pin_len = 4;
+
+ init_test_conditions(data);
+
+ bthost_set_pin_code(bthost, pin, pin_len);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -3899,6 +4008,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_dev_setprop_disctimeout_fail, teardown);
+ test_bredrle("Bluetooth Create Bond PIN - Success",
+ &bt_bond_create_pin_success_test,
+ setup_enabled_adapter,
+ test_bond_create_pin_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 03/11] android/tester: Add create bond with PIN fail test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with PIN fail test case.
---
android/android-tester.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 761827e..d8f7d82 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -847,6 +847,21 @@ static void bond_device_found_cb(int num_properties, bt_property_t *properties)
}
}
+static void bond_nostatus_device_found_cb(int num_properties,
+ bt_property_t *properties)
+{
+ struct test_data *data = tester_get_data();
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ if (data->cb_count == 4) {
+ data->cb_count--;
+ data->if_bluetooth->create_bond(&remote_addr);
+ }
+}
+
static void device_found_cb(int num_properties, bt_property_t *properties)
{
struct test_data *data = tester_get_data();
@@ -982,6 +997,31 @@ static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
sizeof(rp), &rp, NULL, NULL, NULL);
}
+static void bond_create_pin_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_pin_code_reply rp;
+ bdaddr_t remote_addr;
+ static uint8_t bad_device_pin[] = { 0x31, 0x31, 0x31, 0x31 };
+ const void *pin_code = bad_device_pin;
+ uint8_t pin_len = 4;
+
+ memset(&rp, 0, sizeof(rp));
+
+ android2bdaddr(remote_bd_addr, &remote_addr);
+
+ data->cb_count--;
+
+ bacpy(&rp.addr.bdaddr, &remote_addr);
+ rp.addr.type = BDADDR_BREDR;
+ rp.pin_len = pin_len;
+ memcpy(rp.pin_code, pin_code, rp.pin_len);
+
+ mgmt_reply(data->mgmt, MGMT_OP_PIN_CODE_REPLY, data->mgmt_index,
+ sizeof(rp), &rp, NULL, NULL, NULL);
+}
+
static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
bt_bdname_t *bd_name, uint32_t cod)
{
@@ -2023,6 +2063,14 @@ static const struct generic_data bt_bond_create_pin_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_pin_fail_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb = bond_test_state_changed_cb,
+ .expected_hal_cb.pin_request_cb = bond_create_pin_fail_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2760,6 +2808,16 @@ static void test_dev_setprop_disctimeout_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+
+static void bond_device_auth_fail_callback(uint16_t index, uint16_t length,
+ const void *param,
+ void *user_data)
+{
+ const struct mgmt_ev_auth_failed *ev = param;
+
+ check_expected_status(ev->status);
+}
+
static void test_bond_create_pin_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -2776,6 +2834,26 @@ static void test_bond_create_pin_success(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_pin_fail(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ static uint8_t pair_device_pin[] = { 0x30, 0x30, 0x30, 0x30 };
+ const void *pin = pair_device_pin;
+ uint8_t pin_len = 4;
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_AUTH_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ bthost_set_pin_code(bthost, pin, pin_len);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -4013,6 +4091,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_pin_success, teardown);
+ test_bredrle("Bluetooth Create Bond PIN - Bad PIN",
+ &bt_bond_create_pin_fail_test,
+ setup_enabled_adapter,
+ test_bond_create_pin_fail, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 04/11] android/tester: Add create bond with SSP sucess test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with SSP succes test case. Confirm is set as SSP
pairing mode.
---
android/android-tester.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index d8f7d82..bfa23e9 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1033,6 +1033,57 @@ static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
cod);
}
+static void bond_create_ssp_request_cb(const bt_bdaddr_t *remote_bd_addr,
+ bt_ssp_variant_t pairing_variant,
+ bool accept)
+{
+ bdaddr_t remote_addr;
+ struct test_data *data = tester_get_data();
+ struct mgmt_addr_info cp;
+ uint16_t opcode;
+
+ android2bdaddr(remote_bd_addr, &remote_addr);
+
+ if (pairing_variant == 0) { /* HAL_SSP_VARIANT_CONFIRM */
+ if (accept)
+ opcode = MGMT_OP_USER_CONFIRM_REPLY;
+ else
+ opcode = MGMT_OP_USER_CONFIRM_NEG_REPLY;
+
+ data->cb_count--;
+
+ bacpy(&cp.bdaddr, &remote_addr);
+ cp.type = BDADDR_BREDR;
+
+ mgmt_reply(data->mgmt, opcode, data->mgmt_index, sizeof(cp),
+ &cp, NULL, NULL, NULL);
+ } else
+ tester_test_failed();
+}
+
+static void bond_create_ssp_success_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod,
+ bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ bool accept = true;
+
+ bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept);
+}
+
+static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
+ uint32_t cod, bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+
+ if (data->test_init_done &&
+ test->expected_hal_cb.ssp_request_cb)
+ test->expected_hal_cb.ssp_request_cb(remote_bd_addr, bd_name,
+ cod, pairing_variant, pass_key);
+}
+
static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
static char enable_done_bdname_val[] = "BlueZ for Android";
static bt_uuid_t enable_done_uuids_val = {
@@ -2071,6 +2122,14 @@ static const struct generic_data bt_bond_create_pin_fail_test = {
.expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
};
+static const struct generic_data bt_bond_create_ssp_success_test = {
+ .expected_hal_cb.device_found_cb = bond_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb = bond_test_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2078,8 +2137,8 @@ static bt_callbacks_t bt_callbacks = {
.remote_device_properties_cb = remote_device_properties_cb,
.device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
- .ssp_request_cb = NULL,
.pin_request_cb = pin_request_cb,
+ .ssp_request_cb = ssp_request_cb,
.bond_state_changed_cb = bond_state_changed_cb,
.acl_state_changed_cb = NULL,
.thread_evt_cb = NULL,
@@ -2854,6 +2913,18 @@ static void test_bond_create_pin_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_ssp_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -4096,6 +4167,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_pin_fail, teardown);
+ test_bredrle("Bluetooth Create Bond SSP - Success",
+ &bt_bond_create_ssp_success_test,
+ setup_enabled_adapter,
+ test_bond_create_ssp_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 05/11] android/tester: Add create bond with SSP fail test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with SSP fail test case. Confirm is set as SSP
pairing mode.
---
android/android-tester.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index bfa23e9..ba3b812 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -1071,6 +1071,16 @@ static void bond_create_ssp_success_request_cb(bt_bdaddr_t *remote_bd_addr,
bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept);
}
+static void bond_create_ssp_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
+ bt_bdname_t *bd_name, uint32_t cod,
+ bt_ssp_variant_t pairing_variant,
+ uint32_t pass_key)
+{
+ bool accept = false;
+
+ bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept);
+}
+
static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
uint32_t cod, bt_ssp_variant_t pairing_variant,
uint32_t pass_key)
@@ -2130,6 +2140,14 @@ static const struct generic_data bt_bond_create_ssp_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_ssp_fail_test = {
+ .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
+ .expected_hal_cb.bond_state_changed_cb = bond_test_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_fail_request_cb,
+ .expected_cb_count = 4,
+ .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2925,6 +2943,22 @@ static void test_bond_create_ssp_success(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_ssp_fail(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_AUTH_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ data->if_bluetooth->start_discovery();
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -4172,6 +4206,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_ssp_success, teardown);
+ test_bredrle("Bluetooth Create Bond SSP - Negative reply",
+ &bt_bond_create_ssp_fail_test,
+ setup_enabled_adapter,
+ test_bond_create_ssp_fail, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 06/11] android/tester: Add create bond with no discovery test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with no discovery before create bond as NFC does.
SSP with confirm as authentication mode.
---
android/android-tester.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index ba3b812..c8c2a75 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2148,6 +2148,13 @@ static const struct generic_data bt_bond_create_ssp_fail_test = {
.expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
};
+static const struct generic_data bt_bond_create_no_disc_success_test = {
+ .expected_hal_cb.bond_state_changed_cb = bond_test_state_changed_cb,
+ .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
+ .expected_cb_count = 3,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2959,6 +2966,25 @@ static void test_bond_create_ssp_fail(const void *test_data)
data->if_bluetooth->start_discovery();
}
+static void test_bond_create_no_disc_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
+ bt_bdaddr_t remote_addr;
+ bt_status_t status;
+
+ init_test_conditions(data);
+
+ bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
+
+ bthost_write_ssp_mode(bthost, 0x01);
+
+ status = data->if_bluetooth->create_bond(&remote_addr);
+ check_expected_status(status);
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -4211,6 +4237,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_ssp_fail, teardown);
+ test_bredrle("Bluetooth Create Bond - No Discovery",
+ &bt_bond_create_no_disc_success_test,
+ setup_enabled_adapter,
+ test_bond_create_no_disc_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 07/11] android/tester: Add create bond with bad addr fail test case
From: Andrzej Kaczmarek @ 2014-02-02 11:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk
In-Reply-To: <1391339801-587-1-git-send-email-andrzej.kaczmarek@tieto.com>
From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
This adds create bond with bad addr fail test case.
---
android/android-tester.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index c8c2a75..3497f4a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2155,6 +2155,10 @@ static const struct generic_data bt_bond_create_no_disc_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS,
};
+static const struct generic_data bt_bond_create_bad_addr_success_test = {
+ .expected_adapter_status = MGMT_STATUS_CONNECT_FAILED,
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -2985,6 +2989,22 @@ static void test_bond_create_no_disc_success(const void *test_data)
check_expected_status(status);
}
+static void test_bond_create_bad_addr_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_bdaddr_t bad_addr = {
+ .address = { 0x12, 0x34, 0x56, 0x78, 0x90, 0x12 }
+ };
+
+ init_test_conditions(data);
+
+ mgmt_register(data->mgmt, MGMT_EV_CONNECT_FAILED, data->mgmt_index,
+ bond_device_auth_fail_callback, data,
+ NULL);
+
+ data->if_bluetooth->create_bond(&bad_addr);
+}
+
/* Test Socket HAL */
static void adapter_socket_state_changed_cb(bt_state_t state)
@@ -4242,6 +4262,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_bond_create_no_disc_success, teardown);
+ test_bredrle("Bluetooth Create Bond - Bad Address",
+ &bt_bond_create_bad_addr_success_test,
+ setup_enabled_adapter,
+ test_bond_create_bad_addr_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox