-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 @@ -299,32 +299,36 @@ <name>text</name> <string>14</string> </property> </widget> </grid> </widget> <widget row="0" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <property stdset="1"> <name>name</name> <cstring>interfaceName</cstring> </property> <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> </widget> <widget row="1" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <item> <property> <name>text</name> <string><select></string> </property> </item> <item> <property> <name>text</name> @@ -1007,145 +1011,145 @@ </property> <property stdset="1"> <name>text</name> <string>Host</string> </property> </widget> <widget> <class>QComboBox</class> <item> <property> <name>text</name> <string>localhost</string> </property> </item> <property stdset="1"> <name>name</name> - <cstring>ComboBox8</cstring> + <cstring>gpsdHost</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>:</string> </property> </widget> <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> </property> <property stdset="1"> <name>maxValue</name> <number>65535</number> </property> <property stdset="1"> <name>minValue</name> <number>1024</number> </property> <property stdset="1"> <name>value</name> <number>2947</number> </property> </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> </grid> </widget> <customwidgets> <customwidget> <class>ProtocolListView</class> <header location="local">protolistview.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> @@ -1194,33 +1198,33 @@ </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>captureFileName</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>capturePackets</receiver> <slot>setEnabled(bool)</slot> </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> <signal>toggled(bool)</signal> <receiver>commandGPS</receiver> <slot>setEnabled(bool)</slot> </connection> </connections> </UI> 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 @@ -174,19 +174,37 @@ void WellenreiterConfigWindow::getCaptureFileNameClicked() void WellenreiterConfigWindow::channelAllClicked(int state) { bool b = state; channel1->setChecked( b ); channel2->setChecked( b ); channel3->setChecked( b ); channel4->setChecked( b ); channel5->setChecked( b ); channel6->setChecked( b ); channel7->setChecked( b ); channel8->setChecked( b ); channel9->setChecked( b ); 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 @@ -33,30 +33,34 @@ class WellenreiterConfigWindow; class WellenreiterConfigWindow : public WellenreiterConfigBase { Q_OBJECT public: WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); int driverType() const; const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; static WellenreiterConfigWindow* instance() { return _instance; }; 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(); void channelAllClicked(int); protected: QMap<QString, int> _devicetype; static WellenreiterConfigWindow* _instance; int _guess; }; #endif 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 @@ -2,16 +2,64 @@ ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** 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. ** **********************************************************************/ #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 @@ -3,17 +3,36 @@ ** ** This file is part of Opie Environment. ** ** 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. ** **********************************************************************/ #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 @@ -2,32 +2,33 @@ ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** 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 #include <opie/odevice.h> #include <qpe/qcopenvelope_qws.h> using namespace Opie; #endif @@ -72,32 +73,34 @@ Wellenreiter::Wellenreiter( QWidget* parent ) // // detect operating system // #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; } void Wellenreiter::channelHopped(int c) @@ -154,32 +157,40 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) else if ( beacon->canESS() ) { type = "managed"; } 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 ); } } void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) { @@ -225,33 +236,33 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 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 ); qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); if ( action == "Discard" ) { logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); @@ -344,106 +355,121 @@ void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); 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(); switch ( cardtype ) { case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 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 { pcap->open( QFile( interface ) ); } 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 ); } logwindow->log( "(i) Started Scanning." ); sniffing = true; emit( startedSniffing() ); 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 @@ -20,32 +20,33 @@ #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif class QTimerEvent; class QPixmap; class OPacket; class OWaveLanManagementPacket; class OWaveLanDataPacket; class OPacketCapturer; class OWirelessNetworkInterface; class WellenreiterConfigWindow; class MLogWindow; class MHexWindow; +class GPS; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; MHexWindow* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; public: bool sniffing; @@ -68,24 +69,25 @@ class Wellenreiter : public WellenreiterBase { private: void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); void handleData( OPacket* p, OWaveLanDataPacket* data ); void handleNotification( OPacket* p ); void doAction( const QString& action, const QString& protocol, OPacket* p ); QObject* childIfToParse( OPacket* p, const QString& protocol ); bool checkDumpPacket( OPacket* p ); private: #ifdef QWS OSystem _system; // Opie Operating System identifier #endif OWirelessNetworkInterface* iface; OPacketCapturer* pcap; WellenreiterConfigWindow* configwindow; + GPS* gps; //void readConfig(); //void writeConfig(); }; #endif |