2016-11-04 06:12:21 +00:00
|
|
|
/*
|
|
|
|
* wpa_supplicant/hostapd / Debug prints
|
|
|
|
* Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of BSD
|
|
|
|
* license.
|
|
|
|
*
|
|
|
|
* See README and COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WPA_DEBUG_H
|
|
|
|
#define WPA_DEBUG_H
|
|
|
|
|
2018-04-20 03:33:04 +00:00
|
|
|
#include "wpabuf.h"
|
|
|
|
#include "esp_log.h"
|
2020-11-12 08:18:24 +00:00
|
|
|
#include "supplicant_opt.h"
|
2016-11-04 06:12:21 +00:00
|
|
|
|
2018-04-20 03:33:04 +00:00
|
|
|
#ifdef ESPRESSIF_USE
|
|
|
|
|
|
|
|
#define TAG "wpa"
|
|
|
|
|
|
|
|
#define MSG_ERROR ESP_LOG_ERROR
|
|
|
|
#define MSG_WARNING ESP_LOG_WARN
|
|
|
|
#define MSG_INFO ESP_LOG_INFO
|
|
|
|
#define MSG_DEBUG ESP_LOG_DEBUG
|
|
|
|
#define MSG_MSGDUMP ESP_LOG_VERBOSE
|
2021-06-03 13:07:51 +00:00
|
|
|
#define MSG_EXCESSIVE ESP_LOG_VERBOSE
|
2018-04-20 03:33:04 +00:00
|
|
|
|
2020-11-10 07:40:01 +00:00
|
|
|
#else
|
2016-11-04 06:12:21 +00:00
|
|
|
enum { MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR };
|
2018-04-20 03:33:04 +00:00
|
|
|
#endif
|
2016-11-04 06:12:21 +00:00
|
|
|
|
|
|
|
/** EAP authentication completed successfully */
|
|
|
|
#define WPA_EVENT_EAP_SUCCESS "CTRL-EVENT-EAP-SUCCESS "
|
|
|
|
|
|
|
|
int wpa_debug_open_file(const char *path);
|
|
|
|
void wpa_debug_close_file(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_debug_printf_timestamp - Print timestamp for debug output
|
|
|
|
*
|
|
|
|
* This function prints a timestamp in seconds_from_1970.microsoconds
|
|
|
|
* format if debug output has been configured to include timestamps in debug
|
|
|
|
* messages.
|
|
|
|
*/
|
|
|
|
void wpa_debug_print_timestamp(void);
|
|
|
|
|
2019-07-26 14:56:40 +00:00
|
|
|
#ifdef DEBUG_PRINT
|
2016-11-04 06:12:21 +00:00
|
|
|
/**
|
|
|
|
* wpa_printf - conditional printf
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @fmt: printf format string, followed by optional arguments
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration.
|
|
|
|
*
|
|
|
|
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
|
|
|
*/
|
2018-04-20 03:33:04 +00:00
|
|
|
#define wpa_printf(level,fmt, args...) ESP_LOG_LEVEL_LOCAL(level, TAG, fmt, ##args)
|
2020-11-12 08:18:24 +00:00
|
|
|
#define wpa_dbg(ctx, level, fmt, args...) wpa_printf(level, fmt, ##args)
|
2016-11-04 06:12:21 +00:00
|
|
|
|
2018-08-13 08:37:56 +00:00
|
|
|
void wpa_dump_mem(char* desc, uint8_t *addr, uint16_t len);
|
2016-11-04 06:12:21 +00:00
|
|
|
|
2019-07-26 14:56:40 +00:00
|
|
|
/**
|
|
|
|
* wpa_hexdump - conditional hex dump
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @title: title of for the message
|
|
|
|
* @buf: data buffer to be dumped
|
|
|
|
* @len: length of the buf
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. The contents of buf is printed out has hex dump.
|
|
|
|
*/
|
2016-11-04 06:12:21 +00:00
|
|
|
void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len);
|
|
|
|
|
2022-05-13 08:02:24 +00:00
|
|
|
static inline void wpa_hexdump_ascii(int level, const char *title, const void *buf, size_t len)
|
|
|
|
{
|
|
|
|
wpa_hexdump(level, title, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wpa_hexdump_ascii_key(int level, const char *title, const void *buf, size_t len)
|
|
|
|
{
|
|
|
|
wpa_hexdump(level, title, buf, len);
|
|
|
|
}
|
|
|
|
|
2016-11-04 06:12:21 +00:00
|
|
|
static inline void wpa_hexdump_buf(int level, const char *title,
|
|
|
|
const struct wpabuf *buf)
|
|
|
|
{
|
|
|
|
wpa_hexdump(level, title, wpabuf_head(buf), wpabuf_len(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_hexdump_key - conditional hex dump, hide keys
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @title: title of for the message
|
|
|
|
* @buf: data buffer to be dumped
|
|
|
|
* @len: length of the buf
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. The contents of buf is printed out has hex dump. This works
|
|
|
|
* like wpa_hexdump(), but by default, does not include secret keys (passwords,
|
|
|
|
* etc.) in debug output.
|
|
|
|
*/
|
|
|
|
void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len);
|
|
|
|
|
|
|
|
static inline void wpa_hexdump_buf_key(int level, const char *title,
|
|
|
|
const struct wpabuf *buf)
|
|
|
|
{
|
|
|
|
wpa_hexdump_key(level, title, wpabuf_head(buf), wpabuf_len(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_hexdump_ascii - conditional hex dump
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @title: title of for the message
|
|
|
|
* @buf: data buffer to be dumped
|
|
|
|
* @len: length of the buf
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. The contents of buf is printed out has hex dump with both
|
|
|
|
* the hex numbers and ASCII characters (for printable range) are shown. 16
|
|
|
|
* bytes per line will be shown.
|
|
|
|
*/
|
2022-05-13 04:57:47 +00:00
|
|
|
void wpa_hexdump_ascii(int level, const char *title, const void *buf,
|
2016-11-04 06:12:21 +00:00
|
|
|
size_t len);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_hexdump_ascii_key - conditional hex dump, hide keys
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @title: title of for the message
|
|
|
|
* @buf: data buffer to be dumped
|
|
|
|
* @len: length of the buf
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. The contents of buf is printed out has hex dump with both
|
|
|
|
* the hex numbers and ASCII characters (for printable range) are shown. 16
|
|
|
|
* bytes per line will be shown. This works like wpa_hexdump_ascii(), but by
|
|
|
|
* default, does not include secret keys (passwords, etc.) in debug output.
|
|
|
|
*/
|
2022-05-13 04:57:47 +00:00
|
|
|
void wpa_hexdump_ascii_key(int level, const char *title, const void *buf,
|
2016-11-04 06:12:21 +00:00
|
|
|
size_t len);
|
|
|
|
#else
|
2020-01-30 13:55:45 +00:00
|
|
|
#define wpa_printf(level,fmt, args...) do {} while(0)
|
|
|
|
#define wpa_hexdump(...) do {} while(0)
|
|
|
|
#define wpa_dump_mem(...) do {} while(0)
|
|
|
|
#define wpa_hexdump_buf(...) do {} while(0)
|
|
|
|
#define wpa_hexdump_key(...) do {} while(0)
|
|
|
|
#define wpa_hexdump_buf_key(...) do {} while(0)
|
|
|
|
#define wpa_hexdump_ascii(...) do {} while(0)
|
|
|
|
#define wpa_hexdump_ascii_key(...) do {} while(0)
|
2020-11-12 08:18:24 +00:00
|
|
|
#define wpa_dbg(...) do {} while(0)
|
2016-11-04 06:12:21 +00:00
|
|
|
#endif
|
|
|
|
|
2020-07-27 09:11:40 +00:00
|
|
|
#define wpa_auth_logger(...) do {} while(0)
|
|
|
|
#define wpa_auth_vlogger(...) do {} while(0)
|
2016-11-04 06:12:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_msg - Conditional printf for default target and ctrl_iface monitors
|
|
|
|
* @ctx: Pointer to context data; this is the ctx variable registered
|
|
|
|
* with struct wpa_driver_ops::init()
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @fmt: printf format string, followed by optional arguments
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages. The
|
|
|
|
* output may be directed to stdout, stderr, and/or syslog based on
|
|
|
|
* configuration. This function is like wpa_printf(), but it also sends the
|
|
|
|
* same message to all attached ctrl_iface monitors.
|
|
|
|
*
|
|
|
|
* Note: New line '\n' is added to the end of the text when printing to stdout.
|
|
|
|
*/
|
2021-10-09 16:34:55 +00:00
|
|
|
#define wpa_msg(...) do {} while(0)
|
2016-11-04 06:12:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wpa_msg_ctrl - Conditional printf for ctrl_iface monitors
|
|
|
|
* @ctx: Pointer to context data; this is the ctx variable registered
|
|
|
|
* with struct wpa_driver_ops::init()
|
|
|
|
* @level: priority level (MSG_*) of the message
|
|
|
|
* @fmt: printf format string, followed by optional arguments
|
|
|
|
*
|
|
|
|
* This function is used to print conditional debugging and error messages.
|
|
|
|
* This function is like wpa_msg(), but it sends the output only to the
|
|
|
|
* attached ctrl_iface monitors. In other words, it can be used for frequent
|
|
|
|
* events that do not need to be sent to syslog.
|
|
|
|
*/
|
|
|
|
void wpa_msg_ctrl(void *ctx, int level, const char *fmt, ...)
|
|
|
|
PRINTF_FORMAT(3, 4);
|
|
|
|
|
|
|
|
typedef void (*wpa_msg_cb_func)(void *ctx, int level, const char *txt,
|
|
|
|
size_t len);
|
|
|
|
|
|
|
|
#endif /* WPA_DEBUG_H */
|