Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1393263pxj; Fri, 21 May 2021 13:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9et8RgDtpKeOs2GSywTOPe1rWv2wQet+nfh6S0bM1vw52BQATHCOozi/4HPiij6s4PGPX X-Received: by 2002:a50:9558:: with SMTP id v24mr12887326eda.264.1621627694925; Fri, 21 May 2021 13:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621627694; cv=none; d=google.com; s=arc-20160816; b=TXwgl3klhq/dyICnTGMbed6anfhkekUeMfFRJj8c63PWU1lmHzj+JkHCMg0CcR0ake 4FMhkmeOAuc7RnNO1m/bpt1lLqV19PITMeU3mg6Q6zvQX14eXz6YKx9ky8hQS89x9NoN N6vN+ursZdOktdzFWjrf9WkytVh+Joy1DlnA+3qgiRZe29WBeKvXzbb/d+u3U+II5usE XMCVZpvITGScDOlIe1/9qwDSSqqeetlgTimFLRFMx0JIn3gGpzIvdGpduvxup+78TMnD m7NvtV9oI4FuL2aOFmuYse8gLBPWVAx/4Nvd0SU6Sii2GkN54xx9EtMKY1RSSi93MNeI D8zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=rGe4rS+ZCBBmZdyzIKwWth7aSA57alM2esDsZUbFARY=; b=wORdKr8WxKx6qZBFM8DGIMWuQvM1RPpDKMjJYEhrII+5U4pnxu++u+2by3r4Qrys1n Z1mNPliCJG1RH5gmCLtU9AbcO3oXF1bXBp2aQ8wk+F3oCiJIWGsGT75qQy8aj5KfqZYU 388i5XMF78lyAmE7kKTmU9+vuR2mwlYIcsDMTH+2IUGW7mG9+7VuV7/ui3muCwPNwKWY kwIQkJ69awwh8e4NPGAtiuwJDebooKWxsZNAWiKsY+srjOXLCUPsQFU0pc9Ss7L8fBRm Kdp+/F4HtmXhc6RwzJkkxSPZsVU6MbnDN1PqzcuecPXVNd6V9agQPies6iVHx2rRG3bO jpUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=njFcnQ00; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si7661202eje.366.2021.05.21.13.07.51; Fri, 21 May 2021 13:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=njFcnQ00; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232002AbhEUG0H (ORCPT + 99 others); Fri, 21 May 2021 02:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231566AbhEUG0G (ORCPT ); Fri, 21 May 2021 02:26:06 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432C2C061574 for ; Thu, 20 May 2021 23:24:43 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id u7so1852753plq.4 for ; Thu, 20 May 2021 23:24:43 -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=rGe4rS+ZCBBmZdyzIKwWth7aSA57alM2esDsZUbFARY=; b=njFcnQ00L7iinHMmDgaixGJwBx54FviEHv5Vk+FIpV7UveIUKlo6gawhhpcgneRr8L VMWCubYrLp2MCDugQAs6EeWFQp/FvS/iN0J1/VoDnWHQ2j2450PrgsEb7jSPXUXJoXju EIq+U5fh3QpL2anv6k2EphWTnl8trqvTKizQqyq4eogXuwUMYsCHgzbVL5gVq4zCYLeo MiEYmU0yxnCICqZn1r+sXHcNfIEbifytfPURJO76zs0q0fbH8mDcl+h79dwdpFSF3ZI9 JUDj+szBj0f6lDgDssH3pAQdP4xgEuvN9J105BIvodJkwy43cHazQ4/BefAZkx8m1pRG tSjQ== 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=rGe4rS+ZCBBmZdyzIKwWth7aSA57alM2esDsZUbFARY=; b=pk+O9SE57Lr6CSLrHx0nuJlxbwqdNfocNmxVASu8y47lFBX4f3nfyOm2JoJWqrK0gz PY4NONY4n46ttx4w2XiU+Q16kvbRoS36ElrLLUU2sTqKLfahO8xQJVwUte/MyzLXa74y t0nOeocUjFGigMAHrsxgCXWJRLOP+YiELEDGc3f2zzjCG/V6SyhtknUCyleLt3Zard9W /eyIizL+UlP1pNTS+TsWF1JMdX/HToahpiwoCbLZeY+lM1JYK9ZPsaH6YSTtN0czpYuq UublQ0HrsW8n4nkG/t9hFm4Mz2CJyIACFp/OzHVeIgdTuuSe0A6v7GtgxsEYF/chYaPZ g2ng== X-Gm-Message-State: AOAM531UefxI+P96f9ueZZubVmisKyeML9gyEEXPlHBPIn09NKMwsshk eP8AKXMCfR29Ty9GLMTEjvEJ6mqDwpA1Rg== X-Received: by 2002:a17:90a:520f:: with SMTP id v15mr9019390pjh.23.1621578282366; Thu, 20 May 2021 23:24:42 -0700 (PDT) Received: from han1-mobl3.hsd1.or.comcast.net ([2601:1c0:6a01:d830::e853]) by smtp.gmail.com with ESMTPSA id a23sm2965473pjo.21.2021.05.20.23.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 23:24:41 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH 1/2] tools/mgmt-tester: Add test cases for set device id command Date: Thu, 20 May 2021 23:24:40 -0700 Message-Id: <20210521062441.155117-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch adds test cases for the Set Device ID command. --- tools/mgmt-tester.c | 163 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index de35008ad..e3523dcd5 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -5506,6 +5506,119 @@ static const struct generic_data adv_data_invalid_params = { .expect_status = MGMT_STATUS_INVALID_PARAMS, }; +static const uint8_t set_dev_id_param_success_1[] = { + 0x01, /* Source - 0x0001 (Bluetooth SIG) */ + 0x00, + 0x02, /* Vendor */ + 0x00, + 0xcd, /* Product */ + 0xab, + 0x34, + 0x12, /* Version */ +}; + +static const char write_eir_set_dev_id_success_1[241] = { + 0x00, 0x02, 0x0a, 0x00, 0x09, 0x10, 0x01, 0x00, + 0x02, 0x00, 0xcd, 0xab, 0x34, 0x12 }; + +static const struct generic_data set_dev_id_success_1 = { + .setup_settings = settings_powered_ssp, + .send_opcode = MGMT_OP_SET_DEVICE_ID, + .send_param = set_dev_id_param_success_1, + .send_len = sizeof(set_dev_id_param_success_1), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE, + .expect_hci_param = write_eir_set_dev_id_success_1, + .expect_hci_len = sizeof(write_eir_set_dev_id_success_1), +}; + +static const uint8_t set_dev_id_param_success_2[] = { + 0x02, /* Source - 0x0001 (Bluetooth SIG) */ + 0x00, + 0x02, /* Vendor */ + 0x00, + 0xcd, /* Product */ + 0xab, + 0x34, + 0x12, /* Version */ +}; +static const char write_eir_set_dev_id_success_2[241] = { + 0x00, 0x02, 0x0a, 0x00, 0x09, 0x10, 0x02, 0x00, + 0x02, 0x00, 0xcd, 0xab, 0x34, 0x12 }; + +static const struct generic_data set_dev_id_success_2 = { + .setup_settings = settings_powered_ssp, + .send_opcode = MGMT_OP_SET_DEVICE_ID, + .send_param = set_dev_id_param_success_2, + .send_len = sizeof(set_dev_id_param_success_2), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE, + .expect_hci_param = write_eir_set_dev_id_success_2, + .expect_hci_len = sizeof(write_eir_set_dev_id_success_2), +}; + +static const uint8_t set_dev_id_param_disable[8] = { 0x00 }; + +static const struct generic_data set_dev_id_disable = { + .setup_settings = settings_powered_ssp, + .send_opcode = MGMT_OP_SET_DEVICE_ID, + .send_param = set_dev_id_param_disable, + .send_len = sizeof(set_dev_id_param_disable), + .expect_status = MGMT_STATUS_SUCCESS, +}; + +static const struct generic_data set_dev_id_power_off_on = { + .setup_settings = settings_ssp, + .setup_send_opcode = MGMT_OP_SET_DEVICE_ID, + .setup_send_param = set_dev_id_param_success_1, + .setup_send_len = sizeof(set_dev_id_param_success_1), + .send_opcode = MGMT_OP_SET_POWERED, + .send_param = set_powered_on_param, + .send_len = sizeof(set_powered_on_param), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = set_ssp_settings_param_2, + .expect_len = sizeof(set_ssp_settings_param_2), + .expect_settings_set = MGMT_SETTING_POWERED, + .expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE, + .expect_hci_param = write_eir_set_dev_id_success_1, + .expect_hci_len = sizeof(write_eir_set_dev_id_success_1), +}; + +static const struct generic_data set_dev_id_ssp_off_on = { + .setup_settings = settings_powered, + .setup_send_opcode = MGMT_OP_SET_DEVICE_ID, + .setup_send_param = set_dev_id_param_success_1, + .setup_send_len = sizeof(set_dev_id_param_success_1), + .send_opcode = MGMT_OP_SET_SSP, + .send_param = set_ssp_on_param, + .send_len = sizeof(set_ssp_on_param), + .expect_status = MGMT_STATUS_SUCCESS, + .expect_param = set_ssp_settings_param_2, + .expect_len = sizeof(set_ssp_settings_param_2), + .expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE, + .expect_hci_param = write_eir_set_dev_id_success_1, + .expect_hci_len = sizeof(write_eir_set_dev_id_success_1), +}; + +static const uint8_t set_dev_id_invalid_1[] = { + 0x03, /* Source */ + 0x00, + 0x02, /* Vendor */ + 0x00, + 0xcd, /* Product */ + 0xab, + 0x34, + 0x12, /* Version */ +}; + +static const struct generic_data set_dev_id_invalid_param = { + .setup_settings = settings_powered_ssp, + .send_opcode = MGMT_OP_SET_DEVICE_ID, + .send_param = set_dev_id_invalid_1, + .send_len = sizeof(set_dev_id_invalid_1), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + static void client_cmd_complete(uint16_t opcode, uint8_t status, const void *param, uint8_t len, void *user_data) @@ -10697,5 +10810,55 @@ int main(int argc, char *argv[]) setup_ext_adv_params, test_command_generic); + /* MGMT_OP_SET_DEVICE_ID + * Using Bluetooth SIG for source. + */ + test_bredrle50("Set Device ID - Success 1", + &set_dev_id_success_1, + NULL, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_ID + * Using SB Implementer's Forum for source. + */ + test_bredrle50("Set Device ID - Success 2", + &set_dev_id_success_2, + NULL, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_ID + * Disable DID with disable flag for source. + */ + test_bredrle50("Set Device ID - Disable", + &set_dev_id_disable, + NULL, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_ID + * Power off, set device id, and power on. + * Expect Write_Extended_Inquiry with device id when power on. + */ + test_bredrle50("Set Device ID - Power off and Power on", + &set_dev_id_power_off_on, + setup_command_generic, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_ID + * SSP off, set device id, and SSP on. + * Expect Write_Extended_Inquiry with device id when SSP on. + */ + test_bredrle50("Set Device ID - SSP off and Power on", + &set_dev_id_ssp_off_on, + setup_command_generic, + test_command_generic); + + /* MGMT_OP_SET_DEVICE_ID + * Invalid parameter + */ + test_bredrle50("Set Device ID - Invalid Parameter", + &set_dev_id_invalid_param, + NULL, + test_command_generic); + return tester_run(); } -- 2.26.3