Changeset 283
- Timestamp:
- 08/12/08 12:35:00 (3 months ago)
- Location:
- trunk/Sources/Driver/USBJack
- Files:
-
- 2 modified
-
IntersilJack.mm (modified) (2 diffs)
-
USBJack.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Sources/Driver/USBJack/IntersilJack.mm
r282 r283 248 248 KFrame *f = (KFrame *)outBuf; 249 249 250 UInt16 isToDS, isFrDS, subtype, headerLength = 0;250 UInt16 isToDS, isFrDS, subtype, dataLen, headerLength = 0; 251 251 UInt16 type; 252 252 // NSLog(@"_massagePacket %d", len); 253 253 if (len < sizeof(WLFrame)) { 254 NSLog(@"WTF, packet len %d shorter than footer %d!", len, sizeof(WLFrame));254 NSLog(@"WTF, packet len %d shorter than header %d!", len, sizeof(WLFrame)); 255 255 return false; 256 256 } … … 261 261 head->status = NSSwapLittleShortToHost(head->status); 262 262 if (head->status & 0x1 || (head->status & 0x700) != 0x700 || head->status & 0xe000) { 263 return false; 264 } 265 266 263 NSLog(@"FCS error"); 264 return false; 265 } 266 dataLen = NSSwapLittleShortToHost(head->dataLen); 267 // NSLog(@"dataLen %d", dataLen); 267 268 type = (head->frameControl & IEEE80211_TYPE_MASK); 268 //depending on the frame we have to figure the length of the header 269 subtype = (head->frameControl & IEEE80211_SUBTYPE_MASK); 270 isToDS = ((head->frameControl & IEEE80211_DIR_TODS) ? YES : NO); 271 isFrDS = ((head->frameControl & IEEE80211_DIR_FROMDS) ? YES : NO); 269 272 switch(type) { 270 case IEEE80211_TYPE_DATA: //Data Frames 271 isToDS = ((head->frameControl & IEEE80211_DIR_TODS) ? YES : NO); 272 isFrDS = ((head->frameControl & IEEE80211_DIR_FROMDS) ? YES : NO); 273 if (isToDS&&isFrDS) 274 headerLength=30; //WDS Frames are longer 275 else 276 headerLength=24; 273 case IEEE80211_TYPE_MGT: 274 // NSLog(@"MANAGEMENT"); 275 headerLength = sizeof(struct ieee80211_hdr_3addr); 277 276 break; 278 case IEEE80211_TYPE_CTL: //Control Frames 279 subtype=(head->frameControl & IEEE80211_SUBTYPE_MASK); 280 switch(subtype) { 281 case IEEE80211_SUBTYPE_PS_POLL: 282 case IEEE80211_SUBTYPE_RTS: 283 headerLength=16; 284 break; 285 case IEEE80211_SUBTYPE_CTS: 286 case IEEE80211_SUBTYPE_ACK: 287 headerLength=10; 288 break; 289 default: 290 break; 277 case IEEE80211_TYPE_DATA: 278 // NSLog(@"DATA"); 279 if (subtype == IEEE80211_SUBTYPE_QOS_DATA) { 280 // NSLog(@"QOS"); 281 if (isFrDS && isToDS) { 282 // NSLog(@"isFrDS && isToDS"); 283 headerLength = sizeof(struct ieee80211_hdr_4addrqos); 284 } else { 285 // NSLog(@"isFrDS || isToDS"); 286 headerLength = sizeof(struct ieee80211_hdr_3addrqos); 291 287 } 292 break; 293 case IEEE80211_TYPE_MGT: //Management Frame 294 headerLength=24; 288 } else { 289 // NSLog(@"NO QOS"); 290 if (isFrDS && isToDS) { 291 // NSLog(@"isFrDS && isToDS"); 292 headerLength = sizeof(struct ieee80211_hdr_4addr); 293 } else { 294 // NSLog(@"isFrDS || isToDS"); 295 headerLength = sizeof(struct ieee80211_hdr_3addr); 296 } 297 } 295 298 break; 299 case IEEE80211_TYPE_CTL: 300 // NSLog(@"CTL"); 301 switch(subtype) { 302 case IEEE80211_SUBTYPE_PS_POLL: 303 case IEEE80211_SUBTYPE_RTS: 304 headerLength=16; 305 break; 306 case IEEE80211_SUBTYPE_CTS: 307 case IEEE80211_SUBTYPE_ACK: 308 headerLength=10; 309 break; 296 310 default: 311 return false; 312 break; 313 } 297 314 break; 298 } 299 300 NSLog(@"dataLen %d", CFSwapInt16LittleToHost(head->dataLen)); 315 default: 316 NSLog(@"Unknown frame type %u", type); 317 return false; 318 } 319 301 320 memcpy(f->data, pData+sizeof(WLPrismHeader), headerLength); 302 memcpy((f->data)+24, pData+sizeof(WLFrame), len-sizeof(WLFrame)); 303 f->ctrl.len = CFSwapInt16LittleToHost(head->dataLen) + headerLength; 321 if (headerLength >= sizeof(struct ieee80211_hdr_3addr)) 322 memcpy(f->data + 24, pData+sizeof(WLFrame), dataLen); 323 else 324 dataLen = 0; 325 f->ctrl.len = dataLen+headerLength; 304 326 f->ctrl.signal = head->silence; 305 327 f->ctrl.channel = head->channel; -
trunk/Sources/Driver/USBJack/USBJack.mm
r282 r283 379 379 380 380 frame = (KFrame*)&(me->_receiveBuffer.rxfrm); 381 381 // NSLog(@"dataReceived %d", len); 382 382 // Why do we needs to convert ? 383 383 // frameDescriptor->status = NSSwapLittleShortToHost(frameDescriptor->status); … … 442 442 443 443 readon: 444 //bzero(&me->_receiveBuffer, sizeof(me->_receiveBuffer));444 bzero(&me->_receiveBuffer, sizeof(me->_receiveBuffer)); 445 445 kr = (*me->_interface)->ReadPipeAsync((me->_interface), (me->kInPipe), &me->_receiveBuffer, sizeof(me->_receiveBuffer), (IOAsyncCallback1)_interruptReceived, refCon); 446 446 if (kIOReturnSuccess != kr) {
