Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Station table |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 3 | * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "utils/eloop.h" |
| 13 | #include "common/ieee802_11_defs.h" |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 14 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 15 | #include "common/sae.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 16 | #include "radius/radius.h" |
| 17 | #include "radius/radius_client.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 18 | #include "p2p/p2p.h" |
| 19 | #include "hostapd.h" |
| 20 | #include "accounting.h" |
| 21 | #include "ieee802_1x.h" |
| 22 | #include "ieee802_11.h" |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 23 | #include "ieee802_11_auth.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 24 | #include "wpa_auth.h" |
| 25 | #include "preauth_auth.h" |
| 26 | #include "ap_config.h" |
| 27 | #include "beacon.h" |
| 28 | #include "ap_mlme.h" |
| 29 | #include "vlan_init.h" |
| 30 | #include "p2p_hostapd.h" |
| 31 | #include "ap_drv_ops.h" |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 32 | #include "gas_serv.h" |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 33 | #include "wnm_ap.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 34 | #include "sta_info.h" |
| 35 | |
| 36 | static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, |
| 37 | struct sta_info *sta); |
| 38 | static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 39 | static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 40 | static void ap_sta_deauth_cb_timeout(void *eloop_ctx, void *timeout_ctx); |
| 41 | static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 42 | #ifdef CONFIG_IEEE80211W |
| 43 | static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx); |
| 44 | #endif /* CONFIG_IEEE80211W */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 45 | static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 46 | |
| 47 | int ap_for_each_sta(struct hostapd_data *hapd, |
| 48 | int (*cb)(struct hostapd_data *hapd, struct sta_info *sta, |
| 49 | void *ctx), |
| 50 | void *ctx) |
| 51 | { |
| 52 | struct sta_info *sta; |
| 53 | |
| 54 | for (sta = hapd->sta_list; sta; sta = sta->next) { |
| 55 | if (cb(hapd, sta, ctx)) |
| 56 | return 1; |
| 57 | } |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | |
| 63 | struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta) |
| 64 | { |
| 65 | struct sta_info *s; |
| 66 | |
| 67 | s = hapd->sta_hash[STA_HASH(sta)]; |
| 68 | while (s != NULL && os_memcmp(s->addr, sta, 6) != 0) |
| 69 | s = s->hnext; |
| 70 | return s; |
| 71 | } |
| 72 | |
| 73 | |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 74 | #ifdef CONFIG_P2P |
| 75 | struct sta_info * ap_get_sta_p2p(struct hostapd_data *hapd, const u8 *addr) |
| 76 | { |
| 77 | struct sta_info *sta; |
| 78 | |
| 79 | for (sta = hapd->sta_list; sta; sta = sta->next) { |
| 80 | const u8 *p2p_dev_addr; |
| 81 | |
| 82 | if (sta->p2p_ie == NULL) |
| 83 | continue; |
| 84 | |
| 85 | p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie); |
| 86 | if (p2p_dev_addr == NULL) |
| 87 | continue; |
| 88 | |
| 89 | if (os_memcmp(p2p_dev_addr, addr, ETH_ALEN) == 0) |
| 90 | return sta; |
| 91 | } |
| 92 | |
| 93 | return NULL; |
| 94 | } |
| 95 | #endif /* CONFIG_P2P */ |
| 96 | |
| 97 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 98 | static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta) |
| 99 | { |
| 100 | struct sta_info *tmp; |
| 101 | |
| 102 | if (hapd->sta_list == sta) { |
| 103 | hapd->sta_list = sta->next; |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | tmp = hapd->sta_list; |
| 108 | while (tmp != NULL && tmp->next != sta) |
| 109 | tmp = tmp->next; |
| 110 | if (tmp == NULL) { |
| 111 | wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from " |
| 112 | "list.", MAC2STR(sta->addr)); |
| 113 | } else |
| 114 | tmp->next = sta->next; |
| 115 | } |
| 116 | |
| 117 | |
| 118 | void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta) |
| 119 | { |
| 120 | sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)]; |
| 121 | hapd->sta_hash[STA_HASH(sta->addr)] = sta; |
| 122 | } |
| 123 | |
| 124 | |
| 125 | static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta) |
| 126 | { |
| 127 | struct sta_info *s; |
| 128 | |
| 129 | s = hapd->sta_hash[STA_HASH(sta->addr)]; |
| 130 | if (s == NULL) return; |
| 131 | if (os_memcmp(s->addr, sta->addr, 6) == 0) { |
| 132 | hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext; |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | while (s->hnext != NULL && |
| 137 | os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0) |
| 138 | s = s->hnext; |
| 139 | if (s->hnext != NULL) |
| 140 | s->hnext = s->hnext->hnext; |
| 141 | else |
| 142 | wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR |
| 143 | " from hash table", MAC2STR(sta->addr)); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) |
| 148 | { |
| 149 | int set_beacon = 0; |
| 150 | |
| 151 | accounting_sta_stop(hapd, sta); |
| 152 | |
| 153 | /* just in case */ |
| 154 | ap_sta_set_authorized(hapd, sta, 0); |
| 155 | |
| 156 | if (sta->flags & WLAN_STA_WDS) |
Dmitry Shmidt | c2ebb4b | 2013-07-24 12:57:51 -0700 | [diff] [blame] | 157 | hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 158 | |
Dmitry Shmidt | a38abf9 | 2014-03-06 13:38:44 -0800 | [diff] [blame] | 159 | if (!hapd->iface->driver_ap_teardown && |
| 160 | !(sta->flags & WLAN_STA_PREAUTH)) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 161 | hostapd_drv_sta_remove(hapd, sta->addr); |
| 162 | |
| 163 | ap_sta_hash_del(hapd, sta); |
| 164 | ap_sta_list_del(hapd, sta); |
| 165 | |
| 166 | if (sta->aid > 0) |
| 167 | hapd->sta_aid[(sta->aid - 1) / 32] &= |
| 168 | ~BIT((sta->aid - 1) % 32); |
| 169 | |
| 170 | hapd->num_sta--; |
| 171 | if (sta->nonerp_set) { |
| 172 | sta->nonerp_set = 0; |
| 173 | hapd->iface->num_sta_non_erp--; |
| 174 | if (hapd->iface->num_sta_non_erp == 0) |
| 175 | set_beacon++; |
| 176 | } |
| 177 | |
| 178 | if (sta->no_short_slot_time_set) { |
| 179 | sta->no_short_slot_time_set = 0; |
| 180 | hapd->iface->num_sta_no_short_slot_time--; |
| 181 | if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G |
| 182 | && hapd->iface->num_sta_no_short_slot_time == 0) |
| 183 | set_beacon++; |
| 184 | } |
| 185 | |
| 186 | if (sta->no_short_preamble_set) { |
| 187 | sta->no_short_preamble_set = 0; |
| 188 | hapd->iface->num_sta_no_short_preamble--; |
| 189 | if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G |
| 190 | && hapd->iface->num_sta_no_short_preamble == 0) |
| 191 | set_beacon++; |
| 192 | } |
| 193 | |
| 194 | if (sta->no_ht_gf_set) { |
| 195 | sta->no_ht_gf_set = 0; |
| 196 | hapd->iface->num_sta_ht_no_gf--; |
| 197 | } |
| 198 | |
| 199 | if (sta->no_ht_set) { |
| 200 | sta->no_ht_set = 0; |
| 201 | hapd->iface->num_sta_no_ht--; |
| 202 | } |
| 203 | |
| 204 | if (sta->ht_20mhz_set) { |
| 205 | sta->ht_20mhz_set = 0; |
| 206 | hapd->iface->num_sta_ht_20mhz--; |
| 207 | } |
| 208 | |
| 209 | #ifdef CONFIG_P2P |
| 210 | if (sta->no_p2p_set) { |
| 211 | sta->no_p2p_set = 0; |
| 212 | hapd->num_sta_no_p2p--; |
| 213 | if (hapd->num_sta_no_p2p == 0) |
| 214 | hostapd_p2p_non_p2p_sta_disconnected(hapd); |
| 215 | } |
| 216 | #endif /* CONFIG_P2P */ |
| 217 | |
| 218 | #if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N) |
| 219 | if (hostapd_ht_operation_update(hapd->iface) > 0) |
| 220 | set_beacon++; |
| 221 | #endif /* NEED_AP_MLME && CONFIG_IEEE80211N */ |
| 222 | |
| 223 | if (set_beacon) |
| 224 | ieee802_11_set_beacons(hapd->iface); |
| 225 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 226 | wpa_printf(MSG_DEBUG, "%s: cancel ap_handle_timer for " MACSTR, |
| 227 | __func__, MAC2STR(sta->addr)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 228 | eloop_cancel_timeout(ap_handle_timer, hapd, sta); |
| 229 | eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 230 | eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 231 | eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); |
| 232 | eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 233 | |
| 234 | ieee802_1x_free_station(sta); |
| 235 | wpa_auth_sta_deinit(sta->wpa_sm); |
| 236 | rsn_preauth_free_station(hapd, sta); |
| 237 | #ifndef CONFIG_NO_RADIUS |
Dmitry Shmidt | 9657139 | 2013-10-14 12:54:46 -0700 | [diff] [blame] | 238 | if (hapd->radius) |
| 239 | radius_client_flush_auth(hapd->radius, sta->addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 240 | #endif /* CONFIG_NO_RADIUS */ |
| 241 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 242 | os_free(sta->challenge); |
| 243 | |
| 244 | #ifdef CONFIG_IEEE80211W |
| 245 | os_free(sta->sa_query_trans_id); |
| 246 | eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); |
| 247 | #endif /* CONFIG_IEEE80211W */ |
| 248 | |
| 249 | #ifdef CONFIG_P2P |
| 250 | p2p_group_notif_disassoc(hapd->p2p_group, sta->addr); |
| 251 | #endif /* CONFIG_P2P */ |
| 252 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 253 | #ifdef CONFIG_INTERWORKING |
| 254 | if (sta->gas_dialog) { |
| 255 | int i; |
| 256 | for (i = 0; i < GAS_DIALOG_MAX; i++) |
| 257 | gas_serv_dialog_clear(&sta->gas_dialog[i]); |
| 258 | os_free(sta->gas_dialog); |
| 259 | } |
| 260 | #endif /* CONFIG_INTERWORKING */ |
| 261 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 262 | wpabuf_free(sta->wps_ie); |
| 263 | wpabuf_free(sta->p2p_ie); |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 264 | wpabuf_free(sta->hs20_ie); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 265 | |
| 266 | os_free(sta->ht_capabilities); |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 267 | os_free(sta->vht_capabilities); |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 268 | hostapd_free_psk_list(sta->psk); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 269 | os_free(sta->identity); |
| 270 | os_free(sta->radius_cui); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 271 | os_free(sta->remediation_url); |
| 272 | wpabuf_free(sta->hs20_deauth_req); |
| 273 | os_free(sta->hs20_session_info_url); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 274 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 275 | #ifdef CONFIG_SAE |
| 276 | sae_clear_data(sta->sae); |
| 277 | os_free(sta->sae); |
| 278 | #endif /* CONFIG_SAE */ |
| 279 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 280 | os_free(sta); |
| 281 | } |
| 282 | |
| 283 | |
| 284 | void hostapd_free_stas(struct hostapd_data *hapd) |
| 285 | { |
| 286 | struct sta_info *sta, *prev; |
| 287 | |
| 288 | sta = hapd->sta_list; |
| 289 | |
| 290 | while (sta) { |
| 291 | prev = sta; |
| 292 | if (sta->flags & WLAN_STA_AUTH) { |
| 293 | mlme_deauthenticate_indication( |
| 294 | hapd, sta, WLAN_REASON_UNSPECIFIED); |
| 295 | } |
| 296 | sta = sta->next; |
| 297 | wpa_printf(MSG_DEBUG, "Removing station " MACSTR, |
| 298 | MAC2STR(prev->addr)); |
| 299 | ap_free_sta(hapd, prev); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | |
| 304 | /** |
| 305 | * ap_handle_timer - Per STA timer handler |
| 306 | * @eloop_ctx: struct hostapd_data * |
| 307 | * @timeout_ctx: struct sta_info * |
| 308 | * |
| 309 | * This function is called to check station activity and to remove inactive |
| 310 | * stations. |
| 311 | */ |
| 312 | void ap_handle_timer(void *eloop_ctx, void *timeout_ctx) |
| 313 | { |
| 314 | struct hostapd_data *hapd = eloop_ctx; |
| 315 | struct sta_info *sta = timeout_ctx; |
| 316 | unsigned long next_time = 0; |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 317 | int reason; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 318 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 319 | wpa_printf(MSG_DEBUG, "%s: " MACSTR " flags=0x%x timeout_next=%d", |
| 320 | __func__, MAC2STR(sta->addr), sta->flags, |
| 321 | sta->timeout_next); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 322 | if (sta->timeout_next == STA_REMOVE) { |
| 323 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 324 | HOSTAPD_LEVEL_INFO, "deauthenticated due to " |
| 325 | "local deauth request"); |
| 326 | ap_free_sta(hapd, sta); |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | if ((sta->flags & WLAN_STA_ASSOC) && |
| 331 | (sta->timeout_next == STA_NULLFUNC || |
| 332 | sta->timeout_next == STA_DISASSOC)) { |
| 333 | int inactive_sec; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 334 | /* |
| 335 | * Add random value to timeout so that we don't end up bouncing |
| 336 | * all stations at the same time if we have lots of associated |
| 337 | * stations that are idle (but keep re-associating). |
| 338 | */ |
| 339 | int fuzz = os_random() % 20; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 340 | inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr); |
| 341 | if (inactive_sec == -1) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 342 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 343 | "Check inactivity: Could not " |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 344 | "get station info from kernel driver for " |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 345 | MACSTR, MAC2STR(sta->addr)); |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 346 | /* |
| 347 | * The driver may not support this functionality. |
| 348 | * Anyway, try again after the next inactivity timeout, |
| 349 | * but do not disconnect the station now. |
| 350 | */ |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 351 | next_time = hapd->conf->ap_max_inactivity + fuzz; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 352 | } else if (inactive_sec < hapd->conf->ap_max_inactivity && |
| 353 | sta->flags & WLAN_STA_ASSOC) { |
| 354 | /* station activity detected; reset timeout state */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 355 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 356 | "Station " MACSTR " has been active %is ago", |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 357 | MAC2STR(sta->addr), inactive_sec); |
| 358 | sta->timeout_next = STA_NULLFUNC; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 359 | next_time = hapd->conf->ap_max_inactivity + fuzz - |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 360 | inactive_sec; |
| 361 | } else { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 362 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 363 | "Station " MACSTR " has been " |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 364 | "inactive too long: %d sec, max allowed: %d", |
| 365 | MAC2STR(sta->addr), inactive_sec, |
| 366 | hapd->conf->ap_max_inactivity); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 367 | |
| 368 | if (hapd->conf->skip_inactivity_poll) |
| 369 | sta->timeout_next = STA_DISASSOC; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
| 373 | if ((sta->flags & WLAN_STA_ASSOC) && |
| 374 | sta->timeout_next == STA_DISASSOC && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 375 | !(sta->flags & WLAN_STA_PENDING_POLL) && |
| 376 | !hapd->conf->skip_inactivity_poll) { |
| 377 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR |
| 378 | " has ACKed data poll", MAC2STR(sta->addr)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 379 | /* data nullfunc frame poll did not produce TX errors; assume |
| 380 | * station ACKed it */ |
| 381 | sta->timeout_next = STA_NULLFUNC; |
| 382 | next_time = hapd->conf->ap_max_inactivity; |
| 383 | } |
| 384 | |
| 385 | if (next_time) { |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 386 | wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout " |
| 387 | "for " MACSTR " (%lu seconds)", |
| 388 | __func__, MAC2STR(sta->addr), next_time); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 389 | eloop_register_timeout(next_time, 0, ap_handle_timer, hapd, |
| 390 | sta); |
| 391 | return; |
| 392 | } |
| 393 | |
| 394 | if (sta->timeout_next == STA_NULLFUNC && |
| 395 | (sta->flags & WLAN_STA_ASSOC)) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 396 | wpa_printf(MSG_DEBUG, " Polling STA"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 397 | sta->flags |= WLAN_STA_PENDING_POLL; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 398 | hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr, |
| 399 | sta->flags & WLAN_STA_WMM); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 400 | } else if (sta->timeout_next != STA_REMOVE) { |
| 401 | int deauth = sta->timeout_next == STA_DEAUTH; |
| 402 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 403 | wpa_dbg(hapd->msg_ctx, MSG_DEBUG, |
| 404 | "Timeout, sending %s info to STA " MACSTR, |
| 405 | deauth ? "deauthentication" : "disassociation", |
| 406 | MAC2STR(sta->addr)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 407 | |
| 408 | if (deauth) { |
| 409 | hostapd_drv_sta_deauth( |
| 410 | hapd, sta->addr, |
| 411 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 412 | } else { |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 413 | reason = (sta->timeout_next == STA_DISASSOC) ? |
| 414 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY : |
| 415 | WLAN_REASON_PREV_AUTH_NOT_VALID; |
| 416 | |
| 417 | hostapd_drv_sta_disassoc(hapd, sta->addr, reason); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 418 | } |
| 419 | } |
| 420 | |
| 421 | switch (sta->timeout_next) { |
| 422 | case STA_NULLFUNC: |
| 423 | sta->timeout_next = STA_DISASSOC; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 424 | wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout " |
| 425 | "for " MACSTR " (%d seconds - AP_DISASSOC_DELAY)", |
| 426 | __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 427 | eloop_register_timeout(AP_DISASSOC_DELAY, 0, ap_handle_timer, |
| 428 | hapd, sta); |
| 429 | break; |
| 430 | case STA_DISASSOC: |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 431 | case STA_DISASSOC_FROM_CLI: |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 432 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 433 | sta->flags &= ~WLAN_STA_ASSOC; |
| 434 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
| 435 | if (!sta->acct_terminate_cause) |
| 436 | sta->acct_terminate_cause = |
| 437 | RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT; |
| 438 | accounting_sta_stop(hapd, sta); |
| 439 | ieee802_1x_free_station(sta); |
| 440 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 441 | HOSTAPD_LEVEL_INFO, "disassociated due to " |
| 442 | "inactivity"); |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 443 | reason = (sta->timeout_next == STA_DISASSOC) ? |
| 444 | WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY : |
| 445 | WLAN_REASON_PREV_AUTH_NOT_VALID; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 446 | sta->timeout_next = STA_DEAUTH; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 447 | wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout " |
| 448 | "for " MACSTR " (%d seconds - AP_DEAUTH_DELAY)", |
| 449 | __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 450 | eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer, |
| 451 | hapd, sta); |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 452 | mlme_disassociate_indication(hapd, sta, reason); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 453 | break; |
| 454 | case STA_DEAUTH: |
| 455 | case STA_REMOVE: |
| 456 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 457 | HOSTAPD_LEVEL_INFO, "deauthenticated due to " |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 458 | "inactivity (timer DEAUTH/REMOVE)"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 459 | if (!sta->acct_terminate_cause) |
| 460 | sta->acct_terminate_cause = |
| 461 | RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT; |
| 462 | mlme_deauthenticate_indication( |
| 463 | hapd, sta, |
| 464 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 465 | ap_free_sta(hapd, sta); |
| 466 | break; |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | |
| 471 | static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx) |
| 472 | { |
| 473 | struct hostapd_data *hapd = eloop_ctx; |
| 474 | struct sta_info *sta = timeout_ctx; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 475 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 476 | if (!(sta->flags & WLAN_STA_AUTH)) { |
| 477 | if (sta->flags & WLAN_STA_GAS) { |
| 478 | wpa_printf(MSG_DEBUG, "GAS: Remove temporary STA " |
| 479 | "entry " MACSTR, MAC2STR(sta->addr)); |
| 480 | ap_free_sta(hapd, sta); |
| 481 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 482 | return; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 483 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 484 | |
Dmitry Shmidt | 818ea48 | 2014-03-10 13:15:21 -0700 | [diff] [blame] | 485 | hostapd_drv_sta_deauth(hapd, sta->addr, |
| 486 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 487 | mlme_deauthenticate_indication(hapd, sta, |
| 488 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 489 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 490 | HOSTAPD_LEVEL_INFO, "deauthenticated due to " |
| 491 | "session timeout"); |
| 492 | sta->acct_terminate_cause = |
| 493 | RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 494 | ap_free_sta(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | |
Dmitry Shmidt | 5460547 | 2013-11-08 11:10:19 -0800 | [diff] [blame] | 498 | void ap_sta_replenish_timeout(struct hostapd_data *hapd, struct sta_info *sta, |
| 499 | u32 session_timeout) |
| 500 | { |
| 501 | if (eloop_replenish_timeout(session_timeout, 0, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 502 | ap_handle_session_timer, hapd, sta) == 1) { |
Dmitry Shmidt | 5460547 | 2013-11-08 11:10:19 -0800 | [diff] [blame] | 503 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 504 | HOSTAPD_LEVEL_DEBUG, "setting session timeout " |
| 505 | "to %d seconds", session_timeout); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 510 | void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta, |
| 511 | u32 session_timeout) |
| 512 | { |
| 513 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 514 | HOSTAPD_LEVEL_DEBUG, "setting session timeout to %d " |
| 515 | "seconds", session_timeout); |
| 516 | eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); |
| 517 | eloop_register_timeout(session_timeout, 0, ap_handle_session_timer, |
| 518 | hapd, sta); |
| 519 | } |
| 520 | |
| 521 | |
| 522 | void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta) |
| 523 | { |
| 524 | eloop_cancel_timeout(ap_handle_session_timer, hapd, sta); |
| 525 | } |
| 526 | |
| 527 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 528 | static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx) |
| 529 | { |
| 530 | #ifdef CONFIG_WNM |
| 531 | struct hostapd_data *hapd = eloop_ctx; |
| 532 | struct sta_info *sta = timeout_ctx; |
| 533 | |
| 534 | wpa_printf(MSG_DEBUG, "WNM: Session warning time reached for " MACSTR, |
| 535 | MAC2STR(sta->addr)); |
| 536 | if (sta->hs20_session_info_url == NULL) |
| 537 | return; |
| 538 | |
| 539 | wnm_send_ess_disassoc_imminent(hapd, sta, sta->hs20_session_info_url, |
| 540 | sta->hs20_disassoc_timer); |
| 541 | #endif /* CONFIG_WNM */ |
| 542 | } |
| 543 | |
| 544 | |
| 545 | void ap_sta_session_warning_timeout(struct hostapd_data *hapd, |
| 546 | struct sta_info *sta, int warning_time) |
| 547 | { |
| 548 | eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta); |
| 549 | eloop_register_timeout(warning_time, 0, ap_handle_session_warning_timer, |
| 550 | hapd, sta); |
| 551 | } |
| 552 | |
| 553 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 554 | struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) |
| 555 | { |
| 556 | struct sta_info *sta; |
| 557 | |
| 558 | sta = ap_get_sta(hapd, addr); |
| 559 | if (sta) |
| 560 | return sta; |
| 561 | |
| 562 | wpa_printf(MSG_DEBUG, " New STA"); |
| 563 | if (hapd->num_sta >= hapd->conf->max_num_sta) { |
| 564 | /* FIX: might try to remove some old STAs first? */ |
| 565 | wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)", |
| 566 | hapd->num_sta, hapd->conf->max_num_sta); |
| 567 | return NULL; |
| 568 | } |
| 569 | |
| 570 | sta = os_zalloc(sizeof(struct sta_info)); |
| 571 | if (sta == NULL) { |
| 572 | wpa_printf(MSG_ERROR, "malloc failed"); |
| 573 | return NULL; |
| 574 | } |
| 575 | sta->acct_interim_interval = hapd->conf->acct_interim_interval; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 576 | accounting_sta_get_id(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 577 | |
Dmitry Shmidt | 01904cf | 2013-12-05 11:08:35 -0800 | [diff] [blame] | 578 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_INACTIVITY_TIMER)) { |
| 579 | wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout " |
| 580 | "for " MACSTR " (%d seconds - ap_max_inactivity)", |
| 581 | __func__, MAC2STR(addr), |
| 582 | hapd->conf->ap_max_inactivity); |
| 583 | eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, |
| 584 | ap_handle_timer, hapd, sta); |
| 585 | } |
| 586 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 587 | /* initialize STA info data */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 588 | os_memcpy(sta->addr, addr, ETH_ALEN); |
| 589 | sta->next = hapd->sta_list; |
| 590 | hapd->sta_list = sta; |
| 591 | hapd->num_sta++; |
| 592 | ap_sta_hash_add(hapd, sta); |
| 593 | sta->ssid = &hapd->conf->ssid; |
| 594 | ap_sta_remove_in_other_bss(hapd, sta); |
| 595 | |
| 596 | return sta; |
| 597 | } |
| 598 | |
| 599 | |
| 600 | static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta) |
| 601 | { |
| 602 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
| 603 | |
| 604 | wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver", |
| 605 | MAC2STR(sta->addr)); |
| 606 | if (hostapd_drv_sta_remove(hapd, sta->addr) && |
| 607 | sta->flags & WLAN_STA_ASSOC) { |
| 608 | wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR |
| 609 | " from kernel driver.", MAC2STR(sta->addr)); |
| 610 | return -1; |
| 611 | } |
| 612 | return 0; |
| 613 | } |
| 614 | |
| 615 | |
| 616 | static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, |
| 617 | struct sta_info *sta) |
| 618 | { |
| 619 | struct hostapd_iface *iface = hapd->iface; |
| 620 | size_t i; |
| 621 | |
| 622 | for (i = 0; i < iface->num_bss; i++) { |
| 623 | struct hostapd_data *bss = iface->bss[i]; |
| 624 | struct sta_info *sta2; |
| 625 | /* bss should always be set during operation, but it may be |
| 626 | * NULL during reconfiguration. Assume the STA is not |
| 627 | * associated to another BSS in that case to avoid NULL pointer |
| 628 | * dereferences. */ |
| 629 | if (bss == hapd || bss == NULL) |
| 630 | continue; |
| 631 | sta2 = ap_get_sta(bss, sta->addr); |
| 632 | if (!sta2) |
| 633 | continue; |
| 634 | |
| 635 | ap_sta_disconnect(bss, sta2, sta2->addr, |
| 636 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 641 | static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx) |
| 642 | { |
| 643 | struct hostapd_data *hapd = eloop_ctx; |
| 644 | struct sta_info *sta = timeout_ctx; |
| 645 | |
| 646 | ap_sta_remove(hapd, sta); |
| 647 | mlme_disassociate_indication(hapd, sta, sta->disassoc_reason); |
| 648 | } |
| 649 | |
| 650 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 651 | void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta, |
| 652 | u16 reason) |
| 653 | { |
| 654 | wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR, |
| 655 | hapd->conf->iface, MAC2STR(sta->addr)); |
Dmitry Shmidt | 700a137 | 2013-03-15 14:14:44 -0700 | [diff] [blame] | 656 | sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 657 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 658 | sta->timeout_next = STA_DEAUTH; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 659 | wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout " |
| 660 | "for " MACSTR " (%d seconds - " |
| 661 | "AP_MAX_INACTIVITY_AFTER_DISASSOC)", |
| 662 | __func__, MAC2STR(sta->addr), |
| 663 | AP_MAX_INACTIVITY_AFTER_DISASSOC); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 664 | eloop_cancel_timeout(ap_handle_timer, hapd, sta); |
| 665 | eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0, |
| 666 | ap_handle_timer, hapd, sta); |
| 667 | accounting_sta_stop(hapd, sta); |
| 668 | ieee802_1x_free_station(sta); |
| 669 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 670 | sta->disassoc_reason = reason; |
| 671 | sta->flags |= WLAN_STA_PENDING_DISASSOC_CB; |
| 672 | eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); |
| 673 | eloop_register_timeout(hapd->iface->drv_flags & |
| 674 | WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0, |
| 675 | ap_sta_disassoc_cb_timeout, hapd, sta); |
| 676 | } |
| 677 | |
| 678 | |
| 679 | static void ap_sta_deauth_cb_timeout(void *eloop_ctx, void *timeout_ctx) |
| 680 | { |
| 681 | struct hostapd_data *hapd = eloop_ctx; |
| 682 | struct sta_info *sta = timeout_ctx; |
| 683 | |
| 684 | ap_sta_remove(hapd, sta); |
| 685 | mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | |
| 689 | void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta, |
| 690 | u16 reason) |
| 691 | { |
| 692 | wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR, |
| 693 | hapd->conf->iface, MAC2STR(sta->addr)); |
| 694 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 695 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 696 | sta->timeout_next = STA_REMOVE; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 697 | wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout " |
| 698 | "for " MACSTR " (%d seconds - " |
| 699 | "AP_MAX_INACTIVITY_AFTER_DEAUTH)", |
| 700 | __func__, MAC2STR(sta->addr), |
| 701 | AP_MAX_INACTIVITY_AFTER_DEAUTH); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 702 | eloop_cancel_timeout(ap_handle_timer, hapd, sta); |
| 703 | eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0, |
| 704 | ap_handle_timer, hapd, sta); |
| 705 | accounting_sta_stop(hapd, sta); |
| 706 | ieee802_1x_free_station(sta); |
| 707 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 708 | sta->deauth_reason = reason; |
| 709 | sta->flags |= WLAN_STA_PENDING_DEAUTH_CB; |
| 710 | eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); |
| 711 | eloop_register_timeout(hapd->iface->drv_flags & |
| 712 | WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0, |
| 713 | ap_sta_deauth_cb_timeout, hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 717 | #ifdef CONFIG_WPS |
| 718 | int ap_sta_wps_cancel(struct hostapd_data *hapd, |
| 719 | struct sta_info *sta, void *ctx) |
| 720 | { |
| 721 | if (sta && (sta->flags & WLAN_STA_WPS)) { |
| 722 | ap_sta_deauthenticate(hapd, sta, |
| 723 | WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 724 | wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR, |
| 725 | __func__, MAC2STR(sta->addr)); |
| 726 | return 1; |
| 727 | } |
| 728 | |
| 729 | return 0; |
| 730 | } |
| 731 | #endif /* CONFIG_WPS */ |
| 732 | |
| 733 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 734 | int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta, |
| 735 | int old_vlanid) |
| 736 | { |
| 737 | #ifndef CONFIG_NO_VLAN |
| 738 | const char *iface; |
| 739 | struct hostapd_vlan *vlan = NULL; |
| 740 | int ret; |
| 741 | |
| 742 | /* |
| 743 | * Do not proceed furthur if the vlan id remains same. We do not want |
| 744 | * duplicate dynamic vlan entries. |
| 745 | */ |
| 746 | if (sta->vlan_id == old_vlanid) |
| 747 | return 0; |
| 748 | |
| 749 | /* |
| 750 | * During 1x reauth, if the vlan id changes, then remove the old id and |
| 751 | * proceed furthur to add the new one. |
| 752 | */ |
| 753 | if (old_vlanid > 0) |
| 754 | vlan_remove_dynamic(hapd, old_vlanid); |
| 755 | |
| 756 | iface = hapd->conf->iface; |
| 757 | if (sta->ssid->vlan[0]) |
| 758 | iface = sta->ssid->vlan; |
| 759 | |
| 760 | if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED) |
| 761 | sta->vlan_id = 0; |
| 762 | else if (sta->vlan_id > 0) { |
Dmitry Shmidt | d5c075b | 2013-08-05 14:36:10 -0700 | [diff] [blame] | 763 | struct hostapd_vlan *wildcard_vlan = NULL; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 764 | vlan = hapd->conf->vlan; |
| 765 | while (vlan) { |
Dmitry Shmidt | d5c075b | 2013-08-05 14:36:10 -0700 | [diff] [blame] | 766 | if (vlan->vlan_id == sta->vlan_id) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 767 | break; |
Dmitry Shmidt | d5c075b | 2013-08-05 14:36:10 -0700 | [diff] [blame] | 768 | if (vlan->vlan_id == VLAN_ID_WILDCARD) |
| 769 | wildcard_vlan = vlan; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 770 | vlan = vlan->next; |
| 771 | } |
Dmitry Shmidt | d5c075b | 2013-08-05 14:36:10 -0700 | [diff] [blame] | 772 | if (!vlan) |
| 773 | vlan = wildcard_vlan; |
| 774 | if (vlan) |
| 775 | iface = vlan->ifname; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | if (sta->vlan_id > 0 && vlan == NULL) { |
| 779 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 780 | HOSTAPD_LEVEL_DEBUG, "could not find VLAN for " |
| 781 | "binding station to (vlan_id=%d)", |
| 782 | sta->vlan_id); |
| 783 | return -1; |
| 784 | } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) { |
| 785 | vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id); |
| 786 | if (vlan == NULL) { |
| 787 | hostapd_logger(hapd, sta->addr, |
| 788 | HOSTAPD_MODULE_IEEE80211, |
| 789 | HOSTAPD_LEVEL_DEBUG, "could not add " |
| 790 | "dynamic VLAN interface for vlan_id=%d", |
| 791 | sta->vlan_id); |
| 792 | return -1; |
| 793 | } |
| 794 | |
| 795 | iface = vlan->ifname; |
| 796 | if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) { |
| 797 | hostapd_logger(hapd, sta->addr, |
| 798 | HOSTAPD_MODULE_IEEE80211, |
| 799 | HOSTAPD_LEVEL_DEBUG, "could not " |
| 800 | "configure encryption for dynamic VLAN " |
| 801 | "interface for vlan_id=%d", |
| 802 | sta->vlan_id); |
| 803 | } |
| 804 | |
| 805 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 806 | HOSTAPD_LEVEL_DEBUG, "added new dynamic VLAN " |
| 807 | "interface '%s'", iface); |
| 808 | } else if (vlan && vlan->vlan_id == sta->vlan_id) { |
| 809 | if (sta->vlan_id > 0) { |
| 810 | vlan->dynamic_vlan++; |
| 811 | hostapd_logger(hapd, sta->addr, |
| 812 | HOSTAPD_MODULE_IEEE80211, |
| 813 | HOSTAPD_LEVEL_DEBUG, "updated existing " |
| 814 | "dynamic VLAN interface '%s'", iface); |
| 815 | } |
| 816 | |
| 817 | /* |
| 818 | * Update encryption configuration for statically generated |
| 819 | * VLAN interface. This is only used for static WEP |
| 820 | * configuration for the case where hostapd did not yet know |
| 821 | * which keys are to be used when the interface was added. |
| 822 | */ |
| 823 | if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) { |
| 824 | hostapd_logger(hapd, sta->addr, |
| 825 | HOSTAPD_MODULE_IEEE80211, |
| 826 | HOSTAPD_LEVEL_DEBUG, "could not " |
| 827 | "configure encryption for VLAN " |
| 828 | "interface for vlan_id=%d", |
| 829 | sta->vlan_id); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 834 | HOSTAPD_LEVEL_DEBUG, "binding station to interface " |
| 835 | "'%s'", iface); |
| 836 | |
| 837 | if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0) |
| 838 | wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA"); |
| 839 | |
| 840 | ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id); |
| 841 | if (ret < 0) { |
| 842 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 843 | HOSTAPD_LEVEL_DEBUG, "could not bind the STA " |
| 844 | "entry to vlan_id=%d", sta->vlan_id); |
| 845 | } |
| 846 | return ret; |
| 847 | #else /* CONFIG_NO_VLAN */ |
| 848 | return 0; |
| 849 | #endif /* CONFIG_NO_VLAN */ |
| 850 | } |
| 851 | |
| 852 | |
| 853 | #ifdef CONFIG_IEEE80211W |
| 854 | |
| 855 | int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta) |
| 856 | { |
| 857 | u32 tu; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 858 | struct os_reltime now, passed; |
| 859 | os_get_reltime(&now); |
| 860 | os_reltime_sub(&now, &sta->sa_query_start, &passed); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 861 | tu = (passed.sec * 1000000 + passed.usec) / 1024; |
| 862 | if (hapd->conf->assoc_sa_query_max_timeout < tu) { |
| 863 | hostapd_logger(hapd, sta->addr, |
| 864 | HOSTAPD_MODULE_IEEE80211, |
| 865 | HOSTAPD_LEVEL_DEBUG, |
| 866 | "association SA Query timed out"); |
| 867 | sta->sa_query_timed_out = 1; |
| 868 | os_free(sta->sa_query_trans_id); |
| 869 | sta->sa_query_trans_id = NULL; |
| 870 | sta->sa_query_count = 0; |
| 871 | eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); |
| 872 | return 1; |
| 873 | } |
| 874 | |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | |
| 879 | static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx) |
| 880 | { |
| 881 | struct hostapd_data *hapd = eloop_ctx; |
| 882 | struct sta_info *sta = timeout_ctx; |
| 883 | unsigned int timeout, sec, usec; |
| 884 | u8 *trans_id, *nbuf; |
| 885 | |
| 886 | if (sta->sa_query_count > 0 && |
| 887 | ap_check_sa_query_timeout(hapd, sta)) |
| 888 | return; |
| 889 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 890 | nbuf = os_realloc_array(sta->sa_query_trans_id, |
| 891 | sta->sa_query_count + 1, |
| 892 | WLAN_SA_QUERY_TR_ID_LEN); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 893 | if (nbuf == NULL) |
| 894 | return; |
| 895 | if (sta->sa_query_count == 0) { |
| 896 | /* Starting a new SA Query procedure */ |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 897 | os_get_reltime(&sta->sa_query_start); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 898 | } |
| 899 | trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN; |
| 900 | sta->sa_query_trans_id = nbuf; |
| 901 | sta->sa_query_count++; |
| 902 | |
| 903 | os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN); |
| 904 | |
| 905 | timeout = hapd->conf->assoc_sa_query_retry_timeout; |
| 906 | sec = ((timeout / 1000) * 1024) / 1000; |
| 907 | usec = (timeout % 1000) * 1024; |
| 908 | eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta); |
| 909 | |
| 910 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 911 | HOSTAPD_LEVEL_DEBUG, |
| 912 | "association SA Query attempt %d", sta->sa_query_count); |
| 913 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 914 | ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | |
| 918 | void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta) |
| 919 | { |
| 920 | ap_sa_query_timer(hapd, sta); |
| 921 | } |
| 922 | |
| 923 | |
| 924 | void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta) |
| 925 | { |
| 926 | eloop_cancel_timeout(ap_sa_query_timer, hapd, sta); |
| 927 | os_free(sta->sa_query_trans_id); |
| 928 | sta->sa_query_trans_id = NULL; |
| 929 | sta->sa_query_count = 0; |
| 930 | } |
| 931 | |
| 932 | #endif /* CONFIG_IEEE80211W */ |
| 933 | |
| 934 | |
| 935 | void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta, |
| 936 | int authorized) |
| 937 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 938 | const u8 *dev_addr = NULL; |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 939 | char buf[100]; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 940 | #ifdef CONFIG_P2P |
| 941 | u8 addr[ETH_ALEN]; |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 942 | u8 ip_addr_buf[4]; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 943 | #endif /* CONFIG_P2P */ |
| 944 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 945 | if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED)) |
| 946 | return; |
| 947 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 948 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 949 | if (hapd->p2p_group == NULL) { |
| 950 | if (sta->p2p_ie != NULL && |
| 951 | p2p_parse_dev_addr_in_p2p_ie(sta->p2p_ie, addr) == 0) |
| 952 | dev_addr = addr; |
| 953 | } else |
| 954 | dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 955 | #endif /* CONFIG_P2P */ |
| 956 | |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 957 | if (dev_addr) |
| 958 | os_snprintf(buf, sizeof(buf), MACSTR " p2p_dev_addr=" MACSTR, |
| 959 | MAC2STR(sta->addr), MAC2STR(dev_addr)); |
| 960 | else |
| 961 | os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr)); |
| 962 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 963 | if (authorized) { |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 964 | char ip_addr[100]; |
| 965 | ip_addr[0] = '\0'; |
| 966 | #ifdef CONFIG_P2P |
| 967 | if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) { |
| 968 | os_snprintf(ip_addr, sizeof(ip_addr), |
| 969 | " ip_addr=%u.%u.%u.%u", |
| 970 | ip_addr_buf[0], ip_addr_buf[1], |
| 971 | ip_addr_buf[2], ip_addr_buf[3]); |
| 972 | } |
| 973 | #endif /* CONFIG_P2P */ |
| 974 | |
| 975 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s", |
| 976 | buf, ip_addr); |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 977 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 978 | if (hapd->msg_ctx_parent && |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 979 | hapd->msg_ctx_parent != hapd->msg_ctx) |
| 980 | wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, |
Dmitry Shmidt | cf32e60 | 2014-01-28 10:57:39 -0800 | [diff] [blame] | 981 | AP_STA_CONNECTED "%s%s", |
| 982 | buf, ip_addr); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 983 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 984 | sta->flags |= WLAN_STA_AUTHORIZED; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 985 | } else { |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 986 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf); |
| 987 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 988 | if (hapd->msg_ctx_parent && |
Dmitry Shmidt | b6e9aaf | 2013-05-20 14:49:44 -0700 | [diff] [blame] | 989 | hapd->msg_ctx_parent != hapd->msg_ctx) |
| 990 | wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO, |
| 991 | AP_STA_DISCONNECTED "%s", buf); |
| 992 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 993 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 994 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 995 | |
| 996 | if (hapd->sta_authorized_cb) |
| 997 | hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 998 | sta->addr, authorized, dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | |
| 1002 | void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta, |
| 1003 | const u8 *addr, u16 reason) |
| 1004 | { |
| 1005 | |
| 1006 | if (sta == NULL && addr) |
| 1007 | sta = ap_get_sta(hapd, addr); |
| 1008 | |
| 1009 | if (addr) |
| 1010 | hostapd_drv_sta_deauth(hapd, addr, reason); |
| 1011 | |
| 1012 | if (sta == NULL) |
| 1013 | return; |
| 1014 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 1015 | wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH); |
| 1016 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1017 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1018 | wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout " |
| 1019 | "for " MACSTR " (%d seconds - " |
| 1020 | "AP_MAX_INACTIVITY_AFTER_DEAUTH)", |
| 1021 | __func__, MAC2STR(sta->addr), |
| 1022 | AP_MAX_INACTIVITY_AFTER_DEAUTH); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1023 | eloop_cancel_timeout(ap_handle_timer, hapd, sta); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1024 | eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0, |
| 1025 | ap_handle_timer, hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1026 | sta->timeout_next = STA_REMOVE; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1027 | |
| 1028 | sta->deauth_reason = reason; |
| 1029 | sta->flags |= WLAN_STA_PENDING_DEAUTH_CB; |
| 1030 | eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); |
| 1031 | eloop_register_timeout(hapd->iface->drv_flags & |
| 1032 | WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0, |
| 1033 | ap_sta_deauth_cb_timeout, hapd, sta); |
| 1034 | } |
| 1035 | |
| 1036 | |
| 1037 | void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta) |
| 1038 | { |
| 1039 | if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) { |
| 1040 | wpa_printf(MSG_DEBUG, "Ignore deauth cb for test frame"); |
| 1041 | return; |
| 1042 | } |
| 1043 | sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB; |
| 1044 | eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta); |
| 1045 | ap_sta_deauth_cb_timeout(hapd, sta); |
| 1046 | } |
| 1047 | |
| 1048 | |
| 1049 | void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta) |
| 1050 | { |
| 1051 | if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) { |
| 1052 | wpa_printf(MSG_DEBUG, "Ignore disassoc cb for test frame"); |
| 1053 | return; |
| 1054 | } |
| 1055 | sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB; |
| 1056 | eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta); |
| 1057 | ap_sta_disassoc_cb_timeout(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1058 | } |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1059 | |
| 1060 | |
| 1061 | int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen) |
| 1062 | { |
| 1063 | int res; |
| 1064 | |
| 1065 | buf[0] = '\0'; |
| 1066 | res = os_snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
| 1067 | (flags & WLAN_STA_AUTH ? "[AUTH]" : ""), |
| 1068 | (flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""), |
| 1069 | (flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" : ""), |
| 1070 | (flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" : |
| 1071 | ""), |
| 1072 | (flags & WLAN_STA_SHORT_PREAMBLE ? |
| 1073 | "[SHORT_PREAMBLE]" : ""), |
| 1074 | (flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""), |
| 1075 | (flags & WLAN_STA_WMM ? "[WMM]" : ""), |
| 1076 | (flags & WLAN_STA_MFP ? "[MFP]" : ""), |
| 1077 | (flags & WLAN_STA_WPS ? "[WPS]" : ""), |
| 1078 | (flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""), |
| 1079 | (flags & WLAN_STA_WDS ? "[WDS]" : ""), |
| 1080 | (flags & WLAN_STA_NONERP ? "[NonERP]" : ""), |
| 1081 | (flags & WLAN_STA_WPS2 ? "[WPS2]" : ""), |
| 1082 | (flags & WLAN_STA_GAS ? "[GAS]" : ""), |
| 1083 | (flags & WLAN_STA_VHT ? "[VHT]" : ""), |
| 1084 | (flags & WLAN_STA_WNM_SLEEP_MODE ? |
| 1085 | "[WNM_SLEEP_MODE]" : "")); |
| 1086 | |
| 1087 | return res; |
| 1088 | } |