1 #ifndef __ZDAUTHRSP_C__
2 #define __ZDAUTHRSP_C__
7 U8 AuthRspState
= STE_AUTH_RSP_IDLE
;
8 static U8 arChalng
[CHAL_TEXT_LEN
]; //Challenge text
11 extern struct net_device
*g_dev
;
13 BOOLEAN
CheckAlg(U8 alg
)
21 if (mAuthAlogrithms
[i
] == alg
)
28 BOOLEAN
AuthOdd_Idle(Signal_t
*signal
)
30 struct zd1205_private
*macp
=g_dev
->priv
;
38 ZDEBUG("AuthOdd_Idle");
39 pfrmDesc
= signal
->frmInfo
.frmDesc
;
41 arSeq
= authSeqNum(rdu
);
42 arAlg
= authType(rdu
);
43 memcpy((U8
*)&Sta
, (U8
*)addr2(rdu
), 6);
46 arSC
= SC_AUTH_OUT_OF_SEQ
;
47 UpdateStaStatus(&Sta
, STATION_STATE_NOT_AUTH
, vapId
);
48 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, NULL
, vapId
);
49 return sendMgtFrame(signal
, pfrmDesc
);
52 if (!CheckAlg(arAlg
)){
54 UpdateStaStatus(&Sta
, STATION_STATE_NOT_AUTH
, vapId
);
55 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, NULL
, vapId
);
56 return sendMgtFrame(signal
, pfrmDesc
);
59 if (pdot11Obj
->StatusNotify(STA_AUTH_REQ
, (U8
*)&Sta
)){ //Reject it
60 arSC
= SC_UNSPEC_FAILURE
;
61 UpdateStaStatus(&Sta
, STATION_STATE_NOT_AUTH
, vapId
);
62 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, NULL
, vapId
);
63 return sendMgtFrame(signal
, pfrmDesc
);
66 if (arAlg
== OPEN_SYSTEM
){
67 if (UpdateStaStatus(&Sta
, STATION_STATE_AUTH_OPEN
, vapId
))
72 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, NULL
, vapId
);
73 return sendMgtFrame(signal
, pfrmDesc
);
76 if (arAlg
== SHARE_KEY
){
78 if (macp
->cardSetting
.WPAIeLen
){
79 //if ((mDynKeyMode == DYN_KEY_TKIP) || (mDynKeyMode == DYN_KEY_AES)){
81 UpdateStaStatus(&Sta
, STATION_STATE_NOT_AUTH
, vapId
);
82 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, NULL
, vapId
);
84 return sendMgtFrame(signal
, pfrmDesc
);
87 if ((mCurrConnUser
+ 1) > mLimitedUser
)
92 mkAuthFrm(pfrmDesc
, &Sta
, arAlg
, arSeq
+1, arSC
, arChalng
, vapId
);
93 if (arSC
== SC_SUCCESSFUL
){
94 pdot11Obj
->StartTimer(512, DO_CHAL
);
95 AuthRspState
= STE_AUTH_RSP_WAIT_CRSP
;
97 return sendMgtFrame(signal
, pfrmDesc
);
106 BOOLEAN
AuthOdd_WaitChalRsp(Signal_t
*signal
)
117 ZDEBUG("AuthOdd_WaitChalRsp");
118 pfrmDesc
= signal
->frmInfo
.frmDesc
;
119 rdu
= pfrmDesc
->mpdu
;
121 arSeq2
= authSeqNum(rdu
);
122 arAlg2
= authType(rdu
);
123 memcpy((U8
*)&Sta2
, (U8
*)addr2(rdu
), 6);
126 if (memcmp(&Sta
, &Sta2
, 6) == 0){ // open system request from a different station
127 arSC
= SC_UNSPEC_FAILURE
;
131 if (arAlg2
== OPEN_SYSTEM
){
132 arSC
= SC_SUCCESSFUL
;
133 UpdateStaStatus(&Sta
, STATION_STATE_AUTH_OPEN
, vapId
);
134 mkAuthFrm(pfrmDesc
, &Sta2
, arAlg2
, arSeq2
+1, arSC
, NULL
, vapId
);
136 return sendMgtFrame(signal
, pfrmDesc
);
139 arSC
= SC_UNSPEC_FAILURE
;
143 else if(arSeq2
== 3){
144 if (memcmp(&Sta
, &Sta2
, 6) == 0){
145 pdot11Obj
->StopTimer(DO_CHAL
);
147 if (!getElem(rdu
, EID_CTEXT
, (Element
*)&ChalText
[0],1)){
151 //zd1205_OctetDump("ChalText = ", &ChalText[0], CHAL_TEXT_LEN+2);
152 if (memcmp(&ChalText
[2], arChalng
, CHAL_TEXT_LEN
) != 0){
157 if (UpdateStaStatus(&Sta
, STATION_STATE_AUTH_KEY
, vapId
))
158 arSC
= SC_SUCCESSFUL
;
165 UpdateStaStatus(&Sta2
, STATION_STATE_NOT_AUTH
, vapId
);
169 arSC
= SC_UNSPEC_FAILURE
;
170 UpdateStaStatus(&Sta2
, STATION_STATE_NOT_AUTH
, vapId
);
172 AuthRspState
= STE_AUTH_RSP_IDLE
;
173 mkAuthFrm(pfrmDesc
, &Sta2
, arAlg2
, arSeq2
+1, arSC
, NULL
, vapId
);
174 return sendMgtFrame(signal
, pfrmDesc
);
177 arSC
= SC_UNSPEC_FAILURE
;
182 UpdateStaStatus(&Sta2
, STATION_STATE_NOT_AUTH
, vapId
);
183 mkAuthFrm(pfrmDesc
, &Sta2
, arAlg2
, arSeq2
+1, arSC
, NULL
, vapId
);
184 return sendMgtFrame(signal
, pfrmDesc
);
188 BOOLEAN
Tchal_WaitChalRsp(Signal_t
*signal
)
192 ZDEBUG("Tchal_WaitChalRsp");
193 if (AuthRspState
== STE_AUTH_RSP_WAIT_CRSP
){
194 UpdateStaStatus(&Sta
, STATION_STATE_NOT_AUTH
, vapId
);
195 AuthRspState
= STE_AUTH_RSP_IDLE
;
201 BOOLEAN
Deauth(Signal_t
*signal
)
208 pfrmDesc
= signal
->frmInfo
.frmDesc
;
209 rdu
= pfrmDesc
->mpdu
;
210 UpdateStaStatus(addr2(rdu
), STATION_STATE_NOT_AUTH
, vapId
);
211 if (memcmp(&mBssId
, addr2(rdu
), 6) == 0)
212 pdot11Obj
->StatusNotify(STA_DEAUTHED
, (U8
*)addr2(rdu
));
214 if (mBssType
== INFRASTRUCTURE_BSS
){
215 //if (memcmp(&mBssId, addr2(rdu), 6) == 0){
218 memset((U8
*)&mBssId
, 0, 6);
219 mRequestFlag
|= DIS_CONNECT_SET
;
223 //here to handle deauth ind.
229 BOOLEAN
AuthRspEntry(Signal_t
*signal
)
231 if (AuthRspState
== STE_AUTH_RSP_IDLE
){
234 return AuthOdd_Idle(signal
);
237 return Deauth(signal
);
244 else if (AuthRspState
== STE_AUTH_RSP_WAIT_CRSP
){
247 return AuthOdd_WaitChalRsp(signal
);
250 return Deauth(signal
);
253 return Tchal_WaitChalRsp(signal
);