summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp74
1 files changed, 33 insertions, 41 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index fff7c35..fad6efd 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -2,80 +2,72 @@
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// Local
15
16#include "gps.h" 14#include "gps.h"
17#include "wellenreiter.h" 15#include "wellenreiter.h"
18#include "scanlist.h" 16#include "scanlist.h"
19#include "logwindow.h" 17#include "logwindow.h"
20#include "packetview.h" 18#include "packetview.h"
21#include "configwindow.h" 19#include "configwindow.h"
22#include "statwindow.h" 20#include "statwindow.h"
23#include "graphwindow.h" 21#include "graphwindow.h"
24#include "protolistview.h" 22#include "protolistview.h"
25 23
26// Opie 24/* OPIE */
27
28#ifdef QWS 25#ifdef QWS
29#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27#include <opie2/odebug.h>
30#include <opie2/odevice.h> 28#include <opie2/odevice.h>
31#else 29#else
32#include <qapplication.h> 30#include <qapplication.h>
33#endif 31#endif
34#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
35#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
36#include <opie2/opcap.h> 34#include <opie2/opcap.h>
37#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
38using namespace Opie; 36using namespace Opie::Core;
39 37using namespace Opie::Net;
40// Qt 38using namespace Opie::Ui;
41 39
40/* QT */
42#include <qcheckbox.h> 41#include <qcheckbox.h>
43#include <qcombobox.h> 42#include <qcombobox.h>
44#include <qdatetime.h> 43#include <qdatetime.h>
45#include <qpushbutton.h> 44#include <qpushbutton.h>
46#include <qlineedit.h> 45#include <qlineedit.h>
47#include <qmessagebox.h> 46#include <qmessagebox.h>
48#include <qobjectlist.h> 47#include <qobjectlist.h>
49#include <qregexp.h> 48#include <qregexp.h>
50#include <qspinbox.h> 49#include <qspinbox.h>
51#include <qtimer.h> 50#include <qtimer.h>
52#include <qtoolbutton.h> 51#include <qtoolbutton.h>
53#include <qmainwindow.h> 52#include <qmainwindow.h>
54 53
55// Standard 54/* STD */
56
57#include <assert.h> 55#include <assert.h>
58#include <errno.h> 56#include <errno.h>
59#include <unistd.h> 57#include <unistd.h>
60#include <string.h> 58#include <string.h>
61#include <sys/types.h> 59#include <sys/types.h>
62#include <stdlib.h> 60#include <stdlib.h>
63 61
64using namespace Opie::Core;
65using namespace Opie::Net;
66using namespace Opie::Net;
67using namespace Opie::Core;
68using namespace Opie::Net;
69using namespace Opie::Core;
70Wellenreiter::Wellenreiter( QWidget* parent ) 62Wellenreiter::Wellenreiter( QWidget* parent )
71 : WellenreiterBase( parent, 0, 0 ), 63 : WellenreiterBase( parent, 0, 0 ),
72 sniffing( false ), iface( 0 ), configwindow( 0 ) 64 sniffing( false ), iface( 0 ), configwindow( 0 )
73{ 65{
74 66
75 logwindow->log( "(i) Wellenreiter has been started." ); 67 logwindow->log( "(i) Wellenreiter has been started." );
76 68
77 // 69 //
78 // detect operating system 70 // detect operating system
79 // 71 //
80 72
81 #ifdef QWS 73 #ifdef QWS
@@ -97,25 +89,25 @@ Wellenreiter::Wellenreiter( QWidget* parent )
97 89
98} 90}
99 91
100 92
101Wellenreiter::~Wellenreiter() 93Wellenreiter::~Wellenreiter()
102{ 94{
103 delete pcap; 95 delete pcap;
104} 96}
105 97
106 98
107void Wellenreiter::initialTimer() 99void Wellenreiter::initialTimer()
108{ 100{
109 qDebug( "Wellenreiter::preloading manufacturer database..." ); 101 odebug << "Wellenreiter::preloading manufacturer database..." << oendl;
110 OManufacturerDB::instance(); 102 OManufacturerDB::instance();
111} 103}
112 104
113 105
114void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
115{ 107{
116 configwindow = cw; 108 configwindow = cw;
117} 109}
118 110
119 111
120void Wellenreiter::channelHopped(int c) 112void Wellenreiter::channelHopped(int c)
121{ 113{
@@ -140,104 +132,104 @@ void Wellenreiter::channelHopped(int c)
140void Wellenreiter::handleNotification( OPacket* p ) 132void Wellenreiter::handleNotification( OPacket* p )
141{ 133{
142 QObjectList* l = p->queryList(); 134 QObjectList* l = p->queryList();
143 QObjectListIt it( *l ); 135 QObjectListIt it( *l );
144 QObject* o; 136 QObject* o;
145 137
146 while ( (o = it.current()) != 0 ) 138 while ( (o = it.current()) != 0 )
147 { 139 {
148 QString name = it.current()->name(); 140 QString name = it.current()->name();
149 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 141 if ( configwindow->parsePackets->isProtocolChecked( name ) )
150 { 142 {
151 QString action = configwindow->parsePackets->protocolAction( name ); 143 QString action = configwindow->parsePackets->protocolAction( name );
152 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 144 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl;
153 doAction( action, name, p ); 145 doAction( action, name, p );
154 } 146 }
155 else 147 else
156 { 148 {
157 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 149 odebug << "protocol '" << (const char*) name << "' not checked in parsePackets." << oendl;
158 } 150 }
159 ++it; 151 ++it;
160 } 152 }
161} 153}
162 154
163 155
164void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 156void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
165{ 157{
166 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 158 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
167 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 159 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
168 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 160 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
169 else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); 161 else owarn << "Wellenreiter::handleManagementFrame(): '" << (const char*) manage->managementType() << "' - please handle me!" << oendl;
170} 162}
171 163
172 164
173void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) 165void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
174{ 166{
175 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
176 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 168 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
177 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
178 int channel = ds ? ds->channel() : -1; 170 int channel = ds ? ds->channel() : -1;
179 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 171 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
180 172
181 GpsLocation loc( -111, -111 ); 173 GpsLocation loc( -111, -111 );
182 if ( configwindow->enableGPS->isChecked() ) 174 if ( configwindow->enableGPS->isChecked() )
183 { 175 {
184 // TODO: add check if GPS is working!? 176 // TODO: add check if GPS is working!?
185 qDebug( "Wellenreiter::gathering GPS data..." ); 177 odebug << "Wellenreiter::gathering GPS data..." << oendl;
186 loc = gps->position(); 178 loc = gps->position();
187 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 179 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
188 } 180 }
189 181
190 if ( essid.length() ) 182 if ( essid.length() )
191 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 183 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
192 qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); 184 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
193} 185}
194 186
195 187
196void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) 188void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
197{ 189{
198} 190}
199 191
200 192
201void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 193void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
202{ 194{
203 QString type; 195 QString type;
204 if ( beacon->canIBSS() ) 196 if ( beacon->canIBSS() )
205 { 197 {
206 type = "adhoc"; 198 type = "adhoc";
207 } 199 }
208 else if ( beacon->canESS() ) 200 else if ( beacon->canESS() )
209 { 201 {
210 type = "managed"; 202 type = "managed";
211 } 203 }
212 else 204 else
213 { 205 {
214 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 206 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
215 return; 207 return;
216 } 208 }
217 209
218 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 210 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
219 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 211 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
220 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 212 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
221 int channel = ds ? ds->channel() : -1; 213 int channel = ds ? ds->channel() : -1;
222 214
223 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 215 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
224 216
225 GpsLocation loc( -111, -111 ); 217 GpsLocation loc( -111, -111 );
226 if ( configwindow->enableGPS->isChecked() ) 218 if ( configwindow->enableGPS->isChecked() )
227 { 219 {
228 // TODO: add check if GPS is working!? 220 // TODO: add check if GPS is working!?
229 qDebug( "Wellenreiter::gathering GPS data..." ); 221 odebug << "Wellenreiter::gathering GPS data..." << oendl;
230 loc = gps->position(); 222 loc = gps->position();
231 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 223 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
232 } 224 }
233 225
234 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 226 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
235 227
236 // update graph window 228 // update graph window
237 if ( ds ) 229 if ( ds )
238 { 230 {
239 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 231 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
240 if ( prism ) 232 if ( prism )
241 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 233 graphwindow->traffic( ds->channel(), prism->signalStrength() );
242 else 234 else
243 graphwindow->traffic( ds->channel(), 95 ); 235 graphwindow->traffic( ds->channel(), 95 );
@@ -246,25 +238,25 @@ void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPa
246 238
247 239
248void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 240void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
249{ 241{
250 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 242 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
251 243
252 if ( control->controlType() == "Acknowledge" ) 244 if ( control->controlType() == "Acknowledge" )
253 { 245 {
254 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 246 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
255 } 247 }
256 else 248 else
257 { 249 {
258 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); 250 odebug << "Wellenreiter::handleControlFrame - please handle " << (const char*) control->controlType() << " in a future version! :D" << oendl;
259 } 251 }
260} 252}
261 253
262 254
263void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 255void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
264{ 256{
265 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 257 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
266 if ( wlan->fromDS() && !wlan->toDS() ) 258 if ( wlan->fromDS() && !wlan->toDS() )
267 { 259 {
268 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 260 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
269 from = wlan->macAddress3(); 261 from = wlan->macAddress3();
270 to = wlan->macAddress2(); 262 to = wlan->macAddress2();
@@ -295,55 +287,55 @@ void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAd
295 from = data->sourceAddress(); 287 from = data->sourceAddress();
296 to = data->destinationAddress(); 288 to = data->destinationAddress();
297 289
298 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 290 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
299} 291}
300 292
301 293
302void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 294void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
303{ 295{
304 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 296 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
305 if ( arp ) 297 if ( arp )
306 { 298 {
307 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 299 odebug << "Received ARP traffic (type '" << (const char*) arp->type() << "'): " << oendl;
308 if ( arp->type() == "REQUEST" ) 300 if ( arp->type() == "REQUEST" )
309 { 301 {
310 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 302 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
311 } 303 }
312 else if ( arp->type() == "REPLY" ) 304 else if ( arp->type() == "REPLY" )
313 { 305 {
314 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 306 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
315 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 307 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
316 } 308 }
317 } 309 }
318} 310}
319 311
320 312
321void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 313void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
322{ 314{
323 //TODO: Implement more IP based protocols 315 //TODO: Implement more IP based protocols
324 316
325 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 317 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
326 if ( dhcp ) 318 if ( dhcp )
327 { 319 {
328 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 320 odebug << "Received DHCP '" << (const char*) dhcp->type() << "' packet" << oendl;
329 if ( dhcp->type() == "OFFER" ) 321 if ( dhcp->type() == "OFFER" )
330 { 322 {
331 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 323 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << (const char*) dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
332 netView()->identify( source, dhcp->serverAddress().toString() ); 324 netView()->identify( source, dhcp->serverAddress().toString() );
333 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 325 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
334 } 326 }
335 else if ( dhcp->type() == "ACK" ) 327 else if ( dhcp->type() == "ACK" )
336 { 328 {
337 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 329 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << (const char*) dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
338 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 330 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
339 } 331 }
340 } 332 }
341} 333}
342 334
343 335
344QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 336QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
345{ 337{
346 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 338 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
347 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 339 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
348 return 0; 340 return 0;
349 341
@@ -359,34 +351,34 @@ bool Wellenreiter::checkDumpPacket( OPacket* p )
359 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 351 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
360 352
361 QObjectList* l = p->queryList(); 353 QObjectList* l = p->queryList();
362 QObjectListIt it( *l ); 354 QObjectListIt it( *l );
363 QObject* o; 355 QObject* o;
364 356
365 while ( (o = it.current()) != 0 ) 357 while ( (o = it.current()) != 0 )
366 { 358 {
367 QString name = it.current()->name(); 359 QString name = it.current()->name();
368 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 360 if ( configwindow->capturePackets->isProtocolChecked( name ) )
369 { 361 {
370 QString action = configwindow->capturePackets->protocolAction( name ); 362 QString action = configwindow->capturePackets->protocolAction( name );
371 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 363 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl;
372 if ( action == "Discard" ) 364 if ( action == "Discard" )
373 { 365 {
374 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 366 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
375 return false; 367 return false;
376 } 368 }
377 } 369 }
378 else 370 else
379 { 371 {
380 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 372 odebug << "protocol '" << (const char*) name << "' not checked in capturePackets." << oendl;
381 } 373 }
382 ++it; 374 ++it;
383 } 375 }
384 return true; 376 return true;
385} 377}
386 378
387 379
388void Wellenreiter::receivePacket( OPacket* p ) 380void Wellenreiter::receivePacket( OPacket* p )
389{ 381{
390 hexWindow()->add( p ); 382 hexWindow()->add( p );
391 383
392 if ( checkDumpPacket( p ) ) 384 if ( checkDumpPacket( p ) )
@@ -542,70 +534,70 @@ void Wellenreiter::startClicked()
542 } 534 }
543 } 535 }
544 // set monitor mode 536 // set monitor mode
545 bool usePrism = configwindow->usePrismHeader(); 537 bool usePrism = configwindow->usePrismHeader();
546 538
547 switch ( cardtype ) 539 switch ( cardtype )
548 { 540 {
549 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 541 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
550 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 542 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
551 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 543 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
552 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 544 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
553 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 545 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
554 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 546 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << (const char*) interface << "'" << oendl; break;
555 default: assert( 0 ); // shouldn't reach this 547 default: assert( 0 ); // shouldn't reach this
556 } 548 }
557 549
558 // switch device into monitor mode 550 // switch device into monitor mode
559 if ( cardtype < DEVTYPE_FILE ) 551 if ( cardtype < DEVTYPE_FILE )
560 { 552 {
561 if ( cardtype != DEVTYPE_MANUAL ) 553 if ( cardtype != DEVTYPE_MANUAL )
562 iface->setMode( "monitor" ); 554 iface->setMode( "monitor" );
563 if ( iface->mode() != "monitor" ) 555 if ( iface->mode() != "monitor" )
564 { 556 {
565 if ( QMessageBox::warning( this, "Wellenreiter II", 557 if ( QMessageBox::warning( this, "Wellenreiter II",
566 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 558 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
567 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 559 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
568 return; 560 return;
569 } 561 }
570 } 562 }
571 563
572 // open GPS device 564 // open GPS device
573 if ( configwindow->enableGPS->isChecked() ) 565 if ( configwindow->enableGPS->isChecked() )
574 { 566 {
575 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 567 odebug << "Wellenreiter:GPS enabled @ " << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl;
576 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 568 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
577 } 569 }
578 570
579 // open pcap and start sniffing 571 // open pcap and start sniffing
580 572
581 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 573 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
582 { 574 {
583 dumpname = configwindow->captureFileName->text(); 575 dumpname = configwindow->captureFileName->text();
584 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 576 if ( dumpname.isEmpty() ) dumpname = "captureFile";
585 dumpname.append( '-' ); 577 dumpname.append( '-' );
586 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 578 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
587 dumpname.append( ".wellenreiter" ); 579 dumpname.append( ".wellenreiter" );
588 } 580 }
589 else // write it anyway ;) 581 else // write it anyway ;)
590 { 582 {
591 dumpname = "/var/log/dump.wellenreiter"; 583 dumpname = "/var/log/dump.wellenreiter";
592 } 584 }
593 585
594 if ( cardtype != DEVTYPE_FILE ) 586 if ( cardtype != DEVTYPE_FILE )
595 pcap->open( interface ); 587 pcap->open( interface );
596 else 588 else
597 pcap->open( QFile( interface ) ); 589 pcap->open( QFile( interface ) );
598 590
599 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); 591 odebug << "Wellenreiter:: dumping to " << (const char*) dumpname << "" << oendl;
600 pcap->openDumpFile( dumpname ); 592 pcap->openDumpFile( dumpname );
601 593
602 if ( !pcap->isOpen() ) 594 if ( !pcap->isOpen() )
603 { 595 {
604 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 596 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
605 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 597 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
606 return; 598 return;
607 } 599 }
608 600
609 // set capturer to non-blocking mode 601 // set capturer to non-blocking mode
610 pcap->setBlocking( false ); 602 pcap->setBlocking( false );
611 603
@@ -643,25 +635,25 @@ void Wellenreiter::startClicked()
643 emit( startedSniffing() ); 635 emit( startedSniffing() );
644 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 636 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
645 else 637 else
646 { 638 {
647 assert( parent() ); 639 assert( parent() );
648 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 640 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
649 } 641 }
650} 642}
651 643
652 644
653void Wellenreiter::timerEvent( QTimerEvent* ) 645void Wellenreiter::timerEvent( QTimerEvent* )
654{ 646{
655 qDebug( "Wellenreiter::timerEvent()" ); 647 odebug << "Wellenreiter::timerEvent()" << oendl;
656 OPacket* p = pcap->next(); 648 OPacket* p = pcap->next();
657 if ( !p ) // no more packets available 649 if ( !p ) // no more packets available
658 { 650 {
659 stopClicked(); 651 stopClicked();
660 } 652 }
661 else 653 else
662 { 654 {
663 receivePacket( p ); 655 receivePacket( p );
664 // We no longer delete packets here. Ownership of the packets is 656 // We no longer delete packets here. Ownership of the packets is
665 // transferred to the PacketView. 657 // transferred to the PacketView.
666 //delete p; 658 //delete p;
667 } 659 }
@@ -706,28 +698,28 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch
706 return; 698 return;
707 } 699 }
708 700
709 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 701 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
710 (const char*) iface->name(), 702 (const char*) iface->name(),
711 (const char*) type, 703 (const char*) type,
712 (const char*) essid, 704 (const char*) essid,
713 channel, 705 channel,
714 (const char*) macaddr ); 706 (const char*) macaddr );
715 707
716 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 708 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
717 int count = 3; 709 int count = 3;
718 qDebug("sending %d messages",count); 710 odebug << "sending " << count << " messages" << oendl;
719 msg << QString("count") << QString::number(count); 711 msg << QString("count") << QString::number(count);
720 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 712 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
721 msg << QString(iface->name()) << QString("Mode") << type; 713 msg << QString(iface->name()) << QString("Mode") << type;
722 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 714 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
723 msg << QString(iface->name()) << QString("ESSID") << essid; 715 msg << QString(iface->name()) << QString("ESSID") << essid;
724 qDebug("msg >%s< channel >%d<", iface->name(),channel); 716 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
725 msg << QString(iface->name()) << QString("Channel") << channel; 717 msg << QString(iface->name()) << QString("Channel") << channel;
726// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 718// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
727// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 719// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
728 #else 720 #else
729 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 721 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
730 #endif 722 #endif
731 723
732} 724}
733 725