[kismac] [binaervarianz] r184 - in branches/usb-drivers/Sources: Driver/USBJack WaveDrivers

  • From: svn@xxxxxxxxxxxxxxxx
  • To: kismac@xxxxxxxxxxxxx
  • Date: Sun, 03 Sep 2006 10:37:51 +0200

Author: gkruse
Date: 2006-09-03 10:37:41 +0200 (Sun, 03 Sep 2006)
New Revision: 184

Modified:
   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
   branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
   branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
Log:
Ralink seems to use a non-standard 802.11 header, so we have to copy the paket 
in two different hunks to make stuff line up later on.  This is probably not 
right, but allows the ssid to be found.  We probably need to place the 802.3 
header in its spot too.  Rightnow it is 0.  Also added the linksys wusb54g 
device and product id's thanks to Deffie.

Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm   2006-09-02 
19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm   2006-09-03 
08:37:41 UTC (rev 184)
@@ -851,7 +851,7 @@
 
 bool RalinkJack::startCapture(UInt16 channel) {
     setChannel(channel);
-    RTUSBWriteMACRegister(TXRX_CSR2, 0x4e); //enable monitor mode?
+    RTUSBWriteMACRegister(TXRX_CSR2, 0x004e); //enable monitor mode?
     return true;   
 }
 
@@ -861,13 +861,13 @@
     WLFrame * tempFrame;
     PRXD_STRUC         pRxD;
     
-if (len >= (sizeof(RXD_STRUC) + 24)) {
+    bzero(frame,sizeof(_recieveBuffer));
     tempFrame = (WLFrame *)frame;
     
     pData = (unsigned char*)&_recieveBuffer;
 
     pRxD = (PRXD_STRUC)(pData + len - sizeof(RXD_STRUC));
-    if (pRxD->Crc) {
+ /*   if (pRxD->Crc) {
         //NSLog(@"Bad CRC");
         return false;  //its a bad packet, signal the interrupt to continue
     }
@@ -879,16 +879,18 @@
         //NSLog(@"PhyErr");
         return false;  //its a bad packet, signal the interrupt to continue
     }
-    else {
+    else {*/
        // NSLog(@"Good Frame : %d, %d, %d", pRxD->Crc, pRxD->CiErr, 
pRxD->PhyErr);
-        memcpy(frame + sizeof(WLPrismHeader), pData, sizeof(_recieveBuffer));
-        tempFrame->signal = pRxD->BBR1;
+        tempFrame->silence = pRxD->BBR1;
+        tempFrame->dataLen = NSSwapLittleShortToHost(len - 
sizeof(WLPrismHeader) - sizeof(RXD_STRUC));
+        
+        memcpy(frame + sizeof(WLPrismHeader), pData, 24 
/*sizeof(_recieveBuffer)*/); //copy the 80211 header, nnot 24 not 32 bytes
+        memcpy(frame + sizeof(WLPrismHeader) + 32 + 14, pData + 
24,sizeof(_recieveBuffer)-(32+14+sizeof(WLPrismHeader)));
         memcpy(&_recieveBuffer, frame, sizeof(_recieveBuffer));
         return true;         //override if needed
-    }
+   // }
+   // return false;
 }
