Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1788088ybm; Sat, 30 May 2020 21:43:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWPOgmBqv0/2nzjKhrETgl8ZO/nV93DL6lZxAgWk+kVZj95tP7b1hG6/bQkYOkhdSTUy26 X-Received: by 2002:a17:906:b41:: with SMTP id v1mr6086119ejg.147.1590900183069; Sat, 30 May 2020 21:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590900183; cv=none; d=google.com; s=arc-20160816; b=1Jkd43+SuNOrkUFulD6RTMGFAkDkt8hcciy5962bWDRLL9Ok/mIQ7BTWyg4Bqgz3xq gb6TGHIwyPXDpZZ24UntdP6HyONCa74NvsUszelhSU0218og140CCLYd68tW0xMreg7d IrgJLwESGDXgC8V5sGfogfmEzFMXOeRQo3OP3U+f4q5LAaaRKOz5t2yv3bp5hAapnE2+ tu90M0elvfMAi7aCyaHmqMusE3rMl6wmof6mJNBzvRzLp2M+mXPvqk1pAjR9LFEyyQ14 +Pk6PwQyFteUtNGOjjGuccRvRJkavwzHridkzCLE8hXc/mU0tqL6TcfEOoIpH2HDcvLH nF+A== 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=ZRgy8p8++/bwu2YR/3kOAWmLYugwdT8P6pC052s5BjKTw+ecIvRTqRceNJ8U4SmFhq vfPyXX8XEIA847Q4OjO9Z4Sa36KB/Iqw8Yv3zpS0UuymitIYGyKFmuu6hhOhainE2BUS vUO899w979kGSdmJ1E0fIG2B2KGx8kC38LaIPyUryGTuOlMjdh9skFf2pC6yl297J6V9 zfgMa+GeWauHbwK9TBaYyqppOLvFKFzi0WfE9zNBzjaSPfZ5dYEfgVWJSEosg8JhsCfm fZvgM2rq1BOPQ3UAFNH65Dd/+yCECHce3tFPuSbcaGPTeLAL48lVoW85nIKtqGdYGqWo LPQg== 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 nh1si758115ejb.255.2020.05.30.21.42.39; Sat, 30 May 2020 21:43:03 -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 S1728711AbgEaElg (ORCPT + 99 others); Sun, 31 May 2020 00:41:36 -0400 Received: from mga11.intel.com ([192.55.52.93]:40465 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbgEaElg (ORCPT ); Sun, 31 May 2020 00:41:36 -0400 IronPort-SDR: qypyKhNLrWw4pvgMOUSeN8vXRs8J7rFJV8A4b8ecn0QHZlENuv7Ur2I3+d65QOZ6xasJV5H5l1 cem/9RkQKdnQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2020 21:41:35 -0700 IronPort-SDR: x/L7JVHDcBE+BvN8o6DzK3XU3aOoZWSOLiqgYvnvxc6T8mhUcznnu97W1/Y+VkM5TJHXczG1NH pnMuHUdK/2yw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,455,1583222400"; d="scan'208";a="377087055" Received: from rfcheney-mobl.amr.corp.intel.com (HELO ingas-nuc1.sea.intel.com) ([10.254.68.158]) by fmsmga001.fm.intel.com with ESMTP; 30 May 2020 21:41:35 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v2 1/5] mesh: Helper packet print should depend on debug setting Date: Sat, 30 May 2020 21:41:24 -0700 Message-Id: <20200531044128.16734-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200531044128.16734-1-inga.stotland@intel.com> References: <20200531044128.16734-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