summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index e8d9de7..c8d77a7 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -425,205 +425,206 @@ void Wellenreiter::receivePacket( OPacket* p )
OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
if ( eth )
{
handleEthernetData( p, eth, source, dest );
}
// check for an arp frame since arp frames come in two flavours:
// 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
if ( arp )
{
handleARPData( p, arp, source, dest );
}
// check for a ip frame
OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
if ( ip )
{
handleIPData( p, ip, source, dest );
}
//handleNotification( p );
}
void Wellenreiter::stopClicked()
{
if ( iface )
{
disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::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->setMode( "managed" );
// 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
+ if ( cardtype != DEVTYPE_FILE )
+ {
+
if ( !net->isPresent( interface ) )
{
QMessageBox::information( this, "Wellenreiter II",
tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
return;
}
iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
assert( iface );
// bring device UP
- if ( cardtype != DEVTYPE_FILE )
- {
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->setMode( "monitor" );
if ( iface->mode() != "monitor" )
{
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 ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
{
dumpname = configwindow->captureFileName->text();
if ( dumpname.isEmpty() ) dumpname = "captureFile";
dumpname.append( '-' );
dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
dumpname.append( ".wellenreiter" );
}
else // write it anyway ;)
{
dumpname = "/var/log/dump.wellenreiter";
}
if ( cardtype != DEVTYPE_FILE )
pcap->open( interface );
else
pcap->open( QFile( interface ) );
qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
pcap->openDumpFile( dumpname );
if ( !pcap->isOpen() )
{
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(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
}
else
{
// start timer for reading packets
startTimer( 100 );
}
logwindow->log( "(i) Started Scanning." );