From patchwork Wed Jan 25 17:28:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 137804 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1A526B6F74 for ; Thu, 26 Jan 2012 04:29:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id DA94D17C030; Wed, 25 Jan 2012 12:29:01 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y71CUHwzf0bq; Wed, 25 Jan 2012 12:29:01 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7F1F29C1A7; Wed, 25 Jan 2012 12:28:57 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1D7329C1A5 for ; Wed, 25 Jan 2012 12:28:57 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VeJ3mpMmNK4z for ; Wed, 25 Jan 2012 12:28:52 -0500 (EST) Received: from smtp1.u-psud.fr (smtp1.u-psud.fr [129.175.33.41]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 90BE99C1A8 for ; Wed, 25 Jan 2012 12:28:47 -0500 (EST) Received: from smtp1.u-psud.fr (localhost [127.0.0.1]) by localhost (MTA) with SMTP id 31271256233 for ; Wed, 25 Jan 2012 18:28:47 +0100 (CET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by smtp1.u-psud.fr (MTA) with ESMTP id 18D592561FE for ; Wed, 25 Jan 2012 18:28:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 13DE440209 for ; Wed, 25 Jan 2012 18:28:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U5aeX4E8Oviv for ; Wed, 25 Jan 2012 18:28:46 +0100 (CET) Received: from smtp-ng.lri.fr (smtp [129.175.3.73]) by ext.lri.fr (Postfix) with ESMTP id EA57440166 for ; Wed, 25 Jan 2012 18:28:46 +0100 (CET) Received: from lowerbit.lri.fr (lri25-36 [129.175.25.36]) by smtp-ng.lri.fr (Postfix) with ESMTP id DC1AA602EB; Wed, 25 Jan 2012 18:28:46 +0100 (CET) From: Nicolas Cavallari To: hostap@lists.shmoo.com Subject: [PATCH] wpa_debug: Support outputting hexdumps into syslog. Date: Wed, 25 Jan 2012 18:28:35 +0100 Message-Id: <1327512516-9902-1-git-send-email-cavallar@lri.fr> X-Mailer: git-send-email 1.7.8.3 Cc: Nicolas Cavallari X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This patch allows to log hexdumps into syslog. This is useful when testing, as syslog's network logging helps to collect debug outputs from several machines. Signed-hostapd: Nicolas Cavallari --- src/utils/wpa_debug.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index 5b56d83..274067a 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -166,6 +166,38 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, size_t i; if (level < wpa_debug_level) return; +#ifdef CONFIG_DEBUG_SYSLOG + if (wpa_debug_syslog) { + const char* display; + char* strbuf = NULL; + + if (buf == NULL) { + display = " [NULL]"; + } else if (len == 0) { + display = ""; + } else if (show && len) { + strbuf = os_malloc(1 + 3 * len); + if (strbuf == NULL) { + wpa_printf(MSG_ERROR, "wpa_hexdump: Failed to " + "allocate message buffer"); + return; + } + + for (i = 0; i < len; i++) + os_snprintf(&strbuf[i * 3], 4, " %02x", + buf[i]); + + display = strbuf; + } else { + display = " [REMOVED]"; + } + + syslog(syslog_priority(level), "%s - hexdump(len=%lu):%s", + title, len, display); + os_free(strbuf); + return; + } +#endif /* CONFIG_DEBUG_SYSLOG */ wpa_debug_print_timestamp(); #ifdef CONFIG_DEBUG_FILE if (out_file) {