summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-08-11 19:04:52 (UTC)
committer mickeyl <mickeyl>2003-08-11 19:04:52 (UTC)
commite7f79ca3acf58aef3ff150a2974f8087189621f5 (patch) (side-by-side diff)
treeb8397506f85d9a3b547940e416111de4b2da1f18
parent62cb34a352c38f97967882a7ac604d9670f0e75f (diff)
downloadopie-e7f79ca3acf58aef3ff150a2974f8087189621f5.zip
opie-e7f79ca3acf58aef3ff150a2974f8087189621f5.tar.gz
opie-e7f79ca3acf58aef3ff150a2974f8087189621f5.tar.bz2
assorted fixes and more work on GPS
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui52
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp20
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h4
-rw-r--r--noncore/net/wellenreiter/gui/gps.cpp48
-rw-r--r--noncore/net/wellenreiter/gui/gps.h19
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp40
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
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
@@ -311,8 +311,12 @@
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
+ <property stdset="1">
+ <name>editable</name>
+ <bool>false</bool>
+ </property>
<property>
<name>whatsThis</name>
<string>Choose the interface used for sniffing.</string>
</property>
@@ -1019,9 +1023,9 @@
</property>
</item>
<property stdset="1">
<name>name</name>
- <cstring>ComboBox8</cstring>
+ <cstring>gpsdHost</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
@@ -1049,9 +1053,9 @@
<widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
- <cstring>SpinBox2</cstring>
+ <cstring>gpsdPort</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
@@ -1071,69 +1075,69 @@
</widget>
</hbox>
</widget>
<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>
<property stdset="1">
<name>geometry</name>
<rect>
<x>10</x>
- <y>10</y>
- <width>199</width>
- <height>21</height>
+ <y>110</y>
+ <width>210</width>
+ <height>22</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
- <string>Enable GPS logging w/ gpsd</string>
+ <string>gpsd -p /dev/ttyS3 -s 57600</string>
</property>
</widget>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
- <cstring>startGPS</cstring>
+ <cstring>enableGPS</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>10</x>
- <y>80</y>
- <width>171</width>
+ <y>10</y>
+ <width>199</width>
<height>21</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
- <string>Start gpsd on localhost</string>
+ <string>Enable GPS logging w/ gpsd</string>
</property>
</widget>
<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>
<property stdset="1">
<name>geometry</name>
<rect>
<x>10</x>
- <y>110</y>
- <width>210</width>
- <height>22</height>
+ <y>80</y>
+ <width>171</width>
+ <height>21</height>
</rect>
</property>
<property stdset="1">
<name>text</name>
- <string>gpsd -p /dev/ttyS3 -s 57600</string>
+ <string>Start gpsd on localhost</string>
</property>
</widget>
</widget>
</widget>
@@ -1206,15 +1210,15 @@
</connection>
<connection>
<sender>enableGPS</sender>
<signal>toggled(bool)</signal>
- <receiver>ComboBox8</receiver>
+ <receiver>gpsdHost</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>enableGPS</sender>
<signal>toggled(bool)</signal>
- <receiver>SpinBox2</receiver>
+ <receiver>gpsdPort</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>startGPS</sender>
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
@@ -186,7 +186,25 @@ void WellenreiterConfigWindow::channelAllClicked(int state)
channel10->setChecked( b );
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
@@ -45,8 +45,12 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
int hoppingInterval() const;
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
@@ -14,4 +14,52 @@
**********************************************************************/
#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
@@ -15,5 +15,24 @@
#ifndef GPS_H
#define GPS_H
+#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
@@ -14,8 +14,9 @@
***********************************************************************/
// Local
+#include "gps.h"
#include "wellenreiter.h"
#include "scanlist.h"
#include "logwindow.h"
#include "hexwindow.h"
@@ -84,8 +85,10 @@ Wellenreiter::Wellenreiter( QWidget* parent )
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()
@@ -166,8 +169,16 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
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 )
@@ -237,9 +248,9 @@ QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& 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 );
@@ -356,9 +367,12 @@ void Wellenreiter::startClicked()
}
// 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() )
@@ -388,22 +402,31 @@ void Wellenreiter::startClicked()
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 );
@@ -429,9 +452,12 @@ void Wellenreiter::startClicked()
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
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
@@ -32,8 +32,9 @@ class OPacketCapturer;
class OWirelessNetworkInterface;
class WellenreiterConfigWindow;
class MLogWindow;
class MHexWindow;
+class GPS;
class Wellenreiter : public WellenreiterBase {
Q_OBJECT
@@ -80,8 +81,9 @@ class Wellenreiter : public WellenreiterBase {
OWirelessNetworkInterface* iface;
OPacketCapturer* pcap;
WellenreiterConfigWindow* configwindow;
+ GPS* gps;
//void readConfig();
//void writeConfig();
};