-return false;
-}
 
 RalinkJack::RalinkJack() {
     _isEnabled = false;

Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.h
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/USBJack.h       2006-09-02 
19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.h       2006-09-03 
08:37:41 UTC (rev 184)
@@ -39,11 +39,13 @@
     virtual bool    getAllowedChannels(UInt16* channel);
     virtual bool    setChannel(UInt16 channel);
     bool    devicePresent();
+    int     getDeviceType();
     
     WLFrame * receiveFrame();
     bool    sendFrame(UInt8* data);
     
     void    startMatching();
+    virtual IOReturn    _init();
     USBJack();
     virtual ~USBJack();
     
@@ -54,6 +56,12 @@
     int kInterruptPipe;
     int kOutPipe;
     int kInPipe; 
+    
+    enum  deviceTypes {
+        intersil = 1,
+        zydas,
+        ralink
+    } deviceType; 
 
     IOReturn    _doCommand(enum WLCommandCode cmd, UInt16 param0, UInt16 
param1 = 0, UInt16 param2 = 0);
     IOReturn    _doCommandNoWait(enum WLCommandCode cmd, UInt16 param0, UInt16 
param1 = 0, UInt16 param2 = 0);
@@ -73,7 +81,6 @@
     int         _getFirmwareType();
     IOReturn    _disable();
     IOReturn    _enable();
-    virtual IOReturn    _init();
     virtual IOReturn    _reset();
     
     inline void        _lockDevice();

Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm      2006-09-02 
19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm      2006-09-03 
08:37:41 UTC (rev 184)
@@ -29,6 +29,7 @@
 
 #include "USBJack.h"
 #include "IntersilJack.h"
+#include "RalinkJack.h"
 
 #define wlcDeviceGone   (int)0xe000404f
 #define align64(a)      (((a)+63)&~63)
@@ -38,12 +39,6 @@
     UInt16 device;
 };
 
-enum  deviceTypes {
-    intersil,
-    zydas,
-    ralink
-} deviceType; 
-
 static struct identStruct devices[] = {
     { 0x04bb, 0x0922}, //1 IOData AirPort WN-B11/USBS
     { 0x07aa, 0x0012}, //2 Corega Wireless LAN USB Stick-11
@@ -80,12 +75,13 @@
     //zydas
     {0x0586, 0x3401}, //1 Zyxel duh
     //ralink
-    {0x2001, 0x3C00}, //1 Dlink duh
+    {0x2001, 0x3C00}, //1 Dlink rev B1 
+    {0x13b1, 0xd000}, //2 linksys wusb54g
 };
 
 #define dIntersilDeviceCount 32
 #define dZydasDeviceCount 1
-#define dRalinkDeviceCount 1
+#define dRalinkDeviceCount 2
 
 #define dbgOutPutBuf(a) NSLog( @"0x%.4x 0x%.4x 0x%.4x 0x%.4x%.4x", 
NSSwapLittleShortToHost(*((UInt16*)&(a) )), 
NSSwapLittleShortToHost(*((UInt16*)&(a)+1)), 
NSSwapLittleShortToHost(*((UInt16*)&(a)+2)), 
NSSwapLittleShortToHost(*((UInt16*)&(a)+3)), 
NSSwapLittleShortToHost(*((UInt16*)&(a)+4)) );              
 
@@ -118,6 +114,10 @@
     return _devicePresent;
 }
 
+int USBJack::getDeviceType(){
+    return deviceType;
+}
+
 WLFrame * USBJack::receiveFrame() {
     WLFrame* ret;
     
@@ -739,7 +739,7 @@
         }
         
         _devicePresent = true;
