mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-18 02:44:03 -05:00
hostapd: Add support to configure debug log level at runtime
Add support to read/configure log_level using hostapd control interface LOG_LEVEL command similarly to what was already supported in wpa_supplicant. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
ab62f96f55
commit
5c4f0511a2
@ -1961,6 +1961,52 @@ static int hostapd_ctrl_iface_eapol_set(struct hostapd_data *hapd, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int hostapd_ctrl_iface_log_level(struct hostapd_data *hapd, char *cmd,
|
||||||
|
char *buf, size_t buflen)
|
||||||
|
{
|
||||||
|
char *pos, *end, *stamp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* cmd: "LOG_LEVEL [<level>]" */
|
||||||
|
if (*cmd == '\0') {
|
||||||
|
pos = buf;
|
||||||
|
end = buf + buflen;
|
||||||
|
ret = os_snprintf(pos, end - pos, "Current level: %s\n"
|
||||||
|
"Timestamp: %d\n",
|
||||||
|
debug_level_str(wpa_debug_level),
|
||||||
|
wpa_debug_timestamp);
|
||||||
|
if (os_snprintf_error(end - pos, ret))
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*cmd == ' ')
|
||||||
|
cmd++;
|
||||||
|
|
||||||
|
stamp = os_strchr(cmd, ' ');
|
||||||
|
if (stamp) {
|
||||||
|
*stamp++ = '\0';
|
||||||
|
while (*stamp == ' ') {
|
||||||
|
stamp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd && os_strlen(cmd)) {
|
||||||
|
int level = str_to_debug_level(cmd);
|
||||||
|
if (level < 0)
|
||||||
|
return -1;
|
||||||
|
wpa_debug_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stamp && os_strlen(stamp))
|
||||||
|
wpa_debug_timestamp = atoi(stamp);
|
||||||
|
|
||||||
|
os_memcpy(buf, "OK\n", 3);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
|
static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
|
||||||
char *buf, char *reply,
|
char *buf, char *reply,
|
||||||
int reply_size,
|
int reply_size,
|
||||||
@ -2189,6 +2235,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
|
|||||||
} else if (os_strncmp(buf, "EAPOL_SET ", 10) == 0) {
|
} else if (os_strncmp(buf, "EAPOL_SET ", 10) == 0) {
|
||||||
if (hostapd_ctrl_iface_eapol_set(hapd, buf + 10))
|
if (hostapd_ctrl_iface_eapol_set(hapd, buf + 10))
|
||||||
reply_len = -1;
|
reply_len = -1;
|
||||||
|
} else if (os_strncmp(buf, "LOG_LEVEL", 9) == 0) {
|
||||||
|
reply_len = hostapd_ctrl_iface_log_level(
|
||||||
|
hapd, buf + 9, reply, reply_size);
|
||||||
} else {
|
} else {
|
||||||
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
|
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
|
||||||
reply_len = 16;
|
reply_len = 16;
|
||||||
|
@ -1039,6 +1039,25 @@ static int hostapd_cli_cmd_erp_flush(struct wpa_ctrl *ctrl, int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int hostapd_cli_cmd_log_level(struct wpa_ctrl *ctrl, int argc,
|
||||||
|
char *argv[])
|
||||||
|
{
|
||||||
|
char cmd[256];
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = os_snprintf(cmd, sizeof(cmd), "LOG_LEVEL%s%s%s%s",
|
||||||
|
argc >= 1 ? " " : "",
|
||||||
|
argc >= 1 ? argv[0] : "",
|
||||||
|
argc == 2 ? " " : "",
|
||||||
|
argc == 2 ? argv[1] : "");
|
||||||
|
if (os_snprintf_error(sizeof(cmd), res)) {
|
||||||
|
printf("Too long option\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct hostapd_cli_cmd {
|
struct hostapd_cli_cmd {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
|
int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
|
||||||
@ -1096,6 +1115,7 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
|
|||||||
{ "reload", hostapd_cli_cmd_reload },
|
{ "reload", hostapd_cli_cmd_reload },
|
||||||
{ "disable", hostapd_cli_cmd_disable },
|
{ "disable", hostapd_cli_cmd_disable },
|
||||||
{ "erp_flush", hostapd_cli_cmd_erp_flush },
|
{ "erp_flush", hostapd_cli_cmd_erp_flush },
|
||||||
|
{ "log_level", hostapd_cli_cmd_log_level },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user