Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2215324pxb; Fri, 25 Mar 2022 13:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+03nF9dt1KQliXi1Y55OtjzU1Cin9pF6IbLeAo/MKePWKLurhVDfnE0rVLeAuKXNWfQ25 X-Received: by 2002:a65:6955:0:b0:380:64fd:a2dd with SMTP id w21-20020a656955000000b0038064fda2ddmr939654pgq.383.1648239121894; Fri, 25 Mar 2022 13:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648239121; cv=none; d=google.com; s=arc-20160816; b=uh221N0CBNKkZVOP8AOT7z/Rt/q6d+663OVnXR7Vu9voCjRZhmqzRRA50s1PpGTAyB XWA4vmI4T11o+aMBK/L3/hFILvEQhwMLf+pAK9YQ0mDn5V/K0JpDpDStQjwVikpvehmk 2AiYeanchh7pS593SxTRfLA1Cm0luVdHUXrB6C0+93jjIqVeFtYOC3jwrgQ07LHX/Qgb 70myliz/UUBrtl6DNw7VH7Wgv8+AUfbFVWj8+TgEtnPaieoTgzwXakR+mBykOm7W3e8M EWqX9Xpn8VJoIb/6CcrxWzcJAL1yl/avCHtB59h93Lgp7gY2y5vGRFyg1RrEjUd5z7iF I/rw== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GFc9sXDCUSGMKzcmjKZL85zsIJOnPsCDkSf/Z7ucJ1E=; b=vIAh6bWt41Hi38JM5bTiqmx+Xi1DfG6v1wNvCbbX1D1VEJs8wfw1ghcToBt6ma6bj9 etBPVX6Cu/Yo/8xRMENyP5JihMDwN12JTkzz33e7Z6c+PqIuUQig9g6lo2WJPsRbV5dp p8rOhEdUWiuu/zO30dVVE2fXk3OyefQBkCyT3IRTGt9I2QCrRHuskshaqProxL8JaLFz vUVJEXFaW8xM8zKkg8lb1gD5W63bM3F3gWz2qKvKFTJ5R69mi1L3x/+GZx50WI8vKgl7 uFopsDtWfwbN6GHqoSv+EsrBsfJaMKzSV+LDX1A+ZTyTFx2TenYkGXrQ2vPO1JJWL3r/ 6/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EWanTqBb; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h9-20020a17090a470900b001bf65f92794si3646958pjg.118.2022.03.25.13.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 13:12:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EWanTqBb; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B52CF278C49; Fri, 25 Mar 2022 11:54:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345294AbiCWWlp (ORCPT + 99 others); Wed, 23 Mar 2022 18:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345299AbiCWWll (ORCPT ); Wed, 23 Mar 2022 18:41:41 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C8A3819E for ; Wed, 23 Mar 2022 15:40:10 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id mm17-20020a17090b359100b001c6da62a559so7761716pjb.3 for ; Wed, 23 Mar 2022 15:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GFc9sXDCUSGMKzcmjKZL85zsIJOnPsCDkSf/Z7ucJ1E=; b=EWanTqBbrzfO5rczKfYNwHtoyH6e8nPeQ6FG9r2qUb7I9rwdTCXbw3/U08CTdPJfPY 7dcQ1Mpn+/RR7NZ38ECHZRJ/6rhJls5zMaAHguhQhozZX6SqnHEUD/AyoJpAaxXU//OV UfZBr08d93OaZ12LhoaXDzPT1VErZkTzEIDLvClwo4lsOKX/YhbBfyvrnEg4uXUM9mUc XIbw8U4iVDQOZ5kTv8Www3vKyLBj9ZMAhCXCent833wNX747UZW5dCGY8ED9CISxP0MG XMv0dMlDgxF6jRz8nelsw/W67HhHx+fzByN7xPkqjETFl+7DqAjUMUWfIkVlSavyeWHu sLjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GFc9sXDCUSGMKzcmjKZL85zsIJOnPsCDkSf/Z7ucJ1E=; b=Bs9QCDkNaRc0dhIMF8YMSDcSz1lug492aS0mwjcs9ctVfQzgGt6u0hu4GLzCsWrafV GPm5VN4SIr91CHSyUzgRDmp6HDIOG+r5uL+HXbOgJuws1cxjGunfHRBPj4DZIWFHuKWQ bvs37rM18JWD3ndAza34S3+N5IG+/teeMD1l6ijeju3iy9RQ4WhCNcK5IKh7wLDlQyh5 Jim8rWiQaA4iEv7eqchboE7B30FtWoIVneWzLPdxCXGumuBpWZ2/RbzaZ4ruoyJOqC/y qjl8vTDqX4cFHB06lIrc+i2VBYD0YPRU6DHOtPYiD2R9gtIbYclj4gWelvr+SsT/v9wW JKMQ== X-Gm-Message-State: AOAM530nFBMMAqE6p5eydsHB8FpNCEmQv0W4BJcZzB/+hCGw8QK/AKFW JNoXC4N5qk0qb8awzNS7HaSbXmBWFFc= X-Received: by 2002:a17:902:a415:b0:153:a1b6:729f with SMTP id p21-20020a170902a41500b00153a1b6729fmr2395508plq.52.1648075210136; Wed, 23 Mar 2022 15:40:10 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id z14-20020aa7888e000000b004f79f59827asm825109pfe.139.2022.03.23.15.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 15:40:09 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 7/9] gatt-server: Add DBG macro Date: Wed, 23 Mar 2022 15:40:01 -0700 Message-Id: <20220323224003.3736525-8-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220323224003.3736525-1-luiz.dentz@gmail.com> References: <20220323224003.3736525-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 adds gatt_log wrapper for util_debug and DBG so file and function names are printed with the logs. --- src/shared/gatt-server.c | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index 776e5ce2b..2adb4afbf 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -41,6 +41,9 @@ #define NFY_MULT_TIMEOUT 10 +#define DBG(_server, _format, arg...) \ + gatt_log(_server, "%s:%s() " _format, __FILE__, __func__, ## arg) + struct async_read_op { struct bt_att_chan *chan; struct bt_gatt_server *server; @@ -233,6 +236,18 @@ static bool encode_read_by_grp_type_rsp(struct gatt_db *db, struct queue *q, return true; } +static void gatt_log(struct bt_gatt_server *server, const char *format, ...) +{ + va_list ap; + + if (!server || !format || !server->debug_callback) + return; + + va_start(ap, format); + util_debug_va(server->debug_callback, server->debug_data, format, ap); + va_end(ap); +} + static void read_by_grp_type_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu, uint16_t length, void *user_data) @@ -259,9 +274,7 @@ static void read_by_grp_type_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); get_uuid_le(pdu + 4, length - 4, &type); - util_debug(server->debug_callback, server->debug_data, - "Read By Grp Type - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Read By Grp Type - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -483,9 +496,7 @@ static void read_by_type_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); get_uuid_le(pdu + 4, length - 4, &type); - util_debug(server->debug_callback, server->debug_data, - "Read By Type - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Read By Type - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -605,9 +616,7 @@ static void find_info_cb(struct bt_att_chan *chan, uint8_t opcode, start = get_le16(pdu); end = get_le16(pdu + 2); - util_debug(server->debug_callback, server->debug_data, - "Find Info - start: 0x%04x end: 0x%04x", - start, end); + DBG(server, "Find Info - start: 0x%04x end: 0x%04x", start, end); if (!start || !end) { ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -708,9 +717,10 @@ static void find_by_type_val_cb(struct bt_att_chan *chan, uint8_t opcode, end = get_le16(pdu + 2); uuid16 = get_le16(pdu + 4); - util_debug(server->debug_callback, server->debug_data, - "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x", - start, end, uuid16); + DBG(server, + "Find By Type Value - start: 0x%04x end: 0x%04x uuid: 0x%04x", + start, end, uuid16); + ehandle = start; if (start > end) { data.ecode = BT_ATT_ERROR_INVALID_HANDLE; @@ -756,8 +766,7 @@ static void write_complete_cb(struct gatt_db_attribute *attr, int err, return; } - util_debug(server->debug_callback, server->debug_data, - "Write Complete: err %d", err); + DBG(server, "Write Complete: err %d", err); handle = gatt_db_attribute_get_handle(attr); @@ -818,10 +827,8 @@ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Write %s - handle: 0x%04x", - (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", - handle); + DBG(server, "Write %s - handle: 0x%04x", + (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", handle); ecode = check_length(length, 0); if (ecode) @@ -885,8 +892,7 @@ static void read_complete_cb(struct gatt_db_attribute *attr, int err, uint16_t mtu; uint16_t handle; - util_debug(server->debug_callback, server->debug_data, - "Read Complete: err %d", err); + DBG(server, "Read Complete: err %d", err); mtu = bt_att_get_mtu(server->att); handle = gatt_db_attribute_get_handle(attr); @@ -922,10 +928,8 @@ static void handle_read_req(struct bt_att_chan *chan, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Read %sReq - handle: 0x%04x", - opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", - handle); + DBG(server, "Read %sReq - handle: 0x%04x", + opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", handle); ecode = check_permissions(server, attr, BT_ATT_PERM_READ_MASK); if (ecode) @@ -1125,8 +1129,7 @@ static void read_multiple_cb(struct bt_att_chan *chan, uint8_t opcode, handle = data->handles[0]; - util_debug(server->debug_callback, server->debug_data, - "%s Req - %zu handles, 1st: 0x%04x", + DBG(server, "%s Req - %zu handles, 1st: 0x%04x", data->opcode == BT_ATT_OP_READ_MULT_REQ ? "Read Multiple" : "Read Multiple Variable Length", data->num_handles, handle); @@ -1312,8 +1315,7 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode, goto error; } - util_debug(server->debug_callback, server->debug_data, - "Prep Write Req - handle: 0x%04x", handle); + DBG(server, "Prep Write Req - handle: 0x%04x", handle); ecode = check_length(length, offset); if (ecode) @@ -1433,8 +1435,7 @@ static void exec_write_cb(struct bt_att_chan *chan, uint8_t opcode, flags = ((uint8_t *) pdu)[0]; - util_debug(server->debug_callback, server->debug_data, - "Exec Write Req - flags: 0x%02x", flags); + DBG(server, "Exec Write Req - flags: 0x%02x", flags); if (flags == 0x00) write = false; @@ -1505,8 +1506,7 @@ static void exchange_mtu_cb(struct bt_att_chan *chan, uint8_t opcode, server->mtu = final_mtu; bt_att_set_mtu(server->att, final_mtu); - util_debug(server->debug_callback, server->debug_data, - "MTU exchange complete, with MTU: %u", final_mtu); + DBG(server, "MTU exchange complete, with MTU: %u", final_mtu); } static bool gatt_server_register_att_handlers(struct bt_gatt_server *server) -- 2.35.1