Author: gkruse Date: 2006-09-02 19:43:05 +0200 (Sat, 02 Sep 2006) New Revision: 182 Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm branches/usb-drivers/Sources/Driver/USBJack/USBJack.h branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm branches/usb-drivers/Sources/Driver/USBJack/structs.h Log: Shouldn't crash as much now Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2006-09-02 10:06:56 UTC (rev 181) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2006-09-02 17:43:05 UTC (rev 182) @@ -60,7 +60,7 @@ bool getAllowedChannels(UInt16* channels); bool startCapture(UInt16 channel); - void _massagePacket(int len); + bool _massagePacket(int len); private: int temp; Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-02 10:06:56 UTC (rev 181) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-02 17:43:05 UTC (rev 182) @@ -857,9 +857,9 @@ return true; } -void RalinkJack::_massagePacket(int len){ +bool RalinkJack::_massagePacket(int len){ unsigned char* pData; - UInt8 frame[len+sizeof(WLFrame)]; + UInt8 frame[len*2]; WLFrame * tempFrame; PRXD_STRUC pRxD; WLIEEEFrame* testIeee; @@ -870,25 +870,29 @@ testIeee = (WLIEEEFrame*)pData; pRxD = (PRXD_STRUC)(pData + len - sizeof(RXD_STRUC)); + if (pRxD->Crc || pRxD->CiErr || pRxD->PhyErr) { + return false; //its a bad packet, signal the interrupt to continue + } + + tempFrame->signal = pRxD->BBR1; - tempFrame->signal = pRxD->BBR1; - tempFrame->length = pRxD->DataByteCnt; //this should be a memcpy but I can't make it work! tempFrame->frameControl = testIeee->frameControl; tempFrame->duration = testIeee->duration; tempFrame->idnum = testIeee->idnum; tempFrame->sequenceControl = testIeee->sequenceControl; + tempFrame->dataLen = pRxD->DataByteCnt; + tempFrame->dataLen = NSSwapHostShortToLittle(tempFrame->dataLen); memcpy(tempFrame->address1, testIeee->address1, 6); memcpy(tempFrame->address2, testIeee->address2, 6); memcpy(tempFrame->address3, testIeee->address3, 6); memcpy(tempFrame->address4, testIeee->address4, 6); - memcpy(frame + sizeof(WLFrame),pData+sizeof(WLIEEEFrame),len - sizeof(WLIEEEFrame) - sizeof(RXD_STRUC)); - //tempFrame. - //memcpy(&tempFrame.frameControl, pData, len); - memcpy(&_recieveBuffer.rxfrm, tempFrame, len+sizeof(WLFrame) - sizeof(RXD_STRUC)-sizeof(WLIEEEFrame)); + memcpy(frame + sizeof(WLFrame) + sizeof(UInt16), pData+sizeof(WLIEEEFrame), len - sizeof(WLIEEEFrame)); + + memcpy(&_recieveBuffer, tempFrame, len + sizeof(WLPrismHeader)); - return; //override if needed + return true; //override if needed } RalinkJack::RalinkJack() { Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-02 10:06:56 UTC (rev 181) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-02 17:43:05 UTC (rev 182) @@ -86,7 +86,7 @@ static void _addDevice(void *refCon, io_iterator_t iterator); static void _handleDeviceRemoval(void *refCon, io_iterator_t iterator); static void _interruptRecieved(void *refCon, IOReturn result, int len); - virtual void _massagePacket(int len); + virtual bool _massagePacket(int len); static void _runCFRunLoop(USBJack* me); static void _intCFRunLoop(USBJack* me); Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2006-09-02 10:06:56 UTC (rev 181) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2006-09-02 17:43:05 UTC (rev 182) @@ -496,7 +496,7 @@ type = NSSwapLittleShortToHost(me->_recieveBuffer.type); if (_USB_ISRXFRM(type)) { - me->_massagePacket(len); //if this driver needs it, it will be overridden + if(!me->_massagePacket(len)) goto readon; //if this driver needs it, it will be overridden, skip bad packets WLFrame* frameDescriptor = (WLFrame*)&(me->_recieveBuffer.rxfrm); frameDescriptor->status = NSSwapLittleShortToHost(frameDescriptor->status); frameDescriptor->dataLen = NSSwapLittleShortToHost(frameDescriptor->dataLen); @@ -513,8 +513,8 @@ (frameDescriptor->status & 0x700) != 0x700 || frameDescriptor->status & 0xe000) { goto readon; - }*/ - + } + */ if (frameDescriptor->dataLen > 2304) { NSLog(@"MACJackCard::_handleRx: Oversized packet (%d bytes)\n", frameDescriptor->dataLen); @@ -577,8 +577,8 @@ } -void USBJack::_massagePacket(int len){ - return; //override if needed +bool USBJack::_massagePacket(int len){ + return true; //override if needed } #pragma mark - @@ -846,7 +846,7 @@ kern_return_t kr; io_service_t obj; int count = 0; - //USBJack *me = (USBJack*)refCon; + USBJack *me = (USBJack*)refCon; while ((obj = IOIteratorNext(iterator)) != nil) { count++; @@ -854,10 +854,10 @@ kr = IOObjectRelease(obj); } - /*if (count) { + if (count) { me->_interface = NULL; me->stopRun(); - }*/ + } } #pragma mark - Modified: branches/usb-drivers/Sources/Driver/USBJack/structs.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/structs.h 2006-09-02 10:06:56 UTC (rev 181) +++ branches/usb-drivers/Sources/Driver/USBJack/structs.h 2006-09-02 17:43:05 UTC (rev 182) @@ -204,5 +204,5 @@ _usb_rmemresp_t rmemresp ; _usb_bufavail_t bufavail ; _usb_error_t usberror ; - UInt8 boguspad[3000] ; + UInt8 boguspad[3000] ; } __attribute__((packed)) _usbin_t; \ No newline at end of file