From patchwork Tue Jun 1 20:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 12292209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E40C8C47092 for ; Tue, 1 Jun 2021 20:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5536613D6 for ; Tue, 1 Jun 2021 20:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234761AbhFAUVJ (ORCPT ); Tue, 1 Jun 2021 16:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234714AbhFAUVI (ORCPT ); Tue, 1 Jun 2021 16:21:08 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21F8AC061574 for ; Tue, 1 Jun 2021 13:19:26 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id e15so7516217plh.1 for ; Tue, 01 Jun 2021 13:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CdJNU0zP86fQfsZY8fo8y9YbQomtTm+qfzfDCYZeLvc=; b=DvpHPtiww7tPe0cxbRBJud6vxdvEiIEJPm3+O44VVGXzAIVsLo2gxCVsiK4hNDkEW4 CAcgr8v8Tydeln8YK9+iL0KG2pGcLU0k+KW8cmk8O9zQMDUbtgl5rWc6wKdcVHm7MM9o gKTTUBopJh8vCeyK8RvxSXgNz1FefbtQiylzZ+QGdQwlNafIqitFvONbk7DEacS4vNK0 faeHIWI7iu5EqvYZ3eGHyKNduJJVWy0VhfZd/rmKRu6zOZSvTi6elcmoS8AMBroiqAxo pc0NTTO/FFjRQhoVT0zS+zQS7HkbqcssZ/tjbFQP+/YiiAyFeBS8oP8pJS9AVzAj/wzd qyYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CdJNU0zP86fQfsZY8fo8y9YbQomtTm+qfzfDCYZeLvc=; b=iJSsKQZD9KT13yl4lEtjxTdbvn6yIC0V49OuNlkui8aEl2wYYzHVU6WZgxrbpgXZqH 0/vF0LaDUMLiX9R+Oq5KFvdC6ArIvl4MFZqGWdHIVIxPFKtkdDJJlnPHio7/SYy06IVw vY3Xa9fh4HdqdX5tihLSviSgaQWxstXYxL67v2UBjCXaUpZ0vZcRsqvYtviAocUl8hQT 1YmhTUOCE2DShh4M4fczhymgQkrUEzgRIEORzMpd3yz9J2ksHhnFY2Whv6vpV/8OdZmP SSBJ8G7MD/hMh8nLXZcbHpT7G4qS7CQJCgHq7kBulQCVRJua9c1gkbDNeHTRNajd6o4x bmtw== X-Gm-Message-State: AOAM533IUSB2XrzT67/4uQwJFBtEXF2rh+4Ikueg3YRYmzXpiE22KoTv +KV3VmVkmwakaWO3jxn/WoqTIPpD5r0= X-Google-Smtp-Source: ABdhPJxK0Sqajq8yyptqQT6kaQpY/SgCBzK+o8DVdZW018+c3w7tYNGNte5LTGSEFxreeauhnIDrMQ== X-Received: by 2002:a17:90b:3e89:: with SMTP id rj9mr14955311pjb.114.1622578765415; Tue, 01 Jun 2021 13:19:25 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::512a]) by smtp.gmail.com with ESMTPSA id y129sm13399262pfy.123.2021.06.01.13.19.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:19:23 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 1/3] emulator/btdev: Enable LE Privacy feature Date: Tue, 1 Jun 2021 13:19:21 -0700 Message-Id: <20210601201923.899950-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch enables LE Privacy to support LL Privacy feature. --- emulator/btdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/emulator/btdev.c b/emulator/btdev.c index 692fabd71..13abad577 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -5415,6 +5415,7 @@ static void set_bredrle_features(struct btdev *btdev) btdev->features[4] |= 0x80; /* 3 slot EDR ACL packets */ btdev->features[5] |= 0x01; /* 5 slot EDR ACL packets */ + btdev->le_features[0] |= 0x40; /* LE PRIVACY */ btdev->le_features[1] |= 0x01; /* LE 2M PHY */ btdev->le_features[1] |= 0x08; /* LE Coded PHY */ btdev->le_features[1] |= 0x10; /* LE EXT ADV */ From patchwork Tue Jun 1 20:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 12292207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66401C47080 for ; Tue, 1 Jun 2021 20:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DBBA613D6 for ; Tue, 1 Jun 2021 20:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234758AbhFAUVJ (ORCPT ); Tue, 1 Jun 2021 16:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234513AbhFAUVI (ORCPT ); Tue, 1 Jun 2021 16:21:08 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6BE8C06174A for ; Tue, 1 Jun 2021 13:19:26 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id v12so7489995plo.10 for ; Tue, 01 Jun 2021 13:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9YUjnJ2PTkELptkYWCmxO47K33gXfXzwP4BqGN3mI4Y=; b=BTpgZwgHBK2v2a2Q4+Pl9EaJ1n9R1MfxOINRamz4GUW4lgmsVHAfEJGcgXZLloL55Y utUaxLzhZqPeFR9V2ic+8NPMrTMgcmfDV04e2QntMAfibNLsCU5Hrp1wIy9gdNACFeQb dtsuuF1q56sx0xQQDPqc40yb19p8pq++iWAu19x95lLvtigR3GBlWh3jPGz6SrSc32Ql G9JaXkglnmDgyTlLwrYEM5RjGAmj2te4YeEDxadv+87Ylp2uG3/3V6Zqz8cqlFJWEzK8 n6l/jHIllIZf6aDQGHSsQRce1D6zH5/eCKF0ctNiVHDjGt3ddXOYyk4JHwxBxKg8SQ1j +Cbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9YUjnJ2PTkELptkYWCmxO47K33gXfXzwP4BqGN3mI4Y=; b=EMW9Xow4y/ddhO4+k65ZRQpCQ1hv2r+gp+cvJrHaiCwx/Pd3/DJWPyGh5K0QX7vmap wx5RIVPd/xmHxLf7ZSv2VUOCKMpEXEbO7yUIzbpDKFLIs8U6L1Sy/RW9r8N20zo5Uspt dV5CK89gjxf2tdaPashCND+6lJqClVEYqiQIm8ih6Ebk9ibZ1D5gqHN0Lc3nZrStvSBq WkH8FWwHS6/K2oDeRRFtrJoy0SDfyAKZTqwBfL1P1LvD1F2QK4ohT1ft55gnrxOqvdi4 rG9YgqdYvOfYYN8uTqBVS/UJG7Ir03Orr4fs5iEyoA6A9Xz7wg7rHWIubHk12HrPfDpP QDQg== X-Gm-Message-State: AOAM533UjMdhql9n6Ztw8BkcaEZTZiVgXuw84Ekpn6BegHoRDQM6OW55 YehYV4f5SKHoPVM7wD3icxPP3+0N+ZM= X-Google-Smtp-Source: ABdhPJysTjx9s6WRW7OIBogKZl8n8CEQ+tLNeaNtM6En6/DBpnRfysx2MbBY8o+KzfuW90XDoHjOBQ== X-Received: by 2002:a17:902:bd0b:b029:ef:8970:281c with SMTP id p11-20020a170902bd0bb02900ef8970281cmr27301602pls.35.1622578766137; Tue, 01 Jun 2021 13:19:26 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::512a]) by smtp.gmail.com with ESMTPSA id y129sm13399262pfy.123.2021.06.01.13.19.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:19:25 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 2/3] tools/mgmt-tester: Add tests for experimental feature command Date: Tue, 1 Jun 2021 13:19:22 -0700 Message-Id: <20210601201923.899950-2-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210601201923.899950-1-hj.tedd.an@gmail.com> References: <20210601201923.899950-1-hj.tedd.an@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds test cases for Read/Set Experimenal Feature commands. --- tools/mgmt-tester.c | 139 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 138 insertions(+), 1 deletion(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 4550d6e9c..0d7c6b9e1 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -6837,7 +6837,7 @@ static void command_generic_callback(uint8_t status, uint16_t length, expect_param = test->expect_func(&expect_len); if (length != expect_len) { - tester_warn("Invalid cmd response parameter size"); + tester_warn("Invalid cmd response parameter size: %d", length); tester_test_failed(); return; } @@ -9124,6 +9124,100 @@ static const struct generic_data set_dev_flags_fail_3 = { .expect_len = sizeof(set_dev_flags_rsp_param_fail_3), }; +static const uint8_t read_exp_feat_param_success[] = { + 0x02, 0x00, /* Feature Count */ + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, /* UUID - Simultaneous */ + 0x27, 0x92, 0x96, 0x46, 0xc0, 0x42, /* Central Peripheral */ + 0xb5, 0x10, 0x1b, 0x67, + 0x00, 0x00, 0x00, 0x00, /* Flags */ + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, /* UUID - LL Privacy */ + 0xde, 0xb3, 0xea, 0x11, 0x73, 0xc2, + 0x48, 0xa1, 0xc0, 0x15, + 0x02, 0x00, 0x00, 0x00, /* Flags */ +}; + +static const struct generic_data read_exp_feat_success = { + .send_opcode = MGMT_OP_READ_EXP_FEATURES_INFO, + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = read_exp_feat_param_success, + .expect_len = sizeof(read_exp_feat_param_success), +}; + +static uint16_t settings_powered_le_privacy[] = { MGMT_OP_SET_LE, + MGMT_OP_SET_PRIVACY, + MGMT_OP_SET_POWERED, 0 }; + +static const uint8_t set_exp_feat_param_ll_privacy[] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, /* UUID - LL Privacy */ + 0xde, 0xb3, 0xea, 0x11, 0x73, 0xc2, + 0x48, 0xa1, 0xc0, 0x15, + 0x01, /* Action - enable */ +}; + +static const uint8_t set_exp_feat_rsp_param_ll_privacy[] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, /* UUID - LL Privacy */ + 0xde, 0xb3, 0xea, 0x11, 0x73, 0xc2, + 0x48, 0xa1, 0xc0, 0x15, + 0x03, 0x00, 0x00, 0x00, /* Action - enable */ +}; + +static const struct generic_data set_exp_feat_enable_ll_privacy = { + .send_opcode = MGMT_OP_SET_EXP_FEATURE, + .send_param = set_exp_feat_param_ll_privacy, + .send_len = sizeof(set_exp_feat_param_ll_privacy), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = set_exp_feat_rsp_param_ll_privacy, + .expect_len = sizeof(set_exp_feat_rsp_param_ll_privacy), +}; + +static const uint8_t set_exp_feat_param_disable[17] = { 0x00 }; +static const uint8_t set_exp_feat_rsp_param_disable[20] = { 0x00 }; + +static const struct generic_data set_exp_feat_disable = { + .send_opcode = MGMT_OP_SET_EXP_FEATURE, + .send_param = set_exp_feat_param_disable, + .send_len = sizeof(set_exp_feat_param_disable), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = set_exp_feat_rsp_param_disable, + .expect_len = sizeof(set_exp_feat_rsp_param_disable), +}; + +static const struct generic_data set_exp_feat_rejected = { + .setup_settings = settings_powered_le_privacy, + .send_opcode = MGMT_OP_SET_EXP_FEATURE, + .send_param = set_exp_feat_param_ll_privacy, + .send_len = sizeof(set_exp_feat_param_ll_privacy), + .expect_status = MGMT_STATUS_REJECTED, +}; + +static const uint8_t set_exp_feat_param_invalid[] = { + 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, /* UUID - LL Privacy */ + 0xde, 0xb3, 0xea, 0x11, 0x73, 0xc2, + 0x48, 0xa1, 0xc0, 0x15, + 0xff, /* Action - invalid */ +}; + +static const struct generic_data set_exp_feat_invalid = { + .send_opcode = MGMT_OP_SET_EXP_FEATURE, + .send_param = set_exp_feat_param_invalid, + .send_len = sizeof(set_exp_feat_param_invalid), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static const uint8_t set_exp_feat_param_unknown[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* UUID - Unknown */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0x01, /* Action - enable */ +}; + +static const struct generic_data set_exp_feat_unknown = { + .send_opcode = MGMT_OP_SET_EXP_FEATURE, + .send_param = set_exp_feat_param_unknown, + .send_len = sizeof(set_exp_feat_param_unknown), + .expect_status = MGMT_STATUS_NOT_SUPPORTED, +}; + static bool power_off(uint16_t index) { int sk, err; @@ -11192,5 +11286,48 @@ int main(int argc, char *argv[]) setup_get_dev_flags, test_command_generic); + /* MGMT_OP_READ_EXP_FEATURE + * Read Experimental features - success + */ + test_bredrle50("Read Exp Feature - Success", + &read_exp_feat_success, + NULL, test_command_generic); + /* MGMT_OP_SET_EXP_FEATURE + * Enable LL Privacy + */ + test_bredrle50("Set Exp Feature - Enable LL Privacy", + &set_exp_feat_enable_ll_privacy, + NULL, test_command_generic); + + /* MGMT_OP_SET_EXP_FEATURE + * Disable all features by sending zero UUID + */ + test_bredrle50("Set Exp Feature - Disable all", + &set_exp_feat_disable, + NULL, test_command_generic); + + /* MGMT_OP_SET_EXP_FEATURE + * Rejected - If the power is on, the command should be rejected + */ + test_bredrle50("Set Exp Feature - Rejected", + &set_exp_feat_rejected, + NULL, test_command_generic); + + /* MGMT_OP_SET_EXP_FEATURE + * Invalid parameter + */ + test_bredrle50("Set Exp Feature - Invalid params", + &set_exp_feat_invalid, + NULL, test_command_generic); + + + /* MGMT_OP_SET_EXP_FEATURE + * Not Supported UUID + */ + test_bredrle50("Set Exp Feature - Unknown feature", + &set_exp_feat_unknown, + NULL, test_command_generic); + + return tester_run(); } From patchwork Tue Jun 1 20:19:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 12292211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91BA2C47093 for ; Tue, 1 Jun 2021 20:19:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BEC7613CD for ; Tue, 1 Jun 2021 20:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234714AbhFAUVK (ORCPT ); Tue, 1 Jun 2021 16:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234766AbhFAUVJ (ORCPT ); Tue, 1 Jun 2021 16:21:09 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23B0C061574 for ; Tue, 1 Jun 2021 13:19:27 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso407091pji.0 for ; Tue, 01 Jun 2021 13:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BReF2G93QxleV7/aOfYUt0qAzTxqJk2dNOVnjd/DnpA=; b=Ap0DSdGRAcYmJqA41AQ58AvDxH3dAv07SXxz2h4oJS5O04r+ec2t9IcyfsIR/n9W1o RmrT1LV5Nymm7QPnwGHJVe+vgQ+wV8/iJxa6+nRHIJSh3CjeOUxgRh2kRxP1S+0LJF5e ne9UY+qNkpVn1SNXbtuKMjr7HZAGic7xYRnkjZUSZE8B0WF5tqDxXR+ttPkN49PtMTcs dEcGJu87c/8cB9AktKSpSHGj5iIfmmxXD5jhFCArSmzlyw7poObQ0dGknDki9P4ZqTMb wGzQJGETLb6XE+sSpF7HdG9Wg5pks7Tp8xKoAvzV5LQOlXEvFPJgtG6jSeSAQRwjGf/E TKFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BReF2G93QxleV7/aOfYUt0qAzTxqJk2dNOVnjd/DnpA=; b=bICzDUqGaNZs+HRIOl3Z88f1+anwNRSdOU+fk/TTIiHF+oDDqxKrnHgX8a9wLm1W0w p/K1/70f92Swp6SkQNzy5Xz237+sNGT9zw9KCAWSoQgspqmsgGzslMU4J4h5dQ0Kmvyr Fk7fJ5EjLw8bYFXLL5bcbjKva2lbiL394MGaE1KfKS/kCCSBmp3/vwiK69R5zeETVtWs JDxi1Lnqvi/Txqe1nvJAFeGgwSReANxu5yp18KaEAf3BitE7qIdYTpldojY08LY9cSnH QV+4YsLT/9hkAhw0U1eWSz4CRx6qQC7FvNq2El5oMEeu/3GazWYxfmhnboPQkqWWeK6d ucoA== X-Gm-Message-State: AOAM533xe+jOj0ZMqwmiE3Td7YHvYTk/+jMxx17LcSpK6f9fjnuLHbAx Z4zdmWbZzjGx2whZNxZVUF+BvSxdcYY= X-Google-Smtp-Source: ABdhPJyj5oeYhRWPrTJ/+38vZocrxcF0nHA2ZfU+M8dW/YqWSj2z07ttDiGWi/Gxf4zpQ0Yr/k89LQ== X-Received: by 2002:a17:90a:aa96:: with SMTP id l22mr1607090pjq.173.1622578766954; Tue, 01 Jun 2021 13:19:26 -0700 (PDT) Received: from han1-mobl3.intel.com ([2601:1c0:6a01:d830::512a]) by smtp.gmail.com with ESMTPSA id y129sm13399262pfy.123.2021.06.01.13.19.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 13:19:26 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 3/3] tools/mgmt-tester: Add tests for whitelist and resolving list Date: Tue, 1 Jun 2021 13:19:23 -0700 Message-Id: <20210601201923.899950-3-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210601201923.899950-1-hj.tedd.an@gmail.com> References: <20210601201923.899950-1-hj.tedd.an@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds test cases for checking the whitelist and resolving list HCI commands when the LL Privacy feature is enabled. --- tools/mgmt-tester.c | 360 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 357 insertions(+), 3 deletions(-) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index 0d7c6b9e1..d250e9600 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -2066,6 +2066,21 @@ static const struct generic_data start_discovery_valid_param_power_off_1 = { .expect_len = sizeof(start_discovery_bredrle_param), }; +static const char set_resolv_off_param[] = { 0x00 }; +static const char set_resolv_on_param[] = { 0x01 }; + +static const struct generic_data start_discovery_ll_privacy_disable_resolv = { + .send_opcode = MGMT_OP_START_DISCOVERY, + .send_param = start_discovery_le_param, + .send_len = sizeof(start_discovery_le_param), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = start_discovery_le_param, + .expect_len = sizeof(start_discovery_le_param), + .expect_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE, + .expect_hci_param = set_resolv_off_param, + .expect_hci_len = sizeof(set_resolv_off_param), +}; + static const char stop_discovery_bredrle_param[] = { 0x07 }; static const char stop_discovery_bredrle_invalid_param[] = { 0x06 }; static const char stop_discovery_valid_hci[] = { 0x00, 0x00 }; @@ -4049,7 +4064,7 @@ static const struct generic_data add_device_success_1 = { static const uint8_t add_device_success_param_2[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0x01, - 0x00, + 0x02, }; static const uint8_t add_device_rsp_le[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, @@ -4117,6 +4132,65 @@ static const struct generic_data add_device_success_5 = { .expect_hci_len = sizeof(le_scan_enable), }; +static const uint8_t le_add_to_white_list_param[] = { + 0x00, /* Type */ + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ +}; +static const struct generic_data add_device_success_6 = { + .setup_settings = settings_powered_le, + .send_opcode = MGMT_OP_ADD_DEVICE, + .send_param = add_device_success_param_2, + .send_len = sizeof(add_device_success_param_2), + .expect_param = add_device_rsp_le, + .expect_len = sizeof(add_device_rsp_le), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_alt_ev = MGMT_EV_DEVICE_ADDED, + .expect_alt_ev_param = add_device_success_param_2, + .expect_alt_ev_len = sizeof(add_device_success_param_2), + .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_WHITE_LIST, + .expect_hci_param = le_add_to_white_list_param, + .expect_hci_len = sizeof(le_add_to_white_list_param), +}; + +static const uint8_t le_add_to_resolv_list_param[] = { + 0x00, /* Type */ + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, /* Address */ + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, /* Peer IRK */ + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* Local IRK */ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, +}; + +static const struct generic_data add_device_success_7 = { + .send_opcode = MGMT_OP_ADD_DEVICE, + .send_param = add_device_success_param_2, + .send_len = sizeof(add_device_success_param_2), + .expect_param = add_device_rsp_le, + .expect_len = sizeof(add_device_rsp_le), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_alt_ev = MGMT_EV_DEVICE_ADDED, + .expect_alt_ev_param = add_device_success_param_2, + .expect_alt_ev_len = sizeof(add_device_success_param_2), + .expect_hci_command = BT_HCI_CMD_LE_ADD_TO_RESOLV_LIST, + .expect_hci_param = le_add_to_resolv_list_param, + .expect_hci_len = sizeof(le_add_to_resolv_list_param), +}; + +static const struct generic_data add_device_success_8 = { + .send_opcode = MGMT_OP_ADD_DEVICE, + .send_param = add_device_success_param_2, + .send_len = sizeof(add_device_success_param_2), + .expect_param = add_device_rsp_le, + .expect_len = sizeof(add_device_rsp_le), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_alt_ev = MGMT_EV_DEVICE_ADDED, + .expect_alt_ev_param = add_device_success_param_2, + .expect_alt_ev_len = sizeof(add_device_success_param_2), + .expect_hci_command = BT_HCI_CMD_LE_SET_RESOLV_ENABLE, + .expect_hci_param = set_resolv_on_param, + .expect_hci_len = sizeof(set_resolv_on_param), +}; + static const uint8_t remove_device_nval_1[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xff, @@ -4225,6 +4299,47 @@ static const struct generic_data remove_device_success_5 = { .expect_alt_ev_len = sizeof(remove_device_param_2), }; +static const uint8_t remove_device_param_all[7] = { 0x00 }; + +static const struct generic_data remove_device_success_6 = { + .send_opcode = MGMT_OP_REMOVE_DEVICE, + .send_param = remove_device_param_all, + .send_len = sizeof(remove_device_param_all), + .expect_param = remove_device_param_all, + .expect_len = sizeof(remove_device_param_all), + .expect_status = MGMT_STATUS_SUCCESS, +}; + +static const struct generic_data remove_device_success_7 = { + .send_opcode = MGMT_OP_REMOVE_DEVICE, + .send_param = remove_device_param_2, + .send_len = sizeof(remove_device_param_2), + .expect_param = remove_device_param_2, + .expect_len = sizeof(remove_device_param_2), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_WHITE_LIST, + .expect_hci_param = le_add_to_white_list_param, + .expect_hci_len = sizeof(le_add_to_white_list_param), + .expect_alt_ev = MGMT_EV_DEVICE_REMOVED, + .expect_alt_ev_param = remove_device_param_2, + .expect_alt_ev_len = sizeof(remove_device_param_2), +}; + +static const struct generic_data remove_device_success_8 = { + .send_opcode = MGMT_OP_REMOVE_DEVICE, + .send_param = remove_device_param_2, + .send_len = sizeof(remove_device_param_2), + .expect_param = remove_device_param_2, + .expect_len = sizeof(remove_device_param_2), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_hci_command = BT_HCI_CMD_LE_REMOVE_FROM_RESOLV_LIST, + .expect_hci_param = le_add_to_white_list_param, + .expect_hci_len = sizeof(le_add_to_white_list_param), + .expect_alt_ev = MGMT_EV_DEVICE_REMOVED, + .expect_alt_ev_param = remove_device_param_2, + .expect_alt_ev_len = sizeof(remove_device_param_2), +}; + static const struct generic_data read_adv_features_invalid_param_test = { .send_opcode = MGMT_OP_READ_ADV_FEATURES, .send_param = dummy_data, @@ -6870,7 +6985,7 @@ static void command_setup_hci_callback(uint16_t opcode, const void *param, return; if (length != setup_expect_hci_len) { - tester_warn("Invalid parameter size for HCI command"); + tester_warn("Invalid parameter size for HCI command (%d)", length); tester_test_failed(); return; } @@ -6903,7 +7018,7 @@ static void command_hci_callback(uint16_t opcode, const void *param, expect_hci_param = test->expect_hci_func(&expect_hci_len); if (length != expect_hci_len) { - tester_warn("Invalid parameter size for HCI command"); + tester_warn("Invalid parameter size for HCI command (%d)", length); tester_test_failed(); return; } @@ -9218,6 +9333,201 @@ static const struct generic_data set_exp_feat_unknown = { .expect_status = MGMT_STATUS_NOT_SUPPORTED, }; +static const char load_irks_params[] = { 0x01, 0x00, + 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0x01, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }; + + +static void setup_load_irks_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + if (status != MGMT_STATUS_SUCCESS) { + tester_setup_failed(); + return; + } + + tester_print("Load IRK completed"); +} + +static void setup_exp_feat_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + if (status != MGMT_STATUS_SUCCESS) { + tester_setup_failed(); + return; + } + + tester_print("LL Privacy Exp feature is enabled"); +} + +static void setup_ll_privacy(const void *test_data) +{ + struct test_data *data = tester_get_data(); + unsigned char param[] = { 0x01 }; + const uint8_t *ext_feat_param; + size_t ext_feat_len; + const char *irk_param; + size_t irk_len; + unsigned char privacy_param[] = { 0x01, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; + + tester_print("Enabling LL Privacy feature"); + + ext_feat_param = set_exp_feat_param_ll_privacy; + ext_feat_len = sizeof(set_exp_feat_param_ll_privacy); + + irk_param = load_irks_params; + irk_len = sizeof(load_irks_params); + + mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index, + sizeof(param), ¶m, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index, + sizeof(privacy_param), privacy_param, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index, + irk_len, irk_param, + setup_load_irks_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE , data->mgmt_index, + ext_feat_len, ext_feat_param, + setup_exp_feat_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, + sizeof(param), param, + setup_powered_callback, NULL, NULL); + +} + +static void setup_add_device_callback(uint8_t status, uint16_t length, + const void *param, void *user_data) +{ + if (status != MGMT_STATUS_SUCCESS) { + tester_setup_failed(); + return; + } + + tester_print("New Device is Added"); +} + +static void setup_ll_privacy_device(const void *test_data) +{ + struct test_data *data = tester_get_data(); + unsigned char param[] = { 0x01 }; + const uint8_t *ext_feat_param; + size_t ext_feat_len; + const char *irk_param; + size_t irk_len; + const uint8_t *dev_param; + size_t dev_len; + unsigned char privacy_param[] = { 0x01, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; + + tester_print("Enabling LL Privacy feature"); + + ext_feat_param = set_exp_feat_param_ll_privacy; + ext_feat_len = sizeof(set_exp_feat_param_ll_privacy); + + irk_param = load_irks_params; + irk_len = sizeof(load_irks_params); + + dev_param = add_device_success_param_2; + dev_len = sizeof(add_device_success_param_2); + + mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index, + sizeof(param), ¶m, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index, + sizeof(privacy_param), privacy_param, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index, + irk_len, irk_param, + setup_load_irks_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE , data->mgmt_index, + ext_feat_len, ext_feat_param, + setup_exp_feat_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index, + dev_len, dev_param, + setup_add_device_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, + sizeof(param), param, + setup_powered_callback, NULL, NULL); +} + +static const uint8_t add_device_success_param_4[] = { + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, + 0x01, + 0x02, +}; + +/* Enable LL Privacy and Add 2 devices */ +static void setup_ll_privacy_device2(const void *test_data) +{ + struct test_data *data = tester_get_data(); + unsigned char param[] = { 0x01 }; + const uint8_t *ext_feat_param; + size_t ext_feat_len; + const char *irk_param; + size_t irk_len; + const uint8_t *dev_param, *dev2_param; + size_t dev_len, dev2_len; + unsigned char privacy_param[] = { 0x01, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; + + tester_print("Enabling LL Privacy feature"); + + ext_feat_param = set_exp_feat_param_ll_privacy; + ext_feat_len = sizeof(set_exp_feat_param_ll_privacy); + + irk_param = load_irks_params; + irk_len = sizeof(load_irks_params); + + dev_param = add_device_success_param_2; + dev_len = sizeof(add_device_success_param_2); + + dev2_param = add_device_success_param_4; + dev2_len = sizeof(add_device_success_param_4); + + mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index, + sizeof(param), ¶m, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_PRIVACY, data->mgmt_index, + sizeof(privacy_param), privacy_param, + NULL, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_LOAD_IRKS, data->mgmt_index, + irk_len, irk_param, + setup_load_irks_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_EXP_FEATURE , data->mgmt_index, + ext_feat_len, ext_feat_param, + setup_exp_feat_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index, + dev_len, dev_param, + setup_add_device_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_ADD_DEVICE, data->mgmt_index, + dev2_len, dev2_param, + setup_add_device_callback, NULL, NULL); + + mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index, + sizeof(param), param, + setup_powered_callback, NULL, NULL); +} + static bool power_off(uint16_t index) { int sk, err; @@ -10090,6 +10400,13 @@ int main(int argc, char *argv[]) test_bredrle("Start Discovery - Power Off 1", &start_discovery_valid_param_power_off_1, NULL, test_command_generic); + /* MGMT_OP_START_DISCOVERY + * Check if the resolving list is disabled before the scan parameter is + * changed. + */ + test_bredrle50("Start Discovery - Disable Resolve List", + &start_discovery_ll_privacy_disable_resolv, + setup_ll_privacy_device, test_command_generic); test_bredrle("Stop Discovery - Success 1", &stop_discovery_success_test_1, @@ -10489,6 +10806,26 @@ int main(int argc, char *argv[]) test_bredrle("Add Device - Success 5", &add_device_success_5, NULL, test_command_generic); + /* MGMT_OP_ADD_DEVICE + * Add device and check the device is added to the whitelist + */ + test_bredrle50("Add Device - Success 6 - Add to whitelist", + &add_device_success_6, + NULL, test_command_generic); + /* MGMT_OP_ADD_DEVICE + * Add device and check the device is added to the resolve list + * when the LL Privacy is enabled + */ + test_bredrle50("Add Device - Success 7 - Add to resolv list", + &add_device_success_7, + setup_ll_privacy, test_command_generic); + /* MGMT_OP_ADD_DEVICE + * Add device and check the Resolving List is enabled for the device + * when the LL Privacy is enabled + */ + test_bredrle50("Add Device - Success 8 - Enable resolv list", + &add_device_success_8, + setup_ll_privacy, test_command_generic); test_bredrle("Remove Device - Invalid Params 1", &remove_device_fail_1, @@ -10514,6 +10851,23 @@ int main(int argc, char *argv[]) test_le("Remove Device - Success 5", &remove_device_success_5, setup_add_device, test_remove_device); + test_le("Remove Device - Success 6 - All Devices", + &remove_device_success_6, + setup_add_device, test_remove_device); + /* MGMT_OP_REMOVE_DEVICE + * Remove the device and check the device is removed from the whilte + * list as well. + */ + test_bredrle50("Remove Device - Success 7 - Remove from whitelist", + &remove_device_success_7, + setup_ll_privacy_device2, test_command_generic); + /* MGMT_OP_REMOVE_DEVICE + * Remove the device and check the device is removed from the resolving + * list as well when the LL Privacy is enabled. + */ + test_bredrle50("Remove Device - Success 8 - Remove from resolv list", + &remove_device_success_8, + setup_ll_privacy_device2, test_command_generic); test_bredrle("Read Advertising Features - Invalid parameters", &read_adv_features_invalid_param_test,