author | mickeyl <mickeyl> | 2003-10-28 19:13:34 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-28 19:13:34 (UTC) |
commit | d5d9b307e950d9038215e4d63e64bc9cd5d85352 (patch) (unidiff) | |
tree | ccef170352625a48c9c7ff0e7ff119f8d23e2331 | |
parent | 5acd7ce51829c317f6218ff059d0d2f63cdb0871 (diff) | |
download | opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.zip opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.tar.gz opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.tar.bz2 |
catch up with API changes in libopienet
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp2.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 7ce096f..e7d6ff5 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -290,189 +290,189 @@ void WLANImp::writeOpts() { | |||
290 | interfaces->removeInterfaceOption(QString("wireless_key")); | 290 | interfaces->removeInterfaceOption(QString("wireless_key")); |
291 | } | 291 | } |
292 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 292 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
293 | 293 | ||
294 | if(!interfaceSetup->saveChanges()) | 294 | if(!interfaceSetup->saveChanges()) |
295 | return; | 295 | return; |
296 | 296 | ||
297 | QDialog::accept(); | 297 | QDialog::accept(); |
298 | } | 298 | } |
299 | 299 | ||
300 | /* | 300 | /* |
301 | * Scan for possible wireless networks around... | 301 | * Scan for possible wireless networks around... |
302 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> | 302 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> |
303 | */ | 303 | */ |
304 | 304 | ||
305 | void WLANImp::rescanNeighbourhood() | 305 | void WLANImp::rescanNeighbourhood() |
306 | { | 306 | { |
307 | QString name = interface->getInterfaceName(); | 307 | QString name = interface->getInterfaceName(); |
308 | qDebug( "rescanNeighbourhood via '%s'", (const char*) name ); | 308 | qDebug( "rescanNeighbourhood via '%s'", (const char*) name ); |
309 | 309 | ||
310 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); | 310 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); |
311 | assert( wiface ); | 311 | assert( wiface ); |
312 | 312 | ||
313 | // try to guess device type | 313 | // try to guess device type |
314 | QString devicetype; | 314 | QString devicetype; |
315 | QFile m( "/proc/modules" ); | 315 | QFile m( "/proc/modules" ); |
316 | if ( m.open( IO_ReadOnly ) ) | 316 | if ( m.open( IO_ReadOnly ) ) |
317 | { | 317 | { |
318 | QString line; | 318 | QString line; |
319 | QTextStream modules( &m ); | 319 | QTextStream modules( &m ); |
320 | while( !modules.atEnd() && !devicetype ) | 320 | while( !modules.atEnd() && !devicetype ) |
321 | { | 321 | { |
322 | modules >> line; | 322 | modules >> line; |
323 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; | 323 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; |
324 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; | 324 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; |
325 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ | 325 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ |
326 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; | 326 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | if ( devicetype.isEmpty() ) | 329 | if ( devicetype.isEmpty() ) |
330 | { | 330 | { |
331 | qWarning( "rescanNeighbourhood(): couldn't guess device type :(" ); | 331 | qWarning( "rescanNeighbourhood(): couldn't guess device type :(" ); |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | else | 334 | else |
335 | { | 335 | { |
336 | qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype ); | 336 | qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype ); |
337 | } | 337 | } |
338 | 338 | ||
339 | // configure interface to receive 802.11 management frames | 339 | // configure interface to receive 802.11 management frames |
340 | 340 | ||
341 | wiface->setUp( true ); | 341 | wiface->setUp( true ); |
342 | wiface->setPromiscuousMode( true ); | 342 | wiface->setPromiscuousMode( true ); |
343 | 343 | ||
344 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); | 344 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); |
345 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); | 345 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); |
346 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); | 346 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); |
347 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); | 347 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); |
348 | else | 348 | else |
349 | { | 349 | { |
350 | qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" ); | 350 | qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" ); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | 353 | ||
354 | wiface->setMonitorMode( true ); | 354 | wiface->setMode( "monitor" ); |
355 | if ( !wiface->monitorMode() ) | 355 | if ( wiface->mode() != "monitor" ) |
356 | { | 356 | { |
357 | qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) ); | 357 | qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) ); |
358 | return; | 358 | return; |
359 | } | 359 | } |
360 | 360 | ||
361 | // open a packet capturer | 361 | // open a packet capturer |
362 | OPacketCapturer* cap = new OPacketCapturer(); | 362 | OPacketCapturer* cap = new OPacketCapturer(); |
363 | cap->open( name ); | 363 | cap->open( name ); |
364 | if ( !cap->isOpen() ) | 364 | if ( !cap->isOpen() ) |
365 | { | 365 | { |
366 | qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) ); | 366 | qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) ); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | 369 | ||
370 | // display splash screen | 370 | // display splash screen |
371 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); | 371 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); |
372 | splash->setLineWidth( 2 ); | 372 | splash->setLineWidth( 2 ); |
373 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); | 373 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); |
374 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); | 374 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); |
375 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); | 375 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); |
376 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); | 376 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); |
377 | vbox->addWidget( lab ); | 377 | vbox->addWidget( lab ); |
378 | vbox->addWidget( pb ); | 378 | vbox->addWidget( pb ); |
379 | pb->setCenterIndicator( true ); | 379 | pb->setCenterIndicator( true ); |
380 | pb->setFixedHeight( pb->sizeHint().height() ); | 380 | pb->setFixedHeight( pb->sizeHint().height() ); |
381 | QWidget* widgetDesktop = qApp->desktop(); | 381 | QWidget* widgetDesktop = qApp->desktop(); |
382 | int dw = widgetDesktop->width(); | 382 | int dw = widgetDesktop->width(); |
383 | int dh = widgetDesktop->height(); | 383 | int dh = widgetDesktop->height(); |
384 | int pw = vbox->sizeHint().width(); | 384 | int pw = vbox->sizeHint().width(); |
385 | int ph = vbox->sizeHint().height(); | 385 | int ph = vbox->sizeHint().height(); |
386 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); | 386 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); |
387 | splash->show(); | 387 | splash->show(); |
388 | splash->raise(); | 388 | splash->raise(); |
389 | qApp->processEvents(); | 389 | qApp->processEvents(); |
390 | 390 | ||
391 | // set capturer to non-blocking mode | 391 | // set capturer to non-blocking mode |
392 | cap->setBlocking( false ); | 392 | cap->setBlocking( false ); |
393 | 393 | ||
394 | for ( int i = 1; i <= wiface->channels(); ++i ) | 394 | for ( int i = 1; i <= wiface->channels(); ++i ) |
395 | { | 395 | { |
396 | wiface->setChannel( i ); | 396 | wiface->setChannel( i ); |
397 | pb->setProgress( i ); | 397 | pb->setProgress( i ); |
398 | qApp->processEvents(); | 398 | qApp->processEvents(); |
399 | qDebug( "rescanNeighbourhood(): listening on channel %d...", i ); | 399 | qDebug( "rescanNeighbourhood(): listening on channel %d...", i ); |
400 | OPacket* p = cap->next( 1000 ); | 400 | OPacket* p = cap->next( 1000 ); |
401 | if ( !p ) | 401 | if ( !p ) |
402 | { | 402 | { |
403 | qDebug( "rescanNeighbourhood(): nothing received on channel %d", i ); | 403 | qDebug( "rescanNeighbourhood(): nothing received on channel %d", i ); |
404 | } | 404 | } |
405 | else | 405 | else |
406 | { | 406 | { |
407 | qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i ); | 407 | qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i ); |
408 | handlePacket( p ); | 408 | handlePacket( p ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | cap->close(); | 412 | cap->close(); |
413 | wiface->setMonitorMode( false ); | 413 | wiface->setMode( "managed" ); // TODO: use previous mode |
414 | wiface->setPromiscuousMode( true ); | 414 | wiface->setPromiscuousMode( false ); |
415 | 415 | ||
416 | splash->hide(); | 416 | splash->hide(); |
417 | delete splash; | 417 | delete splash; |
418 | 418 | ||
419 | } | 419 | } |
420 | 420 | ||
421 | void WLANImp::handlePacket( OPacket* p ) | 421 | void WLANImp::handlePacket( OPacket* p ) |
422 | { | 422 | { |
423 | 423 | ||
424 | // check if we received a beacon frame | 424 | // check if we received a beacon frame |
425 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 425 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
426 | if ( beacon && beacon->managementType() == "Beacon" ) | 426 | if ( beacon && beacon->managementType() == "Beacon" ) |
427 | { | 427 | { |
428 | 428 | ||
429 | QString type; | 429 | QString type; |
430 | if ( beacon->canIBSS() ) | 430 | if ( beacon->canIBSS() ) |
431 | { | 431 | { |
432 | type = "adhoc"; | 432 | type = "adhoc"; |
433 | } | 433 | } |
434 | else if ( beacon->canESS() ) | 434 | else if ( beacon->canESS() ) |
435 | { | 435 | { |
436 | type = "managed"; | 436 | type = "managed"; |
437 | } | 437 | } |
438 | else | 438 | else |
439 | { | 439 | { |
440 | qWarning( "handlePacket(): invalid frame [possibly noise] detected!" ); | 440 | qWarning( "handlePacket(): invalid frame [possibly noise] detected!" ); |
441 | return; | 441 | return; |
442 | } | 442 | } |
443 | 443 | ||
444 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 444 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
445 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 445 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
446 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 446 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
447 | int channel = ds ? ds->channel() : -1; | 447 | int channel = ds ? ds->channel() : -1; |
448 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 448 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
449 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); | 449 | displayFoundNetwork( type, channel, essid, header->macAddress2() ); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) | 454 | void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) |
455 | { | 455 | { |
456 | 456 | ||
457 | qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel, | 457 | qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel, |
458 | (const char*) ssid, | 458 | (const char*) ssid, |
459 | (const char*) mac.toString() ); | 459 | (const char*) mac.toString() ); |
460 | 460 | ||
461 | QListViewItemIterator it( netView ); | 461 | QListViewItemIterator it( netView ); |
462 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; | 462 | while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; |
463 | if ( !it.current() ) // ssid didn't show up yet | 463 | if ( !it.current() ) // ssid didn't show up yet |
464 | { | 464 | { |
465 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); | 465 | QListViewItem* item = new QListViewItem( netView, mode.left( 1 ).upper(), ssid, QString::number( channel ), mac.toString() ); |
466 | QString name; | 466 | QString name; |
467 | name.sprintf( "networksettings/%s", (const char*) mode ); | 467 | name.sprintf( "networksettings/%s", (const char*) mode ); |
468 | item->setPixmap( col_mode, Resource::loadPixmap( name ) ); | 468 | item->setPixmap( col_mode, Resource::loadPixmap( name ) ); |
469 | qApp->processEvents(); | 469 | qApp->processEvents(); |
470 | } | 470 | } |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | void WLANImp::selectNetwork( QListViewItem* item ) | 475 | void WLANImp::selectNetwork( QListViewItem* item ) |
476 | { | 476 | { |
477 | bool ok; | 477 | bool ok; |
478 | if ( item ) | 478 | if ( item ) |