author | mickeyl <mickeyl> | 2003-04-09 21:40:31 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-09 21:40:31 (UTC) |
commit | cf029a4007ea344c530d8a71cd0b012393ebd7ba (patch) (side-by-side diff) | |
tree | e9f584885299548b9316a6da05ad31845487e6d9 /noncore/net/wellenreiter/gui/wellenreiter.cpp | |
parent | b055856776807f0a459a86b1e1f62902d2d3a9c3 (diff) | |
download | opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.zip opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.tar.gz opie-cf029a4007ea344c530d8a71cd0b012393ebd7ba.tar.bz2 |
- improve keyboard handling
- enable sniffer-menu
- fix handling of start/stop button
- add simple statistic window, fancy will follow ;-)
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 @@ -35,4 +35,5 @@ using namespace Opie; #include <qcombobox.h> #include <qspinbox.h> +#include <qtoolbutton.h> #include <qmainwindow.h> @@ -53,5 +54,5 @@ using namespace Opie; #include "hexwindow.h" #include "configwindow.h" - +#include "statwindow.h" #include "manufacturers.h" @@ -218,98 +219,121 @@ void Wellenreiter::receivePacket(OPacket* p) } -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() ); } |