From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0130C43444 for ; Fri, 14 Dec 2018 22:48:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19EFB208C1 for ; Fri, 14 Dec 2018 22:48:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730700AbeLNWsV (ORCPT ); Fri, 14 Dec 2018 17:48:21 -0500 Received: from mga18.intel.com ([134.134.136.126]:9397 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730682AbeLNWsU (ORCPT ); Fri, 14 Dec 2018 17:48:20 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Dec 2018 14:48:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,354,1539673200"; d="scan'208";a="100810006" Received: from bgix-dell-lap.sea.intel.com ([10.251.138.67]) by orsmga006.jf.intel.com with ESMTP; 14 Dec 2018 14:48:18 -0800 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: johan.hedberg@gmail.com, inga.stotland@intel.com, marcel@holtmann.org, brian.gix@intel.com Subject: [PATCH BlueZ 13/30] mesh: centralize generic utilities Date: Fri, 14 Dec 2018 14:47:36 -0800 Message-Id: <20181214224753.2892-14-brian.gix@intel.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181214224753.2892-1-brian.gix@intel.com> References: <20181214224753.2892-1-brian.gix@intel.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Inga Stotland --- mesh/util.c | 26 ++++++++++++++++++++++++++ mesh/util.h | 1 + 2 files changed, 27 insertions(+) diff --git a/mesh/util.c b/mesh/util.c index 2cdcdf37d..ac0294742 100644 --- a/mesh/util.c +++ b/mesh/util.c @@ -26,10 +26,36 @@ #include #include #include +#include +#include #include +#include +#include + +#include #include "mesh/util.h" +void print_packet(const char *label, const void *data, uint16_t size) +{ + struct timeval pkt_time; + + gettimeofday(&pkt_time, NULL); + + if (size > 0) { + char *str; + + str = l_util_hexstring(data, size); + l_debug("%05d.%03d %s: %s", + (uint32_t) pkt_time.tv_sec % 100000, + (uint32_t) pkt_time.tv_usec/1000, label, str); + l_free(str); + } else + l_debug("%05d.%03d %s: empty", + (uint32_t) pkt_time.tv_sec % 100000, + (uint32_t) pkt_time.tv_usec/1000, label); +} + uint32_t get_timestamp_secs(void) { struct timespec ts; diff --git a/mesh/util.h b/mesh/util.h index 61110104a..b8efb6521 100644 --- a/mesh/util.h +++ b/mesh/util.h @@ -22,3 +22,4 @@ uint32_t get_timestamp_secs(void); bool str2hex(const char *str, uint16_t in_len, uint8_t *out, uint16_t out_len); 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); -- 2.14.5