HS 2.0R2 AP: Add support for Session Info URL RADIUS AVP
[mech_eap.git] / src / ap / sta_info.c
index ada1106..f7af088 100644 (file)
 #include "p2p_hostapd.h"
 #include "ap_drv_ops.h"
 #include "gas_serv.h"
+#include "wnm_ap.h"
 #include "sta_info.h"
 
 static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
                                       struct sta_info *sta);
 static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx);
+static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx);
 static void ap_sta_deauth_cb_timeout(void *eloop_ctx, void *timeout_ctx);
 static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx);
 #ifdef CONFIG_IEEE80211W
@@ -224,6 +226,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
                   __func__, MAC2STR(sta->addr));
        eloop_cancel_timeout(ap_handle_timer, hapd, sta);
        eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
+       eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
        eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
        eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
 
@@ -267,6 +270,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        os_free(sta->radius_cui);
        os_free(sta->remediation_url);
        wpabuf_free(sta->hs20_deauth_req);
+       os_free(sta->hs20_session_info_url);
 
 #ifdef CONFIG_SAE
        sae_clear_data(sta->sae);
@@ -522,6 +526,32 @@ void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
 }
 
 
+static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx)
+{
+#ifdef CONFIG_WNM
+       struct hostapd_data *hapd = eloop_ctx;
+       struct sta_info *sta = timeout_ctx;
+
+       wpa_printf(MSG_DEBUG, "WNM: Session warning time reached for " MACSTR,
+                  MAC2STR(sta->addr));
+       if (sta->hs20_session_info_url == NULL)
+               return;
+
+       wnm_send_ess_disassoc_imminent(hapd, sta, sta->hs20_session_info_url,
+                                      sta->hs20_disassoc_timer);
+#endif /* CONFIG_WNM */
+}
+
+
+void ap_sta_session_warning_timeout(struct hostapd_data *hapd,
+                                   struct sta_info *sta, int warning_time)
+{
+       eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
+       eloop_register_timeout(warning_time, 0, ap_handle_session_warning_timer,
+                              hapd, sta);
+}
+
+
 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
 {
        struct sta_info *sta;