-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 | |||
@@ -258,132 +258,139 @@ void Wellenreiter::stopClicked() | |||
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 | ||