Add support to print MLO link ID in hexdump debug prints. Signed-off-by: Veerendranath Jakkam <quic_vjakkam@xxxxxxxxxxx> --- src/utils/wpa_debug.c | 56 ++++++++++++++++++++++++++++++------------- src/utils/wpa_debug.h | 6 +++++ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index a338a2039..5d255cfed 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -255,16 +255,25 @@ void wpa_printf(int level, const char *fmt, ...) } -static void _wpa_hexdump(int level, const char *title, const u8 *buf, - size_t len, int show, int only_syslog) +static void _wpa_hexdump(int level, int link_id, const char *title, + const u8 *buf, size_t len, int show, int only_syslog) { size_t i; + char link_id_str[20]; + + link_id_str[0] = '\0'; + if (link_id >= 0 && link_id < 15) { + int ret = os_snprintf(link_id_str, sizeof(link_id_str), + " link_id=%d", link_id); + if (os_snprintf_error(sizeof(link_id_str), ret)) + link_id_str[0] = '\0'; + } #ifdef CONFIG_DEBUG_LINUX_TRACING if (wpa_debug_tracing_file != NULL) { fprintf(wpa_debug_tracing_file, - WPAS_TRACE_PFX "%s - hexdump(len=%lu):", - level, title, (unsigned long) len); + WPAS_TRACE_PFX "%s - hexdump(len=%lu%s):", + level, title, (unsigned long) len, link_id_str); if (buf == NULL) { fprintf(wpa_debug_tracing_file, " [NULL]\n"); } else if (!show) { @@ -311,9 +320,9 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, __android_log_print(wpa_to_android_level(level), ANDROID_LOG_NAME, - "%s - hexdump(len=%lu):%s%s", - title, (long unsigned int) len, display, - len > slen ? " ..." : ""); + "%s - hexdump(len=%lu%s):%s%s", + title, (long unsigned int) len, link_id_str, + display, len > slen ? " ..." : ""); bin_clear_free(strbuf, 1 + 3 * slen); return; } @@ -344,8 +353,8 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, display = " [REMOVED]"; } - syslog(syslog_priority(level), "%s - hexdump(len=%lu):%s", - title, (unsigned long) len, display); + syslog(syslog_priority(level), "%s - hexdump(len=%lu%s):%s", + title, (unsigned long) len, link_id_str, display); bin_clear_free(strbuf, 1 + 3 * len); if (only_syslog) return; @@ -354,8 +363,8 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, wpa_debug_print_timestamp(); #ifdef CONFIG_DEBUG_FILE if (out_file) { - fprintf(out_file, "%s - hexdump(len=%lu):", - title, (unsigned long) len); + fprintf(out_file, "%s - hexdump(len=%lu%s):", + title, (unsigned long) len, link_id_str); if (buf == NULL) { fprintf(out_file, " [NULL]"); } else if (show) { @@ -368,7 +377,8 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, } #endif /* CONFIG_DEBUG_FILE */ if (!wpa_debug_syslog && !out_file) { - printf("%s - hexdump(len=%lu):", title, (unsigned long) len); + printf("%s - hexdump(len=%lu%s):", title, (unsigned long) len, + link_id_str); if (buf == NULL) { printf(" [NULL]"); } else if (show) { @@ -384,13 +394,27 @@ static void _wpa_hexdump(int level, const char *title, const u8 *buf, void wpa_hexdump(int level, const char *title, const void *buf, size_t len) { - _wpa_hexdump(level, title, buf, len, 1, 0); + _wpa_hexdump(level, -1, title, buf, len, 1, 0); } void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len) { - _wpa_hexdump(level, title, buf, len, wpa_debug_show_keys, 0); + _wpa_hexdump(level, -1, title, buf, len, wpa_debug_show_keys, 0); +} + + +void wpa_hexdump_link(int level, u8 link_id, const char *title, const void *buf, + size_t len) +{ + _wpa_hexdump(level, link_id, title, buf, len, 1, 0); +} + + +void wpa_hexdump_link_key(int level, u8 link_id, const char *title, + const void *buf, size_t len) +{ + _wpa_hexdump(level, link_id, title, buf, len, wpa_debug_show_keys, 0); } @@ -423,11 +447,11 @@ static void _wpa_hexdump_ascii(int level, const char *title, const void *buf, if (level < wpa_debug_level) return; #ifdef CONFIG_ANDROID_LOG - _wpa_hexdump(level, title, buf, len, show, 0); + _wpa_hexdump(level, -1, title, buf, len, show, 0); #else /* CONFIG_ANDROID_LOG */ #ifdef CONFIG_DEBUG_SYSLOG if (wpa_debug_syslog) - _wpa_hexdump(level, title, buf, len, show, 1); + _wpa_hexdump(level, -1, title, buf, len, show, 1); #endif /* CONFIG_DEBUG_SYSLOG */ wpa_debug_print_timestamp(); #ifdef CONFIG_DEBUG_FILE diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index c6d5cc647..9f3f6443e 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -37,6 +37,8 @@ enum { #define wpa_debug_close_file() do { } while (0) #define wpa_debug_setup_stdout() do { } while (0) #define wpa_dbg(args...) do { } while (0) +#define wpa_hexdump_link(l,li,t,b,le) do { } while (0) +#define wpa_hexdump_link_key(l,li,t,b,le) do { } while (0) static inline int wpa_debug_reopen_file(void) { @@ -85,6 +87,8 @@ PRINTF_FORMAT(2, 3); * configuration. The contents of buf is printed out has hex dump. */ void wpa_hexdump(int level, const char *title, const void *buf, size_t len); +void wpa_hexdump_link(int level, u8 link_id, const char *title, const void *buf, + size_t len); static inline void wpa_hexdump_buf(int level, const char *title, const struct wpabuf *buf) @@ -107,6 +111,8 @@ static inline void wpa_hexdump_buf(int level, const char *title, * etc.) in debug output. */ void wpa_hexdump_key(int level, const char *title, const void *buf, size_t len); +void wpa_hexdump_link_key(int level, u8 link_id, const char *title, + const void *buf, size_t len); static inline void wpa_hexdump_buf_key(int level, const char *title, const struct wpabuf *buf) -- 2.25.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap