summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/ChangeLog1
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp41
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h4
3 files changed, 38 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/ChangeLog b/noncore/net/wellenreiter/ChangeLog
index 755ed76..8bf8cc8 100644
--- a/noncore/net/wellenreiter/ChangeLog
+++ b/noncore/net/wellenreiter/ChangeLog
@@ -1,73 +1,74 @@
1 2004-??-?? Michael Lauer <mickey@Vanille.de> 1 2004-??-?? Michael Lauer <mickey@Vanille.de>
2 2
3 * Added parsing of control frames. Display stations sending them SSID "???" for now.
3 * Added command line option "-nocheck" to skip non-root and dhcp tests 4 * Added command line option "-nocheck" to skip non-root and dhcp tests
4 * Improved the speed reading the manufacturer list 5 * Improved the speed reading the manufacturer list
5 * GPS coordinates are now presented in the DMS (as opposed to decimal) format 6 * GPS coordinates are now presented in the DMS (as opposed to decimal) format
6 7
7 2003-12-18 Michael Lauer <mickey@Vanille.de> 8 2003-12-18 Michael Lauer <mickey@Vanille.de>
8 9
9 * Released as Version 1.0.2 (Development Snapshot) 10 * Released as Version 1.0.2 (Development Snapshot)
10 * Added automatic uploading of capture files to "The Capture Dump" site at 11 * Added automatic uploading of capture files to "The Capture Dump" site at
11 http://www.Vanille.de/projects/capturedump.spy 12 http://www.Vanille.de/projects/capturedump.spy
12 * Initial reading of the manufacturer database happens now in background 13 * Initial reading of the manufacturer database happens now in background
13 * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now. 14 * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now.
14 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that 15 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that
15 doesn't work, it falls back to using the proprietary iwpriv commands 16 doesn't work, it falls back to using the proprietary iwpriv commands
16 17
17 2003-11-30 Michael Lauer <mickey@Vanille.de> 18 2003-11-30 Michael Lauer <mickey@Vanille.de>
18 19
19 * Released as Version 1.0.1 (Development Snapshot) 20 * Released as Version 1.0.1 (Development Snapshot)
20 * Fixed ARP decoding for wired networks. 21 * Fixed ARP decoding for wired networks.
21 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol. 22 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol.
22 * Added reading GPS data from a gps daemon. 23 * Added reading GPS data from a gps daemon.
23 * Started preparations for utilizing Wellenreiter II in wired networks. 24 * Started preparations for utilizing Wellenreiter II in wired networks.
24 * Implemented persistant configuration interface and retriggerable auto detection. 25 * Implemented persistant configuration interface and retriggerable auto detection.
25 * Added QCOP interface for talking to opie-networksettings. 26 * Added QCOP interface for talking to opie-networksettings.
26 * Added parsing of DHCP packets and detecting DHCP servers. 27 * Added parsing of DHCP packets and detecting DHCP servers.
27 * Overhauled the configuration window and started with the customizable event system. 28 * Overhauled the configuration window and started with the customizable event system.
28 * Added disabling the screensaver. 29 * Added disabling the screensaver.
29 * Added automatic opening and scrolling to the network tree if a new station appears. 30 * Added automatic opening and scrolling to the network tree if a new station appears.
30 31
31 2003-05-10 Michael Lauer <mickey@Vanille.de> 32 2003-05-10 Michael Lauer <mickey@Vanille.de>
32 33
33 * Released as Version 1.0 (Stable) 34 * Released as Version 1.0 (Stable)
34 * Added restarting the dhcp client if having killed it before. 35 * Added restarting the dhcp client if having killed it before.
35 * Decouple dump files from live capture to shift control over 'what' is dumped to applications. 36 * Decouple dump files from live capture to shift control over 'what' is dumped to applications.
36 37
37 2003-05-05 Michael Lauer <mickey@Vanille.de> 38 2003-05-05 Michael Lauer <mickey@Vanille.de>
38 39
39 * Released as Version 1.0-RC1 (Release Candidate) 40 * Released as Version 1.0-RC1 (Release Candidate)
40 * Fixed rare segfaults while sniffing and operating the GUI simultaenously. 41 * Fixed rare segfaults while sniffing and operating the GUI simultaenously.
41 * Parse more data packets and detect more participating stations. 42 * Parse more data packets and detect more participating stations.
42 * Added live graph window showing the signal strength on all channels. 43 * Added live graph window showing the signal strength on all channels.
43 * Added parsing ARP packets and identifying IP addresses of participating stations. 44 * Added parsing ARP packets and identifying IP addresses of participating stations.
44 * Added parsing with optionally enabled PRISM headers (signal strength). 45 * Added parsing with optionally enabled PRISM headers (signal strength).
45 46
46 2003-04-12 Michael Lauer <mickey@Vanille.de> 47 2003-04-12 Michael Lauer <mickey@Vanille.de>
47 48
48 * Released as Version 1.0 (Beta) 49 * Released as Version 1.0 (Beta)
49 * GUI enhancements in the Menubar and the Toolbar. 50 * GUI enhancements in the Menubar and the Toolbar.
50 * Improved keyboard handling. 51 * Improved keyboard handling.
51 * Added sanity checks for running Wellenreiter II as non-root or with dhcp clients in the background. 52 * Added sanity checks for running Wellenreiter II as non-root or with dhcp clients in the background.
52 * Add writing and replaying of libpcap compatible capture files. 53 * Add writing and replaying of libpcap compatible capture files.
53 54
54 2003-04-08 Michael Lauer <mickey@Vanille.de> 55 2003-04-08 Michael Lauer <mickey@Vanille.de>
55 56
56 * Released as Version 0.2 (Alpha) 57 * Released as Version 0.2 (Alpha)
57 * Closed memory leak in packet capturer. 58 * Closed memory leak in packet capturer.
58 * Fixed client stations appearing under essid as access points. 59 * Fixed client stations appearing under essid as access points.
59 * Fixed false WEP reporting in some cases. 60 * Fixed false WEP reporting in some cases.
60 * Started with inspecting data packages. 61 * Started with inspecting data packages.
61 * Add detecting associated client stations in infrastructural networks (if they transmit data). 62 * Add detecting associated client stations in infrastructural networks (if they transmit data).
62 * Worked around buggy hostap drivers writing past fixed-length-structures on arm. 63 * Worked around buggy hostap drivers writing past fixed-length-structures on arm.
63 * Added dynamic checking of available private ioctls. 64 * Added dynamic checking of available private ioctls.
64 * Added a saveable hex window for packet dissection. 65 * Added a saveable hex window for packet dissection.
65 66
66 2003-03-30 Michael Lauer <mickey@Vanille.de> 67 2003-03-30 Michael Lauer <mickey@Vanille.de>
67 68
68 * Released as Version 0.1 (Alpha) 69 * Released as Version 0.1 (Alpha)
69 70
70 2003-03-25 Michael Lauer <mickey@Vanille.de> 71 2003-03-25 Michael Lauer <mickey@Vanille.de>
71 72
72 * Rewrote Wellenreiter II from scratch - including the sniffing engine. 73 * Rewrote Wellenreiter II from scratch - including the sniffing engine.
73 * Beacon inspection works and finds ad-hoc networks and managed networks. 74 * Beacon inspection works and finds ad-hoc networks and managed networks.
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 5575d6e..45d7142 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,660 +1,687 @@
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/omanufacturerdb.h>
42#include <opie2/onetwork.h> 42#include <opie2/onetwork.h>
43#include <opie2/opcap.h> 43#include <opie2/opcap.h>
44 44
45// Qt 45// Qt
46 46
47#include <qcheckbox.h> 47#include <qcheckbox.h>
48#include <qcombobox.h> 48#include <qcombobox.h>
49#include <qdatetime.h> 49#include <qdatetime.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qlineedit.h> 51#include <qlineedit.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qobjectlist.h> 53#include <qobjectlist.h>
54#include <qregexp.h> 54#include <qregexp.h>
55#include <qspinbox.h> 55#include <qspinbox.h>
56#include <qtimer.h> 56#include <qtimer.h>
57#include <qtoolbutton.h> 57#include <qtoolbutton.h>
58#include <qmainwindow.h> 58#include <qmainwindow.h>
59 59
60// Standard 60// Standard
61 61
62#include <assert.h> 62#include <assert.h>
63#include <errno.h> 63#include <errno.h>
64#include <unistd.h> 64#include <unistd.h>
65#include <string.h> 65#include <string.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <stdlib.h> 67#include <stdlib.h>
68 68
69Wellenreiter::Wellenreiter( QWidget* parent ) 69Wellenreiter::Wellenreiter( QWidget* parent )
70 : WellenreiterBase( parent, 0, 0 ), 70 : WellenreiterBase( parent, 0, 0 ),
71 sniffing( false ), iface( 0 ), configwindow( 0 ) 71 sniffing( false ), iface( 0 ), configwindow( 0 )
72{ 72{
73 73
74 logwindow->log( "(i) Wellenreiter has been started." ); 74 logwindow->log( "(i) Wellenreiter has been started." );
75 75
76 // 76 //
77 // detect operating system 77 // detect operating system
78 // 78 //
79 79
80 #ifdef QWS 80 #ifdef QWS
81 QString sys; 81 QString sys;
82 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 82 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
83 _system = ODevice::inst()->system(); 83 _system = ODevice::inst()->system();
84 logwindow->log( sys ); 84 logwindow->log( sys );
85 #endif 85 #endif
86 86
87 netview->setColumnWidthMode( 1, QListView::Manual ); 87 netview->setColumnWidthMode( 1, QListView::Manual );
88 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 88 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
89 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 89 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
90 pcap = new OPacketCapturer(); 90 pcap = new OPacketCapturer();
91 91
92 gps = new GPS( this ); 92 gps = new GPS( this );
93 93
94 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 94 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
95 95
96} 96}
97 97
98 98
99Wellenreiter::~Wellenreiter() 99Wellenreiter::~Wellenreiter()
100{ 100{
101 delete pcap; 101 delete pcap;
102} 102}
103 103
104 104
105void Wellenreiter::initialTimer() 105void Wellenreiter::initialTimer()
106{ 106{
107 qDebug( "Wellenreiter::preloading manufacturer database..." ); 107 qDebug( "Wellenreiter::preloading manufacturer database..." );
108 OManufacturerDB::instance(); 108 OManufacturerDB::instance();
109} 109}
110 110
111 111
112void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 112void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
113{ 113{
114 configwindow = cw; 114 configwindow = cw;
115} 115}
116 116
117 117
118void Wellenreiter::channelHopped(int c) 118void Wellenreiter::channelHopped(int c)
119{ 119{
120 QString title = "Wellenreiter II -scan- ["; 120 QString title = "Wellenreiter II -scan- [";
121 QString left; 121 QString left;
122 if ( c > 1 ) left.fill( '.', c-1 ); 122 if ( c > 1 ) left.fill( '.', c-1 );
123 title.append( left ); 123 title.append( left );
124 title.append( '|' ); 124 title.append( '|' );
125 if ( c < iface->channels() ) 125 if ( c < iface->channels() )
126 { 126 {
127 QString right; 127 QString right;
128 right.fill( '.', iface->channels()-c ); 128 right.fill( '.', iface->channels()-c );
129 title.append( right ); 129 title.append( right );
130 } 130 }
131 title.append( "]" ); 131 title.append( "]" );
132 //title.append( QString().sprintf( " %02d", c ) ); 132 //title.append( QString().sprintf( " %02d", c ) );
133 assert( parent() ); 133 assert( parent() );
134 ( (QMainWindow*) parent() )->setCaption( title ); 134 ( (QMainWindow*) parent() )->setCaption( title );
135} 135}
136 136
137 137
138void Wellenreiter::handleNotification( OPacket* p ) 138void Wellenreiter::handleNotification( OPacket* p )
139{ 139{
140 QObjectList* l = p->queryList(); 140 QObjectList* l = p->queryList();
141 QObjectListIt it( *l ); 141 QObjectListIt it( *l );
142 QObject* o; 142 QObject* o;
143 143
144 while ( (o = it.current()) != 0 ) 144 while ( (o = it.current()) != 0 )
145 { 145 {
146 QString name = it.current()->name(); 146 QString name = it.current()->name();
147 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 147 if ( configwindow->parsePackets->isProtocolChecked( name ) )
148 { 148 {
149 QString action = configwindow->parsePackets->protocolAction( name ); 149 QString action = configwindow->parsePackets->protocolAction( name );
150 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 );
151 doAction( action, name, p ); 151 doAction( action, name, p );
152 } 152 }
153 else 153 else
154 { 154 {
155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
156 } 156 }
157 ++it; 157 ++it;
158 } 158 }
159} 159}
160 160
161 161
162void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 162void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
163{ 163{
164 if ( manage->managementType() != "Beacon" ) return; // only handling beacons at that time
165
166 OWaveLanManagementPacket* beacon = manage;
167
164 QString type; 168 QString type;
165 if ( beacon->canIBSS() ) 169 if ( beacon->canIBSS() )
166 { 170 {
167 type = "adhoc"; 171 type = "adhoc";
168 } 172 }
169 else if ( beacon->canESS() ) 173 else if ( beacon->canESS() )
170 { 174 {
171 type = "managed"; 175 type = "managed";
172 } 176 }
173 else 177 else
174 { 178 {
175 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 179 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
176 return; 180 return;
177 } 181 }
178 182
179 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 183 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
180 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 184 QString essid = ssid ? ssid->ID() : QString("<unknown>");
181 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 185 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
182 int channel = ds ? ds->channel() : -1; 186 int channel = ds ? ds->channel() : -1;
183 187
184 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 188 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
185 189
186 GpsLocation loc( 0, 0 ); 190 GpsLocation loc( -111.111, -111.111 );
187 if ( configwindow->enableGPS->isChecked() ) 191 if ( configwindow->enableGPS->isChecked() )
188 { 192 {
189 // TODO: add check if GPS is working!? 193 // TODO: add check if GPS is working!?
190 qDebug( "Wellenreiter::gathering GPS data..." ); 194 qDebug( "Wellenreiter::gathering GPS data..." );
191 loc = gps->position(); 195 loc = gps->position();
192 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 196 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
193 } 197 }
194 198
195 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 199 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
196 200
197 // update graph window 201 // update graph window
198 if ( ds ) 202 if ( ds )
199 { 203 {
200 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 204 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
201 if ( prism ) 205 if ( prism )
202 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 206 graphwindow->traffic( ds->channel(), prism->signalStrength() );
203 else 207 else
204 graphwindow->traffic( ds->channel(), 95 ); 208 graphwindow->traffic( ds->channel(), 95 );
205 } 209 }
206} 210}
207 211
208 212
213void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
214{
215 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
216
217 if ( control->controlType() == "Acknowledge" )
218 {
219 netView()->addNewItem( "adhoc", "???", header->macAddress1(), false, -1, 0, GpsLocation( -111.111, -111.111 ) );
220 }
221 else
222 {
223 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() );
224 }
225}
226
227
209void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 228void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
210{ 229{
211 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 230 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
212 if ( wlan->fromDS() && !wlan->toDS() ) 231 if ( wlan->fromDS() && !wlan->toDS() )
213 { 232 {
214 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 233 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
215 from = wlan->macAddress3(); 234 from = wlan->macAddress3();
216 to = wlan->macAddress2(); 235 to = wlan->macAddress2();
217 } 236 }
218 else if ( !wlan->fromDS() && wlan->toDS() ) 237 else if ( !wlan->fromDS() && wlan->toDS() )
219 { 238 {
220 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 239 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
221 from = wlan->macAddress2(); 240 from = wlan->macAddress2();
222 to = wlan->macAddress3(); 241 to = wlan->macAddress3();
223 } 242 }
224 else if ( wlan->fromDS() && wlan->toDS() ) 243 else if ( wlan->fromDS() && wlan->toDS() )
225 { 244 {
226 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 245 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
227 from = wlan->macAddress4(); 246 from = wlan->macAddress4();
228 to = wlan->macAddress3(); 247 to = wlan->macAddress3();
229 } 248 }
230 else 249 else
231 { 250 {
232 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 251 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
233 from = wlan->macAddress2(); 252 from = wlan->macAddress2();
234 to = wlan->macAddress1(); 253 to = wlan->macAddress1();
235 } 254 }
236} 255}
237 256
238 257
239void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 258void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
240{ 259{
241 from = data->sourceAddress(); 260 from = data->sourceAddress();
242 to = data->destinationAddress(); 261 to = data->destinationAddress();
243 262
244 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); 263 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111.111, -111.111 ) );
245} 264}
246 265
247 266
248void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 267void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
249{ 268{
250 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 269 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
251 if ( arp ) 270 if ( arp )
252 { 271 {
253 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 272 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
254 if ( arp->type() == "REQUEST" ) 273 if ( arp->type() == "REQUEST" )
255 { 274 {
256 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 275 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
257 } 276 }
258 else if ( arp->type() == "REPLY" ) 277 else if ( arp->type() == "REPLY" )
259 { 278 {
260 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 279 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
261 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 280 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
262 } 281 }
263 } 282 }
264} 283}
265 284
266 285
267void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 286void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
268{ 287{
269 //TODO: Implement more IP based protocols 288 //TODO: Implement more IP based protocols
270 289
271 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 290 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
272 if ( dhcp ) 291 if ( dhcp )
273 { 292 {
274 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 293 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
275 if ( dhcp->type() == "OFFER" ) 294 if ( dhcp->type() == "OFFER" )
276 { 295 {
277 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 296 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
278 netView()->identify( source, dhcp->serverAddress().toString() ); 297 netView()->identify( source, dhcp->serverAddress().toString() );
279 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 298 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
280 } 299 }
281 else if ( dhcp->type() == "ACK" ) 300 else if ( dhcp->type() == "ACK" )
282 { 301 {
283 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 302 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
284 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 303 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
285 } 304 }
286 } 305 }
287} 306}
288 307
289 308
290QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 309QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
291{ 310{
292 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 311 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
293 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 312 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
294 return 0; 313 return 0;
295 314
296 return p->child( protocol ); 315 return p->child( protocol );
297} 316}
298 317
299 318
300bool Wellenreiter::checkDumpPacket( OPacket* p ) 319bool Wellenreiter::checkDumpPacket( OPacket* p )
301{ 320{
302 // go through all child packets and see if one is inside the child hierarchy for p 321 // go through all child packets and see if one is inside the child hierarchy for p
303 // if so, do what the user requested (protocolAction), e.g. pass or discard 322 // if so, do what the user requested (protocolAction), e.g. pass or discard
304 if ( !configwindow->writeCaptureFile->isChecked() ) 323 if ( !configwindow->writeCaptureFile->isChecked() )
305 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 324 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
306 325
307 QObjectList* l = p->queryList(); 326 QObjectList* l = p->queryList();
308 QObjectListIt it( *l ); 327 QObjectListIt it( *l );
309 QObject* o; 328 QObject* o;
310 329
311 while ( (o = it.current()) != 0 ) 330 while ( (o = it.current()) != 0 )
312 { 331 {
313 QString name = it.current()->name(); 332 QString name = it.current()->name();
314 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 333 if ( configwindow->capturePackets->isProtocolChecked( name ) )
315 { 334 {
316 QString action = configwindow->capturePackets->protocolAction( name ); 335 QString action = configwindow->capturePackets->protocolAction( name );
317 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 336 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
318 if ( action == "Discard" ) 337 if ( action == "Discard" )
319 { 338 {
320 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 339 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
321 return false; 340 return false;
322 } 341 }
323 } 342 }
324 else 343 else
325 { 344 {
326 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 345 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
327 } 346 }
328 ++it; 347 ++it;
329 } 348 }
330 return true; 349 return true;
331} 350}
332 351
333 352
334void Wellenreiter::receivePacket( OPacket* p ) 353void Wellenreiter::receivePacket( OPacket* p )
335{ 354{
336 hexWindow()->log( p->dump( 8 ) ); 355 hexWindow()->log( p->dump( 8 ) );
337 356
338 if ( checkDumpPacket( p ) ) 357 if ( checkDumpPacket( p ) )
339 { 358 {
340 pcap->dump( p ); 359 pcap->dump( p );
341 } 360 }
342 361
343 // check if we received a beacon frame 362 // check for a management frame
344 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 363 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
345 if ( beacon && beacon->managementType() == "Beacon" ) 364 if ( manage )
365 {
366 handleManagementFrame( p, manage );
367 return;
368 }
369
370 // check for a control frame
371 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
372 if ( control )
346 { 373 {
347 handleBeacon( p, beacon ); 374 handleControlFrame( p, control );
348 return; 375 return;
349 } 376 }
350 377
351 OMacAddress source; 378 OMacAddress source;
352 OMacAddress dest; 379 OMacAddress dest;
353 380
354 //TODO: WEP check here 381 //TODO: WEP check here
355 382
356 // check for a wireless data frame 383 // check for a wireless data frame
357 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 384 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
358 if ( wlan ) 385 if ( wlan )
359 { 386 {
360 handleWlanData( p, wlan, source, dest ); 387 handleWlanData( p, wlan, source, dest );
361 } 388 }
362 389
363 // check for a wired data frame 390 // check for a wired data frame
364 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 391 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
365 if ( eth ) 392 if ( eth )
366 { 393 {
367 handleEthernetData( p, eth, source, dest ); 394 handleEthernetData( p, eth, source, dest );
368 } 395 }
369 396
370 // check for an arp frame since arp frames come in two flavours: 397 // check for an arp frame since arp frames come in two flavours:
371 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 398 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
372 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 399 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
373 if ( arp ) 400 if ( arp )
374 { 401 {
375 handleARPData( p, arp, source, dest ); 402 handleARPData( p, arp, source, dest );
376 } 403 }
377 404
378 // check for a ip frame 405 // check for a ip frame
379 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 406 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
380 if ( ip ) 407 if ( ip )
381 { 408 {
382 handleIPData( p, ip, source, dest ); 409 handleIPData( p, ip, source, dest );
383 } 410 }
384 411
385 //handleNotification( p ); 412 //handleNotification( p );
386 413
387} 414}
388 415
389 416
390void Wellenreiter::stopClicked() 417void Wellenreiter::stopClicked()
391{ 418{
392 if ( iface ) 419 if ( iface )
393 { 420 {
394 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 421 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
395 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 422 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
396 iface->setChannelHopping(); // stop hopping channels 423 iface->setChannelHopping(); // stop hopping channels
397 } 424 }
398 else 425 else
399 killTimers(); 426 killTimers();
400 427
401 pcap->close(); 428 pcap->close();
402 sniffing = false; 429 sniffing = false;
403 430
404 if ( iface ) 431 if ( iface )
405 { 432 {
406 // switch off monitor mode 433 // switch off monitor mode
407 iface->setMode( "managed" ); 434 iface->setMode( "managed" );
408 // switch off promisc flag 435 // switch off promisc flag
409 iface->setPromiscuousMode( false ); 436 iface->setPromiscuousMode( false );
410 437
411 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 438 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
412 } 439 }
413 440
414 logwindow->log( "(i) Stopped Scanning." ); 441 logwindow->log( "(i) Stopped Scanning." );
415 assert( parent() ); 442 assert( parent() );
416 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 443 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
417 444
418 // message the user 445 // message the user
419 QMessageBox::information( this, "Wellenreiter II", 446 QMessageBox::information( this, "Wellenreiter II",
420 tr( "Your wireless card\nshould now be usable again." ) ); 447 tr( "Your wireless card\nshould now be usable again." ) );
421 448
422 sniffing = false; 449 sniffing = false;
423 emit( stoppedSniffing() ); 450 emit( stoppedSniffing() );
424 451
425 #ifdef QWS 452 #ifdef QWS
426 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 453 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
427 { 454 {
428 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 455 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
429 } 456 }
430 #else 457 #else
431 #warning FIXME: setScreenSaverMode is not operational on the X11 build 458 #warning FIXME: setScreenSaverMode is not operational on the X11 build
432 #endif 459 #endif
433 460
434 // print out statistics 461 // print out statistics
435 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 462 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
436 statwindow->updateCounter( it.key(), it.data() ); 463 statwindow->updateCounter( it.key(), it.data() );
437} 464}
438 465
439 466
440void Wellenreiter::startClicked() 467void Wellenreiter::startClicked()
441{ 468{
442 // get configuration from config window 469 // get configuration from config window
443 470
444 const QString& interface = configwindow->interfaceName->currentText(); 471 const QString& interface = configwindow->interfaceName->currentText();
445 const int cardtype = configwindow->driverType(); 472 const int cardtype = configwindow->driverType();
446 const int interval = configwindow->hoppingInterval(); 473 const int interval = configwindow->hoppingInterval();
447 474
448 if ( ( interface == "" ) || ( cardtype == 0 ) ) 475 if ( ( interface == "" ) || ( cardtype == 0 ) )
449 { 476 {
450 QMessageBox::information( this, "Wellenreiter II", 477 QMessageBox::information( this, "Wellenreiter II",
451 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 478 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
452 return; 479 return;
453 } 480 }
454 481
455 // configure device 482 // configure device
456 ONetwork* net = ONetwork::instance(); 483 ONetwork* net = ONetwork::instance();
457 484
458 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 485 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
459 486
460 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 487 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
461 488
462 // bring device UP 489 // bring device UP
463 if ( cardtype != DEVTYPE_FILE ) 490 if ( cardtype != DEVTYPE_FILE )
464 { 491 {
465 iface->setUp( true ); 492 iface->setUp( true );
466 if ( !iface->isUp() ) 493 if ( !iface->isUp() )
467 { 494 {
468 QMessageBox::warning( this, "Wellenreiter II", 495 QMessageBox::warning( this, "Wellenreiter II",
469 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 496 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
470 return; 497 return;
471 } 498 }
472 } 499 }
473 // set monitor mode 500 // set monitor mode
474 bool usePrism = configwindow->usePrismHeader(); 501 bool usePrism = configwindow->usePrismHeader();
475 502
476 switch ( cardtype ) 503 switch ( cardtype )
477 { 504 {
478 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 505 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
479 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 506 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
480 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 507 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
481 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 508 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
482 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 509 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
483 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 510 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
484 default: assert( 0 ); // shouldn't reach this 511 default: assert( 0 ); // shouldn't reach this
485 } 512 }
486 513
487 // switch device into monitor mode 514 // switch device into monitor mode
488 if ( cardtype < DEVTYPE_FILE ) 515 if ( cardtype < DEVTYPE_FILE )
489 { 516 {
490 if ( cardtype != DEVTYPE_MANUAL ) 517 if ( cardtype != DEVTYPE_MANUAL )
491 iface->setMode( "monitor" ); 518 iface->setMode( "monitor" );
492 if ( iface->mode() != "monitor" ) 519 if ( iface->mode() != "monitor" )
493 { 520 {
494 if ( QMessageBox::warning( this, "Wellenreiter II", 521 if ( QMessageBox::warning( this, "Wellenreiter II",
495 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 522 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
496 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 523 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
497 return; 524 return;
498 } 525 }
499 } 526 }
500 527
501 // open GPS device 528 // open GPS device
502 if ( configwindow->enableGPS->isChecked() ) 529 if ( configwindow->enableGPS->isChecked() )
503 { 530 {
504 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 531 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
505 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 532 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
506 } 533 }
507 534
508 // open pcap and start sniffing 535 // open pcap and start sniffing
509 536
510 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 537 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
511 { 538 {
512 dumpname = configwindow->captureFileName->text(); 539 dumpname = configwindow->captureFileName->text();
513 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 540 if ( dumpname.isEmpty() ) dumpname = "captureFile";
514 dumpname.append( '-' ); 541 dumpname.append( '-' );
515 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 542 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
516 dumpname.append( ".wellenreiter" ); 543 dumpname.append( ".wellenreiter" );
517 } 544 }
518 else // write it anyway ;) 545 else // write it anyway ;)
519 { 546 {
520 dumpname = "/var/log/dump.wellenreiter"; 547 dumpname = "/var/log/dump.wellenreiter";
521 } 548 }
522 549
523 if ( cardtype != DEVTYPE_FILE ) 550 if ( cardtype != DEVTYPE_FILE )
524 pcap->open( interface ); 551 pcap->open( interface );
525 else 552 else
526 pcap->open( QFile( interface ) ); 553 pcap->open( QFile( interface ) );
527 554
528 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); 555 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
529 pcap->openDumpFile( dumpname ); 556 pcap->openDumpFile( dumpname );
530 557
531 if ( !pcap->isOpen() ) 558 if ( !pcap->isOpen() )
532 { 559 {
533 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 560 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
534 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 561 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
535 return; 562 return;
536 } 563 }
537 564
538 // set capturer to non-blocking mode 565 // set capturer to non-blocking mode
539 pcap->setBlocking( false ); 566 pcap->setBlocking( false );
540 567
541 // start channel hopper 568 // start channel hopper
542 if ( cardtype != DEVTYPE_FILE ) 569 if ( cardtype != DEVTYPE_FILE )
543 { 570 {
544 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 571 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
545 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 572 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
546 } 573 }
547 574
548 if ( cardtype != DEVTYPE_FILE ) 575 if ( cardtype != DEVTYPE_FILE )
549 { 576 {
550 // connect socket notifier and start channel hopper 577 // connect socket notifier and start channel hopper
551 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 578 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
552 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 579 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
553 } 580 }
554 else 581 else
555 { 582 {
556 // start timer for reading packets 583 // start timer for reading packets
557 startTimer( 100 ); 584 startTimer( 100 );
558 } 585 }
559 586
560 logwindow->log( "(i) Started Scanning." ); 587 logwindow->log( "(i) Started Scanning." );
561 sniffing = true; 588 sniffing = true;
562 589
563 #ifdef QWS 590 #ifdef QWS
564 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 591 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
565 { 592 {
566 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 593 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
567 } 594 }
568 #else 595 #else
569 #warning FIXME: setScreenSaverMode is not operational on the X11 build 596 #warning FIXME: setScreenSaverMode is not operational on the X11 build
570 #endif 597 #endif
571 598
572 emit( startedSniffing() ); 599 emit( startedSniffing() );
573 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 600 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
574 else 601 else
575 { 602 {
576 assert( parent() ); 603 assert( parent() );
577 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 604 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
578 } 605 }
579} 606}
580 607
581 608
582void Wellenreiter::timerEvent( QTimerEvent* ) 609void Wellenreiter::timerEvent( QTimerEvent* )
583{ 610{
584 qDebug( "Wellenreiter::timerEvent()" ); 611 qDebug( "Wellenreiter::timerEvent()" );
585 OPacket* p = pcap->next(); 612 OPacket* p = pcap->next();
586 if ( !p ) // no more packets available 613 if ( !p ) // no more packets available
587 { 614 {
588 stopClicked(); 615 stopClicked();
589 } 616 }
590 else 617 else
591 { 618 {
592 receivePacket( p ); 619 receivePacket( p );
593 delete p; 620 delete p;
594 } 621 }
595} 622}
596 623
597 624
598void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 625void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
599{ 626{
600 #ifdef QWS 627 #ifdef QWS
601 if ( action == "TouchSound" ) 628 if ( action == "TouchSound" )
602 ODevice::inst()->touchSound(); 629 ODevice::inst()->touchSound();
603 else if ( action == "AlarmSound" ) 630 else if ( action == "AlarmSound" )
604 ODevice::inst()->alarmSound(); 631 ODevice::inst()->alarmSound();
605 else if ( action == "KeySound" ) 632 else if ( action == "KeySound" )
606 ODevice::inst()->keySound(); 633 ODevice::inst()->keySound();
607 else if ( action == "LedOn" ) 634 else if ( action == "LedOn" )
608 ODevice::inst()->setLedState( Led_Mail, Led_On ); 635 ODevice::inst()->setLedState( Led_Mail, Led_On );
609 else if ( action == "LedOff" ) 636 else if ( action == "LedOff" )
610 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 637 ODevice::inst()->setLedState( Led_Mail, Led_Off );
611 else if ( action == "LogMessage" ) 638 else if ( action == "LogMessage" )
612 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 639 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
613 else if ( action == "MessageBox" ) 640 else if ( action == "MessageBox" )
614 QMessageBox::information( this, "Notification!", 641 QMessageBox::information( this, "Notification!",
615 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 642 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
616 #else 643 #else
617 #warning Actions do not work with Qt/X11 yet 644 #warning Actions do not work with Qt/X11 yet
618 #endif 645 #endif
619} 646}
620 647
621void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 648void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
622{ 649{
623 #ifdef QWS 650 #ifdef QWS
624 if ( !iface ) 651 if ( !iface )
625 { 652 {
626 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 653 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
627 return; 654 return;
628 } 655 }
629 656
630 if ( sniffing ) 657 if ( sniffing )
631 { 658 {
632 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 659 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
633 return; 660 return;
634 } 661 }
635 662
636 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 663 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
637 (const char*) iface->name(), 664 (const char*) iface->name(),
638 (const char*) type, 665 (const char*) type,
639 (const char*) essid, 666 (const char*) essid,
640 channel, 667 channel,
641 (const char*) macaddr ); 668 (const char*) macaddr );
642 669
643 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 670 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
644 int count = 3; 671 int count = 3;
645 qDebug("sending %d messages",count); 672 qDebug("sending %d messages",count);
646 msg << QString("count") << QString::number(count); 673 msg << QString("count") << QString::number(count);
647 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 674 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
648 msg << QString(iface->name()) << QString("Mode") << type; 675 msg << QString(iface->name()) << QString("Mode") << type;
649 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 676 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
650 msg << QString(iface->name()) << QString("ESSID") << essid; 677 msg << QString(iface->name()) << QString("ESSID") << essid;
651 qDebug("msg >%s< channel >%d<", iface->name(),channel); 678 qDebug("msg >%s< channel >%d<", iface->name(),channel);
652 msg << QString(iface->name()) << QString("Channel") << channel; 679 msg << QString(iface->name()) << QString("Channel") << channel;
653// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 680// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
654// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 681// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
655 #else 682 #else
656 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 683 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
657 #endif 684 #endif
658 685
659} 686}
660 687
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 58dd1fd..5414fda 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,104 +1,106 @@
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 OWaveLanControlPacket;
30class OWaveLanDataPacket; 31class OWaveLanDataPacket;
31class OEthernetPacket; 32class OEthernetPacket;
32class OARPPacket; 33class OARPPacket;
33class OMacAddress; 34class OMacAddress;
34class OIPPacket; 35class OIPPacket;
35class OPacketCapturer; 36class OPacketCapturer;
36class OWirelessNetworkInterface; 37class OWirelessNetworkInterface;
37class WellenreiterConfigWindow; 38class WellenreiterConfigWindow;
38class MLogWindow; 39class MLogWindow;
39class MHexWindow; 40class MHexWindow;
40class GPS; 41class GPS;
41 42
42class Wellenreiter : public WellenreiterBase { 43class Wellenreiter : public WellenreiterBase {
43 Q_OBJECT 44 Q_OBJECT
44 45
45 public: 46 public:
46 Wellenreiter( QWidget* parent = 0 ); 47 Wellenreiter( QWidget* parent = 0 );
47 ~Wellenreiter(); 48 ~Wellenreiter();
48 49
49 void setConfigWindow( WellenreiterConfigWindow* cw ); 50 void setConfigWindow( WellenreiterConfigWindow* cw );
50 MScanListView* netView() const { return netview; }; 51 MScanListView* netView() const { return netview; };
51 MLogWindow* logWindow() const { return logwindow; }; 52 MLogWindow* logWindow() const { return logwindow; };
52 MHexWindow* hexWindow() const { return hexwindow; }; 53 MHexWindow* hexWindow() const { return hexwindow; };
53 bool isDaemonRunning() const { return sniffing; }; 54 bool isDaemonRunning() const { return sniffing; };
54 QString captureFileName() const { return dumpname; }; 55 QString captureFileName() const { return dumpname; };
55 56
56 public: 57 public:
57 bool sniffing; 58 bool sniffing;
58 59
59 protected: 60 protected:
60 virtual void timerEvent( QTimerEvent* ); 61 virtual void timerEvent( QTimerEvent* );
61 62
62 public slots: 63 public slots:
63 void initialTimer(); 64 void initialTimer();
64 65
65 void channelHopped(int); 66 void channelHopped(int);
66 void receivePacket(OPacket*); 67 void receivePacket(OPacket*);
67 void startClicked(); 68 void startClicked();
68 void stopClicked(); 69 void stopClicked();
69 70
70 void joinNetwork(const QString&,const QString&,int,const QString&); 71 void joinNetwork(const QString&,const QString&,int,const QString&);
71 72
72 signals: 73 signals:
73 void startedSniffing(); 74 void startedSniffing();
74 void stoppedSniffing(); 75 void stoppedSniffing();
75 76
76 private: 77 private:
77 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 78 void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage );
79 void handleControlFrame( OPacket* p, OWaveLanControlPacket* control );
78 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 80 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
79 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 81 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
80 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); 82 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
81 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 83 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
82 void handleNotification( OPacket* p ); 84 void handleNotification( OPacket* p );
83 void doAction( const QString& action, const QString& protocol, OPacket* p ); 85 void doAction( const QString& action, const QString& protocol, OPacket* p );
84 QObject* childIfToParse( OPacket* p, const QString& protocol ); 86 QObject* childIfToParse( OPacket* p, const QString& protocol );
85 bool checkDumpPacket( OPacket* p ); 87 bool checkDumpPacket( OPacket* p );
86 88
87 private: 89 private:
88 #ifdef QWS 90 #ifdef QWS
89 OSystem _system; // Opie Operating System identifier 91 OSystem _system; // Opie Operating System identifier
90 #endif 92 #endif
91 93
92 QString dumpname; 94 QString dumpname;
93 OWirelessNetworkInterface* iface; 95 OWirelessNetworkInterface* iface;
94 OPacketCapturer* pcap; 96 OPacketCapturer* pcap;
95 WellenreiterConfigWindow* configwindow; 97 WellenreiterConfigWindow* configwindow;
96 GPS* gps; 98 GPS* gps;
97 99
98 //void readConfig(); 100 //void readConfig();
99 //void writeConfig(); 101 //void writeConfig();
100}; 102};
101 103
102 104
103 105
104#endif 106#endif