diff options
author | Nicolas Cavallari <Nicolas.Cavallari@lri.fr> | 2012-01-29 12:13:43 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-01-29 12:13:43 +0200 |
commit | f31e19df3a97f0610300c847f13c4e4b4656c477 (patch) | |
tree | d7bdd91c5532d2f183fb00a5dc727e1b6d1f433d /src/utils | |
parent | 4ac384c596657bb96c22355d1dd13b85ffbad524 (diff) | |
download | external_wpa_supplicant_8_ti-f31e19df3a97f0610300c847f13c4e4b4656c477.zip external_wpa_supplicant_8_ti-f31e19df3a97f0610300c847f13c4e4b4656c477.tar.gz external_wpa_supplicant_8_ti-f31e19df3a97f0610300c847f13c4e4b4656c477.tar.bz2 |
wpa_debug: Support outputting hexdumps into syslog
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 <cavallar@lri.fr>
Diffstat (limited to 'src/utils')
-rw-r--r-- | 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..c3fd4cf 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) { |