mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-29 16:24:03 -05:00
ca3b71c14f
There is no need to maintain two interfaces for fetching debug information about hostapd state. The control interface is more convenient for number of use cases, so prefer that over the dump_file mechanism. Signed-hostap: Jouni Malinen <j@w1.fi>
78 lines
1.7 KiB
C
78 lines
1.7 KiB
C
/*
|
|
* hostapd / State dump
|
|
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
|
|
*
|
|
* This software may be distributed under the terms of the BSD license.
|
|
* See README for more details.
|
|
*/
|
|
|
|
#include "utils/includes.h"
|
|
#include <time.h>
|
|
|
|
#include "utils/common.h"
|
|
#include "eapol_auth/eapol_auth_sm.h"
|
|
#include "eapol_auth/eapol_auth_sm_i.h"
|
|
#include "eap_server/eap.h"
|
|
#include "ap/hostapd.h"
|
|
#include "ap/ap_config.h"
|
|
#include "ap/sta_info.h"
|
|
#include "dump_state.h"
|
|
#include "ap/ap_drv_ops.h"
|
|
|
|
|
|
static void ieee802_1x_dump_state(FILE *f, const char *prefix,
|
|
struct sta_info *sta)
|
|
{
|
|
struct eapol_state_machine *sm = sta->eapol_sm;
|
|
if (sm == NULL)
|
|
return;
|
|
eapol_auth_dump_state(f, prefix, sm);
|
|
}
|
|
|
|
|
|
/**
|
|
* hostapd_dump_state - SIGUSR1 handler to dump hostapd state to a text file
|
|
*/
|
|
static void hostapd_dump_state(struct hostapd_data *hapd)
|
|
{
|
|
FILE *f;
|
|
time_t now;
|
|
struct sta_info *sta;
|
|
|
|
if (!hapd->conf->dump_log_name) {
|
|
wpa_printf(MSG_DEBUG, "Dump file not defined - ignoring dump "
|
|
"request");
|
|
return;
|
|
}
|
|
|
|
wpa_printf(MSG_DEBUG, "Dumping hostapd state to '%s'",
|
|
hapd->conf->dump_log_name);
|
|
f = fopen(hapd->conf->dump_log_name, "w");
|
|
if (f == NULL) {
|
|
wpa_printf(MSG_WARNING, "Could not open dump file '%s' for "
|
|
"writing.", hapd->conf->dump_log_name);
|
|
return;
|
|
}
|
|
|
|
time(&now);
|
|
fprintf(f, "hostapd state dump - %s", ctime(&now));
|
|
|
|
for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
|
|
fprintf(f, "\nSTA=" MACSTR "\n", MAC2STR(sta->addr));
|
|
ieee802_1x_dump_state(f, " ", sta);
|
|
}
|
|
|
|
fclose(f);
|
|
}
|
|
|
|
|
|
int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; i < iface->num_bss; i++)
|
|
hostapd_dump_state(iface->bss[i]);
|
|
|
|
return 0;
|
|
}
|