-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index b4b6aa3..0105e09 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,389 +1,396 @@ | |||
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 | // Opie | 16 | // Opie |
17 | 17 | ||
18 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <opie/odevice.h> | 19 | #include <opie/odevice.h> |
20 | using namespace Opie; | 20 | using namespace Opie; |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #ifdef QWS | 23 | #ifdef QWS |
24 | #include <opie2/oapplication.h> | 24 | #include <opie2/oapplication.h> |
25 | #else | 25 | #else |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #endif | 27 | #endif |
28 | #include <opie2/onetwork.h> | 28 | #include <opie2/onetwork.h> |
29 | #include <opie2/opcap.h> | 29 | #include <opie2/opcap.h> |
30 | 30 | ||
31 | // Qt | 31 | // Qt |
32 | 32 | ||
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
42 | 42 | ||
43 | // Standard | 43 | // Standard |
44 | 44 | ||
45 | #include <assert.h> | 45 | #include <assert.h> |
46 | #include <errno.h> | 46 | #include <errno.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <string.h> | 48 | #include <string.h> |
49 | #include <sys/types.h> | 49 | #include <sys/types.h> |
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | 51 | ||
52 | // Local | 52 | // Local |
53 | 53 | ||
54 | #include "wellenreiter.h" | 54 | #include "wellenreiter.h" |
55 | #include "scanlist.h" | 55 | #include "scanlist.h" |
56 | #include "logwindow.h" | 56 | #include "logwindow.h" |
57 | #include "hexwindow.h" | 57 | #include "hexwindow.h" |
58 | #include "configwindow.h" | 58 | #include "configwindow.h" |
59 | #include "statwindow.h" | 59 | #include "statwindow.h" |
60 | #include "manufacturers.h" | 60 | #include "manufacturers.h" |
61 | 61 | ||
62 | Wellenreiter::Wellenreiter( QWidget* parent ) | 62 | Wellenreiter::Wellenreiter( QWidget* parent ) |
63 | : WellenreiterBase( parent, 0, 0 ), | 63 | : WellenreiterBase( parent, 0, 0 ), |
64 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) | 64 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) |
65 | { | 65 | { |
66 | 66 | ||
67 | // | 67 | // |
68 | // construct manufacturer database | 68 | // construct manufacturer database |
69 | // | 69 | // |
70 | 70 | ||
71 | QString manufile; | 71 | QString manufile; |
72 | #ifdef QWS | 72 | #ifdef QWS |
73 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 73 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
74 | #else | 74 | #else |
75 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 75 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
76 | #endif | 76 | #endif |
77 | manufacturerdb = new ManufacturerDB( manufile ); | 77 | manufacturerdb = new ManufacturerDB( manufile ); |
78 | 78 | ||
79 | logwindow->log( "(i) Wellenreiter has been started." ); | 79 | logwindow->log( "(i) Wellenreiter has been started." ); |
80 | 80 | ||
81 | // | 81 | // |
82 | // detect operating system | 82 | // detect operating system |
83 | // | 83 | // |
84 | 84 | ||
85 | #ifdef QWS | 85 | #ifdef QWS |
86 | QString sys; | 86 | QString sys; |
87 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 87 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
88 | _system = ODevice::inst()->system(); | 88 | _system = ODevice::inst()->system(); |
89 | logwindow->log( sys ); | 89 | logwindow->log( sys ); |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | // setup GUI | 92 | // setup GUI |
93 | netview->setColumnWidthMode( 1, QListView::Manual ); | 93 | netview->setColumnWidthMode( 1, QListView::Manual ); |
94 | 94 | ||
95 | if ( manufacturerdb ) | 95 | if ( manufacturerdb ) |
96 | netview->setManufacturerDB( manufacturerdb ); | 96 | netview->setManufacturerDB( manufacturerdb ); |
97 | 97 | ||
98 | pcap = new OPacketCapturer(); | 98 | pcap = new OPacketCapturer(); |
99 | 99 | ||
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | Wellenreiter::~Wellenreiter() | 103 | Wellenreiter::~Wellenreiter() |
104 | { | 104 | { |
105 | // no need to delete child widgets, Qt does it all for us | 105 | // no need to delete child widgets, Qt does it all for us |
106 | 106 | ||
107 | delete manufacturerdb; | 107 | delete manufacturerdb; |
108 | delete pcap; | 108 | delete pcap; |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 112 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
113 | { | 113 | { |
114 | configwindow = cw; | 114 | configwindow = cw; |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | void Wellenreiter::channelHopped(int c) | 118 | void 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 | ||
138 | void Wellenreiter::receivePacket(OPacket* p) | 138 | void Wellenreiter::receivePacket(OPacket* p) |
139 | { | 139 | { |
140 | hexWindow()->log( p->dump( 8 ) ); | 140 | hexWindow()->log( p->dump( 8 ) ); |
141 | 141 | ||
142 | // check if we received a beacon frame | 142 | // check if we received a beacon frame |
143 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 143 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
144 | if ( beacon && beacon->managementType() == "Beacon" ) | 144 | if ( beacon && beacon->managementType() == "Beacon" ) |
145 | { | 145 | { |
146 | QString type; | 146 | QString type; |
147 | if ( beacon->canIBSS() ) | 147 | if ( beacon->canIBSS() ) |
148 | { | 148 | { |
149 | type = "adhoc"; | 149 | type = "adhoc"; |
150 | } | 150 | } |
151 | else if ( beacon->canESS() ) | 151 | else if ( beacon->canESS() ) |
152 | { | 152 | { |
153 | type = "managed"; | 153 | type = "managed"; |
154 | } | 154 | } |
155 | else | 155 | else |
156 | { | 156 | { |
157 | qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); | 157 | qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | 160 | ||
161 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 161 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
162 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 162 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
163 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 163 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
164 | int channel = ds ? ds->channel() : -1; | 164 | int channel = ds ? ds->channel() : -1; |
165 | 165 | ||
166 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 166 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
167 | netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); | 167 | netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | // check for a data frame | 171 | // check for a data frame |
172 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); | 172 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); |
173 | if ( data ) | 173 | if ( data ) |
174 | { | 174 | { |
175 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 175 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
176 | if ( wlan->fromDS() && !wlan->toDS() ) | 176 | if ( wlan->fromDS() && !wlan->toDS() ) |
177 | { | 177 | { |
178 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", | 178 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", |
179 | (const char*) wlan->macAddress3().toString(true), | 179 | (const char*) wlan->macAddress3().toString(true), |
180 | (const char*) wlan->macAddress1().toString(true), | 180 | (const char*) wlan->macAddress1().toString(true), |
181 | (const char*) wlan->macAddress2().toString(true) ); | 181 | (const char*) wlan->macAddress2().toString(true) ); |
182 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), | 182 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), |
183 | wlan->macAddress1().toString(), | 183 | wlan->macAddress1().toString(), |
184 | wlan->macAddress2().toString() ); | 184 | wlan->macAddress2().toString() ); |
185 | } | 185 | } |
186 | else | 186 | else |
187 | if ( !wlan->fromDS() && wlan->toDS() ) | 187 | if ( !wlan->fromDS() && wlan->toDS() ) |
188 | { | 188 | { |
189 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", | 189 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", |
190 | (const char*) wlan->macAddress2().toString(true), | 190 | (const char*) wlan->macAddress2().toString(true), |
191 | (const char*) wlan->macAddress3().toString(true), | 191 | (const char*) wlan->macAddress3().toString(true), |
192 | (const char*) wlan->macAddress1().toString(true) ); | 192 | (const char*) wlan->macAddress1().toString(true) ); |
193 | netView()->traffic( "toDS", wlan->macAddress2().toString(), | 193 | netView()->traffic( "toDS", wlan->macAddress2().toString(), |
194 | wlan->macAddress3().toString(), | 194 | wlan->macAddress3().toString(), |
195 | wlan->macAddress1().toString() ); | 195 | wlan->macAddress1().toString() ); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | if ( wlan->fromDS() && wlan->toDS() ) | 198 | if ( wlan->fromDS() && wlan->toDS() ) |
199 | { | 199 | { |
200 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", | 200 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", |
201 | (const char*) wlan->macAddress4().toString(true), | 201 | (const char*) wlan->macAddress4().toString(true), |
202 | (const char*) wlan->macAddress3().toString(true), | 202 | (const char*) wlan->macAddress3().toString(true), |
203 | (const char*) wlan->macAddress1().toString(true), | 203 | (const char*) wlan->macAddress1().toString(true), |
204 | (const char*) wlan->macAddress2().toString(true) ); | 204 | (const char*) wlan->macAddress2().toString(true) ); |
205 | netView()->traffic( "WSD", wlan->macAddress4().toString(), | 205 | netView()->traffic( "WSD", wlan->macAddress4().toString(), |
206 | wlan->macAddress3().toString(), | 206 | wlan->macAddress3().toString(), |
207 | wlan->macAddress1().toString(), | 207 | wlan->macAddress1().toString(), |
208 | wlan->macAddress2().toString() ); | 208 | wlan->macAddress2().toString() ); |
209 | } | 209 | } |
210 | else | 210 | else |
211 | { | 211 | { |
212 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", | 212 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", |
213 | (const char*) wlan->macAddress2().toString(true), | 213 | (const char*) wlan->macAddress2().toString(true), |
214 | (const char*) wlan->macAddress1().toString(true), | 214 | (const char*) wlan->macAddress1().toString(true), |
215 | (const char*) wlan->macAddress3().toString(true) ); | 215 | (const char*) wlan->macAddress3().toString(true) ); |
216 | netView()->traffic( "IBSS", wlan->macAddress2().toString(), | 216 | netView()->traffic( "IBSS", wlan->macAddress2().toString(), |
217 | wlan->macAddress1().toString(), | 217 | wlan->macAddress1().toString(), |
218 | wlan->macAddress3().toString() ); | 218 | wlan->macAddress3().toString() ); |
219 | } | 219 | } |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void Wellenreiter::stopClicked() | 225 | void Wellenreiter::stopClicked() |
226 | { | 226 | { |
227 | if ( iface ) | 227 | if ( iface ) |
228 | { | 228 | { |
229 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 229 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
230 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 230 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
231 | iface->setChannelHopping(); // stop hopping channels | 231 | iface->setChannelHopping(); // stop hopping channels |
232 | } | 232 | } |
233 | else | 233 | else |
234 | killTimers(); | 234 | killTimers(); |
235 | 235 | ||
236 | pcap->close(); | 236 | pcap->close(); |
237 | sniffing = false; | 237 | sniffing = false; |
238 | 238 | ||
239 | if ( iface ) | 239 | if ( iface ) |
240 | { | 240 | { |
241 | // switch off monitor mode | 241 | // switch off monitor mode |
242 | iface->setMonitorMode( false ); | 242 | iface->setMonitorMode( false ); |
243 | // switch off promisc flag | 243 | // switch off promisc flag |
244 | iface->setPromiscuousMode( false ); | 244 | iface->setPromiscuousMode( false ); |
245 | 245 | ||
246 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 246 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
247 | } | 247 | } |
248 | 248 | ||
249 | logwindow->log( "(i) Stopped Scanning." ); | 249 | logwindow->log( "(i) Stopped Scanning." ); |
250 | assert( parent() ); | 250 | assert( parent() ); |
251 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 251 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
252 | 252 | ||
253 | // message the user | 253 | // message the user |
254 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 254 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
255 | 255 | ||
256 | sniffing = false; | 256 | sniffing = false; |
257 | emit( stoppedSniffing() ); | 257 | emit( stoppedSniffing() ); |
258 | 258 | ||
259 | // print out statistics | 259 | // print out statistics |
260 | statwindow->log( "-----------------------------------------" ); | 260 | statwindow->log( "-----------------------------------------" ); |
261 | statwindow->log( "- Wellenreiter II Capturing Statistic -" ); | 261 | statwindow->log( "- Wellenreiter II Capturing Statistic -" ); |
262 | statwindow->log( "-----------------------------------------" ); | 262 | statwindow->log( "-----------------------------------------" ); |
263 | statwindow->log( "Packet Type | Receive Count" ); | 263 | statwindow->log( "Packet Type | Receive Count" ); |
264 | 264 | ||
265 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 265 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
266 | { | 266 | { |
267 | QString left; | 267 | QString left; |
268 | left.sprintf( "%s", (const char*) it.key() ); | 268 | left.sprintf( "%s", (const char*) it.key() ); |
269 | left = left.leftJustify( 20 ); | 269 | left = left.leftJustify( 20 ); |
270 | left.append( '|' ); | 270 | left.append( '|' ); |
271 | QString right; | 271 | QString right; |
272 | right.sprintf( "%d", it.data() ); | 272 | right.sprintf( "%d", it.data() ); |
273 | right = right.rightJustify( 7 ); | 273 | right = right.rightJustify( 7 ); |
274 | statwindow->log( left + right ); | 274 | statwindow->log( left + right ); |
275 | } | 275 | } |
276 | 276 | ||
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | void Wellenreiter::startClicked() | 280 | void Wellenreiter::startClicked() |
281 | { | 281 | { |
282 | // get configuration from config window | 282 | // get configuration from config window |
283 | 283 | ||
284 | const QString& interface = configwindow->interfaceName->currentText(); | 284 | const QString& interface = configwindow->interfaceName->currentText(); |
285 | const int cardtype = configwindow->daemonDeviceType(); | 285 | const int cardtype = configwindow->daemonDeviceType(); |
286 | const int interval = configwindow->daemonHopInterval(); | 286 | const int interval = configwindow->daemonHopInterval(); |
287 | 287 | ||
288 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 288 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
289 | { | 289 | { |
290 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 290 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | 293 | ||
294 | // configure device | 294 | // configure device |
295 | 295 | ||
296 | ONetwork* net = ONetwork::instance(); | 296 | ONetwork* net = ONetwork::instance(); |
297 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 297 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
298 | 298 | ||
299 | // set monitor mode | 299 | // set monitor mode |
300 | 300 | ||
301 | switch ( cardtype ) | 301 | switch ( cardtype ) |
302 | { | 302 | { |
303 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | 303 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
304 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | 304 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
305 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | 305 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
306 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | 306 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; |
307 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break; | 307 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break; |
308 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 308 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
309 | default: assert( 0 ); // shouldn't reach this | 309 | default: assert( 0 ); // shouldn't reach this |
310 | } | 310 | } |
311 | 311 | ||
312 | // switch device into monitor mode | 312 | // switch device into monitor mode |
313 | if ( cardtype < DEVTYPE_FILE ) | 313 | if ( cardtype < DEVTYPE_FILE ) |
314 | { | 314 | { |
315 | if ( cardtype != DEVTYPE_MANUAL ) | 315 | if ( cardtype != DEVTYPE_MANUAL ) |
316 | iface->setMonitorMode( true ); | 316 | iface->setMonitorMode( true ); |
317 | if ( !iface->monitorMode() ) | 317 | if ( !iface->monitorMode() ) |
318 | { | 318 | { |
319 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); | 319 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); |
320 | return; | 320 | return; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | // open pcap and start sniffing | 324 | // open pcap and start sniffing |
325 | if ( cardtype != DEVTYPE_FILE ) | 325 | if ( cardtype != DEVTYPE_FILE ) |
326 | { | 326 | { |
327 | if ( configwindow->writeCaptureFile->isEnabled() ) | 327 | if ( configwindow->writeCaptureFile->isEnabled() ) |
328 | { | 328 | { |
329 | QString dumpname( configwindow->captureFileName->text() ); | 329 | QString dumpname( configwindow->captureFileName->text() ); |
330 | dumpname.append( '-' ); | 330 | dumpname.append( '-' ); |
331 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 331 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
332 | dumpname.append( ".wellenreiter" ); | 332 | dumpname.append( ".wellenreiter" ); |
333 | pcap->open( interface, dumpname ); | 333 | pcap->open( interface, dumpname ); |
334 | } | 334 | } |
335 | else | 335 | else |
336 | { | 336 | { |
337 | pcap->open( interface ); | 337 | pcap->open( interface ); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | else | 340 | else |
341 | { | 341 | { |
342 | pcap->open( QFile( interface ) ); | 342 | pcap->open( QFile( interface ) ); |
343 | } | 343 | } |
344 | 344 | ||
345 | if ( !pcap->isOpen() ) | 345 | if ( !pcap->isOpen() ) |
346 | { | 346 | { |
347 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 347 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | // set capturer to non-blocking mode | 351 | // set capturer to non-blocking mode |
352 | pcap->setBlocking( false ); | 352 | pcap->setBlocking( false ); |
353 | 353 | ||
354 | // start channel hopper | 354 | // start channel hopper |
355 | if ( cardtype != DEVTYPE_FILE ) | 355 | if ( cardtype != DEVTYPE_FILE ) |
356 | iface->setChannelHopping( 1000 ); //use interval from config window | 356 | iface->setChannelHopping( 1000 ); //use interval from config window |
357 | 357 | ||
358 | if ( cardtype != DEVTYPE_FILE ) | 358 | if ( cardtype != DEVTYPE_FILE ) |
359 | { | 359 | { |
360 | // connect socket notifier and start channel hopper | 360 | // connect socket notifier and start channel hopper |
361 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 361 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
362 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 362 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
363 | } | 363 | } |
364 | else | 364 | else |
365 | { | 365 | { |
366 | // start timer for reading packets | 366 | // start timer for reading packets |
367 | startTimer( 100 ); | 367 | startTimer( 100 ); |
368 | } | 368 | } |
369 | 369 | ||
370 | logwindow->log( "(i) Started Scanning." ); | 370 | logwindow->log( "(i) Started Scanning." ); |
371 | sniffing = true; | 371 | sniffing = true; |
372 | emit( startedSniffing() ); | 372 | emit( startedSniffing() ); |
373 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 373 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
374 | else | 374 | else |
375 | { | 375 | { |
376 | assert( parent() ); | 376 | assert( parent() ); |
377 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II - replaying capture file..." ); | 377 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II - replaying capture file..." ); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | void Wellenreiter::timerEvent( QTimerEvent* ) | 382 | void Wellenreiter::timerEvent( QTimerEvent* ) |
383 | { | 383 | { |
384 | qDebug( "Wellenreiter::timerEvent()" ); | 384 | qDebug( "Wellenreiter::timerEvent()" ); |
385 | OPacket* p = pcap->next(); | 385 | OPacket* p = pcap->next(); |
386 | receivePacket( p ); | 386 | if ( !p ) // no more packets available |
387 | delete p; | 387 | { |
388 | stopClicked(); | ||
389 | } | ||
390 | else | ||
391 | { | ||
392 | receivePacket( p ); | ||
393 | delete p; | ||
394 | } | ||
388 | } | 395 | } |
389 | 396 | ||