Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1832876rwl; Fri, 24 Mar 2023 16:40:59 -0700 (PDT) X-Google-Smtp-Source: AKy350b/nib3b85WuM+8hxwQSc1xf8UwmILMe5IRzko66TyrSb0Mwx74AvfICsyVOx6e9vTj5fbV X-Received: by 2002:a17:906:3896:b0:933:3a22:8513 with SMTP id q22-20020a170906389600b009333a228513mr5828628ejd.53.1679701259228; Fri, 24 Mar 2023 16:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679701259; cv=none; d=google.com; s=arc-20160816; b=Gqpug2/ewrVgMywnVVli99w1RPzc3T73wu6nCCnSnRzvzYKU/cDQCTkPSf8f5xve4e gL52uvMiCzcjvfkyHAeUADMnI9aSDNRpD6DgWKzKHUIiMynjHABmDrwt9F0exI6sZ7Ev 1o30+rkvo2yoJu9ZsnMS+YxSg2aZ8kfYfs8Spw9PeOvu+eGy7C753yDPQyxwqvOMPint q+w/3hCj11UXWHmKBXVWBqM9jgFFstBY2hbnfnTjvv4VJ88QZ4i80uAmsiyAHTZLgwq7 Usk2hy1RmVKM6lcz+w7AwJVz5+85hhTDFoD3w48+QyxV4nYf+qaWBB389RBG8OiH+eau Azsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=t80pHO+36rMIEHfz7QCiKbhx6ropjLKoecM2a23jtnk=; b=JyzTS0Y84kKYE0ioclh4u/JulKHMZ7E7vRWcb8nq5HECtWIsF1Q/nwG+tGylx+F5eI /9M1BGEJbGZaFRmrxMNcI7v70acJTEppw2p8w/J7iagQ9pBVvbOTT70sIpp8iQQCPkxt 4dKKtBpLvnEwjrfRtUzdKK6m0CNX6dHH1E2zQrE5h8MAtSRWr0b7M/tA9DFFAVDV8rQq SR7T8CYyKyhxn1ELXQOVvKtVJTrOZf7vrzMkqVIH/L9dr0RpDObwq1REVyL9dNKWs+Tj y2L8GOmFleR3vBwLY7oAop4IkR8p6E2vBPV4RuLNo3OrXIB9V+U4ZSsxAio6n7J7yP9E uxAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UCfO7MSR; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr36-20020a1709073fa400b00932b2915d60si28057990ejc.681.2023.03.24.16.40.23; Fri, 24 Mar 2023 16:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UCfO7MSR; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231959AbjCXXjB (ORCPT + 99 others); Fri, 24 Mar 2023 19:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbjCXXjA (ORCPT ); Fri, 24 Mar 2023 19:39:00 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEB9158AB for ; Fri, 24 Mar 2023 16:38:59 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id mp3-20020a17090b190300b0023fcc8ce113so6536937pjb.4 for ; Fri, 24 Mar 2023 16:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679701138; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=t80pHO+36rMIEHfz7QCiKbhx6ropjLKoecM2a23jtnk=; b=UCfO7MSR56AWTRTK+rh/Y/Opw49BVmDJXxNBPR6L6sAoCjS2tMcgB1hjs0seG8jorm oWnM7UzsjkoNI6imVQiFElEJkIcSLx9hCazuU6pa1J6oIQ6ssakOQEYtH3fP4PhOsip3 1QNjZ07ahTq9frP8Y+W0K8+veSwao0xF7WVIO+eG2vrQt6tXaCjz5bmURA2J1wa3RYgp WfASRDfq7oC3f9+SVY1pRrm9r//h3t2B38uuOIbttTnJ8nqVR2+hA6OlBUkWJg1Qoq7w +IH775gW6ukPL3pu3H6SL+HNRZNX6DJJoHTUwUe7cspp+dl4BKpaeCjuBprKlnUb9HSn eWoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679701138; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t80pHO+36rMIEHfz7QCiKbhx6ropjLKoecM2a23jtnk=; b=voeLm4k/oUAkcD6INy4kkLpBDsMisEdbt3BvQvRnFRF1InVoS7+KfKyYgZ78xtsP4N O+EzR4wWt1JZGwmos49k/nmadU88+AwGrTJzmL53A4JakAOAUcJgC5/mX2X5DGy/jzAt oVBrHPaMKlYyEH5aleSug8K5KOxv1xtQj/ez9psXK/6Bx2p/UBfkLFstbix7HueAoyq2 PhhBnq0pJ8q6fPU5cdpiQYX8PJqcGrHfv5gkEm7jPbw6GkR0d1B7xem2VMMK9L3ShrNv 2RItRSNRV0/nk2HxrpXRDecyku6AyCncPemS6xxwzGXLvf6jb0GAbXRVf7KQaLkV/lVH 9d5g== X-Gm-Message-State: AAQBX9fPKLs1nUYDqXcUGMggpaFGiKiO6jf57teljw6NQLceCLA1ry7n XnPbm0QTjc+U+FBO/gz2sroic5O53CQ= X-Received: by 2002:a17:902:c941:b0:19c:e405:4446 with SMTP id i1-20020a170902c94100b0019ce4054446mr4385078pla.30.1679701138365; Fri, 24 Mar 2023 16:38:58 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id d18-20020a170902aa9200b001a1add0d616sm13666771plr.161.2023.03.24.16.38.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 16:38:57 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/4] shared/gatt-db: Make gatt_db_attribute_get_value public Date: Fri, 24 Mar 2023 16:38:53 -0700 Message-Id: <20230324233856.3693370-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes gatt_db_attribute_get_value public so it can be used by the likes of btmon. --- src/shared/gatt-db.c | 12 ++++++------ src/shared/gatt-db.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index b696fe33da93..676f963eca94 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1549,7 +1549,7 @@ static int gatt_db_attribute_get_index(const struct gatt_db_attribute *attrib) return -1; } -static struct gatt_db_attribute * +struct gatt_db_attribute * gatt_db_attribute_get_value(struct gatt_db_attribute *attrib) { struct gatt_db_service *service; @@ -1559,18 +1559,18 @@ gatt_db_attribute_get_value(struct gatt_db_attribute *attrib) return NULL; index = gatt_db_attribute_get_index(attrib); - if (index < 0) + if (index <= 0) return NULL; service = attrib->service; if (!bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) - index++; - else if (bt_uuid_cmp(&characteristic_uuid, + return service->attributes[index + 1]; + else if (!bt_uuid_cmp(&characteristic_uuid, &service->attributes[index - 1]->uuid)) - return NULL; + return service->attributes[index]; - return service->attributes[index]; + return gatt_db_attribute_get_value(service->attributes[index - 1]); } void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib, diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 163a981df233..fb939e40d40e 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -284,6 +284,8 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, bool gatt_db_attribute_write_result(struct gatt_db_attribute *attrib, unsigned int id, int err); +struct gatt_db_attribute * +gatt_db_attribute_get_value(struct gatt_db_attribute *attrib); struct gatt_db_attribute * gatt_db_attribute_get_ccc(struct gatt_db_attribute *attrib); -- 2.39.2