Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3996991pxu; Mon, 30 Nov 2020 15:14:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1D7gUn9HgyksZCKL0zokuUshDvjhPy4jukaaYNjjGOfay8Skx/09sBJQkEft/XgQfRCMX X-Received: by 2002:a17:906:7813:: with SMTP id u19mr133245ejm.153.1606778078201; Mon, 30 Nov 2020 15:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606778078; cv=none; d=google.com; s=arc-20160816; b=bBNO+U4JEDacvHkGuGgm1mnowX4hrreCYfUTgetFb8oKteg1w+iHBYzuCpdYMCC1Dd jWoRGtW9UDIi7EAfqYHpeCytXrYTLoNTxkFazKIMEYOjPVDaXyT5idtIqHCTqh4tSQPn A09SpI987b2JxfMDYaeUgqzfpHbxrZhW2wnH/q4J0qD/MgPmxqO4t8FrR5rne9h6+v4I W94dT5cAecxmce+AgJlxDpTRaMQzeTe0bN8EpWPn6Tn63wHrMu6iAdDw4Ya1gvIdFffk hAxu/SoVxvIY8cUncmTZ2WNO1wK+aH6FepuooT38DF/Mhvgk1wmSUvdpgPXyKbNVGIyP kpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=1eLB70/LoA1JAyrb2lCBaA7M2noAwc2Ppo14iel1jO4=; b=VXB5hKpbYIDWSs7RWWpmi31pVSrSznP7Z3nZO76Fe8+1Ql7dQn0Z7hCF1wyyf/nPTJ 5zqi07myC0/N2ok/ULSGuhFGc6AuzYFA4FWaAOFa2hv4T0emEqBXEyjuyTEfTncNbhOq ywrRhb5WLdpksh7hlT7wFq5oXrsj5C1tVq4gaaA9i/fmszovedkltwMKkG4xheX3PG/F 0w83pwp5xpd6/JW/5IZNJKWIGE3yWRoLJG4Un9n1mKNgVBa5HMXFNXVY7HAiPpXnqtLY VYHctcpn5lHnJqCWH3FfgSiV8Qt9m6ANMTL2e28BlmJycMkdF07D4oLa8RTA8tBoS0oI 9QpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IVnWNURy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si12868785edz.214.2020.11.30.15.14.15; Mon, 30 Nov 2020 15:14:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20161025 header.b=IVnWNURy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388821AbgK3W7I (ORCPT + 99 others); Mon, 30 Nov 2020 17:59:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388810AbgK3W7F (ORCPT ); Mon, 30 Nov 2020 17:59:05 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B95C061A4D for ; Mon, 30 Nov 2020 14:57:53 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id v9so9490329qtw.12 for ; Mon, 30 Nov 2020 14:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=1eLB70/LoA1JAyrb2lCBaA7M2noAwc2Ppo14iel1jO4=; b=IVnWNURySqY21sL04MVvJPfOk+APOINXesF2PUz/uH+sUy23zlAucl1SDd6BV2/weG UN/+fDqbrsj8fXrpXh18tnD9xS9bGE0+Arg0nJsAgMXTJn5sayfhJbj3t1dw7ffF9p7j PH7goQbaYpf6BdDKfs3gT4BCTuK9o1llE4iU5SDYZuUl9sRVhD+ERtFIfgw5F34LOvx3 935ocqPA1zj+sebyeyMfOcb6rD08vC9Dgnm1l1izLePhliQXYxPIjKPooKqBRRre2XkM 8QUN30kLWd854Vz3fYlrX12KDHJtUptA2zlCeoZIdiiXP0xqmgyGnYbk+rEFxBuBU1uv hjjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1eLB70/LoA1JAyrb2lCBaA7M2noAwc2Ppo14iel1jO4=; b=V5WmAGPW2K3z4zvKwsZPWVfyyFWZRAPqEjyuCPFDcTjyHNcp/gnXrqkmJR5blJXnNd tWgRfyCNYfRAkKXUKoTPCeQ/DxQXEzGsTIBtboeyYGQPdzXspAF+WsN7BNRb14k975S+ f51nibykeNH7nnbQUuPk9u/+uX8fPAcuTBEC+IUnGYysZsYT56blTspYDibPYXskeH+q 5qHKN+frtlM+Ev/VZVa8QT5oijM5UoGE4xUCaH55WBqB29w3P+NBNPEyCFEWepHt9dnm XAqGM2NisrRtVryW7vn8vy1KwEqu6118HXTRtT/X1u5AzQzAWvrIvMe6MHlpWXVBVPYL +zbg== X-Gm-Message-State: AOAM531bNQEKvwnZwsaBwQm6Wppzfgb74hiB7SBOpTuXBDBhnLBiR1J1 jtyCuq5eQYcSDhwlR4pxsE7tZYI4LDNVSLAqJ69g Sender: "danielwinkler via sendgmr" X-Received: from danielwinkler-linux.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:4e59]) (user=danielwinkler job=sendgmr) by 2002:a05:6214:5cd:: with SMTP id t13mr25217023qvz.56.1606777072329; Mon, 30 Nov 2020 14:57:52 -0800 (PST) Date: Mon, 30 Nov 2020 14:57:40 -0800 In-Reply-To: <20201130225744.3793244-1-danielwinkler@google.com> Message-Id: <20201130145609.v6.1.I5f4fa6a76fe81f977f78f06b7e68ff1c76c6bddf@changeid> Mime-Version: 1.0 References: <20201130225744.3793244-1-danielwinkler@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v6 1/5] Bluetooth: Add helper to set adv data From: Daniel Winkler To: marcel@holtmann.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Daniel Winkler , Sonny Sasaka , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We wish to handle advertising data separately from advertising parameters in our new MGMT requests. This change adds a helper that allows the advertising data and scan response to be updated for an existing advertising instance. Reviewed-by: Sonny Sasaka Signed-off-by: Daniel Winkler --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None include/net/bluetooth/hci_core.h | 3 +++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9873e1c8cd163b..300b3572d479e1 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1291,6 +1291,9 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, u16 adv_data_len, u8 *adv_data, u16 scan_rsp_len, u8 *scan_rsp_data, u16 timeout, u16 duration); +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data); int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance); void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 502552d6e9aff3..35afb63514f38b 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3005,6 +3005,37 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, return 0; } +/* This function requires the caller holds hdev->lock */ +int hci_set_adv_instance_data(struct hci_dev *hdev, u8 instance, + u16 adv_data_len, u8 *adv_data, + u16 scan_rsp_len, u8 *scan_rsp_data) +{ + struct adv_info *adv_instance; + + adv_instance = hci_find_adv_instance(hdev, instance); + + /* If advertisement doesn't exist, we can't modify its data */ + if (!adv_instance) + return -ENOENT; + + if (adv_data_len) { + memset(adv_instance->adv_data, 0, + sizeof(adv_instance->adv_data)); + memcpy(adv_instance->adv_data, adv_data, adv_data_len); + adv_instance->adv_data_len = adv_data_len; + } + + if (scan_rsp_len) { + memset(adv_instance->scan_rsp_data, 0, + sizeof(adv_instance->scan_rsp_data)); + memcpy(adv_instance->scan_rsp_data, + scan_rsp_data, scan_rsp_len); + adv_instance->scan_rsp_len = scan_rsp_len; + } + + return 0; +} + /* This function requires the caller holds hdev->lock */ void hci_adv_monitors_clear(struct hci_dev *hdev) { -- 2.29.2.454.gaff20da3a2-goog