Author: gkruse Date: 2006-09-02 12:06:56 +0200 (Sat, 02 Sep 2006) New Revision: 181 Modified: branches/usb-drivers/Sources/Core/80211b.h 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/rt2570.h Log: We are scanning. This is really ugly folks, don't expect much. The MAC addresses are about the only thing we get right at the moment. Also crashes randomly from time to time, I suspect my memcopys are bad. CPU usage also seems to be 100% while scanning, and the card keeps generating interrupts after we stop scanning. Lastly, channel hopping seems to go faster than the card can actually change channels, so automatic hopping is broken at the moment. You can select a channel manually from the menu. Enjoy Modified: branches/usb-drivers/Sources/Core/80211b.h =================================================================== --- branches/usb-drivers/Sources/Core/80211b.h 2006-09-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Core/80211b.h 2006-09-02 10:06:56 UTC (rev 181) @@ -70,7 +70,7 @@ UInt8 tx_rtry; UInt8 tx_rate; UInt16 txControl; -} __attribute__((packed)) WLPrismHeader; +} WLPrismHeader; typedef struct _WLIEEEFrame { UInt16 frameControl; Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2006-09-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2006-09-02 10:06:56 UTC (rev 181) @@ -60,6 +60,8 @@ bool getAllowedChannels(UInt16* channels); bool startCapture(UInt16 channel); + void _massagePacket(int len); + private: int temp; unsigned short EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS]; Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-02 10:06:56 UTC (rev 181) @@ -857,6 +857,40 @@ return true; } +void RalinkJack::_massagePacket(int len){ + unsigned char* pData; + UInt8 frame[len+sizeof(WLFrame)]; + WLFrame * tempFrame; + PRXD_STRUC pRxD; + WLIEEEFrame* testIeee; + + tempFrame = (WLFrame *)frame; + + pData = (unsigned char*)&_recieveBuffer; + + testIeee = (WLIEEEFrame*)pData; + pRxD = (PRXD_STRUC)(pData + len - sizeof(RXD_STRUC)); + + 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; + + 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)); + + return; //override if needed +} + RalinkJack::RalinkJack() { _isEnabled = false; _deviceInit = false; Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-02 10:06:56 UTC (rev 181) @@ -86,6 +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); 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-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2006-09-02 10:06:56 UTC (rev 181) @@ -496,6 +496,7 @@ type = NSSwapLittleShortToHost(me->_recieveBuffer.type); if (_USB_ISRXFRM(type)) { + me->_massagePacket(len); //if this driver needs it, it will be overridden WLFrame* frameDescriptor = (WLFrame*)&(me->_recieveBuffer.rxfrm); frameDescriptor->status = NSSwapLittleShortToHost(frameDescriptor->status); frameDescriptor->dataLen = NSSwapLittleShortToHost(frameDescriptor->dataLen); @@ -508,15 +509,15 @@ * than the monitor mode port, or is a message type other than * normal, we don't want it. */ - if (frameDescriptor->status & 0x1 || + /* if (frameDescriptor->status & 0x1 || (frameDescriptor->status & 0x700) != 0x700 || frameDescriptor->status & 0xe000) { goto readon; - } + }*/ if (frameDescriptor->dataLen > 2304) { - //NSLog(@"MACJackCard::_handleRx: Oversized packet (%d bytes)\n", - // frameDescriptor->dataLen); + NSLog(@"MACJackCard::_handleRx: Oversized packet (%d bytes)\n", + frameDescriptor->dataLen); goto readon; } @@ -576,6 +577,10 @@ } +void USBJack::_massagePacket(int len){ + return; //override if needed +} + #pragma mark - IOReturn USBJack::_configureAnchorDevice(IOUSBDeviceInterface **dev) { Modified: branches/usb-drivers/Sources/Driver/USBJack/rt2570.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/rt2570.h 2006-09-01 06:39:56 UTC (rev 180) +++ branches/usb-drivers/Sources/Driver/USBJack/rt2570.h 2006-09-02 10:06:56 UTC (rev 181) @@ -261,6 +261,37 @@ #define NUM_BBP_REG_PARMS (sizeof(BBPRegTable) / sizeof(USHORT)) +// +// P802.11 Frame control field, 16 bit +// +typedef struct _FRAME_CONTROL { + USHORT Ver:2; // Protocol version + USHORT Type:2; // MSDU type + USHORT Subtype:4; // MSDU subtype + USHORT ToDs:1; // To DS indication + USHORT FrDs:1; // From DS indication + USHORT MoreFrag:1; // More fragment bit + USHORT Retry:1; // Retry status bit + USHORT PwrMgt:1; // Power management bit + USHORT MoreData:1; // More data bit + USHORT Wep:1; // Wep data + USHORT Order:1; // Strict order expected +} FRAME_CONTROL, *PFRAME_CONTROL; + +typedef struct _CONTROL_HEADER { + FRAME_CONTROL Frame; // Frame control structure + USHORT Duration; // Duration value + UInt8 Addr1[6]; // Address 1 field + UInt8 Addr2[6]; // Address 2 field +} CONTROL_HEADER, *PCONTROL_HEADER; + +typedef struct _HEADER_802_11 { + CONTROL_HEADER Controlhead; + UInt8 Addr3[6]; // Address 3 field + USHORT Frag:4; // Fragment number + USHORT Sequence:12; // Sequence number +} HEADER_802_11, *PHEADER_802_11; + typedef struct _BBP_TUNING_PARAMETERS_STRUC { UCHAR BBPTuningThreshold;