• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/staging/rt2860/sta/
1/*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
7 *
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify  *
11 * it under the terms of the GNU General Public License as published by  *
12 * the Free Software Foundation; either version 2 of the License, or     *
13 * (at your option) any later version.                                   *
14 *                                                                       *
15 * This program is distributed in the hope that it will be useful,       *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
18 * GNU General Public License for more details.                          *
19 *                                                                       *
20 * You should have received a copy of the GNU General Public License     *
21 * along with this program; if not, write to the                         *
22 * Free Software Foundation, Inc.,                                       *
23 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
24 *                                                                       *
25 *************************************************************************
26
27	Module Name:
28	auth_rsp.c
29
30	Abstract:
31
32	Revision History:
33	Who			When			What
34	--------	----------		----------------------------------------------
35	John		2004-10-1		copy from RT2560
36*/
37#include "../rt_config.h"
38
39/*
40    ==========================================================================
41    Description:
42        authentication state machine init procedure
43    Parameters:
44        Sm - the state machine
45
46	IRQL = PASSIVE_LEVEL
47
48    ==========================================================================
49 */
50void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
51			     struct rt_state_machine *Sm,
52			     IN STATE_MACHINE_FUNC Trans[])
53{
54	StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG,
55			 (STATE_MACHINE_FUNC) Drop, AUTH_RSP_IDLE,
56			 AUTH_RSP_MACHINE_BASE);
57
58	/* column 1 */
59	StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH,
60			      (STATE_MACHINE_FUNC) PeerDeauthAction);
61
62	/* column 2 */
63	StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH,
64			      (STATE_MACHINE_FUNC) PeerDeauthAction);
65
66}
67
68/*
69    ==========================================================================
70    Description:
71
72	IRQL = DISPATCH_LEVEL
73
74    ==========================================================================
75*/
76void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
77				 struct rt_header_802_11 * pHdr80211,
78				 u16 Alg,
79				 u16 Seq,
80				 u16 Reason, u16 Status)
81{
82	struct rt_header_802_11 AuthHdr;
83	unsigned long FrameLen = 0;
84	u8 *pOutBuffer = NULL;
85	int NStatus;
86
87	if (Reason != MLME_SUCCESS) {
88		DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
89		return;
90	}
91	/*Get an unused nonpaged memory */
92	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
93	if (NStatus != NDIS_STATUS_SUCCESS)
94		return;
95
96	DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
97	MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2,
98			 pAd->MlmeAux.Bssid);
99	MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
100			  &AuthHdr, 2, &Alg, 2, &Seq, 2, &Reason, END_OF_ARGS);
101	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
102	MlmeFreeMemory(pAd, pOutBuffer);
103}
104
105/*
106    ==========================================================================
107    Description:
108
109	IRQL = DISPATCH_LEVEL
110
111    ==========================================================================
112*/
113void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
114{
115	u8 Addr2[MAC_ADDR_LEN];
116	u16 Reason;
117
118	if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
119		if (INFRA_ON(pAd)
120		    && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
121		    ) {
122			DBGPRINT(RT_DEBUG_TRACE,
123				 ("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n",
124				  Reason));
125
126			RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
127						0);
128
129			/* send wireless event - for deauthentication */
130			if (pAd->CommonCfg.bWirelessEvent)
131				RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
132						      pAd->MacTab.
133						      Content[BSSID_WCID].Addr,
134						      BSS0, 0);
135
136			LinkDown(pAd, TRUE);
137		}
138	} else {
139		DBGPRINT(RT_DEBUG_TRACE,
140			 ("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
141	}
142}
143