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.
19 #include "radius/radius_client.h"
20 #include "radius/radius_server.h"
21 #include "eapol_auth/eapol_auth_sm.h"
22 #include "eapol_auth/eapol_auth_sm_i.h"
23 #include "eap_server/eap.h"
26 #include "sta_flags.h"
30 static void fprint_char(FILE *f, char c)
32 if (c >= 32 && c < 127)
35 fprintf(f, "<%02x>", c);
39 static void ieee802_1x_dump_state(FILE *f, const char *prefix,
42 struct eapol_state_machine *sm = sta->eapol_sm;
46 fprintf(f, "%sIEEE 802.1X:\n", prefix);
50 fprintf(f, "%sidentity=", prefix);
51 for (i = 0; i < sm->identity_len; i++)
52 fprint_char(f, sm->identity[i]);
56 fprintf(f, "%slast EAP type: Authentication Server: %d (%s) "
57 "Supplicant: %d (%s)\n", prefix,
59 eap_server_get_name(0, sm->eap_type_authsrv),
60 sm->eap_type_supp, eap_server_get_name(0, sm->eap_type_supp));
62 fprintf(f, "%scached_packets=%s\n", prefix,
63 sm->last_recv_radius ? "[RX RADIUS]" : "");
65 eapol_auth_dump_state(f, prefix, sm);
70 * hostapd_dump_state - SIGUSR1 handler to dump hostapd state to a text file
72 static void hostapd_dump_state(struct hostapd_data *hapd)
78 #ifndef CONFIG_NO_RADIUS
80 #endif /* CONFIG_NO_RADIUS */
82 if (!hapd->conf->dump_log_name) {
83 wpa_printf(MSG_DEBUG, "Dump file not defined - ignoring dump "
88 wpa_printf(MSG_DEBUG, "Dumping hostapd state to '%s'",
89 hapd->conf->dump_log_name);
90 f = fopen(hapd->conf->dump_log_name, "w");
92 wpa_printf(MSG_WARNING, "Could not open dump file '%s' for "
93 "writing.", hapd->conf->dump_log_name);
98 fprintf(f, "hostapd state dump - %s", ctime(&now));
99 fprintf(f, "num_sta=%d num_sta_non_erp=%d "
100 "num_sta_no_short_slot_time=%d\n"
101 "num_sta_no_short_preamble=%d\n",
102 hapd->num_sta, hapd->iface->num_sta_non_erp,
103 hapd->iface->num_sta_no_short_slot_time,
104 hapd->iface->num_sta_no_short_preamble);
106 for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
107 fprintf(f, "\nSTA=" MACSTR "\n", MAC2STR(sta->addr));
110 " AID=%d flags=0x%x %s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
111 " capability=0x%x listen_interval=%d\n",
114 (sta->flags & WLAN_STA_AUTH ? "[AUTH]" : ""),
115 (sta->flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""),
116 (sta->flags & WLAN_STA_PS ? "[PS]" : ""),
117 (sta->flags & WLAN_STA_TIM ? "[TIM]" : ""),
118 (sta->flags & WLAN_STA_PERM ? "[PERM]" : ""),
119 (sta->flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" :
121 (sta->flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" :
123 (sta->flags & WLAN_STA_SHORT_PREAMBLE ?
124 "[SHORT_PREAMBLE]" : ""),
125 (sta->flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""),
126 (sta->flags & WLAN_STA_WMM ? "[WMM]" : ""),
127 (sta->flags & WLAN_STA_MFP ? "[MFP]" : ""),
128 (sta->flags & WLAN_STA_WPS ? "[WPS]" : ""),
129 (sta->flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""),
130 (sta->flags & WLAN_STA_NONERP ? "[NonERP]" : ""),
132 sta->listen_interval);
134 fprintf(f, " supported_rates=");
135 for (i = 0; i < sta->supported_rates_len; i++)
136 fprintf(f, "%02x ", sta->supported_rates[i]);
140 " timeout_next=%s\n",
141 (sta->timeout_next == STA_NULLFUNC ? "NULLFUNC POLL" :
142 (sta->timeout_next == STA_DISASSOC ? "DISASSOC" :
145 ieee802_1x_dump_state(f, " ", sta);
148 #ifndef CONFIG_NO_RADIUS
149 buf = os_malloc(4096);
151 int count = radius_client_get_mib(hapd->radius, buf, 4096);
154 else if (count > 4095)
157 fprintf(f, "%s", buf);
160 count = radius_server_get_mib(hapd->radius_srv, buf, 4096);
163 else if (count > 4095)
166 fprintf(f, "%s", buf);
167 #endif /* RADIUS_SERVER */
171 #endif /* CONFIG_NO_RADIUS */
176 int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx)
180 for (i = 0; i < iface->num_bss; i++)
181 hostapd_dump_state(iface->bss[i]);