MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / auth_rsp.c
blob96d5fd403a628074cc58a302ac267e0546a6329a
1 /*************************************************************************
2 * Ralink Tech Inc. *
3 * 4F, No. 2 Technology 5th Rd. *
4 * Science-based Industrial Park *
5 * Hsin-chu, Taiwan, R.O.C. *
6 * *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 * *
24 ************************************************************************/
26 #include "rt_config.h"
29 ==========================================================================
30 Description:
31 authentication state machine init procedure
32 Parameters:
33 Sm - the state machine
34 Note:
35 the state machine looks like the following
37 AUTH_RSP_IDLE AUTH_RSP_WAIT_CHAL
38 MT2_AUTH_CHALLENGE_TIMEOUT auth_rsp_challenge_timeout_action auth_rsp_challenge_timeout_action
39 MT2_PEER_AUTH_ODD peer_auth_at_auth_rsp_idle_action peer_auth_at_auth_rsp_wait_action
40 MT2_PEER_DEAUTH peer_deauth_action peer_deauth_action
41 ==========================================================================
43 VOID AuthRspStateMachineInit(
44 IN PRTMP_ADAPTER pAd,
45 IN PSTATE_MACHINE Sm,
46 IN STATE_MACHINE_FUNC Trans[])
48 ULONG NOW;
50 StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
52 // column 1
53 // StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_AUTH_CHALLENGEG_TIMEOUT, (STATE_MACHINE_FUNC)AuthRspChallengeTimeoutAction);
54 // StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_AUTH_ODD, (STATE_MACHINE_FUNC)PeerAuthAtAuthRspIdleAction);
55 StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
57 // column 2
58 // StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_AUTH_ODD, (STATE_MACHINE_FUNC)PeerAuthAtAuthRspWaitAction);
59 // StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_AUTH_CHALLENGE_TIMEOUT, (STATE_MACHINE_FUNC)AuthRspChallengeTimeoutAction);
60 StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
62 // initialize timer
63 RTMPInitTimer(pAd, &pAd->Mlme.AuthRspAux.AuthRspTimer, AuthRspChallengeTimeout);
65 // initialize the random number generator
66 NOW = jiffies;
67 LfsrInit(pAd, NOW);
72 ==========================================================================
73 Description:
74 challenge time out, called by timer thread
75 ==========================================================================
77 VOID AuthRspChallengeTimeout(
78 IN unsigned long data)
80 RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)data;
82 DBGPRINT(RT_DEBUG_TRACE,"AUTH_RSP - AuthRspChallengeTimeout \n");
83 MlmeEnqueue(&pAd->Mlme.Queue, AUTH_RSP_STATE_MACHINE, MT2_AUTH_CHALLENGE_TIMEOUT, 0, NULL);
84 MlmeHandler(pAd);
88 ==========================================================================
89 Description:
90 ==========================================================================
92 VOID PeerAuthSimpleRspGenAndSend(
93 IN PRTMP_ADAPTER pAd,
94 IN PMACHDR Hdr,
95 IN USHORT Alg,
96 IN USHORT Seq,
97 IN USHORT Reason,
98 IN USHORT Status)
100 MACHDR AuthHdr;
101 UINT FrameLen = 0;
102 UCHAR *OutBuffer = NULL;
103 NDIS_STATUS NStatus;
105 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
106 if (NStatus != NDIS_STATUS_SUCCESS)
107 return;
109 if (Reason == MLME_SUCCESS)
111 DBGPRINT(RT_DEBUG_TRACE, "Send AUTH response (seq#2)...\n");
112 MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, &Hdr->Addr2, &pAd->PortCfg.Bssid);
113 MakeOutgoingFrame(OutBuffer, &FrameLen,
114 sizeof(MACHDR), &AuthHdr,
115 2, &Alg,
116 2, &Seq,
117 2, &Reason,
118 END_OF_ARGS);
119 MiniportMMRequest(pAd, OutBuffer, FrameLen);
121 else
123 MlmeFreeMemory(pAd, OutBuffer);
124 DBGPRINT(RT_DEBUG_TRACE, "Peer AUTH fail...\n");
129 ==========================================================================
130 Description:
131 ==========================================================================
133 VOID PeerDeauthAction(
134 IN PRTMP_ADAPTER pAd,
135 IN PMLME_QUEUE_ELEM Elem)
137 MACADDR Addr2;
138 USHORT Reason;
140 if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, &Addr2, &Reason))
142 if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(&Addr2, &pAd->PortCfg.Bssid))
144 RTMPCancelTimer(&pAd->Mlme.AuthRspAux.AuthRspTimer);
145 DBGPRINT(RT_DEBUG_TRACE,"AUTH_RSP - receive DE-AUTH from our AP, reason(%d)\n",Reason);
146 LinkDown(pAd);
149 else
151 DBGPRINT(RT_DEBUG_TRACE,"AUTH_RSP - PeerDeauthAction() sanity check fail\n");