Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1844477pxu; Tue, 24 Nov 2020 10:11:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7jDBfu1WLBZu+VxRJLwGiYoTUaZCTmBT1P9Ii8zPzb1HkWHa64UHgDZ8JJ0D0xdcVpFmS X-Received: by 2002:a17:906:8541:: with SMTP id h1mr5054932ejy.445.1606241474369; Tue, 24 Nov 2020 10:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606241474; cv=none; d=google.com; s=arc-20160816; b=oeQJo/ZO2C3pdtSCgMCfuLnvMeeVucFXE8Kh/OrkJKZbGR4zPW8R3b/QKwtc2gzYy+ K/TUSbUvXMc9zykKFofoqrLxgFjzrxeBsBef8/3pJwbIz1MFQt+02tdPfa0mqVt5h7VK 80tfdaeSOtaZUpYoCvLF2eV0LkMgkpklCVD8pCbQ5fVC9LMQRksOsJSIHrW4XHqufeFq y43v9Zl4wGXe1Oo7x3ZOzDtmSsGQzqDuIA5s3qr2D/B7wmPGlr4JLScadTC1mxOeJapm 1AAtCFY7CHz4D1v+8lDn7NHeX4OJDmeWsh58IeKyJATH/ichRvaDGTTFP+VwaRRU6Nx3 NSrw== 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=ugBjHs8qLQMChRHRG7+A3K4v2J2RLx38B7emQOjbJo8=; b=CIdYp5odftbKD40LU1FcGnuAE0egdCJEWawr1CArQi+SJuKeyhnCPQz2vQhOdtJhN+ jnVR7MqjV+uiSZv2cyxInub7SI18BWhEmrBkIl2AlvRCo0ObGGhUlBrrPxHwKNYsMOyq Zgu92ijnS95HVq8a+Dp/VrCI0hDh09k5hVvVMRWD7L4Eer05W8jTvxPPWF4v3SYF+JKi 8wAj9kKya1L6YEnqENyLbW3+TKHMYVpsX9gZwRzES/i6aVUvfjKqgdSv613Rfz8ywdMB wbc83vlPxCulxGVUFjUg1azEkq6QPRuD4P4RE7LWGkMw72E+fsDABEjIYsWKueX5tuyy DgPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kAk7zpej; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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 op9si8735037ejb.447.2020.11.24.10.10.50; Tue, 24 Nov 2020 10:11:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-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=kAk7zpej; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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 S2404231AbgKXSIU (ORCPT + 99 others); Tue, 24 Nov 2020 13:08:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404220AbgKXSHx (ORCPT ); Tue, 24 Nov 2020 13:07:53 -0500 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98761C0613D6 for ; Tue, 24 Nov 2020 10:07:53 -0800 (PST) Received: by mail-qt1-x84a.google.com with SMTP id o1so16793140qtp.7 for ; Tue, 24 Nov 2020 10:07: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=ugBjHs8qLQMChRHRG7+A3K4v2J2RLx38B7emQOjbJo8=; b=kAk7zpejlXea9eHTXlou0iTVDqjH1/CCr1DU06i0EEuuCGqlb4qgAtTzGo/amDke1c raRfU4kKXPcIgwinghEc1v0zIdEW1dgH4O2S8op6//kEJuVy+PVfcrQ0PxStQv3HilaM U7DmacelpbBpbexeeIsE2R53F3AIQEw9s7H6jkyMv8pcJaM80oflSGLweRdIMgwo/LNM gPiwVGMFWGK0n5fG2qlfJqmK4K33uSXRq3H5ihCyKlPmo4eNBY93XAPc5txrzT1DPSVe wJgYkgehdRHPjrubjyzWBLzWW6CMg/P1jep/2Dq/sNf1KFhbwkat9UZ4AoTyhvP5D/Lv WPqA== 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=ugBjHs8qLQMChRHRG7+A3K4v2J2RLx38B7emQOjbJo8=; b=V6dg890lhm2DEjDeJhrCG9SyIAz8uiuUqcwKFjs1usY0nXzwt5i2AHtrdGwdYNkt1C ZW+6M4NIJHkYm64kUFQtBWiSVZ0EKLNwwIEkew7J1CtO8247LTLm2mk46+fflpxtjeSj /9inBbt+wkm83FxGO3/kNTi6B6eI5QWUapJYF1STXVv/xM2F2LDBXgovSIm4Td3rjF14 HC1GdosoF/bhmZyW5LLhMZr1Gn1Asvw7kzw/X8nIV82xEVAZEPIgRLr+MCeYVLD0xsX8 V2X4F+ZkOFhf0G/IbOcXf41XSPPI0LCh4q354yTUH4SDJ3pCGtA/ET6yoPpTDIO0ghsj +jLw== X-Gm-Message-State: AOAM5322zfVANz6HAxO+8geG7pRMZp1G4rPqksUUR5vfNuwCEqYMXUhk hmFNGWzFkWmhf2Q0mUEvymjJdWZCNzHvxSqHtUiC 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:a25:7711:: with SMTP id s17mr9337263ybc.240.1606241272796; Tue, 24 Nov 2020 10:07:52 -0800 (PST) Date: Tue, 24 Nov 2020 10:07:42 -0800 In-Reply-To: <20201124180746.1773091-1-danielwinkler@google.com> Message-Id: <20201124100610.v5.1.I5f4fa6a76fe81f977f78f06b7e68ff1c76c6bddf@changeid> Mime-Version: 1.0 References: <20201124180746.1773091-1-danielwinkler@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v5 1/5] Bluetooth: Add helper to set adv data From: Daniel Winkler To: marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.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-bluetooth@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 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