Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 3372883..5c10c3b 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -218,34 +218,34 @@ void Wellenreiter::receivePacket(OPacket* p) } } void Wellenreiter::stopClicked() { + if ( iface ) + { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); iface->setChannelHopping(); // stop hopping channels + } + else + killTimers(); + pcap->close(); sniffing = false; - #ifdef QWS - oApp->setTitle(); - #else - qApp->mainWidget()->setCaption( "Wellenreiter II" ); - #endif - - // get interface name from config window - const QString& interface = configwindow->interfaceName->currentText(); - ONetwork* net = ONetwork::instance(); - iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); + if ( iface ) + { // switch off monitor mode iface->setMonitorMode( false ); // switch off promisc flag iface->setPromiscuousMode( false ); system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess + } + logwindow->log( "(i) Stopped Scanning." ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); // message the user QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); @@ -294,46 +294,72 @@ void Wellenreiter::startClicked() iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // set monitor mode switch ( cardtype ) { - case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; - case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; - case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; - case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; - default: - QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); + case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; + case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; + case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; + case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; + case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "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 } - if ( cardtype > 0 && cardtype < 5 ) + // switch device into monitor mode + if ( cardtype < DEVTYPE_FILE ) + { + if ( cardtype != DEVTYPE_MANUAL ) iface->setMonitorMode( true ); - if ( !iface->monitorMode() ) { QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); return; } + } // open pcap and start sniffing + if ( cardtype != DEVTYPE_FILE ) pcap->open( interface ); + else + pcap->open( QFile( interface ) ); if ( !pcap->isOpen() ) { QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); return; } // set capturer to non-blocking mode pcap->setBlocking( false ); // start channel hopper + if ( cardtype != DEVTYPE_FILE ) iface->setChannelHopping( 1000 ); //use interval from config window - // connect + 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 ); + } logwindow->log( "(i) Started Scanning." ); sniffing = true; emit( startedSniffing() ); } + + +void Wellenreiter::timerEvent( QTimerEvent* ) +{ + qDebug( "Wellenreiter::timerEvent()" ); + OPacket* p = pcap->next(); + receivePacket( p ); + delete p; +} + |