From patchwork Wed Apr 1 10:24:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468879 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A56D3159A for ; Wed, 1 Apr 2020 10:25:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8395E20787 for ; Wed, 1 Apr 2020 10:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="eEHjJFAm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732148AbgDAKZB (ORCPT ); Wed, 1 Apr 2020 06:25:01 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43922 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728087AbgDAKZA (ORCPT ); Wed, 1 Apr 2020 06:25:00 -0400 Received: by mail-lf1-f67.google.com with SMTP id n20so19940437lfl.10 for ; Wed, 01 Apr 2020 03:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=b96my60rfsHxPwOWqECXE04G4E9wJo6N/lPNkbAIU84=; b=eEHjJFAm9aVQA5JGQgCM5e6Ab1TShwgElP0ltmvtWh3m0vViD1sDALS3P/CVDNm0kw jeKgFppzcVQEBWUHLmvQ38Lju4bBaRzEX5/mnqBe5TIYz7rf2fyJZD26kLkfDmBkA9OK LRDqqPWvkfVuiMV5I9OXZO1BXQk0/jj2shA9QEe0DGoR+BpVdHma9radLY/H/u4hZ304 T4OuGH4bTBIlBYpQx/BX4rKwioCbHtCsJAXB4bDjymmm00EtZJVZDAtqpSH0K7MSmPWE o4x9uOl55UAbpW9q02YofwMqV1jhsbkm5dm7CV1IckioLseBccRx7uzpZFK+nPVm3zDD E1Nw== 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=b96my60rfsHxPwOWqECXE04G4E9wJo6N/lPNkbAIU84=; b=JIqxfTTcDZFE++qN5idicZZleGf19fwMCk3cDuBI/hnUmVYPViT4uqrZyN91j+KmCH yglo8ZpMQh89dGAb9UqhtU+ha0PLklVF2OPD53fOiMfib/Jwu5mo8ntXSSs552Eo26CM yzDp4l/u3SCyCs4rqJV8Jl/nrRj9kIyASnfkEgUs2/hSVPvGcjmIKn7dUNMm9mN+9o8x XuHgOMqQPMmZdX3GNdTEIapM1I7PEOSeU262AWe4HcUQWyA6Dk2n3fICyX0m3PP1Hk0i KDXr/J1rjmdZtSviBd7rJ4sQ3G8HDVL3K32z4rA7cwqGuEUxM1xrJ3v0H0zYaC2MUG/e 9GMQ== X-Gm-Message-State: AGi0PuYcr/TP9WMFEm84FS4D/ohIJ6BKP1vtS1HjbWJVlClM5QH6UYWP LfvGLXd46zihvSOyHegToqB4CzVeuWE= X-Google-Smtp-Source: APiQypLy2b3mL3x9FVv4qP4fLMBtQ8qZrzD9OwSARKIodr6MI8BANPAV1/3FghqC9fUKjTTjOv2lsA== X-Received: by 2002:ac2:51c5:: with SMTP id u5mr14068050lfm.151.1585736697265; Wed, 01 Apr 2020 03:24:57 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.24.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:24:56 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 1/6] tools/mesh-cfgclient: Display unprovisioned OOB data Date: Wed, 1 Apr 2020 12:24:57 +0200 Message-Id: <20200401102502.746-2-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- tools/mesh-cfgclient.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index ae13c4409..43588852b 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -1533,6 +1533,19 @@ static struct l_dbus_message *scan_result_call(struct l_dbus *dbus, bt_shell_printf("\t" COLOR_GREEN "UUID = %s\n" COLOR_OFF, str); l_free(str); + if (n >= 18) { + str = l_util_hexstring_upper(prov_data + 16, 2); + bt_shell_printf("\t" COLOR_GREEN "OOB = %s\n" COLOR_OFF, str); + l_free(str); + } + + if (n >= 22) { + str = l_util_hexstring_upper(prov_data + 18, 4); + bt_shell_printf("\t" COLOR_GREEN "URI Hash = %s\n" COLOR_OFF, + str); + l_free(str); + } + /* TODO: Handle the rest of provisioning data if present */ dev = l_queue_find(devices, match_device_uuid, prov_data); From patchwork Wed Apr 1 10:24:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468883 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E622C92C for ; Wed, 1 Apr 2020 10:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5A0120857 for ; Wed, 1 Apr 2020 10:25:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="Ivine5MD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732156AbgDAKZC (ORCPT ); Wed, 1 Apr 2020 06:25:02 -0400 Received: from mail-lf1-f53.google.com ([209.85.167.53]:44736 "EHLO mail-lf1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732146AbgDAKZC (ORCPT ); Wed, 1 Apr 2020 06:25:02 -0400 Received: by mail-lf1-f53.google.com with SMTP id 131so641387lfh.11 for ; Wed, 01 Apr 2020 03:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=b63k3DErR/1nXLYBaG+6sS5inCIckcEURx2bMOJ8U6k=; b=Ivine5MD3r3VP0TM6ZGEGe/P+M0e+5WQ1STp/dc8yqT50ahfhLMuPDFugooqB8QijO yTNF6Y12T3ZxbDss5VEc1misZbW3s/cDdKuUUNnQS7KFK0DIGs4yBIK6TZyshVPKHKVB eTiHE5huZiROI139QgS/d7QzexkOnvMc43YVTEcWAzqyro+oBNFqnfRG3rbK4iIlZszL Hg4maxwzMC85p0kWNwY86PYc9MHY7RxnapsiSvCh2XQ67Xc4tUsEJIq6wZHW2Fh9SOOc 4YEIMNxlg0+AWZTONAC19DPE7OswvfADqVi5oe60icJAFH6AOIWLQx7SPiM/VoM/iN0Q 6Xxg== 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=b63k3DErR/1nXLYBaG+6sS5inCIckcEURx2bMOJ8U6k=; b=ntWbnnME8JTn9cAlPJlk6BYqPkxGuwopJZdVpScBXb9RDyhkKfuMUSlNXO1txlgrs3 Z1wF9qmQRiSZicQ0KYx4kR4Ld0lHXUVbPwyK3xzawQr6SFbeZmrz4YHSs4K7MfgNy3l7 nCxcFcaHKeMLUZhAptqL8QhlKS5tpkFfThyS3CMEqqL9KBGSsAcel5/cLxjrIPlms2Gz pJPVtaV+iqUpz3TsitLCI0pHzlkY1oBN7/0SDrlFP8Q+kV4BNHM7yFS1NCDmrGNSQLSZ 3/H7Q5aKAvQRg/JAld69M+LwgXA2YcvSS5LWI7HHg+0e5c5NXcbOz86UR+EqfYxnRkJH Rmvg== X-Gm-Message-State: AGi0PuYLB8s/iuSpQ6iV5sxqay4thxFAQ81jxRJMVkImMISxNEr9UcPj w/vLmAH9PEwE4ncn0RHnIjoN/Kt/MMI= X-Google-Smtp-Source: APiQypKnygG2Ih9iOxRmckaeF4h4vW0J6PWzlsI5c6WhPutD6Lv/cGXDM5bCnSCd7hXp+MDjHCJiNw== X-Received: by 2002:a05:6512:403:: with SMTP id u3mr2239904lfk.4.1585736698127; Wed, 01 Apr 2020 03:24:58 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.24.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:24:57 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 2/6] mesh: Remove unused 'server' argument Date: Wed, 1 Apr 2020 12:24:58 +0200 Message-Id: <20200401102502.746-3-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/manager.c | 2 +- mesh/prov-initiator.c | 1 - mesh/provision.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/mesh/manager.c b/mesh/manager.c index 0909c7e16..a4c2f2d41 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -256,7 +256,7 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, } - if (!initiator_start(PB_ADV, uuid, 99, 0, 60, add_pending->agent, + if (!initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, add_data_get, add_cmplt, node, add_pending)) { reply = dbus_error(msg, MESH_ERROR_FAILED, "Failed to start provisioning initiator"); diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index 7a767cfb3..d5bae114a 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -817,7 +817,6 @@ static void int_prov_ack(void *user_data, uint8_t msg_num) bool initiator_start(enum trans_type transport, uint8_t uuid[16], uint16_t max_ele, - uint16_t server, /* Only valid for PB-Remote */ uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, mesh_prov_initiator_data_req_func_t get_prov_data, diff --git a/mesh/provision.h b/mesh/provision.h index 755d848a0..d6f6e0ab0 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -118,7 +118,6 @@ void acceptor_cancel(void *user_data); bool initiator_start(enum trans_type transport, uint8_t uuid[16], uint16_t max_ele, - uint16_t server, /* Only valid for PB-Remote */ uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, mesh_prov_initiator_data_req_func_t get_prov_data, From patchwork Wed Apr 1 10:24:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468881 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45CFE17EF for ; Wed, 1 Apr 2020 10:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2458120857 for ; Wed, 1 Apr 2020 10:25:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="FAOyyzZA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732150AbgDAKZB (ORCPT ); Wed, 1 Apr 2020 06:25:01 -0400 Received: from mail-lf1-f54.google.com ([209.85.167.54]:44739 "EHLO mail-lf1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730720AbgDAKZB (ORCPT ); Wed, 1 Apr 2020 06:25:01 -0400 Received: by mail-lf1-f54.google.com with SMTP id 131so641429lfh.11 for ; Wed, 01 Apr 2020 03:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vYAMV5v1hwqkVPZnIXGU7A7cDowgkZ7nZYotsfKt4II=; b=FAOyyzZAuqS4tljVV93j/My5c7dQ0iI9VU5adosCtaWmd4hhvFYzh9JIV2nuFdV4KB 0fYNV6xyNp4uympH/mgYWF+Fx+ye5CYTQuu3PWrzBVSN1Ywixp8TbDJjmH7w2onH7oyj 4PM9zjDHVvyck/knzxbFqccb3gN+LFsmx1hlNMhjAsRByvMKWKn1oMIkR9jH/suoeMt0 9JXsnR/V6zuY6tpYlzmBCULRlOUB3LrFDx0YeNjKEjvIGNG+bd1aJCQSwrUqhJbTDol8 ckcBNoIg3Gd2S30yH9HvaVNePEdJzsePCihqMjxo0IPrtLI+pZ5JjI2qlRKoVBcvMusE Wq+w== 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=vYAMV5v1hwqkVPZnIXGU7A7cDowgkZ7nZYotsfKt4II=; b=Ync5t60MppUTTcOhOa/wscRnnf+GddS9A2trG93mInTN4g2kWcaV1dhq5rds2oCKL+ 8LHALFsNf8UyPgFF86XmWzwWxs8pwcwVYZSdudpCiYKAerp5gS2HJ+pBLnbbZ+yrSMLt e7J5drMWJ267wTEuEZNo46nUAXXHaVfMbrMUJwoILoBwifQhjckmkD6K+0foWLXDiBA9 2E7rSH0JaPFEXFscHHKVli+FZSbzYSumBQQRYDI46bpulX0RCppP8LISMbrqnzp4+aRG KtrQJ2rLJ2zQ1pJ/NDF7YfB5Q3Xa7GY3hXzM9IoXYKCtdl7V598b6Q2nBRg1vtwrgapR Gscw== X-Gm-Message-State: AGi0PuZ26kUgKKreS9iXdgap/8E4z4K0BZrf6uBv4BWmWiZFTLtFLNr3 gcO+SDOdejHuN2Asmd6x1TCKfZhR3Lc= X-Google-Smtp-Source: APiQypIO5QD4gdZLwbIYpQqMAjGd7oJz6LhocEjRyukS5WihCWGTjr1x0xzhRBv9O8jnlEiYyYkkcg== X-Received: by 2002:a05:6512:202d:: with SMTP id s13mr14243275lfs.19.1585736699107; Wed, 01 Apr 2020 03:24:59 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.24.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:24:58 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 3/6] mesh: Clean up naming of provisioning callbacks Date: Wed, 1 Apr 2020 12:24:59 +0200 Message-Id: <20200401102502.746-4-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/prov-initiator.c | 18 +++++++++--------- mesh/provision.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index d5bae114a..f2ebff69e 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -77,10 +77,10 @@ enum int_state { #define MAT_SECRET (MAT_REMOTE_PUBLIC | MAT_LOCAL_PRIVATE) struct mesh_prov_initiator { - mesh_prov_initiator_complete_func_t cmplt; - mesh_prov_initiator_data_req_func_t get_prov_data; + mesh_prov_initiator_complete_func_t complete_cb; + mesh_prov_initiator_data_req_func_t data_req_cb; prov_trans_tx_t trans_tx; - void *agent; + struct mesh_agent *agent; void *caller_data; void *trans_data; struct mesh_node *node; @@ -125,7 +125,7 @@ static void int_prov_close(void *user_data, uint8_t reason) struct mesh_prov_node_info info; if (reason != PROV_ERR_SUCCESS) { - prov->cmplt(prov->caller_data, reason, NULL); + prov->complete_cb(prov->caller_data, reason, NULL); initiator_free(); return; } @@ -135,7 +135,7 @@ static void int_prov_close(void *user_data, uint8_t reason) info.unicast = prov->unicast; info.num_ele = prov->conf_inputs.caps.num_ele; - prov->cmplt(prov->caller_data, PROV_ERR_SUCCESS, &info); + prov->complete_cb(prov->caller_data, PROV_ERR_SUCCESS, &info); initiator_free(); } @@ -738,7 +738,7 @@ static void int_prov_rx(void *user_data, const uint8_t *data, uint16_t len) goto failure; } - if (!prov->get_prov_data(prov->caller_data, + if (!prov->data_req_cb(prov->caller_data, prov->conf_inputs.caps.num_ele)) { l_error("Provisioning Failed-Data Get"); fail_code[1] = PROV_ERR_CANT_ASSIGN_ADDR; @@ -819,7 +819,7 @@ bool initiator_start(enum trans_type transport, uint16_t max_ele, uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, - mesh_prov_initiator_data_req_func_t get_prov_data, + mesh_prov_initiator_data_req_func_t data_req_cb, mesh_prov_initiator_complete_func_t complete_cb, void *node, void *caller_data) { @@ -836,8 +836,8 @@ bool initiator_start(enum trans_type transport, prov->to_secs = timeout; prov->node = node; prov->agent = agent; - prov->cmplt = complete_cb; - prov->get_prov_data = get_prov_data; + prov->complete_cb = complete_cb; + prov->data_req_cb = data_req_cb; prov->caller_data = caller_data; prov->previous = -1; diff --git a/mesh/provision.h b/mesh/provision.h index d6f6e0ab0..43f53f935 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -120,7 +120,7 @@ bool initiator_start(enum trans_type transport, uint16_t max_ele, uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, - mesh_prov_initiator_data_req_func_t get_prov_data, + mesh_prov_initiator_data_req_func_t data_req_cb, mesh_prov_initiator_complete_func_t complete_cb, void *node, void *caller_data); void initiator_prov_data(uint16_t net_idx, uint16_t primary, void *caller_data); From patchwork Wed Apr 1 10:25:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468885 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCC5392C for ; Wed, 1 Apr 2020 10:25:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A14832078B for ; Wed, 1 Apr 2020 10:25:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="EBl+/8Dt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732158AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:44734 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730720AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: by mail-lf1-f46.google.com with SMTP id 131so641467lfh.11 for ; Wed, 01 Apr 2020 03:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=IecFyvJoyjkzMoYy3KC7YwYN0zPf+QMyEtAzUmAo0zQ=; b=EBl+/8DtsUyp+9D615N96ACa7KorAmeeb12yAkvVpGta99Sy/xlAx3mJ80z7Q9CwwC gKk48hx2LjDfcGmASVEj30EbkC1ypwAkxnZ1XiGNOchSzJmpzv4EJ4Qzjawe+DxqkI9n OxqFZpopFPsB9fYHihw2E6u5oK5C/8a9JYmNe6ZbZxawNuyaMppz4o4DMEYjrow1JYHH 0K/hwGREcUsoEf0Nw7KW5othbuTYvRJu7gXyn1dGVEErGYLmL8sScP/qrGGQIW0k4UY3 0m2InofZKKKXxcggoq+Ukmhv7/iVDSk6dVHvAeArNZMZLBDMIzwt4HffUNo3wJHIRNFA GbUQ== 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=IecFyvJoyjkzMoYy3KC7YwYN0zPf+QMyEtAzUmAo0zQ=; b=bAfLRJayhg9M4l/aGL1or+Q5WvSnVWJYbc41bN9U03nNEfekupCSnU70gHJfVSMCCN wOstwlbCnAw/07oP5PZbY4UQLNiWHhmqZ63HkQ+6fOBDTejBWVYKOJMjU4O+Y3mU/U7V kl4atBFB2hGNB+NutsUwh+hJqabNCldz1PoFFYn5OOD7tVWO56WxMcSXefP07h5C9qfY orh6NLhvPyXMq7nfX71cBXYH4Iw+UelA6CfKumm6FkuDnpeLc/3BrG2I7L6eO6VqqItS A5TNSqAisLHYQqRb8VUJbhez5HUQv87muPW2uVivFVlk0vdq0oPG61oWqPjBGmilWVr1 Ei0w== X-Gm-Message-State: AGi0Puadtk/5z8RIHzSEvZ+thtAwJcRA4VsJjnmMrae25HdPHOuM+mVY YapxapEzPqes+Fb4gB/dY6MA0qaKGlY= X-Google-Smtp-Source: APiQypIhHHllmxxXJ0eIGiFXzwSkV/tlyTTE5sCqvt/wG8DwM5vrEmblVF5Wg8RAxL7thfkXyWoVRQ== X-Received: by 2002:a19:6749:: with SMTP id e9mr13668122lfj.122.1585736699987; Wed, 01 Apr 2020 03:24:59 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.24.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:24:59 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 4/6] mesh: Refresh provisioner's capabilities Date: Wed, 1 Apr 2020 12:25:00 +0200 Message-Id: <20200401102502.746-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org As provisioner's capabilities might change during application lifetime (e.g. no network link to download OOB key), let's query the agent again after application calls AddNode(). --- mesh/agent.c | 105 +++++++++++++++++++++++++++++++++++------- mesh/agent.h | 2 + mesh/manager.c | 33 +++++++++---- mesh/prov-initiator.c | 47 +++++++++++++++---- mesh/provision.h | 3 ++ 5 files changed, 154 insertions(+), 36 deletions(-) diff --git a/mesh/agent.c b/mesh/agent.c index 3ab3893a1..02993738c 100644 --- a/mesh/agent.c +++ b/mesh/agent.c @@ -40,7 +40,8 @@ typedef enum { MESH_AGENT_REQUEST_IN_ALPHA, MESH_AGENT_REQUEST_STATIC_OOB, MESH_AGENT_REQUEST_PRIVATE_KEY, - MESH_AGENT_REQUEST_PUBLIC_KEY + MESH_AGENT_REQUEST_PUBLIC_KEY, + MESH_AGENT_REQUEST_CAPABILITIES, } agent_request_type_t; struct agent_request { @@ -158,6 +159,25 @@ static void parse_oob_info(struct mesh_agent_prov_caps *caps, } } +static void parse_properties(struct mesh_agent *agent, + struct l_dbus_message_iter *properties) +{ + const char *key, *uri_string; + struct l_dbus_message_iter variant; + + while (l_dbus_message_iter_next_entry(properties, &key, &variant)) { + if (!strcmp(key, "Capabilities")) { + parse_prov_caps(&agent->caps, &variant); + } else if (!strcmp(key, "URI")) { + l_dbus_message_iter_get_variant(&variant, "s", + &uri_string); + /* TODO: compute hash */ + } else if (!strcmp(key, "OutOfBandInfo")) { + parse_oob_info(&agent->caps, &variant); + } + } +} + static void agent_free(void *agent_data) { struct mesh_agent *agent = agent_data; @@ -193,6 +213,7 @@ static void agent_free(void *agent_data) case MESH_AGENT_REQUEST_VIBRATE: case MESH_AGENT_REQUEST_OUT_NUMERIC: case MESH_AGENT_REQUEST_OUT_ALPHA: + case MESH_AGENT_REQUEST_CAPABILITIES: simple_cb = agent->req->cb; simple_cb(req->user_data, err); default: @@ -235,26 +256,13 @@ struct mesh_agent *mesh_agent_create(const char *path, const char *owner, struct l_dbus_message_iter *properties) { struct mesh_agent *agent; - const char *key, *uri_string; - struct l_dbus_message_iter variant; agent = l_new(struct mesh_agent, 1); - - while (l_dbus_message_iter_next_entry(properties, &key, &variant)) { - if (!strcmp(key, "Capabilities")) { - parse_prov_caps(&agent->caps, &variant); - } else if (!strcmp(key, "URI")) { - l_dbus_message_iter_get_variant(&variant, "s", - &uri_string); - /* TODO: compute hash */ - } else if (!strcmp(key, "OutOfBandInfo")) { - parse_oob_info(&agent->caps, &variant); - } - } - agent->owner = l_strdup(owner); agent->path = l_strdup(path); + parse_properties(agent, properties); + l_queue_push_tail(agents, agent); return agent; @@ -289,13 +297,76 @@ static int get_reply_error(struct l_dbus_message *reply) if (l_dbus_message_is_error(reply)) { l_dbus_message_get_error(reply, &name, &desc); - l_error("Agent failed output action (%s), %s", name, desc); + l_error("Agent failed (%s), %s", name, desc); return MESH_ERROR_FAILED; } return MESH_ERROR_NONE; } +static void properties_reply(struct l_dbus_message *reply, void *user_data) +{ + struct mesh_agent *agent = user_data; + struct agent_request *req; + mesh_agent_cb_t cb; + struct l_dbus_message_iter properties; + int err; + + if (!l_queue_find(agents, simple_match, agent) || !agent->req) + return; + + req = agent->req; + + err = get_reply_error(reply); + + if (err != MESH_ERROR_NONE) + goto fail; + + if (!l_dbus_message_get_arguments(reply, "a{sv}", &properties)) { + err = MESH_ERROR_FAILED; + goto fail; + } + + parse_properties(agent, &properties); +fail: + if (req->cb) + { + cb = req->cb; + cb(req->user_data, err); + } + + l_dbus_message_unref(req->msg); + l_free(req); + agent->req = NULL; +} + +void mesh_agent_refresh(struct mesh_agent *agent, mesh_agent_cb_t cb, + void *user_data) +{ + struct l_dbus *dbus = dbus_get_bus(); + struct l_dbus_message *msg; + struct l_dbus_message_builder *builder; + + agent->req = create_request(MESH_AGENT_REQUEST_CAPABILITIES, (void *)cb, + user_data); + + msg = l_dbus_message_new_method_call(dbus, agent->owner, agent->path, + L_DBUS_INTERFACE_PROPERTIES, + "GetAll"); + + builder = l_dbus_message_builder_new(msg); + l_dbus_message_builder_append_basic(builder, 's', + MESH_PROVISION_AGENT_INTERFACE); + l_dbus_message_builder_finalize(builder); + l_dbus_message_builder_destroy(builder); + + l_dbus_send_with_reply(dbus_get_bus(), msg, properties_reply, agent, + NULL); + + agent->req->msg = l_dbus_message_ref(msg); +} + + static void simple_reply(struct l_dbus_message *reply, void *user_data) { struct mesh_agent *agent = user_data; diff --git a/mesh/agent.h b/mesh/agent.h index 80333acd5..6cc3d0f71 100644 --- a/mesh/agent.h +++ b/mesh/agent.h @@ -42,6 +42,8 @@ void mesh_agent_init(void); void mesh_agent_cleanup(void); struct mesh_agent *mesh_agent_create(const char *path, const char *owner, struct l_dbus_message_iter *properties); +void mesh_agent_refresh(struct mesh_agent *agent, mesh_agent_cb_t cb, + void *user_data); void mesh_agent_remove(struct mesh_agent *agent); void mesh_agent_cancel(struct mesh_agent *agent); diff --git a/mesh/manager.c b/mesh/manager.c index a4c2f2d41..9ec4a1468 100644 --- a/mesh/manager.c +++ b/mesh/manager.c @@ -81,6 +81,9 @@ static void free_pending_add_call() l_dbus_remove_watch(dbus_get_bus(), add_pending->disc_watch); + if (add_pending->msg) + l_dbus_message_unref(add_pending->msg); + l_free(add_pending); add_pending = NULL; } @@ -212,6 +215,23 @@ static bool add_data_get(void *user_data, uint8_t num_ele) return true; } +static void add_start(void *user_data, int err) +{ + struct l_dbus_message *reply; + + l_info("Start callback"); + + if (err == MESH_ERROR_NONE) + reply = l_dbus_message_new_method_return(add_pending->msg); + else + reply = dbus_error(add_pending->msg, MESH_ERROR_FAILED, + "Failed to start provisioning initiator"); + + l_dbus_send(dbus_get_bus(), reply); + + add_pending->msg = NULL; +} + static struct l_dbus_message *add_node_call(struct l_dbus *dbus, struct l_dbus_message *msg, void *user_data) @@ -243,6 +263,7 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, /* Invoke Prov Initiator */ add_pending = l_new(struct add_data, 1); + add_pending->msg = l_dbus_message_ref(msg); memcpy(add_pending->uuid, uuid, 16); add_pending->node = node; add_pending->agent = node_get_agent(node); @@ -255,20 +276,14 @@ static struct l_dbus_message *add_node_call(struct l_dbus *dbus, goto fail; } - - if (!initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, - add_data_get, add_cmplt, node, add_pending)) { - reply = dbus_error(msg, MESH_ERROR_FAILED, - "Failed to start provisioning initiator"); - goto fail; - } + initiator_start(PB_ADV, uuid, 99, 60, add_pending->agent, add_start, + add_data_get, add_cmplt, node, add_pending); add_pending->disc_watch = l_dbus_add_disconnect_watch(dbus, node_get_owner(node), prov_disc_cb, NULL, NULL); - return l_dbus_message_new_method_return(msg); - + return NULL; fail: l_free(add_pending); add_pending = NULL; diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index f2ebff69e..17bda6521 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -36,6 +36,7 @@ #include "mesh/pb-adv.h" #include "mesh/mesh.h" #include "mesh/agent.h" +#include "mesh/error.h" /* Quick size sanity check */ static const uint16_t expected_pdu_size[] = { @@ -77,6 +78,7 @@ enum int_state { #define MAT_SECRET (MAT_REMOTE_PUBLIC | MAT_LOCAL_PRIVATE) struct mesh_prov_initiator { + mesh_prov_initiator_start_func_t start_cb; mesh_prov_initiator_complete_func_t complete_cb; mesh_prov_initiator_data_req_func_t data_req_cb; prov_trans_tx_t trans_tx; @@ -102,6 +104,7 @@ struct mesh_prov_initiator { uint8_t private_key[32]; uint8_t secret[32]; uint8_t rand_auth_workspace[48]; + uint8_t uuid[16]; }; static struct mesh_prov_initiator *prov = NULL; @@ -814,17 +817,45 @@ static void int_prov_ack(void *user_data, uint8_t msg_num) } } +static void initiator_open_cb(void *user_data, int err) +{ + bool result; + + if (!prov) + return; + + if (err != MESH_ERROR_NONE) + goto fail; + + /* Always register for PB-ADV */ + result = pb_adv_reg(true, int_prov_open, int_prov_close, int_prov_rx, + int_prov_ack, prov->uuid, prov); + + if (!result) { + err = MESH_ERROR_FAILED; + goto fail; + } + + if (!prov) + return; + + prov->start_cb(prov->caller_data, MESH_ERROR_NONE); + return; +fail: + prov->start_cb(prov->caller_data, err); + initiator_free(); +} + bool initiator_start(enum trans_type transport, uint8_t uuid[16], uint16_t max_ele, uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, + mesh_prov_initiator_start_func_t start_cb, mesh_prov_initiator_data_req_func_t data_req_cb, mesh_prov_initiator_complete_func_t complete_cb, void *node, void *caller_data) { - bool result; - /* Invoked from Add() method in mesh-api.txt, to add a * remote unprovisioned device network. */ @@ -837,19 +868,15 @@ bool initiator_start(enum trans_type transport, prov->node = node; prov->agent = agent; prov->complete_cb = complete_cb; + prov->start_cb = start_cb; prov->data_req_cb = data_req_cb; prov->caller_data = caller_data; prov->previous = -1; + memcpy(prov->uuid, uuid, 16); - /* Always register for PB-ADV */ - result = pb_adv_reg(true, int_prov_open, int_prov_close, int_prov_rx, - int_prov_ack, uuid, prov); - - if (result) - return true; + mesh_agent_refresh(prov->agent, initiator_open_cb, prov); - initiator_free(); - return false; + return true; } void initiator_cancel(void *user_data) diff --git a/mesh/provision.h b/mesh/provision.h index 43f53f935..1d78ed8e2 100644 --- a/mesh/provision.h +++ b/mesh/provision.h @@ -100,6 +100,8 @@ typedef bool (*mesh_prov_acceptor_complete_func_t)(void *user_data, uint8_t status, struct mesh_prov_node_info *info); +typedef void (*mesh_prov_initiator_start_func_t)(void *user_data, int err); + typedef bool (*mesh_prov_initiator_data_req_func_t)(void *user_data, uint8_t num_elem); @@ -120,6 +122,7 @@ bool initiator_start(enum trans_type transport, uint16_t max_ele, uint32_t timeout, /* in seconds from mesh.conf */ struct mesh_agent *agent, + mesh_prov_initiator_start_func_t start_cb, mesh_prov_initiator_data_req_func_t data_req_cb, mesh_prov_initiator_complete_func_t complete_cb, void *node, void *caller_data); From patchwork Wed Apr 1 10:25:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468889 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9222392C for ; Wed, 1 Apr 2020 10:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703A520787 for ; Wed, 1 Apr 2020 10:25:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="bkVh2R2f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732169AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: from mail-lf1-f51.google.com ([209.85.167.51]:45111 "EHLO mail-lf1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732154AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: by mail-lf1-f51.google.com with SMTP id v4so19941866lfo.12 for ; Wed, 01 Apr 2020 03:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DygyTHIv6tTK38tMsaaq2FSgilJWE1kf4cxPQwtvpCU=; b=bkVh2R2fccPBtzJCBgY2jAaP9PtIyXmNLNu9AVDdZ5EUnOOB0e86/HpySfBXzW+fFD VRj7XgBagmHoADG6u4SMsjaYCL6J2jnU0szdZLWwaTaEpeHIkQG+5CjgTbq+Wu8zENIs /D6yrtiN0t9rWhDNglG9vFGqT80Wqsazw6dbX+d4IIekbbPMiIZcBcpVV1HTRsU5dZAJ dM7/aEu76W1ie37erph6vpVzVVDgrC/Wwa59VLbwvNJvfvpAtMYCgxj79avAv9/FVajz 8wk6lWjaDxqhruT80UXLKulcIbuadV/2y78+4t/NpF4O0iTIvUDGUN2JzUCEEdZdiKzI S3zw== 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=DygyTHIv6tTK38tMsaaq2FSgilJWE1kf4cxPQwtvpCU=; b=Xipj62obMqIe/nbRtu4gio+T/MDz+rGrlXYpl2Yz07sX/438AQ1ptBP6OS12ku8lcM 8dqIPooceNhCdepVTXBmgboErwIFArrf1MW6Svk3/bHN3unifu7mj0lmUOJet/GDAmol rARGpQGtslP1Ky614sfD+lUhUes24+WhfpziMtr9MPHIUq0pzOwb7p60uBMBd6odCEME TyT1Ck+0tHW8d1nEdn0bTA+yeU028hKy5bjWnR+bbiAj9Pe31R2OJuvOn1rdsmQiV31z w1VAREzRgLyTufRbSMlAh5T+NDn/lJlQiGeZre82brVRKjGprMs+BBT0kLkYwuBNjwLM 8Wmg== X-Gm-Message-State: AGi0Pua3jKoB8JoasTTW8wJlqzPkblXFGqXN7gq+oLSn1cCfys4n6u1v byMgHuSxrezRpwbdi+llZHmY2Pv5/FA= X-Google-Smtp-Source: APiQypK/B86ixQM+rShyKe+ToEvSoq/o4xsQtxHvhJ3QYCD8r9eZ9IXG6bVuZJyxU8YM4trkfRdY8w== X-Received: by 2002:ac2:51de:: with SMTP id u30mr990793lfm.170.1585736700862; Wed, 01 Apr 2020 03:25:00 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.25.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:25:00 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 5/6] mesh: Honor provisioner's capabilities Date: Wed, 1 Apr 2020 12:25:01 +0200 Message-Id: <20200401102502.746-6-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch makes the daemon select authentication method based from capabilities supported by both provisioned node and provisioner application. --- mesh/prov-initiator.c | 82 ++++++++++++++++++++++++++---------------- tools/mesh-cfgclient.c | 7 ++++ 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index 17bda6521..8d523e9c0 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -38,6 +38,8 @@ #include "mesh/agent.h" #include "mesh/error.h" +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + /* Quick size sanity check */ static const uint16_t expected_pdu_size[] = { 2, /* PROV_INVITE */ @@ -587,6 +589,44 @@ failure: int_prov_close(prov, fail_code[1]); } +static void int_prov_start_auth(const struct mesh_agent_prov_caps *prov_caps, + const struct mesh_net_prov_caps *dev_caps, + struct prov_start *start) +{ + uint8_t pub_type = prov_caps->pub_type & dev_caps->pub_type; + uint8_t static_type = prov_caps->static_type & dev_caps->static_type; + uint16_t output_action = prov_caps->output_action & + L_BE16_TO_CPU(dev_caps->output_action); + uint8_t output_size = MIN(prov_caps->output_size, + dev_caps->output_size); + uint16_t input_action = prov_caps->input_action & + L_BE16_TO_CPU(dev_caps->input_action); + uint8_t input_size = MIN(prov_caps->input_size, dev_caps->input_size); + + if (pub_type) + start->pub_key = 0x01; + + /* Parse OOB Options, prefer static, then out, then in */ + if (static_type) { + start->auth_method = 0x01; + return; + } + + if(output_size && output_action) { + start->auth_method = 0x02; + start->auth_action = u16_high_bit(output_action); + start->auth_size = MIN(output_size, 8); + return; + } + + if (input_size && input_action) { + start->auth_method = 0x03; + start->auth_action = u16_high_bit(input_action); + start->auth_size = MIN(input_size, 8); + return; + } +} + static void int_prov_rx(void *user_data, const uint8_t *data, uint16_t len) { struct mesh_prov_initiator *rx_prov = user_data; @@ -638,43 +678,23 @@ static void int_prov_rx(void *user_data, const uint8_t *data, uint16_t len) goto failure; } - /* If Public Key available Out of Band, use it */ - if (prov->conf_inputs.caps.pub_type) { - prov->conf_inputs.start.pub_key = 0x01; + /* + * Select auth mechanism from methods supported by both + * parties. + */ + int_prov_start_auth(mesh_agent_get_caps(prov->agent), + &prov->conf_inputs.caps, + &prov->conf_inputs.start); + + if (prov->conf_inputs.start.pub_key == 0x01) { prov->expected = PROV_CONFIRM; /* Prompt Agent for remote Public Key */ mesh_agent_request_public_key(prov->agent, pub_key_cb, prov); - /* Nothing else for us to do now */ } else prov->expected = PROV_PUB_KEY; - /* Parse OOB Options, prefer static, then out, then in */ - if (prov->conf_inputs.caps.static_type) { - - prov->conf_inputs.start.auth_method = 0x01; - - } else if (prov->conf_inputs.caps.output_size && - prov->conf_inputs.caps.output_action) { - - prov->conf_inputs.start.auth_method = 0x02; - prov->conf_inputs.start.auth_action = - u16_high_bit(l_get_be16(data + 6)); - prov->conf_inputs.start.auth_size = - (data[5] > 8 ? 8 : data[5]); - - } else if (prov->conf_inputs.caps.input_size && - prov->conf_inputs.caps.input_action) { - - prov->conf_inputs.start.auth_method = 0x03; - prov->conf_inputs.start.auth_action = - u16_high_bit(l_get_be16(data + 9)); - prov->conf_inputs.start.auth_size = - (data[8] > 8 ? 8 : data[8]); - - } - out = l_malloc(1 + sizeof(prov->conf_inputs.start)); out[0] = PROV_START; memcpy(out + 1, &prov->conf_inputs.start, @@ -789,7 +809,7 @@ static void int_prov_ack(void *user_data, uint8_t msg_num) switch (prov->state) { case INT_PROV_START_SENT: prov->state = INT_PROV_START_ACKED; - if (prov->conf_inputs.caps.pub_type == 0) + if (!prov->conf_inputs.start.pub_key) send_pub_key(prov); break; @@ -798,7 +818,7 @@ static void int_prov_ack(void *user_data, uint8_t msg_num) break; case INT_PROV_KEY_SENT: - if (prov->conf_inputs.caps.pub_type == 1) + if (prov->conf_inputs.start.pub_key) int_prov_auth(); break; diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 43588852b..6083b2b1f 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -617,6 +617,13 @@ static bool register_agent(void) return false; } + if (!l_dbus_object_add_interface(dbus, app.agent_path, + L_DBUS_INTERFACE_PROPERTIES, NULL)) { + l_error("Failed to add interface %s", + L_DBUS_INTERFACE_PROPERTIES); + return false; + } + return true; } From patchwork Wed Apr 1 10:25:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= X-Patchwork-Id: 11468887 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5504817EF for ; Wed, 1 Apr 2020 10:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 343352080C for ; Wed, 1 Apr 2020 10:25:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="ui+D+d7L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732166AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:33482 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732146AbgDAKZE (ORCPT ); Wed, 1 Apr 2020 06:25:04 -0400 Received: by mail-lf1-f46.google.com with SMTP id x200so12816079lff.0 for ; Wed, 01 Apr 2020 03:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=r3KIKeOoCXTzCSOwCnlRZi5CXO6ooZd8wIikiuhvKRk=; b=ui+D+d7L3Gez0LsxDdnjkAllAvmleueRmEwwCFOCFvI5lNTuY/Cj0L4W3WIJMaH+oe r94JEBsUg7/Ok1DUcIHcv3ABe8YUY32wR713KCNpSS1cEVxYFQj/ibRntyYPgx7X6aLk lrxKnrRh31D2vdyr6rFvAtzkfwwXn7FbS3KGpwKLoWzM77/4lA/d+DRlbF9oywjMPlmA uu8czFgkQ35hKPfVOVh6F2V1CreQsoEkdxceZj/y6YunXcXMVIGBYAjbZZ7C1gEwuKkX V9oejSarf1g2xTmGfC52BUeWfudTHhjgbBf4H+U171DEXfrREFFmyZkHllmLbKc2EmK/ ecMQ== 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=r3KIKeOoCXTzCSOwCnlRZi5CXO6ooZd8wIikiuhvKRk=; b=KaCZkJTxrsXsalVzq7ZOl8g2X0KUw9cmojcZbfPEjjSXWaz8ol4qK4A6XNOCXP1tZO mYkf0FLmv2WAp4BZm415b+bcx7giAP5Yh/GQkZmYZY+x4B2oDHZpBp8iKxr3MBU76RD2 rzynqtCVCqdwQd2tQhQTUZvY0FjcNKMgO12Jwm8aXSwfNO35MimmiIHa/JgKjqgxqiCI 7kw29UnPvA+umXjJ0EPZFofcwCu5gF67yAWJ3u2wwPAYbFkWun6+V6DPpf9KExcfaUd4 JivRVAvKLktgRjzmrMbRSnjq/JQi2xDaYJdZZ6s8eSXrMl3KC8a1g6TojiszTiVKbbxK s4rw== X-Gm-Message-State: AGi0PuZcstJDr5d2qz3mQzzqOqSMb2E28sDBOpq3BYPpuR/ImaVt20eQ LlUgE9r6cezAYDJBLYmtdQ9EYjeXo90= X-Google-Smtp-Source: APiQypKiN+wvgVJIbOgtRkNMTrdl16j1UyX8eSwivDHbRiGAD+Q8ffr6nsIIk66ldit7lt3/B7zoWg== X-Received: by 2002:ac2:4342:: with SMTP id o2mr14117163lfl.195.1585736701939; Wed, 01 Apr 2020 03:25:01 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id r16sm922217ljj.40.2020.04.01.03.25.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 03:25:01 -0700 (PDT) From: =?utf-8?q?Micha=C5=82_Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 6/6] doc/mesh-api: OOB Information field is 16 bit, not 32 Date: Wed, 1 Apr 2020 12:25:02 +0200 Message-Id: <20200401102502.746-7-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> References: <20200401102502.746-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- doc/mesh-api.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt index 848106335..513b021d8 100644 --- a/doc/mesh-api.txt +++ b/doc/mesh-api.txt @@ -950,7 +950,7 @@ Object path freely definable The data parameter is a variable length byte array, that may have 1, 2 or 3 distinct fields contained in it including the 16 - byte remote device UUID (always), a 32 bit mask of OOB + byte remote device UUID (always), a 16 bit mask of OOB authentication flags (optional), and a 32 bit URI hash (if URI bit set in OOB mask). Whether these fields exist or not is a decision of the remote device.