Allow AP mode deauth/disassoc reason code to be overridden
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 4 Jan 2013 10:19:02 +0000 (12:19 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 12 Jan 2013 15:51:54 +0000 (17:51 +0200)
The optional "reason=<reason code>" parameter to the ctrl_iface
deauthenticate and disassociate commands can now be used to change the
reason code used in the disconnection frame. This can be used, e.g., by
P2P GO to disconnect a single P2P client from the group by sending it an
indication of the group getting terminated (Deauthentication frame with
reason code 3). It needs to be noted that the peer device is still in
possession on the PSK, so it can still reconnect to the group after this
if it does not follow the group termination indication.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/ap/ctrl_iface_ap.c

index c55d3fe..1cb7e73 100644 (file)
@@ -189,6 +189,7 @@ int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
        u8 addr[ETH_ALEN];
        struct sta_info *sta;
        const char *pos;
+       u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
 
        wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE DEAUTHENTICATE %s",
                txtaddr);
@@ -228,11 +229,14 @@ int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
        }
 #endif /* CONFIG_P2P_MANAGER */
 
-       hostapd_drv_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
+       pos = os_strstr(txtaddr, " reason=");
+       if (pos)
+               reason = atoi(pos + 8);
+
+       hostapd_drv_sta_deauth(hapd, addr, reason);
        sta = ap_get_sta(hapd, addr);
        if (sta)
-               ap_sta_deauthenticate(hapd, sta,
-                                     WLAN_REASON_PREV_AUTH_NOT_VALID);
+               ap_sta_deauthenticate(hapd, sta, reason);
        else if (addr[0] == 0xff)
                hostapd_free_stas(hapd);
 
@@ -246,6 +250,7 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
        u8 addr[ETH_ALEN];
        struct sta_info *sta;
        const char *pos;
+       u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
 
        wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE DISASSOCIATE %s",
                txtaddr);
@@ -285,11 +290,14 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
        }
 #endif /* CONFIG_P2P_MANAGER */
 
-       hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
+       pos = os_strstr(txtaddr, " reason=");
+       if (pos)
+               reason = atoi(pos + 8);
+
+       hostapd_drv_sta_disassoc(hapd, addr, reason);
        sta = ap_get_sta(hapd, addr);
        if (sta)
-               ap_sta_disassociate(hapd, sta,
-                                   WLAN_REASON_PREV_AUTH_NOT_VALID);
+               ap_sta_disassociate(hapd, sta, reason);
        else if (addr[0] == 0xff)
                hostapd_free_stas(hapd);