A way to force deassociation ? Solved !

Dominique Blas ml at blas.net
Tue Nov 5 13:59:28 EST 2002


Le Lundi 4 Novembre 2002 13:30, Victor Aleo a écrit :
> >does someone know a smooth way to force deassociation on all associated
> >stations ?
>
> Try with: iwconfig wlan# kickmac <mac addr>

I tried this command but the result is not what I expected.
Sta are deauthenticated but the mac addresses remain in /proc/net/hostap/wlan#
which I don't want.
My purpose is REALLY to dissociate all stas without asking about their opinion 
and change the ESSID while they are no other sta associated.

So I need 
	to clear the hostap internal table that lists associated stas 
	and send a deassociation frame to the stas.


> With this command the AP will send a Deauthentication message to the
> <mac addr>, but not a Disassociation one. The result is slightly
> different: the station will be Deauthenticated (state 1, see standard
> for more details) so it will have to authenticate with another AP.
>
> Victor

So I investigated the Jouni's code.

The instruction that is sent when timer expires is (in function 
ap_handle_timer from hostap_ap.c) :

               prism2_send_mgmt(local->dev, WLAN_FC_TYPE_MGMT,
                                 (deauth ? WLAN_FC_STYPE_DEAUTH :
                                  WLAN_FC_STYPE_DISASSOC),
                                 (char *) &resp, 2, 1, sta->addr);


So an instruction that does
	for i in sta do
		prism2_send_mgmt(local->dev, WLAN_FC_TYPE_MGMT, WLAN_FC_STYP_DISASSOC, (char 
*) &resp, 2, 2, sta->i)
	done

will be welcome.


In fact, the function I was looking for is nearly the function 
ap_control_kickmac but working on the list of associated stas instead of 
authenticated stas and doing
prism2_send_mgmt(...WLAN_FC_STYPE_DISASSOC instead of ... 
WLAN_FC_STYPE_DEAUTH.


Such a function exists : it's ap_control_kickall that works by forcing the 
expiration of the timers of inactivity for each sta.

Than looking backward how this function is called I found that funtion 
ap_mac_cmd_ioctl in hostap_ioctl.c is calling it 
when value of the command maccmd is 4 (AP_MAC_CMD_KICKALL = 4 according to 
hostap_wlan.h).

maccmd = 4 does 2 things : 
	deassociation of all stas
and
	deauthentification of all stas

Perfect !


Here is the involved code :
        case AP_MAC_CMD_KICKALL:
                ap_control_kickall(local->ap);
                hostap_deauth_all_stas(local->dev, local->ap, 0);
                break;


The command I was looking for is, in conclusion :
		iwpriv wlan0 maccmd 4
that works as expected : smoothly and efficiently.


The procedure is thus :
	change the ESSID : already associated stations stay associated
	launch iwpriv wlan# maccmd 4 : stations are deassociated and cannot 
reassociate if
			new essid is unknown.
	
Thanks to all,

db









More information about the HostAP mailing list