Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2238012rdb; Fri, 8 Dec 2023 02:17:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrOMP1+Hc84NAPra8pb9/AKfufAQpyMxY1NtQBRsxxoyHyknEI9qvA+D6HeibLzWQ1/vWD X-Received: by 2002:a92:c04d:0:b0:35d:6227:4f03 with SMTP id o13-20020a92c04d000000b0035d62274f03mr4277280ilf.7.1702030656076; Fri, 08 Dec 2023 02:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702030656; cv=none; d=google.com; s=arc-20160816; b=icEGYuRIO1HpJInu2ipb1CI2JEMRRdJmkZ0ktD7+ESeml0AxSFy/0Gpfq5fBkFHoPq qqcVfgVVbHs+eXctQ0WnwzpI+OXD1VpxZQEupeKhTJU4/ak+DgfufKeCdK8lv1UZ3qMj YtOD5X3j85zxJheTW0bR+iZ2cV881y0yLO77sUE/5o2Smlr03z6kZvxnpPd02Uh5lCFo oEuIivs3a191TphFlcWRE/0QXQXBRLYicR0wC58Vu/NbnsUmJV2BAaf4vOenLEroR5IX EA37FD6lNsQUYDpy42oR7cdvnjhXC4QyAfDjcDCrLNShlAInRt59uhl8kI8pL+DRYEKp QIxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=V+/Qu6vvxN6pM2rDw0flckUztSWmg1eD3Ap0VP5Gods=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=xg22itK0NmWBZGoEIUWQ2sS40oNbbKmoa78sJJMsUfMF2hSsFWz5uGQl8ofYYlJOv+ GAvulLOjm1mFWSZ7HHqILj8WQ4UTwyArwgxRcIb9LyMmpRLt1Orx0B/lalu9aAW/YsHm L6fi642AtsaPkR57fP9UnXWeVwCXYBWAUnFxCKetE8BuTqEFxcp/R4S3sL9pHcddyGsl aLnyZI2/3fd7H1A5kobkfVsrVJtCuYbZy3+JdcEDcgV27hauy2h6cLmla9x7HuN3eAZD UEREPx5RiATcmGjKKdpc49Wzgmu8AnnQtHTbpsOAcjYGvHH7qgG0RAHFOq0c8G1MBT2V Dy3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JCcDbPiu; spf=pass (google.com: domain of linux-bluetooth+bounces-461-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 77-20020a630150000000b0057755b2f032si1334456pgb.542.2023.12.08.02.17.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 02:17:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-461-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=JCcDbPiu; spf=pass (google.com: domain of linux-bluetooth+bounces-461-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 88E9BB20C06 for ; Fri, 8 Dec 2023 10:17:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 321AE14A98; Fri, 8 Dec 2023 10:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="JCcDbPiu" X-Original-To: linux-bluetooth@vger.kernel.org Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9409E1720 for ; Fri, 8 Dec 2023 02:17:19 -0800 (PST) Received: from fdanis-XPS-13-9370.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fdanis) by madras.collabora.co.uk (Postfix) with ESMTPSA id 457B4660739E for ; Fri, 8 Dec 2023 10:17:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1702030638; bh=kM7O943Thov/g30dxW9Y+mZbj3gxNq+70yAStmUfGzY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JCcDbPiuUnS0dPrQmmfg00QZ/rgcEPiuh7y+Cexy1w+549XKDXfGk1jxOTWZ/Ud8b 6gmZQjdLbgHQ9BEW9nA8I/8Js56mS7vCRIm6GUWYHFDygsQedG6Y/CFfCz7kAwztGj oZp/rNSviNrJXWRVSaoImxp7yspEaHFWVNcLROd6B3yNdxQatkRvw/hXKdBSLQ5bCS UDlmjtTYz0ou5GSOuaj16aa/FjPGwYt3pppBCMN9QKuV0pO7OAz57xsb/EIai4aEwb ze6fDEF4hocflbl7ZOrZfLPWqR2m3mrPHbdGoF7/XWZSP1Jao3ye42oD+aQMPqzupa yMS205SX500Tw== From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3] tools: avtest: Add reject-code option Date: Fri, 8 Dec 2023 11:17:11 +0100 Message-Id: <20231208101711.624001-1-frederic.danis@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208090013.620051-1-frederic.danis@collabora.com> References: <20231208090013.620051-1-frederic.danis@collabora.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Some PTS tests like A2DP/SNK/AVP/BI-03-C, A2DP/SNK/AVP/BI-08-C , … request some specific rejection code to pass. This commit adds an option to specify the rejection code during AVDTP_SET_CONFIGURATION rejection. E.g. "avtest --reject setconf --reject-code 195" to reject setconf with INVALID_SAMPLING_FREQUENCY code. Reviewed-by: Paul Menzel --- tools/avtest.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/avtest.c b/tools/avtest.c index ca37b3b46..5ac3418aa 100644 --- a/tools/avtest.c +++ b/tools/avtest.c @@ -188,7 +188,8 @@ static void dump_buffer(const unsigned char *buf, int len) } static void process_avdtp(int srv_sk, int sk, unsigned char reject, - int fragment) + int fragment, + int reject_code) { unsigned char buf[672]; ssize_t len; @@ -284,7 +285,8 @@ static void process_avdtp(int srv_sk, int sk, unsigned char reject, if (reject == AVDTP_SET_CONFIGURATION) { hdr->message_type = AVDTP_MSG_TYPE_REJECT; buf[2] = buf[4]; - buf[3] = 0x13; /* SEP In Use */ + buf[3] = reject_code ? reject_code : + 0x13; /* SEP In Use */ printf("Rejecting set configuration command\n"); len = write(sk, buf, 4); } else { @@ -443,7 +445,8 @@ static int set_minimum_mtu(int sk) return 0; } -static void do_listen(const bdaddr_t *src, unsigned char reject, int fragment) +static void do_listen(const bdaddr_t *src, unsigned char reject, int fragment, + int reject_code) { struct sockaddr_l2 addr; socklen_t optlen; @@ -483,7 +486,7 @@ static void do_listen(const bdaddr_t *src, unsigned char reject, int fragment) continue; } - process_avdtp(sk, nsk, reject, fragment); + process_avdtp(sk, nsk, reject, fragment, reject_code); if (media_sock >= 0) { close(media_sock); @@ -709,6 +712,7 @@ static void usage(void) printf("Options:\n" "\t--device HCI device\n" "\t--reject Reject command\n" + "\t--reject-code Reject code to use\n" "\t--send Send command\n" "\t--preconf Configure stream before actual command\n" "\t--wait Wait N seconds before exiting\n" @@ -720,6 +724,7 @@ static struct option main_options[] = { { "help", 0, 0, 'h' }, { "device", 1, 0, 'i' }, { "reject", 1, 0, 'r' }, + { "reject-code", 1, 0, 'R' }, { "send", 1, 0, 's' }, { "invalid", 1, 0, 'f' }, { "preconf", 0, 0, 'c' }, @@ -764,12 +769,12 @@ int main(int argc, char *argv[]) unsigned char cmd = 0x00; bdaddr_t src, dst; int opt, mode = MODE_NONE, sk, invalid = 0, preconf = 0, fragment = 0; - int avctp = 0, wait_before_exit = 0; + int avctp = 0, wait_before_exit = 0, reject_code = 0; bacpy(&src, BDADDR_ANY); bacpy(&dst, BDADDR_ANY); - while ((opt = getopt_long(argc, argv, "+i:r:s:f:hcFCw:", + while ((opt = getopt_long(argc, argv, "+i:r:s:f:hcFCw:R:", main_options, NULL)) != EOF) { switch (opt) { case 'i': @@ -809,6 +814,10 @@ int main(int argc, char *argv[]) wait_before_exit = atoi(optarg); break; + case 'R': + reject_code = atoi(optarg); + break; + case 'h': default: usage(); @@ -826,7 +835,7 @@ int main(int argc, char *argv[]) switch (mode) { case MODE_REJECT: - do_listen(&src, cmd, fragment); + do_listen(&src, cmd, fragment, reject_code); break; case MODE_SEND: sk = do_connect(&src, &dst, avctp, fragment); -- 2.34.1