split STA deletion into immediate and delayed action

When sending a DeAuthentication frame to a STA we have to wait
a bit to make sure the driver has actually delivered the frame.
Once we get the DeAuthetication frame from a STA, we can stop
waiting and delete the STA.
This commit is contained in:
Andreas Schultz 2016-11-10 18:53:14 +01:00
parent 2f2a287928
commit 890a2af6bb
1 changed files with 19 additions and 11 deletions

View File

@ -387,6 +387,20 @@ static void wifi_station_clean(struct wifi_station* station)
station->supportedratescount = 0; station->supportedratescount = 0;
} }
/* */
static void wifi_station_schedule_delete(struct wifi_station* station)
{
ASSERT(station != NULL);
/* */
log_printf(LOG_INFO, "Schedule Delete station: " MACSTR, MAC2STR(station->address));
/* Delay delete station */
station->timeout_action = WIFI_STATION_TIMEOUT_ACTION_DELETE;
station->timeout.repeat = WIFI_STATION_TIMEOUT_AFTER_DEAUTHENTICATED / 1000.0;
ev_timer_again(EV_DEFAULT_UC_ &station->timeout);
}
/* */ /* */
static void wifi_station_delete(struct wifi_station* station) static void wifi_station_delete(struct wifi_station* station)
{ {
@ -395,13 +409,9 @@ static void wifi_station_delete(struct wifi_station* station)
/* */ /* */
log_printf(LOG_INFO, "Delete station: " MACSTR, MAC2STR(station->address)); log_printf(LOG_INFO, "Delete station: " MACSTR, MAC2STR(station->address));
/* */ /* Free station into hash callback function */
wifi_station_clean(station); wifi_station_clean(station);
capwap_hash_delete(g_wifiglobal.stations, station->address);
/* Delay delete station */
station->timeout_action = WIFI_STATION_TIMEOUT_ACTION_DELETE;
station->timeout.repeat = WIFI_STATION_TIMEOUT_AFTER_DEAUTHENTICATED / 1000.0;
ev_timer_again(EV_DEFAULT_UC_ &station->timeout);
} }
/* */ /* */
@ -508,7 +518,7 @@ static void wifi_wlan_deauthentication_station(struct wifi_wlan* wlan,
wifi_wlan_send_mgmt_deauthentication(wlan, station->address, reasoncode); wifi_wlan_send_mgmt_deauthentication(wlan, station->address, reasoncode);
/* delete station */ /* delete station */
wifi_station_delete(station); wifi_station_schedule_delete(station);
} }
/* */ /* */
@ -585,9 +595,7 @@ static void wifi_station_timeout(EV_P_ ev_timer *w, int revents)
station->timeout_action); station->timeout_action);
if (station->timeout_action == WIFI_STATION_TIMEOUT_ACTION_DELETE) { if (station->timeout_action == WIFI_STATION_TIMEOUT_ACTION_DELETE) {
/* Free station into hash callback function */ wifi_station_delete(station);
wifi_station_clean(station);
capwap_hash_delete(g_wifiglobal.stations, station->address);
return; return;
} }
@ -1574,7 +1582,7 @@ wifi_wlan_receive_ac_mgmt_deauthentication(struct wifi_wlan* wlan,
/* Delete station */ /* Delete station */
station = wifi_station_get(wlan, frame->da); station = wifi_station_get(wlan, frame->da);
if (station) if (station)
wifi_station_delete(station); wifi_station_schedule_delete(station);
return 1; return 1;
} }