Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 178 |
1 files changed, 101 insertions, 77 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 0bfc8e9..3372883 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -35,4 +35,5 @@ using namespace Opie; | |||
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qtoolbutton.h> | ||
37 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
38 | 39 | ||
@@ -53,5 +54,5 @@ using namespace Opie; | |||
53 | #include "hexwindow.h" | 54 | #include "hexwindow.h" |
54 | #include "configwindow.h" | 55 | #include "configwindow.h" |
55 | 56 | #include "statwindow.h" | |
56 | #include "manufacturers.h" | 57 | #include "manufacturers.h" |
57 | 58 | ||
@@ -218,98 +219,121 @@ void Wellenreiter::receivePacket(OPacket* p) | |||
218 | } | 219 | } |
219 | 220 | ||
220 | void Wellenreiter::startStopClicked() | 221 | |
222 | void Wellenreiter::stopClicked() | ||
221 | { | 223 | { |
222 | if ( sniffing ) | 224 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
225 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
226 | iface->setChannelHopping(); // stop hopping channels | ||
227 | pcap->close(); | ||
228 | sniffing = false; | ||
229 | #ifdef QWS | ||
230 | oApp->setTitle(); | ||
231 | #else | ||
232 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | ||
233 | #endif | ||
234 | |||
235 | // get interface name from config window | ||
236 | const QString& interface = configwindow->interfaceName->currentText(); | ||
237 | ONetwork* net = ONetwork::instance(); | ||
238 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | ||
239 | |||
240 | // switch off monitor mode | ||
241 | iface->setMonitorMode( false ); | ||
242 | // switch off promisc flag | ||
243 | iface->setPromiscuousMode( false ); | ||
244 | |||
245 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | ||
246 | logwindow->log( "(i) Stopped Scanning." ); | ||
247 | assert( parent() ); | ||
248 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | ||
249 | |||
250 | // message the user | ||
251 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | ||
252 | |||
253 | sniffing = false; | ||
254 | emit( stoppedSniffing() ); | ||
255 | |||
256 | // print out statistics | ||
257 | statwindow->log( "-----------------------------------------" ); | ||
258 | statwindow->log( "- Wellenreiter II Capturing Statistic -" ); | ||
259 | statwindow->log( "-----------------------------------------" ); | ||
260 | statwindow->log( "Packet Type | Receive Count" ); | ||
261 | |||
262 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | ||
223 | { | 263 | { |
224 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 264 | QString left; |
225 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 265 | left.sprintf( "%s", (const char*) it.key() ); |
226 | iface->setChannelHopping(); // stop hopping channels | 266 | left = left.leftJustify( 20 ); |
227 | pcap->close(); | 267 | left.append( '|' ); |
228 | sniffing = false; | 268 | QString right; |
229 | #ifdef QWS | 269 | right.sprintf( "%d", it.data() ); |
230 | oApp->setTitle(); | 270 | right = right.rightJustify( 7 ); |
231 | #else | 271 | statwindow->log( left + right ); |
232 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | ||
233 | #endif | ||
234 | |||
235 | // get interface name from config window | ||
236 | const QString& interface = configwindow->interfaceName->currentText(); | ||
237 | ONetwork* net = ONetwork::instance(); | ||
238 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | ||
239 | |||
240 | // switch off monitor mode | ||
241 | iface->setMonitorMode( false ); | ||
242 | // switch off promisc flag | ||
243 | iface->setPromiscuousMode( false ); | ||
244 | |||
245 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | ||
246 | logwindow->log( "(i) Stopped Scanning." ); | ||
247 | assert( parent() ); | ||
248 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | ||
249 | |||
250 | // message the user | ||
251 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | ||
252 | } | 272 | } |
253 | 273 | ||
254 | else | 274 | } |
255 | { | ||
256 | // get configuration from config window | ||
257 | 275 | ||
258 | const QString& interface = configwindow->interfaceName->currentText(); | ||
259 | const int cardtype = configwindow->daemonDeviceType(); | ||
260 | const int interval = configwindow->daemonHopInterval(); | ||
261 | 276 | ||
262 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 277 | void Wellenreiter::startClicked() |
263 | { | 278 | { |
264 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 279 | // get configuration from config window |
265 | return; | ||
266 | } | ||
267 | 280 | ||
268 | // configure device | 281 | const QString& interface = configwindow->interfaceName->currentText(); |
282 | const int cardtype = configwindow->daemonDeviceType(); | ||
283 | const int interval = configwindow->daemonHopInterval(); | ||
269 | 284 | ||
270 | ONetwork* net = ONetwork::instance(); | 285 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
271 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 286 | { |
287 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | ||
288 | return; | ||
289 | } | ||
272 | 290 | ||
273 | // set monitor mode | 291 | // configure device |
274 | 292 | ||
275 | switch ( cardtype ) | 293 | ONetwork* net = ONetwork::instance(); |
276 | { | 294 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
277 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | ||
278 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | ||
279 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | ||
280 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | ||
281 | default: assert( 0 ); // shouldn't happen | ||
282 | } | ||
283 | 295 | ||
284 | iface->setMonitorMode( true ); | 296 | // set monitor mode |
285 | 297 | ||
286 | if ( !iface->monitorMode() ) | 298 | switch ( cardtype ) |
287 | { | 299 | { |
288 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); | 300 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
289 | return; | 301 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
290 | } | 302 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
303 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | ||
304 | default: | ||
305 | QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); | ||
306 | } | ||
291 | 307 | ||
292 | // open pcap and start sniffing | 308 | if ( cardtype > 0 && cardtype < 5 ) |
293 | pcap->open( interface ); | 309 | iface->setMonitorMode( true ); |
294 | 310 | ||
295 | if ( !pcap->isOpen() ) | 311 | if ( !iface->monitorMode() ) |
296 | { | 312 | { |
297 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 313 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); |
298 | return; | 314 | return; |
299 | } | 315 | } |
300 | 316 | ||
301 | // set capturer to non-blocking mode | 317 | // open pcap and start sniffing |
302 | pcap->setBlocking( false ); | 318 | pcap->open( interface ); |
303 | 319 | ||
304 | // start channel hopper | 320 | if ( !pcap->isOpen() ) |
305 | iface->setChannelHopping( 1000 ); //use interval from config window | 321 | { |
322 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | ||
323 | return; | ||
324 | } | ||
306 | 325 | ||
307 | // connect | 326 | // set capturer to non-blocking mode |
308 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 327 | pcap->setBlocking( false ); |
309 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
310 | 328 | ||
311 | logwindow->log( "(i) Started Scanning." ); | 329 | // start channel hopper |
312 | sniffing = true; | 330 | iface->setChannelHopping( 1000 ); //use interval from config window |
313 | 331 | ||
314 | } | 332 | // connect |
333 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | ||
334 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | ||
335 | |||
336 | logwindow->log( "(i) Started Scanning." ); | ||
337 | sniffing = true; | ||
338 | emit( startedSniffing() ); | ||
315 | } | 339 | } |