-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 14f251a..405eda8 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -364,56 +364,58 @@ void Wellenreiter::stopClicked() void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->driverType(); const int interval = configwindow->hoppingInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); return; } // configure device ONetwork* net = ONetwork::instance(); // TODO: check if interface is wireless and support sniffing for non-wireless interfaces iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! // bring device UP + if ( cardtype != DEVTYPE_FILE ) + { iface->setUp( true ); if ( !iface->isUp() ) { QMessageBox::warning( this, "Wellenreiter II", tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); return; } - + } // set monitor mode bool usePrism = configwindow->usePrismHeader(); switch ( cardtype ) { case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; default: assert( 0 ); // shouldn't reach this } // switch device into monitor mode if ( cardtype < DEVTYPE_FILE ) { if ( cardtype != DEVTYPE_MANUAL ) iface->setMonitorMode( true ); if ( !iface->monitorMode() ) { if ( QMessageBox::warning( this, "Wellenreiter II", tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) @@ -433,50 +435,50 @@ void Wellenreiter::startClicked() { pcap->open( interface ); if ( configwindow->writeCaptureFile->isChecked() ) { QString dumpname( configwindow->captureFileName->text() ); if ( dumpname.isEmpty() ) dumpname = "captureFile"; dumpname.append( '-' ); dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); dumpname.append( ".wellenreiter" ); pcap->openDumpFile( dumpname ); } else { pcap->open( interface ); } } else { pcap->open( QFile( interface ) ); } if ( !pcap->isOpen() ) { - QMessageBox::warning( this, "Wellenreiter II", - tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); + QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( + cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); return; } // set capturer to non-blocking mode pcap->setBlocking( false ); // start channel hopper if ( cardtype != DEVTYPE_FILE ) { logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window } if ( cardtype != DEVTYPE_FILE ) { // connect socket notifier and start channel hopper connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); } else { // start timer for reading packets startTimer( 100 ); } |