]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WNM: Move disassociation imminent sending to wnm_ap.c
authorJouni Malinen <j@w1.fi>
Fri, 27 Dec 2013 17:40:04 +0000 (19:40 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 27 Dec 2013 17:57:47 +0000 (19:57 +0200)
This gets all WNM BSS Transition Management frame building and sending
within hostapd into the same location.

Signed-hostap: Jouni Malinen <j@w1.fi>

hostapd/ctrl_iface.c
src/ap/wnm_ap.c
src/ap/wnm_ap.h

index 6d82cd85af2fadd071d09ef6ebdce39cdbbc2692..125e97fa3515e28186525e0753eb85f14f1dc958 100644 (file)
@@ -666,9 +666,8 @@ static int hostapd_ctrl_iface_disassoc_imminent(struct hostapd_data *hapd,
                                                const char *cmd)
 {
        u8 addr[ETH_ALEN];
-       u8 buf[1000], *pos;
-       struct ieee80211_mgmt *mgmt;
        int disassoc_timer;
+       struct sta_info *sta;
 
        if (hwaddr_aton(cmd, addr))
                return -1;
@@ -676,31 +675,15 @@ static int hostapd_ctrl_iface_disassoc_imminent(struct hostapd_data *hapd,
                return -1;
        disassoc_timer = atoi(cmd + 17);
 
-       os_memset(buf, 0, sizeof(buf));
-       mgmt = (struct ieee80211_mgmt *) buf;
-       mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
-                                          WLAN_FC_STYPE_ACTION);
-       os_memcpy(mgmt->da, addr, ETH_ALEN);
-       os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
-       os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
-       mgmt->u.action.category = WLAN_ACTION_WNM;
-       mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
-       mgmt->u.action.u.bss_tm_req.dialog_token = 1;
-       mgmt->u.action.u.bss_tm_req.req_mode =
-               WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
-       mgmt->u.action.u.bss_tm_req.disassoc_timer =
-               host_to_le16(disassoc_timer);
-       mgmt->u.action.u.bss_tm_req.validity_interval = 0;
-
-       pos = mgmt->u.action.u.bss_tm_req.variable;
-
-       if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
-               wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
-                          "Management Request frame");
+       sta = ap_get_sta(hapd, addr);
+       if (sta == NULL) {
+               wpa_printf(MSG_DEBUG, "Station " MACSTR
+                          " not found for disassociation imminent message",
+                          MAC2STR(addr));
                return -1;
        }
 
-       return 0;
+       return wnm_send_disassoc_imminent(hapd, sta, disassoc_timer);
 }
 
 
index 4089b6c2c62e497332efb034b9b3b933b7c938a6..417fd0e5c1c0af0d0e4d3b572ec80c85c4aa1ab9 100644 (file)
@@ -395,6 +395,42 @@ int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd,
 }
 
 
+int wnm_send_disassoc_imminent(struct hostapd_data *hapd,
+                              struct sta_info *sta, int disassoc_timer)
+{
+       u8 buf[1000], *pos;
+       struct ieee80211_mgmt *mgmt;
+
+       os_memset(buf, 0, sizeof(buf));
+       mgmt = (struct ieee80211_mgmt *) buf;
+       mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
+                                          WLAN_FC_STYPE_ACTION);
+       os_memcpy(mgmt->da, sta->addr, ETH_ALEN);
+       os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
+       os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
+       mgmt->u.action.category = WLAN_ACTION_WNM;
+       mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
+       mgmt->u.action.u.bss_tm_req.dialog_token = 1;
+       mgmt->u.action.u.bss_tm_req.req_mode =
+               WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
+       mgmt->u.action.u.bss_tm_req.disassoc_timer =
+               host_to_le16(disassoc_timer);
+       mgmt->u.action.u.bss_tm_req.validity_interval = 0;
+
+       pos = mgmt->u.action.u.bss_tm_req.variable;
+
+       wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request frame to indicate imminent disassociation (disassoc_timer=%d) to "
+                  MACSTR, disassoc_timer, MAC2STR(sta->addr));
+       if (hostapd_drv_send_mlme(hapd, buf, pos - buf, 0) < 0) {
+               wpa_printf(MSG_DEBUG, "Failed to send BSS Transition "
+                          "Management Request frame");
+               return -1;
+       }
+
+       return 0;
+}
+
+
 int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd,
                                   struct sta_info *sta, const char *url,
                                   int disassoc_timer)
index 3ed0c56951e5c57cdc272832d274f48691f24287..78b1c6be64e33c6fe4d261b4482da457e1773aca 100644 (file)
@@ -14,6 +14,8 @@ struct sta_info;
 
 int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd,
                                struct rx_action *action);
+int wnm_send_disassoc_imminent(struct hostapd_data *hapd,
+                              struct sta_info *sta, int disassoc_timer);
 int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd,
                                   struct sta_info *sta, const char *url,
                                   int disassoc_timer);