Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp328446pxu; Wed, 14 Oct 2020 02:23:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQums6xyW9Khq8laV8Uof7qBdE9IHAfnjLxPkh2/+RvUOUJSnt9R0/PusbDzWUlN3A5Tuo X-Received: by 2002:a50:ef12:: with SMTP id m18mr4144133eds.313.1602667385631; Wed, 14 Oct 2020 02:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602667385; cv=none; d=google.com; s=arc-20160816; b=DCNjKOpsOquGDcy/wZn8qE7vUn3tkgRxFbUxPmODejx0jrRq+KQO68DWyFUVXMS+pw 9/Ib/WqW+V7jW2YcyxK6bwm75X/VsUvOM1fvtTlxWHALuX880EZrz95w6QNxbaS/PoRn +DdAo75XXxffwX4fqHyYF4xQBaQRT9QDRKUDDhjOX1VM4Dm7r51oWZNyya/gQUlY7fH4 /Rfgl4atkpEPRoWb9/LZ4yu+dwOvLIz5g0PYE12LiJO2N0cm6rJbcIi9ueKF8UFSU0CT NUYLI6ETLezJqJbOFeIn//DuoB8rKVwbfK5bD+oN4ZR+SMIFX4gVnT2BBvaleHFH2iNI q2eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oY+WpNPdUU2YB9GoxXL00jTxAVM7ebz/LhxA6RTa66c=; b=XD8vPkKbaK/TLhK41Ki8z9V3RAF+qvGXCh7mkwl3YLSq4+sx1gzwzJXLNPGRIjTQbj N1h0WLrF/8/gOUdCI3Ld3i1nZ6M/YSUOQ1RCdPDrHtQC7N5yetk7O5HKQJeOOEKaYz0f BrXCXtERgVz6e2JZuxzWLL1PEYH+CkJ2j2qHiu5geTcTs2PKyWrIjeRMo5toPFTTOh7t 03yKgXZEEq7TIupyacmIwgdB17rgfEbksdDtWuaQPoPlrN7rbkcKKMbpqKz1W4hHrtF/ YsxvSNKAMeX685bfm5SNMFfJZJRUHKG+ESyjPglw33YFXJPnkJ4lY+rp9pMIKootxfkW 8cUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b6AOGZiE; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si2462836edi.24.2020.10.14.02.22.40; Wed, 14 Oct 2020 02:23:05 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=b6AOGZiE; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgJNJUS (ORCPT + 99 others); Wed, 14 Oct 2020 05:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730747AbgJNJUJ (ORCPT ); Wed, 14 Oct 2020 05:20:09 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB14C08EBB3 for ; Tue, 13 Oct 2020 16:45:38 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id t15so1807459otk.0 for ; Tue, 13 Oct 2020 16:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oY+WpNPdUU2YB9GoxXL00jTxAVM7ebz/LhxA6RTa66c=; b=b6AOGZiE7KwaWXtz7PlErs09see45bH2GErOUMPJuHxV/4hyipHQS/O4tokqZcvU// xRAnh+3JbMwm4kXbjWttnIx7AUIAYUqBwMPVPA9dYjD0xHekViZQKUB1QEfl5xNpzRML axQDMPFpxScS8x+Tl5Bvo32p5fZGnccrjhtXn1vG2K+1x3kZU2WEwYekAKLRbcYA8KFT Qfiwiq4HuqHi/Aoq5bARZkixeHu/8icPXddeGS601SSLxcKd9TpJbUaZ9wc6s+heGRM2 XnE9+uUAyWzqtILMCi/c2Tq7fl97jy+nmKJAp64bm4G0oAHXIw9wnDne2qfKbloI1qkU sDYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oY+WpNPdUU2YB9GoxXL00jTxAVM7ebz/LhxA6RTa66c=; b=VqC/My3N8dvM3nINjL9aG16mO+/SsGzUJZMMcGXTEKdIX3kA1knrxU06AQLlkHSAWW t25pe9pq6Q+pV3rEoYUMqwxaXFt1eanFl7WLAdaDVR1UAHkNyA+KUoVHIBu+DTsN2TqP 7eSiX4xf0E+bRkcZ4fIGQsz+HLA3tVnKyz8uPlxVNv9OApaXpdn6gnBRud1Py5ubJIWe mgbTN5r/s4XaW4yHLiXztVFm39EGd3P5K7i0V/L2E3POrWXib/jIj2oVGFhy3UeQbMfm JP1GuRCVlXixO+R0PgJAaBxBK/Uh5HllEGmKi4NqGMRqvznr8mRRL8aghQPHqj94x8Ze xZkA== X-Gm-Message-State: AOAM532licu3H2Js1RJQ6o7CKDZJEvIH2JNs0Lk306ymRVKyxRture88 QY+zlWYpwxySjomA5y2b1Oh4aDtXKC4HlyNiV7c= X-Received: by 2002:a05:6830:134c:: with SMTP id r12mr1475859otq.240.1602632738175; Tue, 13 Oct 2020 16:45:38 -0700 (PDT) MIME-Version: 1.0 References: <20201006171333.BlueZ.v6.1.I2830b9c1212a64b062201ed9f2b71294f50ad22d@changeid> <20201006171333.BlueZ.v6.2.I578ae5e76fcf7243206a27d4f5a25783662a5f14@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Tue, 13 Oct 2020 16:45:24 -0700 Message-ID: Subject: Re: [BlueZ PATCH v6 2/6] adv_monitor: Implement Adv matching based on stored monitors To: Miao-chen Chou Cc: Bluetooth Kernel Mailing List , Luiz Augusto von Dentz , Howard Chung , ChromeOS Bluetooth Upstreaming , Alain Michaud , Marcel Holtmann , Manish Mandlik , Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Miao-chen, On Mon, Oct 12, 2020 at 2:21 PM Miao-chen Chou wrote: > > Hi Luiz, > > I did think of adding pattern to bt_ad at the beginning, but here are > reasons why I ended up with hosting the definition of pattern in > adv_monitor. > (1) Pattern is specific to monitoring purpose. An advertisement > should not include patterns as its fields due to that fact that a > pattern hosts an offset. So I wasn't sure about its justification to > be placed in shared/ad. But if you foresee that it would be reused, > then I am more than happy to add it to shared/ad. > (2) Introducing helpers as you suggested below indeed make it more > unittestable. However, it also implied that EIR data (this is in fact > AD data) needs to be parsed into a new bt_ad for pattern comparison, > and I didn't see an obvious benefit of converting EIR data into a > bt_ad just for the comparison. Regarding (1) like I said you will need another struct to store the offset and length for doing the pattern matching but otherwise it is pretty similar, regarding (2) there is actually a real benefit that we could in the future drop the eir_ helpers and unit test just the bt_ad including pattern matching as well. > Maybe we can add a struct bt_ad_pattern in shared/ad.h and introduce > the following two functions. What do you think? > > struct bt_ad_pattern *bt_ad_pattern_new(uint8_t type, size_t offset, > size_t len, const void *data); Not sure I follow you here, that doesn't seem to be about the parsing of the AD but the creation of an object for matching, not sure we need that since you can probably just pass a stack variable directly, in any case you would need a free as well. > /* |data| is one single AD data field so that we can avoid converting > EIR data to bt_ad */ > bool bt_ad_pattern bt_ad_pattern_match(struct bt_ad_pattern *pattern, > void *data, size_t len); You may have more than one entry of the same type, anyway if we do have something like bt_ad_new_with_data that means we can pass it around and not have to reparse it when doing custom filtering. We might as well have a callback that does get called every time there is a match, also it may be possible to pass all the pattern at once in which case we can pass the pattern which matched along with the data thus having the call it multiple times for each monitor.