summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 96733ff..c03debb 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -6,24 +6,25 @@
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
***********************************************************************/
// Local
+#include "gps.h"
#include "wellenreiter.h"
#include "scanlist.h"
#include "logwindow.h"
#include "hexwindow.h"
#include "configwindow.h"
#include "statwindow.h"
#include "graphwindow.h"
#include "protolistview.h"
// Opie
#ifdef QWS
@@ -76,24 +77,26 @@ Wellenreiter::Wellenreiter( QWidget* parent )
#ifdef QWS
QString sys;
sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
_system = ODevice::inst()->system();
logwindow->log( sys );
#endif
netview->setColumnWidthMode( 1, QListView::Manual );
connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
pcap = new OPacketCapturer();
+
+ gps = new GPS( this );
}
Wellenreiter::~Wellenreiter()
{
delete pcap;
}
void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
{
configwindow = cw;
@@ -158,24 +161,32 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
else
{
qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
return;
}
OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
QString essid = ssid ? ssid->ID() : QString("<unknown>");
OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
int channel = ds ? ds->channel() : -1;
OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
+
+ if ( configwindow->enableGPS->isChecked() )
+ {
+ qDebug( "Wellenreiter::gathering GPS data..." );
+ float lat = gps->latitude();
+ qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 );
+ }
+
netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 );
// update graph window
if ( ds )
{
OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
if ( prism )
graphwindow->traffic( ds->channel(), prism->signalStrength() );
else
graphwindow->traffic( ds->channel(), 95 );
}
}
@@ -229,25 +240,25 @@ QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
return 0;
return p->child( protocol );
}
bool Wellenreiter::checkDumpPacket( OPacket* p )
{
// go through all child packets and see if one is inside the child hierarchy for p
// if so, do what the user requested (protocolAction), e.g. pass or discard
- if ( !configwindow->writeCaptureFile->isOn() )
+ if ( !configwindow->writeCaptureFile->isChecked() )
return false;
QObjectList* l = p->queryList();
QObjectListIt it( *l );
QObject* o;
while ( (o = it.current()) != 0 )
{
QString name = it.current()->name();
if ( configwindow->capturePackets->isProtocolChecked( name ) )
{
QString action = configwindow->capturePackets->protocolAction( name );
@@ -348,25 +359,28 @@ void Wellenreiter::startClicked()
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();
- iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
+
+ // 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() )
{
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();
@@ -380,38 +394,47 @@ void Wellenreiter::startClicked()
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() )
{
- QMessageBox::warning( this, "Wellenreiter II",
- tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) );
- return;
+ 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->isOn() )
+ 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
{
@@ -421,25 +444,28 @@ void Wellenreiter::startClicked()
if ( !pcap->isOpen() )
{
QMessageBox::warning( this, "Wellenreiter II",
tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
return;
}
// set capturer to non-blocking mode
pcap->setBlocking( false );
// start channel hopper
if ( cardtype != DEVTYPE_FILE )
- iface->setChannelHopping( 1000 ); //use interval from config window
+ {
+ 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 );
}