MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink.org / auth_rsp.c
blob039ef382e9872929cdd3595f6ad119dd1d5e1b0d
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 * (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 ==========================================================================
20 Description:
21 authentication state machine init procedure
22 Parameters:
23 Sm - the state machine
24 Note:
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(
34 IN PRTMP_ADAPTER pAd,
35 IN PSTATE_MACHINE Sm,
36 IN STATE_MACHINE_FUNC Trans[])
38 ULONG NOW;
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);
42 // column 1
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);
47 // column 2
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);
52 // initialize timer
53 RTMPInitTimer(pAd, &pAd->Mlme.AuthRspAux.AuthRspTimer, AuthRspChallengeTimeout);
55 // initialize the random number generator
56 NOW = jiffies;
57 LfsrInit(pAd, NOW);
62 ==========================================================================
63 Description:
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);
74 MlmeHandler(pAd);
78 ==========================================================================
79 Description:
80 ==========================================================================
82 VOID PeerAuthSimpleRspGenAndSend(
83 IN PRTMP_ADAPTER pAd,
84 IN PMACHDR Hdr,
85 IN USHORT Alg,
86 IN USHORT Seq,
87 IN USHORT Reason,
88 IN USHORT Status)
90 MACHDR AuthHdr;
91 UINT FrameLen = 0;
92 UCHAR *OutBuffer = NULL;
93 NDIS_STATUS NStatus;
95 NStatus = MlmeAllocateMemory(pAd, (PVOID)&OutBuffer); //Get an unused nonpaged memory
96 if (NStatus != NDIS_STATUS_SUCCESS)
97 return;
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,
105 2, &Alg,
106 2, &Seq,
107 2, &Reason,
108 END_OF_ARGS);
109 MiniportMMRequest(pAd, OutBuffer, FrameLen);
111 else
113 MlmeFreeMemory(pAd, OutBuffer);
114 DBGPRINT(RT_DEBUG_TRACE, "Peer AUTH fail...\n");
119 ==========================================================================
120 Description:
121 ==========================================================================
123 VOID PeerDeauthAction(
124 IN PRTMP_ADAPTER pAd,
125 IN PMLME_QUEUE_ELEM Elem)
127 MACADDR Addr2;
128 USHORT Reason;
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");
136 LinkDown(pAd);
139 else
141 DBGPRINT(RT_DEBUG_TRACE,"AUTH_RSP - PeerDeauthAction() sanity check fail\n");