summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-09 19:24:37 (UTC)
committer mickeyl <mickeyl>2003-12-09 19:24:37 (UTC)
commit04d6caa37743a1957b9ffa061a58a71a3909ea3d (patch) (unidiff)
tree04a692f57263d0573f2b2c704e4a6e1057aa7d40
parent1642df2b072858b5eec9ad007a23475cc5270bfe (diff)
downloadopie-04d6caa37743a1957b9ffa061a58a71a3909ea3d.zip
opie-04d6caa37743a1957b9ffa061a58a71a3909ea3d.tar.gz
opie-04d6caa37743a1957b9ffa061a58a71a3909ea3d.tar.bz2
preload the manufacturer library during startup (nice trick, btw.)
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,649 +1,661 @@
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 )
228{ 240{
229 from = data->sourceAddress(); 241 from = data->sourceAddress();
230 to = data->destinationAddress(); 242 to = data->destinationAddress();
231 243
232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); 244 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
233} 245}
234 246
235 247
236void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 248void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
237{ 249{
238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 250 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
239 if ( arp ) 251 if ( arp )
240 { 252 {
241 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 253 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
242 if ( arp->type() == "REQUEST" ) 254 if ( arp->type() == "REQUEST" )
243 { 255 {
244 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 256 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
245 } 257 }
246 else if ( arp->type() == "REPLY" ) 258 else if ( arp->type() == "REPLY" )
247 { 259 {
248 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 260 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
249 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 261 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
250 } 262 }
251 } 263 }
252} 264}
253 265
254 266
255void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 267void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
256{ 268{
257 //TODO: Implement more IP based protocols 269 //TODO: Implement more IP based protocols
258 270
259 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 271 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
260 if ( dhcp ) 272 if ( dhcp )
261 { 273 {
262 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 274 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
263 if ( dhcp->type() == "OFFER" ) 275 if ( dhcp->type() == "OFFER" )
264 { 276 {
265 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 277 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
266 netView()->identify( source, dhcp->serverAddress().toString() ); 278 netView()->identify( source, dhcp->serverAddress().toString() );
267 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 279 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
268 } 280 }
269 else if ( dhcp->type() == "ACK" ) 281 else if ( dhcp->type() == "ACK" )
270 { 282 {
271 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 283 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
272 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 284 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
273 } 285 }
274 } 286 }
275} 287}
276 288
277 289
278QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 290QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
279{ 291{
280 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 292 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
281 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 293 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
282 return 0; 294 return 0;
283 295
284 return p->child( protocol ); 296 return p->child( protocol );
285} 297}
286 298
287 299
288bool Wellenreiter::checkDumpPacket( OPacket* p ) 300bool Wellenreiter::checkDumpPacket( OPacket* p )
289{ 301{
290 // go through all child packets and see if one is inside the child hierarchy for p 302 // go through all child packets and see if one is inside the child hierarchy for p
291 // if so, do what the user requested (protocolAction), e.g. pass or discard 303 // if so, do what the user requested (protocolAction), e.g. pass or discard
292 if ( !configwindow->writeCaptureFile->isChecked() ) 304 if ( !configwindow->writeCaptureFile->isChecked() )
293 return false; 305 return false;
294 306
295 QObjectList* l = p->queryList(); 307 QObjectList* l = p->queryList();
296 QObjectListIt it( *l ); 308 QObjectListIt it( *l );
297 QObject* o; 309 QObject* o;
298 310
299 while ( (o = it.current()) != 0 ) 311 while ( (o = it.current()) != 0 )
300 { 312 {
301 QString name = it.current()->name(); 313 QString name = it.current()->name();
302 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 314 if ( configwindow->capturePackets->isProtocolChecked( name ) )
303 { 315 {
304 QString action = configwindow->capturePackets->protocolAction( name ); 316 QString action = configwindow->capturePackets->protocolAction( name );
305 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 317 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
306 if ( action == "Discard" ) 318 if ( action == "Discard" )
307 { 319 {
308 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 320 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
309 return false; 321 return false;
310 } 322 }
311 } 323 }
312 else 324 else
313 { 325 {
314 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 326 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
315 } 327 }
316 ++it; 328 ++it;
317 } 329 }
318 return true; 330 return true;
319} 331}
320 332
321 333
322void Wellenreiter::receivePacket( OPacket* p ) 334void Wellenreiter::receivePacket( OPacket* p )
323{ 335{
324 hexWindow()->log( p->dump( 8 ) ); 336 hexWindow()->log( p->dump( 8 ) );
325 337
326 if ( checkDumpPacket( p ) ) 338 if ( checkDumpPacket( p ) )
327 { 339 {
328 pcap->dump( p ); 340 pcap->dump( p );
329 } 341 }
330 342
331 // check if we received a beacon frame 343 // check if we received a beacon frame
332 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 344 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
333 if ( beacon && beacon->managementType() == "Beacon" ) 345 if ( beacon && beacon->managementType() == "Beacon" )
334 { 346 {
335 handleBeacon( p, beacon ); 347 handleBeacon( p, beacon );
336 return; 348 return;
337 } 349 }
338 350
339 OMacAddress source; 351 OMacAddress source;
340 OMacAddress dest; 352 OMacAddress dest;
341 353
342 //TODO: WEP check here 354 //TODO: WEP check here
343 355
344 // check for a wireless data frame 356 // check for a wireless data frame
345 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 357 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
346 if ( wlan ) 358 if ( wlan )
347 { 359 {
348 handleWlanData( p, wlan, source, dest ); 360 handleWlanData( p, wlan, source, dest );
349 } 361 }
350 362
351 // check for a wired data frame 363 // check for a wired data frame
352 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 364 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
353 if ( eth ) 365 if ( eth )
354 { 366 {
355 handleEthernetData( p, eth, source, dest ); 367 handleEthernetData( p, eth, source, dest );
356 } 368 }
357 369
358 // check for an arp frame since arp frames come in two flavours: 370 // check for an arp frame since arp frames come in two flavours:
359 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 371 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
360 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 372 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
361 if ( arp ) 373 if ( arp )
362 { 374 {
363 handleARPData( p, arp, source, dest ); 375 handleARPData( p, arp, source, dest );
364 } 376 }
365 377
366 // check for a ip frame 378 // check for a ip frame
367 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 379 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
368 if ( ip ) 380 if ( ip )
369 { 381 {
370 handleIPData( p, ip, source, dest ); 382 handleIPData( p, ip, source, dest );
371 } 383 }
372 384
373 //handleNotification( p ); 385 //handleNotification( p );
374 386
375} 387}
376 388
377 389
378void Wellenreiter::stopClicked() 390void Wellenreiter::stopClicked()
379{ 391{
380 if ( iface ) 392 if ( iface )
381 { 393 {
382 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 394 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
383 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 395 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
384 iface->setChannelHopping(); // stop hopping channels 396 iface->setChannelHopping(); // stop hopping channels
385 } 397 }
386 else 398 else
387 killTimers(); 399 killTimers();
388 400
389 pcap->close(); 401 pcap->close();
390 sniffing = false; 402 sniffing = false;
391 403
392 if ( iface ) 404 if ( iface )
393 { 405 {
394 // switch off monitor mode 406 // switch off monitor mode
395 iface->setMode( "managed" ); 407 iface->setMode( "managed" );
396 // switch off promisc flag 408 // switch off promisc flag
397 iface->setPromiscuousMode( false ); 409 iface->setPromiscuousMode( false );
398 410
399 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 411 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
400 } 412 }
401 413
402 logwindow->log( "(i) Stopped Scanning." ); 414 logwindow->log( "(i) Stopped Scanning." );
403 assert( parent() ); 415 assert( parent() );
404 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 416 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
405 417
406 // message the user 418 // message the user
407 QMessageBox::information( this, "Wellenreiter II", 419 QMessageBox::information( this, "Wellenreiter II",
408 tr( "Your wireless card\nshould now be usable again." ) ); 420 tr( "Your wireless card\nshould now be usable again." ) );
409 421
410 sniffing = false; 422 sniffing = false;
411 emit( stoppedSniffing() ); 423 emit( stoppedSniffing() );
412 424
413 #ifdef QWS 425 #ifdef QWS
414 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 426 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
415 { 427 {
416 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 428 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
417 } 429 }
418 #else 430 #else
419 #warning FIXME: setScreenSaverMode is not operational on the X11 build 431 #warning FIXME: setScreenSaverMode is not operational on the X11 build
420 #endif 432 #endif
421 433
422 // print out statistics 434 // print out statistics
423 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 435 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
424 statwindow->updateCounter( it.key(), it.data() ); 436 statwindow->updateCounter( it.key(), it.data() );
425} 437}
426 438
427 439
428void Wellenreiter::startClicked() 440void Wellenreiter::startClicked()
429{ 441{
430 // get configuration from config window 442 // get configuration from config window
431 443
432 const QString& interface = configwindow->interfaceName->currentText(); 444 const QString& interface = configwindow->interfaceName->currentText();
433 const int cardtype = configwindow->driverType(); 445 const int cardtype = configwindow->driverType();
434 const int interval = configwindow->hoppingInterval(); 446 const int interval = configwindow->hoppingInterval();
435 447
436 if ( ( interface == "" ) || ( cardtype == 0 ) ) 448 if ( ( interface == "" ) || ( cardtype == 0 ) )
437 { 449 {
438 QMessageBox::information( this, "Wellenreiter II", 450 QMessageBox::information( this, "Wellenreiter II",
439 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 451 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
440 return; 452 return;
441 } 453 }
442 454
443 // configure device 455 // configure device
444 ONetwork* net = ONetwork::instance(); 456 ONetwork* net = ONetwork::instance();
445 457
446 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 458 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
447 459
448 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 460 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
449 461
450 // bring device UP 462 // bring device UP
451 if ( cardtype != DEVTYPE_FILE ) 463 if ( cardtype != DEVTYPE_FILE )
452 { 464 {
453 iface->setUp( true ); 465 iface->setUp( true );
454 if ( !iface->isUp() ) 466 if ( !iface->isUp() )
455 { 467 {
456 QMessageBox::warning( this, "Wellenreiter II", 468 QMessageBox::warning( this, "Wellenreiter II",
457 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 469 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
458 return; 470 return;
459 } 471 }
460 } 472 }
461 // set monitor mode 473 // set monitor mode
462 bool usePrism = configwindow->usePrismHeader(); 474 bool usePrism = configwindow->usePrismHeader();
463 475
464 switch ( cardtype ) 476 switch ( cardtype )
465 { 477 {
466 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 478 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
467 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 479 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
468 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 480 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
469 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 481 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
470 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 482 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
471 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 483 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
472 default: assert( 0 ); // shouldn't reach this 484 default: assert( 0 ); // shouldn't reach this
473 } 485 }
474 486
475 // switch device into monitor mode 487 // switch device into monitor mode
476 if ( cardtype < DEVTYPE_FILE ) 488 if ( cardtype < DEVTYPE_FILE )
477 { 489 {
478 if ( cardtype != DEVTYPE_MANUAL ) 490 if ( cardtype != DEVTYPE_MANUAL )
479 iface->setMode( "monitor" ); 491 iface->setMode( "monitor" );
480 if ( iface->mode() != "monitor" ) 492 if ( iface->mode() != "monitor" )
481 { 493 {
482 if ( QMessageBox::warning( this, "Wellenreiter II", 494 if ( QMessageBox::warning( this, "Wellenreiter II",
483 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 495 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
484 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 496 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
485 return; 497 return;
486 } 498 }
487 } 499 }
488 500
489 // open GPS device 501 // open GPS device
490 if ( configwindow->enableGPS->isChecked() ) 502 if ( configwindow->enableGPS->isChecked() )
491 { 503 {
492 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 504 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
493 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 505 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
494 } 506 }
495 507
496 // open pcap and start sniffing 508 // open pcap and start sniffing
497 if ( cardtype != DEVTYPE_FILE ) 509 if ( cardtype != DEVTYPE_FILE )
498 { 510 {
499 pcap->open( interface ); 511 pcap->open( interface );
500 512
501 if ( configwindow->writeCaptureFile->isChecked() ) 513 if ( configwindow->writeCaptureFile->isChecked() )
502 { 514 {
503 QString dumpname( configwindow->captureFileName->text() ); 515 QString dumpname( configwindow->captureFileName->text() );
504 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 516 if ( dumpname.isEmpty() ) dumpname = "captureFile";
505 dumpname.append( '-' ); 517 dumpname.append( '-' );
506 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 518 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
507 dumpname.append( ".wellenreiter" ); 519 dumpname.append( ".wellenreiter" );
508 pcap->openDumpFile( dumpname ); 520 pcap->openDumpFile( dumpname );
509 } 521 }
510 else 522 else
511 { 523 {
512 pcap->open( interface ); 524 pcap->open( interface );
513 } 525 }
514 } 526 }
515 else 527 else
516 { 528 {
517 pcap->open( QFile( interface ) ); 529 pcap->open( QFile( interface ) );
518 } 530 }
519 531
520 if ( !pcap->isOpen() ) 532 if ( !pcap->isOpen() )
521 { 533 {
522 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 534 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
523 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 535 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
524 return; 536 return;
525 } 537 }
526 538
527 // set capturer to non-blocking mode 539 // set capturer to non-blocking mode
528 pcap->setBlocking( false ); 540 pcap->setBlocking( false );
529 541
530 // start channel hopper 542 // start channel hopper
531 if ( cardtype != DEVTYPE_FILE ) 543 if ( cardtype != DEVTYPE_FILE )
532 { 544 {
533 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 545 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
534 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 546 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
535 } 547 }
536 548
537 if ( cardtype != DEVTYPE_FILE ) 549 if ( cardtype != DEVTYPE_FILE )
538 { 550 {
539 // connect socket notifier and start channel hopper 551 // connect socket notifier and start channel hopper
540 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 552 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
541 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 553 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
542 } 554 }
543 else 555 else
544 { 556 {
545 // start timer for reading packets 557 // start timer for reading packets
546 startTimer( 100 ); 558 startTimer( 100 );
547 } 559 }
548 560
549 logwindow->log( "(i) Started Scanning." ); 561 logwindow->log( "(i) Started Scanning." );
550 sniffing = true; 562 sniffing = true;
551 563
552 #ifdef QWS 564 #ifdef QWS
553 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 565 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
554 { 566 {
555 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 567 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
556 } 568 }
557 #else 569 #else
558 #warning FIXME: setScreenSaverMode is not operational on the X11 build 570 #warning FIXME: setScreenSaverMode is not operational on the X11 build
559 #endif 571 #endif
560 572
561 emit( startedSniffing() ); 573 emit( startedSniffing() );
562 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 574 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
563 else 575 else
564 { 576 {
565 assert( parent() ); 577 assert( parent() );
566 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 578 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
567 } 579 }
568} 580}
569 581
570 582
571void Wellenreiter::timerEvent( QTimerEvent* ) 583void Wellenreiter::timerEvent( QTimerEvent* )
572{ 584{
573 qDebug( "Wellenreiter::timerEvent()" ); 585 qDebug( "Wellenreiter::timerEvent()" );
574 OPacket* p = pcap->next(); 586 OPacket* p = pcap->next();
575 if ( !p ) // no more packets available 587 if ( !p ) // no more packets available
576 { 588 {
577 stopClicked(); 589 stopClicked();
578 } 590 }
579 else 591 else
580 { 592 {
581 receivePacket( p ); 593 receivePacket( p );
582 delete p; 594 delete p;
583 } 595 }
584} 596}
585 597
586 598
587void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 599void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
588{ 600{
589 #ifdef QWS 601 #ifdef QWS
590 if ( action == "TouchSound" ) 602 if ( action == "TouchSound" )
591 ODevice::inst()->touchSound(); 603 ODevice::inst()->touchSound();
592 else if ( action == "AlarmSound" ) 604 else if ( action == "AlarmSound" )
593 ODevice::inst()->alarmSound(); 605 ODevice::inst()->alarmSound();
594 else if ( action == "KeySound" ) 606 else if ( action == "KeySound" )
595 ODevice::inst()->keySound(); 607 ODevice::inst()->keySound();
596 else if ( action == "LedOn" ) 608 else if ( action == "LedOn" )
597 ODevice::inst()->setLedState( Led_Mail, Led_On ); 609 ODevice::inst()->setLedState( Led_Mail, Led_On );
598 else if ( action == "LedOff" ) 610 else if ( action == "LedOff" )
599 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 611 ODevice::inst()->setLedState( Led_Mail, Led_Off );
600 else if ( action == "LogMessage" ) 612 else if ( action == "LogMessage" )
601 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 613 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
602 else if ( action == "MessageBox" ) 614 else if ( action == "MessageBox" )
603 QMessageBox::information( this, "Notification!", 615 QMessageBox::information( this, "Notification!",
604 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 616 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
605 #else 617 #else
606 #warning Actions do not work with Qt/X11 yet 618 #warning Actions do not work with Qt/X11 yet
607 #endif 619 #endif
608} 620}
609 621
610void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 622void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
611{ 623{
612 #ifdef QWS 624 #ifdef QWS
613 if ( !iface ) 625 if ( !iface )
614 { 626 {
615 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 627 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
616 return; 628 return;
617 } 629 }
618 630
619 if ( sniffing ) 631 if ( sniffing )
620 { 632 {
621 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 633 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
622 return; 634 return;
623 } 635 }
624 636
625 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 637 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
626 (const char*) iface->name(), 638 (const char*) iface->name(),
627 (const char*) type, 639 (const char*) type,
628 (const char*) essid, 640 (const char*) essid,
629 channel, 641 channel,
630 (const char*) macaddr ); 642 (const char*) macaddr );
631 643
632 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 644 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
633 int count = 3; 645 int count = 3;
634 qDebug("sending %d messages",count); 646 qDebug("sending %d messages",count);
635 msg << QString("count") << QString::number(count); 647 msg << QString("count") << QString::number(count);
636 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 648 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
637 msg << QString(iface->name()) << QString("Mode") << type; 649 msg << QString(iface->name()) << QString("Mode") << type;
638 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 650 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
639 msg << QString(iface->name()) << QString("ESSID") << essid; 651 msg << QString(iface->name()) << QString("ESSID") << essid;
640 qDebug("msg >%s< channel >%d<", iface->name(),channel); 652 qDebug("msg >%s< channel >%d<", iface->name(),channel);
641 msg << QString(iface->name()) << QString("Channel") << channel; 653 msg << QString(iface->name()) << QString("Channel") << channel;
642// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 654// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
643// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 655// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
644 #else 656 #else
645 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 657 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
646 #endif 658 #endif
647 659
648} 660}
649 661
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