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