MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / usb / net / Zydas / zdmmrx.c
blob2a1db8c7ae2d1739dc5db10db360a80cb9ad9973
1 #ifndef __ZDMMRX_C__
2 #define __ZDMMRX_C__
4 #include "zd80211.h"
7 void RxPsPoll(Frame_t *rdu)
9 U16 aid;
10 U8 vapId = 0;
11 Hash_t *pHash;
12 MacAddr_t *sta;
14 //PSDEBUG("RxPsPoll");
16 aid = durId(rdu) & 0x3FFF;
17 sta = addr2(rdu);
18 if (isGroup(sta))
19 return;
21 if ((aid > MAX_AID) || (aid == 0)){
22 zd_SendClass3ErrorFrame(sta, vapId);
23 return;
25 else {
26 pHash = sstByAid[aid];
27 if (pHash->asoc == STATION_STATE_ASOC)
28 PsPolled(sta, aid);
29 else
30 zd_SendClass3ErrorFrame(sta, vapId);
34 BOOLEAN RxMgtMpdu(Signal_t *signal)
36 StationState sas, sau;
37 FrmDesc_t *pfrmDesc;
38 Frame_t *rdu;
39 U8 FrmType;
40 U16 authSeq = 0;
43 ZDEBUG("MgtRxMpdu");
44 pfrmDesc = signal->frmInfo.frmDesc;
45 rdu = pfrmDesc->mpdu;
46 FrmType = frmType(rdu);
47 ZDEBUG_V("FrmType", FrmType);
51 switch (FrmType){
52 case ST_PROBE_REQ:
53 signal->id = SIG_PROBE;
54 signal->block = BLOCK_SYNCH;
55 //prince debug
56 if ( memcmp(0x61,addr2(rdu)+5,1) == 0 && memcmp(0xd0,addr2(rdu)+4,1) == 0 )
57 printk("Receive==Probe Requset===\n");
58 goto rx_indicate;
60 case ST_DEAUTH:
61 if (isGroup(addr1(rdu)))
62 goto rx_release;
63 else{
64 if ((memcmp(&mBssId.mac[0],addr2(rdu),6)==0 && mBssType==INFRASTRUCTURE_BSS))
66 #ifdef WPA_DEBUG
67 printk(KERN_ERR "Rx Deauth,Reason:%u\n",reason(rdu));
68 #endif
69 signal->id = SIG_DEAUTH;
70 signal->block = BLOCK_AUTH_RSP;
71 goto rx_indicate;
73 else if ((memcmp(&mBssId.mac[0],addr1(rdu),6)==0 && mBssType==AP_BSS))
75 #ifdef WPA_DEBUG
76 u8 *pCh=(u8*)addr2(rdu);
77 u8 i;
78 printk(KERN_ERR "Rx Deauth from station:");
79 for (i=0; i<6; i++)
81 printk("%02X ", *pCh++);
83 printk("\n");
84 #endif
85 signal->id = SIG_DEAUTH;
86 signal->block = BLOCK_AUTH_RSP;
87 goto rx_indicate;
89 else
91 #ifdef WPA_DEBUG
92 u8 *pCh=(u8*)addr2(rdu);
93 u8 i;
94 printk(KERN_ERR "Rx Deauth from unknown station:");
95 for (i=0; i<6; i++)
97 printk("%02X ", *pCh++);
99 printk("\n");
100 #endif
101 goto rx_release;
107 case ST_AUTH:
108 if (isGroup(addr1(rdu)))
109 goto rx_release;
110 else{
111 authSeq = authSeqNum(rdu);
112 if ((authSeq == 1) || ((authSeq == 3) && wepBit(rdu))){ //Seqence 1 or 3
113 signal->id = SIG_AUTH_ODD;
114 signal->block = BLOCK_AUTH_RSP;
115 goto rx_indicate;
117 else if ((authSeq == 2) || (authSeq == 4)){ //Seqence 2 or 4
118 signal->id = SIG_AUTH_EVEN;
119 signal->block = BLOCK_AUTH_REQ;
120 goto rx_indicate;
122 else{
123 goto rx_release;
127 case ST_DISASOC:
128 SsInquiry(addr2(rdu), &sas, &sau);
129 if ((memcmp(&mBssId.mac[0],addr2(rdu),6)==0 && mBssType==INFRASTRUCTURE_BSS))
131 #ifdef WPA_DEBUG
132 printk(KERN_ERR "Rx DeAssoc,Reason:%u\n",reason(rdu));
133 #endif
135 if(sau == STATION_STATE_NOT_AUTH){
136 goto class2_err;
138 else{
139 signal->id = SIG_DISASSOC;
140 signal->block = BLOCK_ASOC;
141 goto rx_indicate;
144 case ST_ASOC_REQ:
145 SsInquiry(addr2(rdu), &sas, &sau);
146 if (sau == STATION_STATE_NOT_AUTH){
147 goto class2_err;
149 else {
150 signal->id = SIG_ASSOC;
151 signal->block = BLOCK_ASOC;
152 goto rx_indicate;
155 case ST_REASOC_REQ:
156 SsInquiry(addr2(rdu), &sas, &sau);
157 if (sau == STATION_STATE_NOT_AUTH){
158 goto class2_err;
160 else {
161 signal->id = SIG_REASSOC;
162 signal->block = BLOCK_ASOC;
163 goto rx_indicate;
166 case ST_BEACON:
167 case ST_PROBE_RSP:
168 if (mBssType == AP_BSS)
169 goto rx_release;
171 signal->id = SIQ_PROBE_RSP_BEACON;
172 signal->block = BLOCK_SYNCH;
173 goto rx_indicate;
175 case ST_ASOC_RSP:
176 if (mBssType == AP_BSS)
177 goto rx_release;
179 signal->id = SIG_ASSOC_RSP;
180 signal->block = BLOCK_ASOC;
181 goto rx_indicate;
183 case ST_REASOC_RSP:
184 if (mBssType == AP_BSS)
185 goto rx_release;
187 signal->id = SIG_REASSOC_RSP;
188 signal->block = BLOCK_ASOC;
189 goto rx_indicate;
191 default:
192 goto rx_release;
195 rx_release:
196 ZDEBUG("goto rx_release");
197 return FALSE;
199 rx_indicate:
200 signal->frmInfo.frmDesc = pfrmDesc;
201 sigEnque(pMgtQ, (signal));
202 return TRUE;
204 class2_err:
205 ZDEBUG("goto class2_err");
206 signal->id = SIG_DEAUTH_REQ;
207 signal->block = BLOCK_AUTH_REQ;
208 memcpy((U8 *)&signal->frmInfo.Sta, (U8 *)(addr2(rdu)), 6);
209 signal->frmInfo.rCode = RC_CLASS2_ERROR;
210 freeFdesc(pfrmDesc);
211 sigEnque(pMgtQ, (signal));
212 return TRUE;
215 #endif