author | mickeyl <mickeyl> | 2003-04-10 15:49:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-10 15:49:08 (UTC) |
commit | 4e8e3741dca909782e15bb197e5b6a78750536c2 (patch) (side-by-side diff) | |
tree | 37285f8d053b3995aee46487277b57248862848c /noncore/net/wellenreiter/gui/wellenreiter.cpp | |
parent | 3733471135ea180709fcf4695607cce0c5fc7fb5 (diff) | |
download | opie-4e8e3741dca909782e15bb197e5b6a78750536c2.zip opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.gz opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.bz2 |
Wellenreiter can now open and replay capture files as written by tcpdump, ethereal, etc.
Next task: writing capture files
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 94 |
1 files changed, 60 insertions, 34 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 @@ -212,46 +212,46 @@ void Wellenreiter::receivePacket(OPacket* p) (const char*) wlan->macAddress3().toString(true) ); netView()->traffic( "IBSS", wlan->macAddress2().toString(), wlan->macAddress1().toString(), wlan->macAddress3().toString() ); } return; } } void Wellenreiter::stopClicked() { - disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); - iface->setChannelHopping(); // stop hopping channels + 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 ); - // switch off monitor mode - iface->setMonitorMode( false ); - // switch off promisc flag - iface->setPromiscuousMode( false ); + system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess + } - 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." ); sniffing = false; emit( stoppedSniffing() ); // print out statistics statwindow->log( "-----------------------------------------" ); @@ -288,52 +288,78 @@ void Wellenreiter::startClicked() return; } // configure device ONetwork* net = ONetwork::instance(); 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 ) - iface->setMonitorMode( true ); - - if ( !iface->monitorMode() ) + // switch device into monitor mode + if ( cardtype < DEVTYPE_FILE ) { - QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); - return; + 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 - pcap->open( interface ); + 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 - iface->setChannelHopping( 1000 ); //use interval from config window + if ( cardtype != DEVTYPE_FILE ) + iface->setChannelHopping( 1000 ); //use interval from config window - // connect - connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); + 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; +} + |