2009-11-29 13:18:47 -05:00
|
|
|
/*
|
|
|
|
* hostapd / State dump
|
|
|
|
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
2012-02-11 09:46:35 -05:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2009-11-29 13:18:47 -05:00
|
|
|
*/
|
|
|
|
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "utils/includes.h"
|
2011-09-12 15:15:13 -04:00
|
|
|
#include <time.h>
|
2009-11-29 13:18:47 -05:00
|
|
|
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "utils/common.h"
|
2009-11-29 13:18:47 -05:00
|
|
|
#include "eapol_auth/eapol_auth_sm.h"
|
2009-11-29 16:16:04 -05:00
|
|
|
#include "eapol_auth/eapol_auth_sm_i.h"
|
2009-11-29 13:18:47 -05:00
|
|
|
#include "eap_server/eap.h"
|
2009-12-24 18:12:50 -05:00
|
|
|
#include "ap/hostapd.h"
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "ap/ap_config.h"
|
2009-12-24 18:12:50 -05:00
|
|
|
#include "ap/sta_info.h"
|
2009-12-25 07:20:35 -05:00
|
|
|
#include "dump_state.h"
|
2013-01-06 13:39:30 -05:00
|
|
|
#include "ap/ap_drv_ops.h"
|
2009-11-29 13:18:47 -05:00
|
|
|
|
|
|
|
|
2014-01-02 10:37:21 -05:00
|
|
|
static void ieee802_1x_dump_state(FILE *f, struct sta_info *sta)
|
2009-11-29 13:18:47 -05:00
|
|
|
{
|
|
|
|
struct eapol_state_machine *sm = sta->eapol_sm;
|
2014-01-02 10:37:21 -05:00
|
|
|
char buf[4096];
|
|
|
|
int res;
|
|
|
|
|
2009-11-29 13:18:47 -05:00
|
|
|
if (sm == NULL)
|
|
|
|
return;
|
2014-01-02 10:37:21 -05:00
|
|
|
res = eapol_auth_dump_state(sm, buf, sizeof(buf));
|
|
|
|
if (res > 0)
|
|
|
|
fprintf(f, "%s", buf);
|
2009-11-29 13:18:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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));
|
2014-01-02 10:37:21 -05:00
|
|
|
ieee802_1x_dump_state(f, sta);
|
2009-11-29 13:18:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|