author | mickeyl <mickeyl> | 2003-08-11 19:04:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-08-11 19:04:52 (UTC) |
commit | e7f79ca3acf58aef3ff150a2974f8087189621f5 (patch) (side-by-side diff) | |
tree | b8397506f85d9a3b547940e416111de4b2da1f18 | |
parent | 62cb34a352c38f97967882a7ac604d9670f0e75f (diff) | |
download | opie-e7f79ca3acf58aef3ff150a2974f8087189621f5.zip opie-e7f79ca3acf58aef3ff150a2974f8087189621f5.tar.gz opie-e7f79ca3acf58aef3ff150a2974f8087189621f5.tar.bz2 |
assorted fixes and more work on GPS
-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 52 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 20 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 48 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.h | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 40 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 2 |
7 files changed, 153 insertions, 32 deletions
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 @@ -314,2 +314,6 @@ </property> + <property stdset="1"> + <name>editable</name> + <bool>false</bool> + </property> <property> @@ -1022,3 +1026,3 @@ <name>name</name> - <cstring>ComboBox8</cstring> + <cstring>gpsdHost</cstring> </property> @@ -1052,3 +1056,3 @@ <name>name</name> - <cstring>SpinBox2</cstring> + <cstring>gpsdPort</cstring> </property> @@ -1074,6 +1078,10 @@ <widget> - <class>QCheckBox</class> + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>enableGPS</cstring> + <cstring>commandGPS</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> </property> @@ -1083,5 +1091,5 @@ <x>10</x> - <y>10</y> - <width>199</width> - <height>21</height> + <y>110</y> + <width>210</width> + <height>22</height> </rect> @@ -1090,3 +1098,3 @@ <name>text</name> - <string>Enable GPS logging w/ gpsd</string> + <string>gpsd -p /dev/ttyS3 -s 57600</string> </property> @@ -1097,3 +1105,3 @@ <name>name</name> - <cstring>startGPS</cstring> + <cstring>enableGPS</cstring> </property> @@ -1103,4 +1111,4 @@ <x>10</x> - <y>80</y> - <width>171</width> + <y>10</y> + <width>199</width> <height>21</height> @@ -1110,3 +1118,3 @@ <name>text</name> - <string>Start gpsd on localhost</string> + <string>Enable GPS logging w/ gpsd</string> </property> @@ -1114,10 +1122,6 @@ <widget> - <class>QLineEdit</class> + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>commandGPS</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <cstring>startGPS</cstring> </property> @@ -1127,5 +1131,5 @@ <x>10</x> - <y>110</y> - <width>210</width> - <height>22</height> + <y>80</y> + <width>171</width> + <height>21</height> </rect> @@ -1134,3 +1138,3 @@ <name>text</name> - <string>gpsd -p /dev/ttyS3 -s 57600</string> + <string>Start gpsd on localhost</string> </property> @@ -1209,3 +1213,3 @@ <signal>toggled(bool)</signal> - <receiver>ComboBox8</receiver> + <receiver>gpsdHost</receiver> <slot>setEnabled(bool)</slot> @@ -1215,3 +1219,3 @@ <signal>toggled(bool)</signal> - <receiver>SpinBox2</receiver> + <receiver>gpsdPort</receiver> <slot>setEnabled(bool)</slot> 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 @@ -189,4 +189,22 @@ void WellenreiterConfigWindow::channelAllClicked(int state) 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 @@ -48,2 +48,6 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase + bool useGPS() const; + const QString gpsHost() const; + int gpsPort() const; + public slots: 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 @@ -17 +17,49 @@ +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 @@ -18,2 +18,21 @@ +#include <qobject.h> +#include <qsocket.h> + +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 @@ -17,2 +17,3 @@ +#include "gps.h" #include "wellenreiter.h" @@ -87,2 +88,4 @@ Wellenreiter::Wellenreiter( QWidget* parent ) pcap = new OPacketCapturer(); + + gps = new GPS( this ); } @@ -169,2 +172,10 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 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 ); @@ -240,3 +251,3 @@ bool Wellenreiter::checkDumpPacket( OPacket* p ) // if so, do what the user requested (protocolAction), e.g. pass or discard - if ( !configwindow->writeCaptureFile->isOn() ) + if ( !configwindow->writeCaptureFile->isChecked() ) return false; @@ -359,3 +370,6 @@ void Wellenreiter::startClicked() 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! @@ -391,5 +405,6 @@ void Wellenreiter::startClicked() { - 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; } @@ -397,2 +412,9 @@ void Wellenreiter::startClicked() + // 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 @@ -402,5 +424,6 @@ void Wellenreiter::startClicked() - if ( configwindow->writeCaptureFile->isOn() ) + if ( configwindow->writeCaptureFile->isChecked() ) { QString dumpname( configwindow->captureFileName->text() ); + if ( dumpname.isEmpty() ) dumpname = "captureFile"; dumpname.append( '-' ); @@ -432,3 +455,6 @@ void Wellenreiter::startClicked() 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 + } 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 @@ -35,2 +35,3 @@ class MLogWindow; class MHexWindow; +class GPS; @@ -83,2 +84,3 @@ class Wellenreiter : public WellenreiterBase { WellenreiterConfigWindow* configwindow; + GPS* gps; |