3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
21 #include "sta_flags.h"
23 #include "radius/radius_client.h"
24 #include "radius/radius_server.h"
25 #include "eapol_auth/eapol_auth_sm.h"
26 #include "eap_server/eap.h"
29 static void fprint_char(FILE *f, char c)
31 if (c >= 32 && c < 127)
34 fprintf(f, "<%02x>", c);
38 static void ieee802_1x_dump_state(FILE *f, const char *prefix,
41 struct eapol_state_machine *sm = sta->eapol_sm;
45 fprintf(f, "%sIEEE 802.1X:\n", prefix);
49 fprintf(f, "%sidentity=", prefix);
50 for (i = 0; i < sm->identity_len; i++)
51 fprint_char(f, sm->identity[i]);
55 fprintf(f, "%slast EAP type: Authentication Server: %d (%s) "
56 "Supplicant: %d (%s)\n", prefix,
58 eap_server_get_name(0, sm->eap_type_authsrv),
59 sm->eap_type_supp, eap_server_get_name(0, sm->eap_type_supp));
61 fprintf(f, "%scached_packets=%s\n", prefix,
62 sm->last_recv_radius ? "[RX RADIUS]" : "");
64 eapol_auth_dump_state(f, prefix, sm);
69 * hostapd_dump_state - SIGUSR1 handler to dump hostapd state to a text file
71 static void hostapd_dump_state(struct hostapd_data *hapd)
79 if (!hapd->conf->dump_log_name) {
80 wpa_printf(MSG_DEBUG, "Dump file not defined - ignoring dump "
85 wpa_printf(MSG_DEBUG, "Dumping hostapd state to '%s'",
86 hapd->conf->dump_log_name);
87 f = fopen(hapd->conf->dump_log_name, "w");
89 wpa_printf(MSG_WARNING, "Could not open dump file '%s' for "
90 "writing.", hapd->conf->dump_log_name);
95 fprintf(f, "hostapd state dump - %s", ctime(&now));
96 fprintf(f, "num_sta=%d num_sta_non_erp=%d "
97 "num_sta_no_short_slot_time=%d\n"
98 "num_sta_no_short_preamble=%d\n",
99 hapd->num_sta, hapd->iface->num_sta_non_erp,
100 hapd->iface->num_sta_no_short_slot_time,
101 hapd->iface->num_sta_no_short_preamble);
103 for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
104 fprintf(f, "\nSTA=" MACSTR "\n", MAC2STR(sta->addr));
107 " AID=%d flags=0x%x %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
108 " capability=0x%x listen_interval=%d\n",
111 (sta->flags & WLAN_STA_AUTH ? "[AUTH]" : ""),
112 (sta->flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""),
113 (sta->flags & WLAN_STA_PS ? "[PS]" : ""),
114 (sta->flags & WLAN_STA_TIM ? "[TIM]" : ""),
115 (sta->flags & WLAN_STA_PERM ? "[PERM]" : ""),
116 (sta->flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" :
118 (sta->flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" :
120 (sta->flags & WLAN_STA_SHORT_PREAMBLE ?
121 "[SHORT_PREAMBLE]" : ""),
122 (sta->flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""),
123 (sta->flags & WLAN_STA_WMM ? "[WMM]" : ""),
124 (sta->flags & WLAN_STA_MFP ? "[MFP]" : ""),
125 (sta->flags & WLAN_STA_WPS ? "[WPS]" : ""),
126 (sta->flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""),
127 (sta->flags & WLAN_STA_NONERP ? "[NonERP]" : ""),
129 sta->listen_interval);
131 fprintf(f, " supported_rates=");
132 for (i = 0; i < sta->supported_rates_len; i++)
133 fprintf(f, "%02x ", sta->supported_rates[i]);
137 " timeout_next=%s\n",
138 (sta->timeout_next == STA_NULLFUNC ? "NULLFUNC POLL" :
139 (sta->timeout_next == STA_DISASSOC ? "DISASSOC" :
142 ieee802_1x_dump_state(f, " ", sta);
145 buf = os_malloc(4096);
147 int count = radius_client_get_mib(hapd->radius, buf, 4096);
150 else if (count > 4095)
153 fprintf(f, "%s", buf);
155 count = radius_server_get_mib(hapd->radius_srv, buf, 4096);
158 else if (count > 4095)
161 fprintf(f, "%s", buf);
168 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx)
172 for (i = 0; i < iface->num_bss; i++)
173 hostapd_dump_state(iface->bss[i]);