FT: Add set/get session_timeout callback functions

These are needed to allow wpa_auth_ft.c to control session_timeout
values for STAs.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
This commit is contained in:
Michael Braun 2017-05-18 15:21:56 +02:00 committed by Jouni Malinen
parent 13f118dc59
commit 3cb286ca49
2 changed files with 49 additions and 0 deletions

View file

@ -275,6 +275,9 @@ struct wpa_auth_callbacks {
int (*set_radius_cui)(void *ctx, const u8 *sta_addr,
const u8 *radius_cui, size_t radius_cui_len);
size_t (*get_radius_cui)(void *ctx, const u8 *sta_addr, const u8 **buf);
void (*set_session_timeout)(void *ctx, const u8 *sta_addr,
int session_timeout);
int (*get_session_timeout)(void *ctx, const u8 *sta_addr);
int (*send_ft_action)(void *ctx, const u8 *dst,
const u8 *data, size_t data_len);

View file

@ -1030,6 +1030,50 @@ hostapd_wpa_auth_get_radius_cui(void *ctx, const u8 *sta_addr, const u8 **buf)
}
static void hostapd_wpa_auth_set_session_timeout(void *ctx, const u8 *sta_addr,
int session_timeout)
{
struct hostapd_data *hapd = ctx;
struct sta_info *sta;
sta = ap_get_sta(hapd, sta_addr);
if (!sta)
return;
if (session_timeout) {
os_get_reltime(&sta->session_timeout);
sta->session_timeout.sec += session_timeout;
sta->session_timeout_set = 1;
ap_sta_session_timeout(hapd, sta, session_timeout);
} else {
sta->session_timeout_set = 0;
ap_sta_no_session_timeout(hapd, sta);
}
}
static int hostapd_wpa_auth_get_session_timeout(void *ctx, const u8 *sta_addr)
{
struct hostapd_data *hapd = ctx;
struct sta_info *sta;
struct os_reltime now, remaining;
sta = ap_get_sta(hapd, sta_addr);
if (!sta || !sta->session_timeout_set)
return 0;
os_get_reltime(&now);
if (os_reltime_before(&sta->session_timeout, &now)) {
/* already expired, return >0 as timeout was set */
return 1;
}
os_reltime_sub(&sta->session_timeout, &now, &remaining);
return (remaining.sec > 0) ? remaining.sec : 1;
}
static void hostapd_rrb_receive(void *ctx, const u8 *src_addr, const u8 *buf,
size_t len)
{
@ -1155,6 +1199,8 @@ int hostapd_setup_wpa(struct hostapd_data *hapd)
.get_identity = hostapd_wpa_auth_get_identity,
.set_radius_cui = hostapd_wpa_auth_set_radius_cui,
.get_radius_cui = hostapd_wpa_auth_get_radius_cui,
.set_session_timeout = hostapd_wpa_auth_set_session_timeout,
.get_session_timeout = hostapd_wpa_auth_get_session_timeout,
#endif /* CONFIG_IEEE80211R_AP */
};
const u8 *wpa_ie;