summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp12
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 365efb0..1d4a98b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,227 +1,239 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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 "gps.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20#include "scanlist.h" 20#include "scanlist.h"
21#include "logwindow.h" 21#include "logwindow.h"
22#include "hexwindow.h" 22#include "hexwindow.h"
23#include "configwindow.h" 23#include "configwindow.h"
24#include "statwindow.h" 24#include "statwindow.h"
25#include "graphwindow.h" 25#include "graphwindow.h"
26#include "protolistview.h" 26#include "protolistview.h"
27 27
28// Opie 28// Opie
29 29
30#ifdef QWS 30#ifdef QWS
31#include <opie/odevice.h> 31#include <opie/odevice.h>
32#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33using namespace Opie; 33using namespace Opie;
34#endif 34#endif
35 35
36#ifdef QWS 36#ifdef QWS
37#include <opie2/oapplication.h> 37#include <opie2/oapplication.h>
38#else 38#else
39#include <qapplication.h> 39#include <qapplication.h>
40#endif 40#endif
41#include <opie2/omanufacturerdb.h>
41#include <opie2/onetwork.h> 42#include <opie2/onetwork.h>
42#include <opie2/opcap.h> 43#include <opie2/opcap.h>
43 44
44// Qt 45// Qt
45 46
46#include <qcheckbox.h> 47#include <qcheckbox.h>
47#include <qcombobox.h> 48#include <qcombobox.h>
48#include <qdatetime.h> 49#include <qdatetime.h>
49#include <qpushbutton.h> 50#include <qpushbutton.h>
50#include <qlineedit.h> 51#include <qlineedit.h>
51#include <qmessagebox.h> 52#include <qmessagebox.h>
52#include <qobjectlist.h> 53#include <qobjectlist.h>
53#include <qregexp.h> 54#include <qregexp.h>
54#include <qspinbox.h> 55#include <qspinbox.h>
56#include <qtimer.h>
55#include <qtoolbutton.h> 57#include <qtoolbutton.h>
56#include <qmainwindow.h> 58#include <qmainwindow.h>
57 59
58// Standard 60// Standard
59 61
60#include <assert.h> 62#include <assert.h>
61#include <errno.h> 63#include <errno.h>
62#include <unistd.h> 64#include <unistd.h>
63#include <string.h> 65#include <string.h>
64#include <sys/types.h> 66#include <sys/types.h>
65#include <stdlib.h> 67#include <stdlib.h>
66 68
67Wellenreiter::Wellenreiter( QWidget* parent ) 69Wellenreiter::Wellenreiter( QWidget* parent )
68 : WellenreiterBase( parent, 0, 0 ), 70 : WellenreiterBase( parent, 0, 0 ),
69 sniffing( false ), iface( 0 ), configwindow( 0 ) 71 sniffing( false ), iface( 0 ), configwindow( 0 )
70{ 72{
71 73
72 logwindow->log( "(i) Wellenreiter has been started." ); 74 logwindow->log( "(i) Wellenreiter has been started." );
73 75
74 // 76 //
75 // detect operating system 77 // detect operating system
76 // 78 //
77 79
78 #ifdef QWS 80 #ifdef QWS
79 QString sys; 81 QString sys;
80 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 82 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
81 _system = ODevice::inst()->system(); 83 _system = ODevice::inst()->system();
82 logwindow->log( sys ); 84 logwindow->log( sys );
83 #endif 85 #endif
84 86
85 netview->setColumnWidthMode( 1, QListView::Manual ); 87 netview->setColumnWidthMode( 1, QListView::Manual );
86 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 88 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
87 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 89 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
88 pcap = new OPacketCapturer(); 90 pcap = new OPacketCapturer();
89 91
90 gps = new GPS( this ); 92 gps = new GPS( this );
93
94 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
95
91} 96}
92 97
93 98
94Wellenreiter::~Wellenreiter() 99Wellenreiter::~Wellenreiter()
95{ 100{
96 delete pcap; 101 delete pcap;
97} 102}
98 103
99 104
105void Wellenreiter::initialTimer()
106{
107 qDebug( "Wellenreiter::preloading manufacturer database..." );
108 OManufacturerDB::instance();
109}
110
111
100void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 112void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
101{ 113{
102 configwindow = cw; 114 configwindow = cw;
103} 115}
104 116
105 117
106void Wellenreiter::channelHopped(int c) 118void Wellenreiter::channelHopped(int c)
107{ 119{
108 QString title = "Wellenreiter II -scan- ["; 120 QString title = "Wellenreiter II -scan- [";
109 QString left; 121 QString left;
110 if ( c > 1 ) left.fill( '.', c-1 ); 122 if ( c > 1 ) left.fill( '.', c-1 );
111 title.append( left ); 123 title.append( left );
112 title.append( '|' ); 124 title.append( '|' );
113 if ( c < iface->channels() ) 125 if ( c < iface->channels() )
114 { 126 {
115 QString right; 127 QString right;
116 right.fill( '.', iface->channels()-c ); 128 right.fill( '.', iface->channels()-c );
117 title.append( right ); 129 title.append( right );
118 } 130 }
119 title.append( "]" ); 131 title.append( "]" );
120 //title.append( QString().sprintf( " %02d", c ) ); 132 //title.append( QString().sprintf( " %02d", c ) );
121 assert( parent() ); 133 assert( parent() );
122 ( (QMainWindow*) parent() )->setCaption( title ); 134 ( (QMainWindow*) parent() )->setCaption( title );
123} 135}
124 136
125 137
126void Wellenreiter::handleNotification( OPacket* p ) 138void Wellenreiter::handleNotification( OPacket* p )
127{ 139{
128 QObjectList* l = p->queryList(); 140 QObjectList* l = p->queryList();
129 QObjectListIt it( *l ); 141 QObjectListIt it( *l );
130 QObject* o; 142 QObject* o;
131 143
132 while ( (o = it.current()) != 0 ) 144 while ( (o = it.current()) != 0 )
133 { 145 {
134 QString name = it.current()->name(); 146 QString name = it.current()->name();
135 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 147 if ( configwindow->parsePackets->isProtocolChecked( name ) )
136 { 148 {
137 QString action = configwindow->parsePackets->protocolAction( name ); 149 QString action = configwindow->parsePackets->protocolAction( name );
138 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 150 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
139 doAction( action, name, p ); 151 doAction( action, name, p );
140 } 152 }
141 else 153 else
142 { 154 {
143 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
144 } 156 }
145 ++it; 157 ++it;
146 } 158 }
147} 159}
148 160
149 161
150void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 162void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
151{ 163{
152 QString type; 164 QString type;
153 if ( beacon->canIBSS() ) 165 if ( beacon->canIBSS() )
154 { 166 {
155 type = "adhoc"; 167 type = "adhoc";
156 } 168 }
157 else if ( beacon->canESS() ) 169 else if ( beacon->canESS() )
158 { 170 {
159 type = "managed"; 171 type = "managed";
160 } 172 }
161 else 173 else
162 { 174 {
163 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 175 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
164 return; 176 return;
165 } 177 }
166 178
167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 179 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
168 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 180 QString essid = ssid ? ssid->ID() : QString("<unknown>");
169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 181 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
170 int channel = ds ? ds->channel() : -1; 182 int channel = ds ? ds->channel() : -1;
171 183
172 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 184 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
173 185
174 GpsLocation loc( 0, 0 ); 186 GpsLocation loc( 0, 0 );
175 if ( configwindow->enableGPS->isChecked() ) 187 if ( configwindow->enableGPS->isChecked() )
176 { 188 {
177 // TODO: add check if GPS is working!? 189 // TODO: add check if GPS is working!?
178 qDebug( "Wellenreiter::gathering GPS data..." ); 190 qDebug( "Wellenreiter::gathering GPS data..." );
179 loc = gps->position(); 191 loc = gps->position();
180 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); 192 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude );
181 } 193 }
182 194
183 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 195 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
184 196
185 // update graph window 197 // update graph window
186 if ( ds ) 198 if ( ds )
187 { 199 {
188 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 200 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
189 if ( prism ) 201 if ( prism )
190 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 202 graphwindow->traffic( ds->channel(), prism->signalStrength() );
191 else 203 else
192 graphwindow->traffic( ds->channel(), 95 ); 204 graphwindow->traffic( ds->channel(), 95 );
193 } 205 }
194} 206}
195 207
196 208
197void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 209void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
198{ 210{
199 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 211 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
200 if ( wlan->fromDS() && !wlan->toDS() ) 212 if ( wlan->fromDS() && !wlan->toDS() )
201 { 213 {
202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 214 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
203 from = wlan->macAddress3(); 215 from = wlan->macAddress3();
204 to = wlan->macAddress2(); 216 to = wlan->macAddress2();
205 } 217 }
206 else if ( !wlan->fromDS() && wlan->toDS() ) 218 else if ( !wlan->fromDS() && wlan->toDS() )
207 { 219 {
208 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 220 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
209 from = wlan->macAddress2(); 221 from = wlan->macAddress2();
210 to = wlan->macAddress3(); 222 to = wlan->macAddress3();
211 } 223 }
212 else if ( wlan->fromDS() && wlan->toDS() ) 224 else if ( wlan->fromDS() && wlan->toDS() )
213 { 225 {
214 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 226 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
215 from = wlan->macAddress4(); 227 from = wlan->macAddress4();
216 to = wlan->macAddress3(); 228 to = wlan->macAddress3();
217 } 229 }
218 else 230 else
219 { 231 {
220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 232 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
221 from = wlan->macAddress2(); 233 from = wlan->macAddress2();
222 to = wlan->macAddress1(); 234 to = wlan->macAddress1();
223 } 235 }
224} 236}
225 237
226 238
227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 239void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 25a5e8d..d882500 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,100 +1,102 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OWaveLanManagementPacket; 29class OWaveLanManagementPacket;
30class OWaveLanDataPacket; 30class OWaveLanDataPacket;
31class OEthernetPacket; 31class OEthernetPacket;
32class OARPPacket; 32class OARPPacket;
33class OMacAddress; 33class OMacAddress;
34class OIPPacket; 34class OIPPacket;
35class OPacketCapturer; 35class OPacketCapturer;
36class OWirelessNetworkInterface; 36class OWirelessNetworkInterface;
37class WellenreiterConfigWindow; 37class WellenreiterConfigWindow;
38class MLogWindow; 38class MLogWindow;
39class MHexWindow; 39class MHexWindow;
40class GPS; 40class GPS;
41 41
42class Wellenreiter : public WellenreiterBase { 42class Wellenreiter : public WellenreiterBase {
43 Q_OBJECT 43 Q_OBJECT
44 44
45 public: 45 public:
46 Wellenreiter( QWidget* parent = 0 ); 46 Wellenreiter( QWidget* parent = 0 );
47 ~Wellenreiter(); 47 ~Wellenreiter();
48 48
49 void setConfigWindow( WellenreiterConfigWindow* cw ); 49 void setConfigWindow( WellenreiterConfigWindow* cw );
50 MScanListView* netView() const { return netview; }; 50 MScanListView* netView() const { return netview; };
51 MLogWindow* logWindow() const { return logwindow; }; 51 MLogWindow* logWindow() const { return logwindow; };
52 MHexWindow* hexWindow() const { return hexwindow; }; 52 MHexWindow* hexWindow() const { return hexwindow; };
53 bool isDaemonRunning() const { return sniffing; }; 53 bool isDaemonRunning() const { return sniffing; };
54 54
55 public: 55 public:
56 bool sniffing; 56 bool sniffing;
57 57
58 protected: 58 protected:
59 virtual void timerEvent( QTimerEvent* ); 59 virtual void timerEvent( QTimerEvent* );
60 60
61 public slots: 61 public slots:
62 void initialTimer();
63
62 void channelHopped(int); 64 void channelHopped(int);
63 void receivePacket(OPacket*); 65 void receivePacket(OPacket*);
64 void startClicked(); 66 void startClicked();
65 void stopClicked(); 67 void stopClicked();
66 68
67 void joinNetwork(const QString&,const QString&,int,const QString&); 69 void joinNetwork(const QString&,const QString&,int,const QString&);
68 70
69 signals: 71 signals:
70 void startedSniffing(); 72 void startedSniffing();
71 void stoppedSniffing(); 73 void stoppedSniffing();
72 74
73 private: 75 private:
74 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 76 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
75 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 77 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
76 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 78 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
77 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); 79 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
78 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 80 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
79 void handleNotification( OPacket* p ); 81 void handleNotification( OPacket* p );
80 void doAction( const QString& action, const QString& protocol, OPacket* p ); 82 void doAction( const QString& action, const QString& protocol, OPacket* p );
81 QObject* childIfToParse( OPacket* p, const QString& protocol ); 83 QObject* childIfToParse( OPacket* p, const QString& protocol );
82 bool checkDumpPacket( OPacket* p ); 84 bool checkDumpPacket( OPacket* p );
83 85
84 private: 86 private:
85 #ifdef QWS 87 #ifdef QWS
86 OSystem _system; // Opie Operating System identifier 88 OSystem _system; // Opie Operating System identifier
87 #endif 89 #endif
88 90
89 OWirelessNetworkInterface* iface; 91 OWirelessNetworkInterface* iface;
90 OPacketCapturer* pcap; 92 OPacketCapturer* pcap;
91 WellenreiterConfigWindow* configwindow; 93 WellenreiterConfigWindow* configwindow;
92 GPS* gps; 94 GPS* gps;
93 95
94 //void readConfig(); 96 //void readConfig();
95 //void writeConfig(); 97 //void writeConfig();
96}; 98};
97 99
98 100
99 101
100#endif 102#endif