summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Unidiff
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
@@ -12,12 +12,13 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local 16// Local
17 17
18#include "gps.h"
18#include "wellenreiter.h" 19#include "wellenreiter.h"
19#include "scanlist.h" 20#include "scanlist.h"
20#include "logwindow.h" 21#include "logwindow.h"
21#include "hexwindow.h" 22#include "hexwindow.h"
22#include "configwindow.h" 23#include "configwindow.h"
23#include "statwindow.h" 24#include "statwindow.h"
@@ -82,12 +83,14 @@ Wellenreiter::Wellenreiter( QWidget* parent )
82 #endif 83 #endif
83 84
84 netview->setColumnWidthMode( 1, QListView::Manual ); 85 netview->setColumnWidthMode( 1, QListView::Manual );
85 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 86 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
86 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 87 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
87 pcap = new OPacketCapturer(); 88 pcap = new OPacketCapturer();
89
90 gps = new GPS( this );
88} 91}
89 92
90 93
91Wellenreiter::~Wellenreiter() 94Wellenreiter::~Wellenreiter()
92{ 95{
93 delete pcap; 96 delete pcap;
@@ -164,12 +167,20 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
164 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
165 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 168 QString essid = ssid ? ssid->ID() : QString("<unknown>");
166 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
167 int channel = ds ? ds->channel() : -1; 170 int channel = ds ? ds->channel() : -1;
168 171
169 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 172 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
173
174 if ( configwindow->enableGPS->isChecked() )
175 {
176 qDebug( "Wellenreiter::gathering GPS data..." );
177 float lat = gps->latitude();
178 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", lat, 0.0 );
179 }
180
170 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); 181 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 );
171 182
172 // update graph window 183 // update graph window
173 if ( ds ) 184 if ( ds )
174 { 185 {
175 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 186 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
@@ -235,13 +246,13 @@ QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
235 246
236 247
237bool Wellenreiter::checkDumpPacket( OPacket* p ) 248bool Wellenreiter::checkDumpPacket( OPacket* p )
238{ 249{
239 // go through all child packets and see if one is inside the child hierarchy for p 250 // go through all child packets and see if one is inside the child hierarchy for p
240 // if so, do what the user requested (protocolAction), e.g. pass or discard 251 // if so, do what the user requested (protocolAction), e.g. pass or discard
241 if ( !configwindow->writeCaptureFile->isOn() ) 252 if ( !configwindow->writeCaptureFile->isChecked() )
242 return false; 253 return false;
243 254
244 QObjectList* l = p->queryList(); 255 QObjectList* l = p->queryList();
245 QObjectListIt it( *l ); 256 QObjectListIt it( *l );
246 QObject* o; 257 QObject* o;
247 258
@@ -354,13 +365,16 @@ void Wellenreiter::startClicked()
354 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 365 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
355 return; 366 return;
356 } 367 }
357 368
358 // configure device 369 // configure device
359 ONetwork* net = ONetwork::instance(); 370 ONetwork* net = ONetwork::instance();
360 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 371
372 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
373
374 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
361 375
362 // bring device UP 376 // bring device UP
363 iface->setUp( true ); 377 iface->setUp( true );
364 if ( !iface->isUp() ) 378 if ( !iface->isUp() )
365 { 379 {
366 QMessageBox::warning( this, "Wellenreiter II", 380 QMessageBox::warning( this, "Wellenreiter II",
@@ -386,26 +400,35 @@ void Wellenreiter::startClicked()
386 if ( cardtype < DEVTYPE_FILE ) 400 if ( cardtype < DEVTYPE_FILE )
387 { 401 {
388 if ( cardtype != DEVTYPE_MANUAL ) 402 if ( cardtype != DEVTYPE_MANUAL )
389 iface->setMonitorMode( true ); 403 iface->setMonitorMode( true );
390 if ( !iface->monitorMode() ) 404 if ( !iface->monitorMode() )
391 { 405 {
392 QMessageBox::warning( this, "Wellenreiter II", 406 if ( QMessageBox::warning( this, "Wellenreiter II",
393 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); 407 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
394 return; 408 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
409 return;
395 } 410 }
396 } 411 }
397 412
413 // open GPS device
414 if ( configwindow->enableGPS->isChecked() )
415 {
416 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
417 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
418 }
419
398 // open pcap and start sniffing 420 // open pcap and start sniffing
399 if ( cardtype != DEVTYPE_FILE ) 421 if ( cardtype != DEVTYPE_FILE )
400 { 422 {
401 pcap->open( interface ); 423 pcap->open( interface );
402 424
403 if ( configwindow->writeCaptureFile->isOn() ) 425 if ( configwindow->writeCaptureFile->isChecked() )
404 { 426 {
405 QString dumpname( configwindow->captureFileName->text() ); 427 QString dumpname( configwindow->captureFileName->text() );
428 if ( dumpname.isEmpty() ) dumpname = "captureFile";
406 dumpname.append( '-' ); 429 dumpname.append( '-' );
407 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 430 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
408 dumpname.append( ".wellenreiter" ); 431 dumpname.append( ".wellenreiter" );
409 pcap->openDumpFile( dumpname ); 432 pcap->openDumpFile( dumpname );
410 } 433 }
411 else 434 else
@@ -427,13 +450,16 @@ void Wellenreiter::startClicked()
427 450
428 // set capturer to non-blocking mode 451 // set capturer to non-blocking mode
429 pcap->setBlocking( false ); 452 pcap->setBlocking( false );
430 453
431 // start channel hopper 454 // start channel hopper
432 if ( cardtype != DEVTYPE_FILE ) 455 if ( cardtype != DEVTYPE_FILE )
433 iface->setChannelHopping( 1000 ); //use interval from config window 456 {
457 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
458 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
459 }
434 460
435 if ( cardtype != DEVTYPE_FILE ) 461 if ( cardtype != DEVTYPE_FILE )
436 { 462 {
437 // connect socket notifier and start channel hopper 463 // connect socket notifier and start channel hopper
438 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 464 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
439 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 465 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );