From patchwork Wed Oct 23 20:47:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13847907 Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 469A117ADFA for ; Wed, 23 Oct 2024 20:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716432; cv=none; b=bWsC41BkHSMqkGW9pn2GJvWhzuVb7dXGOlAHGe9fCHQObMXlwXzN6HiWb/+yWvOUhWhCvemyYpM1lbo6DUsE87qHsW3UvxZ6swrV5ngVwJSTmflh1R/5iIECn9BAGw/FtBnDKB1l6+EsBaTf+1MnjKTJyzvrkXKR8hCu4McKFpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716432; c=relaxed/simple; bh=WNsBf7ia3QJTV61waFrg37dr8Wlki9gyJ5mes2TdbHY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=kqe2TiCY3HdeYClKnqeu7VkB57Gtmp0vcpkDpmOaW3KtHB3fbMFZj/qDfK10LkiYpV9grUXRys6xSS0n/u3ULTfeZSJp6TTEXE8+ko39fcBeOFlhvQPW67dFWXNsL8CzmN9oL30ueNEn4tzt78enILovINo/fG3qv+EWqvf8AP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hNKCW7KZ; arc=none smtp.client-ip=209.85.221.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hNKCW7KZ" Received: by mail-vk1-f176.google.com with SMTP id 71dfb90a1353d-50d35639d0aso64625e0c.0 for ; Wed, 23 Oct 2024 13:47:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729716429; x=1730321229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=RBwbElsJv4sqforD1IGGN29a1mCMzSY8gUSb2DJiL7c=; b=hNKCW7KZAPmXysgPtKcoLC/cvLUyAs8RaDF/8Yw4pvQVxXSRAb8Im1O9NEGOP46dGE gsdPBuEXw35/WSsw9I/iDX5oKUGWZqNYSZPODKLXzIvEzU4JG9kqoCtx2wOQnsmDJqh3 BFnB33eI5tHrF6s3wZ9BADDRgQdzKSIxU85NQeCeaZfLIp8dBsrkClOE3N7AgDHyehad Sgscurqs+Cci8UUpfWm+3eCxwnbVLRIQiZAX3KpI/qAYcwDFknYi+p7M6z21Q2jYiKsJ k5B6QAykhaxvg1e2eqw17/xu8QALtPa8ABiG9q3hu8Ij2Sze0MVlaT/F8vyfYNzKcDtk xxUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716429; x=1730321229; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RBwbElsJv4sqforD1IGGN29a1mCMzSY8gUSb2DJiL7c=; b=gTcD/wqmLaVFYQ10+WpLpTasDS4cyFHNjMyKLPMIQB0C95uvB1hbvZEU9QcvEm4PH1 US0ZGrGGT4+qKAJYOG9ojRoUmsU2RqDeUWby667hhPfr0/bPFPM5cbHkTykKN0sf7GqD 86gu46AzwU6j4VMP+YpxPlqdurbqQc6TRvLy8UakCYLqyWenPsxxl5ih5kvqXhyNwecW yd2HhtsM/qPN2RIqELkX/Uk9wBZ43ovKVEPBKUK8Hkzj+VSp7XLhc9f9EPeCjNi1cUDW x2pQMcLQC4TUSCmX6x4UI0W7SZ6Kpkm3Fm1dNzkWN/U+RWtCR0SbjW8CEDwG/mQ+j/Mt zHew== X-Gm-Message-State: AOJu0YyWLEuZQPcLB6JiJJDJ0JSw3lfu82FgjalS43by00cCcQUFPyyG l2FduZEDwykwo1aEfpY+nfXAngxSfStA2tf0ubZLVj93icman0NC6K2BEA== X-Google-Smtp-Source: AGHT+IG0pSg/2mxMXtj8VQtVEnivHS/0xmsircJfeqymHIZDHSAvcI52RW30GzlLuhRV+0Kh2A+YPg== X-Received: by 2002:a05:6122:32cc:b0:50a:b8aa:93c3 with SMTP id 71dfb90a1353d-50fd01e16d7mr4978041e0c.3.1729716429435; Wed, 23 Oct 2024 13:47:09 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-50e19e0dbe9sm1168436e0c.3.2024.10.23.13.47.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:47:07 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v1 1/5] mgmt-api: Add Send HCI command and wait for event Command Date: Wed, 23 Oct 2024 16:47:01 -0400 Message-ID: <20241023204705.2422998-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This adds Send HCI command and wait for event Command initial documentation. --- doc/mgmt-api.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 59e61d361dc2..d37eae402861 100644 --- a/doc/mgmt-api.txt +++ b/doc/mgmt-api.txt @@ -3991,6 +3991,36 @@ Cancel Transmit Mesh Packet Command Possible errors: Failed Invalid Parameters +Send HCI command and wait for event Command +=========================================== + + Command Code: 0x005B + Controller Index: + Command Parameters: Opcode (2 Octets) + Event (1 Octet) + Timeout (1 Octet) + Parameter Length (2 Octets) + Parameter (variable) + Return Parameters: Response (1-variable Octets) + + This command may be used to send a HCI command and wait for an + (optional) event. + + The HCI command is specified by the Opcode, any arbitrary is supported + including vendor commands, but contrary to the like of + Raw/User channel it is run as an HCI command send by the kernel + since it uses its command synchronization thus it is possible to wait + for a specific event as a response. + + Setting event to 0x00 will cause the command to wait for either + HCI Command Status or HCI Command Complete. + + Timeout is specified in seconds, setting it to 0 will cause the + default timeout to be used. + + Possible errors: Failed + Invalid Parameters + Command Complete Event ====================== From patchwork Wed Oct 23 20:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13847908 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E94A17ADFA for ; Wed, 23 Oct 2024 20:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716435; cv=none; b=H0PM4X3w1zzuh8nQIoVdiuLeFDHuRD7p5iVSup0GaxcAC0dLLfmRPMhyvl07Hu+rPM1n1XpHXgcE37nPPAudglepre+sqtKhkfja/Tn1h3pJqedyqckeSgHVL1IWMUfB+T9WqErXKj6mHTtL2hYaaPWPaCZfhRQgTimvRzGry7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716435; c=relaxed/simple; bh=qV1w+CduYGYvb+rBO6u8mV7XzWJIHfjELVmhXvs9GWc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qtIUun3wSL824a8p447waDFd5K5jRfnCjDCzhMYZdzZEPKn4QqkcXRivKbz7Aj2oJJYJzHep8BREdDArHuuHtqGsoPExTSxE2vaP/vbJhkqJfQAyjtETDwvKpsXTwqWQEKHjLMlFATI/FxNGHVpe/FfURukV6dwmnXCP9OdossM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FCiWQ4ot; arc=none smtp.client-ip=209.85.221.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FCiWQ4ot" Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-50d564df009so54875e0c.0 for ; Wed, 23 Oct 2024 13:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729716432; x=1730321232; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YpIuY4qniF7o3P1L1HFdsmMwWpqFhjqG5ru635J3Ijo=; b=FCiWQ4otIFb0pHWYcGX1ewyzkhMmOXIguHgZ73wiSdHurPOfkC+j37se7eQfzdzu/8 RIkgvwk8DwKQIdDGmq0+TNNTVHXLvasD2wMf8KzOf5Hc0wLsXJe6LP/TF8Be5yHItVI+ /D7srS9aUN/NiEa3Kzx06Fz649v9q1H8wRfvwgmOzcTyN5wjgbiWjcNXrBWb4zdAVYgO BjQbgaNexTla7BVOepKklyMqRouIyZwNLnc6uCTNJ2JuXchWHRbIVGVwP52df0jLP5Pv J0365O2wDlqVddKzlzYIV7rrH58crfN3WQj1DIV1k9GDkottXFs32aEOshXvPAzns5Du dcyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716432; x=1730321232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YpIuY4qniF7o3P1L1HFdsmMwWpqFhjqG5ru635J3Ijo=; b=wNILV+NtvHXeMtPVR4oIhZ4nQYirdeUEfgeJn+r+YzMh1pcQIoi3ivI2xUtLmJ0sBC 0XQ5FTyToHOvkOWRQfm6hLS3b1XU50axIMd2fGIdbFUwd1HWNJM5mgGESi0PJebQ16g6 Rr2WElvAKirPs+rBB8PNeFkKunnWHBu8AVGuNvMzvbNiSQ0oGFuF5Atm86mS4BDCPwzF KcLtAtaIGmGyNAZYpF+l7nEmu6mYu+qTQ2oc2P/9VwPMcXhn3kmCWEy+eNmRVTGoCB9b 4oCyDtouC/k7QXUa/BiOg55PQnrR2o3CK0wU+IvFyMv0prTDEtoj+/XA30zEIbg2HRdx 6htQ== X-Gm-Message-State: AOJu0YzdA+Iu0bp6SdMNGC/1g+qLHkbeQ0x1IVx8MQ2ds4G0CSI4Tyft QA1ey/AGWeGabf5NqCn21VklXoUAtyz/lfv+mTvNj/Sb+OxzvXb54pWitw== X-Google-Smtp-Source: AGHT+IHh4cxXcbHahXLDY3IyOhMBlnLTGwrlBQyyDLawwM805ILWonGLctENt9bBC5H7+EaxW6Fk+Q== X-Received: by 2002:a05:6122:65aa:b0:50d:8248:83bf with SMTP id 71dfb90a1353d-50fd02db686mr4484884e0c.9.1729716432551; Wed, 23 Oct 2024 13:47:12 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-50e19e0dbe9sm1168436e0c.3.2024.10.23.13.47.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:47:11 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v1 2/5] monitor: Fix opcode for MGMT_OP_MESH_SEND_CANCEL Date: Wed, 23 Oct 2024 16:47:02 -0400 Message-ID: <20241023204705.2422998-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241023204705.2422998-1-luiz.dentz@gmail.com> References: <20241023204705.2422998-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz MGMT_OP_MESH_SEND_CANCEL opcode is 0x005A not 0x0056. --- monitor/packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/packet.c b/monitor/packet.c index 32a440bbea68..6d869ffeadb8 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -14982,7 +14982,7 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0059, "Mesh Send", mgmt_mesh_send_cmd, 19, false, mgmt_mesh_send_rsp, 1, true}, - { 0x0056, "Mesh Send Cancel", + { 0x005A, "Mesh Send Cancel", mgmt_mesh_send_cancel_cmd, 1, true, mgmt_null_rsp, 0, true}, { } From patchwork Wed Oct 23 20:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13847909 Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5076F17ADFA for ; Wed, 23 Oct 2024 20:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716438; cv=none; b=C1NlQctxK2+OvCpeUjgQFQT1wJnJtkf0YK3rl87kZwSSkgE3/g/P6XMBtivE85POGjuVHDHKrdDcke/WJZqEaNTwFhEjt4DuOvVxMoZddD15zWgUWBf9Xl8jCsnsl5pGP3K9y64gBIZamoqbxbM1LvGCDPXmbHFnPP7lrC3pQ74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716438; c=relaxed/simple; bh=PlRXfXGZRXfh/Dg41TphBXFaL6OfVmKKDy1TKlAztjE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpM0oScRjEe4BCDd4Wl4zdqbumdA7sfnsA/51TehUAfWYHYQiSL/9sD7WcorjcMqfYXvTen2av2Q3BoP5x0LetKWt2aN4wID1uCIHuRD++KsqT+SEEG11v9d/nlPhslMz7/jopv9Zj3xf8OFzt298bU7nVwqUsWPhOlSvCZDIYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lHt7WeUf; arc=none smtp.client-ip=209.85.221.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lHt7WeUf" Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-50fcc0cdcefso60181e0c.0 for ; Wed, 23 Oct 2024 13:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729716435; x=1730321235; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RThP8lQ4Dz9fNP6z+7ZeWVvRA9F70KZWYAD89OJlzn0=; b=lHt7WeUf3zmA5yzadS5V9LW1Ryt16ZLvrifspfPMb+duE5bzvSRcbNtpECqT+KUUec OdgBlfcjK/neOoigpHuWzS+m1UAJ8d1O1q+w/ws3I6m5coxFWVrIXxL090LKm8bDuKXv stpNEiSRKGlzOu8/y+rBQnsKvC7KoBqgYKmfl8wOwbsNEq1Q9yjmXhJvIJJOXcmP6kIm sHHHbNZp+dDLZzQm4TSwFlmwBIVYPo7rWajCzudGqtaklCAztOSWHn5MYheCudUtx3GU 3WdFkw0S06qPGuaSYENpsepwlnD8x2AZ1FnT0vUmbKLRqtyRw4kKN18+oqz5Cr9F1ebP B+fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716435; x=1730321235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RThP8lQ4Dz9fNP6z+7ZeWVvRA9F70KZWYAD89OJlzn0=; b=XgIhm3GhwlZS5plOIuUaqScSA6/WR1Oknd8zoPcPOdSWmEGkmdRl78LfZeh10VEham lrkS/NFGkINoAK9+z8jY4g6NB7f997DpmFgrTcEikcwXhx94tvF/heTUmGhgRHtrrqm7 XWieCrKXMcHWuS7ApQfQVvURut0Op4576Q2HNKyWN3ucgHycDA7OVXMHEjYufwNmMSJl usjoxJqUp5CxwcxS7O3DrbzR1dzmV7kAjijUh9Nm+tsN1qWiYi7uwGUnANupg+Z6DPW1 P6APA4MI395Sx6a+NSNeIw/tuIIQVBDlaxtuNeQkxTFKW5tZgsYESCR1qYOyEG0g32U+ T86g== X-Gm-Message-State: AOJu0Yyxh3RO+5eYK3I481nEd7KR1c4jR5cAI/mPh6by89p0fsQ+wN+o 3YNJlv3NJGOGBszqk6K5ixYHMyYlFdJcLbLiFC9D8f5jW/9EDsi/BsMNwQ== X-Google-Smtp-Source: AGHT+IExodb0zunOP45/n09svJjflcB2VMCIUCUZgAlEhMbVbVA4qi3IjAo7yNQRvzD1EGbPFXH0iA== X-Received: by 2002:a05:6122:2a53:b0:50d:60fa:183e with SMTP id 71dfb90a1353d-50fd037aecemr3898007e0c.11.1729716435569; Wed, 23 Oct 2024 13:47:15 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-50e19e0dbe9sm1168436e0c.3.2024.10.23.13.47.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:47:14 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v1 3/5] monitor: Add decoding of MGMT_OP_HCI_CMD_SYNC Date: Wed, 23 Oct 2024 16:47:03 -0400 Message-ID: <20241023204705.2422998-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241023204705.2422998-1-luiz.dentz@gmail.com> References: <20241023204705.2422998-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz @ MGMT Com..nd (0x005b) plen 6 {0x0002} Opcode: 0xffff Event: 0x00 Timeout: 0 seconds Parameters Length: 0 Parameters[0]: @ MGMT Event: Command Status (0x0002) plen 3 {0x0002} Send HCI command and wait for event (0x005b) Status: Failed (0x03) --- monitor/packet.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 6d869ffeadb8..f1a42925a8fc 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -14712,6 +14712,55 @@ static void mgmt_mesh_send_cancel_cmd(const void *data, uint16_t size) print_field("Handle: %d", handle); } +static void mgmt_hci_cmd_sync_cmd(const void *data, uint16_t size) +{ + struct iovec iov = { (void *)data, size }; + uint16_t opcode, len; + uint8_t event; + uint8_t timeout; + + if (!util_iov_pull_le16(&iov, &opcode)) { + print_text(COLOR_ERROR, " invalid opcode"); + return; + } + + print_field("Opcode: 0x%4.4x", opcode); + + if (!util_iov_pull_u8(&iov, &event)) { + print_text(COLOR_ERROR, " invalid event"); + return; + } + + print_field("Event: 0x%2.2x", event); + + if (!util_iov_pull_u8(&iov, &timeout)) { + print_text(COLOR_ERROR, " invalid timeout"); + return; + } + + print_field("Timeout: %d seconds", timeout); + + if (!util_iov_pull_le16(&iov, &len)) { + print_text(COLOR_ERROR, " invalid parameters length"); + return; + } + + print_field("Parameters Length: %d", len); + + if (iov.iov_len != len) { + print_text(COLOR_ERROR, " length mismatch (%zu != %d)", + iov.iov_len, len); + return; + } + + print_hex_field("Parameters", iov.iov_base, iov.iov_len); +} + +static void mgmt_hci_cmd_sync_rsp(const void *data, uint16_t size) +{ + print_hex_field("Response", data, size); +} + struct mgmt_data { uint16_t opcode; const char *str; @@ -14985,6 +15034,9 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x005A, "Mesh Send Cancel", mgmt_mesh_send_cancel_cmd, 1, true, mgmt_null_rsp, 0, true}, + { 0x005B, "Send HCI command and wait for event", + mgmt_hci_cmd_sync_cmd, 6, false, + mgmt_hci_cmd_sync_rsp, 0, false}, { } }; From patchwork Wed Oct 23 20:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13847910 Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DEA51E0DBF for ; Wed, 23 Oct 2024 20:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716440; cv=none; b=cekfWx1eECk+odWgajclKHvH8g8pgXNDB7+A08Hmdo8oFyhh7NBJ/lx8s1DDeK3qLldoGcx4LmHU7d604KRJmK7OnQDilZKreRh3dH80wuGv0UGbvfx0wHOfhsMi/2/Sj2z00Am68zWXTE/WdqQez40iY5QpcZHNKe9IxAdIhA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716440; c=relaxed/simple; bh=0+bhxevoKtrickIUyLV3SLHt0wRxBEWhJsxZ7BcJLVc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=txQRfKUI6jKh/Iz9UFn8JqSESwBzAJtwofcNzTapssFea0k91ylEqHfWyJRNa4wFWSRTvZQl1MRYeMmvk7NbGKxm1McHsaswRHESP3ZMu+NP+N5M2AckxtWH1glFB+RGBP49cMHE198EpmSER2m0v29YoaslR0xQgM0EpV2U5rM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YYLDDWI6; arc=none smtp.client-ip=209.85.221.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YYLDDWI6" Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-50d2e71de18so59022e0c.1 for ; Wed, 23 Oct 2024 13:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729716438; x=1730321238; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JpMGUJhSDYAuV1a3EYKSNR7JPHa9+0fIstpgIY+ratQ=; b=YYLDDWI6sQJbKy3pKh0CY7vhqU2rYcVe5VNhvZ1+p7VIkt017jW6h19BJrT7nLPDLz 5+K8gzdzhFnsxOGdqECp3tjIQ7TAyQG4wBbn8UMCBmg+9LkAHJJfRMMuWmj6rMElwnVJ g2nTTmcXqpOgY9tuG6SpanoazF3aucoE7dmTHQownYjb4WSK0JtxeZCaj0Kukl+gq+vv eGwZgfNo9lD16EkmLSblHRWSryjSFN6jgsW/JhBCpqU33JTgg8OCVTj4o48OF50Lk/oS zUQLr8PNjBlA0AzSfeYyvat8BXo3PuoEFzQVk3EhenDmdgQO23o6L/HyFZnlmF0zlbOB MoDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716438; x=1730321238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JpMGUJhSDYAuV1a3EYKSNR7JPHa9+0fIstpgIY+ratQ=; b=mYen8PKgL5wavjbs8fy/ZfGSzuzgKAiAqs7Mj4EasHLsx+WS3nYdr/U2V4xNzaCoWl G9KVP26lYNgi4j2fOuD7DF2L7o7h4vZG37Gd9AmItpSvtvDxhxXV6HkbW5XTNSOGFjab rMIf0UN4E3RtcUrNitMyGc1CKsIPuYCZ7KFIrVSi7vy6mHG88bu3iTuNyAR2qJwL4XFP 3obzDhEoIVoPm7x83stl2SkXOT4048HUOTQ7+vdmJIEypCroAxUf5F7nXBMSKkkyRuSN uf2oLr6SBncJPQswkrOyn78plAKoQryGyZe0M9oqDb+yi9gl+Hod2gUAAApVCR5P7FVM Toig== X-Gm-Message-State: AOJu0YwwVnDneEJwtiBceQ6bMf/d8Z6DTsIiGN4+S08xHdSfGYCNIxRr Ra051HG8S3iaftkl4W2VGrL62pkHADMIdBdVt4bpxmdVXulG6DgJjIfalA== X-Google-Smtp-Source: AGHT+IEgcIWFVPe/BQGpGVxPzgorQ5kkbJ9j9PLQHGzm4ZK4GQUokFmiSfNY3upaWgBfV82RVd7keQ== X-Received: by 2002:a05:6122:659b:b0:50d:5654:951 with SMTP id 71dfb90a1353d-50fd0216b1bmr4825013e0c.5.1729716437616; Wed, 23 Oct 2024 13:47:17 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-50e19e0dbe9sm1168436e0c.3.2024.10.23.13.47.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:47:16 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v1 4/5] lib/mgmt: Add definitions of MGMT_OP_HCI_CMD_SYNC Date: Wed, 23 Oct 2024 16:47:04 -0400 Message-ID: <20241023204705.2422998-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241023204705.2422998-1-luiz.dentz@gmail.com> References: <20241023204705.2422998-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This adds the definition of MGMT_OP_HCI_CMD_SYNC and its packet structure. --- lib/mgmt.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index 8f92b77315e3..f784dcada191 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -797,7 +797,16 @@ struct mgmt_cp_mesh_send { #define MGMT_OP_MESH_SEND_CANCEL 0x005A struct mgmt_cp_mesh_send_cancel { - uint8_t handle; + uint8_t handle; +} __packed; + +#define MGMT_OP_HCI_CMD_SYNC 0x005B +struct mgmt_cp_hci_cmd_sync { + uint16_t opcode; + uint8_t event; + uint8_t timeout; + uint16_t params_len; + uint8_t params[]; } __packed; #define MGMT_EV_CMD_COMPLETE 0x0001 From patchwork Wed Oct 23 20:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13847911 Received: from mail-vk1-f181.google.com (mail-vk1-f181.google.com [209.85.221.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0EB81D041B for ; Wed, 23 Oct 2024 20:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716444; cv=none; b=YbPRJcGS1b0cq1LKcYAV9sKTvFrX665zEm7+UnFw/Du9CDf2rNi5eX2Sr/SDbN3fsNs0+LHCUMtWRlb2CBFQWXCPwUIqdSIfqt9KThs8kVFEtlC6AC5GpwY1ElQPFsC6l+N7DfY4jfAhmKgM9X9BypnJTrFDETwMaPeYEXhStVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716444; c=relaxed/simple; bh=rRjSjYzmSlQoRZv6OFJRwoa2rYMglZ4crQnGyMkT7eY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RekcBw+SKcvX2JK0XH19QfdBpWp7ph2u80qq5b7RaC6/9PjIHBrG1VW7vrS7EF3iXbriFCmbSLBDwG+dujvVOvw1vkgh357Aw1Mdd1cVAag9tsc0qG5J6bTdqoDsv/PZBghihOAYHuC2WKLdKXFm6Xjgm/ZZr5rGIOcswmXJ5pE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ieodzwY1; arc=none smtp.client-ip=209.85.221.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ieodzwY1" Received: by mail-vk1-f181.google.com with SMTP id 71dfb90a1353d-50d399891d6so47711e0c.1 for ; Wed, 23 Oct 2024 13:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729716441; x=1730321241; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OirxWHKjdKpWRDBbeAPd2l1jC+J3Pjl0j2pDjl1Tywg=; b=ieodzwY1KjSFrt3dVuNputJF9yWkWzj2HzYnbcae/L+Ey78Moo09ZaG/z+S7uFFADr Ld0UPCIvXtBWLpNOkx5xPaC4geZkDhjc+nCb7O32iK8mIj+Sg+Ru3NWcb5QP0F2xUeDu oh7ckMpTTLdi7VVSJJq1SKq/77YI2l32c/TtfyG4eKkM0wmT4hZdnzibHCFxOBOVyySO vXNkVeqRS+FQ6ObbD9WvM2hT/lL5K6yB/j1E5PPX/5HRs0vpLHD5+/KJFJs/Gxm9XKO9 NpAmbjTPBODa5PEmJ8letNCbQSme0TwNwE6l6T36PyKCUFzGj3r6WU6v2Ij3h57OcVGR d3fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716441; x=1730321241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OirxWHKjdKpWRDBbeAPd2l1jC+J3Pjl0j2pDjl1Tywg=; b=ULpMW2YV3PxXbYmfr0BMORTZ7sfi8br8HALQu/Rdk2nr2ifcI0BCN9cJuTAwfQsnAz qwOs6F1tuMgAQn/eTKWt5+kiig6DgHa4NsullNJiHMkCQ+ZIv/5ji82wcQg1PTYEB+wQ diohrIaQQUWBCVlLxNfJ42nqA2rJROrbo+xBjpSHFbyl6B4Bjp3P4Iu6IGapStj/ZXQt mBeAKDtGvnYhvZFTqUUFt78C1yUZTLs9pN426omSUsPKXkMqvUHMGYVufndh/OR/pWsU StUlG2TAXHp3C5cu2UC1974vTTU+XVqJE+5uxZpn5/2W4fueJJfOxZNpupBjVMdJDTf3 aG2Q== X-Gm-Message-State: AOJu0YxCOPPfxv5KIcWEXCoteyl89WfR2/sioI8RgDLYeU2/ph9Psvhc P4yNjwW7/ED2nzMDscnEMP6VqxPcixGLKmzEzBYGQEzWPh4nWKvZV9r8xg== X-Google-Smtp-Source: AGHT+IGOliKWi6GAERLF3PWIDI6JLJSX6BqWes7SE2U8JxsgcdYYMzyC1ZDrhH7y0x6TUbPil0eyFA== X-Received: by 2002:a05:6122:3bcc:b0:50c:55f4:b529 with SMTP id 71dfb90a1353d-50fd0313353mr4543894e0c.8.1729716440639; Wed, 23 Oct 2024 13:47:20 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-50e19e0dbe9sm1168436e0c.3.2024.10.23.13.47.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:47:18 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [RFC v1 5/5] client/mgmt: Add hci-cmd command Date: Wed, 23 Oct 2024 16:47:05 -0400 Message-ID: <20241023204705.2422998-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241023204705.2422998-1-luiz.dentz@gmail.com> References: <20241023204705.2422998-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This adds hci-cmd command which uses the MGMT_OP_HCI_CMD_SYNC: bluetoothctl> mgmt.hci-send 0xffff bluetoothctl[44]: @ MGMT Com..nd (0x005b) plen 6 {0x0002} Opcode: 0xffff Event: 0x00 Timeout: 0 seconds Parameters Length: 0 Parameters[0]: < HCI Command: Vendor (0x3f|0x03ff) plen 0 > HCI Event: Command Status (0x0f) plen 4 Vendor (0x3f|0x03ff) ncmd 1 Status: Unknown HCI Command (0x01) @ MGMT Event: Command Status (0x0002) plen 3 {0x0002} Send HCI command and wait for event (0x005b) Status: Failed (0x03) --- client/mgmt.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/client/mgmt.c b/client/mgmt.c index 602b92228ab8..59dcb3135344 100644 --- a/client/mgmt.c +++ b/client/mgmt.c @@ -2338,6 +2338,115 @@ static void cmd_set_flags(int argc, char **argv) } +static uint8_t *str2bytearray(char *arg, uint8_t *val, long *val_len) +{ + char *entry; + unsigned int i; + + for (i = 0; (entry = strsep(&arg, " \t")) != NULL; i++) { + long v; + char *endptr = NULL; + + if (*entry == '\0') + continue; + + if (i >= *val_len) { + bt_shell_printf("Too much data\n"); + return NULL; + } + + v = strtol(entry, &endptr, 0); + if (!endptr || *endptr != '\0' || v > UINT8_MAX) { + bt_shell_printf("Invalid value at index %d\n", i); + return NULL; + } + + val[i] = v; + } + + *val_len = i; + + return val; +} + +static void hci_cmd_rsp(uint8_t status, uint16_t len, const void *param, + void *user_data) +{ + if (status != 0) { + error("HCI command failed with status 0x%02x (%s)", + status, mgmt_errstr(status)); + bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (len > 0) { + bt_shell_printf("Response: "); + bt_shell_hexdump(param, len); + } + + bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +static void cmd_hci_cmd(int argc, char **argv) +{ + struct { + struct mgmt_cp_hci_cmd_sync cp; + uint8_t data[UINT8_MAX]; + } pkt; + char *endptr = NULL; + long value; + uint16_t index; + + value = strtoul(argv[1], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT16_MAX) { + bt_shell_printf("Invalid opcode: %s", argv[1]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + memset(&pkt, 0, sizeof(pkt)); + pkt.cp.opcode = cpu_to_le16(value); + + if (argc > 2) { + endptr = NULL; + value = strtoul(argv[2], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid event: %s", argv[2]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + pkt.cp.event = value; + } + + if (argc > 3) { + endptr = NULL; + value = strtoul(argv[3], &endptr, 0); + if (!endptr || *endptr != '\0' || value > UINT8_MAX) { + bt_shell_printf("Invalid timeout: %s", argv[2]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + pkt.cp.timeout = value; + } + + if (argc > 4) { + value = sizeof(pkt.data); + if (!str2bytearray(argv[4], pkt.data, &value)) + return bt_shell_noninteractive_quit(EXIT_FAILURE); + + pkt.cp.params_len = value; + } + + index = mgmt_index; + if (index == MGMT_INDEX_NONE) + index = 0; + + if (mgmt_send(mgmt, MGMT_OP_HCI_CMD_SYNC, index, + sizeof(pkt.cp) + pkt.cp.params_len, &pkt, + hci_cmd_rsp, NULL, NULL) == 0) { + error("Unable to send HCI command"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + /* Wrapper to get the index and opcode to the response callback */ struct command_data { uint16_t id; @@ -6016,6 +6125,8 @@ static const struct bt_shell_menu mgmt_menu = { cmd_get_flags, "Get device flags" }, { "set-flags", "[-f flags] [-t type]
", cmd_set_flags, "Set device flags" }, + { "hci-cmd", " [event] [timeout] [param...]", + cmd_hci_cmd, "Send HCI Command and wait for Event" }, {} }, };