[kismac] [binaervarianz] r195 - in branches/usb-drivers: KisMAC.xcodeproj Sources/Core Sources/Driver/USBJack Sources/WaveDrivers
- From: svn@xxxxxxxxxxxxxxxx
- To: kismac@xxxxxxxxxxxxx
- Date: Fri, 22 Sep 2006 16:34:39 +0200
Author: gkruse
Date: 2006-09-22 16:34:31 +0200 (Fri, 22 Sep 2006)
New Revision: 195
Modified:
branches/usb-drivers/KisMAC.xcodeproj/project.pbxproj
branches/usb-drivers/Sources/Core/WaveHelper.m
branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm
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/WaveDrivers/WaveDriverAirport.m
branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
Log:
Multiple USB devices kinda sorta. If you are actually using ralink or prismII
usb, I'd stay with the r194 for now. If you are into testing new stuff, try
this.
Modified: branches/usb-drivers/KisMAC.xcodeproj/project.pbxproj
===================================================================
--- branches/usb-drivers/KisMAC.xcodeproj/project.pbxproj 2006-09-22
03:49:58 UTC (rev 194)
+++ branches/usb-drivers/KisMAC.xcodeproj/project.pbxproj 2006-09-22
14:34:31 UTC (rev 195)
@@ -361,7 +361,6 @@
008ACD6407C38DA800A76ADA /* BIGeneric.framework in Frameworks
*/ = {isa = PBXBuildFile; fileRef = 00F57AAC06A876EC0035AE2F /*
BIGeneric.framework */; };
008ACD6507C38DA800A76ADA /* BIGL.framework in Frameworks */ =
{isa = PBXBuildFile; fileRef = 00F57AAD06A876EC0035AE2F /* BIGL.framework */; };
008ACDB707C3923D00A76ADA /* libcrypto.dylib in Frameworks */ =
{isa = PBXBuildFile; fileRef = 000D15A406AAE47C00935F7C /* libcrypto.dylib */;
};
- 008ACDB807C3924B00A76ADA /* AppKit.framework in Frameworks */ =
{isa = PBXBuildFile; fileRef = 29B97324FDCFA39411CA2CEA /* AppKit.framework */;
};
008ACE4C07C3926500A76ADA /* Carbon.framework in Frameworks */ =
{isa = PBXBuildFile; fileRef = 00F9C64E06DB37E200E357F0 /* Carbon.framework */;
};
008ACFA607C3927900A76ADA /* IOKit.framework in Frameworks */ =
{isa = PBXBuildFile; fileRef = 00F9C64F06DB37E200E357F0 /* IOKit.framework */;
};
008ACFA707C3927900A76ADA /* Security.framework in Frameworks */
= {isa = PBXBuildFile; fileRef = 00F9C63F06DB378F00E357F0 /* Security.framework
*/; };
@@ -809,7 +808,6 @@
00FF593D06C630CC006C7F1E /* WaveDriverPrismGT.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= WaveDriverPrismGT.m; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.framework; name =
Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree
= "<absolute>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa =
PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc;
path = main.m; sourceTree = "<group>"; };
- 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.framework; name =
AppKit.framework; path = /System/Library/Frameworks/AppKit.framework;
sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.framework; name =
Foundation.framework; path = /System/Library/Frameworks/Foundation.framework;
sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* KisMAC_Prefix.pch */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
KisMAC_Prefix.pch; sourceTree = "<group>"; };
6C03D76F09B547F2005B2316 /* Growl.framework */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.framework; name =
Growl.framework; path = Resources/Growl.framework; sourceTree = "<group>"; };
@@ -849,7 +847,6 @@
008ACFA607C3927900A76ADA /* IOKit.framework in
Frameworks */,
008ACFA707C3927900A76ADA /* Security.framework
in Frameworks */,
008ACE4C07C3926500A76ADA /* Carbon.framework in
Frameworks */,
- 008ACDB807C3924B00A76ADA /* AppKit.framework in
Frameworks */,
008ACDB707C3923D00A76ADA /* libcrypto.dylib in
Frameworks */,
008ACD6407C38DA800A76ADA /* BIGeneric.framework
in Frameworks */,
008ACD6507C38DA800A76ADA /* BIGL.framework in
Frameworks */,
@@ -1395,7 +1392,6 @@
isa = PBXGroup;
children = (
29B97325FDCFA39411CA2CEA /*
Foundation.framework */,
- 29B97324FDCFA39411CA2CEA /* AppKit.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
Modified: branches/usb-drivers/Sources/Core/WaveHelper.m
===================================================================
--- branches/usb-drivers/Sources/Core/WaveHelper.m 2006-09-22 03:49:58 UTC
(rev 194)
+++ branches/usb-drivers/Sources/Core/WaveHelper.m 2006-09-22 14:34:31 UTC
(rev 195)
@@ -314,6 +314,8 @@
[w setConfiguration: driverProps];
[_waveDrivers setObject:w forKey:name];
} else {
+ return NO;
+ //this seems to hang instead of ever running the alert panel
NSRunCriticalAlertPanel(NSLocalizedString(@"Could not
instanitiate Driver.", "Driver init failed"),
[NSString stringWithFormat: NSLocalizedString
(@"Instanitiation Failure Description", @"LONG description of what might have
gone wrong"),
// @"KisMAC was able to load the driver backend for %@, but it
was unable to create an interface. "
Modified: branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm 2006-09-22
03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm 2006-09-22
14:34:31 UTC (rev 195)
@@ -109,6 +109,8 @@
WLHardwareAddress macAddr;
int i;
+
+ _attachDevice();
_firmwareType = -1;
for (i = 0; i< wlResetTries; i++) {
@@ -188,6 +190,7 @@
_isEnabled = false;
_deviceInit = false;
_devicePresent = false;
+ deviceType = intersil;
_interface = NULL;
_runLoopSource = NULL;
Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-22
03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2006-09-22
14:34:31 UTC (rev 195)
@@ -18,6 +18,8 @@
unsigned int i;
IOReturn ret;
+ _attachDevice();
+
NSLog(@"--> NICInitializeAsic");
do
@@ -853,13 +855,13 @@
bool RalinkJack::startCapture(UInt16 channel) {
setChannel(channel);
RTUSBWriteMACRegister(MAC_CSR20, 0x0002); //turn on led
- RTUSBWriteMACRegister(TXRX_CSR2, 0x004e); //enable monitor mode?
+ RTUSBWriteMACRegister(TXRX_CSR2, 0x0046); //enable monitor mode?
return true;
}
bool RalinkJack::stopCapture(){
RTUSBWriteMACRegister(MAC_CSR20, 0x0000); //turn off led
- RTUSBWriteMACRegister(TXRX_CSR2, 0x00ff); //disable rx
+ RTUSBWriteMACRegister(TXRX_CSR2, 0xffffffff); //disable rx
return true;
}
@@ -916,6 +918,7 @@
_isEnabled = false;
_deviceInit = false;
_devicePresent = false;
+ deviceType = ralink;
_interface = NULL;
_runLoopSource = NULL;
Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.h
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-22
03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2006-09-22
14:34:31 UTC (rev 195)
@@ -22,6 +22,8 @@
along with KisMAC; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef __USB_JACK
+#define __USB_JACK
#include <Cocoa/Cocoa.h>
#include <IOKit/usb/IOUSBLib.h>
@@ -88,14 +90,19 @@
inline IOReturn _writeWaitForResponse(UInt32 size);
IOReturn _configureAnchorDevice(IOUSBDeviceInterface **dev);
- IOReturn _findInterfaces(void *refCon, IOUSBDeviceInterface **dev);
+ IOReturn _findInterfaces(IOUSBDeviceInterface **dev);
+ void _attachDevice();
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 bool _massagePacket(int len);
static void _runCFRunLoop(USBJack* me);
static void _intCFRunLoop(USBJack* me);
+
+ // static IOUSBDeviceInterface **_foundDevices[10];
+ // static int _deviceType[10];
+ // static int _numDevices;
SInt32 _vendorID;
SInt32 _productID;
@@ -126,4 +133,7 @@
pthread_cond_t _wait_cond;
pthread_mutex_t _recv_mutex;
pthread_cond_t _recv_cond;
-};
\ No newline at end of file
+};
+
+
+#endif
\ No newline at end of file
Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm
===================================================================
--- branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2006-09-22
03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2006-09-22
14:34:31 UTC (rev 195)
@@ -34,6 +34,11 @@
#define wlcDeviceGone (int)0xe000404f
#define align64(a) (((a)+63)&~63)
+bool _matchingDone; //this is static so all instances of this class
can see it!
+int _numDevices = -1;
+IOUSBDeviceInterface **_foundDevices[10];
+int _deviceType[10];
+
struct identStruct {
UInt16 vendor;
UInt16 device;
@@ -79,8 +84,8 @@
{0x0411, 0x0067}, /* Melco */
{0x050d, 0x7050}, /* Belkin */
{0x050d, 0x7051}, /* Belkin */
- {0x050d, 0x705a}, /* Belkin */
- {0x06f8, 0xe000}, /* GUILLEMOT */
+ {0x050d, 0x705a}, /* Belkin */
+ {0x06f8, 0xe000}, /* GUILLEMOT */
{0x0707, 0xee13}, /* SMC */
{0x0b05, 0x1706}, /* ASUS */
{0x0b05, 0x1707}, /* ASUS */
@@ -92,7 +97,7 @@
{0x114b, 0x0110}, /* Spairon */
{0x13b1, 0x000d}, /* Cisco Systems */
{0x13b1, 0x0011}, /* Cisco Systems */
- {0x13b1, 0x001a}, /* Cisco Systems */
+ {0x13b1, 0x001a}, /* Cisco Systems */
{0x148f, 0x1706}, /* Ralink */
{0x148f, 0x2570}, /* Ralink */
{0x148f, 0x2573}, /* CNET CWD-854 */
@@ -102,8 +107,8 @@
{0x2001, 0x3c00}, /* D-LINK */
{0x07d1, 0x3c03}, /* D-LINK */
{0x0411, 0x008b}, /* Nintendo */
- {0x5a57, 0x0260}, /* Zinwell */
- {0x0eb0, 0x9020}, /* Novatech */
+ {0x5a57, 0x0260}, /* Zinwell */
+ {0x0eb0, 0x9020}, /* Novatech */
};
#define dIntersilDeviceCount 32
@@ -142,7 +147,10 @@
}
int USBJack::getDeviceType(){
- return deviceType;
+ if (_numDevices == -1) {
+ return -1;
+ }
+ return _deviceType[_numDevices];
}
WLFrame * USBJack::receiveFrame() {
@@ -505,6 +513,13 @@
IOReturn kr;
UInt32 type;
+/* if (me->deviceType == intersil) {
+ me = (IntersilJack*)refCon;
+ }else if (me->deviceType == ralink){
+ me = (RalinkJack*)refCon;
+ }
+*/
+
//NSLog(@"interruptRecieved.\n");
if (kIOReturnSuccess != result) {
if (result == (IOReturn)0xe00002ed) {
@@ -634,7 +649,7 @@
return kIOReturnSuccess;
}
-IOReturn USBJack::_findInterfaces(void *refCon, IOUSBDeviceInterface **dev) {
+IOReturn USBJack::_findInterfaces(IOUSBDeviceInterface **dev) {
IOReturn kr;
IOUSBFindInterfaceRequest request;
io_iterator_t iterator;
@@ -649,7 +664,6 @@
int pipeRef;
CFRunLoopSourceRef runLoopSource;
BOOL error;
- USBJack *me = (USBJack *) refCon;
request.bInterfaceClass = kIOUSBFindInterfaceDontCare;
@@ -723,9 +737,9 @@
break;
} else {
error = false;
- if (direction == kUSBIn && transferType == kUSBBulk)
me->kInPipe = pipeRef;
- else if (direction == kUSBOut && transferType == kUSBBulk)
me->kOutPipe = pipeRef;
- else if (direction == kUSBIn && transferType ==
kUSBInterrupt) me->kInterruptPipe = pipeRef;
+ if (direction == kUSBIn && transferType == kUSBBulk) kInPipe =
pipeRef;
+ else if (direction == kUSBOut && transferType == kUSBBulk)
kOutPipe = pipeRef;
+ else if (direction == kUSBIn && transferType ==
kUSBInterrupt) kInterruptPipe = pipeRef;
else NSLog(@"Found unknown interface, ignoring");
@@ -766,7 +780,6 @@
}
_devicePresent = true;
- //me->_init();
if (_channel) {
startCapture(_channel);
@@ -778,6 +791,47 @@
return kr;
}
+void USBJack::_attachDevice() {
+ kern_return_t kr;
+ IOUSBDeviceInterface **dev=NULL;
+
+ if ((dev = _foundDevices[_numDevices])) {
+
+ // need to open the device in order to change its state
+ kr = (*dev)->USBDeviceOpen(dev);
+ if (kIOReturnSuccess != kr) {
+ if (kr == kIOReturnExclusiveAccess) {
+ NSLog(@"Device already in use.");
+ }
+ else {
+ NSLog(@"unable to open device: %08x\n", kr);
+ }
+ (*dev)->Release(dev);
+ return;
+ }
+
+ kr = _configureAnchorDevice(dev);
+ if (kIOReturnSuccess != kr) {
+ NSLog(@"unable to configure device: %08x\n", kr);
+ (*dev)->USBDeviceClose(dev);
+ (*dev)->Release(dev);
+ return;
+ }
+
+ kr = _findInterfaces(dev);
+ if (kIOReturnSuccess != kr) {
+ NSLog(@"unable to find interfaces on device: %08x\n", kr);
+ (*dev)->USBDeviceClose(dev);
+ (*dev)->Release(dev);
+ return;
+ }
+
+ _numDevices--;
+ kr = (*dev)->USBDeviceClose(dev);
+ kr = (*dev)->Release(dev);
+ }
+}
+
void USBJack::_addDevice(void *refCon, io_iterator_t iterator) {
USBJack *me;
kern_return_t kr;
@@ -822,61 +876,24 @@
if (i < dIntersilDeviceCount) {
NSLog(@"Intersil USB Device found (vendor = 0x%x, product =
0x%x)\n", vendor, product);
- me = (IntersilJack*)refCon;
- me->deviceType = intersil;
+ _deviceType[++_numDevices] = intersil;
+ _foundDevices[_numDevices] = dev;
}
else if (i < dIntersilDeviceCount + dZydasDeviceCount) {
NSLog(@"Zydas USB Device found (vendor = 0x%x, product = 0x%x)\n",
vendor, product);
- me = (USBJack*)refCon;
- me->deviceType = zydas;
+ _deviceType[++_numDevices] = zydas;
+ _foundDevices[_numDevices] = dev;
}
else if (i < dIntersilDeviceCount + dZydasDeviceCount +
dRalinkDeviceCount) {
NSLog(@"Ralink 2500 USB Device found (vendor = 0x%x, product =
0x%x)\n", vendor, product);
- me = (RalinkJack*)refCon;
- me->deviceType = ralink;
+ _deviceType[++_numDevices] = ralink;
+ _foundDevices[_numDevices] = dev;
}
else {
NSLog(@"found unwanted device (vendor = 0x%x, product = 0x%x)\n",
vendor, product);
(*dev)->Release(dev);
continue;
}
-
- // need to open the device in order to change its state
- kr = (*dev)->USBDeviceOpen(dev);
- if (kIOReturnSuccess != kr) {
- if (kr == kIOReturnExclusiveAccess) {
- NSLog(@"Device already in use.");
- }
- else {
- NSLog(@"unable to open device: %08x\n", kr);
- }
- (*dev)->Release(dev);
- continue;
- }
-
- kr = me->_configureAnchorDevice(dev);
- if (kIOReturnSuccess != kr) {
- NSLog(@"unable to configure device: %08x\n", kr);
- (*dev)->USBDeviceClose(dev);
- (*dev)->Release(dev);
- continue;
- }
-
- kr = me->_findInterfaces(refCon, dev);
- if (kIOReturnSuccess != kr) {
- NSLog(@"unable to find interfaces on device: %08x\n", kr);
- (*dev)->USBDeviceClose(dev);
- (*dev)->Release(dev);
- continue;
- }
-
- //I think we need to hold onto the device to maintain exclusive access
- // kr = (*dev)->USBDeviceClose(dev);
- // kr = (*dev)->Release(dev);
- //we will release it in the destructor
- me->_dev = dev;
-
- break;
}
}
@@ -959,7 +976,8 @@
CFMutableDictionaryRef matchingDict;
kern_return_t kr;
- if (_runLoopSource) return;
+ if (_runLoopSource || _matchingDone) return;
+ _matchingDone = true;
// first create a master_port for my task
kr = IOMasterPort(MACH_PORT_NULL, &masterPort);
@@ -1041,8 +1059,8 @@
USBJack::~USBJack() {
NSLog(@"I'm being destroyed!!!");
stopRun();
- (*_dev)->USBDeviceClose(_dev);
- (*_dev)->Release(_dev);
+//(*_dev)->USBDeviceClose(_dev);
+ // (*_dev)->Release(_dev);
_interface = NULL;
_frameSize = 0;
Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverAirport.m
===================================================================
--- branches/usb-drivers/Sources/WaveDrivers/WaveDriverAirport.m
2006-09-22 03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverAirport.m
2006-09-22 14:34:31 UTC (rev 195)
@@ -114,7 +114,6 @@
WIErr res;
if (_context==Nil) return Nil; //someone killed the aiport driver?!
-
res = WirelessCreateScanResults(_context, 0, &netsp, &netsAdHocp, 0);
if (res) {
return Nil;
Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
===================================================================
--- branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
2006-09-22 03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.h
2006-09-22 14:34:31 UTC (rev 195)
@@ -26,23 +26,27 @@
#import <Foundation/Foundation.h>
#import "WaveDriver.h"
#import "../Driver/USBJack/IntersilJack.h"
-//#import "../Driver/USBJack/RalinkJack.h"
-enum deviceTypes {
- intersil = 1,
- zydas,
- ralink
-} deviceMake;
+//#import "../Driver/USBJack/RalinkJack.h"
class RalinkJack;
@interface WaveDriverUSBIntersil : WaveDriver {
USBJack *_driver;
+ enum deviceTypes {
+ intersil = 1,
+ zydas,
+ ralink
+ } deviceMake;
+
//stuff for timed sending
float _interval;
bool _transmitting;
int _errors;
+
}
+- (id)initAsMaster;
+//- (id)initWithMaster: (WaveDriverUSBIntersil) master;
@end
Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
===================================================================
--- branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
2006-09-22 03:49:58 UTC (rev 194)
+++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm
2006-09-22 14:34:31 UTC (rev 195)
@@ -37,8 +37,8 @@
self=[super init];
if(!self) return Nil;
- _driver = new RalinkJack;
- //make start matching a class function so we can call it before we try to
make an instance
+ _driver = new USBJack;
+ //this will only occur once!
_driver->startMatching();
while(!_driver->getDeviceType() && timeoutCount++ < 10) //wait
until the device is found
@@ -48,19 +48,18 @@
switch(_driver->getDeviceType()){ //cast ourself to the approp type
case intersil:
- delete(_driver);
+ // delete(_driver);
_driver = new IntersilJack;
- _driver->startMatching();
break;
case ralink:
- // delete(_driver);
- // _driver = new RalinkJack;
- // _driver->startMatching();
+ // delete(_driver);
+ _driver = new RalinkJack;
break;
case zydas:
break;
default:
- NSLog(@"The impossible happened!");
+ NSLog(@"No supported USB Device found!");
+ _errors++;
return Nil;
}
@@ -70,6 +69,23 @@
return self;
}
+- (id)initAsMaster {
+ int timeoutCount = 0;
+ self=[super init];
+ if(!self) return Nil;
+
+ _driver = new USBJack;
+ NSLog(@"Init Master USB driver.");
+ //make start matching a class function so we can call it before we try to
make an instance
+ _driver->startMatching();
+
+
+ // _driver->_init();
+ _errors = 0;
+
+ return self;
+}
+
#pragma mark -
+ (enum WaveDriverType) type {
Other related posts:
- » [kismac] [binaervarianz] r195 - in branches/usb-drivers: KisMAC.xcodeproj Sources/Core Sources/Driver/USBJack Sources/WaveDrivers