author | mickeyl <mickeyl> | 2003-10-03 13:44:35 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-03 13:44:35 (UTC) |
commit | 120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed (patch) (side-by-side diff) | |
tree | 253c82439683b8fc2352de0859c92671568fdaff | |
parent | 9450f41ce6109fb9d22fca7b1c72c606fd37f5a7 (diff) | |
download | opie-120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed.zip opie-120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed.tar.gz opie-120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed.tar.bz2 |
fix a few SIGSEGVs related to not checking the value of iface, if we
are capturing from a file (DEVTYPE_FILE)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 18 |
1 files changed, 10 insertions, 8 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 @@ -292,263 +292,265 @@ void Wellenreiter::receivePacket( OPacket* p ) // check if we received a beacon frame OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); if ( beacon && beacon->managementType() == "Beacon" ) { handleBeacon( p, beacon ); return; } //TODO: WEP check here // check for a data frame OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); if ( data ) { handleData( p, data ); } handleNotification( 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; 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", tr( "Your wireless card\nshould now be usable again." ) ); sniffing = false; emit( stoppedSniffing() ); #ifdef QWS if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) { QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #else #warning FIXME: setScreenSaverMode is not operational on the X11 build #endif // print out statistics for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) statwindow->updateCounter( it.key(), it.data() ); } 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 - iface->setUp( true ); - if ( !iface->isUp() ) + if ( cardtype != DEVTYPE_FILE ) { - QMessageBox::warning( this, "Wellenreiter II", - tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); - return; + 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 ) return; } } // open GPS device if ( configwindow->enableGPS->isChecked() ) { qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); } // open pcap and start sniffing if ( cardtype != DEVTYPE_FILE ) { 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 ); } logwindow->log( "(i) Started Scanning." ); sniffing = true; #ifdef QWS if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) { QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; } #else #warning FIXME: setScreenSaverMode is not operational on the X11 build #endif emit( startedSniffing() ); if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title else { assert( parent() ); ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); } } void Wellenreiter::timerEvent( QTimerEvent* ) { qDebug( "Wellenreiter::timerEvent()" ); OPacket* p = pcap->next(); if ( !p ) // no more packets available { stopClicked(); } else { receivePacket( p ); delete p; } } void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) { #ifdef QWS if ( action == "TouchSound" ) ODevice::inst()->touchSound(); else if ( action == "AlarmSound" ) ODevice::inst()->alarmSound(); else if ( action == "KeySound" ) ODevice::inst()->keySound(); else if ( action == "LedOn" ) ODevice::inst()->setLedState( Led_Mail, Led_On ); else if ( action == "LedOff" ) ODevice::inst()->setLedState( Led_Mail, Led_Off ); else if ( action == "LogMessage" ) logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); else if ( action == "MessageBox" ) QMessageBox::information( this, "Notification!", QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); #else #warning Actions do not work with Qt/X11 yet #endif } void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) { #ifdef QWS if ( !iface ) { QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); return; } if ( sniffing ) |