From patchwork Thu Mar 23 10:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 13185458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 885E9C6FD1D for ; Thu, 23 Mar 2023 10:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbjCWKbg (ORCPT ); Thu, 23 Mar 2023 06:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjCWKaf (ORCPT ); Thu, 23 Mar 2023 06:30:35 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C699322785 for ; Thu, 23 Mar 2023 03:27:36 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id o12so84251745edb.9 for ; Thu, 23 Mar 2023 03:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1679567255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E2M8ZS5DPkk4FU2yyrryJViRll0PsOCpoJq9idZw+8k=; b=imxOblQRax6ZLDwSqD8m0eEsfv1gdywb1j5TUTYQLZIgNWMjONsDEUMzSK6lbXBnRJ AAhiUJxypCdpMdmYprgBvvuUY+jDnW1GaQWsibvtaqPoXrVuli/3Eq2O8WYH46P7nUfl uft5CrdsZC6Y5ZeeF+XlTV0hpBJBGaQDelQPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679567255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E2M8ZS5DPkk4FU2yyrryJViRll0PsOCpoJq9idZw+8k=; b=hBqvgkp5PnkYYaADrZov628N2xAw8RU6AesdxQ3ZkYIyrpIGa+rPbu2sIw1hvH3iYy Vu9Rqss6eFTyFic/T/Zj9DHVov6iISiTms+zaY6fFPiFMTN+ZVqoxHXpG1OnGjD/qs16 zWMbj4qsMW8T+31PkCqWvvIQbAVizTHVtxxWdLO2U2mSQ5yjytlzUHxUk6jVHZhwDKu2 5aAQjX2cqqD30GfHujBPbouu+xWKdZ5cmLq/VI03rsT2BtSNGg2RfrMeIoZe05XTG0am gozy5391e+b3jAlLEeMYRVQveOB/vrogQf9PqhCgwNCZKfLC/uTKWzFbMMKxR690uwHd VHxg== X-Gm-Message-State: AO0yUKVddZrvfurupVmMUDL9fcoMvdClrvu4ifA3mkZLWhBca56a2yVI TKeX9GzK+D/fPyN/G5UsGa8WBNloym2rZs3/iM8= X-Google-Smtp-Source: AK7set8DmZkjArYMAGIFMsY67TDlk1JsONDwqlsu4/ST5uw9mfmlxwn4DTeMuCo0bWRyPMsuI68w6A== X-Received: by 2002:a17:906:3999:b0:933:3705:a9f0 with SMTP id h25-20020a170906399900b009333705a9f0mr10810374eje.19.1679567255178; Thu, 23 Mar 2023 03:27:35 -0700 (PDT) Received: from smi-ubuntu.sueba ([2a01:390:0:101:4f8c:7da4:48b2:8bd2]) by smtp.gmail.com with ESMTPSA id u25-20020a50c2d9000000b004faf34064c8sm8880564edf.62.2023.03.23.03.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 03:27:34 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 1/2] l2test: Enable hex input for PSM Date: Thu, 23 Mar 2023 11:27:31 +0100 Message-Id: <20230323102732.566440-2-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230323102732.566440-1-simon.mikuda@streamunlimited.com> References: <20230323102732.566440-1-simon.mikuda@streamunlimited.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- tools/l2test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/l2test.c b/tools/l2test.c index 5aae4b687..595f1dab2 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -1416,7 +1416,10 @@ int main(int argc, char *argv[]) break; case 'P': - psm = atoi(optarg); + if (!strncasecmp(optarg, "0x", 2)) + psm = strtoul(&optarg[2], NULL, 16); + else + psm = atoi(optarg); break; case 'I': From patchwork Thu Mar 23 10:27:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Mikuda X-Patchwork-Id: 13185459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89CECC6FD1C for ; Thu, 23 Mar 2023 10:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231376AbjCWKbi (ORCPT ); Thu, 23 Mar 2023 06:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjCWKag (ORCPT ); Thu, 23 Mar 2023 06:30:36 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F03238442 for ; Thu, 23 Mar 2023 03:27:37 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id ek18so84301748edb.6 for ; Thu, 23 Mar 2023 03:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1679567256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j3tKJg36pKhaz0q4z4JJnvDg/ansCdesQ1ZGxEBivzI=; b=YUldwR6SvnhMUV8um+fDWE9oFoA5s9ZvtI6Ja9B6eWI4APx3LqCR47jeZUvfzjtZQx HJVylUgu1xX0ltonv5NbaY8LSWQ/WUqsV78G4I82IWn9R6AEZQr7P36wvkrh8G8blwmM hZmMlzGGUxp8nzcdNSPfY+5l8fP2cI8DDI9TQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679567256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j3tKJg36pKhaz0q4z4JJnvDg/ansCdesQ1ZGxEBivzI=; b=FKhwtvVXsuHLeDlOzKEGtt1Rjwgs0HITfzZPd28UF3pQWq4kqVfMdrtnbVnF+s9kSi DY4HTcGjqAJeDKDgfJcV6NxS/WR34lqBnX2OFBfbIVSsiWnGH8BNu/hroy2BLAtCSGTJ X7qSJOVifecBESak+7Jmt+aTxOHFAmYVkmaCeU/lsdTW79fhs4VtvjkmqqEhFAedsgrx LJzZwDvRAI6td4fdM8DS2KUiDun/wRlKJ/jkNmr/6YUSBnT9taCFH4d0oAD+/jsSe77b bcc6Tu/WAVCHgBz1/rmxz25V5/JpoOIUE1S8BQhxfN+YvDD0FcAiRdHLuao077qol+h1 Ykcg== X-Gm-Message-State: AO0yUKWpPOWs6d2YfudxjS/X4hodAvjFgPVqH0OasXEtGfKL4vhJx+h7 XBYxb+2e+5+lYehxM0PJKV+y2NVbe6wQ9Sv6N5w= X-Google-Smtp-Source: AK7set9VCsZ9qgc+3jQb/1aq6HNXvUwKWsFhtLaI9r04+2SXLgJ+ZAC1N1y+duwF/7YysHQHA/SI/g== X-Received: by 2002:a17:906:14c5:b0:931:af6a:ad0f with SMTP id y5-20020a17090614c500b00931af6aad0fmr9599149ejc.76.1679567255804; Thu, 23 Mar 2023 03:27:35 -0700 (PDT) Received: from smi-ubuntu.sueba ([2a01:390:0:101:4f8c:7da4:48b2:8bd2]) by smtp.gmail.com with ESMTPSA id u25-20020a50c2d9000000b004faf34064c8sm8880564edf.62.2023.03.23.03.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 03:27:35 -0700 (PDT) From: Simon Mikuda To: linux-bluetooth@vger.kernel.org Cc: Simon Mikuda Subject: [PATCH BlueZ 2/2] l2test: Fix setting mode for BR/EDR l2cap socket Date: Thu, 23 Mar 2023 11:27:32 +0100 Message-Id: <20230323102732.566440-3-simon.mikuda@streamunlimited.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230323102732.566440-1-simon.mikuda@streamunlimited.com> References: <20230323102732.566440-1-simon.mikuda@streamunlimited.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org BT_MODE_* enums are used only for socket SOL_BLUETOOTH, option BT_MODE Otherwise we should use L2CAP_MODE_* enums. --- lib/l2cap.h | 2 ++ tools/l2test.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/l2cap.h b/lib/l2cap.h index 9197800df..62cc04b57 100644 --- a/lib/l2cap.h +++ b/lib/l2cap.h @@ -184,6 +184,8 @@ typedef struct { #define L2CAP_MODE_FLOWCTL 0x02 #define L2CAP_MODE_ERTM 0x03 #define L2CAP_MODE_STREAMING 0x04 +#define L2CAP_MODE_LE_FLOWCTL 0x80 +#define L2CAP_MODE_ECRED 0x81 #define L2CAP_SERVTYPE_NOTRAFFIC 0x00 #define L2CAP_SERVTYPE_BESTEFFORT 0x01 diff --git a/tools/l2test.c b/tools/l2test.c index 595f1dab2..61b2e778e 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -155,6 +155,24 @@ static struct lookup_table bdaddr_types[] = { { NULL, 0 }, }; +static int bt_mode_to_l2cap_mode(int mode) +{ + switch (mode) { + case BT_MODE_BASIC: + return L2CAP_MODE_BASIC; + case BT_MODE_ERTM: + return L2CAP_MODE_ERTM; + case BT_MODE_STREAMING: + return L2CAP_MODE_STREAMING; + case BT_MODE_LE_FLOWCTL: + return L2CAP_MODE_LE_FLOWCTL; + case BT_MODE_EXT_FLOWCTL: + return L2CAP_MODE_FLOWCTL; + default: + return mode; + } +} + static int get_lookup_flag(struct lookup_table *table, char *name) { int i; @@ -287,9 +305,11 @@ static int getopts(int sk, struct l2cap_options *opts, bool connected) static int setopts(int sk, struct l2cap_options *opts) { - if (bdaddr_type == BDADDR_BREDR) + if (bdaddr_type == BDADDR_BREDR) { + opts->mode = bt_mode_to_l2cap_mode(opts->mode); return setsockopt(sk, SOL_L2CAP, L2CAP_OPTIONS, opts, sizeof(*opts)); + } if (opts->mode) { if (setsockopt(sk, SOL_BLUETOOTH, BT_MODE, &opts->mode,