* [PATCHv2 1/6] emulator: Add new method for adding l2cap server
From: Marcin Kraglak @ 2013-12-19 14:29 UTC (permalink / raw)
To: linux-bluetooth
This method allow user to add l2cap server and register
connect callback. If no callback is specified, it will behave
like bthost_set_server_psm() method.
---
emulator/bthost.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++----
emulator/bthost.h | 5 +++++
2 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 654338d..7ccef9c 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -90,6 +90,13 @@ struct l2cap_pending_req {
struct l2cap_pending_req *next;
};
+struct l2cap_conn_cb_data {
+ uint16_t psm;
+ bthost_l2cap_connect_cb func;
+ void *user_data;
+ struct l2cap_conn_cb_data *next;
+};
+
struct bthost {
uint8_t bdaddr[6];
bthost_send_func send_handler;
@@ -101,7 +108,7 @@ struct bthost {
void *cmd_complete_data;
bthost_new_conn_cb new_conn_cb;
void *new_conn_data;
- uint16_t server_psm;
+ struct l2cap_conn_cb_data *new_l2cap_conn_data;
struct l2cap_pending_req *l2reqs;
};
@@ -187,6 +194,19 @@ static struct l2conn *btconn_find_l2cap_conn_by_scid(struct btconn *conn,
return NULL;
}
+static struct l2cap_conn_cb_data *bthost_find_l2cap_cb_by_psm(
+ struct bthost *bthost, uint16_t psm)
+{
+ struct l2cap_conn_cb_data *cb;
+
+ for (cb = bthost->new_l2cap_conn_data; cb != NULL; cb = cb->next) {
+ if (cb->psm == psm)
+ return cb;
+ }
+
+ return NULL;
+}
+
void bthost_destroy(struct bthost *bthost)
{
if (!bthost)
@@ -214,6 +234,13 @@ void bthost_destroy(struct bthost *bthost)
free(req);
}
+ while (bthost->new_l2cap_conn_data) {
+ struct l2cap_conn_cb_data *cb = bthost->new_l2cap_conn_data;
+
+ bthost->new_l2cap_conn_data = cb->next;
+ free(cb);
+ }
+
free(bthost);
}
@@ -737,7 +764,7 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
memset(&rsp, 0, sizeof(rsp));
rsp.scid = req->scid;
- if (bthost->server_psm && bthost->server_psm == psm)
+ if (bthost_find_l2cap_cb_by_psm(bthost, psm))
rsp.dcid = cpu_to_le16(conn->next_cid++);
else
rsp.result = cpu_to_le16(0x0002); /* PSM Not Supported */
@@ -747,6 +774,8 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
if (!rsp.result) {
struct bt_l2cap_pdu_config_req conf_req;
+ struct l2cap_conn_cb_data *cb_data;
+ struct l2conn *l2conn;
bthost_add_l2cap_conn(bthost, conn, le16_to_cpu(rsp.dcid),
le16_to_cpu(rsp.scid),
@@ -757,6 +786,14 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn,
l2cap_sig_send(bthost, conn, BT_L2CAP_PDU_CONFIG_REQ, 0,
&conf_req, sizeof(conf_req));
+
+ cb_data = bthost_find_l2cap_cb_by_psm(bthost, psm);
+ l2conn = btconn_find_l2cap_conn_by_scid(conn,
+ le16_to_cpu(rsp.scid));
+
+ if (cb_data && l2conn->psm == cb_data->psm && cb_data->func)
+ cb_data->func(conn->handle, l2conn->dcid,
+ cb_data->user_data);
}
return true;
@@ -1012,7 +1049,7 @@ static bool l2cap_le_conn_req(struct bthost *bthost, struct btconn *conn,
rsp.mps = 23;
rsp.credits = 1;
- if (bthost->server_psm && bthost->server_psm == psm)
+ if (bthost_find_l2cap_cb_by_psm(bthost, psm))
rsp.dcid = cpu_to_le16(conn->next_cid++);
else
rsp.result = cpu_to_le16(0x0002); /* PSM Not Supported */
@@ -1249,9 +1286,26 @@ void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle,
send_command(bthost, BT_HCI_CMD_LE_START_ENCRYPT, &cmd, sizeof(cmd));
}
+void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
+ bthost_l2cap_connect_cb func, void *user_data)
+{
+ struct l2cap_conn_cb_data *data;
+
+ data = malloc(sizeof(struct l2cap_conn_cb_data));
+ if (!data)
+ return;
+
+ data->psm = psm;
+ data->user_data = user_data;
+ data->func = func;
+ data->next = bthost->new_l2cap_conn_data;
+
+ bthost->new_l2cap_conn_data = data;
+}
+
void bthost_set_server_psm(struct bthost *bthost, uint16_t psm)
{
- bthost->server_psm = psm;
+ bthost_add_l2cap_server(bthost, psm, NULL, NULL);
}
void bthost_start(struct bthost *bthost)
diff --git a/emulator/bthost.h b/emulator/bthost.h
index 474ada9..2b8f212 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -74,8 +74,13 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
void bthost_le_start_encrypt(struct bthost *bthost, uint16_t handle,
const uint8_t ltk[16]);
+typedef void (*bthost_l2cap_connect_cb) (uint16_t handle, uint16_t cid,
+ void *user_data);
void bthost_set_server_psm(struct bthost *bthost, uint16_t psm);
+void bthost_add_l2cap_server(struct bthost *bthost, uint16_t psm,
+ bthost_l2cap_connect_cb func, void *user_data);
+
void bthost_start(struct bthost *bthost);
void bthost_stop(struct bthost *bthost);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH 1/6] android/tester: Fix for not checking for BT_STATUS_SUCCESS
From: Johan Hedberg @ 2013-12-19 13:42 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Thu, Dec 19, 2013, Jakub Tyszkowski wrote:
> For BT_STATUS_SUCCESS no checks were done as it is 0 in bt_status_t
> enum. Valid status for no status expected should be STATUS_NOT_EXPECTED.
>
> ---
> android/android-tester.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index c24f5a6..5549dcb 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -72,7 +72,7 @@ enum hal_bluetooth_callbacks_id {
> };
>
> struct generic_data {
> - uint8_t expected_adapter_status;
> + int expected_adapter_status;
> uint32_t expect_settings_set;
> bt_property_t expected_property;
> uint8_t expected_hal_callbacks[];
> @@ -92,6 +92,8 @@ struct socket_data {
> #define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
> #define EMULATOR_SIGNAL "emulator_started"
>
> +#define BT_STATUS_NOT_EXPECTED -1
> +
> struct test_data {
> struct mgmt *mgmt;
> uint16_t mgmt_index;
> @@ -199,7 +201,7 @@ static void expected_status_init(struct test_data *data)
> {
> const struct generic_data *test_data = data->test_data;
>
> - if (!(test_data->expected_adapter_status))
> + if (test_data->expected_adapter_status == BT_STATUS_NOT_EXPECTED)
> data->status_checked = true;
> }
I suppose it does make sense to have such a special value, but I can't
see you use it anywhere in your patch set. So I'd postpone this patch
until you've got some actual code that needs it.
Johan
^ permalink raw reply
* Re: [PATCH] android/build: Adding l2test to Android.mk
From: Szymon Janc @ 2013-12-19 13:33 UTC (permalink / raw)
To: Sebastian Chlad; +Cc: linux-bluetooth, Sebastian Chlad
In-Reply-To: <1387457595-8020-1-git-send-email-sebastianx.chlad@intel.com>
Hi Sebastian,
> Enabling l2test tool for the android target
> ---
> android/Android.mk | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/android/Android.mk b/android/Android.mk
> index ebc3219..fee2f6c 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -226,3 +226,27 @@ LOCAL_MODULE_TAGS := optional
> LOCAL_MODULE := audio.a2dp.default
>
> include $(BUILD_SHARED_LIBRARY)
> +
> +#
> +# l2cap-test
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> + ../tools/l2test.c \
> + ../lib/bluetooth.c \
> + ../lib/hci.c \
> +
> +LOCAL_C_INCLUDES := \
> + $(LOCAL_PATH)/.. \
> + $(LOCAL_PATH)/../lib \
> + $(LOCAL_PATH)/../src/shared \
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
> +LOCAL_MODULE_TAGS := eng
> +LOCAL_MODULE := l2test
> +
> +include $(BUILD_EXECUTABLE)
>
Applied (after fixing commit message), thanks.
--
BR
Szymon Janc
^ permalink raw reply
* Re: [PATCH] avrcp: Remove unneeded code
From: Luiz Augusto von Dentz @ 2013-12-19 13:18 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1387444404-6834-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thu, Dec 19, 2013 at 11:13 AM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Checking (val & 0x7f) > 127 does not make any sense.
> ---
> profiles/audio/avrcp.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index cd027c6..7731e88 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -1577,15 +1577,10 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session,
> {
> struct avrcp_player *player = session->controller->player;
> uint16_t len = ntohs(pdu->params_len);
> - uint8_t volume;
>
> if (len != 1)
> goto err;
>
> - volume = pdu->params[0] & 0x7F;
> - if (volume > 127)
> - goto err;
> -
> if (!player)
> goto err;
>
> --
> 1.8.3.2
Ive applied a proper fix, there was a real problem since we were not
passing the value stored in volume which does ignore the reserved bits
properly, Ive also removed the the check for > 127 since it will never
be the case after & 0x7F operation which was initially your idea but
we cannot just remove volume for the reasons stated above.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [RFCv4 5/5] Bluetooth: Add management command to relax MITM Protection
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Timo Mueller
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>
From: Timo Mueller <timo.mueller@bmw-carit.de>
As a general rule, the Bluetooth Specification (v4.0 Volume 3, part C,
section 6.5.3) recommends *NOT* to require MITM Protection, unless the
available local services require it. The Kernel doesn't however adhere
to this recommendation because the locally available services are not
known reliably.
This lack of information is exactly what this patch addresses: a
dedicated flag is proposed in the management interface. If set to 1, the
recommentation described in the specification will be followed: it will
be assumed that none of the locally available services require MITM
Protection, unless the Kernel has any evidence of the contrary (i.e. a
socket exists with a high security level, which requires MITM
Protection).
If set to 0, MITM Protection will always be required, provided that it
is possible according to the I/O capabilities. This was the behavior
prior to this patch and therefore the flag is set to 0 by default.
Note that this affects General Bonding and Dedicated Bonding equally as
well as locally or remotely initiated pairing procedures.
Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
include/net/bluetooth/hci.h | 3 ++-
include/net/bluetooth/mgmt.h | 3 +++
net/bluetooth/hci_event.c | 15 ++++++++++++---
net/bluetooth/mgmt.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 5dc3d90..147fac6 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -121,6 +121,7 @@ enum {
HCI_LE_SCAN,
HCI_SSP_ENABLED,
+ HCI_RELAX_MITM,
HCI_HS_ENABLED,
HCI_LE_ENABLED,
HCI_ADVERTISING,
@@ -138,7 +139,7 @@ enum {
* or the HCI device is closed.
*/
#define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \
- BIT(HCI_FAST_CONNECTABLE))
+ BIT(HCI_FAST_CONNECTABLE) | BIT(HCI_RELAX_MITM))
/* HCI ioctl defines */
#define HCIDEVUP _IOW('H', 201, int)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 518c5c8..2da018b 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -94,6 +94,7 @@ struct mgmt_rp_read_index_list {
#define MGMT_SETTING_HS 0x00000100
#define MGMT_SETTING_LE 0x00000200
#define MGMT_SETTING_ADVERTISING 0x00000400
+#define MGMT_SETTING_RELAX_MITM 0x00000800
#define MGMT_OP_READ_INFO 0x0004
#define MGMT_READ_INFO_SIZE 0
@@ -369,6 +370,8 @@ struct mgmt_cp_set_scan_params {
} __packed;
#define MGMT_SET_SCAN_PARAMS_SIZE 4
+#define MGMT_OP_SET_RELAX_MITM 0x002D
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
__le16 opcode;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4516215..d23370b 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3042,6 +3042,12 @@ static u8 hci_get_auth_req(struct hci_conn *conn)
conn->remote_auth == HCI_AT_NO_BONDING_MITM)
return conn->remote_auth | (conn->auth_type & 0x01);
+ /* MITM Protection should be used only if strictly required, so follow
+ * the recommendation in the Spec and do not require it otherwise
+ */
+ if (test_bit(HCI_RELAX_MITM, &conn->hdev->dev_flags))
+ return conn->remote_auth | (conn->auth_type & 0x01);
+
/* If both remote and local have enough IO capabilities, require
* MITM protection
*/
@@ -3085,11 +3091,14 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (conn->remote_auth == 0xff) {
cp.authentication = conn->auth_type;
- /* Request MITM protection if our IO caps allow it
- * except for the no-bonding case
+ /* MITM Protection should be used only if strictly
+ * required, so follow the recommendation in the Spec
+ * and do not require it otherwise (no-bonding is left
+ * unmodified in any case)
*/
if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
- cp.authentication != HCI_AT_NO_BONDING)
+ cp.authentication != HCI_AT_NO_BONDING &&
+ !test_bit(HCI_RELAX_MITM, &conn->hdev->dev_flags))
cp.authentication |= 0x01;
} else {
conn->auth_type = hci_get_auth_req(conn);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8e302f4..2aca565 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -79,6 +79,7 @@ static const u16 mgmt_commands[] = {
MGMT_OP_SET_BREDR,
MGMT_OP_SET_STATIC_ADDRESS,
MGMT_OP_SET_SCAN_PARAMS,
+ MGMT_OP_SET_RELAX_MITM,
};
static const u16 mgmt_events[] = {
@@ -375,6 +376,7 @@ static u32 get_supported_settings(struct hci_dev *hdev)
if (lmp_ssp_capable(hdev)) {
settings |= MGMT_SETTING_SSP;
settings |= MGMT_SETTING_HS;
+ settings |= MGMT_SETTING_RELAX_MITM;
}
}
@@ -423,6 +425,9 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
settings |= MGMT_SETTING_ADVERTISING;
+ if (test_bit(HCI_RELAX_MITM, &hdev->dev_flags))
+ settings |= MGMT_SETTING_RELAX_MITM;
+
return settings;
}
@@ -1719,6 +1724,45 @@ failed:
return err;
}
+static int set_relax_mitm(struct sock *sk, struct hci_dev *hdev, void *data,
+ u16 len)
+{
+ struct mgmt_mode *cp = data;
+ u8 val;
+ int err;
+
+ BT_DBG("request for %s", hdev->name);
+
+ if (!lmp_ssp_capable(hdev))
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_RELAX_MITM,
+ MGMT_STATUS_NOT_SUPPORTED);
+
+ if (cp->val != 0x00 && cp->val != 0x01)
+ return cmd_status(sk, hdev->id, MGMT_OP_SET_RELAX_MITM,
+ MGMT_STATUS_INVALID_PARAMS);
+
+ hci_dev_lock(hdev);
+
+ val = !!cp->val;
+
+ if (val == test_bit(HCI_RELAX_MITM, &hdev->dev_flags)) {
+ err = send_settings_rsp(sk, MGMT_OP_SET_RELAX_MITM, hdev);
+ goto failed;
+ }
+
+ change_bit(HCI_RELAX_MITM, &hdev->dev_flags);
+
+ err = send_settings_rsp(sk, MGMT_OP_SET_RELAX_MITM, hdev);
+ if (err < 0)
+ goto failed;
+
+ err = new_settings(hdev, sk);
+
+failed:
+ hci_dev_unlock(hdev);
+ return err;
+}
+
static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
{
struct mgmt_mode *cp = data;
@@ -4124,6 +4168,7 @@ static const struct mgmt_handler {
{ set_bredr, false, MGMT_SETTING_SIZE },
{ set_static_address, false, MGMT_SET_STATIC_ADDRESS_SIZE },
{ set_scan_params, false, MGMT_SET_SCAN_PARAMS_SIZE },
+ { set_relax_mitm, false, MGMT_SETTING_SIZE },
};
--
1.8.3.1
^ permalink raw reply related
* [RFCv4 4/5] Bluetooth: Request MITM Protection when initiator
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz, Timo Mueller
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The GAP Specification gives the flexibility to decide whether MITM
Protection is requested or not (Bluetooth Core Specification v4.0
Volume 3, part C, section 6.5.3) when replying to an
HCI_EV_IO_CAPA_REQUEST event.
The recommendation is *not* to set this flag "unless the security
policy of an available local service requires MITM Protection"
(regardless of the bonding type). However, the kernel doesn't
necessarily have this information and therefore the safest choice is
to always use MITM Protection, also for General Bonding.
This patch changes the behavior for the General Bonding initiator
role, always requesting MITM Protection even if no high security level
is used. Depending on the remote capabilities, the protection might
not be actually used, and we will accept this locally unless of course
a high security level was originally required.
Note that this was already done for Dedicated Bonding. No-Bonding is
left unmodified because MITM Protection is normally not desired in
these cases.
Signed-off-by: Mikel Astiz <mikel.astiz@bmw-carit.de>
Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
net/bluetooth/hci_event.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 882e569..4516215 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3085,9 +3085,11 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (conn->remote_auth == 0xff) {
cp.authentication = conn->auth_type;
- /* Use MITM protection for outgoing dedicated bonding */
+ /* Request MITM protection if our IO caps allow it
+ * except for the no-bonding case
+ */
if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
- cp.authentication == HCI_AT_DEDICATED_BONDING)
+ cp.authentication != HCI_AT_NO_BONDING)
cp.authentication |= 0x01;
} else {
conn->auth_type = hci_get_auth_req(conn);
--
1.8.3.1
^ permalink raw reply related
* [RFCv4 3/5] Bluetooth: Use MITM Protection when IO caps allow it
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Timo Mueller, Mikel Astiz
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>
From: Timo Mueller <timo.mueller@bmw-carit.de>
When responding to a remotely-initiated pairing procedure, a MITM
protected SSP associaton model can be used for pairing if both local
and remote IO capabilities are set to something other than
NoInputNoOutput, regardless of the bonding type (Dedicated or
General).
This was already done for Dedicated Bonding but this patch proposes to
use the same policy for General Bonding as well.
The GAP Specification gives the flexibility to decide whether MITM
Protection is used ot not (Bluetooth Core Specification v4.0 Volume 3,
part C, section 6.5.3).
Note however that the recommendation is *not* to set this flag "unless
the security policy of an available local service requires MITM
Protection" (for both Dedicated and General Bonding). However, the
kernel doesn't necessarily have this information and therefore the
safest choice is to always use MITM Protection, also for General
Bonding.
Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
Signed-off-by: Mikel Astiz <mikel.astiz@bmw-carit.de>
---
net/bluetooth/hci_event.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1cbec8f..882e569 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3042,11 +3042,6 @@ static u8 hci_get_auth_req(struct hci_conn *conn)
conn->remote_auth == HCI_AT_NO_BONDING_MITM)
return conn->remote_auth | (conn->auth_type & 0x01);
- /* For general bonding, use the given auth_type */
- if (conn->remote_auth == HCI_AT_GENERAL_BONDING ||
- conn->remote_auth == HCI_AT_GENERAL_BONDING_MITM)
- return conn->auth_type;
-
/* If both remote and local have enough IO capabilities, require
* MITM protection
*/
@@ -3054,8 +3049,8 @@ static u8 hci_get_auth_req(struct hci_conn *conn)
conn->io_capability != HCI_IO_NO_INPUT_OUTPUT)
return conn->remote_auth | 0x01;
- /* No MITM protection possible so remove requirement */
- return conn->remote_auth & ~0x01;
+ /* No MITM protection possible so ignore remote requirement */
+ return (conn->remote_auth & ~0x01) | (conn->auth_type & 0x01);
}
static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
--
1.8.3.1
^ permalink raw reply related
* [RFCv4 2/5] Bluetooth: Refactor code for outgoing dedicated bonding
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Do not always set the MITM protection requirement by default in the
field conn->auth_type, since this will be added later in
hci_io_capa_request_evt(), as part of the requirements specified in
HCI_OP_IO_CAPABILITY_REPLY.
This avoids a hackish exception for the auto-reject case, but doesn't
change the behavior of the code at all.
Signed-off-by: Mikel Astiz <mikel.astiz@bmw-carit.de>
---
net/bluetooth/hci_event.c | 14 ++++++++------
net/bluetooth/mgmt.c | 5 +----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6f9c425..1cbec8f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3089,6 +3089,11 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
/* If we are initiators, there is no remote information yet */
if (conn->remote_auth == 0xff) {
cp.authentication = conn->auth_type;
+
+ /* Use MITM protection for outgoing dedicated bonding */
+ if (conn->io_capability != HCI_IO_NO_INPUT_OUTPUT &&
+ cp.authentication == HCI_AT_DEDICATED_BONDING)
+ cp.authentication |= 0x01;
} else {
conn->auth_type = hci_get_auth_req(conn);
cp.authentication = conn->auth_type;
@@ -3160,12 +3165,9 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
rem_mitm = (conn->remote_auth & 0x01);
/* If we require MITM but the remote device can't provide that
- * (it has NoInputNoOutput) then reject the confirmation
- * request. The only exception is when we're dedicated bonding
- * initiators (connect_cfm_cb set) since then we always have the MITM
- * bit set. */
- if (!conn->connect_cfm_cb && loc_mitm &&
- conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) {
+ * (it has NoInputNoOutput) then reject the confirmation request
+ */
+ if (loc_mitm && conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT) {
BT_DBG("Rejecting request: remote device can't provide MITM");
hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
sizeof(ev->bdaddr), &ev->bdaddr);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a03ca3c..8e302f4 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2692,10 +2692,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
}
sec_level = BT_SECURITY_MEDIUM;
- if (cp->io_cap == 0x03)
- auth_type = HCI_AT_DEDICATED_BONDING;
- else
- auth_type = HCI_AT_DEDICATED_BONDING_MITM;
+ auth_type = HCI_AT_DEDICATED_BONDING;
if (cp->addr.type == BDADDR_BREDR)
conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr,
--
1.8.3.1
^ permalink raw reply related
* [RFCv4 1/5] Bluetooth: Refactor hci_get_auth_req()
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz, Timo Mueller
In-Reply-To: <cover.1387450435.git.timo.mueller@bmw-carit.de>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Refactor the code without changing its behavior by handling the
no-bonding cases first followed by General Bonding.
Signed-off-by: Mikel Astiz <mikel.astiz@bmw-carit.de>
Signed-off-by: Timo Mueller <timo.mueller@bmw-carit.de>
---
net/bluetooth/hci_event.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 5f81245..6f9c425 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3037,24 +3037,25 @@ unlock:
static u8 hci_get_auth_req(struct hci_conn *conn)
{
- /* If remote requests dedicated bonding follow that lead */
- if (conn->remote_auth == HCI_AT_DEDICATED_BONDING ||
- conn->remote_auth == HCI_AT_DEDICATED_BONDING_MITM) {
- /* If both remote and local IO capabilities allow MITM
- * protection then require it, otherwise don't */
- if (conn->remote_cap == HCI_IO_NO_INPUT_OUTPUT ||
- conn->io_capability == HCI_IO_NO_INPUT_OUTPUT)
- return HCI_AT_DEDICATED_BONDING;
- else
- return HCI_AT_DEDICATED_BONDING_MITM;
- }
-
/* If remote requests no-bonding follow that lead */
if (conn->remote_auth == HCI_AT_NO_BONDING ||
conn->remote_auth == HCI_AT_NO_BONDING_MITM)
return conn->remote_auth | (conn->auth_type & 0x01);
- return conn->auth_type;
+ /* For general bonding, use the given auth_type */
+ if (conn->remote_auth == HCI_AT_GENERAL_BONDING ||
+ conn->remote_auth == HCI_AT_GENERAL_BONDING_MITM)
+ return conn->auth_type;
+
+ /* If both remote and local have enough IO capabilities, require
+ * MITM protection
+ */
+ if (conn->remote_cap != HCI_IO_NO_INPUT_OUTPUT &&
+ conn->io_capability != HCI_IO_NO_INPUT_OUTPUT)
+ return conn->remote_auth | 0x01;
+
+ /* No MITM protection possible so remove requirement */
+ return conn->remote_auth & ~0x01;
}
static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
@@ -3084,8 +3085,14 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
* to DisplayYesNo as it is not supported by BT spec. */
cp.capability = (conn->io_capability == 0x04) ?
HCI_IO_DISPLAY_YESNO : conn->io_capability;
- conn->auth_type = hci_get_auth_req(conn);
- cp.authentication = conn->auth_type;
+
+ /* If we are initiators, there is no remote information yet */
+ if (conn->remote_auth == 0xff) {
+ cp.authentication = conn->auth_type;
+ } else {
+ conn->auth_type = hci_get_auth_req(conn);
+ cp.authentication = conn->auth_type;
+ }
if (hci_find_remote_oob_data(hdev, &conn->dst) &&
(conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)))
--
1.8.3.1
^ permalink raw reply related
* [RFCv4 0/5] SSP MITM protection
From: Timo Mueller @ 2013-12-19 13:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Timo Mueller
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(-)
--
1.8.3.1
^ permalink raw reply
* Re: [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Szymon Janc @ 2013-12-19 13:01 UTC (permalink / raw)
To: Sebastian Chlad; +Cc: linux-bluetooth, Sebastian Chlad
In-Reply-To: <1387456001-6792-1-git-send-email-sebastianx.chlad@intel.com>
Hi Sebastian,
> This allows better tracking of the current state of implementation
> ---
> android/Makefile.am | 4 +-
> android/pics-l2cap.txt | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
> android/pixit-l2cap.txt | 39 ++++++++++++
> android/pts-l2cap.txt | 148 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 347 insertions(+), 1 deletion(-)
> create mode 100644 android/pics-l2cap.txt
> create mode 100644 android/pixit-l2cap.txt
> create mode 100644 android/pts-l2cap.txt
Patch applied, thanks.
--
BR
Szymon Janc
^ permalink raw reply
* [PATCH] android/build: Adding l2test to Android.mk
From: Sebastian Chlad @ 2013-12-19 12:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian Chlad
Enabling l2test tool for the android target
---
android/Android.mk | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index ebc3219..fee2f6c 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -226,3 +226,27 @@ LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := audio.a2dp.default
include $(BUILD_SHARED_LIBRARY)
+
+#
+# l2cap-test
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ ../tools/l2test.c \
+ ../lib/bluetooth.c \
+ ../lib/hci.c \
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+ $(LOCAL_PATH)/../src/shared \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE := l2test
+
+include $(BUILD_EXECUTABLE)
--
1.8.1.2
^ permalink raw reply related
* [PATCH 6/6] android/tester: Add start device discovery done test case
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
This tests device discovery start being reported as done because of
ongoing discovery.
---
android/android-tester.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 737aeb3..aa0c155 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -98,6 +98,7 @@ struct socket_data {
/* User flags for Device Discovery */
#define DEVICE_DISCOVERY_CANCEL_ON_START 0x01
+#define DEVICE_DISCOVERY_START_ON_START 0x02
struct test_data {
struct mgmt *mgmt;
@@ -543,6 +544,11 @@ static void post_discovery_started_cb(bt_discovery_state_t state)
status = data->if_bluetooth->cancel_discovery();
check_expected_status(status);
}
+
+ if (data->userflag & DEVICE_DISCOVERY_START_ON_START) {
+ status = data->if_bluetooth->start_discovery();
+ check_expected_status(status);
+ }
}
static void discovery_state_changed_cb(bt_discovery_state_t state)
@@ -741,6 +747,12 @@ static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS
};
+static const struct generic_data bluetooth_discovery_start_done_test = {
+ .expected_hal_callbacks = { ADAPTER_DISCOVERY_STATE_ON,
+ ADAPTER_TEST_END },
+ .expected_adapter_status = BT_STATUS_DONE
+};
+
static const struct generic_data bluetooth_discovery_stop_done_test = {
.expected_hal_callbacks = { ADAPTER_TEST_END },
.expected_adapter_status = BT_STATUS_DONE
@@ -1324,6 +1336,20 @@ static void test_discovery_stop_success(const void *test_data)
check_expected_status(status);
}
+static void test_discovery_start_done(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ data->userflag = DEVICE_DISCOVERY_START_ON_START;
+
+ init_test_conditions(data);
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT, BT_HCI_CMD_INQUIRY,
+ pre_inq_compl_hook, data);
+
+ data->if_bluetooth->start_discovery();
+}
+
static gboolean socket_chan_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -1495,6 +1521,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_service_record_invalid, teardown);
+ test_bredrle("Bluetooth BREDR Discovery Start - Done",
+ &bluetooth_discovery_start_done_test,
+ setup_enabled_adapter,
+ test_discovery_start_done, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.5
^ permalink raw reply related
* [PATCH 5/6] android/tester: Add device discovery cancel success test case
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
Test for successfull discovery canceling after it was started.
---
android/android-tester.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 0dae111..737aeb3 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -96,6 +96,9 @@ struct socket_data {
#define BT_STATUS_NOT_EXPECTED -1
+/* User flags for Device Discovery */
+#define DEVICE_DISCOVERY_CANCEL_ON_START 0x01
+
struct test_data {
struct mgmt *mgmt;
uint16_t mgmt_index;
@@ -115,6 +118,8 @@ struct test_data {
bt_property_t test_property;
GSList *expected_callbacks;
+
+ uint32_t userflag;
};
static char exec_dir[PATH_MAX + 1];
@@ -529,11 +534,23 @@ static void adapter_state_changed_cb(bt_state_t state)
}
}
+static void post_discovery_started_cb(bt_discovery_state_t state)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+
+ if (data->userflag & DEVICE_DISCOVERY_CANCEL_ON_START) {
+ status = data->if_bluetooth->cancel_discovery();
+ check_expected_status(status);
+ }
+}
+
static void discovery_state_changed_cb(bt_discovery_state_t state)
{
switch (state) {
case BT_DISCOVERY_STARTED:
update_hal_cb_list(ADAPTER_DISCOVERY_STATE_ON);
+ post_discovery_started_cb(state);
break;
case BT_DISCOVERY_STOPPED:
update_hal_cb_list(ADAPTER_DISCOVERY_STATE_OFF);
@@ -729,6 +746,12 @@ static const struct generic_data bluetooth_discovery_stop_done_test = {
.expected_adapter_status = BT_STATUS_DONE
};
+static const struct generic_data bluetooth_discovery_stop_success_test = {
+ .expected_hal_callbacks = { ADAPTER_DISCOVERY_STATE_ON,
+ ADAPTER_DISCOVERY_STATE_OFF, ADAPTER_TEST_END },
+ .expected_adapter_status = BT_STATUS_SUCCESS
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1279,6 +1302,28 @@ static void test_discovery_stop_done(const void *test_data)
check_expected_status(status);
}
+static bool pre_inq_compl_hook(const void *data, uint16_t len, void *user_data)
+{
+ /* Make sure Inquiry Command Complete is not called */
+ return false;
+}
+
+static void test_discovery_stop_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+
+ data->userflag = DEVICE_DISCOVERY_CANCEL_ON_START;
+
+ init_test_conditions(data);
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT, BT_HCI_CMD_INQUIRY,
+ pre_inq_compl_hook, data);
+
+ status = data->if_bluetooth->start_discovery();
+ check_expected_status(status);
+}
+
static gboolean socket_chan_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -1460,6 +1505,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_discovery_stop_done, teardown);
+ test_bredrle("Bluetooth BREDR Discovery Stop - Success",
+ &bluetooth_discovery_stop_success_test,
+ setup_enabled_adapter,
+ test_discovery_stop_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5
^ permalink raw reply related
* [PATCH 4/6] android/tester: Add stop device discovery done test case
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
Add test case for stopping device discovery when it wasn't started.
---
android/android-tester.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 1880cf1..0dae111 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -724,6 +724,11 @@ static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_adapter_status = BT_STATUS_SUCCESS
};
+static const struct generic_data bluetooth_discovery_stop_done_test = {
+ .expected_hal_callbacks = { ADAPTER_TEST_END },
+ .expected_adapter_status = BT_STATUS_DONE
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1263,6 +1268,17 @@ static void test_discovery_start_success(const void *test_data)
check_expected_status(status);
}
+static void test_discovery_stop_done(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+
+ init_test_conditions(data);
+
+ status = data->if_bluetooth->cancel_discovery();
+ check_expected_status(status);
+}
+
static gboolean socket_chan_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -1439,6 +1455,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_discovery_start_success, teardown);
+ test_bredrle("Bluetooth BREDR Discovery Stop - Done",
+ &bluetooth_discovery_stop_done_test,
+ setup_enabled_adapter,
+ test_discovery_stop_done, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5
^ permalink raw reply related
* [PATCH 3/6] android/tester: Add start device discovery success test case
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
Add test case for starting device discovery with success.
---
android/android-tester.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 68614a2..1880cf1 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -68,7 +68,9 @@ enum hal_bluetooth_callbacks_id {
ADAPTER_PROP_SCAN_MODE,
ADAPTER_PROP_DISC_TIMEOUT,
ADAPTER_PROP_SERVICE_RECORD,
- ADAPTER_PROP_BONDED_DEVICES
+ ADAPTER_PROP_BONDED_DEVICES,
+ ADAPTER_DISCOVERY_STATE_ON,
+ ADAPTER_DISCOVERY_STATE_OFF
};
struct generic_data {
@@ -527,6 +529,20 @@ static void adapter_state_changed_cb(bt_state_t state)
}
}
+static void discovery_state_changed_cb(bt_discovery_state_t state)
+{
+ switch (state) {
+ case BT_DISCOVERY_STARTED:
+ update_hal_cb_list(ADAPTER_DISCOVERY_STATE_ON);
+ break;
+ case BT_DISCOVERY_STOPPED:
+ update_hal_cb_list(ADAPTER_DISCOVERY_STATE_OFF);
+ break;
+ default:
+ break;
+ }
+}
+
static void adapter_properties_cb(bt_status_t status, int num_properties,
bt_property_t *properties)
{
@@ -702,13 +718,19 @@ static const struct generic_data
.expected_property.len = sizeof(setprop_remote_service)
};
+static const struct generic_data bluetooth_discovery_start_success_test = {
+ .expected_hal_callbacks = { ADAPTER_DISCOVERY_STATE_ON,
+ ADAPTER_TEST_END },
+ .expected_adapter_status = BT_STATUS_SUCCESS
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
.adapter_properties_cb = adapter_properties_cb,
.remote_device_properties_cb = NULL,
.device_found_cb = NULL,
- .discovery_state_changed_cb = NULL,
+ .discovery_state_changed_cb = discovery_state_changed_cb,
.pin_request_cb = NULL,
.ssp_request_cb = NULL,
.bond_state_changed_cb = NULL,
@@ -1230,6 +1252,17 @@ clean:
close(sock_fd);
}
+static void test_discovery_start_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+
+ init_test_conditions(data);
+
+ status = data->if_bluetooth->start_discovery();
+ check_expected_status(status);
+}
+
static gboolean socket_chan_cb(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
@@ -1401,6 +1434,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_service_record_invalid, teardown);
+ test_bredrle("Bluetooth BREDR Discovery Start - Success",
+ &bluetooth_discovery_start_success_test,
+ setup_enabled_adapter,
+ test_discovery_start_success, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.5
^ permalink raw reply related
* [PATCH 2/6] android/tester: Fix bluetooth disable success test case
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1387456946-9743-1-git-send-email-jakub.tyszkowski@tieto.com>
This fixes not checking for proper status on bluetooth disable.
---
android/android-tester.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 5549dcb..68614a2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -596,7 +596,8 @@ static const struct generic_data bluetooth_enable_done_test = {
static const struct generic_data bluetooth_disable_success_test = {
.expected_hal_callbacks = { ADAPTER_STATE_CHANGED_OFF,
- ADAPTER_TEST_END }
+ ADAPTER_TEST_END },
+ .expected_adapter_status = BT_STATUS_SUCCESS
};
static const struct generic_data bluetooth_setprop_bdname_success_test = {
@@ -858,10 +859,12 @@ static void test_enable_done(const void *test_data)
static void test_disable(const void *test_data)
{
struct test_data *data = tester_get_data();
+ bt_status_t adapter_status;
init_test_conditions(data);
- data->if_bluetooth->disable();
+ adapter_status = data->if_bluetooth->disable();
+ check_expected_status(adapter_status);
}
static void test_setprop_bdname_success(const void *test_data)
--
1.8.5
^ permalink raw reply related
* [PATCH 1/6] android/tester: Fix for not checking for BT_STATUS_SUCCESS
From: Jakub Tyszkowski @ 2013-12-19 12:42 UTC (permalink / raw)
To: linux-bluetooth
For BT_STATUS_SUCCESS no checks were done as it is 0 in bt_status_t
enum. Valid status for no status expected should be STATUS_NOT_EXPECTED.
---
android/android-tester.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index c24f5a6..5549dcb 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -72,7 +72,7 @@ enum hal_bluetooth_callbacks_id {
};
struct generic_data {
- uint8_t expected_adapter_status;
+ int expected_adapter_status;
uint32_t expect_settings_set;
bt_property_t expected_property;
uint8_t expected_hal_callbacks[];
@@ -92,6 +92,8 @@ struct socket_data {
#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
#define EMULATOR_SIGNAL "emulator_started"
+#define BT_STATUS_NOT_EXPECTED -1
+
struct test_data {
struct mgmt *mgmt;
uint16_t mgmt_index;
@@ -199,7 +201,7 @@ static void expected_status_init(struct test_data *data)
{
const struct generic_data *test_data = data->test_data;
- if (!(test_data->expected_adapter_status))
+ if (test_data->expected_adapter_status == BT_STATUS_NOT_EXPECTED)
data->status_checked = true;
}
--
1.8.5
^ permalink raw reply related
* [PATCH v2 5/5] android: Set umask in system-emulator
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>
This will make sure files are created with proper permissions so
Android daemon doesn't have to handle that. On Android umask is
set by init.
---
android/system-emulator.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/android/system-emulator.c b/android/system-emulator.c
index 24f2741..299de0f 100644
--- a/android/system-emulator.c
+++ b/android/system-emulator.c
@@ -37,6 +37,8 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "monitor/mainloop.h"
@@ -169,5 +171,7 @@ int main(int argc, char *argv[])
mainloop_add_fd(fd, EPOLLIN, system_socket_callback, NULL, NULL);
+ umask(0177);
+
return mainloop_run();
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH v2 4/5] android/bluetooth: Add support for restoring devices from storage
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>
This adds support to restore bonded devices from storage (including
linkkeys).
---
android/bluetooth.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 112 insertions(+), 1 deletion(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 8f2a94c..c84bab6 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1573,6 +1573,117 @@ static void clear_uuids(void)
sizeof(cp), &cp, NULL, NULL, NULL);
}
+static void create_device_from_info(GKeyFile *key_file, const char *peer)
+{
+ struct device *dev;
+ uint8_t type;
+ bdaddr_t bdaddr;
+ char **uuids;
+ char *str;
+
+ DBG("%s", peer);
+
+ type = g_key_file_get_integer(key_file, peer, "Type", NULL);
+
+ str2ba(peer, &bdaddr);
+ dev = create_device(&bdaddr, type);
+
+ dev->bond_state = HAL_BOND_STATE_BONDED;
+
+ str = g_key_file_get_string(key_file, peer, "Name", NULL);
+ if (str) {
+ g_free(dev->name);
+ dev->name = str;
+ }
+
+ str = g_key_file_get_string(key_file, peer, "FriendlyName", NULL);
+ if (str) {
+ g_free(dev->friendly_name);
+ dev->friendly_name = str;
+ }
+
+ dev->class = g_key_file_get_integer(key_file, peer, "Class", NULL);
+
+ uuids = g_key_file_get_string_list(key_file, peer, "Services", NULL,
+ NULL);
+ if (uuids) {
+ char **uuid;
+
+ for (uuid = uuids; *uuid; uuid++) {
+ uint8_t *u = g_malloc0(16);
+ int i;
+
+ for (i = 0; i < 16; i++)
+ sscanf((*uuid) + (i * 2), "%02hhX", &u[i]);
+
+ dev->uuids = g_slist_append(dev->uuids, u);
+ }
+
+ g_strfreev(uuids);
+ }
+}
+
+static struct mgmt_link_key_info *get_key_info(GKeyFile *key_file, const char *peer)
+{
+ struct mgmt_link_key_info *info = NULL;
+ char *str;
+ unsigned int i;
+
+ str = g_key_file_get_string(key_file, peer, "LinkKey", NULL);
+ if (!str || strlen(str) != 32)
+ goto failed;
+
+ info = g_new0(struct mgmt_link_key_info, 1);
+
+ str2ba(peer, &info->addr.bdaddr);
+
+ info->addr.type = g_key_file_get_integer(key_file, peer, "Type", NULL);
+
+ for (i = 0; i < sizeof(info->val); i++)
+ sscanf(str + (i * 2), "%02hhX", &info->val[i]);
+
+ info->type = g_key_file_get_integer(key_file, peer, "LinkKeyType",
+ NULL);
+ info->pin_len = g_key_file_get_integer(key_file, peer,
+ "LinkKeyPINLength", NULL);
+
+failed:
+ g_free(str);
+
+ return info;
+}
+
+static void load_devices_info(bt_bluetooth_ready cb)
+{
+ GKeyFile *key_file;
+ gchar **devs;
+ gsize len = 0;
+ unsigned int i;
+ GSList *keys = NULL;
+
+ key_file = g_key_file_new();
+
+ g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
+ NULL);
+
+ devs = g_key_file_get_groups(key_file, &len);
+
+ for (i = 0; i < len; i++) {
+ struct mgmt_link_key_info *key_info;
+
+ create_device_from_info(key_file, devs[i]);
+
+ key_info = get_key_info(key_file, devs[i]);
+ if (key_info)
+ keys = g_slist_prepend(keys, key_info);
+
+ /* TODO ltk */
+ }
+
+ load_link_keys(keys, cb);
+ g_slist_free_full(keys, g_free);
+}
+
static void read_info_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -1627,7 +1738,7 @@ static void read_info_complete(uint8_t status, uint16_t length,
clear_uuids();
- load_link_keys(NULL, cb);
+ load_devices_info(cb);
set_io_capability();
set_device_id();
--
1.8.3.2
^ permalink raw reply related
* [PATCH v2 3/5] android/bluetooth: Add support for storing link keys
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>
When new linkkey event is received store linkkey in devices info file.
Stored info includes linkkey, linkkey type and pin length.
---
android/bluetooth.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index ede844e..8f2a94c 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -490,7 +490,35 @@ static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
uint8_t type, uint8_t pin_length)
{
- /* TODO store link key */
+ GKeyFile *key_file;
+ char key_str[33];
+ gsize length = 0;
+ char addr[18];
+ char *data;
+ int i;
+
+ key_file = g_key_file_new();
+
+ if (!g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices",
+ 0, NULL))
+ return;
+
+ ba2str(dst, addr);
+
+ DBG("%s type %u pin_len %u", addr, type, pin_length);
+
+ for (i = 0; i < 16; i++)
+ sprintf(key_str + (i * 2), "%2.2X", key[i]);
+
+ g_key_file_set_string(key_file, addr, "LinkKey", key_str);
+ g_key_file_set_integer(key_file, addr, "LinkKeyType", type);
+ g_key_file_set_integer(key_file, addr, "LinkKeyPINLength", pin_length);
+
+ data = g_key_file_to_data(key_file, &length, NULL);
+ g_file_set_contents(ANDROID_STORAGEDIR"/devices", data, length, NULL);
+ g_free(data);
+
+ g_key_file_free(key_file);
}
static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
@@ -717,6 +745,9 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
return;
}
+ set_device_bond_state(&addr->bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDED);
+
if (ev->store_hint) {
const struct mgmt_link_key_info *key = &ev->key;
@@ -724,9 +755,6 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
key->pin_len);
}
- set_device_bond_state(&addr->bdaddr, HAL_STATUS_SUCCESS,
- HAL_BOND_STATE_BONDED);
-
browse_remote_sdp(&addr->bdaddr);
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH v2 2/5] android/bluetooth: Add initial support for storing device info
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>
This allows to store information about remote device. For now this is
stored only for bonded devices. Currently stored data includes devices
ddress, type, name, friendly name, class and uuids.
---
android/bluetooth.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 75 insertions(+), 1 deletion(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index ae136e4..ede844e 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -186,6 +186,76 @@ static void load_adapter_config(void)
g_key_file_free(key_file);
}
+static void store_device_info(struct device *dev)
+{
+ GKeyFile *key_file;
+ char addr[18];
+ gsize length = 0;
+ char **uuids = NULL;
+ char *str;
+
+ if (dev->bond_state != HAL_BOND_STATE_BONDED &&
+ dev->bond_state != HAL_BOND_STATE_NONE)
+ return;
+
+ ba2str(&dev->bdaddr, addr);
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/devices", 0,
+ NULL);
+
+ if (dev->bond_state == HAL_BOND_STATE_NONE) {
+ g_key_file_remove_group(key_file, addr, NULL);
+ goto done;
+ }
+
+ g_key_file_set_integer(key_file, addr, "Type", dev->bdaddr_type);
+
+ g_key_file_set_string(key_file, addr, "Name", dev->name);
+
+ if (dev->friendly_name)
+ g_key_file_set_string(key_file, addr, "FriendlyName",
+ dev->friendly_name);
+ else
+ g_key_file_remove_key(key_file, addr, "FriendlyName", NULL);
+
+ if (dev->class)
+ g_key_file_set_integer(key_file, addr, "Class", dev->class);
+ else
+ g_key_file_remove_key(key_file, addr, "Class", NULL);
+
+ if (dev->uuids) {
+ GSList *l;
+ int i;
+
+ uuids = g_new0(char *, g_slist_length(dev->uuids) + 1);
+
+ for (i = 0, l = dev->uuids; l; l = g_slist_next(l), i++) {
+ int j;
+ uint8_t *u = l->data;
+ char *uuid_str = g_malloc0(33);
+
+ for (j = 0; j < 16; j++)
+ sprintf(uuid_str + (j * 2), "%2.2X", u[j]);
+
+ uuids[i] = uuid_str;
+ }
+
+ g_key_file_set_string_list(key_file, addr, "Services",
+ (const char **)uuids, i);
+ } else {
+ g_key_file_remove_key(key_file, addr, "Services", NULL);
+ }
+
+done:
+ str = g_key_file_to_data(key_file, &length, NULL);
+ g_file_set_contents(ANDROID_STORAGEDIR"/devices", str, length, NULL);
+ g_free(str);
+
+ g_key_file_free(key_file);
+ g_strfreev(uuids);
+}
+
static int bdaddr_cmp(gconstpointer a, gconstpointer b)
{
const bdaddr_t *bda = a;
@@ -448,6 +518,8 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
if (dev->bond_state != state) {
dev->bond_state = state;
send_bond_state_change(&dev->bdaddr, status, state);
+
+ store_device_info(dev);
}
}
@@ -488,6 +560,8 @@ static void set_device_uuids(struct device *dev, GSList *uuids)
g_slist_free_full(dev->uuids, g_free);
dev->uuids = uuids;
+ store_device_info(dev);
+
send_device_uuids_notif(dev);
}
@@ -2529,7 +2603,7 @@ static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
g_free(dev->friendly_name);
dev->friendly_name = g_strndup((const char *) val, len);
- /* TODO store friendly name */
+ store_device_info(dev);
send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
strlen(dev->friendly_name), dev->friendly_name);
--
1.8.3.2
^ permalink raw reply related
* [PATCH v2 1/5] android/bluetooth: Add initial support for permanent storage
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1387456713-12794-1-git-send-email-szymon.janc@tieto.com>
This patch adds initial support for storing adapter configuration.
Currently stored data is address, name and discoverable timeout.
Since Android daemon storage format is to be simpler than Linux check
if correct adapter is used before going operational. This is
a precaution to avoid e.g. using linkkeys generated for different
controller.
---
android/Android.mk | 3 +-
android/bluetooth.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++----
configure.ac | 3 ++
3 files changed, 85 insertions(+), 6 deletions(-)
diff --git a/android/Android.mk b/android/Android.mk
index ebc3219..2953a6e 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -8,7 +8,8 @@ pathmap_INCL += glib:external/bluetooth/glib
# Specify common compiler flags
BLUEZ_COMMON_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\" \
- -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+ -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) \
+ -DANDROID_STORAGEDIR=\"/data/misc/bluetooth\" \
# Disable warnings enabled by Android but not enabled in autotools build
BLUEZ_COMMON_CFLAGS += -Wno-pointer-arith -Wno-missing-field-initializers
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 97d4aae..ae136e4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -27,6 +27,10 @@
#include <errno.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <glib.h>
@@ -123,6 +127,65 @@ static GSList *devices = NULL;
/* This list contains addresses which are asked for records */
static GSList *browse_reqs;
+static void store_adapter_config(void)
+{
+ GKeyFile *key_file;
+ gsize length = 0;
+ char addr[18];
+ char *data;
+
+ key_file = g_key_file_new();
+
+ g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
+ NULL);
+
+ ba2str(&adapter.bdaddr, addr);
+
+ g_key_file_set_string(key_file, "General", "Address", addr);
+ g_key_file_set_string(key_file, "General", "Name", adapter.name);
+ g_key_file_set_integer(key_file, "General", "DiscoverableTimeout",
+ adapter.discoverable_timeout);
+
+ data = g_key_file_to_data(key_file, &length, NULL);
+
+ g_file_set_contents(ANDROID_STORAGEDIR"/settings", data, length, NULL);
+
+ g_free(data);
+ g_key_file_free(key_file);
+}
+
+static void load_adapter_config(void)
+{
+ GError *gerr = NULL;
+ GKeyFile *key_file;
+ char *str;
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, ANDROID_STORAGEDIR"/settings", 0,
+ NULL);
+
+ str = g_key_file_get_string(key_file, "General", "Address", NULL);
+ if (!str) {
+ g_key_file_free(key_file);
+ return;
+ }
+
+ str2ba(str, &adapter.bdaddr);
+ g_free(str);
+
+ adapter.name = g_key_file_get_string(key_file, "General", "Name", NULL);
+
+ adapter.discoverable_timeout = g_key_file_get_integer(key_file,
+ "General", "DiscoverableTimeout", &gerr);
+ if (gerr) {
+ adapter.discoverable_timeout = DEFAULT_DISCOVERABLE_TIMEOUT;
+ g_error_free(gerr);
+ gerr = NULL;
+ }
+
+ g_key_file_free(key_file);
+}
+
static int bdaddr_cmp(gconstpointer a, gconstpointer b)
{
const bdaddr_t *bda = a;
@@ -215,6 +278,8 @@ static void adapter_set_name(const uint8_t *name)
g_free(adapter.name);
adapter.name = g_strdup((const char *) name);
+ store_adapter_config();
+
adapter_name_changed(name);
}
@@ -1385,9 +1450,10 @@ static uint8_t set_adapter_discoverable_timeout(const void *buf, uint16_t len)
* There is no need to use kernel feature for that.
* Just need to store this value here */
- /* TODO: This should be in some storage */
memcpy(&adapter.discoverable_timeout, timeout, sizeof(uint32_t));
+ store_adapter_config();
+
send_adapter_property(HAL_PROP_ADAPTER_DISC_TIMEOUT,
sizeof(adapter.discoverable_timeout),
&adapter.discoverable_timeout);
@@ -1434,17 +1500,26 @@ static void read_info_complete(uint8_t status, uint16_t length,
goto failed;
}
+ load_adapter_config();
+
+ if (!bacmp(&adapter.bdaddr, BDADDR_ANY)) {
+ bacpy(&adapter.bdaddr, &rp->bdaddr);
+ adapter.name = g_strdup((const char *) rp->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;
+ }
+
/* Store adapter information */
- bacpy(&adapter.bdaddr, &rp->bdaddr);
adapter.dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
(rp->dev_class[2] << 16);
- adapter.name = g_strdup((const char *) rp->name);
supported_settings = btohs(rp->supported_settings);
adapter.current_settings = btohs(rp->current_settings);
- /* TODO: Read discoverable timeout from storage here */
-
/* TODO: Register all event notification handlers */
register_mgmt_handlers();
diff --git a/configure.ac b/configure.ac
index 18d0b55..5171c38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,4 +252,7 @@ AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
[enable_android=${enableval}])
AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
+AC_DEFINE_UNQUOTED(ANDROID_STORAGEDIR, "${storagedir}/android",
+ [Directory for the Android daemon storage files])
+
AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
--
1.8.3.2
^ permalink raw reply related
* [PATCH v2 0/5] android: Permanent storage support
From: Szymon Janc @ 2013-12-19 12:38 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
V2:
- removed file creation with open, it is up to init to set proper
umask while staring bluetoothd
- make system-emulator set proper umask
Szymon Janc (5):
android/bluetooth: Add initial support for permanent storage
android/bluetooth: Add initial support for storing device info
android/bluetooth: Add support for storing link keys
android/bluetooth: Add support for restoring devices from storage
android: Set umask in system-emulator
android/Android.mk | 3 +-
android/bluetooth.c | 310 ++++++++++++++++++++++++++++++++++++++++++++--
android/system-emulator.c | 4 +
configure.ac | 3 +
4 files changed, 308 insertions(+), 12 deletions(-)
--
1.8.3.2
^ permalink raw reply
* [PATCH] android/pts: Add PICS, PIXITs and PTS for L2CAP
From: Sebastian Chlad @ 2013-12-19 12:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <2115852EF878384FA984E6B76A9F379E164297@IRSMSX104.ger.corp.intel.com>
This allows better tracking of the current state of implementation
---
android/Makefile.am | 4 +-
android/pics-l2cap.txt | 157 ++++++++++++++++++++++++++++++++++++++++++++++++
android/pixit-l2cap.txt | 39 ++++++++++++
android/pts-l2cap.txt | 148 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 347 insertions(+), 1 deletion(-)
create mode 100644 android/pics-l2cap.txt
create mode 100644 android/pixit-l2cap.txt
create mode 100644 android/pts-l2cap.txt
diff --git a/android/Makefile.am b/android/Makefile.am
index 909846e..a5533de 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -123,4 +123,6 @@ EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
android/pixit-pbap.txt android/pts-gap.txt android/pts-hid.txt \
android/pts-opp.txt android/pts-pbap.txt \
android/audio-ipc-api.txt android/pics-map.txt \
- android/pixit-map.txt android/pts-map.txt
+ android/pixit-map.txt android/pts-map.txt \
+ android/pics-l2cap.txt android/pixit-l2cap.txt \
+ android/pts-l2cap.txt
diff --git a/android/pics-l2cap.txt b/android/pics-l2cap.txt
new file mode 100644
index 0000000..ef25133
--- /dev/null
+++ b/android/pics-l2cap.txt
@@ -0,0 +1,157 @@
+L2CAP PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+ Roles
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_1_1 True Data Channel Initiator (C.1)
+TSPC_L2CAP_1_2 True Data Channel Acceptor (C.1)
+TSPC_L2CAP_1_3 True (#) LE Master (C.2)
+TSPC_L2CAP_1_4 True (#) LE Slave (C.2)
+-------------------------------------------------------------------------------
+C.1: Mandatory IF BR/EDR or BR/EDR/LE is claimed, ELSE Excluded.
+C.2: Mandatory to support (at least one of TSPC_L2CAP_1_3 or TSPC_L2CAP_1_4)
+ IF LE or BR/EDR/LE claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+ General Operation
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_2_1 True Support of L2CAP signaling channel (C.20)
+TSPC_L2CAP_2_2 True Support of configuration process (C.20)
+TSPC_L2CAP_2_4 True Support of command echo request (C.21)
+TSPC_L2CAP_2_3 True Support of connection oriented data
+ channel (C.20)
+TSPC_L2CAP_2_5 True Support of command echo response (C.20)
+TSPC_L2CAP_2_6 True (*) Support of command information request (C.21)
+TSPC_L2CAP_2_7 True Support of command information response (C.20)
+TSPC_L2CAP_2_8 False Support of a channel group (C.21)
+TSPC_L2CAP_2_9 False Support of packet for connectionless
+ channel (C.21)
+TSPC_L2CAP_2_10 False Support retransmission mode (C.21)
+TSPC_L2CAP_2_11 False Support flow control mode(C.21)
+TSPC_L2CAP_2_12 True (*) Enhanced Retransmission Mode (C.1, C.13)
+TSPC_L2CAP_2_13 True (*) Streaming Mode (C.1, C.14)
+TSPC_L2CAP_2_14 True (*) FCS Option (C.2)
+TSPC_L2CAP_2_15 True (*) Generate Local Busy Condition (C.3)
+TSPC_L2CAP_2_16 True (*) Send Reject (C.3)
+TSPC_L2CAP_2_17 True (*) Send Selective Reject (C.3)
+TSPC_L2CAP_2_18 True (*) Mandatory use of ERTM (C.4)
+TSPC_L2CAP_2_19 True (*) Mandatory use of Streaming Mode (C.5)
+TSPC_L2CAP_2_20 True (*) Optional use of ERTM (C.4)
+TSPC_L2CAP_2_21 True (*) Optional use of Streaming Mode (C.5)
+TSPC_L2CAP_2_22 True (*) Send data using SAR in ERTM (C.6)
+TSPC_L2CAP_2_23 True (*) Send data using SAR in Streaming Mode (C.7)
+TSPC_L2CAP_2_24 True (*) Actively request Basic Mode for a PSM that
+ supports the use of ERTM or Streaming
+ Mode (C.8)
+TSPC_L2CAP_2_25 True (*) Supports performing L2CAP channel mode
+ configuration fallback from SM
+ to ERTM (C.9)
+TSPC_L2CAP_2_26 True (*) Supports sending more than one unacknowledged
+ I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_27 True (*) Supports sending more than three unacknowledged
+ I-Frame when operating in ERTM (C.10)
+TSPC_L2CAP_2_28 True (*) Supports configuring the peer TxWindow
+ greater than 1 (C.11)
+TSPC_L2CAP_2_29 False AMP Support (C.12)
+TSPC_L2CAP_2_30 True (*) Fixed Channel Support (C.12)
+TSPC_L2CAP_2_31 False AMP Manager Support (C.12)
+TSPC_L2CAP_2_32 False ERTM over AMP (C.12)
+TSPC_L2CAP_2_33 False Streaming Mode Source over AMP Support (C.15)
+TSPC_L2CAP_2_34 False Streaming Mode Sink over AMP Support (C.15)
+TSPC_L2CAP_2_35 False Unicast Connectionless Data, Reception (C.1, C.16)
+TSPC_L2CAP_2_36 False Ability to transmit an unencrypted packet over
+ a Unicast connectionless L2CAP
+ channel (C.16)
+TSPC_L2CAP_2_37 False Ability to transmit an encrypted packet over
+ a Unicast connectionless L2CAP
+ channel (C.16)
+TSPC_L2CAP_2_38 False Extended Flow Specification for BR/EDR (C.8)
+TSPC_L2CAP_2_39 False Extended Window Size (C.8)
+TSPC_L2CAP_2_40 True (*) Support of Low Energy signaling channel (C.17)
+TSPC_L2CAP_2_41 True (*) Support of command reject (C.17)
+TSPC_L2CAP_2_42 True (*) Send Connection Parameter Update Request (C.18)
+TSPC_L2CAP_2_43 True (*) Send Connection Parameter Update Response (C.19)
+TSPC_L2CAP_2_44 False Extended Flow Specification for AMP (C.22)
+TSPC_L2CAP_2_45 False Send disconnect request command (O)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support at least one of TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 OR
+ TSPC_L2CAP_2_35 IF BR/EDR BR/EDR/LE AND SUM_ICS 31/7 (CSA1) OR
+ SUM_ICS 31/8 (3.0) OR SUM_ICS 31/9 (3.0+HS) OR SUM_ICS 31/10 (4.0))
+ is supported, ELSE Excluded
+C.2: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.3: Optional IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_28 is claimed, ELSE Excluded.
+C.4: IF TSPC_L2CAP_2_12 is claimed THEN either TSPC_L2CAP_2_18
+ OR TSPC_L2CAP_2_20 are Mandatory, ELSE Excluded.
+C.5: IF TSPC_L2CAP_2_13 is claimed THEN either TSPC_L2CAP_2_19
+ OR TSPC_L2CAP_2_21 are Mandatory, ELSE Excluded.
+C.6: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.7: Optional IF TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.8: Optional IF TSPC_L2CAP_2_12 OR TSPC_L2CAP_2_13 is claimed, ELSE Excluded.
+C.9: Mandatory IF TSPC_L2CAP_2_12 AND TSPC_L2CAP_2_13 AND TSPC_L2CAP_2_21
+ is claimed, ELSE Excluded.
+C.10: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.11: Optional IF TSPC_L2CAP_2_12 is claimed, ELSE Excluded.
+C.12: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.13: Mandatory IF SUM_ICS 31/9 (3.0 + HS) is claimed, ELSE Optional.
+C.14: Optional IF SUM_ICS 31/8 OR 31/9 OR 31/10 OR 31/11 is claimed, ELSE Excluded.
+C.15: Optional IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+C.16: Optional IF (SUM_ICS 31/8 OR SUM_ICS 31/9 OR 31/10 OR 31/11) is claimed,
+ ELSE Excluded.
+C.17: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.18: Optional IF (SUM_ICS 31/10 AND 1/4) is claimed, ELSE Excluded.
+C.19: Mandatory IF (SUM_ICS 31/10 AND 1/3) is claimed, ELSE Excluded.
+C.20: Mandatory IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.21: Optional IF LE OR BR/EDR/LE, is claimed, ELSE Excluded
+C.22: Mandatory IF TSPC_L2CAP_2_29 is claimed, ELSE Excluded.
+-------------------------------------------------------------------------------
+
+
+ Configurable Parameters
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_L2CAP_3_1 True Support of RTX timer (M)
+TSPC_L2CAP_3_2 True Support of ERTX timer (C.4)
+TSPC_L2CAP_3_3 True Support minimum MTU size 48 octets (C.4)
+TSPC_L2CAP_3_4 True (*) Support MTU size larger than 48 octets (C.5)
+TSPC_L2CAP_3_5 True Support of flush timeout value for reliable
+ channel (C.4)
+TSPC_L2CAP_3_6 False Support of flush timeout value for unreliable
+ channel (C.5)
+TSPC_L2CAP_3_7 False Support of bi-directional quality of service
+ (QoS) option field (C.1)
+TSPC_L2CAP_3_8 False Negotiate QoS service type (C.5)
+TSPC_L2CAP_3_9 False Negotiate and support service type ‘No
+ traffic’ (C.2)
+TSPC_L2CAP_3_10 False Negotiate and support service type ‘Best
+ effort’ (C.3)
+TSPC_L2CAP_3_11 False Negotiate and support service type
+ ‘Guaranteed’ (C.2)
+TSPC_L2CAP_3_12 True (*) Support minimum MTU size 23 octets (C.6)
+TSPC_L2CAP_3_13 False Negotiate and support service type ‘No traffic’
+ for Extended Flow Specification (C.7)
+TSPC_L2CAP_3_14 False Negotiate and support service type ‘Best Effort'
+ for Extended Flow Specification (C.8)
+TSPC_L2CAP_3_15 False Negotiate and support service type ‘Guaranteed’
+ for Extended Flow Specification (C.9)
+-------------------------------------------------------------------------------
+C.1: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Optional.
+C.2: Optional if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.3: Mandatory if TSPC_L2CAP_3_8 is supported, ELSE Excluded.
+C.4: Mandatory IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.5: Optional IF BR/EDR OR BR/EDR/LE is claimed, ELSE Excluded.
+C.6: Mandatory IF LE OR BR/EDR/LE is claimed, ELSE Excluded.
+C.7: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.8: Mandatory if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+C.9: Optional if TSPC_L2CAP_2_44 OR TSPC_L2CAP_2_38 is supported, ELSE Excluded.
+-------------------------------------------------------------------------------
diff --git a/android/pixit-l2cap.txt b/android/pixit-l2cap.txt
new file mode 100644
index 0000000..7de6638
--- /dev/null
+++ b/android/pixit-l2cap.txt
@@ -0,0 +1,39 @@
+L2CAP PIXIT for the PTS tool.
+
+* - different than PTS defaults
+& - should be set to IUT Bluetooth address
+
+ Required PIXIT settings
+-------------------------------------------------------------------------------
+Parameter Name Value
+-------------------------------------------------------------------------------
+TSPX_bd_addr_iut 112233445566 (*&)
+TSPX_client_class_of_device 100104
+TSPX_server_class_of_device 100104
+TSPX_security_enabled FALSE
+TSPX_delete_link_key FALSE
+TSPX_pin_code 0000
+TSPX_flushto FFFF
+TSPX_inmtu 02A0
+TSPX_no_fail_verditcs FALSE
+TSPX_oumtu 02A0
+TSPX_iut_role_initiator FALSE
+TSPX_psm 1011 (*)
+TSPX_time_guard 180000
+TSPX_timer_ertx 120000
+TSPX_timer_ertx_max 300000
+TSPX_timer_ertx_min 60000
+TSPX_timer_rtx 10000
+TSPX_timer_rtx_max 60000
+TSPX_timer_rtx_min 1000
+TSPX_rfc_mode_tx_window_size 08
+TSPX_rfc_mode_max_transmit 03
+TSPX_rfc_mode_retransmission_timeout 07D0
+TSPX_rfc_mode_monitor_timeout 2EE0
+TSPX_rfc_mode_maximum_pdu_size 02A0
+TSPX_extended_window_size 0012
+TSPX_use_implicit_send TRUE
+TSPX_use_dynamic_pin FALSE
+TSPX_iut_SDU_size_in_bytes 144
+TSPX_secure_simple_pairing_pass_key_confirmation FALSE
+-------------------------------------------------------------------------------
diff --git a/android/pts-l2cap.txt b/android/pts-l2cap.txt
new file mode 100644
index 0000000..d293046
--- /dev/null
+++ b/android/pts-l2cap.txt
@@ -0,0 +1,148 @@
+PTS test results for L2CAP
+
+PTS version: 5.0
+Tested: 18.12.2013
+
+Results:
+PASS test passed
+FAIL test failed
+INC test is inconclusive
+N/A test is disabled due to PICS setup
+
+-------------------------------------------------------------------------------
+Test Name Result Notes
+-------------------------------------------------------------------------------
+TC_COS_CED_BV_01_C PASS
+TC_COS_CED_BV_03_C PASS
+TC_COS_CED_BV_04_C N/A
+TC_COS_CED_BV_05_C PASS
+TC_COS_CED_BV_07_C PASS
+TC_COS_CED_BV_08_C PASS
+TC_COS_CED_BV_09_C INC
+TC_COS_CED_BV_10_C N/A
+TC_COS_CED_BV_11_C PASS
+TC_COS_CED_BI_01_C PASS
+TC_COS_CFD_BV_01_C PASS
+TC_COS_CFD_BV_02_C PASS
+TC_COS_CFD_BV_03_C PASS
+TC_COS_CFD_BV_08_C INC
+TC_COS_CFD_BV_09_C INC
+TC_COS_CFD_BV_10_C N/A
+TC_COS_CFD_BI_11_C PASS
+TC_COS_CFD_BV_12_C PASS
+TC_COS_CFD_BV_13_C N/A
+TC_COS_IEX_BV_01_C PASS
+TC_COS_IEX_BV_02_C PASS
+TC_COS_ECH_BV_01_C PASS
+TC_COS_ECH_BV_02_C INC
+TC_CLS_CLR_BV_01_C N/A
+TC_CLS_UCD_BV_01_C N/A
+TC_CLS_UCD_BV_02_C N/A
+TC_CLS_UCD_BV_03_C N/A
+TC_EXF_BV_01_C PASS
+TC_EXF_BV_02_C PASS
+TC_EXF_BV_03_C PASS
+TC_EXF_BV_04_C N/A
+TC_EXF_BV_05_C PASS
+TC_EXF_BV_06_C N/A
+TC_CMC_BV_01_C INC
+TC_CMC_BV_02_C INC
+TC_CMC_BV_03_C INC
+TC_CMC_BV_04_C INC
+TC_CMC_BV_05_C INC
+TC_CMC_BV_06_C INC
+TC_CMC_BV_07_C INC
+TC_CMC_BV_08_C INC
+TC_CMC_BV_09_C INC
+TC_CMC_BV_10_C INC
+TC_CMC_BV_11_C INC
+TC_CMC_BV_12_C INC
+TC_CMC_BV_13_C INC
+TC_CMC_BV_14_C INC
+TC_CMC_BV_15_C INC
+TC_CMC_BI_01_C INC
+TC_CMC_BI_02_C INC
+TC_CMC_BI_03_C INC
+TC_CMC_BI_04_C INC
+TC_CMC_BI_05_C INC
+TC_CMC_BI_06_C INC
+TC_FOC_BV_01_C INC
+TC_FOC_BV_02_C INC
+TC_FOC_BV_03_C INC
+TC_FOC_BV_04_C INC
+TC_OFS_BV_01_C INC
+TC_OFS_BV_02_C INC
+TC_OFS_BV_03_C INC
+TC_OFS_BV_04_C INC
+TC_OFS_BV_05_C INC
+TC_OFS_BV_06_C INC
+TC_OFS_BV_07_C INC
+TC_OFS_BV_08_C INC
+TC_ERM_BV_01_C INC
+TC_ERM_BV_02_C INC
+TC_ERM_BV_03_C INC
+TC_ERM_BV_04_C INC
+TC_ERM_BV_05_C INC
+TC_ERM_BV_06_C INC
+TC_ERM_BV_07_C INC
+TC_ERM_BV_08_C INC
+TC_ERM_BV_09_C INC
+TC_ERM_BV_10_C INC
+TC_ERM_BV_11_C INC
+TC_ERM_BV_12_C INC
+TC_ERM_BV_13_C INC
+TC_ERM_BV_14_C INC
+TC_ERM_BV_15_C INC
+TC_ERM_BV_16_C INC
+TC_ERM_BV_17_C INC
+TC_ERM_BV_18_C INC
+TC_ERM_BV_19_C INC
+TC_ERM_BV_20_C INC
+TC_ERM_BV_21_C INC
+TC_ERM_BV_22_C INC
+TC_ERM_BV_23_C INC
+TC_ERM_BI_01_C INC
+TC_ERM_BI_02_C INC
+TC_ERM_BI_03_C INC
+TC_ERM_BI_04_C INC
+TC_ERM_BI_05_C INC
+TC_STM_BV_01_C INC
+TC_STM_BV_02_C INC
+TC_STM_BV_03_C INC
+TC_STM_BV_11_C N/A
+TC_STM_BV_12_C N/A
+TC_STM_BV_13_C N/A
+TC_FIX_BV_01_C PASS
+TC_FIX_BV_02_C PASS
+TC_EWC_BV_01_C N/A
+TC_EWC_BV_02_C N/A
+TC_EWC_BV_03_C N/A
+TC_LSC_BV_01_C N/A
+TC_LSC_BV_02_C N/A
+TC_LSC_BV_03_C N/A
+TC_LSC_BI_04_C N/A
+TC_LSC_BI_05_C N/A
+TC_LSC_BV_06_C N/A
+TC_LSC_BV_07_C N/A
+TC_LSC_BV_08_C N/A
+TC_LSC_BV_09_C N/A
+TC_LSC_BI_10_C N/A
+TC_LSC_BI_11_C N/A
+TC_LSC_BV_12_C N/A
+TC_CCH_BV_01_C N/A
+TC_CCH_BV_02_C N/A
+TC_CCH_BV_03_C N/A
+TC_CCH_BV_04_C N/A
+TC_ECF_BV_01_C N/A
+TC_ECF_BV_02_C N/A
+TC_ECF_BV_03_C N/A
+TC_ECF_BV_04_C N/A
+TC_ECF_BV_05_C N/A
+TC_ECF_BV_06_C N/A
+TC_ECF_BV_07_C N/A
+TC_ECF_BV_08_C N/A
+TC_LE_CPU_BV_01_C N/A
+TC_LE_CPU_BV_02_C N/A
+TC_LE_CPU_BI_01_C N/A
+TC_LE_CPU_BI_02_C N/A
+TC_LE_REJ_BV_01_C N/A
--
1.8.1.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