1 /*************************************************************************
3 * 4F, No. 2 Technology 5th Rd. *
4 * Science-based Industrial Park *
5 * Hsin-chu, Taiwan, R.O.C. *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
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. *
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. *
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. *
24 ************************************************************************/
26 #include "rt_config.h"
29 ==========================================================================
31 authentication state machine init procedure
33 Sm - the state machine
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(
46 IN STATE_MACHINE_FUNC Trans
[])
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
);
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
);
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
);
63 RTMPInitTimer(pAd
, &pAd
->Mlme
.AuthRspAux
.AuthRspTimer
, AuthRspChallengeTimeout
);
65 // initialize the random number generator
72 ==========================================================================
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
);
88 ==========================================================================
90 ==========================================================================
92 VOID
PeerAuthSimpleRspGenAndSend(
102 UCHAR
*OutBuffer
= NULL
;
105 NStatus
= MlmeAllocateMemory(pAd
, (PVOID
)&OutBuffer
); //Get an unused nonpaged memory
106 if (NStatus
!= NDIS_STATUS_SUCCESS
)
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
,
119 MiniportMMRequest(pAd
, OutBuffer
, FrameLen
);
123 MlmeFreeMemory(pAd
, OutBuffer
);
124 DBGPRINT(RT_DEBUG_TRACE
, "Peer AUTH fail...\n");
129 ==========================================================================
131 ==========================================================================
133 VOID
PeerDeauthAction(
134 IN PRTMP_ADAPTER pAd
,
135 IN PMLME_QUEUE_ELEM Elem
)
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
);
151 DBGPRINT(RT_DEBUG_TRACE
,"AUTH_RSP - PeerDeauthAction() sanity check fail\n");