Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 178 |
1 files changed, 101 insertions, 77 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 0bfc8e9..3372883 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -25,43 +25,44 @@ using namespace Opie; #else #include <qapplication.h> #endif #include <opie2/onetwork.h> #include <opie2/opcap.h> // Qt #include <qpushbutton.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qspinbox.h> +#include <qtoolbutton.h> #include <qmainwindow.h> // Standard #include <assert.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> // Local #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "hexwindow.h" #include "configwindow.h" - +#include "statwindow.h" #include "manufacturers.h" Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // // construct manufacturer database // QString manufile; @@ -208,108 +209,131 @@ void Wellenreiter::receivePacket(OPacket* p) qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", (const char*) wlan->macAddress2().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress3().toString(true) ); netView()->traffic( "IBSS", wlan->macAddress2().toString(), wlan->macAddress1().toString(), wlan->macAddress3().toString() ); } return; } } -void Wellenreiter::startStopClicked() + +void Wellenreiter::stopClicked() { - if ( sniffing ) + disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); + disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); + iface->setChannelHopping(); // stop hopping channels + 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 )); + + // 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." ); + + sniffing = false; + emit( stoppedSniffing() ); + + // print out statistics + statwindow->log( "-----------------------------------------" ); + statwindow->log( "- Wellenreiter II Capturing Statistic -" ); + statwindow->log( "-----------------------------------------" ); + statwindow->log( "Packet Type | Receive Count" ); + + for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) { - disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); - iface->setChannelHopping(); // stop hopping channels - 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 )); - - // 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." ); + QString left; + left.sprintf( "%s", (const char*) it.key() ); + left = left.leftJustify( 20 ); + left.append( '|' ); + QString right; + right.sprintf( "%d", it.data() ); + right = right.rightJustify( 7 ); + statwindow->log( left + right ); } - else - { - // get configuration from config window +} - const QString& interface = configwindow->interfaceName->currentText(); - const int cardtype = configwindow->daemonDeviceType(); - const int interval = configwindow->daemonHopInterval(); - if ( ( interface == "" ) || ( cardtype == 0 ) ) - { - QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); - return; - } +void Wellenreiter::startClicked() +{ + // get configuration from config window - // configure device + const QString& interface = configwindow->interfaceName->currentText(); + const int cardtype = configwindow->daemonDeviceType(); + const int interval = configwindow->daemonHopInterval(); - ONetwork* net = ONetwork::instance(); - iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); + if ( ( interface == "" ) || ( cardtype == 0 ) ) + { + QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); + return; + } - // set monitor mode + // configure device - 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: assert( 0 ); // shouldn't happen - } + ONetwork* net = ONetwork::instance(); + iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); - iface->setMonitorMode( true ); + // set monitor mode - if ( !iface->monitorMode() ) - { - QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); - return; - } + 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." ); + } - // open pcap and start sniffing - pcap->open( interface ); + if ( cardtype > 0 && cardtype < 5 ) + iface->setMonitorMode( true ); - if ( !pcap->isOpen() ) - { - QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); - return; - } + if ( !iface->monitorMode() ) + { + QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); + return; + } - // set capturer to non-blocking mode - pcap->setBlocking( false ); + // open pcap and start sniffing + pcap->open( interface ); - // start channel hopper - iface->setChannelHopping( 1000 ); //use interval from config window + if ( !pcap->isOpen() ) + { + QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); + return; + } - // connect - connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); + // set capturer to non-blocking mode + pcap->setBlocking( false ); - logwindow->log( "(i) Started Scanning." ); - sniffing = true; + // start channel hopper + 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) ) ); + + logwindow->log( "(i) Started Scanning." ); + sniffing = true; + emit( startedSniffing() ); } |