1 /****************************************************************************
3 * 4F, No. 2 Technology 5th Rd.
4 * Science-based Industrial Park
5 * Hsin-chu, Taiwan, R.O.C.
6 * (c) Copyright 2002, Ralink Technology, Inc.
8 * All rights reserved. Ralink's source code is an unpublished work and the
9 * use of a copyright notice does not imply otherwise. This source code
10 * contains confidential trade secret material of Ralink Tech. Any attemp
11 * or participation in deciphering, decoding, reverse engineering or in any
12 * way altering the source code is stricitly prohibited, unless the prior
13 * written consent of Ralink Technology, Inc. is obtained.
14 ****************************************************************************/
16 #include "rt_config.h"
19 ==========================================================================
21 authentication state machine init procedure
23 Sm - the state machine
25 the state machine looks like the following
27 AUTH_RSP_IDLE AUTH_RSP_WAIT_CHAL
28 MT2_AUTH_CHALLENGE_TIMEOUT auth_rsp_challenge_timeout_action auth_rsp_challenge_timeout_action
29 MT2_PEER_AUTH_ODD peer_auth_at_auth_rsp_idle_action peer_auth_at_auth_rsp_wait_action
30 MT2_PEER_DEAUTH peer_deauth_action peer_deauth_action
31 ==========================================================================
33 VOID
AuthRspStateMachineInit(
36 IN STATE_MACHINE_FUNC Trans
[])
40 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
);
43 // StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_AUTH_CHALLENGEG_TIMEOUT, (STATE_MACHINE_FUNC)AuthRspChallengeTimeoutAction);
44 // StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_AUTH_ODD, (STATE_MACHINE_FUNC)PeerAuthAtAuthRspIdleAction);
45 StateMachineSetAction(Sm
, AUTH_RSP_IDLE
, MT2_PEER_DEAUTH
, (STATE_MACHINE_FUNC
)PeerDeauthAction
);
48 // StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_AUTH_ODD, (STATE_MACHINE_FUNC)PeerAuthAtAuthRspWaitAction);
49 // StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_AUTH_CHALLENGE_TIMEOUT, (STATE_MACHINE_FUNC)AuthRspChallengeTimeoutAction);
50 StateMachineSetAction(Sm
, AUTH_RSP_WAIT_CHAL
, MT2_PEER_DEAUTH
, (STATE_MACHINE_FUNC
)PeerDeauthAction
);
53 RTMPInitTimer(pAd
, &pAd
->Mlme
.AuthRspAux
.AuthRspTimer
, AuthRspChallengeTimeout
);
55 // initialize the random number generator
62 ==========================================================================
64 challenge time out, called by timer thread
65 ==========================================================================
67 VOID
AuthRspChallengeTimeout(
68 IN
unsigned long data
)
70 RTMP_ADAPTER
*pAd
= (RTMP_ADAPTER
*)data
;
72 DBGPRINT(RT_DEBUG_TRACE
,"AUTH_RSP - AuthRspChallengeTimeout \n");
73 MlmeEnqueue(&pAd
->Mlme
.Queue
, AUTH_RSP_STATE_MACHINE
, MT2_AUTH_CHALLENGE_TIMEOUT
, 0, NULL
);
78 ==========================================================================
80 ==========================================================================
82 VOID
PeerAuthSimpleRspGenAndSend(
92 UCHAR
*OutBuffer
= NULL
;
95 NStatus
= MlmeAllocateMemory(pAd
, (PVOID
)&OutBuffer
); //Get an unused nonpaged memory
96 if (NStatus
!= NDIS_STATUS_SUCCESS
)
99 if (Reason
== MLME_SUCCESS
)
101 DBGPRINT(RT_DEBUG_TRACE
, "Send AUTH response (seq#2)...\n");
102 MgtMacHeaderInit(pAd
, &AuthHdr
, SUBTYPE_AUTH
, 0, &Hdr
->Addr2
, &pAd
->PortCfg
.Bssid
);
103 MakeOutgoingFrame(OutBuffer
, &FrameLen
,
104 sizeof(MACHDR
), &AuthHdr
,
109 MiniportMMRequest(pAd
, OutBuffer
, FrameLen
);
113 MlmeFreeMemory(pAd
, OutBuffer
);
114 DBGPRINT(RT_DEBUG_TRACE
, "Peer AUTH fail...\n");
119 ==========================================================================
121 ==========================================================================
123 VOID
PeerDeauthAction(
124 IN PRTMP_ADAPTER pAd
,
125 IN PMLME_QUEUE_ELEM Elem
)
130 if (PeerDeauthSanity(pAd
, Elem
->Msg
, Elem
->MsgLen
, &Addr2
, &Reason
))
132 if (INFRA_ON(pAd
) && MAC_ADDR_EQUAL(&Addr2
, &pAd
->PortCfg
.Bssid
))
134 RTMPCancelTimer(&pAd
->Mlme
.AuthRspAux
.AuthRspTimer
);
135 DBGPRINT(RT_DEBUG_TRACE
,"AUTH_RSP - receive DE-AUTH from our AP\n");
141 DBGPRINT(RT_DEBUG_TRACE
,"AUTH_RSP - PeerDeauthAction() sanity check fail\n");