Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp289237ybm; Thu, 28 May 2020 23:38:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsoYfpwfmZdY5YkMIRIn0O+ToebcxB+0+iQRG6PRRprittb30ltdnlKa1CYvXfw8q+TiyF X-Received: by 2002:a17:906:e211:: with SMTP id gf17mr6382343ejb.495.1590734321699; Thu, 28 May 2020 23:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590734321; cv=none; d=google.com; s=arc-20160816; b=hG1/38fE4+i38MP0ULup4NS72NXj8gBNarr/EE+3n2LdJXTW8oJmkGnGDGkYFRFKSB BeQS3Yz1UKvAXOFsc9Eky4dckIdi5pSil0D5KjezxQK1Vo972R2PHRzr2+Fz5fct+ZPz 527ZhBVfOsvFFSvtMPHqXLVsQy8k/bsfTFhTQrJjIO1A5f9cwHruHqbqqG1k1WgwiMu0 bnA9R/vCRgp9cq/x4zNHMJYCR8DxCGFdEceNu/ayluPazZGUfa0M9LLaK97umYxziV9z T3vaGUizbO4euflTA0rDFN1rEpVYA6+wb07ktTrEnRHmfHNZB3chIyLTfCOmzIZD0dBj WnrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=/I2x+NdwlMUidEHrYp/WjrV2F3tIJKpXJc8zV66VnA0=; b=t4FgtXRbKbh0WqY5WGUoksCmLu7kOVfFUaCEprpCTqp1B7m0mIhJfVY4rbbWzgBHd6 h+n0+pAjGa9Dp8JUfW1u8jpTUGSpFcKRssiYtWpiocC01nbgQKM8YBL6Q6DSV1wW/8h4 KVNOG7yX8v9Strs+Gat/h05gh9DCGkOzwvdQDqhntQPtkWGrEp6U3c9JfQ5KKL75qxik ahvBXnsC8MLGdWILdgGtsIolXG0oLBXMzlR6pusMZhfEN4EPvRbKjjUddz7IsE9BHVMG Nz0uZgseZBetqV6u0z34zClub30c86nDg4NIliVWghx0Fl8NhgWU9PKhvHdUg/9hEajp OWfw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si5015478eda.482.2020.05.28.23.38.00; Thu, 28 May 2020 23:38:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgE2Ghx (ORCPT + 99 others); Fri, 29 May 2020 02:37:53 -0400 Received: from mga12.intel.com ([192.55.52.136]:53719 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgE2Ghx (ORCPT ); Fri, 29 May 2020 02:37:53 -0400 IronPort-SDR: h4gDQnocrz1+36VDF+XTETLHr4oqnNtOmG9/14VACbObT11zHXY7aupbiRyUG8TfYFqof2fnxN ACgAMW2/2ATA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 23:37:53 -0700 IronPort-SDR: 6jm5KFS88cBfZXkLyraLzheyPaTOEBdz+jSOsIFXFAnVq2k2fQBeqXBomNEq2ytNkMslXXKUQb XvO5JXOtlMdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,447,1583222400"; d="scan'208";a="257260590" Received: from dmikkels-mobl1.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.255.228.187]) by fmsmga008.fm.intel.com with ESMTP; 28 May 2020 23:37:52 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 1/5] mesh: Make helper packet print depends on debug setting Date: Thu, 28 May 2020 23:37:46 -0700 Message-Id: <20200529063750.186278-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529063750.186278-1-inga.stotland@intel.com> References: <20200529063750.186278-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This changes the utility function print_packet() to check if daemon is running in debug mode. --- mesh/main.c | 3 ++- mesh/util.c | 11 +++++++++++ mesh/util.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mesh/main.c b/mesh/main.c index c6bf1ff41..1a4e6ba76 100644 --- a/mesh/main.c +++ b/mesh/main.c @@ -37,6 +37,7 @@ #include "mesh/crypto.h" #include "mesh/dbus.h" #include "mesh/mesh-io.h" +#include "mesh/util.h" static const char *config_dir; static const char *mesh_conf_fname; @@ -210,7 +211,7 @@ int main(int argc, char *argv[]) detached = false; break; case 'd': - l_debug_enable("*"); + enable_debug(); break; case 'c': config_dir = optarg; diff --git a/mesh/util.c b/mesh/util.c index 43340f159..7d283331a 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -34,10 +34,15 @@ #include "mesh/util.h" +static bool debug_enabled; + void print_packet(const char *label, const void *data, uint16_t size) { struct timeval pkt_time; + if (!debug_enabled) + return; + gettimeofday(&pkt_time, NULL); if (size > 0) { @@ -154,3 +159,9 @@ void del_path(const char *path) { nftw(path, del_fobject, 5, FTW_DEPTH | FTW_PHYS); } + +void enable_debug(void) +{ + debug_enabled = true; + l_debug_enable("*"); +} diff --git a/mesh/util.h b/mesh/util.h index 092d33041..93c2d8687 100644 --- a/mesh/util.h +++ b/mesh/util.h @@ -24,3 +24,4 @@ size_t hex2str(uint8_t *in, size_t in_len, char *out, size_t out_len); void print_packet(const char *label, const void *data, uint16_t size); int create_dir(const char *dir_name); void del_path(const char *path); +void enable_debug(void); -- 2.26.2