summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-10-29 10:51:08 (UTC)
committer mickeyl <mickeyl>2004-10-29 10:51:08 (UTC)
commit1cde6419bcf60ec1ba23750106b2ec01474416fb (patch) (unidiff)
tree80eab25b6ef88621aab36c4bbb1789e4b9d48502
parent35262b3fbc09b32d4c5b20004f755e0c5651dc1b (diff)
downloadopie-1cde6419bcf60ec1ba23750106b2ec01474416fb.zip
opie-1cde6419bcf60ec1ba23750106b2ec01474416fb.tar.gz
opie-1cde6419bcf60ec1ba23750106b2ec01474416fb.tar.bz2
improve english
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index df8e9c3..9fe463a 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,778 +1,778 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12***********************************************************************/ 12***********************************************************************/
13 13
14#include "gps.h" 14#include "gps.h"
15#include "wellenreiter.h" 15#include "wellenreiter.h"
16#include "scanlist.h" 16#include "scanlist.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "packetview.h" 18#include "packetview.h"
19#include "configwindow.h" 19#include "configwindow.h"
20#include "statwindow.h" 20#include "statwindow.h"
21#include "graphwindow.h" 21#include "graphwindow.h"
22#include "protolistview.h" 22#include "protolistview.h"
23 23
24/* OPIE */ 24/* OPIE */
25#ifdef QWS 25#ifdef QWS
26#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/odevice.h> 28#include <opie2/odevice.h>
29#else 29#else
30#include <qapplication.h> 30#include <qapplication.h>
31#endif 31#endif
32#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/opcap.h> 34#include <opie2/opcap.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36 36
37/* QT */ 37/* QT */
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qobjectlist.h> 44#include <qobjectlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qspinbox.h> 46#include <qspinbox.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qtoolbutton.h> 48#include <qtoolbutton.h>
49#include <qmainwindow.h> 49#include <qmainwindow.h>
50 50
51/* STD */ 51/* STD */
52#include <assert.h> 52#include <assert.h>
53#include <errno.h> 53#include <errno.h>
54#include <unistd.h> 54#include <unistd.h>
55#include <string.h> 55#include <string.h>
56#include <sys/types.h> 56#include <sys/types.h>
57#include <stdlib.h> 57#include <stdlib.h>
58#include <signal.h> 58#include <signal.h>
59 59
60 60
61using namespace Opie::Core; 61using namespace Opie::Core;
62using namespace Opie::Net; 62using namespace Opie::Net;
63using namespace Opie::Ui; 63using namespace Opie::Ui;
64 64
65Wellenreiter* Wellenreiter::instance = 0; 65Wellenreiter* Wellenreiter::instance = 0;
66 66
67Wellenreiter::Wellenreiter( QWidget* parent ) 67Wellenreiter::Wellenreiter( QWidget* parent )
68 : WellenreiterBase( parent, 0, 0 ), 68 : WellenreiterBase( parent, 0, 0 ),
69 sniffing( false ), iface( 0 ), configwindow( 0 ) 69 sniffing( false ), iface( 0 ), configwindow( 0 )
70{ 70{
71 71
72 logwindow->log( "(i) Wellenreiter has been started." ); 72 logwindow->log( "(i) Wellenreiter has been started." );
73 73
74 // 74 //
75 // detect operating system 75 // detect operating system
76 // 76 //
77 77
78 #ifdef QWS 78 #ifdef QWS
79 QString sys = QString( "(i) Running on '%1'.").arg( ODevice::inst()->systemString() ); 79 QString sys = QString( "(i) Running on '%1'.").arg( ODevice::inst()->systemString() );
80 _system = ODevice::inst()->system(); 80 _system = ODevice::inst()->system();
81 logwindow->log( sys ); 81 logwindow->log( sys );
82 #endif 82 #endif
83 83
84 netview->setColumnWidthMode( 1, QListView::Manual ); 84 netview->setColumnWidthMode( 1, QListView::Manual );
85 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 85 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
86 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 86 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
87 pcap = new OPacketCapturer(); 87 pcap = new OPacketCapturer();
88 pcap->setAutoDelete( false ); 88 pcap->setAutoDelete( false );
89 89
90 gps = new GPS( this ); 90 gps = new GPS( this );
91 91
92 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 92 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
93 93
94 registerSignalHandler(); 94 registerSignalHandler();
95} 95}
96 96
97 97
98Wellenreiter::~Wellenreiter() 98Wellenreiter::~Wellenreiter()
99{ 99{
100 delete pcap; 100 delete pcap;
101 //unregisterSignalHandler(); 101 //unregisterSignalHandler();
102} 102}
103 103
104 104
105void Wellenreiter::initialTimer() 105void Wellenreiter::initialTimer()
106{ 106{
107 odebug << "preloading manufacturer database..." << oendl; 107 odebug << "preloading manufacturer database..." << oendl;
108 OManufacturerDB::instance(); 108 OManufacturerDB::instance();
109} 109}
110 110
111 111
112void Wellenreiter::signalHandler( int sig ) 112void Wellenreiter::signalHandler( int sig )
113{ 113{
114 Q_UNUSED( sig ) 114 Q_UNUSED( sig )
115 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; 115 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl;
116 if ( Wellenreiter::instance->sniffing ) 116 if ( Wellenreiter::instance->sniffing )
117 { 117 {
118 Wellenreiter::instance->pcap->closeDumpFile(); 118 Wellenreiter::instance->pcap->closeDumpFile();
119 Wellenreiter::instance->pcap->close(); 119 Wellenreiter::instance->pcap->close();
120 Wellenreiter::instance->stopClicked(); 120 Wellenreiter::instance->stopClicked();
121 } 121 }
122 oerr << "Phew. Seemed to work." << oendl; 122 oerr << "Phew. Seemed to work." << oendl;
123 ::exit( -1 ); 123 ::exit( -1 );
124} 124}
125 125
126 126
127void Wellenreiter::registerSignalHandler() 127void Wellenreiter::registerSignalHandler()
128{ 128{
129 Wellenreiter::instance = this; 129 Wellenreiter::instance = this;
130 struct sigaction action; 130 struct sigaction action;
131 131
132 action.sa_handler = Wellenreiter::signalHandler; 132 action.sa_handler = Wellenreiter::signalHandler;
133 if (sigemptyset(&action.sa_mask)) 133 if (sigemptyset(&action.sa_mask))
134 oerr << "sigemptyset() failure:" << strerror( errno ) << oendl; 134 oerr << "sigemptyset() failure:" << strerror( errno ) << oendl;
135 if (sigaction(SIGSEGV, &action, NULL)) 135 if (sigaction(SIGSEGV, &action, NULL))
136 oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl; 136 oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl;
137 if (sigaction(SIGBUS, &action, NULL)) 137 if (sigaction(SIGBUS, &action, NULL))
138 oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl; 138 oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl;
139 odebug << "signal handlers setup." << oendl; 139 odebug << "signal handlers setup." << oendl;
140} 140}
141 141
142 142
143void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 143void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
144{ 144{
145 configwindow = cw; 145 configwindow = cw;
146} 146}
147 147
148 148
149void Wellenreiter::channelHopped(int c) 149void Wellenreiter::channelHopped(int c)
150{ 150{
151 QString title = "Wellenreiter II -scan- ["; 151 QString title = "Wellenreiter II -scan- [";
152 QString left; 152 QString left;
153 if ( c > 1 ) left.fill( '.', c-1 ); 153 if ( c > 1 ) left.fill( '.', c-1 );
154 title.append( left ); 154 title.append( left );
155 title.append( '|' ); 155 title.append( '|' );
156 if ( c < iface->channels() ) 156 if ( c < iface->channels() )
157 { 157 {
158 QString right; 158 QString right;
159 right.fill( '.', iface->channels()-c ); 159 right.fill( '.', iface->channels()-c );
160 title.append( right ); 160 title.append( right );
161 } 161 }
162 title.append( "]" ); 162 title.append( "]" );
163 //title.append( QString().sprintf( " %02d", c ) ); 163 //title.append( QString().sprintf( " %02d", c ) );
164 assert( parent() ); 164 assert( parent() );
165 ( (QMainWindow*) parent() )->setCaption( title ); 165 ( (QMainWindow*) parent() )->setCaption( title );
166} 166}
167 167
168 168
169void Wellenreiter::handleNotification( OPacket* p ) 169void Wellenreiter::handleNotification( OPacket* p )
170{ 170{
171 QObjectList* l = p->queryList(); 171 QObjectList* l = p->queryList();
172 QObjectListIt it( *l ); 172 QObjectListIt it( *l );
173 QObject* o; 173 QObject* o;
174 174
175 while ( (o = it.current()) != 0 ) 175 while ( (o = it.current()) != 0 )
176 { 176 {
177 QString name = it.current()->name(); 177 QString name = it.current()->name();
178 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 178 if ( configwindow->parsePackets->isProtocolChecked( name ) )
179 { 179 {
180 QString action = configwindow->parsePackets->protocolAction( name ); 180 QString action = configwindow->parsePackets->protocolAction( name );
181 odebug << "parsePacket-action for '" << name << "' seems to be '" << action << "'" << oendl; 181 odebug << "parsePacket-action for '" << name << "' seems to be '" << action << "'" << oendl;
182 doAction( action, name, p ); 182 doAction( action, name, p );
183 } 183 }
184 else 184 else
185 { 185 {
186 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; 186 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl;
187 } 187 }
188 ++it; 188 ++it;
189 } 189 }
190} 190}
191 191
192 192
193void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 193void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
194{ 194{
195 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 195 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
196 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 196 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
197 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 197 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
198 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; 198 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl;
199} 199}
200 200
201 201
202void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* /* request */ ) 202void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* /* request */ )
203{ 203{
204 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 204 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
205 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 205 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
206// OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 206// OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
207// int channel = ds ? ds->channel() : -1; 207// int channel = ds ? ds->channel() : -1;
208 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 208 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
209 209
210 GpsLocation loc( -111, -111 ); 210 GpsLocation loc( -111, -111 );
211 if ( configwindow->enableGPS->isChecked() ) 211 if ( configwindow->enableGPS->isChecked() )
212 { 212 {
213 // TODO: add check if GPS is working!? 213 // TODO: add check if GPS is working!?
214 odebug << "Wellenreiter::gathering GPS data..." << oendl; 214 odebug << "Wellenreiter::gathering GPS data..." << oendl;
215 loc = gps->position(); 215 loc = gps->position();
216 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 216 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
217 } 217 }
218 218
219 if ( essid.length() ) 219 if ( essid.length() )
220 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 220 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
221 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 221 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
222} 222}
223 223
224 224
225void Wellenreiter::handleManagementFrameProbeResponse( OPacket* /* p */, OWaveLanManagementPacket* /* response */ ) 225void Wellenreiter::handleManagementFrameProbeResponse( OPacket* /* p */, OWaveLanManagementPacket* /* response */ )
226{ 226{
227} 227}
228 228
229 229
230void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 230void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
231{ 231{
232 QString type; 232 QString type;
233 if ( beacon->canIBSS() ) 233 if ( beacon->canIBSS() )
234 { 234 {
235 type = "adhoc"; 235 type = "adhoc";
236 } 236 }
237 else if ( beacon->canESS() ) 237 else if ( beacon->canESS() )
238 { 238 {
239 type = "managed"; 239 type = "managed";
240 } 240 }
241 else 241 else
242 { 242 {
243 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 243 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
244 return; 244 return;
245 } 245 }
246 246
247 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 247 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
248 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 248 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
249 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 249 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
250 int channel = ds ? ds->channel() : -1; 250 int channel = ds ? ds->channel() : -1;
251 251
252 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 252 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
253 253
254 GpsLocation loc( -111, -111 ); 254 GpsLocation loc( -111, -111 );
255 if ( configwindow->enableGPS->isChecked() ) 255 if ( configwindow->enableGPS->isChecked() )
256 { 256 {
257 // TODO: add check if GPS is working!? 257 // TODO: add check if GPS is working!?
258 odebug << "Wellenreiter::gathering GPS data..." << oendl; 258 odebug << "Wellenreiter::gathering GPS data..." << oendl;
259 loc = gps->position(); 259 loc = gps->position();
260 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 260 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
261 } 261 }
262 262
263 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 263 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
264 264
265 // update graph window 265 // update graph window
266 if ( ds ) 266 if ( ds )
267 { 267 {
268 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 268 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
269 if ( prism ) 269 if ( prism )
270 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 270 graphwindow->traffic( ds->channel(), prism->signalStrength() );
271 else 271 else
272 graphwindow->traffic( ds->channel(), 95 ); 272 graphwindow->traffic( ds->channel(), 95 );
273 } 273 }
274} 274}
275 275
276 276
277void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 277void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
278{ 278{
279 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 279 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
280 280
281 if ( control->controlType() == "Acknowledge" ) 281 if ( control->controlType() == "Acknowledge" )
282 { 282 {
283 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 283 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
284 } 284 }
285 else 285 else
286 { 286 {
287 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; 287 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl;
288 } 288 }
289} 289}
290 290
291 291
292void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* /* data */ , OMacAddress& from, OMacAddress& to ) 292void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* /* data */ , OMacAddress& from, OMacAddress& to )
293{ 293{
294 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 294 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
295 if ( wlan->fromDS() && !wlan->toDS() ) 295 if ( wlan->fromDS() && !wlan->toDS() )
296 { 296 {
297 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 297 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
298 from = wlan->macAddress3(); 298 from = wlan->macAddress3();
299 to = wlan->macAddress2(); 299 to = wlan->macAddress2();
300 } 300 }
301 else if ( !wlan->fromDS() && wlan->toDS() ) 301 else if ( !wlan->fromDS() && wlan->toDS() )
302 { 302 {
303 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 303 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
304 from = wlan->macAddress2(); 304 from = wlan->macAddress2();
305 to = wlan->macAddress3(); 305 to = wlan->macAddress3();
306 } 306 }
307 else if ( wlan->fromDS() && wlan->toDS() ) 307 else if ( wlan->fromDS() && wlan->toDS() )
308 { 308 {
309 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 309 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
310 from = wlan->macAddress4(); 310 from = wlan->macAddress4();
311 to = wlan->macAddress3(); 311 to = wlan->macAddress3();
312 } 312 }
313 else 313 else
314 { 314 {
315 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 315 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
316 from = wlan->macAddress2(); 316 from = wlan->macAddress2();
317 to = wlan->macAddress1(); 317 to = wlan->macAddress1();
318 } 318 }
319} 319}
320 320
321 321
322void Wellenreiter::handleEthernetData( OPacket* /* p */, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 322void Wellenreiter::handleEthernetData( OPacket* /* p */, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
323{ 323{
324 from = data->sourceAddress(); 324 from = data->sourceAddress();
325 to = data->destinationAddress(); 325 to = data->destinationAddress();
326 326
327 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 327 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
328} 328}
329 329
330 330
331void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& /* source */, OMacAddress& /* dest */ ) 331void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& /* source */, OMacAddress& /* dest */ )
332{ 332{
333 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 333 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
334 if ( arp ) 334 if ( arp )
335 { 335 {
336 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; 336 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl;
337 if ( arp->type() == "REQUEST" ) 337 if ( arp->type() == "REQUEST" )
338 { 338 {
339 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 339 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
340 } 340 }
341 else if ( arp->type() == "REPLY" ) 341 else if ( arp->type() == "REPLY" )
342 { 342 {
343 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 343 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
344 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 344 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
345 } 345 }
346 } 346 }
347} 347}
348 348
349 349
350void Wellenreiter::handleIPData( OPacket* p, OIPPacket* /* ip */, OMacAddress& source, OMacAddress& /* dest */ ) 350void Wellenreiter::handleIPData( OPacket* p, OIPPacket* /* ip */, OMacAddress& source, OMacAddress& /* dest */ )
351{ 351{
352 //TODO: Implement more IP based protocols 352 //TODO: Implement more IP based protocols
353 353
354 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 354 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
355 if ( dhcp ) 355 if ( dhcp )
356 { 356 {
357 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; 357 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl;
358 if ( dhcp->type() == "OFFER" ) 358 if ( dhcp->type() == "OFFER" )
359 { 359 {
360 odebug << "DHCP: '" << source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; 360 odebug << "DHCP: '" << source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
361 netView()->identify( source, dhcp->serverAddress().toString() ); 361 netView()->identify( source, dhcp->serverAddress().toString() );
362 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 362 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
363 } 363 }
364 else if ( dhcp->type() == "ACK" ) 364 else if ( dhcp->type() == "ACK" )
365 { 365 {
366 odebug << "DHCP: '" << dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; 366 odebug << "DHCP: '" << dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
367 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 367 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
368 } 368 }
369 } 369 }
370} 370}
371 371
372 372
373QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 373QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
374{ 374{
375 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 375 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
376 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 376 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
377 return 0; 377 return 0;
378 378
379 return p->child( protocol ); 379 return p->child( protocol );
380} 380}
381 381
382 382
383bool Wellenreiter::checkDumpPacket( OPacket* p ) 383bool Wellenreiter::checkDumpPacket( OPacket* p )
384{ 384{
385 // go through all child packets and see if one is inside the child hierarchy for p 385 // go through all child packets and see if one is inside the child hierarchy for p
386 // if so, do what the user requested (protocolAction), e.g. pass or discard 386 // if so, do what the user requested (protocolAction), e.g. pass or discard
387 if ( !configwindow->writeCaptureFile->isChecked() ) 387 if ( !configwindow->writeCaptureFile->isChecked() )
388 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 388 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
389 389
390 QObjectList* l = p->queryList(); 390 QObjectList* l = p->queryList();
391 QObjectListIt it( *l ); 391 QObjectListIt it( *l );
392 QObject* o; 392 QObject* o;
393 393
394 while ( (o = it.current()) != 0 ) 394 while ( (o = it.current()) != 0 )
395 { 395 {
396 QString name = it.current()->name(); 396 QString name = it.current()->name();
397 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 397 if ( configwindow->capturePackets->isProtocolChecked( name ) )
398 { 398 {
399 QString action = configwindow->capturePackets->protocolAction( name ); 399 QString action = configwindow->capturePackets->protocolAction( name );
400 odebug << "capturePackets-action for '" << name << "' seems to be '" << action << "'" << oendl; 400 odebug << "capturePackets-action for '" << name << "' seems to be '" << action << "'" << oendl;
401 if ( action == "Discard" ) 401 if ( action == "Discard" )
402 { 402 {
403 logwindow->log( QString("(i) dump-discarding of '%1' packet requested." ).arg( name ) ); 403 logwindow->log( QString("(i) dump-discarding of '%1' packet requested." ).arg( name ) );
404 return false; 404 return false;
405 } 405 }
406 } 406 }
407 else 407 else
408 { 408 {
409 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; 409 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl;
410 } 410 }
411 ++it; 411 ++it;
412 } 412 }
413 return true; 413 return true;
414} 414}
415 415
416 416
417void Wellenreiter::receivePacket( OPacket* p ) 417void Wellenreiter::receivePacket( OPacket* p )
418{ 418{
419 hexWindow()->add( p, configwindow->hexViewBuffer() ); 419 hexWindow()->add( p, configwindow->hexViewBuffer() );
420 420
421 if ( checkDumpPacket( p ) ) 421 if ( checkDumpPacket( p ) )
422 { 422 {
423 pcap->dump( p ); 423 pcap->dump( p );
424 } 424 }
425 425
426 // check for a management frame 426 // check for a management frame
427 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 427 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
428 if ( manage ) 428 if ( manage )
429 { 429 {
430 handleManagementFrame( p, manage ); 430 handleManagementFrame( p, manage );
431 return; 431 return;
432 } 432 }
433 433
434 // check for a control frame 434 // check for a control frame
435 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 435 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
436 if ( control ) 436 if ( control )
437 { 437 {
438 handleControlFrame( p, control ); 438 handleControlFrame( p, control );
439 return; 439 return;
440 } 440 }
441 441
442 OMacAddress source; 442 OMacAddress source;
443 OMacAddress dest; 443 OMacAddress dest;
444 444
445 //TODO: WEP check here 445 //TODO: WEP check here
446 446
447 // check for a wireless data frame 447 // check for a wireless data frame
448 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 448 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
449 if ( wlan ) 449 if ( wlan )
450 { 450 {
451 handleWlanData( p, wlan, source, dest ); 451 handleWlanData( p, wlan, source, dest );
452 } 452 }
453 453
454 // check for a wired data frame 454 // check for a wired data frame
455 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 455 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
456 if ( eth ) 456 if ( eth )
457 { 457 {
458 handleEthernetData( p, eth, source, dest ); 458 handleEthernetData( p, eth, source, dest );
459 } 459 }
460 460
461 // check for an arp frame since arp frames come in two flavours: 461 // check for an arp frame since arp frames come in two flavours:
462 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 462 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
463 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 463 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
464 if ( arp ) 464 if ( arp )
465 { 465 {
466 handleARPData( p, arp, source, dest ); 466 handleARPData( p, arp, source, dest );
467 } 467 }
468 468
469 // check for a ip frame 469 // check for a ip frame
470 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 470 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
471 if ( ip ) 471 if ( ip )
472 { 472 {
473 handleIPData( p, ip, source, dest ); 473 handleIPData( p, ip, source, dest );
474 } 474 }
475 475
476 //handleNotification( p ); 476 //handleNotification( p );
477 477
478} 478}
479 479
480 480
481void Wellenreiter::stopClicked() 481void Wellenreiter::stopClicked()
482{ 482{
483 if ( iface ) 483 if ( iface )
484 { 484 {
485 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 485 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
486 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 486 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
487 iface->setChannelHopping(); // stop hopping channels 487 iface->setChannelHopping(); // stop hopping channels
488 } 488 }
489 else 489 else
490 killTimers(); 490 killTimers();
491 491
492 pcap->close(); 492 pcap->close();
493 sniffing = false; 493 sniffing = false;
494 494
495 if ( iface ) 495 if ( iface )
496 { 496 {
497 // switch off monitor mode 497 // switch off monitor mode
498 iface->setMode( "managed" ); 498 iface->setMode( "managed" );
499 // switch off promisc flag 499 // switch off promisc flag
500 iface->setPromiscuousMode( false ); 500 iface->setPromiscuousMode( false );
501 501
502 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 502 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
503 } 503 }
504 504
505 logwindow->log( "(i) Stopped Scanning." ); 505 logwindow->log( "(i) Stopped Scanning." );
506 assert( parent() ); 506 assert( parent() );
507 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 507 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
508 508
509 // message the user 509 // message the user
510 QMessageBox::information( this, "Wellenreiter II", 510 QMessageBox::information( this, "Wellenreiter II",
511 tr( "Your wireless card\nshould now be usable again." ) ); 511 tr( "Your wireless card\nshould now be usable again." ) );
512 512
513 sniffing = false; 513 sniffing = false;
514 emit( stoppedSniffing() ); 514 emit( stoppedSniffing() );
515 515
516 #ifdef QWS 516 #ifdef QWS
517 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 517 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
518 { 518 {
519 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 519 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
520 } 520 }
521 #else 521 #else
522 #warning FIXME: setScreenSaverMode is not operational on the X11 build 522 #warning FIXME: setScreenSaverMode is not operational on the X11 build
523 #endif 523 #endif
524 524
525 updateStatistics(); 525 updateStatistics();
526} 526}
527 527
528 528
529void Wellenreiter::startClicked() 529void Wellenreiter::startClicked()
530{ 530{
531 // get configuration from config window 531 // get configuration from config window
532 532
533 const QString& interface = configwindow->interfaceName->currentText(); 533 const QString& interface = configwindow->interfaceName->currentText();
534 const int cardtype = configwindow->driverType(); 534 const int cardtype = configwindow->driverType();
535// const int interval = configwindow->hoppingInterval(); 535// const int interval = configwindow->hoppingInterval();
536 536
537 if ( ( interface == "" ) || ( cardtype == 0 ) ) 537 if ( ( interface == "" ) || ( cardtype == 0 ) )
538 { 538 {
539 QMessageBox::information( this, "Wellenreiter II", 539 QMessageBox::information( this, "Wellenreiter II",
540 tr( "No device configured.\nPlease reconfigure!" ) ); 540 tr( "No device configured.\nPlease reconfigure!" ) );
541 return; 541 return;
542 } 542 }
543 543
544 // configure device 544 // configure device
545 ONetwork* net = ONetwork::instance(); 545 ONetwork* net = ONetwork::instance();
546 546
547 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 547 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
548 548
549 if ( cardtype != DEVTYPE_FILE ) 549 if ( cardtype != DEVTYPE_FILE )
550 { 550 {
551 551
552 if ( !net->isPresent( interface ) ) 552 if ( !net->isPresent( interface ) )
553 { 553 {
554 QMessageBox::information( this, "Wellenreiter II", 554 QMessageBox::information( this, "Wellenreiter II",
555 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); 555 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
556 return; 556 return;
557 } 557 }
558 558
559 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 559 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
560 assert( iface ); 560 assert( iface );
561 561
562 // bring device UP 562 // bring device UP
563 iface->setUp( true ); 563 iface->setUp( true );
564 if ( !iface->isUp() ) 564 if ( !iface->isUp() )
565 { 565 {
566 QMessageBox::warning( this, "Wellenreiter II", 566 QMessageBox::warning( this, "Wellenreiter II",
567 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 567 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
568 return; 568 return;
569 } 569 }
570 570
571 // check if wireless extension version matches 571 // check if wireless extension version matches
572 if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() ) 572 if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() )
573 { 573 {
574 QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>are not matching!<p>" 574 QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>do not match!<p>"
575 " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" ) 575 " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" )
576 .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) ) 576 .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) )
577 .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) ); 577 .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) );
578 return; 578 return;
579 } 579 }
580 } 580 }
581 // set monitor mode 581 // set monitor mode
582 bool usePrism = configwindow->usePrismHeader(); 582 bool usePrism = configwindow->usePrismHeader();
583 583
584 switch ( cardtype ) 584 switch ( cardtype )
585 { 585 {
586 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 586 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
587 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 587 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
588 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 588 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
589 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 589 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
590 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 590 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
591 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break; 591 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break;
592 default: assert( 0 ); // shouldn't reach this 592 default: assert( 0 ); // shouldn't reach this
593 } 593 }
594 594
595 // switch device into monitor mode 595 // switch device into monitor mode
596 if ( cardtype < DEVTYPE_FILE ) 596 if ( cardtype < DEVTYPE_FILE )
597 { 597 {
598 if ( cardtype != DEVTYPE_MANUAL ) 598 if ( cardtype != DEVTYPE_MANUAL )
599 iface->setMode( "monitor" ); 599 iface->setMode( "monitor" );
600 if ( iface->mode() != "monitor" ) 600 if ( iface->mode() != "monitor" )
601 { 601 {
602 if ( QMessageBox::warning( this, "Wellenreiter II", 602 if ( QMessageBox::warning( this, "Wellenreiter II",
603 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 603 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
604 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 604 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
605 return; 605 return;
606 } 606 }
607 } 607 }
608 608
609 // open GPS device 609 // open GPS device
610 if ( configwindow->enableGPS->isChecked() ) 610 if ( configwindow->enableGPS->isChecked() )
611 { 611 {
612 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; 612 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl;
613 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 613 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
614 } 614 }
615 615
616 // open pcap and start sniffing 616 // open pcap and start sniffing
617 617
618 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 618 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
619 { 619 {
620 dumpname = configwindow->captureFileName->text(); 620 dumpname = configwindow->captureFileName->text();
621 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 621 if ( dumpname.isEmpty() ) dumpname = "captureFile";
622 dumpname.append( '-' ); 622 dumpname.append( '-' );
623 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 623 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
624 dumpname.append( ".wellenreiter" ); 624 dumpname.append( ".wellenreiter" );
625 } 625 }
626 626
627 if ( cardtype != DEVTYPE_FILE ) 627 if ( cardtype != DEVTYPE_FILE )
628 pcap->open( interface ); 628 pcap->open( interface );
629 else 629 else
630 pcap->openCaptureFile( interface ); 630 pcap->openCaptureFile( interface );
631 631
632 if ( configwindow->writeCaptureFile->isChecked() ) 632 if ( configwindow->writeCaptureFile->isChecked() )
633 { 633 {
634 odebug << "Wellenreiter:: dumping to " << dumpname << oendl; 634 odebug << "Wellenreiter:: dumping to " << dumpname << oendl;
635 pcap->openDumpFile( dumpname ); 635 pcap->openDumpFile( dumpname );
636 } 636 }
637 637
638 if ( !pcap->isOpen() ) 638 if ( !pcap->isOpen() )
639 { 639 {
640 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 640 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
641 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 641 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
642 return; 642 return;
643 } 643 }
644 644
645 // set capturer to non-blocking mode 645 // set capturer to non-blocking mode
646 pcap->setBlocking( false ); 646 pcap->setBlocking( false );
647 647
648 // start channel hopper 648 // start channel hopper
649 if ( cardtype != DEVTYPE_FILE ) 649 if ( cardtype != DEVTYPE_FILE )
650 { 650 {
651 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 651 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
652 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 652 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
653 } 653 }
654 654
655 if ( cardtype != DEVTYPE_FILE ) 655 if ( cardtype != DEVTYPE_FILE )
656 { 656 {
657 // connect socket notifier and start channel hopper 657 // connect socket notifier and start channel hopper
658 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 658 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
659 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 659 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
660 } 660 }
661 else 661 else
662 { 662 {
663 // start timer for reading packets 663 // start timer for reading packets
664 startTimer( 100 ); 664 startTimer( 100 );
665 } 665 }
666 666
667 logwindow->log( "(i) Started Scanning." ); 667 logwindow->log( "(i) Started Scanning." );
668 sniffing = true; 668 sniffing = true;
669 669
670 #ifdef QWS 670 #ifdef QWS
671 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 671 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
672 { 672 {
673 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 673 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
674 } 674 }
675 #else 675 #else
676 #warning FIXME: setScreenSaverMode is not operational on the X11 build 676 #warning FIXME: setScreenSaverMode is not operational on the X11 build
677 #endif 677 #endif
678 678
679 emit( startedSniffing() ); 679 emit( startedSniffing() );
680 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 680 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
681 else 681 else
682 { 682 {
683 assert( parent() ); 683 assert( parent() );
684 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 684 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
685 } 685 }
686} 686}
687 687
688 688
689void Wellenreiter::timerEvent( QTimerEvent* ) 689void Wellenreiter::timerEvent( QTimerEvent* )
690{ 690{
691 odebug << "Wellenreiter::timerEvent()" << oendl; 691 odebug << "Wellenreiter::timerEvent()" << oendl;
692 OPacket* p = pcap->next(); 692 OPacket* p = pcap->next();
693 if ( !p ) // no more packets available 693 if ( !p ) // no more packets available
694 { 694 {
695 stopClicked(); 695 stopClicked();
696 } 696 }
697 else 697 else
698 { 698 {
699 receivePacket( p ); 699 receivePacket( p );
700 // We no longer delete packets here. Ownership of the packets is 700 // We no longer delete packets here. Ownership of the packets is
701 // transferred to the PacketView. 701 // transferred to the PacketView.
702 //delete p; 702 //delete p;
703 } 703 }
704} 704}
705 705
706 706
707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* /* p */ ) 707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* /* p */ )
708{ 708{
709 #ifdef QWS 709 #ifdef QWS
710 if ( action == "TouchSound" ) 710 if ( action == "TouchSound" )
711 ODevice::inst()->playTouchSound(); 711 ODevice::inst()->playTouchSound();
712 else if ( action == "AlarmSound" ) 712 else if ( action == "AlarmSound" )
713 ODevice::inst()->playAlarmSound(); 713 ODevice::inst()->playAlarmSound();
714 else if ( action == "KeySound" ) 714 else if ( action == "KeySound" )
715 ODevice::inst()->playKeySound(); 715 ODevice::inst()->playKeySound();
716 else if ( action == "LedOn" ) 716 else if ( action == "LedOn" )
717 ODevice::inst()->setLedState( Led_Mail, Led_On ); 717 ODevice::inst()->setLedState( Led_Mail, Led_On );
718 else if ( action == "LedOff" ) 718 else if ( action == "LedOff" )
719 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 719 ODevice::inst()->setLedState( Led_Mail, Led_Off );
720 else if ( action == "LogMessage" ) 720 else if ( action == "LogMessage" )
721 logwindow->log( QString(tr("Got packet with protocol '%1'","Protocol Name" ) ).arg( protocol ) ); 721 logwindow->log( QString(tr("Got packet with protocol '%1'","Protocol Name" ) ).arg( protocol ) );
722 else if ( action == "MessageBox" ) 722 else if ( action == "MessageBox" )
723 QMessageBox::information( this, "Notification!", 723 QMessageBox::information( this, "Notification!",
724 QString(tr( "Got packet with protocol '%1'", "Protocol Name" ) ).arg( protocol ) ); 724 QString(tr( "Got packet with protocol '%1'", "Protocol Name" ) ).arg( protocol ) );
725 #else 725 #else
726 #warning Actions do not work with Qt/X11 yet 726 #warning Actions do not work with Qt/X11 yet
727 #endif 727 #endif
728} 728}
729 729
730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
731{ 731{
732 #ifdef QWS 732 #ifdef QWS
733 if ( !iface ) 733 if ( !iface )
734 { 734 {
735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
736 return; 736 return;
737 } 737 }
738 738
739 if ( sniffing ) 739 if ( sniffing )
740 { 740 {
741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
742 return; 742 return;
743 } 743 }
744 744
745 odebug << "joinNetwork() with Interface " << iface->name() 745 odebug << "joinNetwork() with Interface " << iface->name()
746 << ": " << type << ", " << essid 746 << ": " << type << ", " << essid
747 << ", " << channel << ", " << macaddr << oendl; 747 << ", " << channel << ", " << macaddr << oendl;
748 748
749 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 749 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
750 int count = 3; 750 int count = 3;
751 odebug << "sending " << count << " messages" << oendl; 751 odebug << "sending " << count << " messages" << oendl;
752 msg << QString("count") << QString::number(count); 752 msg << QString("count") << QString::number(count);
753 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; 753 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
754 msg << QString(iface->name()) << QString("Mode") << type; 754 msg << QString(iface->name()) << QString("Mode") << type;
755 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; 755 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
756 msg << QString(iface->name()) << QString("ESSID") << essid; 756 msg << QString(iface->name()) << QString("ESSID") << essid;
757 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; 757 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
758 msg << QString(iface->name()) << QString("Channel") << channel; 758 msg << QString(iface->name()) << QString("Channel") << channel;
759// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; 759// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
760// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 760// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
761 #else 761 #else
762 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 762 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
763 #endif 763 #endif
764 764
765} 765}
766 766
767void Wellenreiter::updateStatistics() 767void Wellenreiter::updateStatistics()
768{ 768{
769 // print out statistics 769 // print out statistics
770 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 770 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
771 statwindow->updateCounter( it.key(), it.data() ); 771 statwindow->updateCounter( it.key(), it.data() );
772} 772}
773 773
774void Wellenreiter::slotTabChanged( QWidget* wid ) 774void Wellenreiter::slotTabChanged( QWidget* wid )
775{ 775{
776 if ( wid == statwindow ) 776 if ( wid == statwindow )
777 updateStatistics(); 777 updateStatistics();
778} 778}