From e7f79ca3acf58aef3ff150a2974f8087189621f5 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Mon, 11 Aug 2003 19:04:52 +0000 Subject: assorted fixes and more work on GPS --- diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index c1da98d..d9a0aea 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -312,6 +312,10 @@ enabled true + + editable + false + whatsThis Choose the interface used for sniffing. @@ -1020,7 +1024,7 @@ name - ComboBox8 + gpsdHost enabled @@ -1050,7 +1054,7 @@ QSpinBox name - SpinBox2 + gpsdPort enabled @@ -1072,67 +1076,67 @@ - QCheckBox + QLineEdit name - enableGPS + commandGPS + + + enabled + false geometry 10 - 10 - 199 - 21 + 110 + 210 + 22 text - Enable GPS logging w/ gpsd + gpsd -p /dev/ttyS3 -s 57600 QCheckBox name - startGPS + enableGPS geometry 10 - 80 - 171 + 10 + 199 21 text - Start gpsd on localhost + Enable GPS logging w/ gpsd - QLineEdit + QCheckBox name - commandGPS - - - enabled - false + startGPS geometry 10 - 110 - 210 - 22 + 80 + 171 + 21 text - gpsd -p /dev/ttyS3 -s 57600 + Start gpsd on localhost @@ -1207,13 +1211,13 @@ enableGPS toggled(bool) - ComboBox8 + gpsdHost setEnabled(bool) enableGPS toggled(bool) - SpinBox2 + gpsdPort setEnabled(bool) diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 11394d7..a331925 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -187,6 +187,24 @@ void WellenreiterConfigWindow::channelAllClicked(int state) channel11->setChecked( b ); channel12->setChecked( b ); channel13->setChecked( b ); - channel14->setChecked( b ); + channel14->setChecked( b ); } + +bool WellenreiterConfigWindow::useGPS() const +{ + return enableGPS->isChecked(); +} + + +const QString WellenreiterConfigWindow::gpsHost() const +{ + return useGPS() ? gpsdHost->currentText() : QString::null; +} + + +int WellenreiterConfigWindow::gpsPort() const +{ + bool ok; + return useGPS() ? gpsdPort->value() : -1; +} diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index 32dc840..8f160b1 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h @@ -46,6 +46,10 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase bool usePrismHeader() const; bool isChannelChecked( int ) const; + bool useGPS() const; + const QString gpsHost() const; + int gpsPort() const; + public slots: void changedDeviceType(int); void getCaptureFileNameClicked(); diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index c3bff53..4a24647 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp @@ -15,3 +15,51 @@ #include "gps.h" +GPS::GPS( QObject* parent, const char * name ) + :QObject( parent, name ) +{ + qDebug( "GPS::GPS()" ); + _socket = new QSocket( this, "gpsd commsock" ); +} + + +GPS::~GPS() +{ + qDebug( "GPS::~GPS()" ); +} + + +bool GPS::open( const QString& host, int port ) +{ + _socket->connectToHost( host, port ); +} + + +float GPS::latitude() const +{ + char buf[256]; + + int result = _socket->writeBlock( "p\r\n", 3 ); + if ( result ) + { + qDebug( "GPS write succeeded" ); + _socket->waitForMore( 20 ); + if ( _socket->canReadLine() ) + { + + int num = _socket->readLine( &buf[0], sizeof buf ); + if ( num ) + { + qDebug( "GPS got line: %s", &buf ); + return 0.0; + } + } + } + return -1.0; +} + + +float GPS::longitute() const +{ +} + diff --git a/noncore/net/wellenreiter/gui/gps.h b/noncore/net/wellenreiter/gui/gps.h index e7c3dce..ad0b6de 100644 --- a/noncore/net/wellenreiter/gui/gps.h +++ b/noncore/net/wellenreiter/gui/gps.h @@ -16,4 +16,23 @@ #ifndef GPS_H #define GPS_H +#include +#include + +class GPS : public QObject +{ + Q_OBJECT + + public: + GPS( QObject* parent = 0, const char * name = "GPS" ); + ~GPS(); + + bool open( const QString& host = "localhost", int port = 2947 ); + float latitude() const; + float longitute() const; + + private: + QSocket* _socket; +}; + #endif // GPS_H 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 @@ -15,6 +15,7 @@ // Local +#include "gps.h" #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" @@ -85,6 +86,8 @@ Wellenreiter::Wellenreiter( QWidget* parent ) 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 ); } @@ -167,6 +170,14 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast( 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 @@ -238,7 +249,7 @@ 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(); @@ -357,7 +368,10 @@ void Wellenreiter::startClicked() // configure device ONetwork* net = ONetwork::instance(); - iface = static_cast(net->interface( interface )); + + // TODO: check if interface is wireless and support sniffing for non-wireless interfaces + + iface = static_cast(net->interface( interface )); // fails if network is not wireless! // bring device UP iface->setUp( true ); @@ -389,20 +403,29 @@ void Wellenreiter::startClicked() 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" ); @@ -430,7 +453,10 @@ void Wellenreiter::startClicked() // 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 ) { diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index e1062df..43f6f99 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -33,6 +33,7 @@ class OWirelessNetworkInterface; class WellenreiterConfigWindow; class MLogWindow; class MHexWindow; +class GPS; class Wellenreiter : public WellenreiterBase { Q_OBJECT @@ -81,6 +82,7 @@ class Wellenreiter : public WellenreiterBase { OWirelessNetworkInterface* iface; OPacketCapturer* pcap; WellenreiterConfigWindow* configwindow; + GPS* gps; //void readConfig(); //void writeConfig(); -- cgit v0.9.0.2