-        me->_init();
+        //me->_init();
         
         if (_channel) {
             startCapture(_channel);
@@ -752,7 +752,7 @@
 }
 
 void USBJack::_addDevice(void *refCon, io_iterator_t iterator) {
-    USBJack             *me = (USBJack*)refCon;
+    USBJack *me;
     kern_return_t              kr;
     io_service_t               usbDevice;
     IOCFPlugInInterface        **plugInInterface=NULL;
@@ -795,15 +795,18 @@
         
         if (i < dIntersilDeviceCount) {
             NSLog(@"Intersil USB Device found (vendor = 0x%x, product = 
0x%x)\n", vendor, product);
-            deviceType = intersil;
+            me = (IntersilJack*)refCon;
+            me->deviceType = intersil;
         }
      /*   else if (i < dIntersilDeviceCount + dZydasDeviceCount) {
             NSLog(@"Zydas USB Device found (vendor = 0x%x, product = 0x%x)\n", 
vendor, product);
-            deviceType = zydas;
+            me->deviceType = zydas;
+            me = (ZydasJack*) me;
         }*/
         else if (i < dIntersilDeviceCount + dZydasDeviceCount + 
dRalinkDeviceCount) {
             NSLog(@"Ralink 2500 USB Device found (vendor = 0x%x, product = 
0x%x)\n", vendor, product);
-            deviceType = ralink;
+            me = (RalinkJack*)refCon;
+            me->deviceType = ralink;
         }
         else {
             NSLog(@"found unwanted device  (vendor = 0x%x, product = 0x%x)\n", 
vendor, product);

Modified: branches/usb-drivers/Sources/Driver/USBJack/rt2570.h
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/rt2570.h        2006-09-02 
19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/Driver/USBJack/rt2570.h        2006-09-03 
08:37:41 UTC (rev 184)
@@ -529,6 +529,31 @@
 //
 typedef        struct  _RXD_STRUC
 {
+#if 0 
+    //__BIG_ENDIAN__
+    ULONG                              Eiv;// EIV
+    
+    ULONG                              Iv;// IV
+    
+    UCHAR                              Rev3[2];// Rev3
+    UCHAR                              BBR0;// BBP R1 - RSSI
+    UCHAR                              BBR1;// BBP R0 - SIGNAL / rate
+        
+    ULONG                              Rsv2:4;// Rev2
+    ULONG                              DataByteCnt:12;// data byte count 
+        
+    ULONG                              Rsv1:6;// Rev1
+    ULONG                              CiErr:1;// ci error
+    ULONG                              Cipher:1;// cipher
+    ULONG                              PhyErr:1;// phy err
+    ULONG                              Ofdm:1;// OFDM
+    ULONG                              Crc:1;// crc error
+    ULONG                              MyBss:1;// my bss
+    ULONG                              Bcast:1;// bcast
+    ULONG                              Mcast:1;// mcast
+    ULONG                              U2M:1;// u2me
+    ULONG                              Rev0:1;// Rev0
+#else
        // Word    0
        ULONG                           Rev0:1;// Rev0
        ULONG                           U2M:1;// u2me
@@ -552,15 +577,12 @@
        UCHAR                           BBR0;// BBP R1 - RSSI
        UCHAR                           Rev3[2];// Rev3
        
-       
-       
        // Word    2
        ULONG                           Iv;// IV
        
-       
-       
        // Word 3
        ULONG                           Eiv;// EIV
+#endif
 }
 RXD_STRUC, *PRXD_STRUC;
 

Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
===================================================================
--- branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h    
2006-09-02 19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h    
2006-09-03 08:37:41 UTC (rev 184)
@@ -27,10 +27,16 @@
 #import "WaveDriver.h"
 #import "../Driver/USBJack/IntersilJack.h"
 //#import "../Driver/USBJack/RalinkJack.h"
+enum  deviceTypes {
+    intersil = 1,
+    zydas,
+    ralink
+} deviceMake; 
+
 class RalinkJack;
 
 @interface WaveDriverUSBIntersil : WaveDriver {
-    RalinkJack *_driver;
+    USBJack *_driver;
     
     //stuff for timed sending
     float           _interval;

Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
===================================================================
--- branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm   
2006-09-02 19:51:13 UTC (rev 183)
+++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm   
2006-09-03 08:37:41 UTC (rev 184)
@@ -24,7 +24,9 @@
 */
 #import "WaveDriverUSBIntersil.h"
 #import "WaveHelper.h"
+#import "../Driver/USBJack/USBJack.h"
 #import "../Driver/USBJack/RalinkJack.h"
+//#import "../Driver/USBJack/ZydasJack.h"
 
 static bool explicitlyLoadedUSBIntersil = NO;
 
@@ -37,6 +39,26 @@
     _driver = new RalinkJack;
     _driver->startMatching();
     
+    while(!_driver->getDeviceType())        //wait until the device is found
+        usleep(100);
+    
+    switch(_driver->getDeviceType()){       //cast ourself to the approp type
+        case intersil:
+            _driver = new IntersilJack;
+            _driver->startMatching();
+            break;
+        case ralink:
+       //     _driver = new RalinkJack;
+       //     _driver->startMatching();
+            break;
+  /*      case zydas:
+            _driver = (ZydasJack*)_driver;
+            break;*/
+        default:
+            NSLog(@"The impossible happened!");
+    }
+    
+    _driver->_init();
        _errors = 0;
        
     return self;


Other related posts:

  • » [kismac] [binaervarianz] r184 - in branches/usb-drivers/Sources: Driver/USBJack WaveDrivers